aboutsummaryrefslogtreecommitdiff
path: root/stack/include/avrc_api.h
blob: 7796ae0b65d3c56b9cf0102eab2fea31901b9fcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
/******************************************************************************
 *
 *  Copyright 2006-2012 Broadcom Corporation
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at:
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 ******************************************************************************/

/******************************************************************************
 *
 *  nterface to AVRCP Application Programming Interface
 *
 ******************************************************************************/
#ifndef AVRC_API_H
#define AVRC_API_H

#include "avct_api.h"
#include "avrc_defs.h"
#include "bt_target.h"
#include "sdp_api.h"

#include <base/callback.h>

/*****************************************************************************
 *  constants
 ****************************************************************************/

/* API function return value result codes. */
/* 0 Function successful */
#define AVRC_SUCCESS AVCT_SUCCESS
/* 1 Not enough resources */
#define AVRC_NO_RESOURCES AVCT_NO_RESOURCES
/* 2 Bad handle */
#define AVRC_BAD_HANDLE AVCT_BAD_HANDLE
/* 3 PID already in use */
#define AVRC_PID_IN_USE AVCT_PID_IN_USE
/* 4 Connection not open */
#define AVRC_NOT_OPEN AVCT_NOT_OPEN
/* 5 the message length exceed the MTU of the browsing channel */
#define AVRC_MSG_TOO_BIG 5
/* 0x10 generic failure */
#define AVRC_FAIL 0x10
/* 0x11 bad parameter   */
#define AVRC_BAD_PARAM 0x11

/* Control role - same as AVCT_TARGET/AVCT_CONTROL */
/* target  */
#define AVRC_CT_TARGET 1
/* controller  */
#define AVRC_CT_CONTROL 2
/* If conflict, allow the other side to succeed  */
#define AVRC_CT_PASSIVE 4

/* Connection role */
/* initiator */
#define AVRC_CONN_INT AVCT_INT
/* Acceptor  */
#define AVRC_CONN_ACP AVCT_ACP

/* AVRC CTRL events */
/* AVRC_OPEN_IND_EVT event is sent when the connection is successfully opened.
 * This eventis sent in response to an AVRC_Open(). */
#define AVRC_OPEN_IND_EVT 0

/* AVRC_CLOSE_IND_EVT event is sent when a connection is closed.
 * This event can result from a call to AVRC_Close() or when the peer closes
 * the connection.  It is also sent when a connection attempted through
 * AVRC_Open() fails. */
#define AVRC_CLOSE_IND_EVT 1

/* AVRC_CONG_IND_EVT event indicates that AVCTP is congested and cannot send
 * any more messages. */
#define AVRC_CONG_IND_EVT 2

/* AVRC_UNCONG_IND_EVT event indicates that AVCTP is uncongested and ready to
 * send messages. */
#define AVRC_UNCONG_IND_EVT 3

/* AVRC_BROWSE_OPEN_IND_EVT event is sent when the browse channel is
* successfully opened.
* This eventis sent in response to an AVRC_Open() or AVRC_OpenBrowse() . */
#define AVRC_BROWSE_OPEN_IND_EVT 4

/* AVRC_BROWSE_CLOSE_IND_EVT event is sent when a browse channel is closed.
 * This event can result from a call to AVRC_Close(), AVRC_CloseBrowse() or
 * when the peer closes the connection.  It is also sent when a connection
 * attempted through AVRC_OpenBrowse() fails. */
#define AVRC_BROWSE_CLOSE_IND_EVT 5

/* AVRC_BROWSE_CONG_IND_EVT event indicates that AVCTP browse channel is
 * congested and cannot send any more messages. */
#define AVRC_BROWSE_CONG_IND_EVT 6

/* AVRC_BROWSE_UNCONG_IND_EVT event indicates that AVCTP browse channel is
 * uncongested and ready to send messages. */
#define AVRC_BROWSE_UNCONG_IND_EVT 7

/* AVRC_CMD_TIMEOUT_EVT event indicates timeout waiting for AVRC command
 * response from the peer */
#define AVRC_CMD_TIMEOUT_EVT 8

/* Configurable avrcp version key and constant values */
#ifndef AVRC_VERSION_PROPERTY
#define AVRC_VERSION_PROPERTY "persist.bluetooth.avrcpversion"
#endif

#ifndef AVRC_1_6_STRING
#define AVRC_1_6_STRING "avrcp16"
#endif

#ifndef AVRC_1_5_STRING
#define AVRC_1_5_STRING "avrcp15"
#endif

#ifndef AVRC_1_4_STRING
#define AVRC_1_4_STRING "avrcp14"
#endif

#ifndef AVRC_1_3_STRING
#define AVRC_1_3_STRING "avrcp13"
#endif

#ifndef AVRC_DEFAULT_VERSION
#define AVRC_DEFAULT_VERSION AVRC_1_4_STRING
#endif

/* Supported categories */
#define AVRC_SUPF_CT_CAT1 0x0001         /* Category 1 */
#define AVRC_SUPF_CT_CAT2 0x0002         /* Category 2 */
#define AVRC_SUPF_CT_CAT3 0x0004         /* Category 3 */
#define AVRC_SUPF_CT_CAT4 0x0008         /* Category 4 */
#define AVRC_SUPF_CT_APP_SETTINGS 0x0010 /* Player Application Settings */
#define AVRC_SUPF_CT_GROUP_NAVI 0x0020   /* Group Navigation */
#define AVRC_SUPF_CT_BROWSE 0x0040       /* Browsing */

/* Cover Art, get image property */
#define AVRC_SUPF_CT_COVER_ART_GET_IMAGE_PROP 0x0080
/* Cover Art, get image */
#define AVRC_SUPF_CT_COVER_ART_GET_IMAGE 0x0100
/* Cover Art, get Linked Thumbnail */
#define AVRC_SUPF_CT_COVER_ART_GET_THUMBNAIL 0x0200

#define AVRC_SUPF_TG_CAT1 0x0001             /* Category 1 */
#define AVRC_SUPF_TG_CAT2 0x0002             /* Category 2 */
#define AVRC_SUPF_TG_CAT3 0x0004             /* Category 3 */
#define AVRC_SUPF_TG_CAT4 0x0008             /* Category 4 */
#define AVRC_SUPF_TG_APP_SETTINGS 0x0010     /* Player Application Settings */
#define AVRC_SUPF_TG_GROUP_NAVI 0x0020       /* Group Navigation */
#define AVRC_SUPF_TG_BROWSE 0x0040           /* Browsing */
#define AVRC_SUPF_TG_MULTI_PLAYER 0x0080     /* Muliple Media Player */
#define AVRC_SUPF_TG_PLAYER_COVER_ART 0x0100 /* Cover Art */

#define AVRC_META_SUCCESS AVRC_SUCCESS
#define AVRC_META_FAIL AVRC_FAIL
#define AVRC_METADATA_CMD 0x0000
#define AVRC_METADATA_RESP 0x0001

/*****************************************************************************
 *  data type definitions
 ****************************************************************************/

/* This data type is used in AVRC_FindService() to initialize the SDP database
 * to hold the result service search. */
typedef struct {
  uint32_t db_len;         /* Length, in bytes, of the discovery database */
  tSDP_DISCOVERY_DB* p_db; /* Pointer to the discovery database */
  uint16_t num_attr;       /* The number of attributes in p_attrs */
  uint16_t* p_attrs;       /* The attributes filter. If NULL, AVRCP API sets the
                            * attribute filter
                            * to be ATTR_ID_SERVICE_CLASS_ID_LIST,
                            * ATTR_ID_BT_PROFILE_DESC_LIST,
                            * ATTR_ID_SUPPORTED_FEATURES, ATTR_ID_SERVICE_NAME and
                            * ATTR_ID_PROVIDER_NAME.
                            * If not NULL, the input is taken as the filter. */
} tAVRC_SDP_DB_PARAMS;

/* This callback function returns service discovery information to the
 * application after the AVRC_FindService() API function is called.  The
 * implementation of this callback function must copy the p_service_name
 * and p_provider_name parameters passed to it as they are not guaranteed
 * to remain after the callback function exits. */
using tAVRC_FIND_CBACK = base::Callback<void(uint16_t status)>;

/* This is the control callback function.  This function passes events
 * listed in Table 20 to the application. */
using tAVRC_CTRL_CBACK =
    base::Callback<void(uint8_t handle, uint8_t event, uint16_t result,
                        const RawAddress* peer_addr)>;

/* This is the message callback function.  It is executed when AVCTP has
 * a message packet ready for the application.  The implementation of this
 * callback function must copy the tAVRC_MSG structure passed to it as it
 * is not guaranteed to remain after the callback function exits. */
using tAVRC_MSG_CBACK = base::Callback<void(uint8_t handle, uint8_t label,
                                            uint8_t opcode, tAVRC_MSG* p_msg)>;

typedef struct {
  tAVRC_CTRL_CBACK ctrl_cback;    /* application control callback */
  tAVRC_MSG_CBACK msg_cback;      /* application message callback */
  uint32_t company_id;            /* the company ID  */
  uint8_t conn;                   /* Connection role (Initiator/acceptor) */
  uint8_t control;                /* Control role (Control/Target) */
} tAVRC_CONN_CB;

typedef struct {
  uint8_t handle;
  uint8_t label;
  uint8_t msg_mask;
} tAVRC_PARAM;

/*****************************************************************************
 *  external function declarations
 ****************************************************************************/

/******************************************************************************
 *
 * Function         ARVC_GetProfileVersion
 *
 * Description      Get the user assigned AVRCP profile version
 *
 * Returns          The AVRCP profile version
 *
 *****************************************************************************/
extern uint16_t AVRC_GetProfileVersion();

/******************************************************************************
 *
 * Function         AVRC_AddRecord
 *
 * Description      This function is called to build an AVRCP SDP record.
 *                  Prior to calling this function the application must
 *                  call SDP_CreateRecord() to create an SDP record.
 *
 *                  Input Parameters:
 *                      service_uuid:  Indicates
 *                                       TG(UUID_SERVCLASS_AV_REM_CTRL_TARGET)
 *                                    or CT(UUID_SERVCLASS_AV_REMOTE_CONTROL)
 *
 *                      p_service_name:  Pointer to a null-terminated character
 *                      string containing the service name.
 *                      If service name is not used set this to NULL.
 *
 *                      p_provider_name:  Pointer to a null-terminated character
 *                      string containing the provider name.
 *                      If provider name is not used set this to NULL.
 *
 *                      categories:  Supported categories.
 *
 *                      sdp_handle:  SDP handle returned by SDP_CreateRecord().
 *
 *                      browse_supported:  browse support info.
 *
 *                      profile_version:  profile version of avrcp record.
 *
 *                      cover_art_psm: The PSM of a cover art service, if
 *                      supported. Use 0 Otherwise. Ignored on controller
 *
 *                  Output Parameters:
 *                      None.
 *
 * Returns          AVRC_SUCCESS if successful.
 *                  AVRC_NO_RESOURCES if not enough resources to build the SDP
 *                                    record.
 *
 *****************************************************************************/
extern uint16_t AVRC_AddRecord(uint16_t service_uuid,
                               const char* p_service_name,
                               const char* p_provider_name, uint16_t categories,
                               uint32_t sdp_handle, bool browse_supported,
                               uint16_t profile_version,
                               uint16_t cover_art_psm);

/*******************************************************************************
 *
 * Function          AVRC_RemoveRecord
 *
 * Description       This function is called to remove an AVRCP SDP record.
 *
 *                   Input Parameters:
 *                       sdp_handle:  Handle you used with AVRC_AddRecord
 *
 * Returns           AVRC_SUCCESS if successful.
 *                   AVRC_FAIL otherwise
 *
 *******************************************************************************/
extern uint16_t AVRC_RemoveRecord(uint32_t sdp_handle);

/******************************************************************************
 *
 * Function         AVRC_FindService
 *
 * Description      This function is called by the application to perform
 *                  service discovery and retrieve AVRCP SDP record information
 *                  from a peer device.  Information is returned for the first
 *                  service record found on the server that matches the service
 *                  UUID. The callback function will be executed when service
 *                  discovery is complete.  There can only be one outstanding
 *                  call to AVRC_FindService() at a time; the application must
 *                  wait for the callback before it makes another call to the
 *                  function. The application is responsible for allocating
 *                  memory for the discovery database.  It is recommended that
 *                  the size of the discovery database be at least 300 bytes.
 *                  The application can deallocate the memory after the
 *                  callback function has executed.
 *
 *                  Input Parameters:
 *                      service_uuid: Indicates
 *                                       TG(UUID_SERVCLASS_AV_REM_CTRL_TARGET)
 *                                    or CT(UUID_SERVCLASS_AV_REMOTE_CONTROL)
 *
 *                      bd_addr:  BD address of the peer device.
 *
 *                      p_db:  SDP discovery database parameters.
 *
 *                      p_cback:  Pointer to the callback function.
 *
 *                  Output Parameters:
 *                      None.
 *
 * Returns          AVRC_SUCCESS if successful.
 *                  AVRC_BAD_PARAMS if discovery database parameters are
 *                                  invalid.
 *                  AVRC_NO_RESOURCES if there are not enough resources to
 *                                    perform the service search.
 *
 *****************************************************************************/
extern uint16_t AVRC_FindService(uint16_t service_uuid,
                                 const RawAddress& bd_addr,
                                 tAVRC_SDP_DB_PARAMS* p_db,
                                 const tAVRC_FIND_CBACK& cback);

/******************************************************************************
 *
 * Function         AVRC_Open
 *
 * Description      This function is called to open a connection to AVCTP.
 *                  The connection can be either an initiator or acceptor, as
 *                  determined by the p_ccb->stream parameter.
 *                  The connection can be a target, a controller or for both
 *                  roles, as determined by the p_ccb->control parameter.
 *                  By definition, a target connection is an acceptor connection
 *                  that waits for an incoming AVCTP connection from the peer.
 *                  The connection remains available to the application until
 *                  the application closes it by calling AVRC_Close().  The
 *                  application does not need to reopen the connection after an
 *                  AVRC_CLOSE_IND_EVT is received.
 *
 *                  Input Parameters:
 *                      p_ccb->company_id: Company Identifier.
 *
 *                      p_ccb->p_ctrl_cback:  Pointer to the control callback
 *                                            function.
 *
 *                      p_ccb->p_msg_cback:  Pointer to the message callback
 *                                           function.
 *
 *                      p_ccb->conn: AVCTP connection role.  This is set to
 *                      AVCTP_INT for initiator connections and AVCTP_ACP
 *                      for acceptor connections.
 *
 *                      p_ccb->control: Control role.  This is set to
 *                      AVRC_CT_TARGET for target connections, AVRC_CT_CONTROL
 *                      for control connections or
 *                      (AVRC_CT_TARGET|AVRC_CT_CONTROL) for connections that
 *                      support both roles.
 *
 *                      peer_addr: BD address of peer device.  This value is
 *                      only used for initiator connections; for acceptor
 *                      connections it can be set to NULL.
 *
 *                  Output Parameters:
 *                      p_handle: Pointer to handle.  This parameter is only
 *                                valid if AVRC_SUCCESS is returned.
 *
 * Returns          AVRC_SUCCESS if successful.
 *                  AVRC_NO_RESOURCES if there are not enough resources to open
 *                  the connection.
 *
 *****************************************************************************/
extern uint16_t AVRC_Open(uint8_t* p_handle, tAVRC_CONN_CB* p_ccb,
                          const RawAddress& peer_addr);

/******************************************************************************
 *
 * Function         AVRC_Close
 *
 * Description      Close a connection opened with AVRC_Open().
 *                  This function is called when the
 *                  application is no longer using a connection.
 *
 *                  Input Parameters:
 *                      handle: Handle of this connection.
 *
 *                  Output Parameters:
 *                      None.
 *
 * Returns          AVRC_SUCCESS if successful.
 *                  AVRC_BAD_HANDLE if handle is invalid.
 *
 *****************************************************************************/
extern uint16_t AVRC_Close(uint8_t handle);

/******************************************************************************
 *
 * Function         AVRC_OpenBrowse
 *
 * Description      This function is called to open a browsing connection to
 *                  AVCTP. The connection can be either an initiator or
 *                  acceptor, as determined by the conn_role.
 *                  The handle is returned by a previous call to AVRC_Open.
 *
 * Returns          AVRC_SUCCESS if successful.
 *                  AVRC_NO_RESOURCES if there are not enough resources to open
 *                  the connection.
 *
 *****************************************************************************/
extern uint16_t AVRC_OpenBrowse(uint8_t handle, uint8_t conn_role);

/******************************************************************************
 *
 * Function         AVRC_CloseBrowse
 *
 * Description      Close a connection opened with AVRC_OpenBrowse().
 *                  This function is called when the
 *                  application is no longer using a connection.
 *
 * Returns          AVRC_SUCCESS if successful.
 *                  AVRC_BAD_HANDLE if handle is invalid.
 *
 *****************************************************************************/
extern uint16_t AVRC_CloseBrowse(uint8_t handle);

/******************************************************************************
 *
 * Function         AVRC_MsgReq
 *
 * Description      This function is used to send the AVRCP byte stream in p_pkt
 *                  down to AVCTP.
 *
 *                  It is expected that:
 *                  p_pkt->offset is at least AVCT_MSG_OFFSET
 *                  p_pkt->layer_specific is AVCT_DATA_CTRL or AVCT_DATA_BROWSE
 *                  p_pkt->event is AVRC_OP_VENDOR, AVRC_OP_PASS_THRU or
 *                                  AVRC_OP_BROWSING
 *                  The above BT_HDR settings are set by the AVRC_Bld*
 *                  functions.
 *
 * Returns          AVRC_SUCCESS if successful.
 *                  AVRC_BAD_HANDLE if handle is invalid.
 *
 *****************************************************************************/
extern uint16_t AVRC_MsgReq(uint8_t handle, uint8_t label, uint8_t ctype,
                            BT_HDR* p_pkt);

/******************************************************************************
 *
 * Function         AVRC_UnitCmd
 *
 * Description      Send a UNIT INFO command to the peer device.  This
 *                  function can only be called for controller role connections.
 *                  Any response message from the peer is passed back through
 *                  the tAVRC_MSG_CBACK callback function.
 *
 *                  Input Parameters:
 *                      handle: Handle of this connection.
 *
 *                      label: Transaction label.
 *
 *                  Output Parameters:
 *                      None.
 *
 * Returns          AVRC_SUCCESS if successful.
 *                  AVRC_BAD_HANDLE if handle is invalid.
 *
 *****************************************************************************/
extern uint16_t AVRC_UnitCmd(uint8_t handle, uint8_t label);

/******************************************************************************
 *
 * Function         AVRC_SubCmd
 *
 * Description      Send a SUBUNIT INFO command to the peer device.  This
 *                  function can only be called for controller role connections.
 *                  Any response message from the peer is passed back through
 *                  the tAVRC_MSG_CBACK callback function.
 *
 *                  Input Parameters:
 *                      handle: Handle of this connection.
 *
 *                      label: Transaction label.
 *
 *                      page: Specifies which part of the subunit type table
 *                      is requested.  For AVRCP it is typically zero.
 *                      Value range is 0-7.
 *
 *                  Output Parameters:
 *                      None.
 *
 * Returns          AVRC_SUCCESS if successful.
 *                  AVRC_BAD_HANDLE if handle is invalid.
 *
 *****************************************************************************/
extern uint16_t AVRC_SubCmd(uint8_t handle, uint8_t label, uint8_t page);

/******************************************************************************
 *
 * Function         AVRC_PassCmd
 *
 * Description      Send a PASS THROUGH command to the peer device.  This
 *                  function can only be called for controller role connections.
 *                  Any response message from the peer is passed back through
 *                  the tAVRC_MSG_CBACK callback function.
 *
 *                  Input Parameters:
 *                      handle: Handle of this connection.
 *
 *                      label: Transaction label.
 *
 *                      p_msg: Pointer to PASS THROUGH message structure.
 *
 *                  Output Parameters:
 *                      None.
 *
 * Returns          AVRC_SUCCESS if successful.
 *                  AVRC_BAD_HANDLE if handle is invalid.
 *
 *****************************************************************************/
extern uint16_t AVRC_PassCmd(uint8_t handle, uint8_t label,
                             tAVRC_MSG_PASS* p_msg);

/******************************************************************************
 *
 * Function         AVRC_PassRsp
 *
 * Description      Send a PASS THROUGH response to the peer device.  This
 *                  function can only be called for target role connections.
 *                  This function must be called when a PASS THROUGH command
 *                  message is received from the peer through the
 *                  tAVRC_MSG_CBACK callback function.
 *
 *                  Input Parameters:
 *                      handle: Handle of this connection.
 *
 *                      label: Transaction label.  Must be the same value as
 *                      passed with the command message in the callback
 *                      function.
 *
 *                      p_msg: Pointer to PASS THROUGH message structure.
 *
 *                  Output Parameters:
 *                      None.
 *
 * Returns          AVRC_SUCCESS if successful.
 *                  AVRC_BAD_HANDLE if handle is invalid.
 *
 *****************************************************************************/
extern uint16_t AVRC_PassRsp(uint8_t handle, uint8_t label,
                             tAVRC_MSG_PASS* p_msg);

/******************************************************************************
 *
 * Function         AVRC_VendorCmd
 *
 * Description      Send a VENDOR DEPENDENT command to the peer device.  This
 *                  function can only be called for controller role connections.
 *                  Any response message from the peer is passed back through
 *                  the tAVRC_MSG_CBACK callback function.
 *
 *                  Input Parameters:
 *                      handle: Handle of this connection.
 *
 *                      label: Transaction label.
 *
 *                      p_msg: Pointer to VENDOR DEPENDENT message structure.
 *
 *                  Output Parameters:
 *                      None.
 *
 * Returns          AVRC_SUCCESS if successful.
 *                  AVRC_BAD_HANDLE if handle is invalid.
 *
 *****************************************************************************/
extern uint16_t AVRC_VendorCmd(uint8_t handle, uint8_t label,
                               tAVRC_MSG_VENDOR* p_msg);

/******************************************************************************
 *
 * Function         AVRC_VendorRsp
 *
 * Description      Send a VENDOR DEPENDENT response to the peer device.  This
 *                  function can only be called for target role connections.
 *                  This function must be called when a VENDOR DEPENDENT
 *                  command message is received from the peer through the
 *                  tAVRC_MSG_CBACK callback function.
 *
 *                  Input Parameters:
 *                      handle: Handle of this connection.
 *
 *                      label: Transaction label.  Must be the same value as
 *                      passed with the command message in the callback
 *                      function.
 *
 *                      p_msg: Pointer to VENDOR DEPENDENT message structure.
 *
 *                  Output Parameters:
 *                      None.
 *
 * Returns          AVRC_SUCCESS if successful.
 *                  AVRC_BAD_HANDLE if handle is invalid.
 *
 *****************************************************************************/
extern uint16_t AVRC_VendorRsp(uint8_t handle, uint8_t label,
                               tAVRC_MSG_VENDOR* p_msg);

/******************************************************************************
 *
 * Function         AVRC_SetTraceLevel
 *
 * Description      Sets the trace level for AVRC. If 0xff is passed, the
 *                  current trace level is returned.
 *
 *                  Input Parameters:
 *                      new_level:  The level to set the AVRC tracing to:
 *                      0xff-returns the current setting.
 *                      0-turns off tracing.
 *                      >= 1-Errors.
 *                      >= 2-Warnings.
 *                      >= 3-APIs.
 *                      >= 4-Events.
 *                      >= 5-Debug.
 *
 * Returns          The new trace level or current trace level if
 *                  the input parameter is 0xff.
 *
 *****************************************************************************/
extern uint8_t AVRC_SetTraceLevel(uint8_t new_level);

/*******************************************************************************
 *
 * Function         AVRC_Init
 *
 * Description      This function is called at stack startup to allocate the
 *                  control block (if using dynamic memory), and initializes the
 *                  control block and tracing level.
 *
 * Returns          void
 *
 ******************************************************************************/
extern void AVRC_Init(void);

/*******************************************************************************
 *
 * Function         AVRC_Ctrl_ParsCommand
 *
 * Description      This function is used to parse cmds received for CTRL
 *                  Currently it is for SetAbsVolume and Volume Change
 *                      Notification..
 *
 * Returns          AVRC_STS_NO_ERROR, if the message in p_data is parsed
 *                      successfully.
 *                  Otherwise, the error code defined by AVRCP 1.4
 *
 ******************************************************************************/
extern tAVRC_STS AVRC_Ctrl_ParsCommand(tAVRC_MSG* p_msg,
                                       tAVRC_COMMAND* p_result);

/*******************************************************************************
 *
 * Function         AVRC_ParsCommand
 *
 * Description      This function is used to parse the received command.
 *
 * Returns          AVRC_STS_NO_ERROR, if the message in p_data is parsed
 *                      successfully.
 *                  Otherwise, the error code defined by AVRCP 1.4
 *
 ******************************************************************************/
extern tAVRC_STS AVRC_ParsCommand(tAVRC_MSG* p_msg, tAVRC_COMMAND* p_result,
                                  uint8_t* p_buf, uint16_t buf_len);

/*******************************************************************************
 *
 * Function         AVRC_ParsResponse
 *
 * Description      This function is used to parse the received response.
 *
 * Returns          AVRC_STS_NO_ERROR, if the message in p_data is parsed
 *                      successfully.
 *                  Otherwise, the error code defined by AVRCP 1.4
 *
 ******************************************************************************/
extern tAVRC_STS AVRC_ParsResponse(tAVRC_MSG* p_msg, tAVRC_RESPONSE* p_result,
                                   uint8_t* p_buf, uint16_t buf_len);

/*******************************************************************************
 *
 * Function         AVRC_Ctrl_ParsResponse
 *
 * Description      This function is a parse response for AVRCP Controller.
 *
 * Returns          AVRC_STS_NO_ERROR, if the message in p_data is parsed
 *                      successfully.
 *                  Otherwise, the error code defined by AVRCP 1.4
 *
 ******************************************************************************/
extern tAVRC_STS AVRC_Ctrl_ParsResponse(tAVRC_MSG* p_msg,
                                        tAVRC_RESPONSE* p_result,
                                        uint8_t* p_buf, uint16_t* buf_len);

/*******************************************************************************
 *
 * Function         AVRC_BldCommand
 *
 * Description      This function builds the given AVRCP command to the given
 *                  GKI buffer
 *
 * Returns          AVRC_STS_NO_ERROR, if the command is built successfully
 *                  Otherwise, the error code.
 *
 ******************************************************************************/
extern tAVRC_STS AVRC_BldCommand(tAVRC_COMMAND* p_cmd, BT_HDR** pp_pkt);

/*******************************************************************************
 *
 * Function         AVRC_BldResponse
 *
 * Description      This function builds the given AVRCP response to the given
 *                  GKI buffer
 *
 * Returns          AVRC_STS_NO_ERROR, if the response is built successfully
 *                  Otherwise, the error code.
 *
 ******************************************************************************/
extern tAVRC_STS AVRC_BldResponse(uint8_t handle, tAVRC_RESPONSE* p_rsp,
                                  BT_HDR** pp_pkt);

/**************************************************************************
 *
 * Function         AVRC_IsValidAvcType
 *
 * Description      Check if correct AVC type is specified
 *
 * Returns          returns true if it is valid
 *
 *
 ******************************************************************************/
extern bool AVRC_IsValidAvcType(uint8_t pdu_id, uint8_t avc_type);

/*******************************************************************************
 *
 * Function         AVRC_IsValidPlayerAttr
 *
 * Description      Check if the given attrib value is a valid one
 *
 *
 * Returns          returns true if it is valid
 *
 ******************************************************************************/
extern bool AVRC_IsValidPlayerAttr(uint8_t attr);

#endif /* AVRC_API_H */