-
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.
This commit adds Published Audio Capabilities Service/Prifile. In pair ble_audio_codec module is added, that supports registering supported codecs with their corresponding configurations.
- Loading branch information
1 parent
e5acfe0
commit daa4f27
Showing
20 changed files
with
1,268 additions
and
10 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/* | ||
* 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_CODEC_ | ||
#define H_BLE_AUDIO_CODEC_ | ||
|
||
#include "stdint.h" | ||
#include "ble_audio_common.h" | ||
|
||
#define BLE_AUDIO_CODEC_FLAG_SOURCE 0x01 | ||
#define BLE_AUDIO_CODEC_FLAG_SINK 0x02 | ||
|
||
/** Codec list entry */ | ||
struct ble_audio_codec_record { | ||
/* Pointer to next codec list entry */ | ||
STAILQ_ENTRY(ble_audio_codec_record) next; | ||
|
||
/* Codec ID */ | ||
struct ble_audio_codec_id codec_id; | ||
|
||
/* Length of Codec Specific Capabilities */ | ||
uint8_t codec_spec_caps_len; | ||
|
||
/* Codec Specific Capabilities data */ | ||
const uint8_t *codec_spec_caps; | ||
|
||
/* Metadata length */ | ||
uint8_t metadata_len; | ||
|
||
/* Metadata */ | ||
const uint8_t *metadata; | ||
|
||
/* Codec entry flags. It is any combination of following flags: | ||
* - BLE_AUDIO_CODEC_FLAG_SOURCE | ||
* - BLE_AUDIO_CODEC_FLAG_SINK | ||
*/ | ||
uint8_t flags; | ||
}; | ||
|
||
/** Type definition codec iteration callback function. */ | ||
typedef int ble_audio_codec_foreach_fn(const struct ble_audio_codec_record *record, void *arg); | ||
|
||
struct ble_audio_codec_register_params { | ||
/* Codec ID structure */ | ||
struct ble_audio_codec_id codec_id; | ||
|
||
/* Codec Specific Capabilities length */ | ||
uint8_t codec_spec_caps_len; | ||
|
||
/* Codec Specific Capabilities data */ | ||
uint8_t *codec_spec_caps; | ||
|
||
/* Metadata length */ | ||
uint8_t metadata_len; | ||
|
||
/* Metadata */ | ||
uint8_t *metadata; | ||
|
||
/* Codec entry flags. It is any combination of following flags: | ||
* - BLE_AUDIO_CODEC_FLAG_SOURCE | ||
* - BLE_AUDIO_CODEC_FLAG_SINK | ||
*/ | ||
uint8_t flags; | ||
}; | ||
|
||
/** | ||
* @brief Register codec entry | ||
* | ||
* @param[in] params Pointer to a `ble_audio_codec_register_params` | ||
* structure that defines Codec Specific Capabilities | ||
* @param[in] cb Function used to parse Codec | ||
* Specific Capabilities | ||
* @param[in] cb_arg Optional callback argument. | ||
* @param[out] out_record Pointer to registered codec entry. | ||
* | ||
* @return 0 on success; | ||
* A non-zero value on failure. | ||
*/ | ||
int ble_audio_codec_register(const struct ble_audio_codec_register_params | ||
*params, | ||
struct ble_audio_codec_record *out_record); | ||
/** | ||
* @brief Remove codec entry from register | ||
* | ||
* @param[in] codec_record Pointer to registered codec entry. | ||
* | ||
* @return 0 on success; | ||
* A non-zero value on failure. | ||
*/ | ||
int ble_audio_codec_unregister(struct ble_audio_codec_record *codec_record); | ||
|
||
/** | ||
* @brief Iterate through all registered codecs and call function on every | ||
* one of them. | ||
* | ||
* @param[in] cb Callback to be called on codec entries. | ||
* @param[in] arg Optional callback argument. | ||
* @param[in] flags Codec entry flags. It is any | ||
* combination of following flags: | ||
* - BLE_AUDIO_CODEC_FLAG_SOURCE | ||
* - BLE_AUDIO_CODEC_FLAG_SINK | ||
* This filters entries so the callback is called | ||
* only on these that match the flag. | ||
* | ||
* @return 0 on success; | ||
* A non-zero value on failure. | ||
*/ | ||
int ble_audio_codec_foreach(uint8_t flags, ble_audio_codec_foreach_fn *cb, void *arg); | ||
|
||
#endif /* H_BLE_AUDIO_CODEC_ */ |
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
42 changes: 42 additions & 0 deletions
42
nimble/host/services/audio/pacs/include/services/pacs/ble_audio_svc_pacs.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,42 @@ | ||
/* | ||
* 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_SVC_PACS_ | ||
#define H_BLE_AUDIO_SVC_PACS_ | ||
|
||
#define BLE_SVC_AUDIO_PACS_UUID16 0x1850 | ||
#define BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_PAC 0x2BC9 | ||
#define BLE_SVC_AUDIO_PACS_CHR_UUID16_SINK_AUDIO_LOCATIONS 0x2BCA | ||
#define BLE_SVC_AUDIO_PACS_CHR_UUID16_SOURCE_PAC 0x2BCB | ||
#define BLE_SVC_AUDIO_PACS_CHR_UUID16_SOURCE_AUDIO_LOCATIONS 0x2BCC | ||
#define BLE_SVC_AUDIO_PACS_CHR_UUID16_AVAILABLE_AUDIO_CONTEXTS 0x2BCD | ||
#define BLE_SVC_AUDIO_PACS_CHR_UUID16_SUPPORTED_AUDIO_CONTEXTS 0x2BCE | ||
|
||
struct ble_svc_audio_pacs_set_param { | ||
uint32_t audio_locations; | ||
uint16_t supported_contexts; | ||
}; | ||
|
||
int ble_svc_audio_pacs_set(uint8_t flags, struct ble_svc_audio_pacs_set_param *param); | ||
|
||
int ble_svc_audio_pacs_set_avail_contexts(uint16_t conn_handle, | ||
uint16_t sink_contexts, | ||
uint16_t source_contexts); | ||
|
||
#endif /* H_BLE_AUDIO_SVC_PACS_ */ |
27 changes: 27 additions & 0 deletions
27
nimble/host/services/audio/pacs/lc3/include/services/pacs/ble_audio_svc_pacs_lc3.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,27 @@ | ||
/* | ||
* 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_SVC_PACS_LC3_ | ||
#define H_BLE_AUDIO_SVC_PACS_LC3_ | ||
|
||
int ble_svc_audio_pacs_lc3_set_avail_contexts(uint16_t conn_handle, | ||
uint16_t sink_contexts, | ||
uint16_t source_contexts); | ||
|
||
#endif /* H_BLE_AUDIO_SVC_PACS_LC3_ */ |
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,33 @@ | ||
# 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. | ||
|
||
pkg.name: nimble/host/services/audio/pacs/lc3 | ||
pkg.description: LC3 codec entry for Published Audio Capabilities Service | ||
pkg.author: "Apache Mynewt <[email protected]>" | ||
pkg.homepage: "http://mynewt.apache.org/" | ||
pkg.keywords: | ||
- ble | ||
- bluetooth | ||
- pacs | ||
- nimble | ||
|
||
pkg.deps: | ||
- nimble/host/services/audio/pacs | ||
- nimble/host | ||
|
||
pkg.init: | ||
ble_svc_audio_pacs_lc3_init: 'MYNEWT_VAL(BLE_SVC_AUDIO_PACS_LC3_SYSINIT_STAGE)' |
Oops, something went wrong.