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