1 /*
2  * Copyright (c) 2021 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef ZEPHYR_SUBSYS_BLUETOOTH_AUDIO_MEDIA_PROXY_INTERNAL_H_
8 #define ZEPHYR_SUBSYS_BLUETOOTH_AUDIO_MEDIA_PROXY_INTERNAL_H_
9 
10 /** @brief Internal APIs for Bluetooth Media Control */
11 
12 #include <zephyr/bluetooth/audio/media_proxy.h>
13 
14 #define MPL_NO_TRACK_ID 0
15 
16 /* Debug output of 48 bit Object ID value */
17 /* (Zephyr does not yet support debug output of more than 32 bit values.) */
18 /* Takes a text and a 64-bit integer as input */
19 #define LOG_DBG_OBJ_ID(text, id64) \
20 	do { \
21 		if (IS_ENABLED(CONFIG_BT_MCS_LOG_LEVEL_DBG)) { \
22 			char t[BT_OTS_OBJ_ID_STR_LEN]; \
23 			(void)bt_ots_obj_id_to_str(id64, t, sizeof(t)); \
24 			LOG_DBG(text "0x%s", t); \
25 		} \
26 	} while (0)
27 
28 
29 /* SYNCHRONOUS (CALL/RETURN) API FOR CONTROLLERS */
30 
31 /** @brief Callbacks to a controller, from the media proxy */
32 struct media_proxy_sctrl_cbs {
33 	void (*player_name)(const char *name);
34 
35 	void (*icon_url)(const char *url);
36 
37 	void (*track_changed)(void);
38 
39 	void (*track_title)(const char *title);
40 
41 	void (*track_duration)(int32_t duration);
42 
43 	void (*track_position)(int32_t position);
44 
45 	void (*playback_speed)(int8_t speed);
46 
47 	void (*seeking_speed)(int8_t speed);
48 #ifdef CONFIG_BT_OTS
49 	void (*current_track_id)(uint64_t id);
50 
51 	void (*next_track_id)(uint64_t id);
52 
53 	void (*current_group_id)(uint64_t id);
54 
55 	void (*parent_group_id)(uint64_t id);
56 #endif /* CONFIG_BT_OTS */
57 
58 	void (*playing_order)(uint8_t order);
59 
60 	void (*media_state)(uint8_t state);
61 
62 	void (*command)(const struct mpl_cmd_ntf *cmd_ntf);
63 
64 	void (*commands_supported)(uint32_t opcodes);
65 
66 #ifdef CONFIG_BT_OTS
67 	void (*search)(uint8_t result_code);
68 
69 	void (*search_results_id)(uint64_t id);
70 #endif /* CONFIG_BT_OTS */
71 };
72 
73 /** @brief Register a controller with the media proxy */
74 int media_proxy_sctrl_register(struct media_proxy_sctrl_cbs *sctrl_cbs);
75 
76 
77 const char *media_proxy_sctrl_get_player_name(void);
78 
79 #ifdef CONFIG_BT_OTS
80 uint64_t media_proxy_sctrl_get_icon_id(void);
81 #endif /* CONFIG_BT_OTS */
82 
83 const char *media_proxy_sctrl_get_icon_url(void);
84 
85 
86 const char *media_proxy_sctrl_get_track_title(void);
87 
88 int32_t media_proxy_sctrl_get_track_duration(void);
89 
90 int32_t media_proxy_sctrl_get_track_position(void);
91 void media_proxy_sctrl_set_track_position(int32_t position);
92 
93 int8_t media_proxy_sctrl_get_playback_speed(void);
94 void media_proxy_sctrl_set_playback_speed(int8_t speed);
95 
96 int8_t media_proxy_sctrl_get_seeking_speed(void);
97 
98 #ifdef CONFIG_BT_OTS
99 uint64_t media_proxy_sctrl_get_track_segments_id(void);
100 
101 uint64_t media_proxy_sctrl_get_current_track_id(void);
102 void media_proxy_sctrl_set_current_track_id(uint64_t id);
103 
104 uint64_t media_proxy_sctrl_get_next_track_id(void);
105 void media_proxy_sctrl_set_next_track_id(uint64_t id);
106 
107 uint64_t media_proxy_sctrl_get_current_group_id(void);
108 void media_proxy_sctrl_set_current_group_id(uint64_t id);
109 
110 uint64_t media_proxy_sctrl_get_parent_group_id(void);
111 #endif /* CONFIG_BT_OTS */
112 
113 uint8_t media_proxy_sctrl_get_playing_order(void);
114 void media_proxy_sctrl_set_playing_order(uint8_t order);
115 
116 uint16_t media_proxy_sctrl_get_playing_orders_supported(void);
117 
118 uint8_t media_proxy_sctrl_get_media_state(void);
119 
120 void media_proxy_sctrl_send_command(const struct mpl_cmd *command);
121 
122 uint32_t media_proxy_sctrl_get_commands_supported(void);
123 
124 #ifdef CONFIG_BT_OTS
125 void media_proxy_sctrl_send_search(const struct mpl_search *search);
126 
127 uint64_t media_proxy_sctrl_get_search_results_id(void);
128 #endif /* CONFIG_BT_OTS */
129 
130 uint8_t media_proxy_sctrl_get_content_ctrl_id(void);
131 
132 #endif /* ZEPHYR_SUBSYS_BLUETOOTH_AUDIO_MEDIA_PROXY_INTERNAL_H_ */
133