Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fdbc8756 authored by Zhihai Xu's avatar Zhihai Xu Committed by Android (Google) Code Review
Browse files

Merge "Initial version of Stack for AVRCP 1.3" into jb-mr2-dev

parents 835434db 78b35205
Loading
Loading
Loading
Loading

system/bta/av/bta_av_act.c

100644 → 100755
+64 −1
Original line number Diff line number Diff line
@@ -760,6 +760,8 @@ tBTA_AV_EVT bta_av_proc_meta_cmd(tAVRC_RESPONSE *p_rc_rsp, tBTA_AV_RC_MSG *p_ms
    UINT16      u16;
    tAVRC_MSG_VENDOR    *p_vendor = &p_msg->msg.vendor;

#if (AVRC_METADATA_INCLUDED == TRUE)

    pdu = *(p_vendor->p_vendor_data);
    p_rc_rsp->pdu = pdu;
    *p_ctype = AVRC_RSP_REJ;
@@ -772,6 +774,13 @@ tBTA_AV_EVT bta_av_proc_meta_cmd(tAVRC_RESPONSE *p_rc_rsp, tBTA_AV_RC_MSG *p_ms
        p_vendor->hdr.ctype = BTA_AV_RSP_NOT_IMPL;
        AVRC_VendorRsp(p_msg->handle, p_msg->label, &p_msg->msg.vendor);
    }
    else if (!AVRC_IsValidAvcType(pdu, p_vendor->hdr.ctype) )
    {
        APPL_TRACE_DEBUG2("Invalid pdu/ctype: 0x%x, %d", pdu, p_vendor->hdr.ctype);
        /* reject invalid message without reporting to app */
        evt = 0;
        p_rc_rsp->rsp.status = AVRC_STS_BAD_CMD;
    }
    else
    {
        switch (pdu)
@@ -823,6 +832,12 @@ tBTA_AV_EVT bta_av_proc_meta_cmd(tAVRC_RESPONSE *p_rc_rsp, tBTA_AV_RC_MSG *p_ms

        }
    }
#else
    APPL_TRACE_DEBUG0("AVRCP 1.3 Metadata not supporteed. Reject command.");
    /* reject invalid message without reporting to app */
    evt = 0;
    p_rc_rsp->rsp.status = AVRC_STS_BAD_CMD;
#endif

    return evt;
}
@@ -844,6 +859,13 @@ void bta_av_rc_msg(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
    BT_HDR      *p_pkt = NULL;
    tAVRC_MSG_VENDOR    *p_vendor = &p_data->rc_msg.msg.vendor;
    BOOLEAN is_inquiry = ((p_data->rc_msg.msg.hdr.ctype == AVRC_CMD_SPEC_INQ) || p_data->rc_msg.msg.hdr.ctype == AVRC_CMD_GEN_INQ);
#if (AVRC_METADATA_INCLUDED == TRUE)
    tAVRC_STS   res;
    UINT8       ctype;
    tAVRC_RESPONSE  rc_rsp;

    rc_rsp.rsp.status = BTA_AV_STS_NO_RSP;
#endif

    if (p_data->rc_msg.opcode == AVRC_OP_PASS_THRU)
    {
@@ -857,6 +879,12 @@ void bta_av_rc_msg(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
            if (p_data->rc_msg.msg.pass.op_id == AVRC_ID_VENDOR)
            {
                p_data->rc_msg.msg.hdr.ctype = BTA_AV_RSP_NOT_IMPL;
#if (AVRC_METADATA_INCLUDED == TRUE)
                if (p_cb->features & BTA_AV_FEAT_METADATA)
                    p_data->rc_msg.msg.hdr.ctype =
                        bta_av_group_navi_supported(p_data->rc_msg.msg.pass.pass_len,
                        p_data->rc_msg.msg.pass.p_pass_data, is_inquiry);
#endif
            }
            else
            {
@@ -912,12 +940,30 @@ void bta_av_rc_msg(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
        if ((p_cb->features & BTA_AV_FEAT_VENDOR)  &&
            p_data->rc_msg.msg.hdr.ctype <= AVRC_CMD_GEN_INQ)
        {
#if (AVRC_METADATA_INCLUDED == TRUE)
            if ((p_cb->features & BTA_AV_FEAT_METADATA) &&
               (p_vendor->company_id == AVRC_CO_METADATA))
            {
                av.meta_msg.p_msg = &p_data->rc_msg.msg;
                evt = bta_av_proc_meta_cmd (&rc_rsp, &p_data->rc_msg, &ctype);
            }
            else
#endif
                evt = BTA_AV_VENDOR_CMD_EVT;
        }
        /* else if configured to support vendor specific and it's a response */
        else if ((p_cb->features & BTA_AV_FEAT_VENDOR) &&
                 p_data->rc_msg.msg.hdr.ctype >= AVRC_RSP_ACCEPT)
        {
#if (AVRC_METADATA_INCLUDED == TRUE)
            if ((p_cb->features & BTA_AV_FEAT_METADATA) &&
               (p_vendor->company_id == AVRC_CO_METADATA))
            {
                av.meta_msg.p_msg = &p_data->rc_msg.msg;
                evt = BTA_AV_META_MSG_EVT;
            }
            else
#endif
                evt = BTA_AV_VENDOR_RSP_EVT;

        }
@@ -936,6 +982,18 @@ void bta_av_rc_msg(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
           AVRC_VendorRsp(p_data->rc_msg.handle, p_data->rc_msg.label, &p_data->rc_msg.msg.vendor);
        }
    }
#if (AVRC_METADATA_INCLUDED == TRUE)
    if (evt == 0 && rc_rsp.rsp.status != BTA_AV_STS_NO_RSP)
    {
        if (!p_pkt)
        {
            rc_rsp.rsp.opcode = p_data->rc_msg.opcode;
            res = AVRC_BldResponse (0, &rc_rsp, &p_pkt);
        }
        if (p_pkt)
            AVRC_MsgReq (p_data->rc_msg.handle, p_data->rc_msg.label, ctype, p_pkt);
    }
#endif

    /* call callback */
    if (evt != 0)
@@ -1655,7 +1713,12 @@ void bta_av_rc_disc_done(tBTA_AV_DATA *p_data)
    APPL_TRACE_DEBUG1("rc_handle %d", rc_handle);
    /* check peer version and whether support CT and TG role */
    peer_features = bta_av_check_peer_features (UUID_SERVCLASS_AV_REMOTE_CONTROL);
    if ((p_cb->features & BTA_AV_FEAT_ADV_CTRL) && ((peer_features&BTA_AV_FEAT_ADV_CTRL) == 0))
    {
        /* if we support advance control and peer does not, check their support on TG role
         * some implementation uses 1.3 on CT ans 1.4 on TG */
        peer_features |= bta_av_check_peer_features (UUID_SERVCLASS_AV_REM_CTRL_TARGET);
    }

    p_cb->disc = 0;
    utl_freebuf((void **) &p_cb->p_disc_db);

system/bta/av/bta_av_cfg.c

100644 → 100755
+13 −7
Original line number Diff line number Diff line
@@ -28,13 +28,10 @@
#include "bta_api.h"
#include "bta_av_int.h"



#ifndef BTA_AV_RC_PASS_RSP_CODE
#define BTA_AV_RC_PASS_RSP_CODE     BTA_AV_RSP_NOT_IMPL
#endif


const UINT32  bta_av_meta_caps_co_ids[] = {
    AVRC_CO_METADATA,
    AVRC_CO_BROADCOM
@@ -43,7 +40,6 @@ const UINT32 bta_av_meta_caps_co_ids[] = {
/* AVRCP cupported categories */
#define BTA_AV_RC_SUPF_CT       (AVRC_SUPF_CT_CAT2)


/* Added to modify
**	1. flush timeout
**	2. Remove Group navigation support in SupportedFeatures
@@ -62,8 +58,12 @@ const UINT16 bta_av_audio_flush_to[] = {
};     /* AVDTP audio transport channel flush timeout */

/* Note: Android doesnt support AVRC_SUPF_TG_GROUP_NAVI  */
/* Note: if AVRC_SUPF_TG_GROUP_NAVI is set, bta_av_cfg.avrc_group should be TRUE */
#if AVRC_METADATA_INCLUDED == TRUE
#define BTA_AV_RC_SUPF_TG       (AVRC_SUPF_TG_CAT1) /* TODO: | AVRC_SUPF_TG_APP_SETTINGS) */
#else
#define BTA_AV_RC_SUPF_TG       (AVRC_SUPF_TG_CAT1)

#endif

/*
 * If the number of event IDs is changed in this array, BTA_AV_ NUM_RC_EVT_IDS   also needs to be changed.
@@ -71,8 +71,9 @@ const UINT16 bta_av_audio_flush_to[] = {
const UINT8  bta_av_meta_caps_evt_ids[] = {
    AVRC_EVT_PLAY_STATUS_CHANGE,
    AVRC_EVT_TRACK_CHANGE,
    AVRC_EVT_PLAY_POS_CHANGED,
    AVRC_EVT_APP_SETTING_CHANGE,
    /* TODO: Add support for these events */
    /* AVRC_EVT_PLAY_POS_CHANGED,
    AVRC_EVT_APP_SETTING_CHANGE, */
};
#ifndef BTA_AV_NUM_RC_EVT_IDS
#define BTA_AV_NUM_RC_EVT_IDS   (sizeof(bta_av_meta_caps_evt_ids) / sizeof(bta_av_meta_caps_evt_ids[0]))
@@ -88,8 +89,13 @@ const UINT8 bta_av_meta_caps_evt_ids[] = {
const tBTA_AV_CFG bta_av_cfg =
{
    AVRC_CO_BROADCOM,       /* AVRCP Company ID */
#if AVRC_METADATA_INCLUDED == TRUE
    512,                    /* AVRCP MTU at L2CAP for control channel */
    BTA_AV_MAX_RC_BR_MTU,   /* AVRCP MTU at L2CAP for browsing channel */
#else
    48,                     /* AVRCP MTU at L2CAP for control channel */
    BTA_AV_MAX_RC_BR_MTU,   /* AVRCP MTU at L2CAP for browsing channel */
#endif
    BTA_AV_RC_SUPF_CT,      /* AVRCP controller categories */
    BTA_AV_RC_SUPF_TG,      /* AVRCP target categories */
    672,                    /* AVDTP signaling channel MTU at L2CAP */

system/btif/include/btif_av.h

100644 → 100755
+12 −0
Original line number Diff line number Diff line
@@ -113,4 +113,16 @@ void btif_dispatch_sm_event(btif_av_sm_event_t event, void *p_data, int len);

bt_status_t btif_av_init(void);

/*******************************************************************************
**
** Function         btif_av_is_connected
**
** Description      Checks if av has a connected sink
**
** Returns          BOOLEAN
**
*******************************************************************************/

BOOLEAN btif_av_is_connected(void);

#endif /* BTIF_AV_H */
+3 −1
Original line number Diff line number Diff line
@@ -56,9 +56,11 @@ const char* dump_property_type(bt_property_type_t type);
const char* dump_hf_audio_state(UINT16 event);
const char* dump_adapter_scan_mode(bt_scan_mode_t mode);
const char* dump_thread_evt(bt_cb_thread_evt evt);

const char* dump_av_conn_state(UINT16 event);
const char* dump_av_audio_state(UINT16 event);
const char* dump_rc_event(UINT8 event);
const char* dump_rc_notification_event_id(UINT8 event_id);
const char* dump_rc_pdu(UINT8 pdu);

int str2bd(char *str, bt_bdaddr_t *addr);
char *bd2str(const bt_bdaddr_t *addr, bdstr_t *bdstr);

system/btif/src/bluetooth.c

100644 → 100755
+8 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@
#include <hardware/bt_hl.h>
#include <hardware/bt_pan.h>
#include <hardware/bt_gatt.h>
#include <hardware/bt_rc.h>

#define LOG_NDDEBUG 0
#define LOG_TAG "bluedroid"
@@ -83,6 +84,8 @@ extern bthl_interface_t *btif_hl_get_interface();
extern btpan_interface_t *btif_pan_get_interface();
/* gatt */
extern btgatt_interface_t *btif_gatt_get_interface();
/* avrc */
extern btrc_interface_t *btif_rc_get_interface();

/************************************************************************************
**  Functions
@@ -322,8 +325,13 @@ static const void* get_profile_interface (const char *profile_id)

    if (is_profile(profile_id, BT_PROFILE_HEALTH_ID))
        return btif_hl_get_interface();

    if (is_profile(profile_id, BT_PROFILE_GATT_ID))
        return btif_gatt_get_interface();

    if (is_profile(profile_id, BT_PROFILE_AV_RC_ID))
        return btif_rc_get_interface();

    return NULL;
}

Loading