-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nimble/audio: Add initial audio broadcast sink implementation
This adds initial implementation of audio broadcast sink.
- Loading branch information
1 parent
8b7eda2
commit 048498a
Showing
9 changed files
with
934 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
195 changes: 195 additions & 0 deletions
195
nimble/host/audio/include/audio/ble_audio_broadcast_sink.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
#ifndef H_BLE_AUDIO_BROADCAST_SINK_ | ||
#define H_BLE_AUDIO_BROADCAST_SINK_ | ||
|
||
/** | ||
* @file ble_audio_broadcast_sink.h | ||
* | ||
* @brief Bluetooth Low Energy Audio Broadcast Sink API | ||
* | ||
* @defgroup ble_audio_broadcast_sink Bluetooth LE Audio Broadcast Sink | ||
* @ingroup bt_host | ||
* @{ | ||
*/ | ||
|
||
#include <stdint.h> | ||
#include "host/ble_gap.h" | ||
#include "host/ble_iso.h" | ||
#include "ble_audio.h" | ||
|
||
/** @brief Periodic Advertisement Sync parameters */ | ||
struct ble_audio_broadcast_sink_pa_sync_params { | ||
/** Advertiser Address for the Broadcast Source */ | ||
const ble_addr_t *adv_addr; | ||
|
||
/** Advertising Set ID */ | ||
uint8_t adv_sid; | ||
|
||
/** Periodic advertising interval in 1.25 ms units */ | ||
uint16_t pa_interval; | ||
|
||
/** Retry count. The parameter is used to calculate the Sync Timeout */ | ||
uint8_t retry_count; | ||
|
||
/** The maximum number of periodic advertising events that controller can | ||
* skip after a successful receive. | ||
*/ | ||
uint16_t skip; | ||
}; | ||
|
||
/** | ||
* @brief Synchronize to Periodic Advertisement | ||
* | ||
* Start receiving the BIGInfo and Broadcast Audio Source Endpoint (BASE) | ||
* reports. | ||
* | ||
* This function initiates Periodic Advertisement Synchronization Procedure. | ||
* The function requires extended scan to be enabled. | ||
* | ||
* @param[in] source_id Audio Broadcast Source ID. | ||
* @param[in] params Periodic Advertisement Sync parameters to use. | ||
* | ||
* @return 0 on success; | ||
* A non-zero value on failure. | ||
*/ | ||
int ble_audio_broadcast_sink_pa_sync( | ||
uint8_t source_id, | ||
const struct ble_audio_broadcast_sink_pa_sync_params *params); | ||
|
||
/** @brief Periodic Advertisement Sync Transfer parameters */ | ||
struct ble_audio_broadcast_sink_pa_sync_recv_params { | ||
/** Connection handle */ | ||
uint16_t conn_handle; | ||
|
||
/** Periodic advertising interval in 1.25 ms units */ | ||
uint16_t pa_interval; | ||
|
||
/** Retry count. The parameter is used to calculate the Sync Timeout */ | ||
uint8_t retry_count; | ||
|
||
/** The maximum number of periodic advertising events that controller can | ||
* skip after a successful receive. | ||
*/ | ||
uint16_t skip; | ||
}; | ||
|
||
/** | ||
* @brief Synchronize to Periodic Advertisement with PAST | ||
* | ||
* Start receiving the BIGInfo and Broadcast Audio Source Endpoint (BASE) | ||
* reports. | ||
* | ||
* This function initiates Periodic Advertisement Sync Transfer (PAST) procedure | ||
* to offload the scanning. | ||
* | ||
* @param[in] source_id Audio Broadcast Source ID. | ||
* @param[in] params Periodic Advertisement Sync parameters to use. | ||
* | ||
* @return 0 on success; | ||
* A non-zero value on failure. | ||
*/ | ||
int ble_audio_broadcast_sink_pa_sync_recv( | ||
uint8_t source_id, | ||
const struct ble_audio_broadcast_sink_pa_sync_recv_params *params); | ||
|
||
/** | ||
* @brief Terminate or cancel pending Periodic Advertisement Sync | ||
* | ||
* This function terminates active Periodic Advertisement Sync or cancels the | ||
* pending sync. | ||
* | ||
* @param[in] source_id Audio Broadcast Source ID. | ||
* | ||
* @return 0 on success; | ||
* A non-zero value on failure. | ||
*/ | ||
int ble_audio_broadcast_sink_pa_sync_term(uint8_t source_id); | ||
|
||
/** @brief BIS Sync parameters */ | ||
struct ble_audio_broadcast_sink_bis_sync_params { | ||
/** BIS index */ | ||
uint8_t bis_index; | ||
|
||
/** ISO data received callback */ | ||
ble_iso_event_fn *cb; | ||
|
||
/** Callback argument */ | ||
void *cb_arg; | ||
}; | ||
|
||
/** @brief Broadcast Sink Sync parameters */ | ||
struct ble_audio_broadcast_sink_sync_params { | ||
/** NULL-terminated broadcast code */ | ||
const char *broadcast_code; | ||
|
||
/** Number of BISes */ | ||
uint8_t num_bis; | ||
|
||
/** BIS Sync parameters */ | ||
struct ble_audio_broadcast_sink_bis_sync_params *params; | ||
}; | ||
|
||
/** | ||
* @brief Synchronize to Audio Broadcast | ||
* | ||
* This function is used to synchronize to Audio Broadcast to start | ||
* reception of audio data. | ||
* | ||
* @param[in] source_id Audio Broadcast Source ID. | ||
* @param[in] params Broadcast Sink Sync parameters to use. | ||
* | ||
* @return 0 on success; | ||
* BLE_HS_EINVAL if the parameters are invalid; | ||
* BLE_HS_ENOENT if missing PA synchronization; | ||
* BLE_HS_EAGAIN if PA Sync is in progress; | ||
* BLE_HS_EENCRYPT if Broadcast Code is missing; | ||
* BLE_HS_ENOMEM if memory capacity exceeded; | ||
* Other nonzero on error. | ||
*/ | ||
int ble_audio_broadcast_sink_sync( | ||
uint8_t source_id, | ||
const struct ble_audio_broadcast_sink_sync_params *params); | ||
|
||
/** | ||
* @brief Terminate or cancel pending Audio Broadcast synchronization | ||
* | ||
* This function terminates active Audio Broadcast sync or cancels the | ||
* pending sync. | ||
* | ||
* @param[in] source_id Audio Broadcast Source ID. | ||
* | ||
* @return 0 on success; | ||
* A non-zero value on failure. | ||
*/ | ||
int ble_audio_broadcast_sink_sync_term(uint8_t source_id); | ||
|
||
/** | ||
* @brief Initialize Broadcast Sink role | ||
* | ||
* This function is restricted to be called by sysinit. | ||
*/ | ||
int ble_audio_broadcast_sink_init(void); | ||
|
||
/** | ||
* @} | ||
*/ | ||
|
||
#endif /* H_BLE_AUDIO_BROADCAST_SINK_*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.