Skip to content

Commit

Permalink
host/audio: move old LE Audio files to new directory
Browse files Browse the repository at this point in the history
LE Audio lives now in nimble/host/audio.
  • Loading branch information
KKopyscinski committed Feb 29, 2024
1 parent ebe1e78 commit 32cb19b
Show file tree
Hide file tree
Showing 22 changed files with 307 additions and 331 deletions.
1 change: 1 addition & 0 deletions .github/test_build_apps_syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ syscfg.vals:
BLE_PERIODIC_ADV_SYNC_BIGINFO_REPORTS: 1
BLE_ISO: 1
BLE_ISO_TEST: 1
BLE_AUDIO: 1
BLE_ISO_BROADCAST_SOURCE: 1
BLE_HCI_VS: 1
BLE_POWER_CONTROL: 1
Expand Down
2 changes: 1 addition & 1 deletion apps/auracast/pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ pkg.deps:
- nimble/host/util
- nimble/host/services/gap
- nimble/host/store/config
- nimble/host/audio/services/auracast
- "@apache-mynewt-core/kernel/os"
- "@apache-mynewt-core/sys/console"
- "@apache-mynewt-core/sys/log"
- "@apache-mynewt-core/sys/stats"
- "@apache-mynewt-core/sys/sysinit"
- "@apache-mynewt-core/sys/id"
- "@apache-mynewt-nimble/nimble/host/services/auracast"
4 changes: 3 additions & 1 deletion apps/auracast/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,6 @@ syscfg.vals:
BLE_MAX_BIG: 1
BLE_MAX_BIS: 2

BLE_PHY_NRF52_HEADERMASK_WORKAROUND: 1
BLE_PHY_NRF52_HEADERMASK_WORKAROUND: 1

BLE_AUDIO: 1
3 changes: 3 additions & 0 deletions apps/btshell/pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,8 @@ pkg.deps:
- nimble/host/store/config
- nimble/host/util

pkg.deps.BLE_AUDIO:
- nimble/host/audio

pkg.deps.BTSHELL_ANS:
- nimble/host/services/ans
2 changes: 1 addition & 1 deletion apps/btshell/src/btshell.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "host/ble_gatt.h"
#include "host/ble_gap.h"
#if (MYNEWT_VAL(BLE_ISO_BROADCAST_SOURCE))
#include "host/ble_audio_broadcast_source.h"
#include "audio/ble_audio_bcst_source.h"
#endif

#ifdef __cplusplus
Expand Down
4 changes: 2 additions & 2 deletions apps/btshell/src/cmd_leaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
* under the License.
*/

#include "host/ble_audio_broadcast_source.h"
#include "cmd_leaudio.h"
#include "btshell.h"
#include "console/console.h"
#include "errno.h"

#if (MYNEWT_VAL(BLE_ISO_BROADCAST_SOURCE))
#if (MYNEWT_VAL(BLE_AUDIO))
#include "audio/ble_audio_bcst_source.h"
int
cmd_leaudio_base_add(int argc, char **argv)
{
Expand Down
6 changes: 4 additions & 2 deletions apps/btshell/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@
#include "host/ble_gatt.h"
#include "host/ble_store.h"
#include "host/ble_sm.h"
#include "host/ble_audio_common.h"
#include "host/ble_audio_broadcast_source.h"
#if MYNEWT_VAL(BLE_AUDIO)
#include "audio/ble_audio_bcst_source.h"
#include "audio/ble_audio.h"
#endif
#include "host/util/util.h"

/* Mandatory services. */
Expand Down
1 change: 1 addition & 0 deletions apps/leaudio_broadcaster/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ syscfg.vals:
MSYS_1_BLOCK_COUNT: 32

BLE_VERSION: 54
BLE_AUDIO: 1
BLE_ISO: 1
BLE_ISO_BROADCAST_SOURCE: 1
BLE_MAX_BIG: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,16 @@
* under the License.
*/

#ifndef H_BLE_AUDIO_COMMON_
#define H_BLE_AUDIO_COMMON_
#ifndef H_BLE_AUDIO_
#define H_BLE_AUDIO_

/**
* @file ble_audio_common.h
*
* @brief Bluetooth Low Energy Audio Common API
*
* @defgroup bt_le_audio_common Bluetooth LE Audio Common
* @ingroup bt_host
* @{
*/

#include "stdint.h"
#include "os/queue.h"
#include <stdint.h>
#include <sys/queue.h>

/**
* @cond
* Helper macros for BLE_AUDIO_BUILD_CODEC_CONFIG
* @{
* @private @{
*/
#define FIELD_LEN_2(_len, _type, _field) _len, _type, _field,
#define FIELD_LEN_5(_len, _type, _field) _len, _type, _field, \
Expand Down Expand Up @@ -276,6 +266,271 @@ struct ble_audio_codec_id {
uint16_t vendor_specific;
};

/** @brief Public Broadcast Announcement features bits */
enum ble_audio_pub_bcst_announcement_feat {
/** Broadcast Stream Encryption */
BLE_AUDIO_PUB_BCST_ANNOUNCEMENT_FEAT_ENCRYPTION = 1 << 0,

/** Standard Quality Public Broadcast Audio */
BLE_AUDIO_PUB_BCST_ANNOUNCEMENT_FEAT_SQ = 1 << 1,

/** High Quality Public Broadcast Audio */
BLE_AUDIO_PUB_BCST_ANNOUNCEMENT_FEAT_HQ = 1 << 2,
};

/** @brief Public Broadcast Announcement structure */
struct ble_audio_pub_bcst_announcement {
/** Public Broadcast Announcement features bitfield */
enum ble_audio_pub_bcst_announcement_feat features;

/** Metadata length */
uint8_t metadata_len;

/** Metadata */
const uint8_t *metadata;
};

struct ble_audio_bcst_name {
/** Broadcast Name length */
uint8_t name_len;

/** Broadcast Name */
const char *name;
};

/**
* @defgroup ble_audio_events Bluetooth Low Energy Audio Events
* @{
*/

/** BLE Audio event: Broadcast Announcement */
#define BLE_AUDIO_EVENT_BCST_ANNOUNCEMENT 0

/** @} */

/** @brief Broadcast Announcement */
struct ble_audio_event_bcst_announcement {
/** Extended advertising report */
const struct ble_gap_ext_disc_desc *ext_disc;

/** Broadcast ID */
uint32_t broadcast_id;

/** Additional service data included in Broadcast Audio Announcement */
const uint8_t *svc_data;

/** Additional service data length */
uint16_t svc_data_len;

/** Optional Public Broadcast Announcement data */
struct ble_audio_pub_bcst_announcement *pub_announcement_data;

/** Optional Broadcast Name */
struct ble_audio_bcst_name *name;
};

/**
* Represents a BLE Audio related event. When such an event occurs, the host
* notifies the application by passing an instance of this structure to an
* application-specified callback.
*/
struct ble_audio_event {
/**
* Indicates the type of BLE Audio event that occurred. This is one of the
* BLE_AUDIO_EVENT codes.
*/
uint8_t type;

/**
* A discriminated union containing additional details concerning the event.
* The 'type' field indicates which member of the union is valid.
*/
union {
/**
* @ref BLE_AUDIO_EVENT_BCST_ANNOUNCEMENT
*
* Represents a received Broadcast Announcement.
*/
struct ble_audio_event_bcst_announcement bcst_announcement;
};
};

/** Callback function type for handling BLE Audio events. */
typedef int ble_audio_event_fn(struct ble_audio_event *event, void *arg);

/**
* Event listener structure
*
* This should be used as an opaque structure and not modified manually.
*/
struct ble_audio_event_listener {
/** The function to call when a BLE Audio event occurs. */
ble_audio_event_fn *fn;

/** An optional argument to pass to the event handler function. */
void *arg;

/** Singly-linked list entry. */
SLIST_ENTRY(ble_audio_event_listener) next;
};

/**
* Registers listener for BLE Audio events
*
* On success listener structure will be initialized automatically and does not
* need to be initialized prior to calling this function. To change callback
* and/or argument unregister listener first and register it again.
*
* @param[in] listener Listener structure
* @param[in] event_mask Optional event mask
* @param[in] fn Callback function
* @param[in] arg Optional callback argument
*
* @return 0 on success
* BLE_HS_EINVAL if no callback is specified
* BLE_HS_EALREADY if listener is already registered
*/
int ble_audio_event_listener_register(struct ble_audio_event_listener *listener,
ble_audio_event_fn *fn, void *arg);

/**
* Unregisters listener for BLE Audio events
*
* @param[in] listener Listener structure
*
* @return 0 on success
* BLE_HS_ENOENT if listener was not registered
*/
int ble_audio_event_listener_unregister(struct ble_audio_event_listener *listener);

/**
* BASE iterator
*
* The iterator structure used by @ref ble_audio_base_subgroup_iter and
* @ble_audio_base_bis_iter functions to iterate the BASE Level 2 and 3 elements
* (Subgroups and BISes).
* This should be used as an opaque structure and not modified manually.
*
* Example:
* @code{.c}
* struct ble_audio_base_iter subgroup_iter;
* struct ble_audio_base_iter bis_iter;
* struct ble_audio_base_group group;
* struct ble_audio_base_subgroup subgroup;
* struct ble_audio_base_bis bis;
*
* rc = ble_audio_base_parse(data, data_size, &group, &subgroup_iter);
* if (rc == 0) {
* for (uint8_t i = 0; i < group->num_subgroups; i++) {
* rc = ble_audio_base_subgroup_iter(&subgroup_iter, &subgroup, &bis_iter);
* if (rc == 0) {
* for (uint8_t j = 0; j < subgroup->num_bis; j++) {
* rc = ble_audio_base_bis_iter(&bis_iter, &bis);
* if (rc == 0) {
* foo(&group, &subgroup, &bis);
* }
* }
* }
* }
* }
* @endcode
*/
struct ble_audio_base_iter {
/** Data pointer */
const uint8_t *data;

/** Base length */
uint8_t buf_len;

/** Original BASE pointer */
const uint8_t *buf;

/** Remaining number of elements */
uint8_t num_elements;
};

/** @brief Broadcast Audio Source Endpoint Group structure */
struct ble_audio_base_group {
/** Presentation Delay */
uint32_t presentation_delay;

/** Number of subgroups */
uint8_t num_subgroups;
};

/**
* Parse the BASE received from Basic Audio Announcement data.
*
* @param[in] data Pointer to the BASE data buffer to parse.
* @param[in] data_len Length of the BASE data buffer.
* @param[out] group Group object.
* @param[out] subgroup_iter Subgroup iterator object.
*
* @return 0 on success; nonzero on failure.
*/
int ble_audio_base_parse(const uint8_t *data, uint8_t data_len,
struct ble_audio_base_group *group,
struct ble_audio_base_iter *subgroup_iter);

/** @brief Broadcast Audio Source Endpoint Subgroup structure */
struct ble_audio_base_subgroup {
/** Codec information for the subgroup */
struct ble_audio_codec_id codec_id;

/** Length of the Codec Specific Configuration for the subgroup */
uint8_t codec_spec_config_len;

/** Codec Specific Configuration for the subgroup */
const uint8_t *codec_spec_config;

/** Length of the Metadata for the subgroup */
uint8_t metadata_len;

/** Series of LTV structures containing Metadata */
const uint8_t *metadata;

/** Number of BISes in the subgroup */
uint8_t num_bis;
};

/**
* @brief Basic Audio Announcement Subgroup information
*
* @param[in] subgroup_iter Subgroup iterator object.
* @param[out] subgroup Subgroup object.
* @param[out] bis_iter BIS iterator object.
*
* @return 0 on success;
* A non-zero value on failure.
*/
int ble_audio_base_subgroup_iter(struct ble_audio_base_iter *subgroup_iter,
struct ble_audio_base_subgroup *subgroup,
struct ble_audio_base_iter *bis_iter);

/** @brief Broadcast Audio Source Endpoint BIS structure */
struct ble_audio_base_bis {
/** BIS_index value for the BIS */
uint8_t index;

/** Length of the Codec Specific Configuration for the BIS */
uint8_t codec_spec_config_len;

/** Codec Specific Configuration for the BIS */
const uint8_t *codec_spec_config;
};

/**
* @brief Basic Audio Announcement Subgroup information
*
* @param[in] bis_iter BIS iterator object.
* @param[out] bis BIS object.
*
* @return 0 on success;
* A non-zero value on failure.
*/
int ble_audio_base_bis_iter(struct ble_audio_base_iter *bis_iter,
struct ble_audio_base_bis *bis);

/** Broadcast Isochronous Streams (BIS) */
struct ble_audio_bis {
/** Pointer to next BIS in subgroup */
Expand Down Expand Up @@ -333,8 +588,4 @@ struct ble_audio_base {
STAILQ_HEAD(, ble_audio_big_subgroup) subs;
};

/**
* @}
*/

#endif /* H_BLE_AUDIO_COMMON_ */
#endif /* H_BLE_AUDIO_ */
Loading

0 comments on commit 32cb19b

Please sign in to comment.