1 // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 /*******************************************************************************
16  *
17  *  Filename:      btc_a2dp_sink.h
18  *
19  *******************************************************************************/
20 
21 #ifndef __BTC_A2DP_SINK_H__
22 #define __BTC_A2DP_SINK_H__
23 
24 #include <stdbool.h>
25 #include "common/bt_target.h"
26 #include "bta/bta_api.h"
27 #include "btc_av_api.h"
28 #include "esp_a2dp_api.h"
29 
30 #if BTC_AV_SINK_INCLUDED
31 /*******************************************************************************
32  **  Data types
33  *******************************************************************************/
34 typedef struct {
35     BT_HDR hdr;
36     UINT8 codec_info[AVDT_CODEC_SIZE];
37 } tBTC_MEDIA_SINK_CFG_UPDATE;
38 
39 /*******************************************************************************
40  **  Public functions
41  *******************************************************************************/
42 
43 /*******************************************************************************
44  **
45  ** Function         btc_a2dp_sink_startup
46  **
47  ** Description      Initialize and startup the A2DP sink module. This function
48  **                  should be called by the BTC AV state machine prior to using
49  **                  the module.
50  **
51  ** Returns          true if success
52  **
53  *******************************************************************************/
54 bool btc_a2dp_sink_startup(void);
55 
56 /*******************************************************************************
57  **
58  ** Function         btc_a2dp_sink_shutdown
59  **
60  ** Description      Shutdown and cleanup the A2DP sink module
61  **
62  *******************************************************************************/
63 void btc_a2dp_sink_shutdown(void);
64 
65 /*******************************************************************************
66  **
67  ** Function         btc_a2dp_sink_rx_flush_req
68  **
69  ** Description      Request to flush audio decoding pipe
70  **
71  ** Returns          TRUE if success
72  **
73  *******************************************************************************/
74 BOOLEAN btc_a2dp_sink_rx_flush_req(void);
75 
76 /*******************************************************************************
77  **
78  ** Function         btc_a2dp_sink_enque_buf
79  **
80  ** Description      Enqueue a Advance Audio media buffer to be processed by btc media task.
81  **
82  ** Returns          size of the queue
83  **
84  *******************************************************************************/
85 UINT8 btc_a2dp_sink_enque_buf(BT_HDR *p_buf);
86 
87 
88 /*******************************************************************************
89  **
90  ** Function         btc_a2dp_sink_on_idle
91  **
92  ** Description      Process 'idle' request from the BTC AV state machine during
93  **                  initialization
94  **
95  *******************************************************************************/
96 void btc_a2dp_sink_on_idle(void);
97 
98 /*******************************************************************************
99  **
100  ** Function         btc_a2dp_sink_on_stopped
101  **
102  ** Description      Process 'stop' request from the BTC AV state machine to stop
103  **                  A2DP streaming
104  **
105  *******************************************************************************/
106 void btc_a2dp_sink_on_stopped(tBTA_AV_SUSPEND *p_av);
107 
108 /*******************************************************************************
109  **
110  ** Function         btc_a2dp_sink_on_suspended
111  **
112  ** Description      Process 'suspend' request from the BTC AV state machine to
113  **                  suspend A2DP streaming
114  **
115  *******************************************************************************/
116 void btc_a2dp_sink_on_suspended(tBTA_AV_SUSPEND *p_av);
117 
118 /*******************************************************************************
119  **
120  ** Function         btc_a2dp_sink_set_rx_flush
121  **
122  ** Description      enable/disabel discarding of received A2DP frames
123  **
124  *******************************************************************************/
125 void btc_a2dp_sink_set_rx_flush(BOOLEAN enable);
126 
127 /*******************************************************************************
128  **
129  ** Function         btc_a2dp_sink_reset_decoder
130  **
131  ** Description      Reset decoder parameters according to configuration from remote
132  **                  device
133  **
134  *******************************************************************************/
135 void btc_a2dp_sink_reset_decoder(UINT8 *p_av);
136 
137 #endif /* #if BTC_AV_SINK_INCLUDED */
138 
139 #endif /* __BTC_A2DP_SINK_H__ */
140