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