nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
broadcast_source.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#ifndef _BROADCAST_SOURCE_H_
8#define _BROADCAST_SOURCE_H_
9
10#include <zephyr/bluetooth/audio/cap.h>
11#include <zephyr/bluetooth/audio/bap_lc3_preset.h>
12#include "bt_le_audio_tx.h"
13
14#if CONFIG_BT_AUDIO_BROADCAST_CONFIGURABLE
15#define BT_BAP_LC3_BROADCAST_PRESET_NRF5340_AUDIO \
16 BT_BAP_LC3_PRESET_CONFIGURABLE( \
17 BT_AUDIO_LOCATION_FRONT_LEFT | BT_AUDIO_LOCATION_FRONT_RIGHT, \
18 BT_AUDIO_CONTEXT_TYPE_MEDIA, CONFIG_BT_AUDIO_BITRATE_BROADCAST_SRC)
19
20#elif CONFIG_BT_BAP_BROADCAST_16_2_1
21#define BT_BAP_LC3_BROADCAST_PRESET_NRF5340_AUDIO \
22 BT_BAP_LC3_BROADCAST_PRESET_16_2_1(BT_AUDIO_LOCATION_FRONT_LEFT | \
23 BT_AUDIO_LOCATION_FRONT_RIGHT, \
24 BT_AUDIO_CONTEXT_TYPE_MEDIA)
25
26#elif CONFIG_BT_BAP_BROADCAST_16_2_2
27#define BT_BAP_LC3_BROADCAST_PRESET_NRF5340_AUDIO \
28 BT_BAP_LC3_BROADCAST_PRESET_16_2_2(BT_AUDIO_LOCATION_FRONT_LEFT | \
29 BT_AUDIO_LOCATION_FRONT_RIGHT, \
30 BT_AUDIO_CONTEXT_TYPE_MEDIA)
31
32#elif CONFIG_BT_BAP_BROADCAST_24_2_1
33#define BT_BAP_LC3_BROADCAST_PRESET_NRF5340_AUDIO \
34 BT_BAP_LC3_BROADCAST_PRESET_24_2_1(BT_AUDIO_LOCATION_FRONT_LEFT | \
35 BT_AUDIO_LOCATION_FRONT_RIGHT, \
36 BT_AUDIO_CONTEXT_TYPE_MEDIA)
37
38#elif CONFIG_BT_BAP_BROADCAST_24_2_2
39#define BT_BAP_LC3_BROADCAST_PRESET_NRF5340_AUDIO \
40 BT_BAP_LC3_BROADCAST_PRESET_24_2_2(BT_AUDIO_LOCATION_FRONT_LEFT | \
41 BT_AUDIO_LOCATION_FRONT_RIGHT, \
42 BT_AUDIO_CONTEXT_TYPE_MEDIA)
43
44#elif CONFIG_BT_BAP_BROADCAST_48_2_1
45#define BT_BAP_LC3_BROADCAST_PRESET_NRF5340_AUDIO \
46 BT_BAP_LC3_BROADCAST_PRESET_48_2_1(BT_AUDIO_LOCATION_FRONT_LEFT | \
47 BT_AUDIO_LOCATION_FRONT_RIGHT, \
48 BT_AUDIO_CONTEXT_TYPE_MEDIA)
49#elif CONFIG_BT_BAP_BROADCAST_48_2_2
50#define BT_BAP_LC3_BROADCAST_PRESET_NRF5340_AUDIO \
51 BT_BAP_LC3_BROADCAST_PRESET_48_2_2(BT_AUDIO_LOCATION_FRONT_LEFT | \
52 BT_AUDIO_LOCATION_FRONT_RIGHT, \
53 BT_AUDIO_CONTEXT_TYPE_MEDIA)
54
55#elif CONFIG_BT_BAP_BROADCAST_48_4_1
56#define BT_BAP_LC3_BROADCAST_PRESET_NRF5340_AUDIO \
57 BT_BAP_LC3_BROADCAST_PRESET_48_4_1(BT_AUDIO_LOCATION_FRONT_LEFT | \
58 BT_AUDIO_LOCATION_FRONT_RIGHT, \
59 BT_AUDIO_CONTEXT_TYPE_MEDIA)
60
61#elif CONFIG_BT_BAP_BROADCAST_48_4_2
62#define BT_BAP_LC3_BROADCAST_PRESET_NRF5340_AUDIO \
63 BT_BAP_LC3_BROADCAST_PRESET_48_4_2(BT_AUDIO_LOCATION_FRONT_LEFT | \
64 BT_AUDIO_LOCATION_FRONT_RIGHT, \
65 BT_AUDIO_CONTEXT_TYPE_MEDIA)
66
67#elif CONFIG_BT_BAP_BROADCAST_48_6_1
68#define BT_BAP_LC3_BROADCAST_PRESET_NRF5340_AUDIO \
69 BT_BAP_LC3_BROADCAST_PRESET_48_6_1(BT_AUDIO_LOCATION_FRONT_LEFT | \
70 BT_AUDIO_LOCATION_FRONT_RIGHT, \
71 BT_AUDIO_CONTEXT_TYPE_MEDIA)
72
73#elif CONFIG_BT_BAP_BROADCAST_48_6_2
74#define BT_BAP_LC3_BROADCAST_PRESET_NRF5340_AUDIO \
75 BT_BAP_LC3_BROADCAST_PRESET_48_6_2(BT_AUDIO_LOCATION_FRONT_LEFT | \
76 BT_AUDIO_LOCATION_FRONT_RIGHT, \
77 BT_AUDIO_CONTEXT_TYPE_MEDIA)
78#else
79#error Unsupported LC3 codec preset for broadcast
80#endif /* CONFIG_BT_AUDIO_BROADCAST_CONFIGURABLE */
81
82/* Size of the Public Broadcast Announcement header, 2-octet Service UUID followed by
83 * an octet for the features and an octet for the length of the meta data field.
84 */
85#define BROADCAST_SOURCE_PBA_HEADER_SIZE (BT_UUID_SIZE_16 + (sizeof(uint8_t) * 2))
86
87#define BROADCAST_SOURCE_ADV_NAME_MAX (32)
88#define BROADCAST_SOURCE_ADV_ID_START (BT_UUID_SIZE_16)
89
91 enum bt_audio_location *location;
92 uint8_t num_bises;
93 enum bt_audio_context context;
94 struct bt_bap_lc3_preset group_lc3_preset;
96};
97
101 uint8_t packing;
103 uint8_t broadcast_code[BT_AUDIO_BROADCAST_CODE_SIZE + 1];
105 char adv_name[CONFIG_BT_DEVICE_NAME_MAX + 1];
107 uint32_t broadcast_id;
108};
109
114 /* Broadcast Audio Streaming UUIDs. */
115 struct net_buf_simple *uuid_buf;
116
117 /* Broadcast Audio Streaming Endpoint advertising data. */
118 uint8_t brdcst_id_buf[BT_UUID_SIZE_16 + BT_AUDIO_BROADCAST_ID_SIZE];
119
120 /* Buffer for Appearance. */
121 uint8_t brdcst_appearance_buf[(sizeof(uint8_t) * 2)];
122
123 /* Broadcast name, must be between 4 and 32 UTF-8 encoded characters in length. */
125
126#if (CONFIG_AURACAST)
127 /* Number of free metadata items */
128 uint8_t pba_metadata_vacant_cnt;
129
130 /* Public Broadcast Announcement buffer. */
131 uint8_t *pba_buf;
132#endif /* (CONFIG_AURACAST) */
133};
134
139 /* Buffer for periodic advertising data */
140 struct net_buf_simple *base_buf;
141};
142
158int broadcast_source_ext_adv_populate(uint8_t big_index, bool fixed_id, uint32_t broadcast_id,
159 struct broadcast_source_ext_adv_data *ext_adv_data,
160 struct bt_data *ext_adv_buf, size_t ext_adv_buf_vacant);
161
174 struct broadcast_source_per_adv_data *per_adv_data,
175 struct bt_data *per_adv_buf, size_t per_adv_buf_vacant);
176
186bool broadcast_source_is_streaming(uint8_t big_index);
187
197int broadcast_source_start(uint8_t big_index, struct bt_le_ext_adv *ext_adv);
198
206int broadcast_source_stop(uint8_t big_index);
207
220int broadcast_source_id_get(uint8_t big_index, uint32_t *broadcast_id);
221
231int broadcast_source_send(uint8_t big_index, uint8_t subgroup_index,
232 struct le_audio_encoded_audio enc_audio);
233
241int broadcast_source_disable(uint8_t big_index);
242
253
263int broadcast_source_enable(struct broadcast_source_big const *const broadcast_param,
264 uint8_t big_index);
265
266#endif /* _BROADCAST_SOURCE_H_ */
int broadcast_source_enable(struct broadcast_source_big const *const broadcast_param, uint8_t big_index)
Enable the LE Audio broadcast (BIS) source.
int broadcast_source_per_adv_populate(uint8_t big_index, struct broadcast_source_per_adv_data *per_adv_data, struct bt_data *per_adv_buf, size_t per_adv_buf_vacant)
Populate the periodic advertising data buffer.
int broadcast_source_send(uint8_t big_index, uint8_t subgroup_index, struct le_audio_encoded_audio enc_audio)
Broadcast the Bluetooth LE Audio data.
int broadcast_source_id_get(uint8_t big_index, uint32_t *broadcast_id)
Get the broadcast ID for the given Broadcast Isochronous Group (BIG).
int broadcast_source_disable(uint8_t big_index)
Disable the LE Audio broadcast (BIS) source.
int broadcast_source_start(uint8_t big_index, struct bt_le_ext_adv *ext_adv)
Start the Bluetooth LE Audio broadcast (BIS) source.
bool broadcast_source_is_streaming(uint8_t big_index)
Check if the broadcast source is streaming.
#define BROADCAST_SOURCE_ADV_NAME_MAX
Definition: broadcast_source.h:87
int broadcast_source_ext_adv_populate(uint8_t big_index, bool fixed_id, uint32_t broadcast_id, struct broadcast_source_ext_adv_data *ext_adv_data, struct bt_data *ext_adv_buf, size_t ext_adv_buf_vacant)
Populate the extended advertising data buffer.
int broadcast_source_stop(uint8_t big_index)
Stop the Bluetooth LE Audio broadcast (BIS) source.
void broadcast_source_default_create(struct broadcast_source_big *broadcast_param)
Create a set up for a default broadcaster.
uint8_t packing
Definition: broadcast_source.h:101
bool fixed_id
Definition: broadcast_source.h:106
char broadcast_name[(32)+1]
Definition: broadcast_source.h:104
uint8_t broadcast_code[BT_AUDIO_BROADCAST_CODE_SIZE+1]
Definition: broadcast_source.h:103
bool encryption
Definition: broadcast_source.h:102
uint8_t num_subgroups
Definition: broadcast_source.h:100
uint32_t broadcast_id
Definition: broadcast_source.h:107
struct subgroup_config * subgroups
Definition: broadcast_source.h:99
char adv_name[CONFIG_BT_DEVICE_NAME_MAX+1]
Definition: broadcast_source.h:105
Definition: broadcast_source.h:98
uint8_t brdcst_appearance_buf[(sizeof(uint8_t) *2)]
Definition: broadcast_source.h:121
uint8_t brdcst_name_buf[(32)]
Definition: broadcast_source.h:124
uint8_t brdcst_id_buf[BT_UUID_SIZE_16+BT_AUDIO_BROADCAST_ID_SIZE]
Definition: broadcast_source.h:118
struct net_buf_simple * uuid_buf
Definition: broadcast_source.h:115
Advertising data for broadcast source.
Definition: broadcast_source.h:113
struct net_buf_simple * base_buf
Definition: broadcast_source.h:140
Periodic advertising data for broadcast source.
Definition: broadcast_source.h:138
Encoded audio data and information.
Definition: le_audio.h:63
enum bt_audio_context context
Definition: broadcast_source.h:93
enum bt_audio_location * location
Definition: broadcast_source.h:91
uint8_t num_bises
Definition: broadcast_source.h:92
struct bt_bap_lc3_preset group_lc3_preset
Definition: broadcast_source.h:94
char * preset_name
Definition: broadcast_source.h:95
Definition: broadcast_source.h:90