• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright 2011-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 implementation of the API for the advanced audio/video (AV)
22  *  subsystem of BTA, Broadcom's Bluetooth application layer for mobile
23  *  phones.
24  *
25  ******************************************************************************/
26 
27 #define LOG_TAG "bt_bta_av"
28 
29 #include <base/logging.h>
30 
31 #include "bt_target.h"
32 
33 #include <string.h>
34 #include "bt_common.h"
35 #include "bta_api.h"
36 #include "bta_av_api.h"
37 #include "bta_av_int.h"
38 #include "bta_sys.h"
39 
40 #include "osi/include/allocator.h"
41 #include "osi/include/log.h"
42 
43 /*****************************************************************************
44  *  Constants
45  ****************************************************************************/
46 
47 static const tBTA_SYS_REG bta_av_reg = {bta_av_hdl_event, BTA_AvDisable};
48 
49 /*******************************************************************************
50  *
51  * Function         BTA_AvEnable
52  *
53  * Description      Enable the advanced audio/video service. When the enable
54  *                  operation is complete the callback function will be
55  *                  called with a BTA_AV_ENABLE_EVT. This function must
56  *                  be called before other function in the AV API are
57  *                  called.
58  *
59  * Returns          void
60  *
61  ******************************************************************************/
BTA_AvEnable(tBTA_SEC sec_mask,tBTA_AV_FEAT features,tBTA_AV_CBACK * p_cback)62 void BTA_AvEnable(tBTA_SEC sec_mask, tBTA_AV_FEAT features,
63                   tBTA_AV_CBACK* p_cback) {
64   tBTA_AV_API_ENABLE* p_buf =
65       (tBTA_AV_API_ENABLE*)osi_malloc(sizeof(tBTA_AV_API_ENABLE));
66 
67   /* register with BTA system manager */
68   bta_sys_register(BTA_ID_AV, &bta_av_reg);
69 
70   p_buf->hdr.event = BTA_AV_API_ENABLE_EVT;
71   p_buf->p_cback = p_cback;
72   p_buf->features = features;
73   p_buf->sec_mask = sec_mask;
74 
75   bta_sys_sendmsg(p_buf);
76 }
77 
78 /*******************************************************************************
79  *
80  * Function         BTA_AvDisable
81  *
82  * Description      Disable the advanced audio/video service.
83  *
84  * Returns          void
85  *
86  ******************************************************************************/
BTA_AvDisable(void)87 void BTA_AvDisable(void) {
88   BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR));
89 
90   bta_sys_deregister(BTA_ID_AV);
91   p_buf->event = BTA_AV_API_DISABLE_EVT;
92 
93   bta_sys_sendmsg(p_buf);
94 }
95 
96 /*******************************************************************************
97  *
98  * Function         BTA_AvRegister
99  *
100  * Description      Register the audio or video service to stack. When the
101  *                  operation is complete the callback function will be
102  *                  called with a BTA_AV_REGISTER_EVT. This function must
103  *                  be called before AVDT stream is open.
104  *
105  *
106  * Returns          void
107  *
108  ******************************************************************************/
BTA_AvRegister(tBTA_AV_CHNL chnl,const char * p_service_name,uint8_t app_id,tBTA_AV_SINK_DATA_CBACK * p_sink_data_cback,uint16_t service_uuid)109 void BTA_AvRegister(tBTA_AV_CHNL chnl, const char* p_service_name,
110                     uint8_t app_id, tBTA_AV_SINK_DATA_CBACK* p_sink_data_cback,
111                     uint16_t service_uuid) {
112   tBTA_AV_API_REG* p_buf =
113       (tBTA_AV_API_REG*)osi_malloc(sizeof(tBTA_AV_API_REG));
114 
115   p_buf->hdr.layer_specific = chnl;
116   p_buf->hdr.event = BTA_AV_API_REGISTER_EVT;
117   if (p_service_name)
118     strlcpy(p_buf->p_service_name, p_service_name, BTA_SERVICE_NAME_LEN);
119   else
120     p_buf->p_service_name[0] = 0;
121   p_buf->app_id = app_id;
122   p_buf->p_app_sink_data_cback = p_sink_data_cback;
123   p_buf->service_uuid = service_uuid;
124 
125   bta_sys_sendmsg(p_buf);
126 }
127 
128 /*******************************************************************************
129  *
130  * Function         BTA_AvDeregister
131  *
132  * Description      Deregister the audio or video service
133  *
134  * Returns          void
135  *
136  ******************************************************************************/
BTA_AvDeregister(tBTA_AV_HNDL hndl)137 void BTA_AvDeregister(tBTA_AV_HNDL hndl) {
138   BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR));
139 
140   p_buf->layer_specific = hndl;
141   p_buf->event = BTA_AV_API_DEREGISTER_EVT;
142 
143   bta_sys_sendmsg(p_buf);
144 }
145 
146 /*******************************************************************************
147  *
148  * Function         BTA_AvOpen
149  *
150  * Description      Opens an advanced audio/video connection to a peer device.
151  *                  When connection is open callback function is called
152  *                  with a BTA_AV_OPEN_EVT.
153  *
154  * Returns          void
155  *
156  ******************************************************************************/
BTA_AvOpen(const RawAddress & bd_addr,tBTA_AV_HNDL handle,bool use_rc,tBTA_SEC sec_mask,uint16_t uuid)157 void BTA_AvOpen(const RawAddress& bd_addr, tBTA_AV_HNDL handle, bool use_rc,
158                 tBTA_SEC sec_mask, uint16_t uuid) {
159   LOG_INFO(LOG_TAG,
160            "%s: peer %s bta_handle:0x%x use_rc=%s sec_mask=0x%x uuid=0x%x",
161            __func__, bd_addr.ToString().c_str(), handle,
162            (use_rc) ? "true" : "false", sec_mask, uuid);
163 
164   tBTA_AV_API_OPEN* p_buf =
165       (tBTA_AV_API_OPEN*)osi_malloc(sizeof(tBTA_AV_API_OPEN));
166 
167   p_buf->hdr.event = BTA_AV_API_OPEN_EVT;
168   p_buf->hdr.layer_specific = handle;
169   p_buf->bd_addr = bd_addr;
170   p_buf->use_rc = use_rc;
171   p_buf->sec_mask = sec_mask;
172   p_buf->switch_res = BTA_AV_RS_NONE;
173   p_buf->uuid = uuid;
174 
175   bta_sys_sendmsg(p_buf);
176 }
177 
178 /*******************************************************************************
179  *
180  * Function         BTA_AvClose
181  *
182  * Description      Close the current streams.
183  *
184  * Returns          void
185  *
186  ******************************************************************************/
BTA_AvClose(tBTA_AV_HNDL handle)187 void BTA_AvClose(tBTA_AV_HNDL handle) {
188   LOG_INFO(LOG_TAG, "%s: bta_handle:0x%x", __func__, handle);
189 
190   BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR));
191 
192   p_buf->event = BTA_AV_API_CLOSE_EVT;
193   p_buf->layer_specific = handle;
194 
195   bta_sys_sendmsg(p_buf);
196 }
197 
198 /*******************************************************************************
199  *
200  * Function         BTA_AvDisconnect
201  *
202  * Description      Close the connection to the address.
203  *
204  * Returns          void
205  *
206  ******************************************************************************/
BTA_AvDisconnect(const RawAddress & bd_addr)207 void BTA_AvDisconnect(const RawAddress& bd_addr) {
208   LOG_INFO(LOG_TAG, "%s: peer %s", __func__, bd_addr.ToString().c_str());
209 
210   tBTA_AV_API_DISCNT* p_buf =
211       (tBTA_AV_API_DISCNT*)osi_malloc(sizeof(tBTA_AV_API_DISCNT));
212 
213   p_buf->hdr.event = BTA_AV_API_DISCONNECT_EVT;
214   p_buf->bd_addr = bd_addr;
215 
216   bta_sys_sendmsg(p_buf);
217 }
218 
219 /*******************************************************************************
220  *
221  * Function         BTA_AvStart
222  *
223  * Description      Start audio/video stream data transfer.
224  *
225  * Returns          void
226  *
227  ******************************************************************************/
BTA_AvStart(tBTA_AV_HNDL handle)228 void BTA_AvStart(tBTA_AV_HNDL handle) {
229   LOG_INFO(LOG_TAG, "%s: bta_handle=0x%x", __func__, handle);
230 
231   BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR));
232 
233   p_buf->event = BTA_AV_API_START_EVT;
234   p_buf->layer_specific = handle;
235 
236   bta_sys_sendmsg(p_buf);
237 }
238 
239 /*******************************************************************************
240  *
241  * Function         BTA_AvOffloadStart
242  *
243  * Description      Start a2dp audio offloading.
244  *
245  * Returns          void
246  *
247  ******************************************************************************/
BTA_AvOffloadStart(tBTA_AV_HNDL hndl)248 void BTA_AvOffloadStart(tBTA_AV_HNDL hndl) {
249   LOG_INFO(LOG_TAG, "%s: bta_handle=0x%x", __func__, hndl);
250 
251   BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR));
252 
253   p_buf->event = BTA_AV_API_OFFLOAD_START_EVT;
254   p_buf->layer_specific = hndl;
255 
256   bta_sys_sendmsg(p_buf);
257 }
258 
259 /*******************************************************************************
260  *
261  * Function         BTA_AvOffloadStartRsp
262  *
263  * Description      Response from vendor lib for A2DP Offload Start request.
264  *
265  * Returns          void
266  *
267  ******************************************************************************/
BTA_AvOffloadStartRsp(tBTA_AV_HNDL hndl,tBTA_AV_STATUS status)268 void BTA_AvOffloadStartRsp(tBTA_AV_HNDL hndl, tBTA_AV_STATUS status) {
269   tBTA_AV_API_STATUS_RSP* p_buf =
270       (tBTA_AV_API_STATUS_RSP*)osi_malloc(sizeof(tBTA_AV_API_STATUS_RSP));
271 
272   p_buf->hdr.event = BTA_AV_API_OFFLOAD_START_RSP_EVT;
273   p_buf->hdr.layer_specific = hndl;
274   p_buf->status = status;
275 
276   bta_sys_sendmsg(p_buf);
277 }
278 
279 /*******************************************************************************
280  *
281  * Function         BTA_AvStop
282  *
283  * Description      Stop audio/video stream data transfer.
284  *                  If suspend is true, this function sends AVDT suspend signal
285  *                  to the connected peer(s).
286  *
287  * Returns          void
288  *
289  ******************************************************************************/
BTA_AvStop(tBTA_AV_HNDL handle,bool suspend)290 void BTA_AvStop(tBTA_AV_HNDL handle, bool suspend) {
291   LOG_INFO(LOG_TAG, "%s: bta_handle=0x%x suspend=%s", __func__, handle,
292            logbool(suspend).c_str());
293 
294   tBTA_AV_API_STOP* p_buf =
295       (tBTA_AV_API_STOP*)osi_malloc(sizeof(tBTA_AV_API_STOP));
296 
297   p_buf->hdr.event = BTA_AV_API_STOP_EVT;
298   p_buf->hdr.layer_specific = handle;
299   p_buf->flush = true;
300   p_buf->suspend = suspend;
301   p_buf->reconfig_stop = false;
302 
303   bta_sys_sendmsg(p_buf);
304 }
305 
306 /*******************************************************************************
307  *
308  * Function         BTA_AvReconfig
309  *
310  * Description      Reconfigure the audio/video stream.
311  *                  If suspend is true, this function tries the
312  *                  suspend/reconfigure procedure first.
313  *                  If suspend is false or when suspend/reconfigure fails,
314  *                  this function closes and re-opens the AVDT connection.
315  *
316  * Returns          void
317  *
318  ******************************************************************************/
BTA_AvReconfig(tBTA_AV_HNDL hndl,bool suspend,uint8_t sep_info_idx,uint8_t * p_codec_info,uint8_t num_protect,const uint8_t * p_protect_info)319 void BTA_AvReconfig(tBTA_AV_HNDL hndl, bool suspend, uint8_t sep_info_idx,
320                     uint8_t* p_codec_info, uint8_t num_protect,
321                     const uint8_t* p_protect_info) {
322   LOG_INFO(LOG_TAG, "%s: bta_handle=0x%x suspend=%s sep_info_idx=%d", __func__,
323            hndl, logbool(suspend).c_str(), sep_info_idx);
324 
325   tBTA_AV_API_RCFG* p_buf =
326       (tBTA_AV_API_RCFG*)osi_malloc(sizeof(tBTA_AV_API_RCFG) + num_protect);
327 
328   p_buf->hdr.layer_specific = hndl;
329   p_buf->hdr.event = BTA_AV_API_RECONFIG_EVT;
330   p_buf->num_protect = num_protect;
331   p_buf->suspend = suspend;
332   p_buf->sep_info_idx = sep_info_idx;
333   p_buf->p_protect_info = (uint8_t*)(p_buf + 1);
334   memcpy(p_buf->codec_info, p_codec_info, AVDT_CODEC_SIZE);
335   memcpy(p_buf->p_protect_info, p_protect_info, num_protect);
336 
337   bta_sys_sendmsg(p_buf);
338 }
339 
340 /*******************************************************************************
341  *
342  * Function         BTA_AvProtectReq
343  *
344  * Description      Send a content protection request.  This function can only
345  *                  be used if AV is enabled with feature BTA_AV_FEAT_PROTECT.
346  *
347  * Returns          void
348  *
349  ******************************************************************************/
BTA_AvProtectReq(tBTA_AV_HNDL hndl,uint8_t * p_data,uint16_t len)350 void BTA_AvProtectReq(tBTA_AV_HNDL hndl, uint8_t* p_data, uint16_t len) {
351   tBTA_AV_API_PROTECT_REQ* p_buf = (tBTA_AV_API_PROTECT_REQ*)osi_malloc(
352       sizeof(tBTA_AV_API_PROTECT_REQ) + len);
353 
354   p_buf->hdr.layer_specific = hndl;
355   p_buf->hdr.event = BTA_AV_API_PROTECT_REQ_EVT;
356   p_buf->len = len;
357   if (p_data == NULL) {
358     p_buf->p_data = NULL;
359   } else {
360     p_buf->p_data = (uint8_t*)(p_buf + 1);
361     memcpy(p_buf->p_data, p_data, len);
362   }
363 
364   bta_sys_sendmsg(p_buf);
365 }
366 
367 /*******************************************************************************
368  *
369  * Function         BTA_AvProtectRsp
370  *
371  * Description      Send a content protection response.  This function must
372  *                  be called if a BTA_AV_PROTECT_REQ_EVT is received.
373  *                  This function can only be used if AV is enabled with
374  *                  feature BTA_AV_FEAT_PROTECT.
375  *
376  * Returns          void
377  *
378  ******************************************************************************/
BTA_AvProtectRsp(tBTA_AV_HNDL hndl,uint8_t error_code,uint8_t * p_data,uint16_t len)379 void BTA_AvProtectRsp(tBTA_AV_HNDL hndl, uint8_t error_code, uint8_t* p_data,
380                       uint16_t len) {
381   tBTA_AV_API_PROTECT_RSP* p_buf = (tBTA_AV_API_PROTECT_RSP*)osi_malloc(
382       sizeof(tBTA_AV_API_PROTECT_RSP) + len);
383 
384   p_buf->hdr.layer_specific = hndl;
385   p_buf->hdr.event = BTA_AV_API_PROTECT_RSP_EVT;
386   p_buf->len = len;
387   p_buf->error_code = error_code;
388   if (p_data == NULL) {
389     p_buf->p_data = NULL;
390   } else {
391     p_buf->p_data = (uint8_t*)(p_buf + 1);
392     memcpy(p_buf->p_data, p_data, len);
393   }
394 
395   bta_sys_sendmsg(p_buf);
396 }
397 
398 /*******************************************************************************
399  *
400  * Function         BTA_AvRemoteCmd
401  *
402  * Description      Send a remote control command.  This function can only
403  *                  be used if AV is enabled with feature BTA_AV_FEAT_RCCT.
404  *
405  * Returns          void
406  *
407  ******************************************************************************/
BTA_AvRemoteCmd(uint8_t rc_handle,uint8_t label,tBTA_AV_RC rc_id,tBTA_AV_STATE key_state)408 void BTA_AvRemoteCmd(uint8_t rc_handle, uint8_t label, tBTA_AV_RC rc_id,
409                      tBTA_AV_STATE key_state) {
410   tBTA_AV_API_REMOTE_CMD* p_buf =
411       (tBTA_AV_API_REMOTE_CMD*)osi_malloc(sizeof(tBTA_AV_API_REMOTE_CMD));
412 
413   p_buf->hdr.event = BTA_AV_API_REMOTE_CMD_EVT;
414   p_buf->hdr.layer_specific = rc_handle;
415   p_buf->msg.op_id = rc_id;
416   p_buf->msg.state = key_state;
417   p_buf->msg.p_pass_data = NULL;
418   p_buf->msg.pass_len = 0;
419   p_buf->label = label;
420 
421   bta_sys_sendmsg(p_buf);
422 }
423 
424 /*******************************************************************************
425  *
426  * Function         BTA_AvRemoteVendorUniqueCmd
427  *
428  * Description      Send a remote control command with Vendor Unique rc_id.
429  *                  This function can only be used if AV is enabled with
430  *                  feature BTA_AV_FEAT_RCCT.
431  *
432  * Returns          void
433  *
434  ******************************************************************************/
BTA_AvRemoteVendorUniqueCmd(uint8_t rc_handle,uint8_t label,tBTA_AV_STATE key_state,uint8_t * p_msg,uint8_t buf_len)435 void BTA_AvRemoteVendorUniqueCmd(uint8_t rc_handle, uint8_t label,
436                                  tBTA_AV_STATE key_state, uint8_t* p_msg,
437                                  uint8_t buf_len) {
438   tBTA_AV_API_REMOTE_CMD* p_buf = (tBTA_AV_API_REMOTE_CMD*)osi_malloc(
439       sizeof(tBTA_AV_API_REMOTE_CMD) + buf_len);
440 
441   p_buf->label = label;
442   p_buf->hdr.event = BTA_AV_API_REMOTE_CMD_EVT;
443   p_buf->hdr.layer_specific = rc_handle;
444   p_buf->msg.op_id = AVRC_ID_VENDOR;
445   p_buf->msg.state = key_state;
446   p_buf->msg.pass_len = buf_len;
447   if (p_msg == NULL) {
448     p_buf->msg.p_pass_data = NULL;
449   } else {
450     p_buf->msg.p_pass_data = (uint8_t*)(p_buf + 1);
451     memcpy(p_buf->msg.p_pass_data, p_msg, buf_len);
452   }
453   bta_sys_sendmsg(p_buf);
454 }
455 
456 /*******************************************************************************
457  *
458  * Function         BTA_AvVendorCmd
459  *
460  * Description      Send a vendor dependent remote control command.  This
461  *                  function can only be used if AV is enabled with feature
462  *                  BTA_AV_FEAT_VENDOR.
463  *
464  * Returns          void
465  *
466  ******************************************************************************/
BTA_AvVendorCmd(uint8_t rc_handle,uint8_t label,tBTA_AV_CODE cmd_code,uint8_t * p_data,uint16_t len)467 void BTA_AvVendorCmd(uint8_t rc_handle, uint8_t label, tBTA_AV_CODE cmd_code,
468                      uint8_t* p_data, uint16_t len) {
469   tBTA_AV_API_VENDOR* p_buf =
470       (tBTA_AV_API_VENDOR*)osi_malloc(sizeof(tBTA_AV_API_VENDOR) + len);
471 
472   p_buf->hdr.event = BTA_AV_API_VENDOR_CMD_EVT;
473   p_buf->hdr.layer_specific = rc_handle;
474   p_buf->msg.hdr.ctype = cmd_code;
475   p_buf->msg.hdr.subunit_type = AVRC_SUB_PANEL;
476   p_buf->msg.hdr.subunit_id = 0;
477   p_buf->msg.company_id = p_bta_av_cfg->company_id;
478   p_buf->label = label;
479   p_buf->msg.vendor_len = len;
480   if (p_data == NULL) {
481     p_buf->msg.p_vendor_data = NULL;
482   } else {
483     p_buf->msg.p_vendor_data = (uint8_t*)(p_buf + 1);
484     memcpy(p_buf->msg.p_vendor_data, p_data, len);
485   }
486 
487   bta_sys_sendmsg(p_buf);
488 }
489 
490 /*******************************************************************************
491  *
492  * Function         BTA_AvVendorRsp
493  *
494  * Description      Send a vendor dependent remote control response.
495  *                  This function must be called if a BTA_AV_VENDOR_CMD_EVT
496  *                  is received. This function can only be used if AV is
497  *                  enabled with feature BTA_AV_FEAT_VENDOR.
498  *
499  * Returns          void
500  *
501  ******************************************************************************/
BTA_AvVendorRsp(uint8_t rc_handle,uint8_t label,tBTA_AV_CODE rsp_code,uint8_t * p_data,uint16_t len,uint32_t company_id)502 void BTA_AvVendorRsp(uint8_t rc_handle, uint8_t label, tBTA_AV_CODE rsp_code,
503                      uint8_t* p_data, uint16_t len, uint32_t company_id) {
504   tBTA_AV_API_VENDOR* p_buf =
505       (tBTA_AV_API_VENDOR*)osi_malloc(sizeof(tBTA_AV_API_VENDOR) + len);
506 
507   p_buf->hdr.event = BTA_AV_API_VENDOR_RSP_EVT;
508   p_buf->hdr.layer_specific = rc_handle;
509   p_buf->msg.hdr.ctype = rsp_code;
510   p_buf->msg.hdr.subunit_type = AVRC_SUB_PANEL;
511   p_buf->msg.hdr.subunit_id = 0;
512   if (company_id)
513     p_buf->msg.company_id = company_id;
514   else
515     p_buf->msg.company_id = p_bta_av_cfg->company_id;
516   p_buf->label = label;
517   p_buf->msg.vendor_len = len;
518   if (p_data == NULL) {
519     p_buf->msg.p_vendor_data = NULL;
520   } else {
521     p_buf->msg.p_vendor_data = (uint8_t*)(p_buf + 1);
522     memcpy(p_buf->msg.p_vendor_data, p_data, len);
523   }
524 
525   bta_sys_sendmsg(p_buf);
526 }
527 
528 /*******************************************************************************
529  *
530  * Function         BTA_AvOpenRc
531  *
532  * Description      Open an AVRCP connection toward the device with the
533  *                  specified handle
534  *
535  * Returns          void
536  *
537  ******************************************************************************/
BTA_AvOpenRc(tBTA_AV_HNDL handle)538 void BTA_AvOpenRc(tBTA_AV_HNDL handle) {
539   tBTA_AV_API_OPEN_RC* p_buf =
540       (tBTA_AV_API_OPEN_RC*)osi_malloc(sizeof(tBTA_AV_API_OPEN_RC));
541 
542   p_buf->hdr.event = BTA_AV_API_RC_OPEN_EVT;
543   p_buf->hdr.layer_specific = handle;
544 
545   bta_sys_sendmsg(p_buf);
546 }
547 
548 /*******************************************************************************
549  *
550  * Function         BTA_AvCloseRc
551  *
552  * Description      Close an AVRCP connection
553  *
554  * Returns          void
555  *
556  ******************************************************************************/
BTA_AvCloseRc(uint8_t rc_handle)557 void BTA_AvCloseRc(uint8_t rc_handle) {
558   tBTA_AV_API_CLOSE_RC* p_buf =
559       (tBTA_AV_API_CLOSE_RC*)osi_malloc(sizeof(tBTA_AV_API_CLOSE_RC));
560 
561   p_buf->hdr.event = BTA_AV_API_RC_CLOSE_EVT;
562   p_buf->hdr.layer_specific = rc_handle;
563 
564   bta_sys_sendmsg(p_buf);
565 }
566 
567 /*******************************************************************************
568  *
569  * Function         BTA_AvMetaRsp
570  *
571  * Description      Send a Metadata/Advanced Control response. The message
572  *                  contained in p_pkt can be composed with AVRC utility
573  *                  functions.
574  *                  This function can only be used if AV is enabled with feature
575  *                  BTA_AV_FEAT_METADATA.
576  *
577  * Returns          void
578  *
579  ******************************************************************************/
BTA_AvMetaRsp(uint8_t rc_handle,uint8_t label,tBTA_AV_CODE rsp_code,BT_HDR * p_pkt)580 void BTA_AvMetaRsp(uint8_t rc_handle, uint8_t label, tBTA_AV_CODE rsp_code,
581                    BT_HDR* p_pkt) {
582   tBTA_AV_API_META_RSP* p_buf =
583       (tBTA_AV_API_META_RSP*)osi_malloc(sizeof(tBTA_AV_API_META_RSP));
584 
585   p_buf->hdr.event = BTA_AV_API_META_RSP_EVT;
586   p_buf->hdr.layer_specific = rc_handle;
587   p_buf->rsp_code = rsp_code;
588   p_buf->p_pkt = p_pkt;
589   p_buf->is_rsp = true;
590   p_buf->label = label;
591 
592   bta_sys_sendmsg(p_buf);
593 }
594 
595 /*******************************************************************************
596  *
597  * Function         BTA_AvMetaCmd
598  *
599  * Description      Send a Metadata/Advanced Control command. The message
600 *contained
601  *                  in p_pkt can be composed with AVRC utility functions.
602  *                  This function can only be used if AV is enabled with feature
603  *                  BTA_AV_FEAT_METADATA.
604  *                  This message is sent only when the peer supports the TG
605 *role.
606 *8                  The only command makes sense right now is the absolute
607 *volume command.
608  *
609  * Returns          void
610  *
611  ******************************************************************************/
BTA_AvMetaCmd(uint8_t rc_handle,uint8_t label,tBTA_AV_CMD cmd_code,BT_HDR * p_pkt)612 void BTA_AvMetaCmd(uint8_t rc_handle, uint8_t label, tBTA_AV_CMD cmd_code,
613                    BT_HDR* p_pkt) {
614   tBTA_AV_API_META_RSP* p_buf =
615       (tBTA_AV_API_META_RSP*)osi_malloc(sizeof(tBTA_AV_API_META_RSP));
616 
617   p_buf->hdr.event = BTA_AV_API_META_RSP_EVT;
618   p_buf->hdr.layer_specific = rc_handle;
619   p_buf->p_pkt = p_pkt;
620   p_buf->rsp_code = cmd_code;
621   p_buf->is_rsp = false;
622   p_buf->label = label;
623 
624   bta_sys_sendmsg(p_buf);
625 }
626