1 /*
2  * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /*******************************************************************************
8  *
9  *  Filename:      btc_a2dp_sink.h
10  *
11  *******************************************************************************/
12 
13 #ifndef __BTC_A2DP_SINK_H__
14 #define __BTC_A2DP_SINK_H__
15 
16 #include <stdbool.h>
17 #include "common/bt_target.h"
18 #include "bta/bta_api.h"
19 #include "btc_av_api.h"
20 #include "esp_a2dp_api.h"
21 
22 #if BTC_AV_SINK_INCLUDED
23 /*******************************************************************************
24  **  Data types
25  *******************************************************************************/
26 typedef struct {
27     BT_HDR hdr;
28     UINT8 codec_info[AVDT_CODEC_SIZE];
29 } tBTC_MEDIA_SINK_CFG_UPDATE;
30 
31 /*******************************************************************************
32  **  Public functions
33  *******************************************************************************/
34 
35 /*******************************************************************************
36  **
37  ** Function         btc_a2dp_sink_startup
38  **
39  ** Description      Initialize and startup the A2DP sink module. This function
40  **                  should be called by the BTC AV state machine prior to using
41  **                  the module.
42  **
43  ** Returns          true if success
44  **
45  *******************************************************************************/
46 bool btc_a2dp_sink_startup(void);
47 
48 /*******************************************************************************
49  **
50  ** Function         btc_a2dp_sink_shutdown
51  **
52  ** Description      Shutdown and cleanup the A2DP sink module
53  **
54  *******************************************************************************/
55 void btc_a2dp_sink_shutdown(void);
56 
57 /*******************************************************************************
58  **
59  ** Function         btc_a2dp_sink_rx_flush_req
60  **
61  ** Description      Request to flush audio decoding pipe
62  **
63  ** Returns          TRUE if success
64  **
65  *******************************************************************************/
66 BOOLEAN btc_a2dp_sink_rx_flush_req(void);
67 
68 /*******************************************************************************
69  **
70  ** Function         btc_a2dp_sink_enque_buf
71  **
72  ** Description      Enqueue a Advance Audio media buffer to be processed by btc media task.
73  **
74  ** Returns          size of the queue
75  **
76  *******************************************************************************/
77 UINT8 btc_a2dp_sink_enque_buf(BT_HDR *p_buf);
78 
79 
80 /*******************************************************************************
81  **
82  ** Function         btc_a2dp_sink_on_idle
83  **
84  ** Description      Process 'idle' request from the BTC AV state machine during
85  **                  initialization
86  **
87  *******************************************************************************/
88 void btc_a2dp_sink_on_idle(void);
89 
90 /*******************************************************************************
91  **
92  ** Function         btc_a2dp_sink_on_stopped
93  **
94  ** Description      Process 'stop' request from the BTC AV state machine to stop
95  **                  A2DP streaming
96  **
97  *******************************************************************************/
98 void btc_a2dp_sink_on_stopped(tBTA_AV_SUSPEND *p_av);
99 
100 /*******************************************************************************
101  **
102  ** Function         btc_a2dp_sink_on_suspended
103  **
104  ** Description      Process 'suspend' request from the BTC AV state machine to
105  **                  suspend A2DP streaming
106  **
107  *******************************************************************************/
108 void btc_a2dp_sink_on_suspended(tBTA_AV_SUSPEND *p_av);
109 
110 /*******************************************************************************
111  **
112  ** Function         btc_a2dp_sink_set_rx_flush
113  **
114  ** Description      enable/disabel discarding of received A2DP frames
115  **
116  *******************************************************************************/
117 void btc_a2dp_sink_set_rx_flush(BOOLEAN enable);
118 
119 /*******************************************************************************
120  **
121  ** Function         btc_a2dp_sink_reset_decoder
122  **
123  ** Description      Reset decoder parameters according to configuration from remote
124  **                  device
125  **
126  *******************************************************************************/
127 void btc_a2dp_sink_reset_decoder(UINT8 *p_av);
128 
129 #endif /* #if BTC_AV_SINK_INCLUDED */
130 
131 #endif /* __BTC_A2DP_SINK_H__ */
132