Home | History | Annotate | Download | only in include
      1 /******************************************************************************
      2  *
      3  *  Copyright (C) 2004-2012 Broadcom Corporation
      4  *
      5  *  Licensed under the Apache License, Version 2.0 (the "License");
      6  *  you may not use this file except in compliance with the License.
      7  *  You may obtain a copy of the License at:
      8  *
      9  *  http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  *  Unless required by applicable law or agreed to in writing, software
     12  *  distributed under the License is distributed on an "AS IS" BASIS,
     13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  *  See the License for the specific language governing permissions and
     15  *  limitations under the License.
     16  *
     17  ******************************************************************************/
     18 
     19 /******************************************************************************
     20  *
     21  *  This is the public interface file for the advanced audio/video streaming
     22  *  (AV) subsystem of BTA, Broadcom's Bluetooth application layer for mobile
     23  *  phones.
     24  *
     25  ******************************************************************************/
     26 #ifndef BTA_AV_API_H
     27 #define BTA_AV_API_H
     28 
     29 #include "avrc_api.h"
     30 #include "avdt_api.h"
     31 #include "a2d_api.h"
     32 #include "bta_api.h"
     33 
     34 /*****************************************************************************
     35 **  Constants and data types
     36 *****************************************************************************/
     37 /* Set to TRUE if seperate authorization prompt desired for AVCTP besides A2DP authorization */
     38 /* Typically FALSE when AVRCP is used in conjunction with A2DP */
     39 #ifndef BTA_AV_WITH_AVCTP_AUTHORIZATION
     40 #define BTA_AV_WITH_AVCTP_AUTHORIZATION     FALSE
     41 #endif
     42 
     43 /* AV status values */
     44 #define BTA_AV_SUCCESS          0       /* successful operation */
     45 #define BTA_AV_FAIL             1       /* generic failure */
     46 #define BTA_AV_FAIL_SDP         2       /* service not found */
     47 #define BTA_AV_FAIL_STREAM      3       /* stream connection failed */
     48 #define BTA_AV_FAIL_RESOURCES   4       /* no resources */
     49 #define BTA_AV_FAIL_ROLE        5       /* failed due to role management related issues */
     50 #define BTA_AV_FAIL_GET_CAP     6       /* get capability failed due to no SEP availale on the peer  */
     51 
     52 typedef UINT8 tBTA_AV_STATUS;
     53 
     54 /* AV features masks */
     55 #define BTA_AV_FEAT_RCTG        0x0001  /* remote control target */
     56 #define BTA_AV_FEAT_RCCT        0x0002  /* remote control controller */
     57 #define BTA_AV_FEAT_PROTECT     0x0004  /* streaming media contect protection */
     58 #define BTA_AV_FEAT_VENDOR      0x0008  /* remote control vendor dependent commands */
     59 #define BTA_AV_FEAT_REPORT      0x0020  /* use reporting service for VDP */
     60 #define BTA_AV_FEAT_METADATA    0x0040  /* remote control Metadata Transfer command/response */
     61 #define BTA_AV_FEAT_MULTI_AV    0x0080  /* use multi-av, if controller supports it */
     62 #define BTA_AV_FEAT_BROWSE      0x0010  /* use browsing channel */
     63 #define BTA_AV_FEAT_MASTER      0x0100  /* stream only as master role */
     64 #define BTA_AV_FEAT_ADV_CTRL    0x0200  /* remote control Advanced Control command/response */
     65 #define BTA_AV_FEAT_DELAY_RPT   0x0400  /* allow delay reporting */
     66 #define BTA_AV_FEAT_ACP_START   0x0800  /* start stream when 2nd SNK was accepted   */
     67 #define BTA_AV_FEAT_APP_SETTING 0x2000  /* Player app setting support */
     68 
     69 /* Internal features */
     70 #define BTA_AV_FEAT_NO_SCO_SSPD 0x8000  /* Do not suspend av streaming as to AG events(SCO or Call) */
     71 
     72 typedef UINT16 tBTA_AV_FEAT;
     73 
     74 /* AV channel values */
     75 #define BTA_AV_CHNL_MSK             0xC0
     76 #define BTA_AV_CHNL_AUDIO           0x40  /* audio channel */
     77 #define BTA_AV_CHNL_VIDEO           0x80  /* video channel */
     78 typedef UINT8 tBTA_AV_CHNL;
     79 
     80 
     81 #define BTA_AV_HNDL_MSK             0x3F
     82 typedef UINT8 tBTA_AV_HNDL;
     83 /* handle index to mask */
     84 #define BTA_AV_HNDL_TO_MSK(h)       ((UINT8)(1 << (h)))
     85 
     86 /* tBTA_AV_HNDL to mask */
     87 #define BTA_AV_HNDL_TYPE_TO_MSK(h)  ((UINT8)(1 << (h&BTA_AV_HNDL_MSK)))
     88 
     89 /* offset of codec type in codec info byte array */
     90 #define BTA_AV_CODEC_TYPE_IDX       AVDT_CODEC_TYPE_INDEX   /* 2 */
     91 
     92 
     93 
     94 /* maximum number of streams created: 1 for audio, 1 for video */
     95 #ifndef BTA_AV_NUM_STRS
     96 #define BTA_AV_NUM_STRS         2
     97 #endif
     98 
     99 #ifndef BTA_AV_MAX_SEPS
    100 #define BTA_AV_MAX_SEPS         2
    101 #endif
    102 
    103 #ifndef BTA_AV_MAX_A2DP_MTU
    104  /*#define BTA_AV_MAX_A2DP_MTU     668 //224 (DM5) * 3 - 4(L2CAP header) */
    105 #define BTA_AV_MAX_A2DP_MTU     1008
    106 #endif
    107 
    108 #ifndef BTA_AV_MAX_VDP_MTU
    109 #define BTA_AV_MAX_VDP_MTU      1008
    110 #endif
    111 
    112 
    113 /* codec type */
    114 #define BTA_AV_CODEC_SBC        A2D_MEDIA_CT_SBC        /* SBC media codec type */
    115 #define BTA_AV_CODEC_M12        A2D_MEDIA_CT_M12        /* MPEG-1, 2 Audio media codec type */
    116 #define BTA_AV_CODEC_M24        A2D_MEDIA_CT_M24        /* MPEG-2, 4 AAC media codec type */
    117 #define BTA_AV_CODEC_ATRAC      A2D_MEDIA_CT_ATRAC      /* ATRAC family media codec type */
    118 #define BTA_AV_CODEC_H263_P0    VDP_MEDIA_CT_H263_P0    /* H.263 baseline (profile 0) */
    119 #define BTA_AV_CODEC_MPEG4      VDP_MEDIA_CT_MPEG4      /* MPEG-4 Visual Simple Profile */
    120 #define BTA_AV_CODEC_H263_P3    VDP_MEDIA_CT_H263_P3    /* H.263 profile 3 */
    121 #define BTA_AV_CODEC_H263_P8    VDP_MEDIA_CT_H263_P8    /* H.263 profile 8 */
    122 #define BTA_AV_CODEC_VEND       VDP_MEDIA_CT_VEND       /* Non-VDP */
    123 
    124 typedef UINT8 tBTA_AV_CODEC;
    125 
    126 /* Company ID in BT assigned numbers */
    127 #define BTA_AV_BT_VENDOR_ID     VDP_BT_VENDOR_ID        /* Broadcom Corporation */
    128 
    129 /* vendor specific codec ID */
    130 #define BTA_AV_CODEC_ID_H264    VDP_CODEC_ID_H264       /* Non-VDP codec ID - H.264 */
    131 #define BTA_AV_CODEC_ID_IMG     VDP_CODEC_ID_IMG        /* Non-VDP codec ID - images/slideshow */
    132 
    133 /* operation id list for BTA_AvRemoteCmd */
    134 #define BTA_AV_RC_SELECT        AVRC_ID_SELECT      /* select */
    135 #define BTA_AV_RC_UP            AVRC_ID_UP          /* up */
    136 #define BTA_AV_RC_DOWN          AVRC_ID_DOWN        /* down */
    137 #define BTA_AV_RC_LEFT          AVRC_ID_LEFT        /* left */
    138 #define BTA_AV_RC_RIGHT         AVRC_ID_RIGHT       /* right */
    139 #define BTA_AV_RC_RIGHT_UP      AVRC_ID_RIGHT_UP    /* right-up */
    140 #define BTA_AV_RC_RIGHT_DOWN    AVRC_ID_RIGHT_DOWN  /* right-down */
    141 #define BTA_AV_RC_LEFT_UP       AVRC_ID_LEFT_UP     /* left-up */
    142 #define BTA_AV_RC_LEFT_DOWN     AVRC_ID_LEFT_DOWN   /* left-down */
    143 #define BTA_AV_RC_ROOT_MENU     AVRC_ID_ROOT_MENU   /* root menu */
    144 #define BTA_AV_RC_SETUP_MENU    AVRC_ID_SETUP_MENU  /* setup menu */
    145 #define BTA_AV_RC_CONT_MENU     AVRC_ID_CONT_MENU   /* contents menu */
    146 #define BTA_AV_RC_FAV_MENU      AVRC_ID_FAV_MENU    /* favorite menu */
    147 #define BTA_AV_RC_EXIT          AVRC_ID_EXIT        /* exit */
    148 #define BTA_AV_RC_0             AVRC_ID_0           /* 0 */
    149 #define BTA_AV_RC_1             AVRC_ID_1           /* 1 */
    150 #define BTA_AV_RC_2             AVRC_ID_2           /* 2 */
    151 #define BTA_AV_RC_3             AVRC_ID_3           /* 3 */
    152 #define BTA_AV_RC_4             AVRC_ID_4           /* 4 */
    153 #define BTA_AV_RC_5             AVRC_ID_5           /* 5 */
    154 #define BTA_AV_RC_6             AVRC_ID_6           /* 6 */
    155 #define BTA_AV_RC_7             AVRC_ID_7           /* 7 */
    156 #define BTA_AV_RC_8             AVRC_ID_8           /* 8 */
    157 #define BTA_AV_RC_9             AVRC_ID_9           /* 9 */
    158 #define BTA_AV_RC_DOT           AVRC_ID_DOT         /* dot */
    159 #define BTA_AV_RC_ENTER         AVRC_ID_ENTER       /* enter */
    160 #define BTA_AV_RC_CLEAR         AVRC_ID_CLEAR       /* clear */
    161 #define BTA_AV_RC_CHAN_UP       AVRC_ID_CHAN_UP     /* channel up */
    162 #define BTA_AV_RC_CHAN_DOWN     AVRC_ID_CHAN_DOWN   /* channel down */
    163 #define BTA_AV_RC_PREV_CHAN     AVRC_ID_PREV_CHAN   /* previous channel */
    164 #define BTA_AV_RC_SOUND_SEL     AVRC_ID_SOUND_SEL   /* sound select */
    165 #define BTA_AV_RC_INPUT_SEL     AVRC_ID_INPUT_SEL   /* input select */
    166 #define BTA_AV_RC_DISP_INFO     AVRC_ID_DISP_INFO   /* display information */
    167 #define BTA_AV_RC_HELP          AVRC_ID_HELP        /* help */
    168 #define BTA_AV_RC_PAGE_UP       AVRC_ID_PAGE_UP     /* page up */
    169 #define BTA_AV_RC_PAGE_DOWN     AVRC_ID_PAGE_DOWN   /* page down */
    170 #define BTA_AV_RC_POWER         AVRC_ID_POWER       /* power */
    171 #define BTA_AV_RC_VOL_UP        AVRC_ID_VOL_UP      /* volume up */
    172 #define BTA_AV_RC_VOL_DOWN      AVRC_ID_VOL_DOWN    /* volume down */
    173 #define BTA_AV_RC_MUTE          AVRC_ID_MUTE        /* mute */
    174 #define BTA_AV_RC_PLAY          AVRC_ID_PLAY        /* play */
    175 #define BTA_AV_RC_STOP          AVRC_ID_STOP        /* stop */
    176 #define BTA_AV_RC_PAUSE         AVRC_ID_PAUSE       /* pause */
    177 #define BTA_AV_RC_RECORD        AVRC_ID_RECORD      /* record */
    178 #define BTA_AV_RC_REWIND        AVRC_ID_REWIND      /* rewind */
    179 #define BTA_AV_RC_FAST_FOR      AVRC_ID_FAST_FOR    /* fast forward */
    180 #define BTA_AV_RC_EJECT         AVRC_ID_EJECT       /* eject */
    181 #define BTA_AV_RC_FORWARD       AVRC_ID_FORWARD     /* forward */
    182 #define BTA_AV_RC_BACKWARD      AVRC_ID_BACKWARD    /* backward */
    183 #define BTA_AV_RC_ANGLE         AVRC_ID_ANGLE       /* angle */
    184 #define BTA_AV_RC_SUBPICT       AVRC_ID_SUBPICT     /* subpicture */
    185 #define BTA_AV_RC_F1            AVRC_ID_F1          /* F1 */
    186 #define BTA_AV_RC_F2            AVRC_ID_F2          /* F2 */
    187 #define BTA_AV_RC_F3            AVRC_ID_F3          /* F3 */
    188 #define BTA_AV_RC_F4            AVRC_ID_F4          /* F4 */
    189 #define BTA_AV_RC_F5            AVRC_ID_F5          /* F5 */
    190 #define BTA_AV_VENDOR           AVRC_ID_VENDOR      /* vendor unique */
    191 
    192 typedef UINT8 tBTA_AV_RC;
    193 
    194 /* state flag for pass through command */
    195 #define BTA_AV_STATE_PRESS      AVRC_STATE_PRESS    /* key pressed */
    196 #define BTA_AV_STATE_RELEASE    AVRC_STATE_RELEASE  /* key released */
    197 
    198 typedef UINT8 tBTA_AV_STATE;
    199 
    200 /* command codes for BTA_AvVendorCmd */
    201 #define BTA_AV_CMD_CTRL         AVRC_CMD_CTRL
    202 #define BTA_AV_CMD_STATUS       AVRC_CMD_STATUS
    203 #define BTA_AV_CMD_SPEC_INQ     AVRC_CMD_SPEC_INQ
    204 #define BTA_AV_CMD_NOTIF        AVRC_CMD_NOTIF
    205 #define BTA_AV_CMD_GEN_INQ      AVRC_CMD_GEN_INQ
    206 
    207 typedef UINT8 tBTA_AV_CMD;
    208 
    209 /* response codes for BTA_AvVendorRsp */
    210 #define BTA_AV_RSP_NOT_IMPL     AVRC_RSP_NOT_IMPL
    211 #define BTA_AV_RSP_ACCEPT       AVRC_RSP_ACCEPT
    212 #define BTA_AV_RSP_REJ          AVRC_RSP_REJ
    213 #define BTA_AV_RSP_IN_TRANS     AVRC_RSP_IN_TRANS
    214 #define BTA_AV_RSP_IMPL_STBL    AVRC_RSP_IMPL_STBL
    215 #define BTA_AV_RSP_CHANGED      AVRC_RSP_CHANGED
    216 #define BTA_AV_RSP_INTERIM      AVRC_RSP_INTERIM
    217 
    218 typedef UINT8 tBTA_AV_CODE;
    219 
    220 /* error codes for BTA_AvProtectRsp */
    221 #define BTA_AV_ERR_NONE             A2D_SUCCESS         /* Success, no error */
    222 #define BTA_AV_ERR_BAD_STATE        AVDT_ERR_BAD_STATE  /* Message cannot be processed in this state */
    223 #define BTA_AV_ERR_RESOURCE         AVDT_ERR_RESOURCE   /* Insufficient resources */
    224 #define BTA_AV_ERR_BAD_CP_TYPE      A2D_BAD_CP_TYPE     /* The requested Content Protection Type is not supported */
    225 #define BTA_AV_ERR_BAD_CP_FORMAT    A2D_BAD_CP_FORMAT   /* The format of Content Protection Data is not correct */
    226 
    227 typedef UINT8 tBTA_AV_ERR;
    228 
    229 
    230 /* AV callback events */
    231 #define BTA_AV_ENABLE_EVT       0       /* AV enabled */
    232 #define BTA_AV_REGISTER_EVT     1       /* registered to AVDT */
    233 #define BTA_AV_OPEN_EVT         2       /* connection opened */
    234 #define BTA_AV_CLOSE_EVT        3       /* connection closed */
    235 #define BTA_AV_START_EVT        4       /* stream data transfer started */
    236 #define BTA_AV_STOP_EVT         5       /* stream data transfer stopped */
    237 #define BTA_AV_PROTECT_REQ_EVT  6       /* content protection request */
    238 #define BTA_AV_PROTECT_RSP_EVT  7       /* content protection response */
    239 #define BTA_AV_RC_OPEN_EVT      8       /* remote control channel open */
    240 #define BTA_AV_RC_CLOSE_EVT     9       /* remote control channel closed */
    241 #define BTA_AV_REMOTE_CMD_EVT   10      /* remote control command */
    242 #define BTA_AV_REMOTE_RSP_EVT   11      /* remote control response */
    243 #define BTA_AV_VENDOR_CMD_EVT   12      /* vendor dependent remote control command */
    244 #define BTA_AV_VENDOR_RSP_EVT   13      /* vendor dependent remote control response */
    245 #define BTA_AV_RECONFIG_EVT     14      /* reconfigure response */
    246 #define BTA_AV_SUSPEND_EVT      15      /* suspend response */
    247 #define BTA_AV_PENDING_EVT      16      /* incoming connection pending:
    248                                          * signal channel is open and stream is
    249                                          * not open after
    250                                          * BTA_AV_SIGNALLING_TIMEOUT_MS */
    251 #define BTA_AV_META_MSG_EVT     17      /* metadata messages */
    252 #define BTA_AV_REJECT_EVT       18      /* incoming connection rejected */
    253 #define BTA_AV_RC_FEAT_EVT      19      /* remote control channel peer supported features update */
    254 #define BTA_AV_MEDIA_SINK_CFG_EVT    20 /* command to configure codec */
    255 #define BTA_AV_MEDIA_DATA_EVT   21      /* sending data to Media Task */
    256 #define BTA_AV_OFFLOAD_START_RSP_EVT 22 /* a2dp offload start response */
    257 /* Max BTA event */
    258 #define BTA_AV_MAX_EVT          23
    259 
    260 
    261 typedef UINT8 tBTA_AV_EVT;
    262 
    263 /* Event associated with BTA_AV_ENABLE_EVT */
    264 typedef struct
    265 {
    266     tBTA_AV_FEAT    features;
    267 } tBTA_AV_ENABLE;
    268 
    269 /* Event associated with BTA_AV_REGISTER_EVT */
    270 typedef struct
    271 {
    272     tBTA_AV_CHNL    chnl;       /* audio/video */
    273     tBTA_AV_HNDL    hndl;       /* Handle associated with the stream. */
    274     UINT8           app_id;     /* ID associated with call to BTA_AvRegister() */
    275     tBTA_AV_STATUS  status;
    276 } tBTA_AV_REGISTER;
    277 
    278 /* data associated with BTA_AV_OPEN_EVT */
    279 #define BTA_AV_EDR_2MBPS        0x01
    280 #define BTA_AV_EDR_3MBPS        0x02
    281 typedef UINT8 tBTA_AV_EDR;
    282 
    283 typedef struct
    284 {
    285     tBTA_AV_CHNL    chnl;
    286     tBTA_AV_HNDL    hndl;
    287     BD_ADDR         bd_addr;
    288     tBTA_AV_STATUS  status;
    289     BOOLEAN         starting;
    290     tBTA_AV_EDR     edr;        /* 0, if peer device does not support EDR */
    291     UINT8           sep;        /*  sep type of peer device */
    292 } tBTA_AV_OPEN;
    293 
    294 /* data associated with BTA_AV_CLOSE_EVT */
    295 typedef struct
    296 {
    297     tBTA_AV_CHNL    chnl;
    298     tBTA_AV_HNDL    hndl;
    299 } tBTA_AV_CLOSE;
    300 
    301 /* data associated with BTA_AV_START_EVT */
    302 typedef struct
    303 {
    304     tBTA_AV_CHNL    chnl;
    305     tBTA_AV_HNDL    hndl;
    306     tBTA_AV_STATUS  status;
    307     BOOLEAN         initiator; /* TRUE, if local device initiates the START */
    308     BOOLEAN         suspending;
    309 } tBTA_AV_START;
    310 
    311 /* data associated with BTA_AV_SUSPEND_EVT */
    312 typedef struct
    313 {
    314     tBTA_AV_CHNL    chnl;
    315     tBTA_AV_HNDL    hndl;
    316     BOOLEAN         initiator; /* TRUE, if local device initiates the SUSPEND */
    317     tBTA_AV_STATUS  status;
    318 } tBTA_AV_SUSPEND;
    319 
    320 /* data associated with BTA_AV_RECONFIG_EVT */
    321 typedef struct
    322 {
    323     tBTA_AV_CHNL    chnl;
    324     tBTA_AV_HNDL    hndl;
    325     tBTA_AV_STATUS  status;
    326 } tBTA_AV_RECONFIG;
    327 
    328 /* data associated with BTA_AV_PROTECT_REQ_EVT */
    329 typedef struct
    330 {
    331     tBTA_AV_CHNL    chnl;
    332     tBTA_AV_HNDL    hndl;
    333     UINT8           *p_data;
    334     UINT16          len;
    335 } tBTA_AV_PROTECT_REQ;
    336 
    337 /* data associated with BTA_AV_PROTECT_RSP_EVT */
    338 typedef struct
    339 {
    340     tBTA_AV_CHNL    chnl;
    341     tBTA_AV_HNDL    hndl;
    342     UINT8           *p_data;
    343     UINT16          len;
    344     tBTA_AV_ERR     err_code;
    345 } tBTA_AV_PROTECT_RSP;
    346 
    347 /* data associated with BTA_AV_RC_OPEN_EVT */
    348 typedef struct
    349 {
    350     UINT8           rc_handle;
    351     tBTA_AV_FEAT    peer_features;
    352     BD_ADDR         peer_addr;
    353     tBTA_AV_STATUS  status;
    354 } tBTA_AV_RC_OPEN;
    355 
    356 /* data associated with BTA_AV_RC_CLOSE_EVT */
    357 typedef struct
    358 {
    359     UINT8           rc_handle;
    360     BD_ADDR         peer_addr;
    361 } tBTA_AV_RC_CLOSE;
    362 
    363 /* data associated with BTA_AV_RC_FEAT_EVT */
    364 typedef struct
    365 {
    366     UINT8           rc_handle;
    367     tBTA_AV_FEAT    peer_features;
    368     BD_ADDR         peer_addr;
    369 } tBTA_AV_RC_FEAT;
    370 
    371 /* data associated with BTA_AV_REMOTE_CMD_EVT */
    372 typedef struct
    373 {
    374     UINT8           rc_handle;
    375     tBTA_AV_RC      rc_id;
    376     tBTA_AV_STATE   key_state;
    377     UINT8           len;
    378     UINT8           *p_data;
    379     tAVRC_HDR       hdr;    /* Message header. */
    380     UINT8           label;
    381 } tBTA_AV_REMOTE_CMD;
    382 
    383 /* data associated with BTA_AV_REMOTE_RSP_EVT */
    384 typedef struct
    385 {
    386     UINT8           rc_handle;
    387     tBTA_AV_RC      rc_id;
    388     tBTA_AV_STATE   key_state;
    389     UINT8           len;
    390     UINT8           *p_data;
    391     tBTA_AV_CODE    rsp_code;
    392     UINT8           label;
    393 } tBTA_AV_REMOTE_RSP;
    394 
    395 /* data associated with BTA_AV_VENDOR_CMD_EVT, BTA_AV_VENDOR_RSP_EVT */
    396 typedef struct
    397 {
    398     UINT8           rc_handle;
    399     UINT16          len;            /* Max vendor dependent message is 512 */
    400     UINT8           label;
    401     tBTA_AV_CODE    code;
    402     UINT32          company_id;
    403     UINT8           *p_data;
    404 } tBTA_AV_VENDOR;
    405 
    406 /* data associated with BTA_AV_META_MSG_EVT */
    407 typedef struct
    408 {
    409     UINT8           rc_handle;
    410     UINT16          len;
    411     UINT8           label;
    412     tBTA_AV_CODE    code;
    413     UINT32          company_id;
    414     UINT8           *p_data;
    415     tAVRC_MSG       *p_msg;
    416 } tBTA_AV_META_MSG;
    417 
    418 /* data associated with BTA_AV_PENDING_EVT */
    419 typedef struct
    420 {
    421     BD_ADDR         bd_addr;
    422 } tBTA_AV_PEND;
    423 
    424 /* data associated with BTA_AV_REJECT_EVT */
    425 typedef struct
    426 {
    427     BD_ADDR         bd_addr;
    428     tBTA_AV_HNDL    hndl;       /* Handle associated with the stream that rejected the connection. */
    429 } tBTA_AV_REJECT;
    430 
    431 
    432 /* union of data associated with AV callback */
    433 typedef union
    434 {
    435     tBTA_AV_CHNL        chnl;
    436     tBTA_AV_ENABLE      enable;
    437     tBTA_AV_REGISTER    registr;
    438     tBTA_AV_OPEN        open;
    439     tBTA_AV_CLOSE       close;
    440     tBTA_AV_START       start;
    441     tBTA_AV_PROTECT_REQ protect_req;
    442     tBTA_AV_PROTECT_RSP protect_rsp;
    443     tBTA_AV_RC_OPEN     rc_open;
    444     tBTA_AV_RC_CLOSE    rc_close;
    445     tBTA_AV_REMOTE_CMD  remote_cmd;
    446     tBTA_AV_REMOTE_RSP  remote_rsp;
    447     tBTA_AV_VENDOR      vendor_cmd;
    448     tBTA_AV_VENDOR      vendor_rsp;
    449     tBTA_AV_RECONFIG    reconfig;
    450     tBTA_AV_SUSPEND     suspend;
    451     tBTA_AV_PEND        pend;
    452     tBTA_AV_META_MSG    meta_msg;
    453     tBTA_AV_REJECT      reject;
    454     tBTA_AV_RC_FEAT     rc_feat;
    455     tBTA_AV_STATUS      status;
    456 } tBTA_AV;
    457 
    458 typedef struct
    459 {
    460     UINT8 *codec_info;
    461     BD_ADDR bd_addr;;
    462 } tBTA_AVK_CONFIG;
    463 
    464 /* union of data associated with AV Media callback */
    465 typedef union
    466 {
    467     BT_HDR     *p_data;
    468     tBTA_AVK_CONFIG avk_config;
    469 } tBTA_AV_MEDIA;
    470 
    471 
    472 #define BTA_AVC_PACKET_LEN                  AVRC_PACKET_LEN
    473 #define BTA_VENDOR_DATA_OFFSET              6
    474 #define BTA_VENDOR_HEADER_LEN               4
    475 #define BTA_MAX_VENDOR_DEPENDENT_DATA_LEN   (BTA_AVC_PACKET_LEN-BTA_VENDOR_DATA_OFFSET-BTA_VENDOR_HEADER_LEN)
    476 #define BTA_GROUP_NAVI_MSG_OP_DATA_LEN      5
    477 
    478 #define BTA_ERROR_INVALID_CMD           AVRC_STS_BAD_CMD
    479 #define BTA_ERROR_INVALID_PARAM         AVRC_STS_BAD_PARAM
    480 #define BTA_ERROR_BAD_CONTENTS          AVRC_STS_NOT_FOUND
    481 #define BTA_ERROR_INTERNAL              AVRC_STS_INTERNAL_ERR
    482 
    483 #define BTA_AV_META_SINGLE_PACKET       AVRC_PKT_SINGLE
    484 
    485 #define BTA_AV_CO_METADATA              AVRC_CO_METADATA
    486 
    487 /* AV callback */
    488 typedef void (tBTA_AV_CBACK)(tBTA_AV_EVT event, tBTA_AV *p_data);
    489 typedef void (tBTA_AV_DATA_CBACK)(tBTA_AV_EVT event, tBTA_AV_MEDIA *p_data);
    490 
    491 /* type for stream state machine action functions */
    492 typedef void (*tBTA_AV_ACT)(void *p_cb, void *p_data);
    493 
    494 /* type for registering VDP */
    495 typedef void (tBTA_AV_REG) (tAVDT_CS *p_cs, char *p_service_name, void *p_data);
    496 
    497 /* AV configuration structure */
    498 typedef struct
    499 {
    500     UINT32  company_id;         /* AVRCP Company ID */
    501     UINT16  avrc_mtu;           /* AVRCP MTU at L2CAP for control channel */
    502     UINT16  avrc_br_mtu;        /* AVRCP MTU at L2CAP for browsing channel */
    503     UINT16  avrc_ct_cat;        /* AVRCP controller categories */
    504     UINT16  avrc_tg_cat;        /* AVRCP target categories */
    505     UINT16  sig_mtu;            /* AVDTP signaling channel MTU at L2CAP */
    506     UINT16  audio_mtu;          /* AVDTP audio transport channel MTU at L2CAP */
    507     const UINT16 *p_audio_flush_to;/* AVDTP audio transport channel flush timeout */
    508     UINT16  audio_mqs;          /* AVDTP audio channel max data queue size */
    509     UINT16  video_mtu;          /* AVDTP video transport channel MTU at L2CAP */
    510     UINT16  video_flush_to;     /* AVDTP video transport channel flush timeout */
    511     BOOLEAN avrc_group;         /* TRUE, to accept AVRC 1.3 group nevigation command */
    512     UINT8   num_co_ids;         /* company id count in p_meta_co_ids */
    513     UINT8   num_evt_ids;        /* event id count in p_meta_evt_ids */
    514     tBTA_AV_CODE  rc_pass_rsp;  /* the default response code for pass through commands */
    515     const UINT32 *p_meta_co_ids;/* the metadata Get Capabilities response for company id */
    516     const UINT8 *p_meta_evt_ids;/* the the metadata Get Capabilities response for event id */
    517     const tBTA_AV_ACT *p_act_tbl;/* the action function table for VDP stream */
    518     tBTA_AV_REG       *p_reg;   /* action function to register VDP */
    519     char              avrc_controller_name[BTA_SERVICE_NAME_LEN]; /* Default AVRCP controller name */
    520     char              avrc_target_name[BTA_SERVICE_NAME_LEN];     /* Default AVRCP target name*/
    521 } tBTA_AV_CFG;
    522 
    523 #ifdef __cplusplus
    524 extern "C"
    525 {
    526 #endif
    527 
    528 /*****************************************************************************
    529 **  External Function Declarations
    530 *****************************************************************************/
    531 
    532 /*******************************************************************************
    533 **
    534 ** Function         BTA_AvEnable
    535 **
    536 ** Description      Enable the advanced audio/video service. When the enable
    537 **                  operation is complete the callback function will be
    538 **                  called with a BTA_AV_ENABLE_EVT. This function must
    539 **                  be called before other function in the AV API are
    540 **                  called.
    541 **
    542 ** Returns          void
    543 **
    544 *******************************************************************************/
    545 void BTA_AvEnable(tBTA_SEC sec_mask, tBTA_AV_FEAT features,
    546                           tBTA_AV_CBACK *p_cback);
    547 
    548 /*******************************************************************************
    549 **
    550 ** Function         BTA_AvDisable
    551 **
    552 ** Description      Disable the advanced audio/video service.
    553 **
    554 **
    555 ** Returns          void
    556 **
    557 *******************************************************************************/
    558 void BTA_AvDisable(void);
    559 
    560 /*******************************************************************************
    561 **
    562 ** Function         BTA_AvRegister
    563 **
    564 ** Description      Register the audio or video service to stack. When the
    565 **                  operation is complete the callback function will be
    566 **                  called with a BTA_AV_REGISTER_EVT. This function must
    567 **                  be called before AVDT stream is open.
    568 **
    569 **
    570 ** Returns          void
    571 **
    572 *******************************************************************************/
    573 void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name,
    574                     UINT8 app_id, tBTA_AV_DATA_CBACK  *p_data_cback, UINT16 service_uuid);
    575 
    576 /*******************************************************************************
    577 **
    578 ** Function         BTA_AvDeregister
    579 **
    580 ** Description      Deregister the audio or video service
    581 **
    582 ** Returns          void
    583 **
    584 *******************************************************************************/
    585 void BTA_AvDeregister(tBTA_AV_HNDL hndl);
    586 
    587 /*******************************************************************************
    588 **
    589 ** Function         BTA_AvOpen
    590 **
    591 ** Description      Opens an advanced audio/video connection to a peer device.
    592 **                  When connection is open callback function is called
    593 **                  with a BTA_AV_OPEN_EVT.
    594 **
    595 ** Returns          void
    596 **
    597 *******************************************************************************/
    598 void BTA_AvOpen(BD_ADDR bd_addr, tBTA_AV_HNDL handle,
    599                         BOOLEAN use_rc, tBTA_SEC sec_mask, UINT16 uuid);
    600 
    601 /*******************************************************************************
    602 **
    603 ** Function         BTA_AvClose
    604 **
    605 ** Description      Close the current streams.
    606 **
    607 ** Returns          void
    608 **
    609 *******************************************************************************/
    610 void BTA_AvClose(tBTA_AV_HNDL handle);
    611 
    612 /*******************************************************************************
    613 **
    614 ** Function         BTA_AvDisconnect
    615 **
    616 ** Description      Close the connection to the address.
    617 **
    618 ** Returns          void
    619 **
    620 *******************************************************************************/
    621 void BTA_AvDisconnect(BD_ADDR bd_addr);
    622 
    623 /*******************************************************************************
    624 **
    625 ** Function         BTA_AvEnable_Sink
    626 **
    627 ** Description      Enable/Disable A2DP Sink.
    628 **
    629 ** Returns          void
    630 **
    631 *******************************************************************************/
    632 void BTA_AvEnable_Sink(int enable);
    633 
    634 /*******************************************************************************
    635 **
    636 ** Function         BTA_AvStart
    637 **
    638 ** Description      Start audio/video stream data transfer.
    639 **
    640 ** Returns          void
    641 **
    642 *******************************************************************************/
    643 void BTA_AvStart(void);
    644 
    645 /*******************************************************************************
    646 **
    647 ** Function         BTA_AvStop
    648 **
    649 ** Description      Stop audio/video stream data transfer.
    650 **                  If suspend is TRUE, this function sends AVDT suspend signal
    651 **                  to the connected peer(s).
    652 **
    653 ** Returns          void
    654 **
    655 *******************************************************************************/
    656 void BTA_AvStop(BOOLEAN suspend);
    657 
    658 /*******************************************************************************
    659 **
    660 ** Function         BTA_AvReconfig
    661 **
    662 ** Description      Reconfigure the audio/video stream.
    663 **                  If suspend is TRUE, this function tries the suspend/reconfigure
    664 **                  procedure first.
    665 **                  If suspend is FALSE or when suspend/reconfigure fails,
    666 **                  this function closes and re-opens the AVDT connection.
    667 **
    668 ** Returns          void
    669 **
    670 *******************************************************************************/
    671 void BTA_AvReconfig(tBTA_AV_HNDL hndl, BOOLEAN suspend, UINT8 sep_info_idx,
    672                             UINT8 *p_codec_info, UINT8 num_protect, UINT8 *p_protect_info);
    673 
    674 /*******************************************************************************
    675 **
    676 ** Function         BTA_AvProtectReq
    677 **
    678 ** Description      Send a content protection request.  This function can only
    679 **                  be used if AV is enabled with feature BTA_AV_FEAT_PROTECT.
    680 **
    681 ** Returns          void
    682 **
    683 *******************************************************************************/
    684 void BTA_AvProtectReq(tBTA_AV_HNDL hndl, UINT8 *p_data, UINT16 len);
    685 
    686 /*******************************************************************************
    687 **
    688 ** Function         BTA_AvProtectRsp
    689 **
    690 ** Description      Send a content protection response.  This function must
    691 **                  be called if a BTA_AV_PROTECT_REQ_EVT is received.
    692 **                  This function can only be used if AV is enabled with
    693 **                  feature BTA_AV_FEAT_PROTECT.
    694 **
    695 ** Returns          void
    696 **
    697 *******************************************************************************/
    698 void BTA_AvProtectRsp(tBTA_AV_HNDL hndl, UINT8 error_code, UINT8 *p_data,
    699                               UINT16 len);
    700 
    701 /*******************************************************************************
    702 **
    703 ** Function         BTA_AvRemoteCmd
    704 **
    705 ** Description      Send a remote control command.  This function can only
    706 **                  be used if AV is enabled with feature BTA_AV_FEAT_RCCT.
    707 **
    708 ** Returns          void
    709 **
    710 *******************************************************************************/
    711 void BTA_AvRemoteCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_RC rc_id,
    712                              tBTA_AV_STATE key_state);
    713 
    714 /*******************************************************************************
    715 **
    716 ** Function         BTA_AvRemoteVendorUniqueCmd
    717 **
    718 ** Description      Send a remote control command with Vendor Unique rc_id.
    719 **                  This function can only be used if AV is enabled with
    720 **                  feature BTA_AV_FEAT_RCCT.
    721 **
    722 ** Returns          void
    723 **
    724 *******************************************************************************/
    725 void BTA_AvRemoteVendorUniqueCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_STATE key_state,
    726                                          UINT8* p_msg, UINT8 buf_len);
    727 
    728 /*******************************************************************************
    729 **
    730 ** Function         BTA_AvVendorCmd
    731 **
    732 ** Description      Send a vendor dependent remote control command.  This
    733 **                  function can only be used if AV is enabled with feature
    734 **                  BTA_AV_FEAT_VENDOR.
    735 **
    736 ** Returns          void
    737 **
    738 *******************************************************************************/
    739 void BTA_AvVendorCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE cmd_code,
    740                              UINT8 *p_data, UINT16 len);
    741 
    742 /*******************************************************************************
    743 **
    744 ** Function         BTA_AvVendorRsp
    745 **
    746 ** Description      Send a vendor dependent remote control response.
    747 **                  This function must be called if a BTA_AV_VENDOR_CMD_EVT
    748 **                  is received. This function can only be used if AV is
    749 **                  enabled with feature BTA_AV_FEAT_VENDOR.
    750 **
    751 ** Returns          void
    752 **
    753 *******************************************************************************/
    754 void BTA_AvVendorRsp(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE rsp_code,
    755                              UINT8 *p_data, UINT16 len, UINT32 company_id);
    756 
    757 
    758 /*******************************************************************************
    759 **
    760 ** Function         BTA_AvOpenRc
    761 **
    762 ** Description      Open an AVRCP connection toward the device with the
    763 **                  specified handle
    764 **
    765 ** Returns          void
    766 **
    767 *******************************************************************************/
    768 void BTA_AvOpenRc(tBTA_AV_HNDL handle);
    769 
    770 /*******************************************************************************
    771 **
    772 ** Function         BTA_AvCloseRc
    773 **
    774 ** Description      Close an AVRCP connection
    775 **
    776 ** Returns          void
    777 **
    778 *******************************************************************************/
    779 void BTA_AvCloseRc(UINT8 rc_handle);
    780 
    781 /*******************************************************************************
    782 **
    783 ** Function         BTA_AvMetaRsp
    784 **
    785 ** Description      Send a Metadata command/response. The message contained
    786 **                  in p_pkt can be composed with AVRC utility functions.
    787 **                  This function can only be used if AV is enabled with feature
    788 **                  BTA_AV_FEAT_METADATA.
    789 **
    790 ** Returns          void
    791 **
    792 *******************************************************************************/
    793 void BTA_AvMetaRsp(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE rsp_code,
    794                                BT_HDR *p_pkt);
    795 
    796 /*******************************************************************************
    797 **
    798 ** Function         BTA_AvMetaCmd
    799 **
    800 ** Description      Send a Metadata/Advanced Control command. The message contained
    801 **                  in p_pkt can be composed with AVRC utility functions.
    802 **                  This function can only be used if AV is enabled with feature
    803 **                  BTA_AV_FEAT_METADATA.
    804 **                  This message is sent only when the peer supports the TG role.
    805 *8                  The only command makes sense right now is the absolute volume command.
    806 **
    807 ** Returns          void
    808 **
    809 *******************************************************************************/
    810 void BTA_AvMetaCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_CMD cmd_code, BT_HDR *p_pkt);
    811 
    812 /*******************************************************************************
    813 **
    814 ** Function         BTA_AvOffloadStart
    815 **
    816 ** Description      Request Starting of A2DP Offload.
    817 **                  This function is used to start A2DP offload if vendor lib has
    818 **                  the feature enabled.
    819 **
    820 ** Returns          void
    821 **
    822 *******************************************************************************/
    823 void BTA_AvOffloadStart(tBTA_AV_HNDL hndl);
    824 
    825 /*******************************************************************************
    826 **
    827 ** Function         BTA_AvOffloadStartRsp
    828 **
    829 ** Description      Response from vendor library indicating response for
    830 **                  OffloadStart.
    831 **
    832 ** Returns          void
    833 **
    834 *******************************************************************************/
    835 void BTA_AvOffloadStartRsp(tBTA_AV_HNDL hndl, tBTA_AV_STATUS status);
    836 
    837 
    838 #ifdef __cplusplus
    839 }
    840 #endif
    841 
    842 #endif /* BTA_AV_API_H */
    843