Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nimble/services: add PACS #1675

Merged
merged 1 commit into from
Mar 4, 2024
Merged

nimble/services: add PACS #1675

merged 1 commit into from
Mar 4, 2024

Conversation

KKopyscinski
Copy link
Contributor

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.

@KKopyscinski
Copy link
Contributor Author

@MariuszSkamra

@KKopyscinski KKopyscinski force-pushed the pacs branch 3 times, most recently from 524ff53 to 134b6cc Compare January 24, 2024 12:53
@KKopyscinski KKopyscinski marked this pull request as ready for review January 24, 2024 12:53
nimble/host/include/host/ble_audio_codec.h Outdated Show resolved Hide resolved
nimble/host/include/host/ble_audio_codec.h Outdated Show resolved Hide resolved
nimble/host/include/host/ble_audio_codec.h Outdated Show resolved Hide resolved
nimble/host/include/host/ble_audio_codec.h Outdated Show resolved Hide resolved
nimble/host/include/host/ble_audio_codec.h Outdated Show resolved Hide resolved
nimble/host/services/audio/pacs/src/ble_audio_svc_pacs.c Outdated Show resolved Hide resolved
nimble/host/services/audio/pacs/src/ble_audio_svc_pacs.c Outdated Show resolved Hide resolved
nimble/host/services/audio/pacs/src/ble_audio_svc_pacs.c Outdated Show resolved Hide resolved
nimble/host/services/audio/pacs/src/ble_audio_svc_pacs.c Outdated Show resolved Hide resolved
Comment on lines 31 to 89
int ble_svc_audio_pacs_set_sink_audio_loc(uint32_t audio_locations);
int ble_svc_audio_pacs_set_source_audio_loc(uint32_t audio_locations);
int ble_svc_audio_pacs_set_sup_contexts(uint16_t sink_contexts,
uint16_t source_contexts);
int ble_svc_audio_pacs_set_avail_contexts(uint16_t conn_handle,
uint16_t sink_contexts,
uint16_t source_contexts);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether is there a need to have those 4 functions instead of 1 e.g. ble_svc_audio_pacs_init. As those are basically used to initialize the characteristic values. What's your opinion on that?

struct ble_svc_audio_pacs_init_param {
    uint32_t audio_locations;
    uint16_t available_contexts;
    uint16_t supported_contexts;
};

struct ble_svc_audio_pacs_init(uint8_t flags, struct ble_svc_audio_pacs_init_param *param);

where flags are the ones from Codec API. Hmm, this makes me feel that those should not be flags, but rather type` with 2 possible values Sink and Source defined as enum probably so that we could reuse it in different services.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One problem I see is that available_contexts are per connection - so they cannot be set on service init, but after connection is established. So we have one exception. And because in previous comment you asked to disallow re-setting these values, because there is no notifications support for them (which I 100% agree with), we would have to split these into these that init on startup and available_contexts. On the other hand we here, as you notice, SRC/SNK pairs, and there will be more in other services. So I'm not sure if we can solve this cleanly with flags(types?) as we do in codecs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed this offline and I made it into single functions, as you suggested. There is also second function that sets available_contexts - this must be done after connection exists and we know conn_handle.

@KKopyscinski
Copy link
Contributor Author

Fixed ble_svc_audio_pacs_avail_contexts array, all array elements should have BLE_HS_CONN_HANDLE_NONE on init

@KKopyscinski
Copy link
Contributor Author

KKopyscinski commented Jan 29, 2024

TODO: add LC3 PACS package

edit: done

@KKopyscinski
Copy link
Contributor Author

@rymanluk Added LC3 PACS package, resolved some bugs and tested code. I'll add doxygen soon

@KKopyscinski KKopyscinski force-pushed the pacs branch 5 times, most recently from 9b269eb to 466134a Compare February 1, 2024 11:58
@KKopyscinski KKopyscinski force-pushed the pacs branch 3 times, most recently from e9cf703 to 3ea7781 Compare February 6, 2024 07:15
Copy link
Contributor

@rymanluk rymanluk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple comments

nimble/host/include/host/ble_audio_codec.h Outdated Show resolved Hide resolved
nimble/host/include/host/ble_audio_codec.h Outdated Show resolved Hide resolved
nimble/host/include/host/ble_audio_codec.h Outdated Show resolved Hide resolved
nimble/host/include/host/ble_audio_codec.h Outdated Show resolved Hide resolved
nimble/host/include/host/ble_audio_codec.h Outdated Show resolved Hide resolved
nimble/host/include/host/ble_audio_codec.h Outdated Show resolved Hide resolved
nimble/host/include/host/ble_audio_codec.h Outdated Show resolved Hide resolved
nimble/host/include/host/ble_audio_common.h Outdated Show resolved Hide resolved
nimble/host/include/host/ble_audio_common.h Outdated Show resolved Hide resolved
nimble/host/include/host/ble_audio_common.h Outdated Show resolved Hide resolved
@KKopyscinski
Copy link
Contributor Author

KKopyscinski commented Mar 1, 2024

This patch is blocked by #1714. I'll update this with working one once the other one is merged (There are issues with includes in current tree structure. They need to be fixed first, and this PR will use new directories)

Edit: rebased after refactor was merged

@KKopyscinski
Copy link
Contributor Author

@MariuszSkamra @rymanluk rebased onto master

Comment on lines 539 to 552
/** @brief Codec Registered */
struct ble_audio_event_codec_changed {
/** Change type */
enum {
CODEC_REGISTERED,
CODEC_UNREGISTERED,
} change;

/** Codec Record */
const struct ble_audio_codec_record *record;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this one. IMO it would be cleaner to split this into 2 events:
BLE_AUDIO_EVENT_CODEC_REGISTERED
BLE_AUDIO_EVENT_CODEC_UNREGISTERED

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll also give them different structs (ble_audio_event_codec_registered and ble_audio_event_codec_unregistered), maybe in the future it'll have something more than ble_audio_codec_record

Copy link
Contributor

@rymanluk rymanluk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - one comment from Mariusz left and we should be good to merge

- nimble/host

pkg.init:
# ble_svc_audio_pacs_lc3_init: 'MYNEWT_VAL(BLE_SVC_AUDIO_PACS_LC3_SYSINIT_STAGE)'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

BLE_AUDIO_MAX_CODEC_RECORDS:
description: >
Maximum number of registered audio codecs.
value: 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it make sense to include audio package and have no audio codecs registered?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can have app withouth codecs registered - it's not mandatory to register codecs you will use. So you can for example include this package, create broadcast application (bare bones, just sending advertising chain and BISes), use some codec to encode audio and not register it. But you need to register so it'll be visible in PACS (and also include PACS itself).

I think I should add compiler guards so ble_audio_codec.c is compiled only when this is >0

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.
Copy link
Contributor

@rymanluk rymanluk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@MariuszSkamra MariuszSkamra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@KKopyscinski KKopyscinski merged commit e55baf9 into apache:master Mar 4, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants