1 /*
2  * Copyright (c) 2019 - 2021 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_MCS_H_
8 #define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_MCS_H_
9 
10 /**
11  * @brief Media Control Service (MCS)
12  *
13  * @defgroup bt_mcs Media Control Service (MCS)
14  *
15  * @ingroup bluetooth
16  * @{
17  *
18  * [Experimental] Users should note that the APIs can change
19  * as a part of ongoing development.
20  *
21  * Definitions and types related to the Media Control Service and Media Control
22  * Profile specifications.
23  */
24 
25 #include <zephyr/sys/util.h>
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #define BT_MCS_ERR_LONG_VAL_CHANGED     0x80
32 
33 /** @brief Playback speeds
34  *
35  * All values from -128 to 127 allowed, only some defined
36  */
37 #define BT_MCS_PLAYBACK_SPEED_MIN     -128
38 #define BT_MCS_PLAYBACK_SPEED_QUARTER -128
39 #define BT_MCS_PLAYBACK_SPEED_HALF     -64
40 #define BT_MCS_PLAYBACK_SPEED_UNITY      0
41 #define BT_MCS_PLAYBACK_SPEED_DOUBLE    64
42 #define BT_MCS_PLAYBACK_SPEED_MAX      127
43 
44 /** @brief Seeking speed
45  *
46  * The allowed values for seeking speed are the range -64 to -4
47  * (endpoints included), the value 0, and the range 4 to 64
48  * (endpoints included).
49  */
50 #define BT_MCS_SEEKING_SPEED_FACTOR_MAX  64
51 #define BT_MCS_SEEKING_SPEED_FACTOR_MIN   4
52 #define BT_MCS_SEEKING_SPEED_FACTOR_ZERO  0
53 
54 /** Playing orders */
55 #define BT_MCS_PLAYING_ORDER_SINGLE_ONCE    0X01
56 #define BT_MCS_PLAYING_ORDER_SINGLE_REPEAT  0x02
57 #define BT_MCS_PLAYING_ORDER_INORDER_ONCE   0x03
58 #define BT_MCS_PLAYING_ORDER_INORDER_REPEAT 0x04
59 #define BT_MCS_PLAYING_ORDER_OLDEST_ONCE    0x05
60 #define BT_MCS_PLAYING_ORDER_OLDEST_REPEAT  0x06
61 #define BT_MCS_PLAYING_ORDER_NEWEST_ONCE    0x07
62 #define BT_MCS_PLAYING_ORDER_NEWEST_REPEAT  0x08
63 #define BT_MCS_PLAYING_ORDER_SHUFFLE_ONCE   0x09
64 #define BT_MCS_PLAYING_ORDER_SHUFFLE_REPEAT 0x0a
65 
66 /** @brief Playing orders supported
67  *
68  * A bitmap, in the same order as the playing orders above.
69  * Note that playing order 1 corresponds to bit 0, and so on.
70  */
71 #define BT_MCS_PLAYING_ORDERS_SUPPORTED_SINGLE_ONCE    BIT(0)
72 #define BT_MCS_PLAYING_ORDERS_SUPPORTED_SINGLE_REPEAT  BIT(1)
73 #define BT_MCS_PLAYING_ORDERS_SUPPORTED_INORDER_ONCE   BIT(2)
74 #define BT_MCS_PLAYING_ORDERS_SUPPORTED_INORDER_REPEAT BIT(3)
75 #define BT_MCS_PLAYING_ORDERS_SUPPORTED_OLDEST_ONCE    BIT(4)
76 #define BT_MCS_PLAYING_ORDERS_SUPPORTED_OLDEST_REPEAT  BIT(5)
77 #define BT_MCS_PLAYING_ORDERS_SUPPORTED_NEWEST_ONCE    BIT(6)
78 #define BT_MCS_PLAYING_ORDERS_SUPPORTED_NEWEST_REPEAT  BIT(7)
79 #define BT_MCS_PLAYING_ORDERS_SUPPORTED_SHUFFLE_ONCE   BIT(8)
80 #define BT_MCS_PLAYING_ORDERS_SUPPORTED_SHUFFLE_REPEAT BIT(9)
81 
82 /** Media states */
83 #define BT_MCS_MEDIA_STATE_INACTIVE 0x00
84 #define BT_MCS_MEDIA_STATE_PLAYING  0x01
85 #define BT_MCS_MEDIA_STATE_PAUSED   0x02
86 #define BT_MCS_MEDIA_STATE_SEEKING  0x03
87 #define BT_MCS_MEDIA_STATE_LAST     0x04
88 
89 /** Media control point opcodes */
90 #define BT_MCS_OPC_PLAY          0x01
91 #define BT_MCS_OPC_PAUSE         0x02
92 #define BT_MCS_OPC_FAST_REWIND   0x03
93 #define BT_MCS_OPC_FAST_FORWARD  0x04
94 #define BT_MCS_OPC_STOP          0x05
95 
96 #define BT_MCS_OPC_MOVE_RELATIVE 0x10
97 
98 #define BT_MCS_OPC_PREV_SEGMENT  0x20
99 #define BT_MCS_OPC_NEXT_SEGMENT  0x21
100 #define BT_MCS_OPC_FIRST_SEGMENT 0x22
101 #define BT_MCS_OPC_LAST_SEGMENT  0x23
102 #define BT_MCS_OPC_GOTO_SEGMENT  0x24
103 
104 #define BT_MCS_OPC_PREV_TRACK    0x30
105 #define BT_MCS_OPC_NEXT_TRACK    0x31
106 #define BT_MCS_OPC_FIRST_TRACK   0x32
107 #define BT_MCS_OPC_LAST_TRACK    0x33
108 #define BT_MCS_OPC_GOTO_TRACK    0x34
109 
110 #define BT_MCS_OPC_PREV_GROUP    0x40
111 #define BT_MCS_OPC_NEXT_GROUP    0x41
112 #define BT_MCS_OPC_FIRST_GROUP   0x42
113 #define BT_MCS_OPC_LAST_GROUP    0x43
114 #define BT_MCS_OPC_GOTO_GROUP    0x44
115 
116 /** Media control point supported opcodes length */
117 #define BT_MCS_OPCODES_SUPPORTED_LEN 4
118 
119 /** Media control point supported opcodes values */
120 #define BT_MCS_OPC_SUP_PLAY          BIT(0)
121 #define BT_MCS_OPC_SUP_PAUSE         BIT(1)
122 #define BT_MCS_OPC_SUP_FAST_REWIND   BIT(2)
123 #define BT_MCS_OPC_SUP_FAST_FORWARD  BIT(3)
124 #define BT_MCS_OPC_SUP_STOP          BIT(4)
125 
126 #define BT_MCS_OPC_SUP_MOVE_RELATIVE BIT(5)
127 
128 #define BT_MCS_OPC_SUP_PREV_SEGMENT  BIT(6)
129 #define BT_MCS_OPC_SUP_NEXT_SEGMENT  BIT(7)
130 #define BT_MCS_OPC_SUP_FIRST_SEGMENT BIT(8)
131 #define BT_MCS_OPC_SUP_LAST_SEGMENT  BIT(9)
132 #define BT_MCS_OPC_SUP_GOTO_SEGMENT  BIT(10)
133 
134 #define BT_MCS_OPC_SUP_PREV_TRACK    BIT(11)
135 #define BT_MCS_OPC_SUP_NEXT_TRACK    BIT(12)
136 #define BT_MCS_OPC_SUP_FIRST_TRACK   BIT(13)
137 #define BT_MCS_OPC_SUP_LAST_TRACK    BIT(14)
138 #define BT_MCS_OPC_SUP_GOTO_TRACK    BIT(15)
139 
140 #define BT_MCS_OPC_SUP_PREV_GROUP    BIT(16)
141 #define BT_MCS_OPC_SUP_NEXT_GROUP    BIT(17)
142 #define BT_MCS_OPC_SUP_FIRST_GROUP   BIT(18)
143 #define BT_MCS_OPC_SUP_LAST_GROUP    BIT(19)
144 #define BT_MCS_OPC_SUP_GOTO_GROUP    BIT(20)
145 
146 /** Media control point notification result codes */
147 #define BT_MCS_OPC_NTF_SUCCESS             0x01
148 #define BT_MCS_OPC_NTF_NOT_SUPPORTED       0x02
149 #define BT_MCS_OPC_NTF_PLAYER_INACTIVE     0x03
150 #define BT_MCS_OPC_NTF_CANNOT_BE_COMPLETED 0x04
151 
152 /** Search control point type values */
153 /* Reference: Media Control Service spec v1.0 section 3.20.2 */
154 #define BT_MCS_SEARCH_TYPE_TRACK_NAME    0x01
155 #define BT_MCS_SEARCH_TYPE_ARTIST_NAME   0x02
156 #define BT_MCS_SEARCH_TYPE_ALBUM_NAME    0x03
157 #define BT_MCS_SEARCH_TYPE_GROUP_NAME    0x04
158 #define BT_MCS_SEARCH_TYPE_EARLIEST_YEAR 0x05
159 #define BT_MCS_SEARCH_TYPE_LATEST_YEAR   0x06
160 #define BT_MCS_SEARCH_TYPE_GENRE         0x07
161 #define BT_MCS_SEARCH_TYPE_ONLY_TRACKS   0x08
162 #define BT_MCS_SEARCH_TYPE_ONLY_GROUPS   0x09
163 
164 /** Search control point values */
165 #define SEARCH_LEN_MIN 2       /* At least one search control item (SCI),
166 				* consisting of the length octet and the type
167 				* octet. (The parameter field may be empty.)
168 				*/
169 
170 #define SEARCH_SCI_LEN_MIN 1   /* An SCI length can be as little as one byte,
171 				* for an SCI that has only the type field.
172 				* (The SCI len is the length of type + param.)
173 				*/
174 
175 #define SEARCH_LEN_MAX 64      /* Max total length of search, defined by spec */
176 
177 #define SEARCH_PARAM_MAX 62    /* A search may have a single search control item
178 				* consisting of length, type and parameter
179 				*/
180 
181 /** Search notification result codes */
182 /* Reference: Media Control Service spec v1.0 section 3.20.2 */
183 #define BT_MCS_SCP_NTF_SUCCESS  0x01
184 #define BT_MCS_SCP_NTF_FAILURE  0x02
185 
186 /* Group object object types */
187 /* Reference: Media Control Service spec v1.0 section 4.4.1 */
188 #define BT_MCS_GROUP_OBJECT_TRACK_TYPE 0x00
189 #define BT_MCS_GROUP_OBJECT_GROUP_TYPE 0x01
190 
191 
192 #ifdef __cplusplus
193 }
194 #endif
195 
196 /**
197  * @}
198  */
199 
200 #endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_MCS_H_ */
201