1 /* 2 * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef __BTC_AV_CO_H__ 8 #define __BTC_AV_CO_H__ 9 10 #include "btc_a2dp.h" 11 #include "bta/bta_av_co.h" 12 13 #if (BTA_AV_INCLUDED == TRUE) 14 /******************************************************************************* 15 ** Constants & Macros 16 ********************************************************************************/ 17 18 enum { 19 BTC_SV_AV_AA_SBC_INDEX = 0, 20 BTC_SV_AV_AA_SBC_SINK_INDEX, 21 BTC_SV_AV_AA_SEP_INDEX /* Last index */ 22 }; 23 24 /***************************************************************************** 25 ** Local data 26 *****************************************************************************/ 27 typedef struct { 28 UINT8 sep_info_idx; /* local SEP index (in BTA tables) */ 29 UINT8 seid; /* peer SEP index (in peer tables) */ 30 UINT8 codec_type; /* peer SEP codec type */ 31 UINT8 codec_caps[AVDT_CODEC_SIZE]; /* peer SEP codec capabilities */ 32 UINT8 num_protect; /* peer SEP number of CP elements */ 33 UINT8 protect_info[BTA_AV_CP_INFO_LEN]; /* peer SEP content protection info */ 34 } tBTA_AV_CO_SINK; 35 36 typedef struct { 37 BD_ADDR addr; /* address of audio/video peer */ 38 tBTA_AV_CO_SINK snks[BTC_SV_AV_AA_SEP_INDEX]; /* array of supported sinks */ 39 tBTA_AV_CO_SINK srcs[BTC_SV_AV_AA_SEP_INDEX]; /* array of supported srcs */ 40 UINT8 num_snks; /* total number of sinks at peer */ 41 UINT8 num_srcs; /* total number of srcs at peer */ 42 UINT8 num_seps; /* total number of seids at peer */ 43 UINT8 num_rx_snks; /* number of received sinks */ 44 UINT8 num_rx_srcs; /* number of received srcs */ 45 UINT8 num_sup_snks; /* number of supported sinks in the snks array */ 46 UINT8 num_sup_srcs; /* number of supported srcs in the srcs array */ 47 tBTA_AV_CO_SINK *p_snk; /* currently selected sink */ 48 tBTA_AV_CO_SINK *p_src; /* currently selected src */ 49 UINT8 codec_cfg[AVDT_CODEC_SIZE]; /* current codec configuration */ 50 BOOLEAN cp_active; /* current CP configuration */ 51 BOOLEAN acp; /* acceptor */ 52 BOOLEAN recfg_needed; /* reconfiguration is needed */ 53 BOOLEAN opened; /* opened */ 54 UINT16 mtu; /* maximum transmit unit size */ 55 UINT16 uuid_to_connect; /* uuid of peer device */ 56 BOOLEAN got_disc_res; /* got the results of initiating discovery */ 57 } tBTA_AV_CO_PEER; 58 59 typedef struct { 60 BOOLEAN active; 61 UINT8 flag; 62 } tBTA_AV_CO_CP; 63 64 typedef struct { 65 /* Connected peer information */ 66 tBTA_AV_CO_PEER peers[BTA_AV_NUM_STRS]; 67 /* Current codec configuration - access to this variable must be protected */ 68 tBTC_AV_CODEC_INFO codec_cfg; 69 tBTC_AV_CODEC_INFO codec_cfg_setconfig; /* remote peer setconfig preference */ 70 71 tBTA_AV_CO_CP cp; 72 } tBTA_AV_CO_CB; 73 74 /* Control block instance */ 75 #if AVRC_DYNAMIC_MEMORY == FALSE 76 extern tBTA_AV_CO_CB bta_av_co_cb; 77 #else 78 extern tBTA_AV_CO_CB *bta_av_co_cb_ptr; 79 #define bta_av_co_cb (*bta_av_co_cb_ptr) 80 #endif 81 /******************************************************************************* 82 ** Functions 83 ********************************************************************************/ 84 85 /******************************************************************************* 86 ** 87 ** Function bta_av_co_cp_is_active 88 ** 89 ** Description Get the current configuration of content protection 90 ** 91 ** Returns TRUE if the current streaming has CP, FALSE otherwise 92 ** 93 *******************************************************************************/ 94 BOOLEAN bta_av_co_cp_is_active(void); 95 96 /******************************************************************************* 97 ** 98 ** Function bta_av_co_cp_get_flag 99 ** 100 ** Description Get content protection flag 101 ** BTA_AV_CP_SCMS_COPY_NEVER 102 ** BTA_AV_CP_SCMS_COPY_ONCE 103 ** BTA_AV_CP_SCMS_COPY_FREE 104 ** 105 ** Returns The current flag value 106 ** 107 *******************************************************************************/ 108 UINT8 bta_av_co_cp_get_flag(void); 109 110 /******************************************************************************* 111 ** 112 ** Function bta_av_co_cp_set_flag 113 ** 114 ** Description Set content protection flag 115 ** BTA_AV_CP_SCMS_COPY_NEVER 116 ** BTA_AV_CP_SCMS_COPY_ONCE 117 ** BTA_AV_CP_SCMS_COPY_FREE 118 ** 119 ** Returns TRUE if setting the SCMS flag is supported else FALSE 120 ** 121 *******************************************************************************/ 122 BOOLEAN bta_av_co_cp_set_flag(UINT8 cp_flag); 123 124 /******************************************************************************* 125 ** 126 ** Function bta_av_co_audio_codec_reset 127 ** 128 ** Description Reset the current codec configuration 129 ** 130 ** Returns void 131 ** 132 *******************************************************************************/ 133 void bta_av_co_audio_codec_reset(void); 134 135 /******************************************************************************* 136 ** 137 ** Function bta_av_co_audio_codec_supported 138 ** 139 ** Description Check if all opened connections are compatible with a codec 140 ** configuration 141 ** 142 ** Returns TRUE if all opened devices support this codec, FALSE otherwise 143 ** 144 *******************************************************************************/ 145 BOOLEAN bta_av_co_audio_codec_supported(tBTC_AV_STATUS *p_status); 146 147 /******************************************************************************* 148 ** 149 ** Function bta_av_co_audio_set_codec 150 ** 151 ** Description Set the current codec configuration from the feeding type. 152 ** This function is starting to modify the configuration, it 153 ** should be protected. 154 ** 155 ** Returns TRUE if successful, FALSE otherwise 156 ** 157 *******************************************************************************/ 158 BOOLEAN bta_av_co_audio_set_codec(const tBTC_AV_MEDIA_FEEDINGS *p_feeding, tBTC_AV_STATUS *p_status); 159 160 /******************************************************************************* 161 ** 162 ** Function bta_av_co_audio_get_sbc_config 163 ** 164 ** Description Retrieves the SBC codec configuration. If the codec in use 165 ** is not SBC, return the default SBC codec configuration. 166 ** 167 ** Returns TRUE if codec is SBC, FALSE otherwise 168 ** 169 *******************************************************************************/ 170 BOOLEAN bta_av_co_audio_get_sbc_config(tA2D_SBC_CIE *p_sbc_config, UINT16 *p_minmtu); 171 172 /******************************************************************************* 173 ** 174 ** Function bta_av_co_audio_discard_config 175 ** 176 ** Description Discard the codec configuration of a connection 177 ** 178 ** Returns Nothing 179 ** 180 *******************************************************************************/ 181 void bta_av_co_audio_discard_config(tBTA_AV_HNDL hndl); 182 183 /******************************************************************************* 184 ** 185 ** Function bta_av_co_init 186 ** 187 ** Description Initialization 188 ** 189 ** Returns Nothing 190 ** 191 *******************************************************************************/ 192 void bta_av_co_init(void); 193 194 195 /******************************************************************************* 196 ** 197 ** Function bta_av_co_peer_cp_supported 198 ** 199 ** Description Checks if the peer supports CP 200 ** 201 ** Returns TRUE if the peer supports CP 202 ** 203 *******************************************************************************/ 204 BOOLEAN bta_av_co_peer_cp_supported(tBTA_AV_HNDL hndl); 205 206 /******************************************************************************* 207 ** 208 ** Function bta_av_co_get_remote_bitpool_pref 209 ** 210 ** Description Check if remote side did a setconfig within the limits 211 ** of our exported bitpool range. If set we will set the 212 ** remote preference. 213 ** 214 ** Returns TRUE if config set, FALSE otherwize 215 ** 216 *******************************************************************************/ 217 BOOLEAN bta_av_co_get_remote_bitpool_pref(UINT8 *min, UINT8 *max); 218 219 #endif ///BTA_AV_INCLUDED == TRUE 220 221 #endif 222