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
        AVRCP_INFO(("AvrcpGetElementAttributesResponse:"
                "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"));
    }
}
void AvrcpGetPlayStatusResponse(AVRCP               *avrcp, 
                                avrcp_response_type response, 
                                uint32              song_length, 
                                uint32              song_elapsed, 
                                avrcp_play_status   play_status)
{
    /* Only send a response if the command was received. */
    if (avrcp->block_received_data == avrcp_get_play_status)
    {
        sendPlayStatusResponse(avrcp, response, song_length,
                               song_elapsed, play_status);
    }
    else
    {
        AVRCP_INFO(("AvrcpGetPlayStatusResponse: CT not waiting for response\n"));
    }
}
void AvrcpGetAppSettingAttributeTextResponse(AVRCP *avrcp, 
                                        avrcp_response_type response, 
                                        uint16 number_of_attributes, 
                                        uint16 size_attributes, 
                                        Source attributes)
{
    /* Send the response only if the command arrived to start with. */
    if (avrcp->block_received_data == avrcp_get_app_attribute_text)
    {
        sendGetAttributeTextResponse(avrcp, response, 
                                    number_of_attributes, size_attributes,
                                    attributes);
    }
    else
        AVRCP_INFO(("AvrcpGetAppSettingAttributeTextResponse:"
                " CT not waiting for response\n"));
}
void AvrcpEventTrackReachedStartResponse(AVRCP               *avrcp, 
                                         avrcp_response_type response)
{
    /* Only send a response if this event was registered by the CT. */
    if (avrcp->registered_events & (1<<EVENT_TRACK_START))
    {
        MAKE_AVRCP_MESSAGE(AVRCP_INTERNAL_EVENT_TRACK_REACHED_START_RES);
        message->response = response;
        MessageSend(&avrcp->task, 
                    AVRCP_INTERNAL_EVENT_TRACK_REACHED_START_RES, message);
        if (response == avctp_response_changed)
            clearRegisterNotification(avrcp, EVENT_TRACK_START);
    }
    else
    {
        AVRCP_INFO(("AvrcpEventTrackReachedStartResponse: Event not registered\n"));
    }
}
Exemplo n.º 6
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);
        }
    }
}
/****************************************************************************
*NAME    
*    AvrcpGetAppValueTextResponse    
*
*DESCRIPTION
*  API function to send GetApplicationSettingValueText Response to CT.
*  All parameters are described in the header file.   
******************************************************************************/
void AvrcpGetAppValueTextResponse( AVRCP *avrcp, 
                                   avrcp_response_type response, 
                                   uint16 number_of_values,
                                   uint16 size_values, 
                                   Source values)
{
    /* Send the response only if the command arrived to start with. */
    if (avrcp->block_received_data == avrcp_get_app_value_text)
    {
        sendGetValueTextResponse(avrcp, response, number_of_values,
                                 size_values, values);
    }
    else
    {
        SourceEmpty( values );
        AVRCP_INFO(("AvrcpGetAppSettingValueResponse:"
                " CT not waiting for response\n"));
    }
}
/****************************************************************************
*NAME    
*    AvrcpEventSystemStatusChangedResponse    
*
*DESCRIPTION
*  API function to notify battery status change event at TG.
*    
*PARAMETERS
*   avrcp       - Task
*   response    - On success , avctp_response_interim for intermediate response
*                 and avctp_response_changed for final response.
*   battery_status - Current battery status
*
*RETURN
*****************************************************************************/
void AvrcpEventSystemStatusChangedResponse(AVRCP *avrcp, 
                                           avrcp_response_type response, 
                                           avrcp_system_status system_status)
{
    /* Only send a response if this event was registered by the CT. */
    if (avrcp->registered_events & (1<<EVENT_SYSTEM_STATUS_CHANGED))
    {
        MAKE_AVRCP_MESSAGE(AVRCP_INTERNAL_EVENT_SYSTEM_STATUS_CHANGED_RES);
        message->response = response;
        message->system_status = system_status;
        MessageSend(&avrcp->task,
                    AVRCP_INTERNAL_EVENT_SYSTEM_STATUS_CHANGED_RES, message);
        if (response == avctp_response_changed)
            clearRegisterNotification(avrcp, EVENT_SYSTEM_STATUS_CHANGED);
    }
    else
    {
        AVRCP_INFO(("AvrcpEventSystemStatusChangedResponse: Event not registered\n"));
    }
}
Exemplo n.º 9
0
/****************************************************************************
*NAME    
*    AvrcpSetAbsoluteVolumeResponse
*
*DESCRIPTION
*  API function to respond to SetAbsoluteVolume request. TG application shall
*  call function on receiving AVRCP_SET_ABSOLUTE_VOLUME_IND. If the volume 
*  got changed due to this procedure, Application must call 
*  AvrcpEventVolumeChangedResponse() if CT has registered for 
*  EVENT_VOLUME_CHANGED notification.
*    
*PARAMETERS
*   avrcp                   - Task
*   avrcp_response_code     - response.  Expected responses are 
*                             avctp_response_accepted or avctp_response_rejected
*                             or avrcp_response_rejected_internal_error.
*   uint8                   - Volume at TG. 0x0 as Minimum and 0x7F as Max 
*
*RETURN
*******************************************************************************/
void AvrcpSetAbsoluteVolumeResponse(AVRCP               *avrcp, 
                                    avrcp_response_type response, 
                                    uint8               volume) 
{

    if (avrcp->block_received_data == avrcp_absolute_volume)
    {
        MAKE_AVRCP_MESSAGE(AVRCP_INTERNAL_SET_ABSOLUTE_VOL_RES); 

        message->volume=(volume < AVRCP_MAX_VOL_MASK)?volume:AVRCP_MAX_VOL_MASK;
        message->response=response;
        MessageSend(&avrcp->task, 
                    AVRCP_INTERNAL_SET_ABSOLUTE_VOL_RES,
                    message);
    }
    else
    {
        AVRCP_INFO(("AvrcpSetAbsoluteVolumeResponse: CT is not waiting for"
                     " the response\n"));  
    }
} 
void AvrcpEventPlaybackPosChangedResponse(AVRCP *avrcp, 
                                          avrcp_response_type response, 
                                          uint32 playback_pos)
{
    /* Only send a response if this event was registered by the CT. */
    if (avrcp->registered_events & (1<<EVENT_PLAYBACK_POS_CHANGED))
    {
        MAKE_AVRCP_MESSAGE(AVRCP_INTERNAL_EVENT_PLAYBACK_POS_CHANGED_RES);
        message->response = response;
        message->playback_pos = playback_pos;
        MessageSend(&avrcp->task, 
                    AVRCP_INTERNAL_EVENT_PLAYBACK_POS_CHANGED_RES, 
                    message);
        if (response == avctp_response_changed)
            clearRegisterNotification(avrcp, EVENT_PLAYBACK_POS_CHANGED);
    }
    else
    {
        AVRCP_INFO(("AvrcpEventPlaybackPosChangedResponse: Event not registered\n"));
    }
}
void AvrcpEventTrackChangedResponse(AVRCP               *avrcp, 
                                    avrcp_response_type response, 
                                    uint32              track_index_high, 
                                    uint32              track_index_low)
{
    /* Only send a response if this event was registered by the CT. */
    if (avrcp->registered_events & (1<<EVENT_TRACK_CHANGED))
    {
        MAKE_AVRCP_MESSAGE(AVRCP_INTERNAL_EVENT_TRACK_CHANGED_RES);
        message->response = response;
        message->track_index_high = track_index_high;
        message->track_index_low = track_index_low;
        MessageSend(&avrcp->task, 
                    AVRCP_INTERNAL_EVENT_TRACK_CHANGED_RES, message);
        if (response == avctp_response_changed)
            clearRegisterNotification(avrcp, EVENT_TRACK_CHANGED);
    }
    else
    {
        AVRCP_INFO(("AvrcpEventTrackChangedResponse: Event not registered\n"));
    }
}
Exemplo n.º 12
0
/****************************************************************************
*NAME    
*   AvrcpEventVolumeChangedResponse 
*
*DESCRIPTION
*  TG shall use this API function to send volume change events if CT has
*  Registered for EVENT_VOLUME_CHANGED notifications. TG shall send an interim
*  response immediately after receiving a AVRCP_REGISTER_NOTIFICATION_IND  for 
*  EVENT_VOLUME_CHANGED from the CT before sending the final response on Volume 
*  change.  Otherwise lib will reject the Register Notification request from CT
*  after timeout of 1000ms. 
* 
*    
*PARAMETERS
*   avrcp                   - Task
*   avrcp_response_code     - response.  Response indicating whether the volume
*                             has been changed or the notification was 
*                             rejected. 
*                             Expected response values avctp_response_changed, 
*                             avrcp_response_interim or avctp_response_rejected.
*   uint8                   - Volume at TG. 0x0 as Minimum and 0x7F as Max 
*
*RETURN
*******************************************************************************/
void AvrcpEventVolumeChangedResponse(AVRCP               *avrcp, 
                                     avrcp_response_type response,
                                     uint8               volume)
{
      /* Only send a response if this event was registered by the CT. */
    if (isEventRegistered(avrcp,EVENT_VOLUME_CHANGED))
    {
        /* Internal Event response */
        MAKE_AVRCP_MESSAGE(AVRCP_INTERNAL_EVENT_VOLUME_CHANGED_RES); 

        message->volume=(volume < AVRCP_MAX_VOL_MASK)?volume:AVRCP_MAX_VOL_MASK;
        message->response=response;
        MessageSend(&avrcp->task, 
                    AVRCP_INTERNAL_EVENT_VOLUME_CHANGED_RES,
                    message);

    }
    else
    {
       AVRCP_INFO(("AvrcpEventVolumeChangedResponse: " 
                    "Event not registered\n"));
    }
}
void avrcpHandleGetPlayStatusResponse(AVRCP             *avrcp, 
                                      avrcp_status_code status,
                                      uint16            transaction, 
                                      const  uint8      *ptr, 
                                      uint16            packet_size)
{
    uint32 song_length = 0, song_elapsed = 0;
    uint8 play_status =0;

    if(status == avrcp_rejected)
    {
        /* next data is error status code */
        status = ptr[0] + avrcp_rejected_invalid_pdu;
    }

    /* packet should be greater than 9 bytes */
    if(packet_size < AVRCP_GET_PLAY_STATUS_SIZE)
    {
        AVRCP_INFO(("avrcpHandleGetPlayStatusResponse: Invalid Length\n",
                    packet_length)); 
    }
    else
    {
        /* Song length in 0-3 bytes */
        song_length = convertUint8ValuesToUint32(&ptr[0]);

        /* song elapsed in 4-7 bytes */
        song_elapsed = convertUint8ValuesToUint32(&ptr[4]);

        /* copy play status in the 8th byte*/
        play_status = ptr[8];
    } 

    avrcpSendGetPlayStatusCfm(avrcp, status,
                              song_length, song_elapsed, play_status, 
                              transaction);
}
/****************************************************************************
*NAME    
*    AvrcpEventPlayerAppSettingChangedResponse    
*
*DESCRIPTION
*  API function to notify player app setting change event at TG.
*    
*PARAMETERS
*   avrcp       - Task
*   response    - On success , avctp_response_interim for intermediate response
*                 and avctp_response_changed for final response.
*   size_attributes - The length of the supplied attribute data (in bytes)
*   attributes -  The list of attribute data returned in the response.
*
*RETURN
*****************************************************************************/
void AvrcpEventPlayerAppSettingChangedResponse(AVRCP    *avrcp, 
                                              avrcp_response_type response, 
                                              uint16    size_attributes, 
                                              Source    attributes)
{
    /* Only send a response if this event was registered by the CT. */
    if (avrcp->registered_events & (1<<EVENT_PLAYER_SETTING_CHANGED))
    {
        MAKE_AVRCP_MESSAGE(AVRCP_INTERNAL_EVENT_PLAYER_APP_SETTING_CHANGED_RES);
        message->response = response;
        message->size_attributes = size_attributes;
        message->attributes = attributes;
        MessageSend(&avrcp->task, 
                    AVRCP_INTERNAL_EVENT_PLAYER_APP_SETTING_CHANGED_RES,
                    message);
        if (response == avctp_response_changed)
            clearRegisterNotification(avrcp, EVENT_PLAYER_SETTING_CHANGED);
    }
    else
    {
        AVRCP_INFO(("AvrcpEventPlayerAppSettingChangedResponse: "
                "Event not registered\n"));
    }
}
Exemplo n.º 15
0
/****************************************************************************
*NAME 
*   AvrcpBrowseChangePathResponse
*
*DESCRIPTION
*   This function is used to send response for  Changepath command to CT.
*   This will be called in response to a AVRCP_BROWSE_CHANGE_PATH_IND message.
*
*PARAMETRS
*   avrcp              - Task
*   avrcp_response_type- response. avrcp_response_browsing_success on Success.
*   uint32             - number of items
*****************************************************************************/
void AvrcpBrowseChangePathResponse(AVRCP*               avrcp,
                                   avrcp_response_type  response,
                                   uint32               num_items)
{
    AVBP *avbp = (AVBP*)avrcp->avbp_task;

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

        /* Queue the Response */
        MessageSend(&avbp->task,
                    AVRCP_INTERNAL_CHANGE_PATH_RES,
                    message);
    }
    else
    {
        AVRCP_INFO(("Wrong state.Ignoring the response\n"));
    }
}
Exemplo n.º 16
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);
        }
    }
}
Exemplo n.º 17
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);
        }
    }
}