1 /******************************************************************************
2  *
3  *  Copyright 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 <cstdint>
30 
31 #include "bta/include/bta_api.h"
32 #include "stack/include/avrc_defs.h"
33 #include "stack/include/bt_hdr.h"
34 #include "types/raw_address.h"
35 
36 /*****************************************************************************
37  *  Constants and data types
38  ****************************************************************************/
39 
40 /* AV status values */
41 #define BTA_AV_SUCCESS 0        /* successful operation */
42 #define BTA_AV_FAIL 1           /* generic failure */
43 #define BTA_AV_FAIL_SDP 2       /* service not found */
44 #define BTA_AV_FAIL_STREAM 3    /* stream connection failed */
45 #define BTA_AV_FAIL_RESOURCES 4 /* no resources */
46 #define BTA_AV_FAIL_ROLE 5      /* failed due to role management related issues */
47 #define BTA_AV_FAIL_GET_CAP 6   /* get capability failed due to no SEP availale on the peer  */
48 
49 typedef uint8_t tBTA_AV_STATUS;
50 
51 /* AV features masks */
52 #define BTA_AV_FEAT_RCTG 0x0001    /* remote control target */
53 #define BTA_AV_FEAT_RCCT 0x0002    /* remote control controller */
54 #define BTA_AV_FEAT_PROTECT 0x0004 /* streaming media contect protection */
55 #define BTA_AV_FEAT_VENDOR                                                           \
56   0x0008                                 /* remote control vendor dependent commands \
57                                           */
58 #define BTA_AV_FEAT_REPORT 0x0020        /* use reporting service for VDP */
59 #define BTA_AV_FEAT_METADATA 0x0040      /* remote control Metadata Transfer command/response */
60 #define BTA_AV_FEAT_MULTI_AV 0x0080      /* use multi-av, if controller supports it */
61 #define BTA_AV_FEAT_BROWSE 0x0010        /* use browsing channel */
62 #define BTA_AV_FEAT_ADV_CTRL 0x0200      /* remote control Advanced Control command/response */
63 #define BTA_AV_FEAT_DELAY_RPT 0x0400     /* allow delay reporting */
64 #define BTA_AV_FEAT_ACP_START 0x0800     /* start stream when 2nd SNK was accepted   */
65 #define BTA_AV_FEAT_COVER_ARTWORK 0x1000 /* use cover art feature */
66 #define BTA_AV_FEAT_APP_SETTING 0x2000   /* Player app setting support */
67 
68 /* Internal features */
69 #define BTA_AV_FEAT_NO_SCO_SSPD \
70   0x8000 /* Do not suspend av streaming as to AG events(SCO or Call) */
71 
72 /* it indicates the feature is for source */
73 #define BTA_AV_FEAT_SRC 0x4000
74 
75 typedef uint16_t tBTA_AV_FEAT;
76 
77 /* AV channel values */
78 #define BTA_AV_CHNL_MSK 0xC0
79 #define BTA_AV_CHNL_AUDIO 0x40 /* audio channel */
80 #define BTA_AV_CHNL_VIDEO 0x80 /* video channel */
81 typedef uint8_t tBTA_AV_CHNL;
82 
83 #define BTA_AV_HNDL_MSK 0x3F
84 typedef uint8_t tBTA_AV_HNDL;
85 /* handle index to mask */
86 #define BTA_AV_HNDL_TO_MSK(h) ((uint8_t)(1 << (h)))
87 #define BTA_AV_INVALID_HANDLE 0x00
88 
89 /* maximum number of streams created */
90 #ifndef BTA_AV_NUM_STRS
91 #define BTA_AV_NUM_STRS 6
92 #endif
93 
94 /* operation id list for BTA_AvRemoteCmd */
95 typedef uint8_t tBTA_AV_RC;
96 
97 /* state flag for pass through command */
98 typedef uint8_t tBTA_AV_STATE;
99 
100 /* command codes for BTA_AvVendorCmd */
101 typedef uint8_t tBTA_AV_CMD;
102 
103 /* response codes for BTA_AvVendorRsp */
104 typedef uint8_t tBTA_AV_CODE;
105 
106 /* error codes for BTA_AvProtectRsp */
107 typedef uint8_t tBTA_AV_ERR;
108 
109 /* AV callback events */
110 #define BTA_AV_ENABLE_EVT 0      /* AV enabled */
111 #define BTA_AV_REGISTER_EVT 1    /* registered to AVDT */
112 #define BTA_AV_OPEN_EVT 2        /* connection opened */
113 #define BTA_AV_CLOSE_EVT 3       /* connection closed */
114 #define BTA_AV_START_EVT 4       /* stream data transfer started */
115 #define BTA_AV_STOP_EVT 5        /* stream data transfer stopped */
116 #define BTA_AV_PROTECT_REQ_EVT 6 /* content protection request */
117 #define BTA_AV_PROTECT_RSP_EVT 7 /* content protection response */
118 #define BTA_AV_RC_OPEN_EVT 8     /* remote control channel open */
119 #define BTA_AV_RC_CLOSE_EVT 9    /* remote control channel closed */
120 #define BTA_AV_REMOTE_CMD_EVT 10 /* remote control command */
121 #define BTA_AV_REMOTE_RSP_EVT 11 /* remote control response */
122 #define BTA_AV_VENDOR_CMD_EVT 12 /* vendor dependent remote control command */
123 #define BTA_AV_VENDOR_RSP_EVT                                              \
124   13                           /* vendor dependent remote control response \
125                                 */
126 #define BTA_AV_RECONFIG_EVT 14 /* reconfigure response */
127 #define BTA_AV_SUSPEND_EVT 15  /* suspend response */
128 #define BTA_AV_PENDING_EVT                                                      \
129   16                                    /* incoming connection pending:         \
130                                          * signal channel is open and stream is \
131                                          * not open after                       \
132                                          * BTA_AV_SIGNALLING_TIMEOUT_MS */
133 #define BTA_AV_META_MSG_EVT 17          /* metadata messages */
134 #define BTA_AV_REJECT_EVT 18            /* incoming connection rejected */
135 #define BTA_AV_RC_FEAT_EVT 19           /* remote control channel peer supported features update */
136 #define BTA_AV_SINK_MEDIA_CFG_EVT 20    /* command to configure codec */
137 #define BTA_AV_SINK_MEDIA_DATA_EVT 21   /* sending data to Media Task */
138 #define BTA_AV_OFFLOAD_START_RSP_EVT 22 /* a2dp offload start response */
139 #define BTA_AV_RC_BROWSE_OPEN_EVT 23    /* remote control channel open */
140 #define BTA_AV_RC_BROWSE_CLOSE_EVT 24   /* remote control channel closed */
141 #define BTA_AV_RC_PSM_EVT 25            /* cover art psm update */
142 /* Max BTA event */
143 #define BTA_AV_MAX_EVT 26
144 
145 typedef uint8_t tBTA_AV_EVT;
146 
147 typedef enum {
148   BTA_AV_CODEC_TYPE_UNKNOWN = 0x00,
149   BTA_AV_CODEC_TYPE_SBC = 0x01,
150   BTA_AV_CODEC_TYPE_AAC = 0x02,
151   BTA_AV_CODEC_TYPE_APTX = 0x04,
152   BTA_AV_CODEC_TYPE_APTXHD = 0x08,
153   BTA_AV_CODEC_TYPE_LDAC = 0x10,
154   BTA_AV_CODEC_TYPE_OPUS = 0x20
155 } tBTA_AV_CODEC_TYPE;
156 
157 /* Event associated with BTA_AV_ENABLE_EVT */
158 typedef struct {
159   tBTA_AV_FEAT features;
160 } tBTA_AV_ENABLE;
161 
162 /* Event associated with BTA_AV_REGISTER_EVT */
163 typedef struct {
164   tBTA_AV_CHNL chnl; /* audio/video */
165   tBTA_AV_HNDL hndl; /* Handle associated with the stream. */
166   uint8_t app_id;    /* ID associated with call to BTA_AvRegister() */
167   tBTA_AV_STATUS status;
168   uint8_t peer_sep; /* peer sep type */
169 } tBTA_AV_REGISTER;
170 
171 /* data associated with BTA_AV_OPEN_EVT */
172 #define BTA_AV_EDR_2MBPS 0x01
173 #define BTA_AV_EDR_3MBPS 0x02
174 typedef uint8_t tBTA_AV_EDR;
175 
176 typedef struct {
177   tBTA_AV_CHNL chnl;
178   tBTA_AV_HNDL hndl;
179   RawAddress bd_addr;
180   tBTA_AV_STATUS status;
181   bool starting;
182   tBTA_AV_EDR edr; /* 0, if peer device does not support EDR */
183   uint8_t sep;     /*  sep type of peer device */
184 } tBTA_AV_OPEN;
185 
186 /* data associated with BTA_AV_CLOSE_EVT */
187 typedef struct {
188   tBTA_AV_CHNL chnl;
189   tBTA_AV_HNDL hndl;
190 } tBTA_AV_CLOSE;
191 
192 /* data associated with BTA_AV_START_EVT */
193 typedef struct {
194   tBTA_AV_CHNL chnl;
195   tBTA_AV_HNDL hndl;
196   tBTA_AV_STATUS status;
197   bool initiator; /* true, if local device initiates the START */
198   bool suspending;
199 } tBTA_AV_START;
200 
201 /* data associated with BTA_AV_SUSPEND_EVT, BTA_AV_STOP_EVT */
202 typedef struct {
203   tBTA_AV_CHNL chnl;
204   tBTA_AV_HNDL hndl;
205   bool initiator; /* true, if local device initiates the SUSPEND */
206   tBTA_AV_STATUS status;
207 } tBTA_AV_SUSPEND;
208 
209 /* data associated with BTA_AV_RECONFIG_EVT */
210 typedef struct {
211   tBTA_AV_CHNL chnl;
212   tBTA_AV_HNDL hndl;
213   tBTA_AV_STATUS status;
214 } tBTA_AV_RECONFIG;
215 
216 /* data associated with BTA_AV_PROTECT_REQ_EVT */
217 typedef struct {
218   tBTA_AV_CHNL chnl;
219   tBTA_AV_HNDL hndl;
220   uint8_t* p_data;
221   uint16_t len;
222 } tBTA_AV_PROTECT_REQ;
223 
224 /* data associated with BTA_AV_PROTECT_RSP_EVT */
225 typedef struct {
226   tBTA_AV_CHNL chnl;
227   tBTA_AV_HNDL hndl;
228   uint8_t* p_data;
229   uint16_t len;
230   tBTA_AV_ERR err_code;
231 } tBTA_AV_PROTECT_RSP;
232 
233 /* data associated with BTA_AV_RC_OPEN_EVT */
234 typedef struct {
235   uint8_t rc_handle;
236   uint16_t cover_art_psm;
237   tBTA_AV_FEAT peer_features;
238   tBTA_AV_FEAT peer_ct_features;
239   tBTA_AV_FEAT peer_tg_features;
240   RawAddress peer_addr;
241   tBTA_AV_STATUS status;
242 } tBTA_AV_RC_OPEN;
243 
244 /* data associated with BTA_AV_RC_CLOSE_EVT */
245 typedef struct {
246   uint8_t rc_handle;
247   RawAddress peer_addr;
248 } tBTA_AV_RC_CLOSE;
249 
250 /* data associated with BTA_AV_RC_BROWSE_OPEN_EVT */
251 typedef struct {
252   uint8_t rc_handle;
253   RawAddress peer_addr;
254   tBTA_AV_STATUS status;
255 } tBTA_AV_RC_BROWSE_OPEN;
256 
257 /* data associated with BTA_AV_RC_BROWSE_CLOSE_EVT */
258 typedef struct {
259   uint8_t rc_handle;
260   RawAddress peer_addr;
261 } tBTA_AV_RC_BROWSE_CLOSE;
262 
263 /* data associated with BTA_AV_RC_FEAT_EVT */
264 typedef struct {
265   uint8_t rc_handle;
266   tBTA_AV_FEAT peer_features;
267   tBTA_AV_FEAT peer_ct_features;
268   tBTA_AV_FEAT peer_tg_features;
269   RawAddress peer_addr;
270 } tBTA_AV_RC_FEAT;
271 
272 /* data associated with BTA_AV_RC_PSM_EVT */
273 typedef struct {
274   uint8_t rc_handle;
275   uint16_t cover_art_psm;
276   RawAddress peer_addr;
277 } tBTA_AV_RC_PSM;
278 
279 /* data associated with BTA_AV_REMOTE_CMD_EVT */
280 typedef struct {
281   uint8_t rc_handle;
282   tBTA_AV_RC rc_id;
283   tBTA_AV_STATE key_state;
284   uint8_t len;
285   uint8_t* p_data;
286   tAVRC_HDR hdr; /* Message header. */
287   uint8_t label;
288 } tBTA_AV_REMOTE_CMD;
289 
290 /* data associated with BTA_AV_REMOTE_RSP_EVT */
291 typedef struct {
292   uint8_t rc_handle;
293   tBTA_AV_RC rc_id;
294   tBTA_AV_STATE key_state;
295   uint8_t len;
296   uint8_t* p_data;
297   tBTA_AV_CODE rsp_code;
298   uint8_t label;
299 } tBTA_AV_REMOTE_RSP;
300 
301 /* data associated with BTA_AV_VENDOR_CMD_EVT, BTA_AV_VENDOR_RSP_EVT */
302 typedef struct {
303   uint8_t rc_handle;
304   uint16_t len; /* Max vendor dependent message is 512 */
305   uint8_t label;
306   tBTA_AV_CODE code;
307   uint32_t company_id;
308   uint8_t* p_data;
309 } tBTA_AV_VENDOR;
310 
311 /* data associated with BTA_AV_META_MSG_EVT */
312 typedef struct {
313   uint8_t rc_handle;
314   uint16_t len;
315   uint8_t label;
316   tBTA_AV_CODE code;
317   uint32_t company_id;
318   uint8_t* p_data;
319   tAVRC_MSG* p_msg;
320 } tBTA_AV_META_MSG;
321 
322 /* data associated with BTA_AV_PENDING_EVT */
323 typedef struct {
324   RawAddress bd_addr;
325 } tBTA_AV_PEND;
326 
327 /* data associated with BTA_AV_REJECT_EVT */
328 typedef struct {
329   RawAddress bd_addr;
330   tBTA_AV_HNDL hndl; /* Handle associated with the stream that rejected the
331                         connection. */
332 } tBTA_AV_REJECT;
333 
334 /* union of data associated with AV callback */
335 typedef union {
336   tBTA_AV_CHNL chnl;
337   tBTA_AV_ENABLE enable;
338   tBTA_AV_REGISTER reg;
339   tBTA_AV_OPEN open;
340   tBTA_AV_CLOSE close;
341   tBTA_AV_START start;
342   tBTA_AV_PROTECT_REQ protect_req;
343   tBTA_AV_PROTECT_RSP protect_rsp;
344   tBTA_AV_RC_OPEN rc_open;
345   tBTA_AV_RC_CLOSE rc_close;
346   tBTA_AV_RC_BROWSE_OPEN rc_browse_open;
347   tBTA_AV_RC_BROWSE_CLOSE rc_browse_close;
348   tBTA_AV_REMOTE_CMD remote_cmd;
349   tBTA_AV_REMOTE_RSP remote_rsp;
350   tBTA_AV_VENDOR vendor_cmd;
351   tBTA_AV_VENDOR vendor_rsp;
352   tBTA_AV_RECONFIG reconfig;
353   tBTA_AV_SUSPEND suspend;
354   tBTA_AV_PEND pend;
355   tBTA_AV_META_MSG meta_msg;
356   tBTA_AV_REJECT reject;
357   tBTA_AV_RC_FEAT rc_feat;
358   tBTA_AV_RC_PSM rc_cover_art_psm;
359   tBTA_AV_STATUS status;
360 } tBTA_AV;
361 
362 typedef struct {
363   uint8_t* codec_info;
364   RawAddress bd_addr;
365 } tBTA_AVK_CONFIG;
366 
367 /* union of data associated with AV Media callback */
368 typedef union {
369   BT_HDR* p_data;
370   tBTA_AVK_CONFIG avk_config;
371 } tBTA_AV_MEDIA;
372 
373 #define BTA_GROUP_NAVI_MSG_OP_DATA_LEN 5
374 
375 /* AV callback */
376 typedef void(tBTA_AV_CBACK)(tBTA_AV_EVT event, tBTA_AV* p_data);
377 typedef void(tBTA_AV_SINK_DATA_CBACK)(const RawAddress&, tBTA_AV_EVT event, tBTA_AV_MEDIA* p_data);
378 
379 /* type for stream state machine action functions */
380 struct tBTA_AV_SCB;
381 union tBTA_AV_DATA;
382 typedef void (*tBTA_AV_ACT)(tBTA_AV_SCB* p_cb, tBTA_AV_DATA* p_data);
383 
384 /* AV configuration structure */
385 typedef struct {
386   uint32_t company_id;           /* AVRCP Company ID */
387   uint16_t avrc_ct_cat;          /* AVRCP controller categories */
388   uint16_t avrc_tg_cat;          /* AVRCP target categories */
389   uint16_t audio_mqs;            /* AVDTP audio channel max data queue size */
390   bool avrc_group;               /* true, to accept AVRC 1.3 group nevigation command */
391   uint8_t num_co_ids;            /* company id count in p_meta_co_ids */
392   uint8_t num_evt_ids;           /* event id count in p_meta_evt_ids */
393   tBTA_AV_CODE rc_pass_rsp;      /* the default response code for pass through commands */
394   const uint32_t* p_meta_co_ids; /* the metadata Get Capabilities response for company id */
395   const uint8_t* p_meta_evt_ids; /* the the metadata Get Capabilities response
396                                     for event id */
397   char avrc_controller_name[BTA_SERVICE_NAME_LEN]; /* Default AVRCP controller
398                                                       name */
399   char avrc_target_name[BTA_SERVICE_NAME_LEN];     /* Default AVRCP target name*/
400 } tBTA_AV_CFG;
401 
402 /*****************************************************************************
403  *  External Function Declarations
404  ****************************************************************************/
405 
406 /*******************************************************************************
407  *
408  * Function         BTA_AvEnable
409  *
410  * Description      Enable the advanced audio/video service. When the enable
411  *                  operation is complete the callback function will be
412  *                  called with a BTA_AV_ENABLE_EVT. This function must
413  *                  be called before other function in the AV API are
414  *                  called.
415  *
416  * Returns          void
417  *
418  ******************************************************************************/
419 void BTA_AvEnable(tBTA_AV_FEAT features, tBTA_AV_CBACK* p_cback);
420 
421 /*******************************************************************************
422  *
423  * Function         BTA_AvDisable
424  *
425  * Description      Disable the advanced audio/video service.
426  *
427  *
428  * Returns          void
429  *
430  ******************************************************************************/
431 void BTA_AvDisable(void);
432 
433 /*******************************************************************************
434  *
435  * Function         BTA_AvRegister
436  *
437  * Description      Register the audio or video service to stack. When the
438  *                  operation is complete the callback function will be
439  *                  called with a BTA_AV_REGISTER_EVT. This function must
440  *                  be called before AVDT stream is open.
441  *
442  *
443  * Returns          void
444  *
445  ******************************************************************************/
446 void BTA_AvRegister(tBTA_AV_CHNL chnl, const char* p_service_name, uint8_t app_id,
447                     tBTA_AV_SINK_DATA_CBACK* p_sink_data_cback, uint16_t service_uuid);
448 
449 /*******************************************************************************
450  *
451  * Function         BTA_AvDeregister
452  *
453  * Description      Deregister the audio or video service
454  *
455  * Returns          void
456  *
457  ******************************************************************************/
458 void BTA_AvDeregister(tBTA_AV_HNDL hndl);
459 
460 /*******************************************************************************
461  *
462  * Function         BTA_AvOpen
463  *
464  * Description      Opens an advanced audio/video connection to a peer device.
465  *                  When connection is open callback function is called
466  *                  with a BTA_AV_OPEN_EVT.
467  *
468  * Returns          void
469  *
470  ******************************************************************************/
471 void BTA_AvOpen(const RawAddress& bd_addr, tBTA_AV_HNDL handle, bool use_rc, uint16_t uuid);
472 
473 /*******************************************************************************
474  *
475  * Function         BTA_AvClose
476  *
477  * Description      Close the current streams.
478  *
479  * Returns          void
480  *
481  ******************************************************************************/
482 void BTA_AvClose(tBTA_AV_HNDL handle);
483 
484 /*******************************************************************************
485  *
486  * Function         BTA_AvDisconnect
487  *
488  * Description      Close the connection to the address.
489  *
490  * Returns          void
491  *
492  ******************************************************************************/
493 void BTA_AvDisconnect(tBTA_AV_HNDL handle);
494 
495 /*******************************************************************************
496  *
497  * Function         BTA_AvStart
498  *
499  * Description      Start audio/video stream data transfer.
500  *
501  * Returns          void
502  *
503  ******************************************************************************/
504 void BTA_AvStart(tBTA_AV_HNDL handle, bool use_latency_mode);
505 
506 /*******************************************************************************
507  *
508  * Function         BTA_AvStop
509  *
510  * Description      Stop audio/video stream data transfer.
511  *                  If suspend is true, this function sends AVDT suspend signal
512  *                  to the connected peer(s).
513  *
514  * Returns          void
515  *
516  ******************************************************************************/
517 void BTA_AvStop(tBTA_AV_HNDL handle, bool suspend);
518 
519 /*******************************************************************************
520  *
521  * Function         BTA_AvReconfig
522  *
523  * Description      Reconfigure the audio/video stream.
524  *                  If suspend is true, this function tries the
525  *                  suspend/reconfigure procedure first.
526  *                  If suspend is false or when suspend/reconfigure fails,
527  *                  this function closes and re-opens the AVDT connection.
528  *
529  * Returns          void
530  *
531  ******************************************************************************/
532 void BTA_AvReconfig(tBTA_AV_HNDL hndl, bool suspend, uint8_t sep_info_idx, uint8_t* p_codec_info,
533                     uint8_t num_protect, const uint8_t* p_protect_info);
534 
535 /*******************************************************************************
536  *
537  * Function         BTA_AvProtectReq
538  *
539  * Description      Send a content protection request.  This function can only
540  *                  be used if AV is enabled with feature BTA_AV_FEAT_PROTECT.
541  *
542  * Returns          void
543  *
544  ******************************************************************************/
545 void BTA_AvProtectReq(tBTA_AV_HNDL hndl, uint8_t* p_data, uint16_t len);
546 
547 /*******************************************************************************
548  *
549  * Function         BTA_AvProtectRsp
550  *
551  * Description      Send a content protection response.  This function must
552  *                  be called if a BTA_AV_PROTECT_REQ_EVT is received.
553  *                  This function can only be used if AV is enabled with
554  *                  feature BTA_AV_FEAT_PROTECT.
555  *
556  * Returns          void
557  *
558  ******************************************************************************/
559 void BTA_AvProtectRsp(tBTA_AV_HNDL hndl, uint8_t error_code, uint8_t* p_data, uint16_t len);
560 
561 /*******************************************************************************
562  *
563  * Function         BTA_AvRemoteCmd
564  *
565  * Description      Send a remote control command.  This function can only
566  *                  be used if AV is enabled with feature BTA_AV_FEAT_RCCT.
567  *
568  * Returns          void
569  *
570  ******************************************************************************/
571 void BTA_AvRemoteCmd(uint8_t rc_handle, uint8_t label, tBTA_AV_RC rc_id, tBTA_AV_STATE key_state);
572 
573 /*******************************************************************************
574  *
575  * Function         BTA_AvRemoteVendorUniqueCmd
576  *
577  * Description      Send a remote control command with Vendor Unique rc_id.
578  *                  This function can only be used if AV is enabled with
579  *                  feature BTA_AV_FEAT_RCCT.
580  *
581  * Returns          void
582  *
583  ******************************************************************************/
584 void BTA_AvRemoteVendorUniqueCmd(uint8_t rc_handle, uint8_t label, tBTA_AV_STATE key_state,
585                                  uint8_t* p_msg, uint8_t buf_len);
586 
587 /*******************************************************************************
588  *
589  * Function         BTA_AvVendorCmd
590  *
591  * Description      Send a vendor dependent remote control command.  This
592  *                  function can only be used if AV is enabled with feature
593  *                  BTA_AV_FEAT_VENDOR.
594  *
595  * Returns          void
596  *
597  ******************************************************************************/
598 void BTA_AvVendorCmd(uint8_t rc_handle, uint8_t label, tBTA_AV_CODE cmd_code, uint8_t* p_data,
599                      uint16_t len);
600 
601 /*******************************************************************************
602  *
603  * Function         BTA_AvVendorRsp
604  *
605  * Description      Send a vendor dependent remote control response.
606  *                  This function must be called if a BTA_AV_VENDOR_CMD_EVT
607  *                  is received. This function can only be used if AV is
608  *                  enabled with feature BTA_AV_FEAT_VENDOR.
609  *
610  * Returns          void
611  *
612  ******************************************************************************/
613 void BTA_AvVendorRsp(uint8_t rc_handle, uint8_t label, tBTA_AV_CODE rsp_code, uint8_t* p_data,
614                      uint16_t len, uint32_t company_id);
615 
616 /*******************************************************************************
617  *
618  * Function         BTA_AvOpenRc
619  *
620  * Description      Open an AVRCP connection toward the device with the
621  *                  specified handle
622  *
623  * Returns          void
624  *
625  ******************************************************************************/
626 void BTA_AvOpenRc(tBTA_AV_HNDL handle);
627 
628 /*******************************************************************************
629  *
630  * Function         BTA_AvCloseRc
631  *
632  * Description      Close an AVRCP connection
633  *
634  * Returns          void
635  *
636  ******************************************************************************/
637 void BTA_AvCloseRc(uint8_t rc_handle);
638 
639 /*******************************************************************************
640  *
641  * Function         BTA_AvMetaRsp
642  *
643  * Description      Send a Metadata command/response. The message contained
644  *                  in p_pkt can be composed with AVRC utility functions.
645  *                  This function can only be used if AV is enabled with feature
646  *                  BTA_AV_FEAT_METADATA.
647  *
648  * Returns          void
649  *
650  ******************************************************************************/
651 void BTA_AvMetaRsp(uint8_t rc_handle, uint8_t label, tBTA_AV_CODE rsp_code, BT_HDR* p_pkt);
652 
653 /*******************************************************************************
654  *
655  * Function         BTA_AvMetaCmd
656  *
657  * Description      Send a Metadata/Advanced Control command. The message
658  *contained
659  *                  in p_pkt can be composed with AVRC utility functions.
660  *                  This function can only be used if AV is enabled with feature
661  *                  BTA_AV_FEAT_METADATA.
662  *                  This message is sent only when the peer supports the TG
663  *role.
664  *8                  The only command makes sense right now is the absolute
665  *volume command.
666  *
667  * Returns          void
668  *
669  ******************************************************************************/
670 void BTA_AvMetaCmd(uint8_t rc_handle, uint8_t label, tBTA_AV_CMD cmd_code, BT_HDR* p_pkt);
671 
672 /*******************************************************************************
673  *
674  * Function         BTA_AvSetLatency
675  *
676  * Description      Set audio/video stream latency.
677  *
678  * Returns          void
679  *
680  ******************************************************************************/
681 void BTA_AvSetLatency(tBTA_AV_HNDL handle, bool is_low_latency);
682 
683 /*******************************************************************************
684  *
685  * Function         BTA_AvOffloadStart
686  *
687  * Description      Request Starting of A2DP Offload.
688  *                  This function is used to start A2DP offload if vendor lib
689  *                  has the feature enabled.
690  *
691  * Returns          void
692  *
693  ******************************************************************************/
694 void BTA_AvOffloadStart(tBTA_AV_HNDL hndl);
695 
696 /**
697  * Obtain the Channel Index for a peer.
698  * If the peer already has associated internal state, the corresponding
699  * Channel Index for that state is returned. Otherwise, the Channel Index
700  * for unused internal state is returned instead.
701  *
702  * @param peer_address the peer address
703  * @return the peer Channel Index index if obtained, otherwise -1
704  */
705 int BTA_AvObtainPeerChannelIndex(const RawAddress& peer_address);
706 
707 /**
708  * Dump debug-related information for the BTA AV module.
709  *
710  * @param fd the file descriptor to use for writing the ASCII formatted
711  * information
712  */
713 void bta_debug_av_dump(int fd);
714 
715 /**
716  * Set peer sep in order to delete wrong avrcp handle
717  * there are may be two avrcp handle at start, delete the wrong when a2dp
718  * connected
719  *
720  * @param peer_address the peer address
721  * @param sep the peer sep
722  */
723 void BTA_AvSetPeerSep(const RawAddress& bdaddr, uint8_t sep);
724 
725 #endif /* BTA_AV_API_H */
726