1 /****************************************************************************** 2 * 3 * Copyright (C) 2003-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 * This is the interface file for advanced audio/video call-out functions. 22 * 23 ******************************************************************************/ 24 #ifndef BTA_AV_CO_H 25 #define BTA_AV_CO_H 26 27 #include "stack/l2c_api.h" 28 #include "bta/bta_av_api.h" 29 30 #if (BTA_AV_INCLUDED == TRUE) 31 32 /***************************************************************************** 33 ** Constants and data types 34 *****************************************************************************/ 35 36 /* TRUE to use SCMS-T content protection */ 37 #ifndef BTA_AV_CO_CP_SCMS_T 38 #define BTA_AV_CO_CP_SCMS_T FALSE 39 #endif 40 41 /* the content protection IDs assigned by BT SIG */ 42 #define BTA_AV_CP_SCMS_T_ID 0x0002 43 #define BTA_AV_CP_DTCP_ID 0x0001 44 45 #define BTA_AV_CP_LOSC 2 46 #define BTA_AV_CP_INFO_LEN 3 47 48 #define BTA_AV_CP_SCMS_COPY_MASK 3 49 #define BTA_AV_CP_SCMS_COPY_FREE 2 50 #define BTA_AV_CP_SCMS_COPY_ONCE 1 51 #define BTA_AV_CP_SCMS_COPY_NEVER 0 52 53 #define BTA_AV_CO_DEFAULT_AUDIO_OFFSET AVDT_MEDIA_OFFSET 54 55 enum { 56 BTA_AV_CO_ST_INIT, 57 BTA_AV_CO_ST_IN, 58 BTA_AV_CO_ST_OUT, 59 BTA_AV_CO_ST_OPEN, 60 BTA_AV_CO_ST_STREAM 61 }; 62 63 64 /* data type for the Audio Codec Information*/ 65 typedef struct { 66 UINT16 bit_rate; /* SBC encoder bit rate in kbps */ 67 UINT16 bit_rate_busy; /* SBC encoder bit rate in kbps */ 68 UINT16 bit_rate_swampd;/* SBC encoder bit rate in kbps */ 69 UINT8 busy_level; /* Busy level indicating the bit-rate to be used */ 70 UINT8 codec_info[AVDT_CODEC_SIZE]; 71 UINT8 codec_type; /* Codec type */ 72 } tBTA_AV_AUDIO_CODEC_INFO; 73 74 /******************************************************************************* 75 ** 76 ** Function bta_av_co_audio_init 77 ** 78 ** Description This callout function is executed by AV when it is 79 ** started by calling BTA_AvEnable(). This function can be 80 ** used by the phone to initialize audio paths or for other 81 ** initialization purposes. 82 ** 83 ** 84 ** Returns Stream codec and content protection capabilities info. 85 ** 86 *******************************************************************************/ 87 extern BOOLEAN bta_av_co_audio_init(UINT8 *p_codec_type, UINT8 *p_codec_info, 88 UINT8 *p_num_protect, UINT8 *p_protect_info, UINT8 tsep); 89 90 /******************************************************************************* 91 ** 92 ** Function bta_av_co_audio_disc_res 93 ** 94 ** Description This callout function is executed by AV to report the 95 ** number of stream end points (SEP) were found during the 96 ** AVDT stream discovery process. 97 ** 98 ** 99 ** Returns void. 100 ** 101 *******************************************************************************/ 102 extern void bta_av_co_audio_disc_res(tBTA_AV_HNDL hndl, UINT8 num_seps, 103 UINT8 num_snk, UINT8 num_src, BD_ADDR addr, UINT16 uuid_local); 104 105 /******************************************************************************* 106 ** 107 ** Function bta_av_co_video_disc_res 108 ** 109 ** Description This callout function is executed by AV to report the 110 ** number of stream end points (SEP) were found during the 111 ** AVDT stream discovery process. 112 ** 113 ** 114 ** Returns void. 115 ** 116 *******************************************************************************/ 117 extern void bta_av_co_video_disc_res(tBTA_AV_HNDL hndl, UINT8 num_seps, 118 UINT8 num_snk, BD_ADDR addr); 119 120 /******************************************************************************* 121 ** 122 ** Function bta_av_co_audio_getconfig 123 ** 124 ** Description This callout function is executed by AV to retrieve the 125 ** desired codec and content protection configuration for the 126 ** audio stream. 127 ** 128 ** 129 ** Returns Stream codec and content protection configuration info. 130 ** 131 *******************************************************************************/ 132 extern UINT8 bta_av_co_audio_getconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, 133 UINT8 *p_codec_info, UINT8 *p_sep_info_idx, UINT8 seid, 134 UINT8 *p_num_protect, UINT8 *p_protect_info); 135 136 /******************************************************************************* 137 ** 138 ** Function bta_av_co_video_getconfig 139 ** 140 ** Description This callout function is executed by AV to retrieve the 141 ** desired codec and content protection configuration for the 142 ** video stream. 143 ** 144 ** 145 ** Returns Stream codec and content protection configuration info. 146 ** 147 *******************************************************************************/ 148 extern UINT8 bta_av_co_video_getconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, 149 UINT8 *p_codec_info, UINT8 *p_sep_info_idx, UINT8 seid, 150 UINT8 *p_num_protect, UINT8 *p_protect_info); 151 152 /******************************************************************************* 153 ** 154 ** Function bta_av_co_audio_setconfig 155 ** 156 ** Description This callout function is executed by AV to set the 157 ** codec and content protection configuration of the audio stream. 158 ** 159 ** 160 ** Returns void 161 ** 162 *******************************************************************************/ 163 extern void bta_av_co_audio_setconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, 164 UINT8 *p_codec_info, UINT8 seid, BD_ADDR addr, 165 UINT8 num_protect, UINT8 *p_protect_info, UINT8 t_local_sep, UINT8 avdt_handle); 166 167 /******************************************************************************* 168 ** 169 ** Function bta_av_co_video_setconfig 170 ** 171 ** Description This callout function is executed by AV to set the 172 ** codec and content protection configuration of the video stream. 173 ** 174 ** 175 ** Returns void 176 ** 177 *******************************************************************************/ 178 extern void bta_av_co_video_setconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, 179 UINT8 *p_codec_info, UINT8 seid, BD_ADDR addr, 180 UINT8 num_protect, UINT8 *p_protect_info); 181 182 /******************************************************************************* 183 ** 184 ** Function bta_av_co_audio_open 185 ** 186 ** Description This function is called by AV when the audio stream connection 187 ** is opened. 188 ** BTA-AV maintains the MTU of A2DP streams. 189 ** If this is the 2nd audio stream, mtu is the smaller of the 2 190 ** streams. 191 ** 192 ** Returns void 193 ** 194 *******************************************************************************/ 195 extern void bta_av_co_audio_open(tBTA_AV_HNDL hndl, 196 tBTA_AV_CODEC codec_type, UINT8 *p_codec_info, 197 UINT16 mtu); 198 199 /******************************************************************************* 200 ** 201 ** Function bta_av_co_video_open 202 ** 203 ** Description This function is called by AV when the video stream connection 204 ** is opened. 205 ** 206 ** 207 ** Returns void 208 ** 209 *******************************************************************************/ 210 extern void bta_av_co_video_open(tBTA_AV_HNDL hndl, 211 tBTA_AV_CODEC codec_type, UINT8 *p_codec_info, 212 UINT16 mtu); 213 214 /******************************************************************************* 215 ** 216 ** Function bta_av_co_audio_close 217 ** 218 ** Description This function is called by AV when the audio stream connection 219 ** is closed. 220 ** BTA-AV maintains the MTU of A2DP streams. 221 ** When one stream is closed and no other audio stream is open, 222 ** mtu is reported as 0. 223 ** Otherwise, the MTU remains open is reported. 224 ** 225 ** Returns void 226 ** 227 *******************************************************************************/ 228 extern void bta_av_co_audio_close(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, 229 UINT16 mtu); 230 231 /******************************************************************************* 232 ** 233 ** Function bta_av_co_video_close 234 ** 235 ** Description This function is called by AV when the video stream connection 236 ** is closed. 237 ** 238 ** 239 ** Returns void 240 ** 241 *******************************************************************************/ 242 extern void bta_av_co_video_close(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, 243 UINT16 mtu); 244 245 /******************************************************************************* 246 ** 247 ** Function bta_av_co_audio_start 248 ** 249 ** Description This function is called by AV when the audio streaming data 250 ** transfer is started. 251 ** 252 ** 253 ** Returns void 254 ** 255 *******************************************************************************/ 256 extern void bta_av_co_audio_start(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, 257 UINT8 *p_codec_info, BOOLEAN *p_no_rtp_hdr); 258 259 /******************************************************************************* 260 ** 261 ** Function bta_av_co_video_start 262 ** 263 ** Description This function is called by AV when the video streaming data 264 ** transfer is started. 265 ** 266 ** 267 ** Returns void 268 ** 269 *******************************************************************************/ 270 extern void bta_av_co_video_start(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, 271 UINT8 *p_codec_info, BOOLEAN *p_no_rtp_hdr); 272 273 /******************************************************************************* 274 ** 275 ** Function bta_av_co_audio_stop 276 ** 277 ** Description This function is called by AV when the audio streaming data 278 ** transfer is stopped. 279 ** 280 ** 281 ** Returns void 282 ** 283 *******************************************************************************/ 284 extern void bta_av_co_audio_stop(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type); 285 286 /******************************************************************************* 287 ** 288 ** Function bta_av_co_video_stop 289 ** 290 ** Description This function is called by AV when the video streaming data 291 ** transfer is stopped. 292 ** 293 ** 294 ** Returns void 295 ** 296 *******************************************************************************/ 297 extern void bta_av_co_video_stop(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type); 298 299 /******************************************************************************* 300 ** 301 ** Function bta_av_co_audio_src_data_path 302 ** 303 ** Description This function is called to get the next data buffer from 304 ** the audio codec 305 ** 306 ** Returns NULL if data is not ready. 307 ** Otherwise, a buffer (BT_HDR*) containing the audio data. 308 ** 309 *******************************************************************************/ 310 extern void *bta_av_co_audio_src_data_path(tBTA_AV_CODEC codec_type, 311 UINT32 *p_len, UINT32 *p_timestamp); 312 313 /******************************************************************************* 314 ** 315 ** Function bta_av_co_video_src_data_path 316 ** 317 ** Description This function is called to get the next data buffer from 318 ** the video codec. 319 ** 320 ** Returns NULL if data is not ready. 321 ** Otherwise, a video data buffer (UINT8*). 322 ** 323 *******************************************************************************/ 324 extern void *bta_av_co_video_src_data_path(tBTA_AV_CODEC codec_type, 325 UINT32 *p_len, UINT32 *p_timestamp); 326 327 /******************************************************************************* 328 ** 329 ** Function bta_av_co_audio_drop 330 ** 331 ** Description An Audio packet is dropped. . 332 ** It's very likely that the connected headset with this handle 333 ** is moved far away. The implementation may want to reduce 334 ** the encoder bit rate setting to reduce the packet size. 335 ** 336 ** Returns void 337 ** 338 *******************************************************************************/ 339 extern void bta_av_co_audio_drop(tBTA_AV_HNDL hndl); 340 341 /******************************************************************************* 342 ** 343 ** Function bta_av_co_video_report_conn 344 ** 345 ** Description This function is called by AV when the reporting channel is 346 ** opened (open=TRUE) or closed (open=FALSE). 347 ** 348 ** Returns void 349 ** 350 *******************************************************************************/ 351 extern void bta_av_co_video_report_conn (BOOLEAN open, UINT8 avdt_handle); 352 353 /******************************************************************************* 354 ** 355 ** Function bta_av_co_video_report_rr 356 ** 357 ** Description This function is called by AV when a Receiver Report is 358 ** received 359 ** 360 ** Returns void 361 ** 362 *******************************************************************************/ 363 extern void bta_av_co_video_report_rr (UINT32 packet_lost); 364 365 /******************************************************************************* 366 ** 367 ** Function bta_av_co_audio_delay 368 ** 369 ** Description This function is called by AV when the audio stream connection 370 ** needs to send the initial delay report to the connected SRC. 371 ** 372 ** 373 ** Returns void 374 ** 375 *******************************************************************************/ 376 extern void bta_av_co_audio_delay(tBTA_AV_HNDL hndl, UINT16 delay); 377 378 /******************************************************************************* 379 ** 380 ** Function bta_av_co_video_delay 381 ** 382 ** Description This function is called by AV when the video stream connection 383 ** needs to send the initial delay report to the connected SRC. 384 ** 385 ** 386 ** Returns void 387 ** 388 *******************************************************************************/ 389 extern void bta_av_co_video_delay(tBTA_AV_HNDL hndl, UINT16 delay); 390 391 #endif ///BTA_AV_INCLUDED == TRUE 392 393 #endif /* BTA_AV_CO_H */ 394