Bluetooth: Audio: Media control client

This commit adds the Media Control Client from the topic-le-audio
branch.  This is a part of the upmerge of the le-audio media control
files.

This client has been developed and maintained over a couple of years
now, and is mature.  During the development it has passed both
IOP-testing and PTS qualification testing.

The commit is a pure copy of the files and content in the
topic-le-audio branch, with the following exceptions:

- files are in bluetooth/audio instead of bluetooth/host/audio, with
  some include paths updated as a consequence
- as a consequence, CMake files and Kconfig files updates are done in
  other locations
- a macro for debug output of Object ID values has been (temporarily)
  added to mcc.h, to avoid a dependency
- a blank line added after a declaration and an overlong line split,
  to pass check_compliance
- copyrights have been updated

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
This commit is contained in:
Asbjørn Sæbø 2021-10-22 09:31:23 +02:00 committed by Carles Cufí
commit 6f94d02463
5 changed files with 3922 additions and 0 deletions

View file

@ -0,0 +1,938 @@
/**
* @brief Bluetooth Media Control Client (MCC) interface
*
* Updated to the Media Control Profile specification revision 1.0
*
* @defgroup bt_gatt_mcc Media Control Client (MCC)
*
* @ingroup bluetooth
* @{
*
* [Experimental] Users should note that the APIs can change
* as a part of ongoing development.
*/
/*
* Copyright (c) 2019 - 2021 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_MCC_
#define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_MCC_
#include <zephyr/types.h>
#include <bluetooth/conn.h>
#include <net/buf.h>
#include <bluetooth/audio/media_proxy.h>
#ifdef __cplusplus
extern "C" {
#endif
/**** Callback functions ******************************************************/
/**
* @brief Callback function for bt_mcc_discover_mcs()
*
* Called when a media control server is discovered
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
*/
typedef void (*bt_mcc_discover_mcs_cb)(struct bt_conn *conn, int err);
/**
* @brief Callback function for bt_mcc_read_player_name()
*
* Called when the player name is read or notified
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param name Player name
*/
typedef void (*bt_mcc_read_player_name_cb)(struct bt_conn *conn, int err, const char *name);
#ifdef CONFIG_BT_OTC
/**
* @brief Callback function for bt_mcc_read_icon_obj_id()
*
* Called when the icon object ID is read
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param icon_id The ID of the Icon Object. This is a UINT48 in a uint64_t
*/
typedef void (*bt_mcc_read_icon_obj_id_cb)(struct bt_conn *conn, int err, uint64_t id);
#endif /* CONFIG_BT_OTC */
/**
* @brief Callback function for bt_mcc_read_icon_url()
*
* Called when the icon URL is read
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param icon_url The URL of the Icon
*/
typedef void (*bt_mcc_read_icon_url_cb)(struct bt_conn *conn, int err, const char *icon_url);
/**
* @brief Callback function for track changed notifications
*
* Called when a track change is notified.
*
* The track changed characteristic is a special case. It can not be read or
* set, it can only be notified.
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
*/
typedef void (*bt_mcc_track_changed_ntf_cb)(struct bt_conn *conn, int err);
/**
* @brief Callback function for bt_mcc_read_track_title()
*
* Called when the track title is read or notified
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param title The title of the track
*/
typedef void (*bt_mcc_read_track_title_cb)(struct bt_conn *conn, int err, const char *title);
/**
* @brief Callback function for bt_mcc_read_track_duration()
*
* Called when the track duration is read or notified
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param dur The duration of the track
*/
typedef void (*bt_mcc_read_track_duration_cb)(struct bt_conn *conn, int err, int32_t dur);
/**
* @brief Callback function for bt_mcc_read_track_position()
*
* Called when the track position is read or notified
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param pos The Track Position
*/
typedef void (*bt_mcc_read_track_position_cb)(struct bt_conn *conn, int err, int32_t pos);
/**
* @brief Callback function for bt_mcc_set_track_position()
*
* Called when the track position is set
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param pos The Track Position set (or attempted to set)
*/
typedef void (*bt_mcc_set_track_position_cb)(struct bt_conn *conn, int err, int32_t pos);
/**
* @brief Callback function for bt_mcc_read_playback_speed()
*
* Called when the playback speed is read or notified
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param speed The Playback Speed
*/
typedef void (*bt_mcc_read_playback_speed_cb)(struct bt_conn *conn, int err, int8_t speed);
/**
* @brief Callback function for bt_mcc_set_playback_speed()
*
* Called when the playback speed is set
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param speed The Playback Speed set (or attempted to set)
*/
typedef void (*bt_mcc_set_playback_speed_cb)(struct bt_conn *conn, int err, int8_t speed);
/**
* @brief Callback function for bt_mcc_read_seeking_speed()
*
* Called when the seeking speed is read or notified
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param speed The Seeking Speed
*/
typedef void (*bt_mcc_read_seeking_speed_cb)(struct bt_conn *conn, int err, int8_t speed);
#ifdef CONFIG_BT_OTC
/**
* @brief Callback function for bt_mcc_read_segments_obj_id()
*
* Called when the track segments object ID is read
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param id The Track Segments Object ID (UINT48)
*/
typedef void (*bt_mcc_read_segments_obj_id_cb)(struct bt_conn *conn, int err, uint64_t id);
/**
* @brief Callback function for bt_mcc_read_current_track_obj_id()
*
* Called when the current track object ID is read or notified
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param id The Current Track Object ID (UINT48)
*/
typedef void (*bt_mcc_read_current_track_obj_id_cb)(struct bt_conn *conn, int err, uint64_t id);
/**
* @brief Callback function for bt_mcc_set_current_track_obj_id()
*
* Called when the current track object ID is set
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param id The Object ID (UINT48) set (or attempted to set)
*/
typedef void (*bt_mcc_set_current_track_obj_id_cb)(struct bt_conn *conn, int err, uint64_t id);
/**
* @brief Callback function for bt_mcc_read_next_track_obj_id_obj()
*
* Called when the next track object ID is read or notified
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param id The Next Track Object ID (UINT48)
*/
typedef void (*bt_mcc_read_next_track_obj_id_cb)(struct bt_conn *conn, int err, uint64_t id);
/**
* @brief Callback function for bt_mcc_set_next_track_obj_id()
*
* Called when the next track object ID is set
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param id The Object ID (UINT48) set (or attempted to set)
*/
typedef void (*bt_mcc_set_next_track_obj_id_cb)(struct bt_conn *conn, int err, uint64_t id);
/**
* @brief Callback function for bt_mcc_read_parent_group_obj_id()
*
* Called when the parent group object ID is read or notified
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param id The Parent Group Object ID (UINT48)
*/
typedef void (*bt_mcc_read_parent_group_obj_id_cb)(struct bt_conn *conn, int err, uint64_t id);
/**
* @brief Callback function for bt_mcc_read_current_group_obj_id()
*
* Called when the current group object ID is read or notified
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param id The Current Group Object ID (UINT48)
*/
typedef void (*bt_mcc_read_current_group_obj_id_cb)(struct bt_conn *conn, int err, uint64_t id);
/**
* @brief Callback function for bt_mcc_set_current_group_obj_id()
*
* Called when the current group object ID is set
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param id The Object ID (UINT48) set (or attempted to set)
*/
typedef void (*bt_mcc_set_current_group_obj_id_cb)(struct bt_conn *conn, int err, uint64_t obj_id);
#endif /* CONFIG_BT_OTC */
/**
* @brief Callback function for bt_mcc_read_playing_order()
*
* Called when the playing order is read or notified
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param order The playback order
*/
typedef void (*bt_mcc_read_playing_order_cb)(struct bt_conn *conn, int err, uint8_t order);
/**
* @brief Callback function for bt_mcc_set_playing_order()
*
* Called when the playing order is set
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param order The Playing Order set (or attempted to set)
*/
typedef void (*bt_mcc_set_playing_order_cb)(struct bt_conn *conn, int err, uint8_t order);
/**
* @brief Callback function for bt_mcc_read_playing_orders_supported()
*
* Called when the supported playing orders are read or notified
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param orders The playing orders supported (bitmap)
*/
typedef void (*bt_mcc_read_playing_orders_supported_cb)(struct bt_conn *conn, int err,
uint16_t orders);
/**
* @brief Callback function for bt_mcc_read_media_state()
*
* Called when the media state is read or notified
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param state The Media State
*/
typedef void (*bt_mcc_read_media_state_cb)(struct bt_conn *conn, int err, uint8_t state);
/**
* @brief Callback function for bt_mcc_send_cmd()
*
* Called when a command is sent, i.e. when the media control point is set
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param cmd The command sent
*/
typedef void (*bt_mcc_send_cmd_cb)(struct bt_conn *conn, int err, struct mpl_cmd cmd);
/**
* @brief Callback function for command notifications
*
* Called when the media control point is notified
*
* Notifications for commands (i.e. for writes to the media control point) use a
* different parameter structure than what is used for sending commands (writing
* to the media control point)
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param ntf The command notification
*/
typedef void (*bt_mcc_cmd_ntf_cb)(struct bt_conn *conn, int err, struct mpl_cmd_ntf ntf);
/**
* @brief Callback function for bt_mcc_read_opcodes_supported()
*
* Called when the supported opcodes (commands) are read or notified
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param opcodes The supported opcodes
*/
typedef void (*bt_mcc_read_opcodes_supported_cb)(struct bt_conn *conn, int err,
uint32_t opcodes);
#ifdef CONFIG_BT_OTC
/**
* @brief Callback function for bt_mcc_send_search()
*
* Called when a search is sent, i.e. when the search control point is set
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param search The search set (or attempted to set)
*/
typedef void (*bt_mcc_send_search_cb)(struct bt_conn *conn, int err,
struct mpl_search search);
/**
* @brief Callback function for search notifications
*
* Called when the search control point is notified
*
* Notifications for searches (i.e. for writes to the search control point) use a
* different parameter structure than what is used for sending searches (writing
* to the search control point)
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param ntf The search notification
*/
typedef void (*bt_mcc_search_ntf_cb)(struct bt_conn *conn, int err,
uint8_t result_code);
/**
* @brief Callback function for bt_mcc_read_search_results_obj_id()
*
* Called when the search results object ID is read or notified
*
* Note that the Search Results Object ID value may be zero, in case the
* characteristic does not exist on the server. (This will be the case if
* there has not been a successful search.)
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param id The Search Results Object ID (UINT48)
*/
typedef void (*bt_mcc_read_search_results_obj_id_cb)(struct bt_conn *conn,
int err, uint64_t id);
#endif /* CONFIG_BT_OTC */
/**
* @brief Callback function for bt_mcc_read_content_control_id()
*
* Called when the content control ID is read
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param ccid The Content Control ID
*/
typedef void (*bt_mcc_read_content_control_id_cb)(struct bt_conn *conn,
int err, uint8_t ccid);
#ifdef CONFIG_BT_OTC
/**** Callback functions for the included Object Transfer service *************/
/**
* @brief Callback function for object selected
*
* Called when an object is selected
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
*/
typedef void (*bt_mcc_otc_obj_selected_cb)(struct bt_conn *conn, int err);
/**
* @brief Callback function for bt_mcc_otc_read_object_meatadata()
*
* Called when object metadata is read
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
*/
typedef void (*bt_mcc_otc_obj_metadata_cb)(struct bt_conn *conn, int err);
/**
* @brief Callback function for bt_mcc_otc_read_icon_object()
*
* Called when the icon object is read
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param buf Buffer containing the object contents
*
* If err is EMSGSIZE, the object contents have been truncated.
*/
typedef void (*bt_mcc_otc_read_icon_object_cb)(struct bt_conn *conn, int err,
struct net_buf_simple *buf);
/**
* @brief Callback function for bt_mcc_otc_read_track_segments_object()
*
* Called when the track segments object is read
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param buf Buffer containing the object contents
*
* If err is EMSGSIZE, the object contents have been truncated.
*/
typedef void (*bt_mcc_otc_read_track_segments_object_cb)(struct bt_conn *conn, int err,
struct net_buf_simple *buf);
/**
* @brief Callback function for bt_mcc_otc_read_current_track_object()
*
* Called when the current track object is read
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param buf Buffer containing the object contents
*
* If err is EMSGSIZE, the object contents have been truncated.
*/
typedef void (*bt_mcc_otc_read_current_track_object_cb)(struct bt_conn *conn, int err,
struct net_buf_simple *buf);
/**
* @brief Callback function for bt_mcc_otc_read_next_track_object()
*
* Called when the next track object is read
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param buf Buffer containing the object contents
*
* If err is EMSGSIZE, the object contents have been truncated.
*/
typedef void (*bt_mcc_otc_read_next_track_object_cb)(struct bt_conn *conn, int err,
struct net_buf_simple *buf);
/**
* @brief Callback function for bt_mcc_otc_read_parent_group_object()
*
* Called when the parent group object is read
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param buf Buffer containing the object contents
*
* If err is EMSGSIZE, the object contents have been truncated.
*/
typedef void (*bt_mcc_otc_read_parent_group_object_cb)(struct bt_conn *conn, int err,
struct net_buf_simple *buf);
/**
* @brief Callback function for bt_mcc_otc_read_current_group_object()
*
* Called when the current group object is read
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param buf Buffer containing the object contents
*
* If err is EMSGSIZE, the object contents have been truncated.
*/
typedef void (*bt_mcc_otc_read_current_group_object_cb)(struct bt_conn *conn, int err,
struct net_buf_simple *buf);
#endif /* CONFIG_BT_OTC */
/**
* @brief Media control client callbacks
*/
struct bt_mcc_cb {
bt_mcc_discover_mcs_cb discover_mcs;
bt_mcc_read_player_name_cb read_player_name;
#ifdef CONFIG_BT_OTC
bt_mcc_read_icon_obj_id_cb read_icon_obj_id;
#endif /* CONFIG_BT_OTC */
bt_mcc_read_icon_url_cb read_icon_url;
bt_mcc_track_changed_ntf_cb track_changed_ntf;
bt_mcc_read_track_title_cb read_track_title;
bt_mcc_read_track_duration_cb read_track_duration;
bt_mcc_read_track_position_cb read_track_position;
bt_mcc_set_track_position_cb set_track_position;
bt_mcc_read_playback_speed_cb read_playback_speed;
bt_mcc_set_playback_speed_cb set_playback_speed;
bt_mcc_read_seeking_speed_cb read_seeking_speed;
#ifdef CONFIG_BT_OTC
bt_mcc_read_segments_obj_id_cb read_segments_obj_id;
bt_mcc_read_current_track_obj_id_cb read_current_track_obj_id;
bt_mcc_set_current_track_obj_id_cb set_current_track_obj_id;
bt_mcc_read_next_track_obj_id_cb read_next_track_obj_id;
bt_mcc_set_next_track_obj_id_cb set_next_track_obj_id;
bt_mcc_read_current_group_obj_id_cb read_current_group_obj_id;
bt_mcc_set_current_group_obj_id_cb set_current_group_obj_id;
bt_mcc_read_parent_group_obj_id_cb read_parent_group_obj_id;
#endif /* CONFIG_BT_OTC */
bt_mcc_read_playing_order_cb read_playing_order;
bt_mcc_set_playing_order_cb set_playing_order;
bt_mcc_read_playing_orders_supported_cb read_playing_orders_supported;
bt_mcc_read_media_state_cb read_media_state;
bt_mcc_send_cmd_cb send_cmd;
bt_mcc_cmd_ntf_cb cmd_ntf;
bt_mcc_read_opcodes_supported_cb read_opcodes_supported;
#ifdef CONFIG_BT_OTC
bt_mcc_send_search_cb send_search;
bt_mcc_search_ntf_cb search_ntf;
bt_mcc_read_search_results_obj_id_cb read_search_results_obj_id;
#endif /* CONFIG_BT_OTC */
bt_mcc_read_content_control_id_cb read_content_control_id;
#ifdef CONFIG_BT_OTC
bt_mcc_otc_obj_selected_cb otc_obj_selected;
bt_mcc_otc_obj_metadata_cb otc_obj_metadata;
bt_mcc_otc_read_icon_object_cb otc_icon_object;
bt_mcc_otc_read_track_segments_object_cb otc_track_segments_object;
bt_mcc_otc_read_current_track_object_cb otc_current_track_object;
bt_mcc_otc_read_next_track_object_cb otc_next_track_object;
bt_mcc_otc_read_current_group_object_cb otc_current_group_object;
bt_mcc_otc_read_parent_group_object_cb otc_parent_group_object;
#endif /* CONFIG_BT_OTC */
};
/**** Functions ***************************************************************/
/**
* @brief Initialize Media Control Client
*
* @param cb Callbacks to be used
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_init(struct bt_mcc_cb *cb);
/**
* @brief Discover Media Control Service
*
* Discover Media Control Service (MCS) on the server given by the connection
* Optionally subscribe to notifications.
*
* Shall be called once, after media control client initialization and before
* using other media control client functionality.
*
* @param conn Connection to the peer device
* @param subscribe Whether to subscribe to notifications
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_discover_mcs(struct bt_conn *conn, bool subscribe);
/**
* @brief Read Media Player Name
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_player_name(struct bt_conn *conn);
#ifdef CONFIG_BT_OTC
/**
* @brief Read Icon Object ID
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_icon_obj_id(struct bt_conn *conn);
#endif /* CONFIG_BT_OTC */
/**
* @brief Read Icon Object URL
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_icon_url(struct bt_conn *conn);
/**
* @brief Read Track Title
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_track_title(struct bt_conn *conn);
/**
* @brief Read Track Duration
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_track_duration(struct bt_conn *conn);
/**
* @brief Read Track Position
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_track_position(struct bt_conn *conn);
/**
* @brief Set Track position
*
* @param conn Connection to the peer device
* @param pos Track position
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_set_track_position(struct bt_conn *conn, int32_t pos);
/**
* @brief Read Playback speed
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_playback_speed(struct bt_conn *conn);
/**
* @brief Set Playback Speed
*
* @param conn Connection to the peer device
* @param speed Playback speed
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_set_playback_speed(struct bt_conn *conn, int8_t speed);
/**
* @brief Read Seeking speed
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_seeking_speed(struct bt_conn *conn);
#ifdef CONFIG_BT_OTC
/**
* @brief Read Track Segments Object ID
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_segments_obj_id(struct bt_conn *conn);
/**
* @brief Read Current Track Object ID
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_current_track_obj_id(struct bt_conn *conn);
/**
* @brief Set Current Track Object ID
*
* Set the Current Track to the the track given by the @p id parameter
*
* @param conn Connection to the peer device
* @param id Object Transfer Service ID (UINT48) of the track to set as the current track
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_set_current_track_obj_id(struct bt_conn *conn, uint64_t id);
/**
* @brief Read Next Track Object ID
*
* @param conn Connection to the peer device
* @param id Object Transfer Service ID (UINT48) of the track to set as the current track
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_next_track_obj_id(struct bt_conn *conn);
/**
* @brief Set Next Track Object ID
*
* Set the Next Track to the the track given by the @p id parameter
*
* @param conn Connection to the peer device
* @param id Object Transfer Service ID (UINT48) of the track to set as the next track
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_set_next_track_obj_id(struct bt_conn *conn, uint64_t id);
/**
* @brief Read Current Group Object ID
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_current_group_obj_id(struct bt_conn *conn);
/**
* @brief Set Current Group Object ID
*
* Set the Current Group to the the group given by the @p id parameter
*
* @param conn Connection to the peer device
* @param id Object Transfer Service ID (UINT48) of the group to set as the current group
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_set_current_group_obj_id(struct bt_conn *conn, uint64_t id);
/**
* @brief Read Parent Group Object ID
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_parent_group_obj_id(struct bt_conn *conn);
#endif /* CONFIG_BT_OTC */
/**
* @brief Read Playing Order
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_playing_order(struct bt_conn *conn);
/**
* @brief Set Playing Order
*
* @param conn Connection to the peer device
* @param order Playing order
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_set_playing_order(struct bt_conn *conn, uint8_t order);
/**
* @brief Read Playing Orders Supported
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_playing_orders_supported(struct bt_conn *conn);
/**
* @brief Read Media State
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_media_state(struct bt_conn *conn);
/**
* @brief Send a command
*
* Write a command (e.g. "play", "pause") to the server's media control point.
*
* @param conn Connection to the peer device
* @param cmd The command to send
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_send_cmd(struct bt_conn *conn, struct mpl_cmd cmd);
/**
* @brief Read Opcodes Supported
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_opcodes_supported(struct bt_conn *conn);
#ifdef CONFIG_BT_OTC
/**
* @brief Send a Search command
*
* Write a search to the server's search control point.
*
* @param conn Connection to the peer device
* @param search The search
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_send_search(struct bt_conn *conn, struct mpl_search search);
/**
* @brief Search Results Group Object ID
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_search_results_obj_id(struct bt_conn *conn);
#endif /* CONFIG_BT_OTC */
/**
* @brief Read Content Control ID
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_content_control_id(struct bt_conn *conn);
#ifdef CONFIG_BT_OTC
/**
* @brief Read the current object metadata
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_otc_read_object_metadata(struct bt_conn *conn);
/**
* @brief Read the Icon Object
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_otc_read_icon_object(struct bt_conn *conn);
/**
* @brief Read the Track Segments Object
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_otc_read_track_segments_object(struct bt_conn *conn);
/**
* @brief Read the Current Track Object
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_otc_read_current_track_object(struct bt_conn *conn);
/**
* @brief Read the Next Track Object
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_otc_read_next_track_object(struct bt_conn *conn);
/**
* @brief Read the Current Group Object
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_otc_read_current_group_object(struct bt_conn *conn);
/**
* @brief Read the Parent Group Object
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_otc_read_parent_group_object(struct bt_conn *conn);
#if defined(CONFIG_BT_MCC_SHELL)
struct bt_otc_instance_t *bt_mcc_otc_inst(void);
#endif /* defined(CONFIG_BT_MCC_SHELL) */
#endif /* CONFIG_BT_OTC */
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_MCC__ */

View file

@ -33,3 +33,5 @@ if (CONFIG_BT_CSIS OR CONFIG_BT_CSIS_CLIENT)
endif() endif()
zephyr_library_sources_ifdef(CONFIG_BT_OTC otc.c) zephyr_library_sources_ifdef(CONFIG_BT_OTC otc.c)
zephyr_library_sources_ifdef(CONFIG_BT_MCC mcc.c)

View file

@ -63,5 +63,6 @@ rsource "Kconfig.vcs"
rsource "Kconfig.mics" rsource "Kconfig.mics"
rsource "Kconfig.csis" rsource "Kconfig.csis"
rsource "Kconfig.otc" rsource "Kconfig.otc"
rsource "Kconfig.mcs"
endif # BT_AUDIO endif # BT_AUDIO

View file

@ -0,0 +1,207 @@
# Bluetooth Audio - Media control configuration options
#
# Copyright (c) 2020 Nordic Semiconductor
#
# SPDX-License-Identifier: Apache-2.0
#
if BT_AUDIO
#### Media Control Service ################################
config BT_MCS
bool "Media Control Service Support"
select BT_CCID
select EXPERIMENTAL
help
This option enables support for the Media Control Service.
if BT_MCS
config BT_MCS_MEDIA_PLAYER_NAME
string "Media Player Name"
default "Player0"
help
Use this option to set the name of the media player.
config BT_MCS_ICON_URL
string "Media player Icon URL"
default "http://server.some.where/path/icon.png"
help
Use this option to set the URL of the Media Player Icon.
#### Debug logs ################################################################
config BT_DEBUG_MCS
bool "Media Control Service debug"
depends on BT_AUDIO_DEBUG
help
Use this option to enable Media Control Service debug logs for the
Bluetooth Audio functionality.
endif # BT_MCS
#### Media Control Client ################################
config BT_MCC
bool "Media Control Client Support"
select BT_GATT_CLIENT
select BT_GATT_AUTO_DISCOVER_CCC
select EXPERIMENTAL
help
This option enables support for the Media Control Client.
if BT_MCC
config BT_MCC_OTS
bool "Media Control Client support for Object Transfer Service"
depends on BT_OTC
help
Use this option to configure support in the Media Control Client for
an included Object Transfer Service in the Media Control Service.
if BT_MCC_OTS
config BT_MCC_OTC_OBJ_BUF_SIZE
int "The size of the buffer used for OTC object in MCC"
default 512
range 1 65536
help
Sets the size (in octets) of the buffer used for receiving the content
of objects.
Should be set large enough to fit any expected object.
config BT_MCC_TOTAL_OBJ_CONTENT_MEM
int "Total memory size to use for storing the content of objects"
default 1
range 0 65536
help
Sets the total memory size (in octets) to use for storing the content
of objects.
This is used for the total memory pool buffer size from which memory
is allocated when reading object content.
config BT_MCC_TRACK_SEGS_MAX_CNT
int "Maximum number of tracks segments in a track segment object"
default 25
range 0 500
help
Sets the maximum number of tracks segments in a track segment object.
If the received object is bigger, the remaining data in the object
will be ignored.
config BT_MCC_GROUP_RECORDS_MAX
int "Maximum number of records in a group object"
default 25
range 0 500
help
Sets the maximum number of records in a group object. If the received
group object has more records than this, the remaining records in the
object will be ignored.
endif # BT_MCC_OTS
config BT_MCC_SHELL
bool "Media Control Client Shell Support"
default y if BT_SHELL
help
This option enables shell support for the Media Control Client.
#### MCC Debug logs ####
config BT_DEBUG_MCC
bool "Media Control Client debug"
depends on BT_AUDIO_DEBUG
help
Use this option to enable Media Control Client debug logs for the
Bluetooth Audio functionality.
endif # BT_MCC
if BT_MCS || BT_MCC
config BT_MCS_MEDIA_PLAYER_NAME_MAX
int "Max length of media player name"
default 20
range 1 255
help
Sets the maximum number of bytes (including the null termination) of
the name of the media player.
config BT_MCS_ICON_URL_MAX
int "Max length of media player icon URL"
default 30
range 1 255
help
Sets the maximum number of bytes (including the null termination) of
the media player icon URL.
config BT_MCS_TRACK_TITLE_MAX
int "Max length of the title of a track"
default 25
range 1 255
help
Sets the maximum number of bytes (including the null termination) of
the title of any track in the media player.
config BT_MCS_GROUP_TITLE_MAX
int "Max length of the title of a group of tracks"
default BT_MCS_TRACK_TITLE_MAX
range 1 255
help
Sets the maximum number of bytes (including the null termination) of
the title of any track in the media player.
config BT_MCS_SEGMENT_NAME_MAX
int "Max length of the name of a track segment"
default 25
range 1 255
help
Sets the the maximum number of bytes (including the null termination)
of the name of any track segment in the media player.
config BT_MCS_ICON_BITMAP_SIZE
int "Media player Icon bitmap object size"
default 127
help
This option sets the maximum size (in octets) of the icon object.
config BT_MCS_TRACK_SEG_MAX_SIZE
int "Maximum size for a track segment object"
default 127
help
This option sets the maximum size (in octets) of a track segment object.
config BT_MCS_TRACK_MAX_SIZE
int "Maximum size for a track object"
default 127
help
This option sets the maximum size (in octets) of a track object.
config BT_MCS_GROUP_MAX_SIZE
int "Maximum size for a group object"
default 127
help
This option sets the maximum size (in octets) of a group object.
config BT_MCS_MAX_OBJ_SIZE
int "Total memory size to use for storing the content of objects"
default 127
range 0 65536
help
Sets the total memory size (in octets) to use for storing the content of objects.
This is used for the total memory pool buffer size from which memory
is allocated when sending object content.
config BT_DEBUG_MEDIA_PROXY
bool "Media Proxy debug"
depends on BT_AUDIO_DEBUG
help
Use this option to enable Media Proxy debug logs for the
Bluetooth Audio functionality.
endif # BT_MCS || BT_MCC
endif # BT_AUDIO

2774
subsys/bluetooth/audio/mcc.c Normal file

File diff suppressed because it is too large Load diff