Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit da9e4830 authored by Jakub Tyszkowski's avatar Jakub Tyszkowski
Browse files

LeAudio: Improve codec spec. capabilities type names

To make sure codec capabilities LTV types are not confused with configuration
LTV types the former one names are now matching the names from the
official BT assigned numbers specification.

Bug: 295972694
Test: atest --host bluetooth_le_audio_test bluetooth_le_audio_client_test bluetooth_test_broadcaster bluetooth_test_broadcaster_state_machine bluetooth_le_audio_codec_manager_test
Change-Id: I2c7a2738f66a625f7d133e24e73fe6d271dcf502
parent cdde1c97
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -657,7 +657,7 @@ uint8_t LeAudioDevice::GetLc3SupportedChannelCount(uint8_t direction) {
        continue;

      auto supported_channel_count_ltv = pac.codec_spec_caps.Find(
          codec_spec_caps::kLeAudioLtvTypeAudioChannelCounts);
          codec_spec_caps::kLeAudioLtvTypeSupportedAudioChannelCounts);

      if (supported_channel_count_ltv == std::nullopt ||
          supported_channel_count_ltv->size() == 0L) {
+10 −10
Original line number Diff line number Diff line
@@ -358,15 +358,15 @@ class PublishedAudioCapabilitiesBuilder {
    pac_records_.push_back(
        acs_ac_record({.codec_id = codec_id,
                       .codec_spec_caps = LeAudioLtvMap({
                           {kLeAudioLtvTypeSamplingFreq,
                           {kLeAudioLtvTypeSupportedSamplingFrequencies,
                            UINT16_TO_VEC_UINT8(sampling_frequencies)},
                           {kLeAudioLtvTypeFrameDuration,
                           {kLeAudioLtvTypeSupportedFrameDurations,
                            UINT8_TO_VEC_UINT8(frame_durations)},
                           {kLeAudioLtvTypeAudioChannelCounts,
                           {kLeAudioLtvTypeSupportedAudioChannelCounts,
                            UINT8_TO_VEC_UINT8(audio_channel_counts)},
                           {kLeAudioLtvTypeOctetsPerCodecFrame,
                           {kLeAudioLtvTypeSupportedOctetsPerCodecFrame,
                            UINT32_TO_VEC_UINT8(octets_per_frame_range)},
                           {kLeAudioLtvTypeMaxCodecFramesPerSdu,
                           {kLeAudioLtvTypeSupportedMaxCodecFramesPerSdu,
                            UINT8_TO_VEC_UINT8(max_codec_frames_per_sdu)},
                       }),
                       .metadata = std::vector<uint8_t>(0)}));
@@ -382,15 +382,15 @@ class PublishedAudioCapabilitiesBuilder {
    pac_records_.push_back(
        acs_ac_record({.codec_id = codec_id,
                       .codec_spec_caps = LeAudioLtvMap({
                           {kLeAudioLtvTypeSamplingFreq,
                           {kLeAudioLtvTypeSupportedSamplingFrequencies,
                            UINT16_TO_VEC_UINT8(capa_sampling_frequency)},
                           {kLeAudioLtvTypeFrameDuration,
                           {kLeAudioLtvTypeSupportedFrameDurations,
                            UINT8_TO_VEC_UINT8(capa_frame_duration)},
                           {kLeAudioLtvTypeAudioChannelCounts,
                           {kLeAudioLtvTypeSupportedAudioChannelCounts,
                            UINT8_TO_VEC_UINT8(audio_channel_counts)},
                           {kLeAudioLtvTypeOctetsPerCodecFrame,
                           {kLeAudioLtvTypeSupportedOctetsPerCodecFrame,
                            UINT32_TO_VEC_UINT8(octets_per_frame_range)},
                           {kLeAudioLtvTypeMaxCodecFramesPerSdu,
                           {kLeAudioLtvTypeSupportedMaxCodecFramesPerSdu,
                            UINT8_TO_VEC_UINT8(codec_frames_per_sdu)},
                       }),
                       .metadata = std::vector<uint8_t>(0)}));
+11 −10
Original line number Diff line number Diff line
@@ -255,7 +255,8 @@ static bool IsCodecConfigurationSupported(

  /* Sampling frequency */
  auto req = reqs.Find(codec_spec_conf::kLeAudioLtvTypeSamplingFreq);
  auto pac = pacs.Find(codec_spec_caps::kLeAudioLtvTypeSamplingFreq);
  auto pac =
      pacs.Find(codec_spec_caps::kLeAudioLtvTypeSupportedSamplingFrequencies);
  if (!req || !pac) {
    LOG_DEBUG(", lack of sampling frequency fields");
    return false;
@@ -289,7 +290,7 @@ static bool IsCodecConfigurationSupported(

  /* Frame duration */
  req = reqs.Find(codec_spec_conf::kLeAudioLtvTypeFrameDuration);
  pac = pacs.Find(codec_spec_caps::kLeAudioLtvTypeFrameDuration);
  pac = pacs.Find(codec_spec_caps::kLeAudioLtvTypeSupportedFrameDurations);
  if (!req || !pac) {
    LOG_DEBUG(", lack of frame duration fields");
    return false;
@@ -309,7 +310,7 @@ static bool IsCodecConfigurationSupported(
  }

  uint8_t required_audio_chan_num = lc3_config.GetChannelCount();
  pac = pacs.Find(codec_spec_caps::kLeAudioLtvTypeAudioChannelCounts);
  pac = pacs.Find(codec_spec_caps::kLeAudioLtvTypeSupportedAudioChannelCounts);

  /*
   * BAP_Validation_r07 1.9.2 Audio channel support requirements
@@ -336,7 +337,7 @@ static bool IsCodecConfigurationSupported(

  /* Octets per frame */
  req = reqs.Find(codec_spec_conf::kLeAudioLtvTypeOctetsPerCodecFrame);
  pac = pacs.Find(codec_spec_caps::kLeAudioLtvTypeOctetsPerCodecFrame);
  pac = pacs.Find(codec_spec_caps::kLeAudioLtvTypeSupportedOctetsPerCodecFrame);

  if (!req || !pac) {
    LOG_DEBUG(", lack of octet per frame fields");
@@ -457,15 +458,15 @@ const std::map<uint8_t, uint32_t> LeAudioCoreCodecConfig::frame_duration_map = {

std::string CapabilityTypeToStr(const uint8_t& type) {
  switch (type) {
    case codec_spec_caps::kLeAudioLtvTypeSamplingFreq:
    case codec_spec_caps::kLeAudioLtvTypeSupportedSamplingFrequencies:
      return "Supported Sampling Frequencies";
    case codec_spec_caps::kLeAudioLtvTypeFrameDuration:
    case codec_spec_caps::kLeAudioLtvTypeSupportedFrameDurations:
      return "Supported Frame Durations";
    case codec_spec_caps::kLeAudioLtvTypeAudioChannelCounts:
    case codec_spec_caps::kLeAudioLtvTypeSupportedAudioChannelCounts:
      return "Supported Audio Channel Count";
    case codec_spec_caps::kLeAudioLtvTypeOctetsPerCodecFrame:
    case codec_spec_caps::kLeAudioLtvTypeSupportedOctetsPerCodecFrame:
      return "Supported Octets Per Codec Frame";
    case codec_spec_caps::kLeAudioLtvTypeMaxCodecFramesPerSdu:
    case codec_spec_caps::kLeAudioLtvTypeSupportedMaxCodecFramesPerSdu:
      return "Supported Max Codec Frames Per SDU";
    default:
      return "Unknown";
@@ -767,7 +768,7 @@ void AppendMetadataLtvEntryForStreamingContext(

uint8_t GetMaxCodecFramesPerSduFromPac(const acs_ac_record* pac) {
  auto tlv_ent = pac->codec_spec_caps.Find(
      codec_spec_caps::kLeAudioLtvTypeMaxCodecFramesPerSdu);
      codec_spec_caps::kLeAudioLtvTypeSupportedMaxCodecFramesPerSdu);

  if (tlv_ent) return VEC_UINT8_TO_UINT8(tlv_ent.value());

+5 −5
Original line number Diff line number Diff line
@@ -211,15 +211,15 @@ inline uint8_t GetAudioChannelCounts(std::bitset<32> allocation) {
/* LTV Types - same values as in Codec Specific Configurations but 0x03 is
 * named differently.
 */
constexpr uint8_t kLeAudioLtvTypeSamplingFreq =
constexpr uint8_t kLeAudioLtvTypeSupportedSamplingFrequencies =
    codec_spec_conf::kLeAudioLtvTypeSamplingFreq;
constexpr uint8_t kLeAudioLtvTypeFrameDuration =
constexpr uint8_t kLeAudioLtvTypeSupportedFrameDurations =
    codec_spec_conf::kLeAudioLtvTypeFrameDuration;
constexpr uint8_t kLeAudioLtvTypeAudioChannelCounts =
constexpr uint8_t kLeAudioLtvTypeSupportedAudioChannelCounts =
    codec_spec_conf::kLeAudioLtvTypeAudioChannelAllocation;
constexpr uint8_t kLeAudioLtvTypeOctetsPerCodecFrame =
constexpr uint8_t kLeAudioLtvTypeSupportedOctetsPerCodecFrame =
    codec_spec_conf::kLeAudioLtvTypeOctetsPerCodecFrame;
constexpr uint8_t kLeAudioLtvTypeMaxCodecFramesPerSdu =
constexpr uint8_t kLeAudioLtvTypeSupportedMaxCodecFramesPerSdu =
    codec_spec_conf::kLeAudioLtvTypeCodecFrameBlocksPerSdu;

/* Sampling Frequencies */