Skip to content

Commit 9973d2f

Browse files
MariuszSkamracarlescufi
authored andcommitted
Bluetooth: audio: Factor out PACS related API to internal header
This moves the PACS API to internal header, as it duplicates the bt_capabilities API. Signed-off-by: Mariusz Skamra <[email protected]>
1 parent 94251ac commit 9973d2f

File tree

2 files changed

+91
-123
lines changed

2 files changed

+91
-123
lines changed

include/zephyr/bluetooth/audio/audio.h

Lines changed: 0 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,95 +1492,6 @@ struct bt_audio_unicast_server_cb {
14921492
int (*release)(struct bt_audio_stream *stream);
14931493
};
14941494

1495-
/** @brief Callback structure for the Public Audio Capabilities Service (PACS)
1496-
*
1497-
* This is used for the Unicast Server
1498-
* (@kconfig{CONFIG_BT_AUDIO_UNICAST_SERVER}) and Broadcast Sink
1499-
* (@kconfig{CONFIG_BT_AUDIO_BROADCAST_SINK}) roles.
1500-
*/
1501-
struct bt_audio_pacs_cb {
1502-
/** @brief Get available audio contexts callback
1503-
*
1504-
* Get available audio contexts callback is called whenever a remote client
1505-
* requests to read the value of Published Audio Capabilities (PAC) Available
1506-
* Audio Contexts, or if the value needs to be notified.
1507-
*
1508-
* @param[in] conn The connection that requests the available audio
1509-
* contexts. Will be NULL if requested for sending
1510-
* a notification, as a result of calling
1511-
* bt_pacs_available_contexts_changed().
1512-
* @param[in] dir Direction of the endpoint.
1513-
* @param[out] context Pointer to the contexts that needs to be set.
1514-
*
1515-
* @return 0 in case of success or negative value in case of error.
1516-
*/
1517-
int (*get_available_contexts)(struct bt_conn *conn, enum bt_audio_dir dir,
1518-
enum bt_audio_context *context);
1519-
1520-
/** @brief Publish Capability callback
1521-
*
1522-
* Publish Capability callback is called whenever a remote client
1523-
* requests to read the Published Audio Capabilities (PAC) records.
1524-
* The callback will be called iteratively until it returns an error,
1525-
* increasing the @p index each time. Once an error value (non-zero)
1526-
* is returned, the previously returned @p codec values (if any) will
1527-
* be sent to the client that requested the value.
1528-
*
1529-
* @param conn The connection that requests the capabilities.
1530-
* Will be NULL if the capabilities is requested for
1531-
* sending a notification, as a result of calling
1532-
* bt_audio_capability_register() or
1533-
* bt_audio_capability_unregister().
1534-
* @param type Type of the endpoint.
1535-
* @param index Index of the codec object requested. Multiple objects
1536-
* may be returned, and this value keep tracks of how
1537-
* many have previously been returned.
1538-
* @param codec Codec object that shall be populated if returning
1539-
* success (0). Ignored if returning non-zero.
1540-
*
1541-
* @return 0 in case of success or negative value in case of error.
1542-
*/
1543-
int (*publish_capability)(struct bt_conn *conn, uint8_t type,
1544-
uint8_t index, struct bt_codec *const codec);
1545-
1546-
#if defined(CONFIG_BT_PAC_SNK_LOC) || defined(CONFIG_BT_PAC_SRC_LOC)
1547-
/** @brief Publish location callback
1548-
*
1549-
* Publish location callback is called whenever a remote client
1550-
* requests to read the Published Audio Capabilities (PAC) location,
1551-
* or if the location needs to be notified.
1552-
*
1553-
* @param[in] conn The connection that requests the location.
1554-
* Will be NULL if the location is requested
1555-
* for sending a notification, as a result of
1556-
* calling bt_audio_pacs_location_changed().
1557-
* @param[in] dir Direction of the endpoint.
1558-
* @param[out] location Pointer to the location that needs to be set.
1559-
*
1560-
* @return 0 in case of success or negative value in case of error.
1561-
*/
1562-
int (*publish_location)(struct bt_conn *conn,
1563-
enum bt_audio_dir dir,
1564-
enum bt_audio_location *location);
1565-
1566-
#if defined(CONFIG_BT_PAC_SNK_LOC_WRITEABLE) || defined(CONFIG_BT_PAC_SRC_LOC_WRITEABLE)
1567-
/** @brief Write location callback
1568-
*
1569-
* Write location callback is called whenever a remote client
1570-
* requests to write the Published Audio Capabilities (PAC) location.
1571-
*
1572-
* @param conn The connection that requests the write.
1573-
* @param dir Direction of the endpoint.
1574-
* @param location The location being written.
1575-
*
1576-
* @return 0 in case of success or negative value in case of error.
1577-
*/
1578-
int (*write_location)(struct bt_conn *conn, enum bt_audio_dir dir,
1579-
enum bt_audio_location location);
1580-
#endif /* CONFIG_BT_PAC_SNK_LOC_WRITEABLE || CONFIG_BT_PAC_SRC_LOC_WRITEABLE */
1581-
#endif /* CONFIG_BT_PAC_SNK_LOC || CONFIG_BT_PAC_SRC_LOC */
1582-
};
1583-
15841495
/** Broadcast Audio Sink callback structure */
15851496
struct bt_audio_broadcast_sink_cb {
15861497
/** @brief Scan receive callback
@@ -1794,40 +1705,6 @@ void bt_audio_stream_cb_register(struct bt_audio_stream *stream,
17941705
* @{
17951706
*/
17961707

1797-
/** @brief Register Published Audio Capabilities Service callbacks.
1798-
*
1799-
* Only one callback structure can be registered, and attempting to
1800-
* registering more than one will result in an error.
1801-
*
1802-
* This can only be done for the Unicast Server
1803-
* (@kconfig{CONFIG_BT_AUDIO_UNICAST_SERVER}) and Broadcast Sink
1804-
* (@kconfig{CONFIG_BT_AUDIO_BROADCAST_SINK}) roles.
1805-
*
1806-
* Calling bt_audio_capability_register() will implicitly register the
1807-
* callbacks.
1808-
*
1809-
* @param cb Unicast server callback structure.
1810-
*
1811-
* @return 0 in case of success or negative value in case of error.
1812-
*/
1813-
int bt_audio_pacs_register_cb(const struct bt_audio_pacs_cb *cb);
1814-
1815-
/** @brief Notify that the location has changed
1816-
*
1817-
* @param dir Direction of the location changed.
1818-
*
1819-
* @return 0 in case of success or negative value in case of error.
1820-
*/
1821-
int bt_audio_pacs_location_changed(enum bt_audio_dir dir);
1822-
1823-
/** @brief Notify available audio contexts changed
1824-
*
1825-
* Notify connected clients that the available audio contexts has changed
1826-
*
1827-
* @return 0 in case of success or negative value in case of error.
1828-
*/
1829-
int bt_pacs_available_contexts_changed(void);
1830-
18311708
/** @brief Register unicast server callbacks.
18321709
*
18331710
* Only one callback structure can be registered, and attempting to

subsys/bluetooth/audio/pacs_internal.h

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,97 @@ struct bt_pacs_context {
5050
uint16_t src;
5151
} __packed;
5252

53+
/** @brief Callback structure for the Public Audio Capabilities Service (PACS)
54+
*
55+
* This is used for the Unicast Server
56+
* (@kconfig{CONFIG_BT_AUDIO_UNICAST_SERVER}) and Broadcast Sink
57+
* (@kconfig{CONFIG_BT_AUDIO_BROADCAST_SINK}) roles.
58+
*/
59+
struct bt_audio_pacs_cb {
60+
/** @brief Get available audio contexts callback
61+
*
62+
* Get available audio contexts callback is called whenever a remote client
63+
* requests to read the value of Published Audio Capabilities (PAC) Available
64+
* Audio Contexts, or if the value needs to be notified.
65+
*
66+
* @param[in] conn The connection that requests the available audio
67+
* contexts. Will be NULL if requested for sending
68+
* a notification, as a result of calling
69+
* bt_pacs_available_contexts_changed().
70+
* @param[in] dir Direction of the endpoint.
71+
* @param[out] context Pointer to the contexts that needs to be set.
72+
*
73+
* @return 0 in case of success or negative value in case of error.
74+
*/
75+
int (*get_available_contexts)(struct bt_conn *conn, enum bt_audio_dir dir,
76+
enum bt_audio_context *context);
77+
78+
/** @brief Publish Capability callback
79+
*
80+
* Publish Capability callback is called whenever a remote client
81+
* requests to read the Published Audio Capabilities (PAC) records.
82+
* The callback will be called iteratively until it returns an error,
83+
* increasing the @p index each time. Once an error value (non-zero)
84+
* is returned, the previously returned @p codec values (if any) will
85+
* be sent to the client that requested the value.
86+
*
87+
* @param conn The connection that requests the capabilities.
88+
* Will be NULL if the capabilities is requested for
89+
* sending a notification, as a result of calling
90+
* bt_audio_capability_register() or
91+
* bt_audio_capability_unregister().
92+
* @param type Type of the endpoint.
93+
* @param index Index of the codec object requested. Multiple objects
94+
* may be returned, and this value keep tracks of how
95+
* many have previously been returned.
96+
* @param codec Codec object that shall be populated if returning
97+
* success (0). Ignored if returning non-zero.
98+
*
99+
* @return 0 in case of success or negative value in case of error.
100+
*/
101+
int (*publish_capability)(struct bt_conn *conn, uint8_t type,
102+
uint8_t index, struct bt_codec *const codec);
103+
104+
#if defined(CONFIG_BT_PAC_SNK_LOC) || defined(CONFIG_BT_PAC_SRC_LOC)
105+
/** @brief Publish location callback
106+
*
107+
* Publish location callback is called whenever a remote client
108+
* requests to read the Published Audio Capabilities (PAC) location,
109+
* or if the location needs to be notified.
110+
*
111+
* @param[in] conn The connection that requests the location.
112+
* Will be NULL if the location is requested
113+
* for sending a notification, as a result of
114+
* calling bt_audio_pacs_location_changed().
115+
* @param[in] dir Direction of the endpoint.
116+
* @param[out] location Pointer to the location that needs to be set.
117+
*
118+
* @return 0 in case of success or negative value in case of error.
119+
*/
120+
int (*publish_location)(struct bt_conn *conn,
121+
enum bt_audio_dir dir,
122+
enum bt_audio_location *location);
123+
124+
#if defined(CONFIG_BT_PAC_SNK_LOC_WRITEABLE) || defined(CONFIG_BT_PAC_SRC_LOC_WRITEABLE)
125+
/** @brief Write location callback
126+
*
127+
* Write location callback is called whenever a remote client
128+
* requests to write the Published Audio Capabilities (PAC) location.
129+
*
130+
* @param conn The connection that requests the write.
131+
* @param dir Direction of the endpoint.
132+
* @param location The location being written.
133+
*
134+
* @return 0 in case of success or negative value in case of error.
135+
*/
136+
int (*write_location)(struct bt_conn *conn, enum bt_audio_dir dir,
137+
enum bt_audio_location location);
138+
#endif /* CONFIG_BT_PAC_SNK_LOC_WRITEABLE || CONFIG_BT_PAC_SRC_LOC_WRITEABLE */
139+
#endif /* CONFIG_BT_PAC_SNK_LOC || CONFIG_BT_PAC_SRC_LOC */
140+
};
141+
142+
int bt_audio_pacs_register_cb(const struct bt_audio_pacs_cb *cb);
143+
int bt_audio_pacs_location_changed(enum bt_audio_dir dir);
53144
void bt_pacs_capabilities_changed(enum bt_audio_dir dir);
54145
int bt_pacs_available_contexts_changed(void);
55146
bool bt_pacs_context_available(enum bt_audio_dir dir, uint16_t context);

0 commit comments

Comments
 (0)