1 /** 2 * @file 3 * @brief Bluetooth Media Control Client (MCC) APIs. 4 */ 5 6 /* 7 * Copyright (c) 2019 - 2024 Nordic Semiconductor ASA 8 * 9 * SPDX-License-Identifier: Apache-2.0 10 */ 11 12 #ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_MCC_ 13 #define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_MCC_ 14 15 /** 16 * @brief Bluetooth Media Control Client (MCC) interface 17 * 18 * Updated to the Media Control Profile specification revision 1.0 19 * 20 * @defgroup bt_gatt_mcc Media Control Client (MCC) 21 * 22 * @since 3.0 23 * @version 0.8.0 24 * 25 * @ingroup bluetooth 26 * @{ 27 */ 28 29 #include <stdint.h> 30 #include <stdbool.h> 31 32 #include <zephyr/bluetooth/conn.h> 33 #include <zephyr/net/buf.h> 34 #include <zephyr/bluetooth/audio/media_proxy.h> 35 36 #ifdef __cplusplus 37 extern "C" { 38 #endif 39 40 /**** Callback functions ******************************************************/ 41 42 /** 43 * @brief Callback function for bt_mcc_discover_mcs() 44 * 45 * Called when a media control server is discovered 46 * 47 * @param conn The connection that was used to initialise the media control client 48 * @param err Error value. 0 on success, GATT error or errno on fail 49 */ 50 typedef void (*bt_mcc_discover_mcs_cb)(struct bt_conn *conn, int err); 51 52 /** 53 * @brief Callback function for bt_mcc_read_player_name() 54 * 55 * Called when the player name is read or notified 56 * 57 * @param conn The connection that was used to initialise the media control client 58 * @param err Error value. 0 on success, GATT error or errno on fail 59 * @param name Player name 60 */ 61 typedef void (*bt_mcc_read_player_name_cb)(struct bt_conn *conn, int err, const char *name); 62 63 /** 64 * @brief Callback function for bt_mcc_read_icon_obj_id() 65 * 66 * Called when the icon object ID is read 67 * 68 * @param conn The connection that was used to initialise the media control client 69 * @param err Error value. 0 on success, GATT error or errno on fail 70 * @param icon_id The ID of the Icon Object. This is a UINT48 in a uint64_t 71 */ 72 typedef void (*bt_mcc_read_icon_obj_id_cb)(struct bt_conn *conn, int err, uint64_t icon_id); 73 74 /** 75 * @brief Callback function for bt_mcc_read_icon_url() 76 * 77 * Called when the icon URL is read 78 * 79 * @param conn The connection that was used to initialise the media control client 80 * @param err Error value. 0 on success, GATT error or errno on fail 81 * @param icon_url The URL of the Icon 82 */ 83 typedef void (*bt_mcc_read_icon_url_cb)(struct bt_conn *conn, int err, const char *icon_url); 84 85 /** 86 * @brief Callback function for track changed notifications 87 * 88 * Called when a track change is notified. 89 * 90 * The track changed characteristic is a special case. It can not be read or 91 * set, it can only be notified. 92 * 93 * @param conn The connection that was used to initialise the media control client 94 * @param err Error value. 0 on success, GATT error or errno on fail 95 */ 96 typedef void (*bt_mcc_track_changed_ntf_cb)(struct bt_conn *conn, int err); 97 98 99 /** 100 * @brief Callback function for bt_mcc_read_track_title() 101 * 102 * Called when the track title is read or notified 103 * 104 * @param conn The connection that was used to initialise the media control client 105 * @param err Error value. 0 on success, GATT error or errno on fail 106 * @param title The title of the track 107 */ 108 typedef void (*bt_mcc_read_track_title_cb)(struct bt_conn *conn, int err, const char *title); 109 110 /** 111 * @brief Callback function for bt_mcc_read_track_duration() 112 * 113 * Called when the track duration is read or notified 114 * 115 * @param conn The connection that was used to initialise the media control client 116 * @param err Error value. 0 on success, GATT error or errno on fail 117 * @param dur The duration of the track 118 */ 119 typedef void (*bt_mcc_read_track_duration_cb)(struct bt_conn *conn, int err, int32_t dur); 120 121 /** 122 * @brief Callback function for bt_mcc_read_track_position() 123 * 124 * Called when the track position is read or notified 125 * 126 * @param conn The connection that was used to initialise the media control client 127 * @param err Error value. 0 on success, GATT error or errno on fail 128 * @param pos The Track Position 129 */ 130 typedef void (*bt_mcc_read_track_position_cb)(struct bt_conn *conn, int err, int32_t pos); 131 132 /** 133 * @brief Callback function for bt_mcc_set_track_position() 134 * 135 * Called when the track position is set 136 * 137 * @param conn The connection that was used to initialise the media control client 138 * @param err Error value. 0 on success, GATT error or errno on fail 139 * @param pos The Track Position set (or attempted to set) 140 */ 141 typedef void (*bt_mcc_set_track_position_cb)(struct bt_conn *conn, int err, int32_t pos); 142 143 /** 144 * @brief Callback function for bt_mcc_read_playback_speed() 145 * 146 * Called when the playback speed is read or notified 147 * 148 * @param conn The connection that was used to initialise the media control client 149 * @param err Error value. 0 on success, GATT error or errno on fail 150 * @param speed The Playback Speed 151 */ 152 typedef void (*bt_mcc_read_playback_speed_cb)(struct bt_conn *conn, int err, int8_t speed); 153 154 /** 155 * @brief Callback function for bt_mcc_set_playback_speed() 156 * 157 * Called when the playback speed is set 158 * 159 * @param conn The connection that was used to initialise the media control client 160 * @param err Error value. 0 on success, GATT error or errno on fail 161 * @param speed The Playback Speed set (or attempted to set) 162 */ 163 typedef void (*bt_mcc_set_playback_speed_cb)(struct bt_conn *conn, int err, int8_t speed); 164 165 /** 166 * @brief Callback function for bt_mcc_read_seeking_speed() 167 * 168 * Called when the seeking speed is read or notified 169 * 170 * @param conn The connection that was used to initialise the media control client 171 * @param err Error value. 0 on success, GATT error or errno on fail 172 * @param speed The Seeking Speed 173 */ 174 typedef void (*bt_mcc_read_seeking_speed_cb)(struct bt_conn *conn, int err, int8_t speed); 175 176 /** 177 * @brief Callback function for bt_mcc_read_segments_obj_id() 178 * 179 * Called when the track segments object ID is read 180 * 181 * @param conn The connection that was used to initialise the media control client 182 * @param err Error value. 0 on success, GATT error or errno on fail 183 * @param id The Track Segments Object ID (UINT48) 184 */ 185 typedef void (*bt_mcc_read_segments_obj_id_cb)(struct bt_conn *conn, int err, uint64_t id); 186 187 /** 188 * @brief Callback function for bt_mcc_read_current_track_obj_id() 189 * 190 * Called when the current track object ID is read or notified 191 * 192 * @param conn The connection that was used to initialise the media control client 193 * @param err Error value. 0 on success, GATT error or errno on fail 194 * @param id The Current Track Object ID (UINT48) 195 */ 196 typedef void (*bt_mcc_read_current_track_obj_id_cb)(struct bt_conn *conn, int err, uint64_t id); 197 198 /** 199 * @brief Callback function for bt_mcc_set_current_track_obj_id() 200 * 201 * Called when the current track object ID is set 202 * 203 * @param conn The connection that was used to initialise the media control client 204 * @param err Error value. 0 on success, GATT error or errno on fail 205 * @param id The Object ID (UINT48) set (or attempted to set) 206 */ 207 typedef void (*bt_mcc_set_current_track_obj_id_cb)(struct bt_conn *conn, int err, uint64_t id); 208 209 /** 210 * @brief Callback function for bt_mcc_read_next_track_obj_id_obj() 211 * 212 * Called when the next track object ID is read or notified 213 * 214 * @param conn The connection that was used to initialise the media control client 215 * @param err Error value. 0 on success, GATT error or errno on fail 216 * @param id The Next Track Object ID (UINT48) 217 */ 218 typedef void (*bt_mcc_read_next_track_obj_id_cb)(struct bt_conn *conn, int err, uint64_t id); 219 220 /** 221 * @brief Callback function for bt_mcc_set_next_track_obj_id() 222 * 223 * Called when the next track object ID is set 224 * 225 * @param conn The connection that was used to initialise the media control client 226 * @param err Error value. 0 on success, GATT error or errno on fail 227 * @param id The Object ID (UINT48) set (or attempted to set) 228 */ 229 typedef void (*bt_mcc_set_next_track_obj_id_cb)(struct bt_conn *conn, int err, uint64_t id); 230 231 /** 232 * @brief Callback function for bt_mcc_read_parent_group_obj_id() 233 * 234 * Called when the parent group object ID is read or notified 235 * 236 * @param conn The connection that was used to initialise the media control client 237 * @param err Error value. 0 on success, GATT error or errno on fail 238 * @param id The Parent Group Object ID (UINT48) 239 */ 240 typedef void (*bt_mcc_read_parent_group_obj_id_cb)(struct bt_conn *conn, int err, uint64_t id); 241 242 /** 243 * @brief Callback function for bt_mcc_read_current_group_obj_id() 244 * 245 * Called when the current group object ID is read or notified 246 * 247 * @param conn The connection that was used to initialise the media control client 248 * @param err Error value. 0 on success, GATT error or errno on fail 249 * @param id The Current Group Object ID (UINT48) 250 */ 251 typedef void (*bt_mcc_read_current_group_obj_id_cb)(struct bt_conn *conn, int err, uint64_t id); 252 253 /** 254 * @brief Callback function for bt_mcc_set_current_group_obj_id() 255 * 256 * Called when the current group object ID is set 257 * 258 * @param conn The connection that was used to initialise the media control client 259 * @param err Error value. 0 on success, GATT error or errno on fail 260 * @param obj_id The Object ID (UINT48) set (or attempted to set) 261 */ 262 typedef void (*bt_mcc_set_current_group_obj_id_cb)(struct bt_conn *conn, int err, uint64_t obj_id); 263 264 /** 265 * @brief Callback function for bt_mcc_read_playing_order() 266 * 267 * Called when the playing order is read or notified 268 * 269 * @param conn The connection that was used to initialise the media control client 270 * @param err Error value. 0 on success, GATT error or errno on fail 271 * @param order The playback order 272 */ 273 typedef void (*bt_mcc_read_playing_order_cb)(struct bt_conn *conn, int err, uint8_t order); 274 275 /** 276 * @brief Callback function for bt_mcc_set_playing_order() 277 * 278 * Called when the playing order is set 279 * 280 * @param conn The connection that was used to initialise the media control client 281 * @param err Error value. 0 on success, GATT error or errno on fail 282 * @param order The Playing Order set (or attempted to set) 283 */ 284 typedef void (*bt_mcc_set_playing_order_cb)(struct bt_conn *conn, int err, uint8_t order); 285 286 /** 287 * @brief Callback function for bt_mcc_read_playing_orders_supported() 288 * 289 * Called when the supported playing orders are read or notified 290 * 291 * @param conn The connection that was used to initialise the media control client 292 * @param err Error value. 0 on success, GATT error or errno on fail 293 * @param orders The playing orders supported (bitmap) 294 */ 295 typedef void (*bt_mcc_read_playing_orders_supported_cb)(struct bt_conn *conn, int err, 296 uint16_t orders); 297 298 /** 299 * @brief Callback function for bt_mcc_read_media_state() 300 * 301 * Called when the media state is read or notified 302 * 303 * @param conn The connection that was used to initialise the media control client 304 * @param err Error value. 0 on success, GATT error or errno on fail 305 * @param state The Media State 306 */ 307 typedef void (*bt_mcc_read_media_state_cb)(struct bt_conn *conn, int err, uint8_t state); 308 309 /** 310 * @brief Callback function for bt_mcc_send_cmd() 311 * 312 * Called when a command is sent, i.e. when the media control point is set 313 * 314 * @param conn The connection that was used to initialise the media control client 315 * @param err Error value. 0 on success, GATT error or errno on fail 316 * @param cmd The command sent 317 */ 318 typedef void (*bt_mcc_send_cmd_cb)(struct bt_conn *conn, int err, const struct mpl_cmd *cmd); 319 320 /** 321 * @brief Callback function for command notifications 322 * 323 * Called when the media control point is notified 324 * 325 * Notifications for commands (i.e. for writes to the media control point) use a 326 * different parameter structure than what is used for sending commands (writing 327 * to the media control point) 328 * 329 * @param conn The connection that was used to initialise the media control client 330 * @param err Error value. 0 on success, GATT error or errno on fail 331 * @param ntf The command notification 332 */ 333 typedef void (*bt_mcc_cmd_ntf_cb)(struct bt_conn *conn, int err, const struct mpl_cmd_ntf *ntf); 334 335 /** 336 * @brief Callback function for bt_mcc_read_opcodes_supported() 337 * 338 * Called when the supported opcodes (commands) are read or notified 339 * 340 * @param conn The connection that was used to initialise the media control client 341 * @param err Error value. 0 on success, GATT error or errno on fail 342 * @param opcodes The supported opcodes 343 */ 344 typedef void (*bt_mcc_read_opcodes_supported_cb)(struct bt_conn *conn, int err, 345 uint32_t opcodes); 346 347 /** 348 * @brief Callback function for bt_mcc_send_search() 349 * 350 * Called when a search is sent, i.e. when the search control point is set 351 * 352 * @param conn The connection that was used to initialise the media control client 353 * @param err Error value. 0 on success, GATT error or errno on fail 354 * @param search The search set (or attempted to set) 355 */ 356 typedef void (*bt_mcc_send_search_cb)(struct bt_conn *conn, int err, 357 const struct mpl_search *search); 358 359 /** 360 * @brief Callback function for search notifications 361 * 362 * Called when the search control point is notified 363 * 364 * Notifications for searches (i.e. for writes to the search control point) use a 365 * different parameter structure than what is used for sending searches (writing 366 * to the search control point) 367 * 368 * @param conn The connection that was used to initialise the media control client 369 * @param err Error value. 0 on success, GATT error or errno on fail 370 * @param result_code The search notification 371 */ 372 typedef void (*bt_mcc_search_ntf_cb)(struct bt_conn *conn, int err, 373 uint8_t result_code); 374 375 /** 376 * @brief Callback function for bt_mcc_read_search_results_obj_id() 377 * 378 * Called when the search results object ID is read or notified 379 * 380 * Note that the Search Results Object ID value may be zero, in case the 381 * characteristic does not exist on the server. (This will be the case if 382 * there has not been a successful search.) 383 * 384 * @param conn The connection that was used to initialise the media control client 385 * @param err Error value. 0 on success, GATT error or errno on fail 386 * @param id The Search Results Object ID (UINT48) 387 */ 388 typedef void (*bt_mcc_read_search_results_obj_id_cb)(struct bt_conn *conn, 389 int err, uint64_t id); 390 391 /** 392 * @brief Callback function for bt_mcc_read_content_control_id() 393 * 394 * Called when the content control ID is read 395 * 396 * @param conn The connection that was used to initialise the media control client 397 * @param err Error value. 0 on success, GATT error or errno on fail 398 * @param ccid The Content Control ID 399 */ 400 typedef void (*bt_mcc_read_content_control_id_cb)(struct bt_conn *conn, 401 int err, uint8_t ccid); 402 403 /**** Callback functions for the included Object Transfer service *************/ 404 405 /** 406 * @brief Callback function for object selected 407 * 408 * Called when an object is selected 409 * 410 * @param conn The connection that was used to initialise the media control client 411 * @param err Error value. 0 on success, GATT error or errno on fail 412 */ 413 typedef void (*bt_mcc_otc_obj_selected_cb)(struct bt_conn *conn, int err); 414 415 /** 416 * @brief Callback function for bt_mcc_otc_read_object_metadata() 417 * 418 * Called when object metadata is read 419 * 420 * @param conn The connection that was used to initialise the media control client 421 * @param err Error value. 0 on success, GATT error or errno on fail 422 */ 423 typedef void (*bt_mcc_otc_obj_metadata_cb)(struct bt_conn *conn, int err); 424 425 /** 426 * @brief Callback function for bt_mcc_otc_read_icon_object() 427 * 428 * Called when the icon object is read 429 * 430 * @param conn The connection that was used to initialise the media control client 431 * @param err Error value. 0 on success, GATT error or errno on fail 432 * @param buf Buffer containing the object contents 433 * 434 * If err is EMSGSIZE, the object contents have been truncated. 435 */ 436 typedef void (*bt_mcc_otc_read_icon_object_cb)(struct bt_conn *conn, int err, 437 struct net_buf_simple *buf); 438 439 /** 440 * @brief Callback function for bt_mcc_otc_read_track_segments_object() 441 * 442 * Called when the track segments object is read 443 * 444 * @param conn The connection that was used to initialise the media control client 445 * @param err Error value. 0 on success, GATT error or errno on fail 446 * @param buf Buffer containing the object contents 447 * 448 * If err is EMSGSIZE, the object contents have been truncated. 449 */ 450 typedef void (*bt_mcc_otc_read_track_segments_object_cb)(struct bt_conn *conn, int err, 451 struct net_buf_simple *buf); 452 453 /** 454 * @brief Callback function for bt_mcc_otc_read_current_track_object() 455 * 456 * Called when the current track object is read 457 * 458 * @param conn The connection that was used to initialise the media control client 459 * @param err Error value. 0 on success, GATT error or errno on fail 460 * @param buf Buffer containing the object contents 461 * 462 * If err is EMSGSIZE, the object contents have been truncated. 463 */ 464 typedef void (*bt_mcc_otc_read_current_track_object_cb)(struct bt_conn *conn, int err, 465 struct net_buf_simple *buf); 466 467 /** 468 * @brief Callback function for bt_mcc_otc_read_next_track_object() 469 * 470 * Called when the next track object is read 471 * 472 * @param conn The connection that was used to initialise the media control client 473 * @param err Error value. 0 on success, GATT error or errno on fail 474 * @param buf Buffer containing the object contents 475 * 476 * If err is EMSGSIZE, the object contents have been truncated. 477 */ 478 typedef void (*bt_mcc_otc_read_next_track_object_cb)(struct bt_conn *conn, int err, 479 struct net_buf_simple *buf); 480 481 /** 482 * @brief Callback function for bt_mcc_otc_read_parent_group_object() 483 * 484 * Called when the parent group object is read 485 * 486 * @param conn The connection that was used to initialise the media control client 487 * @param err Error value. 0 on success, GATT error or errno on fail 488 * @param buf Buffer containing the object contents 489 * 490 * If err is EMSGSIZE, the object contents have been truncated. 491 */ 492 typedef void (*bt_mcc_otc_read_parent_group_object_cb)(struct bt_conn *conn, int err, 493 struct net_buf_simple *buf); 494 495 /** 496 * @brief Callback function for bt_mcc_otc_read_current_group_object() 497 * 498 * Called when the current group object is read 499 * 500 * @param conn The connection that was used to initialise the media control client 501 * @param err Error value. 0 on success, GATT error or errno on fail 502 * @param buf Buffer containing the object contents 503 * 504 * If err is EMSGSIZE, the object contents have been truncated. 505 */ 506 typedef void (*bt_mcc_otc_read_current_group_object_cb)(struct bt_conn *conn, int err, 507 struct net_buf_simple *buf); 508 509 510 /** 511 * @brief Media control client callbacks 512 */ 513 struct bt_mcc_cb { 514 /** Callback when discovery has finished */ 515 bt_mcc_discover_mcs_cb discover_mcs; 516 /** Callback when reading the player name */ 517 bt_mcc_read_player_name_cb read_player_name; 518 #if defined(CONFIG_BT_OTS_CLIENT) || defined(__DOXYGEN__) 519 /** Callback when reading the icon object ID */ 520 bt_mcc_read_icon_obj_id_cb read_icon_obj_id; 521 #endif /* CONFIG_BT_OTS_CLIENT */ 522 #if defined(CONFIG_BT_MCC_READ_MEDIA_PLAYER_ICON_URL) || defined(__DOXYGEN__) 523 /** Callback when reading the icon URL */ 524 bt_mcc_read_icon_url_cb read_icon_url; 525 #endif /* defined(CONFIG_BT_MCC_READ_MEDIA_PLAYER_ICON_URL) */ 526 /** Callback when getting a track changed notification */ 527 bt_mcc_track_changed_ntf_cb track_changed_ntf; 528 #if defined(CONFIG_BT_MCC_READ_TRACK_TITLE) || defined(__DOXYGEN__) 529 /** Callback when reading the track title */ 530 bt_mcc_read_track_title_cb read_track_title; 531 #endif /* defined(CONFIG_BT_MCC_READ_TRACK_TITLE) */ 532 #if defined(CONFIG_BT_MCC_READ_TRACK_DURATION) || defined(__DOXYGEN__) 533 /** Callback when reading the track duration */ 534 bt_mcc_read_track_duration_cb read_track_duration; 535 #endif /* defined(CONFIG_BT_MCC_READ_TRACK_DURATION) */ 536 #if defined(CONFIG_BT_MCC_READ_TRACK_POSITION) || defined(__DOXYGEN__) 537 /** Callback when reading the track position */ 538 bt_mcc_read_track_position_cb read_track_position; 539 #endif /* defined(CONFIG_BT_MCC_READ_TRACK_POSITION) */ 540 #if defined(CONFIG_BT_MCC_SET_TRACK_POSITION) || defined(__DOXYGEN__) 541 /** Callback when setting the track position */ 542 bt_mcc_set_track_position_cb set_track_position; 543 #endif /* defined(CONFIG_BT_MCC_SET_TRACK_POSITION) */ 544 #if defined(CONFIG_BT_MCC_READ_PLAYBACK_SPEED) || defined(__DOXYGEN__) 545 /** Callback when reading the playback speed */ 546 bt_mcc_read_playback_speed_cb read_playback_speed; 547 #endif /* defined (CONFIG_BT_MCC_READ_PLAYBACK_SPEED) */ 548 #if defined(CONFIG_BT_MCC_SET_PLAYBACK_SPEED) || defined(__DOXYGEN__) 549 /** Callback when setting the playback speed */ 550 bt_mcc_set_playback_speed_cb set_playback_speed; 551 #endif /* defined (CONFIG_BT_MCC_SET_PLAYBACK_SPEED) */ 552 #if defined(CONFIG_BT_MCC_READ_SEEKING_SPEED) || defined(__DOXYGEN__) 553 /** Callback when reading the seeking speed */ 554 bt_mcc_read_seeking_speed_cb read_seeking_speed; 555 #endif /* defined (CONFIG_BT_MCC_READ_SEEKING_SPEED) */ 556 #if defined(CONFIG_BT_OTS_CLIENT) || defined(__DOXYGEN__) 557 /** Callback when reading the segments object ID */ 558 bt_mcc_read_segments_obj_id_cb read_segments_obj_id; 559 /** Callback when reading the current track object ID */ 560 bt_mcc_read_current_track_obj_id_cb read_current_track_obj_id; 561 /** Callback when setting the current track object ID */ 562 bt_mcc_set_current_track_obj_id_cb set_current_track_obj_id; 563 /** Callback when reading the next track object ID */ 564 bt_mcc_read_next_track_obj_id_cb read_next_track_obj_id; 565 /** Callback when setting the next track object ID */ 566 bt_mcc_set_next_track_obj_id_cb set_next_track_obj_id; 567 /** Callback when reading the current group object ID */ 568 bt_mcc_read_current_group_obj_id_cb read_current_group_obj_id; 569 /** Callback when setting the current group object ID */ 570 bt_mcc_set_current_group_obj_id_cb set_current_group_obj_id; 571 /** Callback when reading the parent group object ID */ 572 bt_mcc_read_parent_group_obj_id_cb read_parent_group_obj_id; 573 #endif /* CONFIG_BT_OTS_CLIENT */ 574 #if defined(CONFIG_BT_MCC_READ_PLAYING_ORDER) || defined(__DOXYGEN__) 575 /** Callback when reading the playing order */ 576 bt_mcc_read_playing_order_cb read_playing_order; 577 #endif /* defined(CONFIG_BT_MCC_READ_PLAYING_ORDER) */ 578 #if defined(CONFIG_BT_MCC_SET_PLAYING_ORDER) || defined(__DOXYGEN__) 579 /** Callback when setting the playing order */ 580 bt_mcc_set_playing_order_cb set_playing_order; 581 #endif /* defined(CONFIG_BT_MCC_SET_PLAYING_ORDER) */ 582 #if defined(CONFIG_BT_MCC_READ_PLAYING_ORDER_SUPPORTED) || defined(__DOXYGEN__) 583 /** Callback when reading the supported playing orders */ 584 bt_mcc_read_playing_orders_supported_cb read_playing_orders_supported; 585 #endif /* defined(CONFIG_BT_MCC_READ_PLAYING_ORDER_SUPPORTED) */ 586 #if defined(CONFIG_BT_MCC_READ_MEDIA_STATE) || defined(__DOXYGEN__) 587 /** Callback when reading the media state */ 588 bt_mcc_read_media_state_cb read_media_state; 589 #endif /* defined(CONFIG_BT_MCC_READ_MEDIA_STATE) */ 590 #if defined(CONFIG_BT_MCC_SET_MEDIA_CONTROL_POINT) || defined(__DOXYGEN__) 591 /** Callback when sending a command */ 592 bt_mcc_send_cmd_cb send_cmd; 593 #endif /* defined(CONFIG_BT_MCC_SET_MEDIA_CONTROL_POINT) */ 594 /** Callback command notifications */ 595 bt_mcc_cmd_ntf_cb cmd_ntf; 596 #if defined(CONFIG_BT_MCC_READ_MEDIA_CONTROL_POINT_OPCODES_SUPPORTED) || defined(__DOXYGEN__) 597 /** Callback when reading the supported opcodes */ 598 bt_mcc_read_opcodes_supported_cb read_opcodes_supported; 599 #endif /* defined(CONFIG_BT_MCC_READ_MEDIA_CONTROL_POINT_OPCODES_SUPPORTED) */ 600 #if defined(CONFIG_BT_OTS_CLIENT) || defined(__DOXYGEN__) 601 /** Callback when sending the a search query */ 602 bt_mcc_send_search_cb send_search; 603 /** Callback when receiving a search notification */ 604 bt_mcc_search_ntf_cb search_ntf; 605 /** Callback when reading the search results object ID */ 606 bt_mcc_read_search_results_obj_id_cb read_search_results_obj_id; 607 #endif /* CONFIG_BT_OTS_CLIENT */ 608 #if defined(CONFIG_BT_MCC_READ_CONTENT_CONTROL_ID) || defined(__DOXYGEN__) 609 /** Callback when reading the content control ID */ 610 bt_mcc_read_content_control_id_cb read_content_control_id; 611 #endif /* defined(CONFIG_BT_MCC_READ_CONTENT_CONTROL_ID) */ 612 #if defined(CONFIG_BT_OTS_CLIENT) || defined(__DOXYGEN__) 613 /** Callback when selecting an object */ 614 bt_mcc_otc_obj_selected_cb otc_obj_selected; 615 /** Callback when receiving the current object metadata */ 616 bt_mcc_otc_obj_metadata_cb otc_obj_metadata; 617 /** Callback when reading the current icon object */ 618 bt_mcc_otc_read_icon_object_cb otc_icon_object; 619 /** Callback when reading the track segments object */ 620 bt_mcc_otc_read_track_segments_object_cb otc_track_segments_object; 621 /** Callback when reading the current track object */ 622 bt_mcc_otc_read_current_track_object_cb otc_current_track_object; 623 /** Callback when reading the next track object */ 624 bt_mcc_otc_read_next_track_object_cb otc_next_track_object; 625 /** Callback when reading the current group object */ 626 bt_mcc_otc_read_current_group_object_cb otc_current_group_object; 627 /** Callback when reading the parent group object */ 628 bt_mcc_otc_read_parent_group_object_cb otc_parent_group_object; 629 #endif /* CONFIG_BT_OTS_CLIENT */ 630 }; 631 632 /**** Functions ***************************************************************/ 633 634 /** 635 * @brief Initialize Media Control Client 636 * 637 * @param cb Callbacks to be used 638 * 639 * @return 0 if success, errno on failure. 640 */ 641 int bt_mcc_init(struct bt_mcc_cb *cb); 642 643 644 /** 645 * @brief Discover Media Control Service 646 * 647 * Discover Media Control Service (MCS) on the server given by the connection 648 * Optionally subscribe to notifications. 649 * 650 * Shall be called once, after media control client initialization and before 651 * using other media control client functionality. 652 * 653 * @param conn Connection to the peer device 654 * @param subscribe Whether to subscribe to notifications 655 * 656 * @return 0 if success, errno on failure. 657 */ 658 int bt_mcc_discover_mcs(struct bt_conn *conn, bool subscribe); 659 660 /** 661 * @brief Read Media Player Name 662 * 663 * @param conn Connection to the peer device 664 * 665 * @return 0 if success, errno on failure. 666 */ 667 int bt_mcc_read_player_name(struct bt_conn *conn); 668 669 /** 670 * @brief Read Icon Object ID 671 * 672 * @param conn Connection to the peer device 673 * 674 * @return 0 if success, errno on failure. 675 */ 676 int bt_mcc_read_icon_obj_id(struct bt_conn *conn); 677 678 /** 679 * @brief Read Icon Object URL 680 * 681 * @param conn Connection to the peer device 682 * 683 * @return 0 if success, errno on failure. 684 */ 685 int bt_mcc_read_icon_url(struct bt_conn *conn); 686 687 /** 688 * @brief Read Track Title 689 * 690 * @param conn Connection to the peer device 691 * 692 * @return 0 if success, errno on failure. 693 */ 694 int bt_mcc_read_track_title(struct bt_conn *conn); 695 696 /** 697 * @brief Read Track Duration 698 * 699 * @param conn Connection to the peer device 700 * 701 * @return 0 if success, errno on failure. 702 */ 703 int bt_mcc_read_track_duration(struct bt_conn *conn); 704 705 /** 706 * @brief Read Track Position 707 * 708 * @param conn Connection to the peer device 709 * 710 * @return 0 if success, errno on failure. 711 */ 712 int bt_mcc_read_track_position(struct bt_conn *conn); 713 714 /** 715 * @brief Set Track position 716 * 717 * @param conn Connection to the peer device 718 * @param pos Track position 719 * 720 * @return 0 if success, errno on failure. 721 */ 722 int bt_mcc_set_track_position(struct bt_conn *conn, int32_t pos); 723 724 /** 725 * @brief Read Playback speed 726 * 727 * @param conn Connection to the peer device 728 * 729 * @return 0 if success, errno on failure. 730 */ 731 int bt_mcc_read_playback_speed(struct bt_conn *conn); 732 733 /** 734 * @brief Set Playback Speed 735 * 736 * @param conn Connection to the peer device 737 * @param speed Playback speed 738 * 739 * @return 0 if success, errno on failure. 740 */ 741 int bt_mcc_set_playback_speed(struct bt_conn *conn, int8_t speed); 742 743 /** 744 * @brief Read Seeking speed 745 * 746 * @param conn Connection to the peer device 747 * 748 * @return 0 if success, errno on failure. 749 */ 750 int bt_mcc_read_seeking_speed(struct bt_conn *conn); 751 752 /** 753 * @brief Read Track Segments Object ID 754 * 755 * @param conn Connection to the peer device 756 * 757 * @return 0 if success, errno on failure. 758 */ 759 int bt_mcc_read_segments_obj_id(struct bt_conn *conn); 760 761 /** 762 * @brief Read Current Track Object ID 763 * 764 * @param conn Connection to the peer device 765 * 766 * @return 0 if success, errno on failure. 767 */ 768 int bt_mcc_read_current_track_obj_id(struct bt_conn *conn); 769 770 /** 771 * @brief Set Current Track Object ID 772 * 773 * Set the Current Track to the track given by the @p id parameter 774 * 775 * @param conn Connection to the peer device 776 * @param id Object Transfer Service ID (UINT48) of the track to set as the current track 777 * 778 * @return 0 if success, errno on failure. 779 */ 780 int bt_mcc_set_current_track_obj_id(struct bt_conn *conn, uint64_t id); 781 782 /** 783 * @brief Read Next Track Object ID 784 * 785 * @param conn Connection to the peer device 786 * 787 * @return 0 if success, errno on failure. 788 */ 789 int bt_mcc_read_next_track_obj_id(struct bt_conn *conn); 790 791 /** 792 * @brief Set Next Track Object ID 793 * 794 * Set the Next Track to the track given by the @p id parameter 795 * 796 * @param conn Connection to the peer device 797 * @param id Object Transfer Service ID (UINT48) of the track to set as the next track 798 * 799 * @return 0 if success, errno on failure. 800 */ 801 int bt_mcc_set_next_track_obj_id(struct bt_conn *conn, uint64_t id); 802 803 /** 804 * @brief Read Current Group Object ID 805 * 806 * @param conn Connection to the peer device 807 * 808 * @return 0 if success, errno on failure. 809 */ 810 int bt_mcc_read_current_group_obj_id(struct bt_conn *conn); 811 812 /** 813 * @brief Set Current Group Object ID 814 * 815 * Set the Current Group to the group given by the @p id parameter 816 * 817 * @param conn Connection to the peer device 818 * @param id Object Transfer Service ID (UINT48) of the group to set as the current group 819 * 820 * @return 0 if success, errno on failure. 821 */ 822 int bt_mcc_set_current_group_obj_id(struct bt_conn *conn, uint64_t id); 823 824 /** 825 * @brief Read Parent Group Object ID 826 * 827 * @param conn Connection to the peer device 828 * 829 * @return 0 if success, errno on failure. 830 */ 831 int bt_mcc_read_parent_group_obj_id(struct bt_conn *conn); 832 833 /** 834 * @brief Read Playing Order 835 * 836 * @param conn Connection to the peer device 837 * 838 * @return 0 if success, errno on failure. 839 */ 840 int bt_mcc_read_playing_order(struct bt_conn *conn); 841 842 /** 843 * @brief Set Playing Order 844 * 845 * @param conn Connection to the peer device 846 * @param order Playing order 847 * 848 * @return 0 if success, errno on failure. 849 */ 850 int bt_mcc_set_playing_order(struct bt_conn *conn, uint8_t order); 851 852 /** 853 * @brief Read Playing Orders Supported 854 * 855 * @param conn Connection to the peer device 856 * 857 * @return 0 if success, errno on failure. 858 */ 859 int bt_mcc_read_playing_orders_supported(struct bt_conn *conn); 860 861 /** 862 * @brief Read Media State 863 * 864 * @param conn Connection to the peer device 865 * 866 * @return 0 if success, errno on failure. 867 */ 868 int bt_mcc_read_media_state(struct bt_conn *conn); 869 870 /** 871 * @brief Send a command 872 * 873 * Write a command (e.g. "play", "pause") to the server's media control point. 874 * 875 * @param conn Connection to the peer device 876 * @param cmd The command to send 877 * 878 * @return 0 if success, errno on failure. 879 */ 880 int bt_mcc_send_cmd(struct bt_conn *conn, const struct mpl_cmd *cmd); 881 882 /** 883 * @brief Read Opcodes Supported 884 * 885 * @param conn Connection to the peer device 886 * 887 * @return 0 if success, errno on failure. 888 */ 889 int bt_mcc_read_opcodes_supported(struct bt_conn *conn); 890 891 /** 892 * @brief Send a Search command 893 * 894 * Write a search to the server's search control point. 895 * 896 * @param conn Connection to the peer device 897 * @param search The search 898 * 899 * @return 0 if success, errno on failure. 900 */ 901 int bt_mcc_send_search(struct bt_conn *conn, const struct mpl_search *search); 902 903 /** 904 * @brief Search Results Group Object ID 905 * 906 * @param conn Connection to the peer device 907 * 908 * @return 0 if success, errno on failure. 909 */ 910 int bt_mcc_read_search_results_obj_id(struct bt_conn *conn); 911 912 /** 913 * @brief Read Content Control ID 914 * 915 * @param conn Connection to the peer device 916 * 917 * @return 0 if success, errno on failure. 918 */ 919 int bt_mcc_read_content_control_id(struct bt_conn *conn); 920 921 /** 922 * @brief Read the current object metadata 923 * 924 * @param conn Connection to the peer device 925 * 926 * @return 0 if success, errno on failure. 927 */ 928 int bt_mcc_otc_read_object_metadata(struct bt_conn *conn); 929 930 /** 931 * @brief Read the Icon Object 932 * 933 * @param conn Connection to the peer device 934 * 935 * @return 0 if success, errno on failure. 936 */ 937 int bt_mcc_otc_read_icon_object(struct bt_conn *conn); 938 939 /** 940 * @brief Read the Track Segments Object 941 * 942 * @param conn Connection to the peer device 943 * 944 * @return 0 if success, errno on failure. 945 */ 946 int bt_mcc_otc_read_track_segments_object(struct bt_conn *conn); 947 948 /** 949 * @brief Read the Current Track Object 950 * 951 * @param conn Connection to the peer device 952 * 953 * @return 0 if success, errno on failure. 954 */ 955 int bt_mcc_otc_read_current_track_object(struct bt_conn *conn); 956 957 /** 958 * @brief Read the Next Track Object 959 * 960 * @param conn Connection to the peer device 961 * 962 * @return 0 if success, errno on failure. 963 */ 964 int bt_mcc_otc_read_next_track_object(struct bt_conn *conn); 965 966 /** 967 * @brief Read the Current Group Object 968 * 969 * @param conn Connection to the peer device 970 * 971 * @return 0 if success, errno on failure. 972 */ 973 int bt_mcc_otc_read_current_group_object(struct bt_conn *conn); 974 975 /** 976 * @brief Read the Parent Group Object 977 * 978 * @param conn Connection to the peer device 979 * 980 * @return 0 if success, errno on failure. 981 */ 982 int bt_mcc_otc_read_parent_group_object(struct bt_conn *conn); 983 984 /** 985 * @brief Look up MCC OTC instance 986 * 987 * @param conn The connection to the MCC server. 988 * 989 * @return Pointer to a MCC OTC instance if found else NULL. 990 * 991 */ 992 struct bt_ots_client *bt_mcc_otc_inst(struct bt_conn *conn); 993 994 #ifdef __cplusplus 995 } 996 #endif 997 998 /** 999 * @} 1000 */ 1001 1002 #endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_MCC__ */ 1003