• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright 2006-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  *  nterface to AVRCP Application Programming Interface
22  *
23  ******************************************************************************/
24 #ifndef AVRC_API_H
25 #define AVRC_API_H
26 
27 #include <base/callback.h>
28 
29 #include <cstdint>
30 
31 #include "bt_target.h"
32 #include "stack/include/avct_api.h"
33 #include "stack/include/avrc_defs.h"
34 #include "stack/include/bt_hdr.h"
35 #include "stack/include/sdp_api.h"
36 #include "types/raw_address.h"
37 
38 /*****************************************************************************
39  *  constants
40  ****************************************************************************/
41 
42 /* API function return value result codes. */
43 /* 0 Function successful */
44 #define AVRC_SUCCESS AVCT_SUCCESS
45 /* 1 Not enough resources */
46 #define AVRC_NO_RESOURCES AVCT_NO_RESOURCES
47 /* 2 Bad handle */
48 #define AVRC_BAD_HANDLE AVCT_BAD_HANDLE
49 /* 3 PID already in use */
50 #define AVRC_PID_IN_USE AVCT_PID_IN_USE
51 /* 4 Connection not open */
52 #define AVRC_NOT_OPEN AVCT_NOT_OPEN
53 /* 5 the message length exceed the MTU of the browsing channel */
54 #define AVRC_MSG_TOO_BIG 5
55 /* 0x10 generic failure */
56 #define AVRC_FAIL 0x10
57 /* 0x11 bad parameter   */
58 #define AVRC_BAD_PARAM 0x11
59 
60 /* Control role - same as AVCT_TARGET/AVCT_CONTROL */
61 /* target  */
62 #define AVRC_CT_TARGET 1
63 /* controller  */
64 #define AVRC_CT_CONTROL 2
65 /* If conflict, allow the other side to succeed  */
66 #define AVRC_CT_PASSIVE 4
67 
68 /* Connection role */
69 /* initiator */
70 #define AVRC_CONN_INT AVCT_INT
71 /* Acceptor  */
72 #define AVRC_CONN_ACP AVCT_ACP
73 
74 /* AVRC CTRL events */
75 /* AVRC_OPEN_IND_EVT event is sent when the connection is successfully opened.
76  * This eventis sent in response to an AVRC_Open(). */
77 #define AVRC_OPEN_IND_EVT 0
78 
79 /* AVRC_CLOSE_IND_EVT event is sent when a connection is closed.
80  * This event can result from a call to AVRC_Close() or when the peer closes
81  * the connection.  It is also sent when a connection attempted through
82  * AVRC_Open() fails. */
83 #define AVRC_CLOSE_IND_EVT 1
84 
85 /* AVRC_CONG_IND_EVT event indicates that AVCTP is congested and cannot send
86  * any more messages. */
87 #define AVRC_CONG_IND_EVT 2
88 
89 /* AVRC_UNCONG_IND_EVT event indicates that AVCTP is uncongested and ready to
90  * send messages. */
91 #define AVRC_UNCONG_IND_EVT 3
92 
93 /* AVRC_BROWSE_OPEN_IND_EVT event is sent when the browse channel is
94 * successfully opened.
95 * This eventis sent in response to an AVRC_Open() or AVRC_OpenBrowse() . */
96 #define AVRC_BROWSE_OPEN_IND_EVT 4
97 
98 /* AVRC_BROWSE_CLOSE_IND_EVT event is sent when a browse channel is closed.
99  * This event can result from a call to AVRC_Close(), AVRC_CloseBrowse() or
100  * when the peer closes the connection.  It is also sent when a connection
101  * attempted through AVRC_OpenBrowse() fails. */
102 #define AVRC_BROWSE_CLOSE_IND_EVT 5
103 
104 /* AVRC_BROWSE_CONG_IND_EVT event indicates that AVCTP browse channel is
105  * congested and cannot send any more messages. */
106 #define AVRC_BROWSE_CONG_IND_EVT 6
107 
108 /* AVRC_BROWSE_UNCONG_IND_EVT event indicates that AVCTP browse channel is
109  * uncongested and ready to send messages. */
110 #define AVRC_BROWSE_UNCONG_IND_EVT 7
111 
112 /* AVRC_CMD_TIMEOUT_EVT event indicates timeout waiting for AVRC command
113  * response from the peer */
114 #define AVRC_CMD_TIMEOUT_EVT 8
115 
116 /* Configurable avrcp version key and constant values */
117 #ifndef AVRC_VERSION_PROPERTY
118 #define AVRC_VERSION_PROPERTY "persist.bluetooth.avrcpversion"
119 #endif
120 
121 #ifndef AVRC_1_6_STRING
122 #define AVRC_1_6_STRING "avrcp16"
123 #endif
124 
125 #ifndef AVRC_1_5_STRING
126 #define AVRC_1_5_STRING "avrcp15"
127 #endif
128 
129 #ifndef AVRC_1_4_STRING
130 #define AVRC_1_4_STRING "avrcp14"
131 #endif
132 
133 #ifndef AVRC_1_3_STRING
134 #define AVRC_1_3_STRING "avrcp13"
135 #endif
136 
137 #ifndef AVRC_DEFAULT_VERSION
138 #define AVRC_DEFAULT_VERSION AVRC_1_5_STRING
139 #endif
140 
141 /* Configurable dynamic avrcp version enable key*/
142 #ifndef AVRC_DYNAMIC_AVRCP_ENABLE_PROPERTY
143 #define AVRC_DYNAMIC_AVRCP_ENABLE_PROPERTY \
144   "persist.bluetooth.dynamic_avrcp.enable"
145 #endif
146 
147 /* Avrcp controller version key for bt_config.conf */
148 #ifndef AVRCP_CONTROLLER_VERSION_CONFIG_KEY
149 #define AVRCP_CONTROLLER_VERSION_CONFIG_KEY "AvrcpControllerVersion"
150 #endif
151 
152 /* Supported categories */
153 #define AVRC_SUPF_CT_CAT1 0x0001         /* Category 1 */
154 #define AVRC_SUPF_CT_CAT2 0x0002         /* Category 2 */
155 #define AVRC_SUPF_CT_CAT3 0x0004         /* Category 3 */
156 #define AVRC_SUPF_CT_CAT4 0x0008         /* Category 4 */
157 #define AVRC_SUPF_CT_APP_SETTINGS 0x0010 /* Player Application Settings */
158 #define AVRC_SUPF_CT_GROUP_NAVI 0x0020   /* Group Navigation */
159 #define AVRC_SUPF_CT_BROWSE 0x0040       /* Browsing */
160 
161 /* Cover Art, get image property */
162 #define AVRC_SUPF_CT_COVER_ART_GET_IMAGE_PROP 0x0080
163 /* Cover Art, get image */
164 #define AVRC_SUPF_CT_COVER_ART_GET_IMAGE 0x0100
165 /* Cover Art, get Linked Thumbnail */
166 #define AVRC_SUPF_CT_COVER_ART_GET_THUMBNAIL 0x0200
167 
168 #define AVRC_SUPF_TG_CAT1 0x0001             /* Category 1 */
169 #define AVRC_SUPF_TG_CAT2 0x0002             /* Category 2 */
170 #define AVRC_SUPF_TG_CAT3 0x0004             /* Category 3 */
171 #define AVRC_SUPF_TG_CAT4 0x0008             /* Category 4 */
172 #define AVRC_SUPF_TG_APP_SETTINGS 0x0010     /* Player Application Settings */
173 #define AVRC_SUPF_TG_GROUP_NAVI 0x0020       /* Group Navigation */
174 #define AVRC_SUPF_TG_BROWSE 0x0040           /* Browsing */
175 #define AVRC_SUPF_TG_MULTI_PLAYER 0x0080     /* Muliple Media Player */
176 #define AVRC_SUPF_TG_PLAYER_COVER_ART 0x0100 /* Cover Art */
177 
178 #define AVRC_META_SUCCESS AVRC_SUCCESS
179 #define AVRC_META_FAIL AVRC_FAIL
180 #define AVRC_METADATA_CMD 0x0000
181 #define AVRC_METADATA_RESP 0x0001
182 
183 /*****************************************************************************
184  *  data type definitions
185  ****************************************************************************/
186 
187 /* This data type is used in AVRC_FindService() to initialize the SDP database
188  * to hold the result service search. */
189 typedef struct {
190   uint32_t db_len;         /* Length, in bytes, of the discovery database */
191   tSDP_DISCOVERY_DB* p_db; /* Pointer to the discovery database */
192   uint16_t num_attr;       /* The number of attributes in p_attrs */
193   uint16_t* p_attrs;       /* The attributes filter. If NULL, AVRCP API sets the
194                             * attribute filter
195                             * to be ATTR_ID_SERVICE_CLASS_ID_LIST,
196                             * ATTR_ID_BT_PROFILE_DESC_LIST,
197                             * ATTR_ID_SUPPORTED_FEATURES, ATTR_ID_SERVICE_NAME and
198                             * ATTR_ID_PROVIDER_NAME.
199                             * If not NULL, the input is taken as the filter. */
200 } tAVRC_SDP_DB_PARAMS;
201 
202 /* This callback function returns service discovery information to the
203  * application after the AVRC_FindService() API function is called.  The
204  * implementation of this callback function must copy the p_service_name
205  * and p_provider_name parameters passed to it as they are not guaranteed
206  * to remain after the callback function exits. */
207 using tAVRC_FIND_CBACK = base::Callback<void(uint16_t status)>;
208 
209 /* This is the control callback function.  This function passes events
210  * listed in Table 20 to the application. */
211 using tAVRC_CTRL_CBACK =
212     base::Callback<void(uint8_t handle, uint8_t event, uint16_t result,
213                         const RawAddress* peer_addr)>;
214 
215 /* This is the message callback function.  It is executed when AVCTP has
216  * a message packet ready for the application.  The implementation of this
217  * callback function must copy the tAVRC_MSG structure passed to it as it
218  * is not guaranteed to remain after the callback function exits. */
219 using tAVRC_MSG_CBACK = base::Callback<void(uint8_t handle, uint8_t label,
220                                             uint8_t opcode, tAVRC_MSG* p_msg)>;
221 
222 typedef struct {
223   tAVRC_CTRL_CBACK ctrl_cback;    /* application control callback */
224   tAVRC_MSG_CBACK msg_cback;      /* application message callback */
225   uint32_t company_id;            /* the company ID  */
226   uint8_t conn;                   /* Connection role (Initiator/acceptor) */
227   uint8_t control;                /* Control role (Control/Target) */
228 } tAVRC_CONN_CB;
229 
230 typedef struct {
231   uint8_t handle;
232   uint8_t label;
233   uint8_t msg_mask;
234 } tAVRC_PARAM;
235 
236 /*****************************************************************************
237  *  external function declarations
238  ****************************************************************************/
239 /******************************************************************************
240  *
241  * Function         avrcp_absolute_volume_is_enabled
242  *
243  * Description      Check if config support advance control (absolute volume)
244  *
245  * Returns          return true if absolute_volume is enabled
246  *
247  *****************************************************************************/
248 bool avrcp_absolute_volume_is_enabled();
249 
250 /******************************************************************************
251  *
252  * Function         ARVC_GetProfileVersion
253  *
254  * Description      Get the user assigned AVRCP profile version
255  *
256  * Returns          The AVRCP profile version
257  *
258  *****************************************************************************/
259 extern uint16_t AVRC_GetProfileVersion();
260 
261 /******************************************************************************
262  *
263  * Function         AVRC_AddRecord
264  *
265  * Description      This function is called to build an AVRCP SDP record.
266  *                  Prior to calling this function the application must
267  *                  call SDP_CreateRecord() to create an SDP record.
268  *
269  *                  Input Parameters:
270  *                      service_uuid:  Indicates
271  *                                       TG(UUID_SERVCLASS_AV_REM_CTRL_TARGET)
272  *                                    or CT(UUID_SERVCLASS_AV_REMOTE_CONTROL)
273  *
274  *                      p_service_name:  Pointer to a null-terminated character
275  *                      string containing the service name.
276  *                      If service name is not used set this to NULL.
277  *
278  *                      p_provider_name:  Pointer to a null-terminated character
279  *                      string containing the provider name.
280  *                      If provider name is not used set this to NULL.
281  *
282  *                      categories:  Supported categories.
283  *
284  *                      sdp_handle:  SDP handle returned by SDP_CreateRecord().
285  *
286  *                      browse_supported:  browse support info.
287  *
288  *                      profile_version:  profile version of avrcp record.
289  *
290  *                      cover_art_psm: The PSM of a cover art service, if
291  *                      supported. Use 0 Otherwise. Ignored on controller
292  *
293  *                  Output Parameters:
294  *                      None.
295  *
296  * Returns          AVRC_SUCCESS if successful.
297  *                  AVRC_NO_RESOURCES if not enough resources to build the SDP
298  *                                    record.
299  *
300  *****************************************************************************/
301 extern uint16_t AVRC_AddRecord(uint16_t service_uuid,
302                                const char* p_service_name,
303                                const char* p_provider_name, uint16_t categories,
304                                uint32_t sdp_handle, bool browse_supported,
305                                uint16_t profile_version,
306                                uint16_t cover_art_psm);
307 
308 /*******************************************************************************
309  *
310  * Function          AVRC_RemoveRecord
311  *
312  * Description       This function is called to remove an AVRCP SDP record.
313  *
314  *                   Input Parameters:
315  *                       sdp_handle:  Handle you used with AVRC_AddRecord
316  *
317  * Returns           AVRC_SUCCESS if successful.
318  *                   AVRC_FAIL otherwise
319  *
320  *******************************************************************************/
321 extern uint16_t AVRC_RemoveRecord(uint32_t sdp_handle);
322 
323 /******************************************************************************
324  *
325  * Function         AVRC_FindService
326  *
327  * Description      This function is called by the application to perform
328  *                  service discovery and retrieve AVRCP SDP record information
329  *                  from a peer device.  Information is returned for the first
330  *                  service record found on the server that matches the service
331  *                  UUID. The callback function will be executed when service
332  *                  discovery is complete.  There can only be one outstanding
333  *                  call to AVRC_FindService() at a time; the application must
334  *                  wait for the callback before it makes another call to the
335  *                  function. The application is responsible for allocating
336  *                  memory for the discovery database.  It is recommended that
337  *                  the size of the discovery database be at least 300 bytes.
338  *                  The application can deallocate the memory after the
339  *                  callback function has executed.
340  *
341  *                  Input Parameters:
342  *                      service_uuid: Indicates
343  *                                       TG(UUID_SERVCLASS_AV_REM_CTRL_TARGET)
344  *                                    or CT(UUID_SERVCLASS_AV_REMOTE_CONTROL)
345  *
346  *                      bd_addr:  BD address of the peer device.
347  *
348  *                      p_db:  SDP discovery database parameters.
349  *
350  *                      p_cback:  Pointer to the callback function.
351  *
352  *                  Output Parameters:
353  *                      None.
354  *
355  * Returns          AVRC_SUCCESS if successful.
356  *                  AVRC_BAD_PARAMS if discovery database parameters are
357  *                                  invalid.
358  *                  AVRC_NO_RESOURCES if there are not enough resources to
359  *                                    perform the service search.
360  *
361  *****************************************************************************/
362 extern uint16_t AVRC_FindService(uint16_t service_uuid,
363                                  const RawAddress& bd_addr,
364                                  tAVRC_SDP_DB_PARAMS* p_db,
365                                  const tAVRC_FIND_CBACK& cback);
366 
367 /******************************************************************************
368  *
369  * Function         AVRC_Open
370  *
371  * Description      This function is called to open a connection to AVCTP.
372  *                  The connection can be either an initiator or acceptor, as
373  *                  determined by the p_ccb->stream parameter.
374  *                  The connection can be a target, a controller or for both
375  *                  roles, as determined by the p_ccb->control parameter.
376  *                  By definition, a target connection is an acceptor connection
377  *                  that waits for an incoming AVCTP connection from the peer.
378  *                  The connection remains available to the application until
379  *                  the application closes it by calling AVRC_Close().  The
380  *                  application does not need to reopen the connection after an
381  *                  AVRC_CLOSE_IND_EVT is received.
382  *
383  *                  Input Parameters:
384  *                      p_ccb->company_id: Company Identifier.
385  *
386  *                      p_ccb->p_ctrl_cback:  Pointer to the control callback
387  *                                            function.
388  *
389  *                      p_ccb->p_msg_cback:  Pointer to the message callback
390  *                                           function.
391  *
392  *                      p_ccb->conn: AVCTP connection role.  This is set to
393  *                      AVCTP_INT for initiator connections and AVCTP_ACP
394  *                      for acceptor connections.
395  *
396  *                      p_ccb->control: Control role.  This is set to
397  *                      AVRC_CT_TARGET for target connections, AVRC_CT_CONTROL
398  *                      for control connections or
399  *                      (AVRC_CT_TARGET|AVRC_CT_CONTROL) for connections that
400  *                      support both roles.
401  *
402  *                      peer_addr: BD address of peer device.  This value is
403  *                      only used for initiator connections; for acceptor
404  *                      connections it can be set to NULL.
405  *
406  *                  Output Parameters:
407  *                      p_handle: Pointer to handle.  This parameter is only
408  *                                valid if AVRC_SUCCESS is returned.
409  *
410  * Returns          AVRC_SUCCESS if successful.
411  *                  AVRC_NO_RESOURCES if there are not enough resources to open
412  *                  the connection.
413  *
414  *****************************************************************************/
415 extern uint16_t AVRC_Open(uint8_t* p_handle, tAVRC_CONN_CB* p_ccb,
416                           const RawAddress& peer_addr);
417 
418 /******************************************************************************
419  *
420  * Function         AVRC_Close
421  *
422  * Description      Close a connection opened with AVRC_Open().
423  *                  This function is called when the
424  *                  application is no longer using a connection.
425  *
426  *                  Input Parameters:
427  *                      handle: Handle of this connection.
428  *
429  *                  Output Parameters:
430  *                      None.
431  *
432  * Returns          AVRC_SUCCESS if successful.
433  *                  AVRC_BAD_HANDLE if handle is invalid.
434  *
435  *****************************************************************************/
436 extern uint16_t AVRC_Close(uint8_t handle);
437 
438 /******************************************************************************
439  *
440  * Function         AVRC_OpenBrowse
441  *
442  * Description      This function is called to open a browsing connection to
443  *                  AVCTP. The connection can be either an initiator or
444  *                  acceptor, as determined by the conn_role.
445  *                  The handle is returned by a previous call to AVRC_Open.
446  *
447  * Returns          AVRC_SUCCESS if successful.
448  *                  AVRC_NO_RESOURCES if there are not enough resources to open
449  *                  the connection.
450  *
451  *****************************************************************************/
452 extern uint16_t AVRC_OpenBrowse(uint8_t handle, uint8_t conn_role);
453 
454 /******************************************************************************
455  *
456  * Function         AVRC_CloseBrowse
457  *
458  * Description      Close a connection opened with AVRC_OpenBrowse().
459  *                  This function is called when the
460  *                  application is no longer using a connection.
461  *
462  * Returns          AVRC_SUCCESS if successful.
463  *                  AVRC_BAD_HANDLE if handle is invalid.
464  *
465  *****************************************************************************/
466 extern uint16_t AVRC_CloseBrowse(uint8_t handle);
467 
468 /******************************************************************************
469  *
470  * Function         AVRC_MsgReq
471  *
472  * Description      This function is used to send the AVRCP byte stream in p_pkt
473  *                  down to AVCTP.
474  *
475  *                  It is expected that:
476  *                  p_pkt->offset is at least AVCT_MSG_OFFSET
477  *                  p_pkt->layer_specific is AVCT_DATA_CTRL or AVCT_DATA_BROWSE
478  *                  p_pkt->event is AVRC_OP_VENDOR, AVRC_OP_PASS_THRU or
479  *                                  AVRC_OP_BROWSING
480  *                  The above BT_HDR settings are set by the AVRC_Bld*
481  *                  functions.
482  *
483  * Returns          AVRC_SUCCESS if successful.
484  *                  AVRC_BAD_HANDLE if handle is invalid.
485  *
486  *****************************************************************************/
487 extern uint16_t AVRC_MsgReq(uint8_t handle, uint8_t label, uint8_t ctype,
488                             BT_HDR* p_pkt);
489 
490 /******************************************************************************
491  *
492  * Function         AVRC_SaveControllerVersion
493  *
494  * Description      Save AVRC controller version of peer device into bt_config.
495  *                  This version is used to send same AVRC target version to
496  *                  peer device to avoid version mismatch IOP issue.
497  *
498  *                  Input Parameters:
499  *                      bdaddr: BD address of peer device.
500  *
501  *                      version: AVRC controller version of peer device.
502  *
503  *                  Output Parameters:
504  *                      None.
505  *
506  * Returns          Nothing
507  *
508  *****************************************************************************/
509 extern void AVRC_SaveControllerVersion(const RawAddress& bdaddr,
510                                        uint16_t new_version);
511 
512 /******************************************************************************
513  *
514  * Function         AVRC_UnitCmd
515  *
516  * Description      Send a UNIT INFO command to the peer device.  This
517  *                  function can only be called for controller role connections.
518  *                  Any response message from the peer is passed back through
519  *                  the tAVRC_MSG_CBACK callback function.
520  *
521  *                  Input Parameters:
522  *                      handle: Handle of this connection.
523  *
524  *                      label: Transaction label.
525  *
526  *                  Output Parameters:
527  *                      None.
528  *
529  * Returns          AVRC_SUCCESS if successful.
530  *                  AVRC_BAD_HANDLE if handle is invalid.
531  *
532  *****************************************************************************/
533 extern uint16_t AVRC_UnitCmd(uint8_t handle, uint8_t label);
534 
535 /******************************************************************************
536  *
537  * Function         AVRC_SubCmd
538  *
539  * Description      Send a SUBUNIT INFO command to the peer device.  This
540  *                  function can only be called for controller role connections.
541  *                  Any response message from the peer is passed back through
542  *                  the tAVRC_MSG_CBACK callback function.
543  *
544  *                  Input Parameters:
545  *                      handle: Handle of this connection.
546  *
547  *                      label: Transaction label.
548  *
549  *                      page: Specifies which part of the subunit type table
550  *                      is requested.  For AVRCP it is typically zero.
551  *                      Value range is 0-7.
552  *
553  *                  Output Parameters:
554  *                      None.
555  *
556  * Returns          AVRC_SUCCESS if successful.
557  *                  AVRC_BAD_HANDLE if handle is invalid.
558  *
559  *****************************************************************************/
560 extern uint16_t AVRC_SubCmd(uint8_t handle, uint8_t label, uint8_t page);
561 
562 /******************************************************************************
563  *
564  * Function         AVRC_PassCmd
565  *
566  * Description      Send a PASS THROUGH command to the peer device.  This
567  *                  function can only be called for controller role connections.
568  *                  Any response message from the peer is passed back through
569  *                  the tAVRC_MSG_CBACK callback function.
570  *
571  *                  Input Parameters:
572  *                      handle: Handle of this connection.
573  *
574  *                      label: Transaction label.
575  *
576  *                      p_msg: Pointer to PASS THROUGH message structure.
577  *
578  *                  Output Parameters:
579  *                      None.
580  *
581  * Returns          AVRC_SUCCESS if successful.
582  *                  AVRC_BAD_HANDLE if handle is invalid.
583  *
584  *****************************************************************************/
585 extern uint16_t AVRC_PassCmd(uint8_t handle, uint8_t label,
586                              tAVRC_MSG_PASS* p_msg);
587 
588 /******************************************************************************
589  *
590  * Function         AVRC_PassRsp
591  *
592  * Description      Send a PASS THROUGH response to the peer device.  This
593  *                  function can only be called for target role connections.
594  *                  This function must be called when a PASS THROUGH command
595  *                  message is received from the peer through the
596  *                  tAVRC_MSG_CBACK callback function.
597  *
598  *                  Input Parameters:
599  *                      handle: Handle of this connection.
600  *
601  *                      label: Transaction label.  Must be the same value as
602  *                      passed with the command message in the callback
603  *                      function.
604  *
605  *                      p_msg: Pointer to PASS THROUGH message structure.
606  *
607  *                  Output Parameters:
608  *                      None.
609  *
610  * Returns          AVRC_SUCCESS if successful.
611  *                  AVRC_BAD_HANDLE if handle is invalid.
612  *
613  *****************************************************************************/
614 extern uint16_t AVRC_PassRsp(uint8_t handle, uint8_t label,
615                              tAVRC_MSG_PASS* p_msg);
616 
617 /******************************************************************************
618  *
619  * Function         AVRC_VendorCmd
620  *
621  * Description      Send a VENDOR DEPENDENT command to the peer device.  This
622  *                  function can only be called for controller role connections.
623  *                  Any response message from the peer is passed back through
624  *                  the tAVRC_MSG_CBACK callback function.
625  *
626  *                  Input Parameters:
627  *                      handle: Handle of this connection.
628  *
629  *                      label: Transaction label.
630  *
631  *                      p_msg: Pointer to VENDOR DEPENDENT message structure.
632  *
633  *                  Output Parameters:
634  *                      None.
635  *
636  * Returns          AVRC_SUCCESS if successful.
637  *                  AVRC_BAD_HANDLE if handle is invalid.
638  *
639  *****************************************************************************/
640 extern uint16_t AVRC_VendorCmd(uint8_t handle, uint8_t label,
641                                tAVRC_MSG_VENDOR* p_msg);
642 
643 /******************************************************************************
644  *
645  * Function         AVRC_VendorRsp
646  *
647  * Description      Send a VENDOR DEPENDENT response to the peer device.  This
648  *                  function can only be called for target role connections.
649  *                  This function must be called when a VENDOR DEPENDENT
650  *                  command message is received from the peer through the
651  *                  tAVRC_MSG_CBACK callback function.
652  *
653  *                  Input Parameters:
654  *                      handle: Handle of this connection.
655  *
656  *                      label: Transaction label.  Must be the same value as
657  *                      passed with the command message in the callback
658  *                      function.
659  *
660  *                      p_msg: Pointer to VENDOR DEPENDENT message structure.
661  *
662  *                  Output Parameters:
663  *                      None.
664  *
665  * Returns          AVRC_SUCCESS if successful.
666  *                  AVRC_BAD_HANDLE if handle is invalid.
667  *
668  *****************************************************************************/
669 extern uint16_t AVRC_VendorRsp(uint8_t handle, uint8_t label,
670                                tAVRC_MSG_VENDOR* p_msg);
671 
672 /******************************************************************************
673  *
674  * Function         AVRC_SetTraceLevel
675  *
676  * Description      Sets the trace level for AVRC. If 0xff is passed, the
677  *                  current trace level is returned.
678  *
679  *                  Input Parameters:
680  *                      new_level:  The level to set the AVRC tracing to:
681  *                      0xff-returns the current setting.
682  *                      0-turns off tracing.
683  *                      >= 1-Errors.
684  *                      >= 2-Warnings.
685  *                      >= 3-APIs.
686  *                      >= 4-Events.
687  *                      >= 5-Debug.
688  *
689  * Returns          The new trace level or current trace level if
690  *                  the input parameter is 0xff.
691  *
692  *****************************************************************************/
693 extern uint8_t AVRC_SetTraceLevel(uint8_t new_level);
694 
695 /*******************************************************************************
696  *
697  * Function         AVRC_Init
698  *
699  * Description      This function is called at stack startup to allocate the
700  *                  control block (if using dynamic memory), and initializes the
701  *                  control block and tracing level.
702  *
703  * Returns          void
704  *
705  ******************************************************************************/
706 extern void AVRC_Init(void);
707 
708 /*******************************************************************************
709  *
710  * Function         AVRC_Ctrl_ParsCommand
711  *
712  * Description      This function is used to parse cmds received for CTRL
713  *                  Currently it is for SetAbsVolume and Volume Change
714  *                      Notification..
715  *
716  * Returns          AVRC_STS_NO_ERROR, if the message in p_data is parsed
717  *                      successfully.
718  *                  Otherwise, the error code defined by AVRCP 1.4
719  *
720  ******************************************************************************/
721 extern tAVRC_STS AVRC_Ctrl_ParsCommand(tAVRC_MSG* p_msg,
722                                        tAVRC_COMMAND* p_result);
723 
724 /*******************************************************************************
725  *
726  * Function         AVRC_ParsCommand
727  *
728  * Description      This function is used to parse the received command.
729  *
730  * Returns          AVRC_STS_NO_ERROR, if the message in p_data is parsed
731  *                      successfully.
732  *                  Otherwise, the error code defined by AVRCP 1.4
733  *
734  ******************************************************************************/
735 extern tAVRC_STS AVRC_ParsCommand(tAVRC_MSG* p_msg, tAVRC_COMMAND* p_result,
736                                   uint8_t* p_buf, uint16_t buf_len);
737 
738 /*******************************************************************************
739  *
740  * Function         AVRC_ParsResponse
741  *
742  * Description      This function is used to parse the received response.
743  *
744  * Returns          AVRC_STS_NO_ERROR, if the message in p_data is parsed
745  *                      successfully.
746  *                  Otherwise, the error code defined by AVRCP 1.4
747  *
748  ******************************************************************************/
749 extern tAVRC_STS AVRC_ParsResponse(tAVRC_MSG* p_msg, tAVRC_RESPONSE* p_result,
750                                    uint8_t* p_buf, uint16_t buf_len);
751 
752 /*******************************************************************************
753  *
754  * Function         AVRC_Ctrl_ParsResponse
755  *
756  * Description      This function is a parse response for AVRCP Controller.
757  *
758  * Returns          AVRC_STS_NO_ERROR, if the message in p_data is parsed
759  *                      successfully.
760  *                  Otherwise, the error code defined by AVRCP 1.4
761  *
762  ******************************************************************************/
763 extern tAVRC_STS AVRC_Ctrl_ParsResponse(tAVRC_MSG* p_msg,
764                                         tAVRC_RESPONSE* p_result,
765                                         uint8_t* p_buf, uint16_t* buf_len);
766 
767 /*******************************************************************************
768  *
769  * Function         AVRC_BldCommand
770  *
771  * Description      This function builds the given AVRCP command to the given
772  *                  GKI buffer
773  *
774  * Returns          AVRC_STS_NO_ERROR, if the command is built successfully
775  *                  Otherwise, the error code.
776  *
777  ******************************************************************************/
778 extern tAVRC_STS AVRC_BldCommand(tAVRC_COMMAND* p_cmd, BT_HDR** pp_pkt);
779 
780 /*******************************************************************************
781  *
782  * Function         AVRC_BldResponse
783  *
784  * Description      This function builds the given AVRCP response to the given
785  *                  GKI buffer
786  *
787  * Returns          AVRC_STS_NO_ERROR, if the response is built successfully
788  *                  Otherwise, the error code.
789  *
790  ******************************************************************************/
791 extern tAVRC_STS AVRC_BldResponse(uint8_t handle, tAVRC_RESPONSE* p_rsp,
792                                   BT_HDR** pp_pkt);
793 
794 /**************************************************************************
795  *
796  * Function         AVRC_IsValidAvcType
797  *
798  * Description      Check if correct AVC type is specified
799  *
800  * Returns          returns true if it is valid
801  *
802  *
803  ******************************************************************************/
804 extern bool AVRC_IsValidAvcType(uint8_t pdu_id, uint8_t avc_type);
805 
806 /*******************************************************************************
807  *
808  * Function         AVRC_IsValidPlayerAttr
809  *
810  * Description      Check if the given attrib value is a valid one
811  *
812  *
813  * Returns          returns true if it is valid
814  *
815  ******************************************************************************/
816 extern bool AVRC_IsValidPlayerAttr(uint8_t attr);
817 
818 #endif /* AVRC_API_H */
819