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