1 /** @file 2 * @brief Bluetooth Audio handling 3 */ 4 5 /* 6 * Copyright (c) 2020 Intel Corporation 7 * Copyright (c) 2020-2023 Nordic Semiconductor ASA 8 * 9 * SPDX-License-Identifier: Apache-2.0 10 */ 11 #ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_AUDIO_H_ 12 #define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_AUDIO_H_ 13 14 /** 15 * @brief Bluetooth Audio 16 * @defgroup bt_audio Bluetooth Audio 17 * @ingroup bluetooth 18 * @{ 19 */ 20 21 #include <zephyr/sys/atomic.h> 22 #include <zephyr/bluetooth/buf.h> 23 #include <zephyr/bluetooth/conn.h> 24 #include <zephyr/bluetooth/hci.h> 25 #include <zephyr/bluetooth/iso.h> 26 #include <zephyr/bluetooth/gatt.h> 27 #include <zephyr/bluetooth/audio/lc3.h> 28 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 #define BT_AUDIO_BROADCAST_ID_SIZE 3 /* octets */ 35 /** Maximum broadcast ID value */ 36 #define BT_AUDIO_BROADCAST_ID_MAX 0xFFFFFFU 37 /** Indicates that the server have no preference for the presentation delay */ 38 #define BT_AUDIO_PD_PREF_NONE 0x000000U 39 /** Maximum presentation delay in microseconds */ 40 #define BT_AUDIO_PD_MAX 0xFFFFFFU 41 42 #define BT_AUDIO_BROADCAST_CODE_SIZE 16 43 44 /** @brief Audio Context Type for Generic Audio 45 * 46 * These values are defined by the Generic Audio Assigned Numbers, bluetooth.com 47 */ 48 enum bt_audio_context { 49 BT_AUDIO_CONTEXT_TYPE_PROHIBITED = 0, 50 BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED = BIT(0), 51 BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL = BIT(1), 52 BT_AUDIO_CONTEXT_TYPE_MEDIA = BIT(2), 53 BT_AUDIO_CONTEXT_TYPE_GAME = BIT(3), 54 BT_AUDIO_CONTEXT_TYPE_INSTRUCTIONAL = BIT(4), 55 BT_AUDIO_CONTEXT_TYPE_VOICE_ASSISTANTS = BIT(5), 56 BT_AUDIO_CONTEXT_TYPE_LIVE = BIT(6), 57 BT_AUDIO_CONTEXT_TYPE_SOUND_EFFECTS = BIT(7), 58 BT_AUDIO_CONTEXT_TYPE_NOTIFICATIONS = BIT(8), 59 BT_AUDIO_CONTEXT_TYPE_RINGTONE = BIT(9), 60 BT_AUDIO_CONTEXT_TYPE_ALERTS = BIT(10), 61 BT_AUDIO_CONTEXT_TYPE_EMERGENCY_ALARM = BIT(11), 62 }; 63 64 /** 65 * Any known context. 66 */ 67 #define BT_AUDIO_CONTEXT_TYPE_ANY (BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED | \ 68 BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | \ 69 BT_AUDIO_CONTEXT_TYPE_MEDIA | \ 70 BT_AUDIO_CONTEXT_TYPE_GAME | \ 71 BT_AUDIO_CONTEXT_TYPE_INSTRUCTIONAL | \ 72 BT_AUDIO_CONTEXT_TYPE_VOICE_ASSISTANTS | \ 73 BT_AUDIO_CONTEXT_TYPE_LIVE | \ 74 BT_AUDIO_CONTEXT_TYPE_SOUND_EFFECTS | \ 75 BT_AUDIO_CONTEXT_TYPE_NOTIFICATIONS | \ 76 BT_AUDIO_CONTEXT_TYPE_RINGTONE | \ 77 BT_AUDIO_CONTEXT_TYPE_ALERTS | \ 78 BT_AUDIO_CONTEXT_TYPE_EMERGENCY_ALARM) 79 80 /** 81 * @brief Parental rating defined by the Generic Audio assigned numbers (bluetooth.com). 82 * 83 * The numbering scheme is aligned with Annex F of EN 300 707 v1.2.1 which 84 * defined parental rating for viewing. 85 */ 86 enum bt_audio_parental_rating { 87 BT_AUDIO_PARENTAL_RATING_NO_RATING = 0x00, 88 BT_AUDIO_PARENTAL_RATING_AGE_ANY = 0x01, 89 BT_AUDIO_PARENTAL_RATING_AGE_5_OR_ABOVE = 0x02, 90 BT_AUDIO_PARENTAL_RATING_AGE_6_OR_ABOVE = 0x03, 91 BT_AUDIO_PARENTAL_RATING_AGE_7_OR_ABOVE = 0x04, 92 BT_AUDIO_PARENTAL_RATING_AGE_8_OR_ABOVE = 0x05, 93 BT_AUDIO_PARENTAL_RATING_AGE_9_OR_ABOVE = 0x06, 94 BT_AUDIO_PARENTAL_RATING_AGE_10_OR_ABOVE = 0x07, 95 BT_AUDIO_PARENTAL_RATING_AGE_11_OR_ABOVE = 0x08, 96 BT_AUDIO_PARENTAL_RATING_AGE_12_OR_ABOVE = 0x09, 97 BT_AUDIO_PARENTAL_RATING_AGE_13_OR_ABOVE = 0x0A, 98 BT_AUDIO_PARENTAL_RATING_AGE_14_OR_ABOVE = 0x0B, 99 BT_AUDIO_PARENTAL_RATING_AGE_15_OR_ABOVE = 0x0C, 100 BT_AUDIO_PARENTAL_RATING_AGE_16_OR_ABOVE = 0x0D, 101 BT_AUDIO_PARENTAL_RATING_AGE_17_OR_ABOVE = 0x0E, 102 BT_AUDIO_PARENTAL_RATING_AGE_18_OR_ABOVE = 0x0F 103 }; 104 105 /** @brief Audio Active State defined by the Generic Audio assigned numbers (bluetooth.com). */ 106 enum bt_audio_active_state { 107 BT_AUDIO_ACTIVE_STATE_DISABLED = 0x00, 108 BT_AUDIO_ACTIVE_STATE_ENABLED = 0x01, 109 }; 110 111 /** 112 * @brief Codec metadata type IDs 113 * 114 * Metadata types defined by the Generic Audio assigned numbers (bluetooth.com). 115 */ 116 enum bt_audio_metadata_type { 117 /** @brief Preferred audio context. 118 * 119 * Bitfield of preferred audio contexts. 120 * 121 * If 0, the context type is not a preferred use case for this codec 122 * configuration. 123 * 124 * See the BT_AUDIO_CONTEXT_* for valid values. 125 */ 126 BT_AUDIO_METADATA_TYPE_PREF_CONTEXT = 0x01, 127 128 /** @brief Streaming audio context. 129 * 130 * Bitfield of streaming audio contexts. 131 * 132 * If 0, the context type is not a preferred use case for this codec 133 * configuration. 134 * 135 * See the BT_AUDIO_CONTEXT_* for valid values. 136 */ 137 BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT = 0x02, 138 139 /** UTF-8 encoded title or summary of stream content */ 140 BT_AUDIO_METADATA_TYPE_PROGRAM_INFO = 0x03, 141 142 /** @brief Stream language 143 * 144 * 3 octet lower case language code defined by ISO 639-3 145 */ 146 BT_AUDIO_METADATA_TYPE_STREAM_LANG = 0x04, 147 148 /** Array of 8-bit CCID values */ 149 BT_AUDIO_METADATA_TYPE_CCID_LIST = 0x05, 150 151 /** @brief Parental rating 152 * 153 * See @ref bt_audio_parental_rating for valid values. 154 */ 155 BT_AUDIO_METADATA_TYPE_PARENTAL_RATING = 0x06, 156 157 /** UTF-8 encoded URI for additional Program information */ 158 BT_AUDIO_METADATA_TYPE_PROGRAM_INFO_URI = 0x07, 159 160 /** @brief Audio active state 161 * 162 * See @ref bt_audio_active_state for valid values. 163 */ 164 BT_AUDIO_METADATA_TYPE_AUDIO_STATE = 0x08, 165 166 /** Broadcast Audio Immediate Rendering flag */ 167 BT_AUDIO_METADATA_TYPE_BROADCAST_IMMEDIATE = 0x09, 168 169 /** Extended metadata */ 170 BT_AUDIO_METADATA_TYPE_EXTENDED = 0xFE, 171 172 /** Vendor specific metadata */ 173 BT_AUDIO_METADATA_TYPE_VENDOR = 0xFF, 174 }; 175 176 /** 177 * Helper to check whether metadata type is known by the stack. 178 */ 179 #define BT_AUDIO_METADATA_TYPE_IS_KNOWN(_type) \ 180 (IN_RANGE(_type, BT_AUDIO_METADATA_TYPE_PREF_CONTEXT, \ 181 BT_AUDIO_METADATA_TYPE_BROADCAST_IMMEDIATE) || \ 182 IN_RANGE(_type, BT_AUDIO_METADATA_TYPE_EXTENDED, BT_AUDIO_METADATA_TYPE_VENDOR)) 183 184 /* Unicast Announcement Type, Generic Audio */ 185 #define BT_AUDIO_UNICAST_ANNOUNCEMENT_GENERAL 0x00 186 #define BT_AUDIO_UNICAST_ANNOUNCEMENT_TARGETED 0x01 187 188 /** 189 * @brief Helper to declare elements of bt_audio_codec_cap arrays 190 * 191 * This macro is mainly for creating an array of struct bt_audio_codec_cap data arrays. 192 * 193 * @param _type Type of advertising data field 194 * @param _bytes Variable number of single-byte parameters 195 */ 196 #define BT_AUDIO_CODEC_DATA(_type, _bytes...) \ 197 (sizeof((uint8_t)_type) + sizeof((uint8_t[]){_bytes})), (_type), _bytes 198 199 /** 200 * @brief Helper to declare @ref bt_audio_codec_cfg 201 * 202 * @param _id Codec ID 203 * @param _cid Company ID 204 * @param _vid Vendor ID 205 * @param _data Codec Specific Data in LVT format 206 * @param _meta Codec Specific Metadata in LVT format 207 */ 208 #define BT_AUDIO_CODEC_CFG(_id, _cid, _vid, _data, _meta) \ 209 ((struct bt_audio_codec_cfg){ \ 210 /* Use HCI data path as default, can be overwritten by application */ \ 211 .path_id = BT_ISO_DATA_PATH_HCI, \ 212 .id = _id, \ 213 .cid = _cid, \ 214 .vid = _vid, \ 215 .data_len = sizeof((uint8_t[])_data), \ 216 .data = _data, \ 217 .meta_len = sizeof((uint8_t[])_meta), \ 218 .meta = _meta, \ 219 }) 220 221 /** 222 * @brief Helper to declare @ref bt_audio_codec_cap structure 223 * 224 * @param _id Codec ID 225 * @param _cid Company ID 226 * @param _vid Vendor ID 227 * @param _data Codec Specific Data in LVT format 228 * @param _meta Codec Specific Metadata in LVT format 229 */ 230 #define BT_AUDIO_CODEC_CAP(_id, _cid, _vid, _data, _meta) \ 231 ((struct bt_audio_codec_cap){ \ 232 /* Use HCI data path as default, can be overwritten by application */ \ 233 .path_id = BT_ISO_DATA_PATH_HCI, \ 234 .id = (_id), \ 235 .cid = (_cid), \ 236 .vid = (_vid), \ 237 .data_len = sizeof((uint8_t[])_data), \ 238 .data = _data, \ 239 .meta_len = sizeof((uint8_t[])_meta), \ 240 .meta = _meta, \ 241 }) 242 243 /** @brief Location values for BT Audio. 244 * 245 * These values are defined by the Generic Audio Assigned Numbers, bluetooth.com 246 */ 247 enum bt_audio_location { 248 BT_AUDIO_LOCATION_PROHIBITED = 0, 249 BT_AUDIO_LOCATION_FRONT_LEFT = BIT(0), 250 BT_AUDIO_LOCATION_FRONT_RIGHT = BIT(1), 251 BT_AUDIO_LOCATION_FRONT_CENTER = BIT(2), 252 BT_AUDIO_LOCATION_LOW_FREQ_EFFECTS_1 = BIT(3), 253 BT_AUDIO_LOCATION_BACK_LEFT = BIT(4), 254 BT_AUDIO_LOCATION_BACK_RIGHT = BIT(5), 255 BT_AUDIO_LOCATION_FRONT_LEFT_OF_CENTER = BIT(6), 256 BT_AUDIO_LOCATION_FRONT_RIGHT_OF_CENTER = BIT(7), 257 BT_AUDIO_LOCATION_BACK_CENTER = BIT(8), 258 BT_AUDIO_LOCATION_LOW_FREQ_EFFECTS_2 = BIT(9), 259 BT_AUDIO_LOCATION_SIDE_LEFT = BIT(10), 260 BT_AUDIO_LOCATION_SIDE_RIGHT = BIT(11), 261 BT_AUDIO_LOCATION_TOP_FRONT_LEFT = BIT(12), 262 BT_AUDIO_LOCATION_TOP_FRONT_RIGHT = BIT(13), 263 BT_AUDIO_LOCATION_TOP_FRONT_CENTER = BIT(14), 264 BT_AUDIO_LOCATION_TOP_CENTER = BIT(15), 265 BT_AUDIO_LOCATION_TOP_BACK_LEFT = BIT(16), 266 BT_AUDIO_LOCATION_TOP_BACK_RIGHT = BIT(17), 267 BT_AUDIO_LOCATION_TOP_SIDE_LEFT = BIT(18), 268 BT_AUDIO_LOCATION_TOP_SIDE_RIGHT = BIT(19), 269 BT_AUDIO_LOCATION_TOP_BACK_CENTER = BIT(20), 270 BT_AUDIO_LOCATION_BOTTOM_FRONT_CENTER = BIT(21), 271 BT_AUDIO_LOCATION_BOTTOM_FRONT_LEFT = BIT(22), 272 BT_AUDIO_LOCATION_BOTTOM_FRONT_RIGHT = BIT(23), 273 BT_AUDIO_LOCATION_FRONT_LEFT_WIDE = BIT(24), 274 BT_AUDIO_LOCATION_FRONT_RIGHT_WIDE = BIT(25), 275 BT_AUDIO_LOCATION_LEFT_SURROUND = BIT(26), 276 BT_AUDIO_LOCATION_RIGHT_SURROUND = BIT(27), 277 }; 278 279 /** 280 * Any known location. 281 */ 282 #define BT_AUDIO_LOCATION_ANY (BT_AUDIO_LOCATION_FRONT_LEFT | \ 283 BT_AUDIO_LOCATION_FRONT_RIGHT | \ 284 BT_AUDIO_LOCATION_FRONT_CENTER | \ 285 BT_AUDIO_LOCATION_LOW_FREQ_EFFECTS_1 | \ 286 BT_AUDIO_LOCATION_BACK_LEFT | \ 287 BT_AUDIO_LOCATION_BACK_RIGHT | \ 288 BT_AUDIO_LOCATION_FRONT_LEFT_OF_CENTER | \ 289 BT_AUDIO_LOCATION_FRONT_RIGHT_OF_CENTER | \ 290 BT_AUDIO_LOCATION_BACK_CENTER | \ 291 BT_AUDIO_LOCATION_LOW_FREQ_EFFECTS_2 | \ 292 BT_AUDIO_LOCATION_SIDE_LEFT | \ 293 BT_AUDIO_LOCATION_SIDE_RIGHT | \ 294 BT_AUDIO_LOCATION_TOP_FRONT_LEFT | \ 295 BT_AUDIO_LOCATION_TOP_FRONT_RIGHT | \ 296 BT_AUDIO_LOCATION_TOP_FRONT_CENTER | \ 297 BT_AUDIO_LOCATION_TOP_CENTER | \ 298 BT_AUDIO_LOCATION_TOP_BACK_LEFT | \ 299 BT_AUDIO_LOCATION_TOP_BACK_RIGHT | \ 300 BT_AUDIO_LOCATION_TOP_SIDE_LEFT | \ 301 BT_AUDIO_LOCATION_TOP_SIDE_RIGHT | \ 302 BT_AUDIO_LOCATION_TOP_BACK_CENTER | \ 303 BT_AUDIO_LOCATION_BOTTOM_FRONT_CENTER | \ 304 BT_AUDIO_LOCATION_BOTTOM_FRONT_LEFT | \ 305 BT_AUDIO_LOCATION_BOTTOM_FRONT_RIGHT | \ 306 BT_AUDIO_LOCATION_FRONT_LEFT_WIDE | \ 307 BT_AUDIO_LOCATION_FRONT_RIGHT_WIDE | \ 308 BT_AUDIO_LOCATION_LEFT_SURROUND | \ 309 BT_AUDIO_LOCATION_RIGHT_SURROUND) 310 311 /** @brief Codec capability structure. */ 312 struct bt_audio_codec_cap { 313 /** Data path ID 314 * 315 * @ref BT_ISO_DATA_PATH_HCI for HCI path, or any other value for 316 * vendor specific ID. 317 */ 318 uint8_t path_id; 319 /** Codec ID */ 320 uint8_t id; 321 /** Codec Company ID */ 322 uint16_t cid; 323 /** Codec Company Vendor ID */ 324 uint16_t vid; 325 #if CONFIG_BT_AUDIO_CODEC_CAP_MAX_DATA_SIZE > 0 326 /** Codec Specific Capabilities Data count */ 327 size_t data_len; 328 /** Codec Specific Capabilities Data */ 329 uint8_t data[CONFIG_BT_AUDIO_CODEC_CAP_MAX_DATA_SIZE]; 330 #endif /* CONFIG_BT_AUDIO_CODEC_CAP_MAX_DATA_SIZE > 0 */ 331 #if defined(CONFIG_BT_AUDIO_CODEC_CAP_MAX_METADATA_SIZE) 332 /** Codec Specific Capabilities Metadata count */ 333 size_t meta_len; 334 /** Codec Specific Capabilities Metadata */ 335 uint8_t meta[CONFIG_BT_AUDIO_CODEC_CAP_MAX_METADATA_SIZE]; 336 #endif /* CONFIG_BT_AUDIO_CODEC_CAP_MAX_METADATA_SIZE */ 337 }; 338 339 /** @brief Codec specific configuration structure. */ 340 struct bt_audio_codec_cfg { 341 /** Data path ID 342 * 343 * @ref BT_ISO_DATA_PATH_HCI for HCI path, or any other value for 344 * vendor specific ID. 345 */ 346 uint8_t path_id; 347 /** Codec ID */ 348 uint8_t id; 349 /** Codec Company ID */ 350 uint16_t cid; 351 /** Codec Company Vendor ID */ 352 uint16_t vid; 353 #if CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_SIZE > 0 354 /** Codec Specific Capabilities Data count */ 355 size_t data_len; 356 /** Codec Specific Capabilities Data */ 357 uint8_t data[CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_SIZE]; 358 #endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_SIZE > 0 */ 359 #if CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE > 0 360 /** Codec Specific Capabilities Metadata count */ 361 size_t meta_len; 362 /** Codec Specific Capabilities Metadata */ 363 uint8_t meta[CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE]; 364 #endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE > 0 */ 365 }; 366 367 /** 368 * @brief Helper for parsing length-type-value data. 369 * 370 * @param ltv Length-type-value (LTV) encoded data. 371 * @param size Size of the @p ltv data. 372 * @param func Callback function which will be called for each element 373 * that's found in the data. The callback should return 374 * true to continue parsing, or false to stop parsing. 375 * @param user_data User data to be passed to the callback. 376 * 377 * @retval 0 if all entries were parsed. 378 * @retval -EINVAL if the data is incorrectly encoded 379 * @retval -ECANCELED if parsing was prematurely cancelled by the callback 380 */ 381 int bt_audio_data_parse(const uint8_t ltv[], size_t size, 382 bool (*func)(struct bt_data *data, void *user_data), void *user_data); 383 384 /** @brief Audio Capability type */ 385 enum bt_audio_dir { 386 BT_AUDIO_DIR_SINK = 0x01, 387 BT_AUDIO_DIR_SOURCE = 0x02, 388 }; 389 390 /** 391 * @brief Helper to declare elements of bt_audio_codec_qos 392 * 393 * @param _interval SDU interval (usec) 394 * @param _framing Framing 395 * @param _phy Target PHY 396 * @param _sdu Maximum SDU Size 397 * @param _rtn Retransmission number 398 * @param _latency Maximum Transport Latency (msec) 399 * @param _pd Presentation Delay (usec) 400 */ 401 #define BT_AUDIO_CODEC_QOS(_interval, _framing, _phy, _sdu, _rtn, _latency, _pd) \ 402 ((struct bt_audio_codec_qos){ \ 403 .interval = _interval, \ 404 .framing = _framing, \ 405 .phy = _phy, \ 406 .sdu = _sdu, \ 407 .rtn = _rtn, \ 408 .latency = _latency, \ 409 .pd = _pd, \ 410 }) 411 412 /** @brief Codec QoS Framing */ 413 enum bt_audio_codec_qos_framing { 414 BT_AUDIO_CODEC_QOS_FRAMING_UNFRAMED = 0x00, 415 BT_AUDIO_CODEC_QOS_FRAMING_FRAMED = 0x01, 416 }; 417 418 /** @brief Codec QoS Preferred PHY */ 419 enum { 420 BT_AUDIO_CODEC_QOS_1M = BIT(0), 421 BT_AUDIO_CODEC_QOS_2M = BIT(1), 422 BT_AUDIO_CODEC_QOS_CODED = BIT(2), 423 }; 424 425 /** 426 * @brief Helper to declare Input Unframed bt_audio_codec_qos 427 * 428 * @param _interval SDU interval (usec) 429 * @param _sdu Maximum SDU Size 430 * @param _rtn Retransmission number 431 * @param _latency Maximum Transport Latency (msec) 432 * @param _pd Presentation Delay (usec) 433 */ 434 #define BT_AUDIO_CODEC_QOS_UNFRAMED(_interval, _sdu, _rtn, _latency, _pd) \ 435 BT_AUDIO_CODEC_QOS(_interval, BT_AUDIO_CODEC_QOS_FRAMING_UNFRAMED, BT_AUDIO_CODEC_QOS_2M, \ 436 _sdu, _rtn, _latency, _pd) 437 438 /** 439 * @brief Helper to declare Input Framed bt_audio_codec_qos 440 * 441 * @param _interval SDU interval (usec) 442 * @param _sdu Maximum SDU Size 443 * @param _rtn Retransmission number 444 * @param _latency Maximum Transport Latency (msec) 445 * @param _pd Presentation Delay (usec) 446 */ 447 #define BT_AUDIO_CODEC_QOS_FRAMED(_interval, _sdu, _rtn, _latency, _pd) \ 448 BT_AUDIO_CODEC_QOS(_interval, BT_AUDIO_CODEC_QOS_FRAMING_FRAMED, BT_AUDIO_CODEC_QOS_2M, \ 449 _sdu, _rtn, _latency, _pd) 450 451 /** @brief Codec QoS structure. */ 452 struct bt_audio_codec_qos { 453 /** QoS PHY */ 454 uint8_t phy; 455 456 /** QoS Framing */ 457 enum bt_audio_codec_qos_framing framing; 458 459 /** QoS Retransmission Number */ 460 uint8_t rtn; 461 462 /** QoS SDU */ 463 uint16_t sdu; 464 465 #if defined(CONFIG_BT_BAP_BROADCAST_SOURCE) || defined(CONFIG_BT_BAP_UNICAST) 466 /** 467 * @brief QoS Transport Latency 468 * 469 * Not used for the @kconfig{CONFIG_BT_BAP_BROADCAST_SINK} role. 470 */ 471 uint16_t latency; 472 #endif /* CONFIG_BT_BAP_BROADCAST_SOURCE || CONFIG_BT_BAP_UNICAST */ 473 474 /** QoS Frame Interval */ 475 uint32_t interval; 476 477 /** @brief QoS Presentation Delay in microseconds 478 * 479 * Value range 0 to @ref BT_AUDIO_PD_MAX. 480 */ 481 uint32_t pd; 482 }; 483 484 /** 485 * @brief Helper to declare elements of @ref bt_audio_codec_qos_pref 486 * 487 * @param _unframed_supported Unframed PDUs supported 488 * @param _phy Preferred Target PHY 489 * @param _rtn Preferred Retransmission number 490 * @param _latency Preferred Maximum Transport Latency (msec) 491 * @param _pd_min Minimum Presentation Delay (usec) 492 * @param _pd_max Maximum Presentation Delay (usec) 493 * @param _pref_pd_min Preferred Minimum Presentation Delay (usec) 494 * @param _pref_pd_max Preferred Maximum Presentation Delay (usec) 495 */ 496 #define BT_AUDIO_CODEC_QOS_PREF(_unframed_supported, _phy, _rtn, _latency, _pd_min, _pd_max, \ 497 _pref_pd_min, _pref_pd_max) \ 498 { \ 499 .unframed_supported = _unframed_supported, \ 500 .phy = _phy, \ 501 .rtn = _rtn, \ 502 .latency = _latency, \ 503 .pd_min = _pd_min, \ 504 .pd_max = _pd_max, \ 505 .pref_pd_min = _pref_pd_min, \ 506 .pref_pd_max = _pref_pd_max, \ 507 } 508 509 /** @brief Audio Stream Quality of Service Preference structure. */ 510 struct bt_audio_codec_qos_pref { 511 /** @brief Unframed PDUs supported 512 * 513 * Unlike the other fields, this is not a preference but whether 514 * the codec supports unframed ISOAL PDUs. 515 */ 516 bool unframed_supported; 517 518 /** Preferred PHY */ 519 uint8_t phy; 520 521 /** Preferred Retransmission Number */ 522 uint8_t rtn; 523 524 /** Preferred Transport Latency */ 525 uint16_t latency; 526 527 /** @brief Minimum Presentation Delay in microseconds 528 * 529 * Unlike the other fields, this is not a preference but a minimum 530 * requirement. 531 * 532 * Value range 0 to @ref BT_AUDIO_PD_MAX, or @ref BT_AUDIO_PD_PREF_NONE 533 * to indicate no preference. 534 */ 535 uint32_t pd_min; 536 537 /** @brief Maximum Presentation Delay 538 * 539 * Unlike the other fields, this is not a preference but a maximum 540 * requirement. 541 * 542 * Value range 0 to @ref BT_AUDIO_PD_MAX, or @ref BT_AUDIO_PD_PREF_NONE 543 * to indicate no preference. 544 */ 545 uint32_t pd_max; 546 547 /** @brief Preferred minimum Presentation Delay 548 * 549 * Value range 0 to @ref BT_AUDIO_PD_MAX. 550 */ 551 uint32_t pref_pd_min; 552 553 /** @brief Preferred maximum Presentation Delay 554 * 555 * Value range 0 to @ref BT_AUDIO_PD_MAX. 556 */ 557 uint32_t pref_pd_max; 558 }; 559 560 /** 561 * @brief Audio codec Config APIs 562 * @defgroup bt_audio_codec_cfg Codec config parsing APIs 563 * 564 * Functions to parse codec config data when formatted as LTV wrapped into @ref bt_audio_codec_cfg. 565 * 566 * @{ 567 */ 568 569 /** 570 * @brief Convert assigned numbers frequency to frequency value. 571 * 572 * @param freq The assigned numbers frequency to convert. 573 * 574 * @retval -EINVAL if arguments are invalid. 575 * @retval The converted frequency value in Hz. 576 */ 577 int bt_audio_codec_cfg_freq_to_freq_hz(enum bt_audio_codec_config_freq freq); 578 579 /** 580 * @brief Convert frequency value to assigned numbers frequency. 581 * 582 * @param freq_hz The frequency value to convert. 583 * 584 * @retval -EINVAL if arguments are invalid. 585 * @retval The assigned numbers frequency (@ref bt_audio_codec_config_freq). 586 */ 587 int bt_audio_codec_cfg_freq_hz_to_freq(uint32_t freq_hz); 588 589 /**@brief Extract the frequency from a codec configuration. 590 * 591 * @param codec_cfg The codec configuration to extract data from. 592 * 593 * @retval A @ref bt_audio_codec_config_freq value 594 * @retval -EINVAL if arguments are invalid 595 * @retval -ENODATA if not found 596 * @retval -EBADMSG if found value has invalid size or value 597 */ 598 int bt_audio_codec_cfg_get_freq(const struct bt_audio_codec_cfg *codec_cfg); 599 600 /** 601 * @brief Set the frequency of a codec configuration. 602 * 603 * @param codec_cfg The codec configuration to set data for. 604 * @param freq The assigned numbers frequency to set. 605 * 606 * @retval The data_len of @p codec_cfg on success 607 * @retval -EINVAL if arguments are invalid 608 * @retval -ENOMEM if the new value could not set or added due to memory 609 */ 610 int bt_audio_codec_cfg_set_freq(struct bt_audio_codec_cfg *codec_cfg, 611 enum bt_audio_codec_config_freq freq); 612 613 /** @brief Extract frame duration from BT codec config 614 * 615 * @param codec_cfg The codec configuration to extract data from. 616 * 617 * @retval Frame duration in microseconds 618 * @retval -EINVAL if arguments are invalid 619 * @retval -ENODATA if not found 620 * @retval -EBADMSG if found value has invalid size or value 621 */ 622 int bt_audio_codec_cfg_get_frame_duration_us(const struct bt_audio_codec_cfg *codec_cfg); 623 624 /** @brief Extract channel allocation from BT codec config 625 * 626 * The value returned is a bit field representing one or more audio locations as 627 * specified by @ref bt_audio_location 628 * Shall match one or more of the bits set in BT_PAC_SNK_LOC/BT_PAC_SRC_LOC. 629 * 630 * Up to the configured @ref BT_AUDIO_CODEC_LC3_CHAN_COUNT number of channels can be present. 631 * 632 * @param codec_cfg The codec configuration to extract data from. 633 * @param chan_allocation Pointer to the variable to store the extracted value in. 634 * 635 * @retval 0 if value is found and stored in the pointer provided 636 * @retval -EINVAL if arguments are invalid 637 * @retval -ENODATA if not found 638 * @retval -EBADMSG if found value has invalid size or value 639 */ 640 int bt_audio_codec_cfg_get_chan_allocation(const struct bt_audio_codec_cfg *codec_cfg, 641 enum bt_audio_location *chan_allocation); 642 643 /** 644 * @brief Set the channel allocation of a codec configuration. 645 * 646 * @param codec_cfg The codec configuration to set data for. 647 * @param chan_allocation The channel allocation to set. 648 * 649 * @retval The data_len of @p codec_cfg on success 650 * @retval -EINVAL if arguments are invalid 651 * @retval -ENOMEM if the new value could not set or added due to memory 652 */ 653 int bt_audio_codec_cfg_set_chan_allocation(struct bt_audio_codec_cfg *codec_cfg, 654 enum bt_audio_location chan_allocation); 655 656 /** @brief Extract frame size in octets from BT codec config 657 * 658 * The overall SDU size will be octets_per_frame * blocks_per_sdu. 659 * 660 * The Bluetooth specificationa are not clear about this value - it does not state that 661 * the codec shall use this SDU size only. A codec like LC3 supports variable bit-rate 662 * (per SDU) hence it might be allowed for an encoder to reduce the frame size below this 663 * value. 664 * Hence it is recommended to use the received SDU size and divide by 665 * blocks_per_sdu rather than relying on this octets_per_sdu value to be fixed. 666 * 667 * @param codec_cfg The codec configuration to extract data from. 668 * 669 * @retval Frame length in octets 670 * @retval -EINVAL if arguments are invalid 671 * @retval -ENODATA if not found 672 * @retval -EBADMSG if found value has invalid size or value 673 */ 674 int bt_audio_codec_cfg_get_octets_per_frame(const struct bt_audio_codec_cfg *codec_cfg); 675 676 /** 677 * @brief Set the octets per codec frame of a codec configuration. 678 * 679 * @param codec_cfg The codec configuration to set data for. 680 * @param octets_per_frame The octets per codec frame to set. 681 * 682 * @retval The data_len of @p codec_cfg on success 683 * @retval -EINVAL if arguments are invalid 684 * @retval -ENOMEM if the new value could not set or added due to memory 685 */ 686 int bt_audio_codec_cfg_set_octets_per_frame(struct bt_audio_codec_cfg *codec_cfg, 687 uint16_t octets_per_frame); 688 689 /** @brief Extract number of audio frame blockss in each SDU from BT codec config 690 * 691 * The overall SDU size will be octets_per_frame * frame_blocks_per_sdu * number-of-channels. 692 * 693 * If this value is not present a default value of 1 shall be used. 694 * 695 * A frame block is one or more frames that represents data for the same period of time but 696 * for different channels. If the stream have two audio channels and this value is two 697 * there will be four frames in the SDU. 698 * 699 * @param codec_cfg The codec configuration to extract data from. 700 * @param fallback_to_default If true this function will return the default value of 1 701 * if the type is not found. In this case the function will only fail if a NULL 702 * pointer is provided. 703 * 704 * @retval The count of codec frames in each SDU if value is found else of @p fallback_to_default 705 * is true then the value 1 is returned if frames per sdu is not found. 706 * @retval -EINVAL if arguments are invalid 707 * @retval -ENODATA if not found 708 * @retval -EBADMSG if found value has invalid size or value 709 */ 710 int bt_audio_codec_cfg_get_frame_blocks_per_sdu(const struct bt_audio_codec_cfg *codec_cfg, 711 bool fallback_to_default); 712 713 /** 714 * @brief Set the frame blocks per SDU of a codec configuration. 715 * 716 * @param codec_cfg The codec configuration to set data for. 717 * @param frame_blocks The frame blocks per SDU to set. 718 * 719 * @retval The data_len of @p codec_cfg on success 720 * @retval -EINVAL if arguments are invalid 721 * @retval -ENOMEM if the new value could not set or added due to memory 722 */ 723 int bt_audio_codec_cfg_set_frame_blocks_per_sdu(struct bt_audio_codec_cfg *codec_cfg, 724 uint8_t frame_blocks); 725 726 /** @brief Lookup a specific codec configuration value 727 * 728 * @param[in] codec_cfg The codec data to search in. 729 * @param[in] type The type id to look for 730 * @param[out] data Pointer to the data-pointer to update when item is found 731 * @return Length of found @p data or 0 if not found 732 */ 733 uint8_t bt_audio_codec_cfg_get_val(const struct bt_audio_codec_cfg *codec_cfg, uint8_t type, 734 const uint8_t **data); 735 736 /** 737 * @brief Set or add a specific codec configuration value 738 * 739 * @param codec_cfg The codec data to set the value in. 740 * @param type The type id to set 741 * @param data Pointer to the data-pointer to set 742 * @param data_len Length of @p data 743 * 744 * @retval The data_len of @p codec_cfg on success 745 * @retval -EINVAL if arguments are invalid 746 * @retval -ENOMEM if the new value could not set or added due to memory 747 */ 748 int bt_audio_codec_cfg_set_val(struct bt_audio_codec_cfg *codec_cfg, uint8_t type, 749 const uint8_t *data, size_t data_len); 750 751 /** @brief Lookup a specific metadata value based on type 752 * 753 * 754 * @param[in] codec_cfg The codec data to search in. 755 * @param[in] type The type id to look for 756 * @param[out] data Pointer to the data-pointer to update when item is found 757 * 758 * @retval Length of found @p data (may be 0) 759 * @retval -EINVAL if arguments are invalid 760 * @retval -ENODATA if not found 761 */ 762 int bt_audio_codec_cfg_meta_get_val(const struct bt_audio_codec_cfg *codec_cfg, uint8_t type, 763 const uint8_t **data); 764 765 /** @brief Extract preferred contexts 766 * 767 * See @ref BT_AUDIO_METADATA_TYPE_PREF_CONTEXT for more information about this value. 768 * 769 * @param codec_cfg The codec data to search in. 770 * 771 * @retval The preferred context type if positive or 0 772 * @retval -EINVAL if arguments are invalid 773 * @retval -ENODATA if not found 774 * @retval -EBADMSG if found value has invalid size 775 */ 776 int bt_audio_codec_cfg_meta_get_pref_context(const struct bt_audio_codec_cfg *codec_cfg); 777 778 /** @brief Extract stream contexts 779 * 780 * See @ref BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT for more information about this value. 781 * 782 * @param codec_cfg The codec data to search in. 783 * 784 * @retval The stream context type if positive or 0 785 * @retval -EINVAL if arguments are invalid 786 * @retval -ENODATA if not found 787 * @retval -EBADMSG if found value has invalid size 788 */ 789 int bt_audio_codec_cfg_meta_get_stream_context(const struct bt_audio_codec_cfg *codec_cfg); 790 791 /** @brief Extract program info 792 * 793 * See @ref BT_AUDIO_METADATA_TYPE_PROGRAM_INFO for more information about this value. 794 * 795 * @param[in] codec_cfg The codec data to search in. 796 * @param[out] program_info Pointer to the UTF-8 formatted program info. 797 * 798 * @retval The length of the @p program_info (may be 0) 799 * @retval -EINVAL if arguments are invalid 800 * @retval -ENODATA if not found 801 */ 802 int bt_audio_codec_cfg_meta_get_program_info(const struct bt_audio_codec_cfg *codec_cfg, 803 const uint8_t **program_info); 804 805 /** @brief Extract stream language 806 * 807 * See @ref BT_AUDIO_METADATA_TYPE_STREAM_LANG for more information about this value. 808 * 809 * @param codec_cfg The codec data to search in. 810 * 811 * @retval The stream language if positive or 0 812 * @retval -EINVAL if arguments are invalid 813 * @retval -ENODATA if not found 814 * @retval -EBADMSG if found value has invalid size 815 */ 816 int bt_audio_codec_cfg_meta_get_stream_lang(const struct bt_audio_codec_cfg *codec_cfg); 817 818 /** @brief Extract CCID list 819 * 820 * See @ref BT_AUDIO_METADATA_TYPE_CCID_LIST for more information about this value. 821 * 822 * @param[in] codec_cfg The codec data to search in. 823 * @param[out] ccid_list Pointer to the array containing 8-bit CCIDs. 824 * 825 * @retval The length of the @p ccid_list (may be 0) 826 * @retval -EINVAL if arguments are invalid 827 * @retval -ENODATA if not found 828 */ 829 int bt_audio_codec_cfg_meta_get_ccid_list(const struct bt_audio_codec_cfg *codec_cfg, 830 const uint8_t **ccid_list); 831 832 /** @brief Extract parental rating 833 * 834 * See @ref BT_AUDIO_METADATA_TYPE_PARENTAL_RATING for more information about this value. 835 * 836 * @param codec_cfg The codec data to search in. 837 * 838 * @retval The parental rating if positive or 0 839 * @retval -EINVAL if arguments are invalid 840 * @retval -ENODATA if not found 841 * @retval -EBADMSG if found value has invalid size 842 */ 843 int bt_audio_codec_cfg_meta_get_parental_rating(const struct bt_audio_codec_cfg *codec_cfg); 844 845 /** @brief Extract program info URI 846 * 847 * See @ref BT_AUDIO_METADATA_TYPE_PROGRAM_INFO_URI for more information about this value. 848 * 849 * @param[in] codec_cfg The codec data to search in. 850 * @param[out] program_info_uri Pointer to the UTF-8 formatted program info URI. 851 * 852 * @retval The length of the @p ccid_list (may be 0) 853 * @retval -EINVAL if arguments are invalid 854 * @retval -ENODATA if not found 855 */ 856 int bt_audio_codec_cfg_meta_get_program_info_uri(const struct bt_audio_codec_cfg *codec_cfg, 857 const uint8_t **program_info_uri); 858 859 /** @brief Extract audio active state 860 * 861 * See @ref BT_AUDIO_METADATA_TYPE_AUDIO_STATE for more information about this value. 862 * 863 * @param codec_cfg The codec data to search in. 864 * 865 * @retval The preferred context type if positive or 0 866 * @retval -EINVAL if arguments are invalid 867 * @retval -ENODATA if not found 868 * @retval -EBADMSG if found value has invalid size 869 */ 870 int bt_audio_codec_cfg_meta_get_audio_active_state(const struct bt_audio_codec_cfg *codec_cfg); 871 872 /** @brief Extract broadcast audio immediate rendering flag 873 * 874 * See @ref BT_AUDIO_METADATA_TYPE_BROADCAST_IMMEDIATE for more information about this value. 875 * 876 * @param codec_cfg The codec data to search in. 877 * 878 * @retval 0 if the flag was found 879 * @retval -EINVAL if arguments are invalid 880 * @retval -ENODATA if not the flag was not found 881 */ 882 int bt_audio_codec_cfg_meta_get_bcast_audio_immediate_rend_flag( 883 const struct bt_audio_codec_cfg *codec_cfg); 884 885 /** @brief Extract extended metadata 886 * 887 * See @ref BT_AUDIO_METADATA_TYPE_EXTENDED for more information about this value. 888 * 889 * @param[in] codec_cfg The codec data to search in. 890 * @param[out] extended_meta Pointer to the extended metadata. 891 * 892 * @retval The length of the @p ccid_list (may be 0) 893 * @retval -EINVAL if arguments are invalid 894 * @retval -ENODATA if not found 895 */ 896 int bt_audio_codec_cfg_meta_get_extended(const struct bt_audio_codec_cfg *codec_cfg, 897 const uint8_t **extended_meta); 898 899 /** @brief Extract vendor specific metadata 900 * 901 * See @ref BT_AUDIO_METADATA_TYPE_VENDOR for more information about this value. 902 * 903 * @param[in] codec_cfg The codec data to search in. 904 * @param[out] vendor_meta Pointer to the vendor specific metadata. 905 * 906 * @retval The length of the @p ccid_list (may be 0) 907 * @retval -EINVAL if arguments are invalid 908 * @retval -ENODATA if not found 909 */ 910 int bt_audio_codec_cfg_meta_get_vendor(const struct bt_audio_codec_cfg *codec_cfg, 911 const uint8_t **vendor_meta); 912 /** @} */ /* End of bt_audio_codec_cfg */ 913 914 /** 915 * @brief Audio codec capabilities APIs 916 * @defgroup bt_audio_codec_cap Codec capability parsing APIs 917 * 918 * Functions to parse codec capability data when formatted as LTV wrapped into @ref 919 * bt_audio_codec_cap. 920 * 921 * @{ 922 */ 923 924 /** 925 * @brief Lookup a specific value based on type 926 * 927 * @param[in] codec_cap The codec data to search in. 928 * @param[in] type The type id to look for 929 * @param[out] data Pointer to the data-pointer to update when item is found 930 * 931 * @return Length of found @p data or 0 if not found 932 */ 933 uint8_t bt_audio_codec_cap_get_val(const struct bt_audio_codec_cap *codec_cap, uint8_t type, 934 const uint8_t **data); 935 936 /** 937 * @brief Extract the frequency from a codec capability. 938 * 939 * @param codec_cap The codec configuration to extract data from. 940 * 941 * @retval Bitfield of supported frequencies if 0 or positive 942 * @retval -EINVAL if arguments are invalid 943 * @retval -ENODATA if not found 944 * @retval -EBADMSG if found value has invalid size or value 945 */ 946 int bt_audio_codec_cap_get_freq(const struct bt_audio_codec_cap *codec_cap); 947 948 /** 949 * @brief Extract the frequency from a codec capability. 950 * 951 * @param codec_cap The codec configuration to extract data from. 952 * 953 * @retval Bitfield of supported frame durations if 0 or positive 954 * @retval -EINVAL if arguments are invalid 955 * @retval -ENODATA if not found 956 * @retval -EBADMSG if found value has invalid size or value 957 */ 958 int bt_audio_codec_cap_get_frame_duration(const struct bt_audio_codec_cap *codec_cap); 959 960 /** 961 * @brief Extract the frequency from a codec capability. 962 * 963 * @param codec_cap The codec configuration to extract data from. 964 * 965 * @retval Bitfield of supported channel counts if 0 or positive 966 * @retval -EINVAL if arguments are invalid 967 * @retval -ENODATA if not found 968 * @retval -EBADMSG if found value has invalid size or value 969 */ 970 int bt_audio_codec_cap_get_supported_audio_chan_counts(const struct bt_audio_codec_cap *codec_cap); 971 972 /** 973 * @brief Extract the frequency from a codec capability. 974 * 975 * @param[in] codec_cap The codec configuration to extract data from. 976 * @param[out] codec_frame Struct to place the resulting values in 977 * 978 * @retval 0 on success 979 * @retval -EINVAL if arguments are invalid 980 * @retval -ENODATA if not found 981 * @retval -EBADMSG if found value has invalid size or value 982 */ 983 int bt_audio_codec_cap_get_octets_per_frame( 984 const struct bt_audio_codec_cap *codec_cap, 985 struct bt_audio_codec_octets_per_codec_frame *codec_frame); 986 987 /** 988 * @brief Extract the frequency from a codec capability. 989 * 990 * @param codec_cap The codec configuration to extract data from. 991 * 992 * @retval Maximum number of codec frames per SDU supported 993 * @retval -EINVAL if arguments are invalid 994 * @retval -ENODATA if not found 995 * @retval -EBADMSG if found value has invalid size or value 996 */ 997 int bt_audio_codec_cap_get_max_codec_frames_per_sdu(const struct bt_audio_codec_cap *codec_cap); 998 999 /** @brief Lookup a specific metadata value based on type 1000 * 1001 * @param[in] codec_cap The codec data to search in. 1002 * @param[in] type The type id to look for 1003 * @param[out] data Pointer to the data-pointer to update when item is found 1004 * 1005 * @retval Length of found @p data (may be 0) 1006 * @retval -EINVAL if arguments are invalid 1007 * @retval -ENODATA if not found 1008 */ 1009 int bt_audio_codec_cap_meta_get_val(const struct bt_audio_codec_cap *codec_cap, uint8_t type, 1010 const uint8_t **data); 1011 1012 /** @brief Extract preferred contexts 1013 * 1014 * See @ref BT_AUDIO_METADATA_TYPE_PREF_CONTEXT for more information about this value. 1015 * 1016 * @param codec_cap The codec data to search in. 1017 * 1018 * @retval The preferred context type if positive or 0 1019 * @retval -EINVAL if arguments are invalid 1020 * @retval -ENODATA if not found 1021 * @retval -EBADMSG if found value has invalid size 1022 */ 1023 int bt_audio_codec_cap_meta_get_pref_context(const struct bt_audio_codec_cap *codec_cap); 1024 1025 /** @brief Extract stream contexts 1026 * 1027 * See @ref BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT for more information about this value. 1028 * 1029 * @param codec_cap The codec data to search in. 1030 * 1031 * @retval The stream context type if positive or 0 1032 * @retval -EINVAL if arguments are invalid 1033 * @retval -ENODATA if not found 1034 * @retval -EBADMSG if found value has invalid size 1035 */ 1036 int bt_audio_codec_cap_meta_get_stream_context(const struct bt_audio_codec_cap *codec_cap); 1037 1038 /** @brief Extract program info 1039 * 1040 * See @ref BT_AUDIO_METADATA_TYPE_PROGRAM_INFO for more information about this value. 1041 * 1042 * @param[in] codec_cap The codec data to search in. 1043 * @param[out] program_info Pointer to the UTF-8 formatted program info. 1044 * 1045 * @retval The length of the @p program_info (may be 0) 1046 * @retval -EINVAL if arguments are invalid 1047 * @retval -ENODATA if not found 1048 */ 1049 int bt_audio_codec_cap_meta_get_program_info(const struct bt_audio_codec_cap *codec_cap, 1050 const uint8_t **program_info); 1051 1052 /** @brief Extract stream language 1053 * 1054 * See @ref BT_AUDIO_METADATA_TYPE_STREAM_LANG for more information about this value. 1055 * 1056 * @param codec_cap The codec data to search in. 1057 * 1058 * @retval The stream language if positive or 0 1059 * @retval -EINVAL if arguments are invalid 1060 * @retval -ENODATA if not found 1061 * @retval -EBADMSG if found value has invalid size 1062 */ 1063 int bt_audio_codec_cap_meta_get_stream_lang(const struct bt_audio_codec_cap *codec_cap); 1064 1065 /** @brief Extract CCID list 1066 * 1067 * See @ref BT_AUDIO_METADATA_TYPE_CCID_LIST for more information about this value. 1068 * 1069 * @param[in] codec_cap The codec data to search in. 1070 * @param[out] ccid_list Pointer to the array containing 8-bit CCIDs. 1071 * 1072 * @retval The length of the @p ccid_list (may be 0) 1073 * @retval -EINVAL if arguments are invalid 1074 * @retval -ENODATA if not found 1075 */ 1076 int bt_audio_codec_cap_meta_get_ccid_list(const struct bt_audio_codec_cap *codec_cap, 1077 const uint8_t **ccid_list); 1078 1079 /** @brief Extract parental rating 1080 * 1081 * See @ref BT_AUDIO_METADATA_TYPE_PARENTAL_RATING for more information about this value. 1082 * 1083 * @param codec_cap The codec data to search in. 1084 * 1085 * @retval The parental rating if positive or 0 1086 * @retval -EINVAL if arguments are invalid 1087 * @retval -ENODATA if not found 1088 * @retval -EBADMSG if found value has invalid size 1089 */ 1090 int bt_audio_codec_cap_meta_get_parental_rating(const struct bt_audio_codec_cap *codec_cap); 1091 1092 /** @brief Extract program info URI 1093 * 1094 * See @ref BT_AUDIO_METADATA_TYPE_PROGRAM_INFO_URI for more information about this value. 1095 * 1096 * @param[in] codec_cap The codec data to search in. 1097 * @param[out] program_info_uri Pointer to the UTF-8 formatted program info URI. 1098 * 1099 * @retval The length of the @p ccid_list (may be 0) 1100 * @retval -EINVAL if arguments are invalid 1101 * @retval -ENODATA if not found 1102 */ 1103 int bt_audio_codec_cap_meta_get_program_info_uri(const struct bt_audio_codec_cap *codec_cap, 1104 const uint8_t **program_info_uri); 1105 1106 /** @brief Extract audio active state 1107 * 1108 * See @ref BT_AUDIO_METADATA_TYPE_AUDIO_STATE for more information about this value. 1109 * 1110 * @param codec_cap The codec data to search in. 1111 * 1112 * @retval The preferred context type if positive or 0 1113 * @retval -EINVAL if arguments are invalid 1114 * @retval -ENODATA if not found 1115 * @retval -EBADMSG if found value has invalid size 1116 */ 1117 int bt_audio_codec_cap_meta_get_audio_active_state(const struct bt_audio_codec_cap *codec_cap); 1118 1119 /** @brief Extract broadcast audio immediate rendering flag 1120 * 1121 * See @ref BT_AUDIO_METADATA_TYPE_BROADCAST_IMMEDIATE for more information about this value. 1122 * 1123 * @param codec_cap The codec data to search in. 1124 * 1125 * @retval 0 if the flag was found 1126 * @retval -EINVAL if arguments are invalid 1127 * @retval -ENODATA if not the flag was not found 1128 */ 1129 int bt_audio_codec_cap_meta_get_bcast_audio_immediate_rend_flag( 1130 const struct bt_audio_codec_cap *codec_cap); 1131 1132 /** @brief Extract extended metadata 1133 * 1134 * See @ref BT_AUDIO_METADATA_TYPE_EXTENDED for more information about this value. 1135 * 1136 * @param[in] codec_cap The codec data to search in. 1137 * @param[out] extended_meta Pointer to the extended metadata. 1138 * 1139 * @retval The length of the @p ccid_list (may be 0) 1140 * @retval -EINVAL if arguments are invalid 1141 * @retval -ENODATA if not found 1142 */ 1143 int bt_audio_codec_cap_meta_get_extended(const struct bt_audio_codec_cap *codec_cap, 1144 const uint8_t **extended_meta); 1145 1146 /** @brief Extract vendor specific metadata 1147 * 1148 * See @ref BT_AUDIO_METADATA_TYPE_VENDOR for more information about this value. 1149 * 1150 * @param[in] codec_cap The codec data to search in. 1151 * @param[out] vendor_meta Pointer to the vendor specific metadata. 1152 * 1153 * @retval The length of the @p ccid_list (may be 0) 1154 * @retval -EINVAL if arguments are invalid 1155 * @retval -ENODATA if not found 1156 */ 1157 int bt_audio_codec_cap_meta_get_vendor(const struct bt_audio_codec_cap *codec_cap, 1158 const uint8_t **vendor_meta); 1159 /** @} */ /* End of bt_audio_codec_cap */ 1160 1161 #ifdef __cplusplus 1162 } 1163 #endif 1164 1165 /** @} */ /* end of bt_audio */ 1166 1167 #endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_H_ */ 1168