Exemple #1
0
/****************************************************************************
*NAME 
*   AvrcpBrowseGetFolderItemsResponse
*
*DESCRIPTION
*   This function is used to send response for  GetFolderItems command to CT.
*   This will be called in response to a AVRCP_BROWSE_GET_FOLDER_ITEMS_IND
*   message.
*
*PARAMETRS
*   avrcp              - Task
*   avrcp_response_type- response. avrcp_response_browsing_success on Success.
*   uint16             - UID Counter. 0 for non database aware players
*   uint16             - number of items returned
*   uint16             - size of the item list in bytes
*   Source             - item list
*****************************************************************************/
void AvrcpBrowseGetFolderItemsResponse( AVRCP*              avrcp,         
                                        avrcp_response_type response,     
                                        uint16              uid_counter, 
                                        uint16              num_items,  
                                        uint16              item_list_size,
                                        Source              item_list)
{
    AVBP *avbp = (AVBP*)avrcp->avbp_task;

    if((SourceBoundary(item_list) < item_list_size) ||
       (!num_items && item_list_size) || 
       (item_list_size > (avbp->avbp_mtu - AVBP_MAX_FIXED_PDU_SIZE)))
    {
        AVRCP_DEBUG(("Wrong parameters\n"));
        if(item_list)
        {
            SourceEmpty(item_list);
        }
        return; 
    }
     
    if((isAvbpCheckConnected(avbp)) && 
      (avbp->blocking_cmd == AVBP_GET_FOLDER_ITEMS_PDU_ID))
    {
        MAKE_AVRCP_MESSAGE(AVRCP_INTERNAL_GET_FOLDER_ITEMS_RES);
        message->response = response;
        message->num_items = num_items;
        message->item_list_size = item_list_size;
        message->item_list = item_list;
        if(isAvrcpDatabaseEnabled(avrcpGetDeviceTask()))
        {
           message->uid_counter = uid_counter;
        }
        else
        {
           message->uid_counter = 0;
        }

        /* Queue the Response */
        MessageSend(&avbp->task,
                    AVRCP_INTERNAL_GET_FOLDER_ITEMS_RES,
                    message);
    }
    else
    {
        AVRCP_INFO(("Wrong State. Ignoring the response\n"));
        if(item_list)
        {
            SourceEmpty(item_list);
        }
    }
}
Exemple #2
0
/****************************************************************************
*NAME 
*   AvrcpBrowseSearchRequest
*
*DESCRIPTION
*   This function is used to send Search Command to the TG.
*
*PARAMETRS
*   avrcp                  - Task
*   char_set               - Reserved. Always avrcp_char_set_utf_8 
*   str_length             - String length
*   string                 - Search String.    
*
*RETURN
*   AVRCP_BROWSE_SEARCH_CFM
*****************************************************************************/
void AvrcpBrowseSearchRequest( AVRCP*              avrcp,
                        avrcp_char_set      char_set, 
                        uint16              str_length,
                        Source              string)
{
    AVBP *avbp = (AVBP*)avrcp->avbp_task;

    if((!string) || (!str_length))
    {
        avrcpSearchCfm(avbp, avrcp_rejected_invalid_param, NULL, 0); 
        return;
    }
    
    if(SourceBoundary(string) < str_length)
    {
        AVRCP_INFO(("Invalid Content \n"));
        avrcpSearchCfm(avbp,avrcp_rejected_invalid_content, NULL, 0); 
        SourceEmpty(string);
        return;
    }

    if(char_set != avrcp_char_set_utf_8)
    {
        avrcpSearchCfm(avbp, avrcp_rejected_invalid_param, NULL, 0); 
        SourceEmpty(string);
        return;
    }

    if(isAvbpCheckConnected(avbp))
    {
        MAKE_AVRCP_MESSAGE(AVRCP_INTERNAL_SEARCH_REQ);
        message->char_set = char_set;
        message->str_length = str_length;
        message->string = string;

       /* Queue the Command if there is any Outstanding command in progress */
       MessageSendConditionally(&avbp->task,
                                  AVRCP_INTERNAL_SEARCH_REQ,
                                  message,
                                  &avbp->blocking_cmd);

    }
    else
    {
        AVRCP_INFO(("Browsing channel not connected\n"));
        SourceEmpty(string);
        avrcpSearchCfm(avbp, avrcp_browsing_channel_not_connected,
                        NULL, 0); 
    }
}
/****************************************************************************
 *NAME    
 *    abortContinuation    
 *
 *DESCRIPTION
 *   Abort the stored Continuation response packet. 
 *
 *PARAMETERS
 * avrcp        -       AVRCP Entity
 *****************************************************************************/
void abortContinuation(AVRCP *avrcp)
{
    /* Abort sending continuing packets back to CT. */
    if (avrcp->continuation_data)
        SourceEmpty(avrcp->continuation_data);

    MessageCancelAll(&avrcp->task, AVRCP_INTERNAL_NEXT_CONTINUATION_PACKET);
    avrcp->continuation_pdu = 0;
}
Exemple #4
0
void AvrcpBrowseGetItemAttributesResponse(AVRCP*              avrcp,
                                          avrcp_response_type response,
                                          uint8               num_attributes,
                                          uint16              size_attr_list,
                                          Source              attr_value_list)
{
    AVBP *avbp = (AVBP*)avrcp->avbp_task;

    if((SourceBoundary(attr_value_list) < size_attr_list) ||
       (!num_attributes && size_attr_list) ||
       (size_attr_list > (avbp->avbp_mtu - AVBP_MAX_FIXED_PDU_SIZE)))
    {
        AVRCP_DEBUG(("Invalid parameters\n"));
        if(attr_value_list)
        {
            SourceEmpty(attr_value_list);
        }
        return;
    }

    /* validate avbp and send the message if it is connected */
    if((isAvbpCheckConnected(avbp)) &&
       (avbp->blocking_cmd == AVBP_GET_ITEM_ATTRIBUTES_PDU_ID))
    {
        MAKE_AVRCP_MESSAGE(AVRCP_INTERNAL_GET_ITEM_ATTRIBUTES_RES);
        message->response = response;
        message->num_attributes = num_attributes;
        message->size_attr_list = size_attr_list;
        message->attr_value_list = attr_value_list;

        /* Queue the Response */
        MessageSend(&avbp->task,
                    AVRCP_INTERNAL_GET_ITEM_ATTRIBUTES_RES,
                    message);
    }
    else
    {
        AVRCP_INFO(("Wrong State.Ignoring the response\n"));
        if(attr_value_list)
        { 
            SourceEmpty(attr_value_list);
        }
    }
}
Exemple #5
0
/****************************************************************************
*NAME 
*   AvrcpBrowseSetPlayerResponse
*
*DESCRIPTION
*   This function is used to send response for SetBrowsedPlayer command to CT.
*   This will be called in response to a AVRCP_BROWSE_SET_PLAYER_IND message.
*
*PARAMETRS
*   avrcp              - Task
*   avrcp_response_type- response. avrcp_response_browsing_success on Success.
*   uint16             - uid counter 
*   uint32             - number of items
*   avrcp_char_type    - char_type
*   uint8              - folder_depth
*   uint16             - size_folder_path
*   Source             - folder_path
*****************************************************************************/
void AvrcpBrowseSetPlayerResponse(AVRCP*                avrcp, 
                                  avrcp_response_type   response,
                                  uint16                uid_counter,
                                  uint32                num_items, 
                                  avrcp_char_set        char_type, 
                                  uint8                 folder_depth, 
                                  uint16                size_folder_path,
                                  Source                folder_path)
{
    AVBP *avbp = (AVBP*)avrcp->avbp_task;

    /* validate avbp and send the message if it is connected */
    if(isAvbpCheckConnected(avbp) && 
       (avbp->blocking_cmd == AVBP_SET_BROWSED_PLAYER_PDU_ID))
    {
        MAKE_AVRCP_MESSAGE(AVRCP_INTERNAL_BROWSE_SET_PLAYER_RES);
        message->response = response;

        if(isAvrcpDatabaseEnabled(avrcpGetDeviceTask()))
        {
            message->uid_counter = uid_counter;
        }
        else
        {
            message->uid_counter = 0;
        }

        message->num_items = num_items;
        message->char_type = char_type;
        message->folder_depth = folder_depth;
        message->size_folder_path = size_folder_path;
        message->folder_path = folder_path;
 
        /* Queue the Response */
        MessageSend(&avbp->task,
                   AVRCP_INTERNAL_BROWSE_SET_PLAYER_RES,
                   message);
    }
    else
    {
        AVRCP_INFO(("Ignoring the response\n"));
        if(folder_path)
        {
            SourceEmpty(folder_path);
        }
    }


}
/*lint -e818 -e830 */
void AvrcpPassthrough(AVRCP *avrcp, avc_subunit_type subunit_type, avc_subunit_id subunit_id, bool state, avc_operation_id opid, uint16 operation_data_length, Source operation_data)
{
    
#ifdef AVRCP_DEBUG_LIB	
	if (subunit_type > 0x1F)
	{
		AVRCP_DEBUG(("Out of range subunit type  0x%x\n", subunit_type));
	}
    if (subunit_id > 0x07)
	{
		AVRCP_DEBUG(("Out of range subunit id  0x%x\n", subunit_id));
	}
    if (opid > 0x7F)
	{
		AVRCP_DEBUG(("Out of range op id  0x%x\n", opid));
	}
#endif
    
	if (avrcp->block_received_data || (avrcp->pending && (avrcp->pending != avrcp_next_group) && (avrcp->pending != avrcp_previous_group)))
		avrcpSendPassthroughCfmToClient(avrcp, avrcp_busy);
	else if (!avrcp->sink)
		/* Immediately reject the request if we have not been passed a valid sink */
		avrcpSendPassthroughCfmToClient(avrcp, avrcp_invalid_sink);
	else
	{
		MAKE_AVRCP_MESSAGE(AVRCP_INTERNAL_PASSTHROUGH_REQ);
		message->subunit_type = subunit_type;
		message->subunit_id = subunit_id;
		message->state = state;
		message->opid = opid;

		if (opid == opid_vendor_unique)
		{
			message->operation_data = operation_data;
			message->operation_data_length = operation_data_length;
		}
		else
		{
            if (SourceSize(operation_data))
                SourceEmpty(operation_data);
			message->operation_data = 0;
			message->operation_data_length = 0;
		}

		MessageSend(&avrcp->task, AVRCP_INTERNAL_PASSTHROUGH_REQ, message);
	}
}
/****************************************************************************
*NAME    
*    AvrcpGetAppValueResponse    
*
*DESCRIPTION
*  API function to send GetCurrentPlayerApplicationSettingValue response to CT.
*  All parameters are described in the header file.
******************************************************************************/
void AvrcpGetAppValueResponse( AVRCP *avrcp, 
                               avrcp_response_type response, 
                               uint16 size_values, 
                               Source values)
{
    /* Send the response only if the command arrived to start with. */
    if (avrcp->block_received_data == avrcp_get_app_values)
    {
        sendGetValuesResponse(avrcp, response, size_values, values);
    }
    else
    {
        SourceEmpty( values );
        AVRCP_INFO(("AvrcpGetCurrentAppSettingValueResponse:"
               "CT not waiting for response\n"));
    }
}
/****************************************************************************
* NAME    
* AvrcpListAppAttributeResponse    
*
* DESCRIPTION
* API to send ListPlayerApplicationSettingAttributes response to the CT. 
* All parameters are described in the header file.
*******************************************************************************/
void AvrcpListAppAttributeResponse( AVRCP *avrcp, 
                                    avrcp_response_type response, 
                                    uint16 size_attributes, 
                                    Source attributes )
{
    /* Send the response only if the command arrived to start with. */
    if (avrcp->block_received_data == avrcp_list_app_attributes)
    {
        sendListAttrResponse(avrcp, response, size_attributes, attributes);
    }
    else
    {
        SourceEmpty( attributes );
        AVRCP_INFO(("AvrcpListAppSettingAttributeResponse:"
              "CT not waiting for response\n"));
    }
}
Exemple #9
0
fs_ret_t FileSource::GetBuffer( size_t N = 1024 )
{
	while ( !SourceEmpty() && accum_len < N )
	{
		size_t N_new = N - accum_len;

		// Check to see if the buffer is large enough, if not increase size
		unsigned long worst_case_size = accum_len + N;
		if ( accum_total_len < worst_case_size )
			IncreaseBufferSize( worst_case_size - accum_total_len );


		size_t successfully_read_bytes = sizeof(unsigned char) * fread ( (void*) (accum + accum_len), sizeof(unsigned char), N_new, file_p );

		if ( successfully_read_bytes == 0 )
		{
			IterateFileList();
			continue;
		}

		accum_len += successfully_read_bytes;
            
		current_file_bytes_read += successfully_read_bytes;
		bytes_read += successfully_read_bytes;
	}
            
	time_t current_time = time( NULL );
	if ( difftime( current_time, previous_time ) > 3.0 )
	{
		char BPS_str[100];
		GetHumanReadableDataSize( BPS_str, double(bytes_read) / difftime( current_time, previous_time ) );
		printf("Throughput: %s/s; Progress: %.2f%%\n", BPS_str, ((double) current_file_bytes_read) / ((double) current_file_size) * 100.0 );

		bytes_read = 0;
		previous_time = current_time;
	}

	fs_ret_t ret_s;
	ret_s.accum = accum;
	ret_s.accum_len = accum_len;
	ret_s.accum_total_len = accum_total_len;
	return ret_s;
}
void AvrcpGetElementAttributesResponse(AVRCP               *avrcp, 
                                       avrcp_response_type response, 
                                       uint16              number_of_attributes,
                                       uint16              size_attributes, 
                                       Source              attributes)
{
    /* Only allow a response to be sent if the corresponding command arrived. */
    if (avrcp->block_received_data == avrcp_get_element_attributes)
    {
        sendGetElementsResponse(avrcp, response, 
                                number_of_attributes, 
                                size_attributes, attributes);    
    }
    else
    {
        SourceEmpty( attributes );
        AVRCP_INFO(("AvrcpGetElementAttributesResponse:"
                "CT not waiting for response\n"));
    }
}
Exemple #11
0
/****************************************************************************
*NAME 
*   AvrcpBrowseGetFolderItemsRequest
*
*DESCRIPTION
*   This function is used to send GetFolderItems Command to the TG.
*
*PARAMETRS
*   avrcp                  - Task
*   avrcp_browse_scope     - Scope for media navigation.
*   start                  - Start index of the item in the folder.
*   end                    - End index of the item in the folder
*   uint8                  - Number of attributes requested. 0 for all and 
*                            0xFF for No attributes.
*   Source                 - Size of source should be number of attributes * 4.
*
*RETURN
*   AVRCP_BROWSE_GET_FOLDER_ITEMS_CFM
*****************************************************************************/
void AvrcpBrowseGetFolderItemsRequest( AVRCP*              avrcp,   
                                avrcp_browse_scope  scope,   
                                uint32              start,   
                                uint32              end,      
                                uint8               num_attr, 
                                Source              attr_list)
{
    AVBP *avbp = (AVBP*)avrcp->avbp_task;
    uint16 size_attr_list = num_attr * 4;

    if(num_attr == 0 || num_attr == 0xFF)
    {
        if(attr_list)
        {
            SourceEmpty(attr_list);
        }
        size_attr_list =  0;
        attr_list = 0;
    }
    else
    {
        /* Validate the length */
        if(SourceBoundary(attr_list) < size_attr_list)
        {
            AVRCP_INFO(("Invalid length of attributes \n"));
            avrcpGetFolderItemsCfm(avbp,avrcp_rejected_invalid_content,
                                     NULL, 0); 
            if(attr_list)
            {
                SourceEmpty(attr_list);
            }
            return;
        }
    }

    /* validate the start and end index */
    if(start > end)
    {
        AVRCP_INFO(("End index > Start\n"));
        avrcpGetFolderItemsCfm(avbp, avrcp_rejected_out_of_bound, NULL, 0);
        if(attr_list)
        {
            SourceEmpty(attr_list);
        }
        return; 
    }

    if(isAvbpCheckConnected(avbp))
    {
        MAKE_AVRCP_MESSAGE(AVRCP_INTERNAL_GET_FOLDER_ITEMS_REQ);
        message->scope = scope;
        message->start = start;
        message->end = end;
        message->num_attr = num_attr;
        message->attr_list_size = size_attr_list;
        message->attr_list = attr_list;
        

        /* Queue the Command if there is any Outstanding command in progress */
        MessageSendConditionally(&avbp->task,
                                  AVRCP_INTERNAL_GET_FOLDER_ITEMS_REQ,
                                  message,
                                  &avbp->blocking_cmd);

    }
    else
    {
        AVRCP_INFO(("Browsing channel not connected\n"));
        avrcpGetFolderItemsCfm(avbp, avrcp_browsing_channel_not_connected,
                                 NULL, 0); 
        if(attr_list)
        {
            SourceEmpty(attr_list);
        }
    }
}
Exemple #12
0
/****************************************************************************
*NAME 
*   AvrcpBrowseGetItemAttributesRequest
*
*DESCRIPTION
*   This function is used to send GetItemAttributes Command to the TG.
*
*PARAMETRS
*   avrcp                  - Task
*   avrcp_browse_scope     - Scope in which the UID of the media element 
*                            item or folder item is valid.
*   avrcp_browse_uid       - The UID of the  media element item or folder item
*   uint16                 - UID Counter
*   uint8                  - Number of attributes requested. 0 for all and 
*                            0xFF for No attributes.
*   Source                 - Size of source should be number of attributes * 4.
*
*RETURN
*   AVRCP_BROWSE_GET_ITEM_ATTRIBUTES_CFM
*****************************************************************************/
void AvrcpBrowseGetItemAttributesRequest(  AVRCP*               avrcp,
                                    avrcp_browse_scope   scope,  
                                    avrcp_browse_uid     uid,   
                                    uint16               uid_counter, 
                                    uint8                num_attr, 
                                    Source               attr_list)
{
    AVBP *avbp = (AVBP*)avrcp->avbp_task;
    uint16 size_attr_list = num_attr * 4;

    if(num_attr == 0 || num_attr == 0xFF)
    {
        if(attr_list)
        {
            SourceEmpty(attr_list);
        }
        size_attr_list =  0;
        attr_list = 0;
    }
    else
    {
        /* Validate the length */
        if(SourceBoundary(attr_list) < size_attr_list)
        {
            AVRCP_INFO(("Invalid length of attributes \n"));
            avrcpGetItemAttributesCfm(avbp,avrcp_rejected_invalid_content,
                                     NULL, 0); 
            if(attr_list)
            {
                SourceEmpty(attr_list);
            }
            return;
        }
    }

    /* validate avbp and send the message if it is connected */
    if(isAvbpCheckConnected(avbp))
    {
        MAKE_AVRCP_MESSAGE(AVRCP_INTERNAL_GET_ITEM_ATTRIBUTES_REQ);
        message->scope = scope;
        message->uid = uid;
        message->uid_counter = uid_counter;
        message->num_attr = num_attr;
        message->attr_list_size = size_attr_list;
        message->attr_list = attr_list;
        

        /* Queue the Command if there is any Outstanding command in progress */
        MessageSendConditionally(&avbp->task,
                                  AVRCP_INTERNAL_GET_ITEM_ATTRIBUTES_REQ,
                                  message,
                                  &avbp->blocking_cmd);

    }
    else
    {
        AVRCP_INFO(("Browsing channel not connected\n"));
        avrcpGetItemAttributesCfm(avbp, avrcp_browsing_channel_not_connected,
                                 NULL, 0); 
        if(attr_list)
        {
            SourceEmpty(attr_list);
        }
    }
}