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

Commit 2f3fa9ec authored by Jakub Tyszkowski's avatar Jakub Tyszkowski Committed by Łukasz Rymanowski
Browse files

LeAudio: Improve printing data types

This adds the missing operators and improves the existing ones
to pretty-print the configurations for debugging purpose.

Additionaly these string stream operator are mandatary for the upcoming
unit tests as the testing frameworks requires them to report the results.

Bug: 340400084
Test: atest --host bluetooth_le_audio_test bluetooth_le_audio_client_test bluetooth_test_broadcaster bluetooth_test_broadcaster_state_machine --verbose
Flag: EXEMPT; No functional change
Change-Id: I333af0edf6201fc9c6982b4239c97482002b5fb9
parent e72495de
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -295,8 +295,11 @@ cc_test {
        "le_audio_software_unittest.cc",
    ],
    static_libs: [
        "libbt-bta",
        "libbt-platform-protos-lite",
        "libgmock",
    ],
    header_libs: ["libbluetooth_headers"],
    cflags: [
        "-DBUILDCFG",
    ],
+18 −4
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@

#include "broadcaster_types.h"

#include <base/strings/string_number_conversions.h>

#include <vector>

#include "bta/le_audio/audio_hal_client/audio_hal_client.h"
@@ -258,10 +260,13 @@ std::ostream& operator<<(
     << +config.GetLeAudioCodecId().vendor_company_id << ":"
     << +config.GetLeAudioCodecId().vendor_codec_id << "}, ";
  os << "BISes=[";
  if (!config.bis_codec_configs_.empty()) {
    for (auto const& bis_config : config.bis_codec_configs_) {
      os << bis_config << ", ";
    }
  os << "\r\r]";
    os << "\b\b";
  }
  os << "]";
  os << ", BitsPerSample=" << +config.GetBitsPerSample() << "}";
  os << "}";
  return os;
@@ -272,7 +277,16 @@ std::ostream& operator<<(
    const le_audio::broadcaster::BroadcastSubgroupBisCodecConfig& config) {
  os << "BisCfg={numBis=" << +config.GetNumBis()
     << ", NumChannelsPerBis=" << +config.GetNumChannelsPerBis()
     << ", SamplingFreqHz=" << +config.GetSamplingFrequencyHz() << "}";
     << ", CodecSpecific=" << config.GetCodecSpecData().GetAsCoreCodecConfig();
  if (config.GetVendorCodecSpecific().has_value()) {
    os << ", VendorSpecific=[";
    if (!config.GetVendorCodecSpecific()->empty()) {
      os << base::HexEncode(config.GetVendorCodecSpecific()->data(),
                            config.GetVendorCodecSpecific()->size());
    }
    os << "]";
  }
  os << "}";
  return os;
}

+72 −15
Original line number Diff line number Diff line
@@ -150,6 +150,62 @@ uint8_t CodecConfigSetting::GetBitsPerSample() const {
      return 0;
  }
};

std::ostream& operator<<(std::ostream& os, const QosConfigSetting& config) {
  os << "QosConfigSetting{";
  os << "targetLatency: " << (int)config.target_latency;
  os << ", retransmissionNum: " << (int)config.retransmission_number;
  os << ", maxTransportLatency: " << (int)config.max_transport_latency;
  os << ", sduIntervalUs: " << (int)config.sduIntervalUs;
  os << ", maxSdu: " << (int)config.maxSdu;
  os << "}";
  return os;
}

std::ostream& operator<<(std::ostream& os, const AseConfiguration& config) {
  os << "AseConfiguration{";
  os << "dataPath: " << config.data_path_configuration;
  os << ", codec: " << config.codec;
  os << ", qos: " << config.qos;
  os << "}";
  return os;
}

std::ostream& operator<<(std::ostream& os,
                         const AudioSetConfiguration& config) {
  os << "AudioSetConfiguration{";
  os << "name: " << config.name;
  os << ", packing: " << (int)config.packing;
  os << ", sinkConfs: [";
  for (auto const& conf : config.confs.sink) {
    os << conf;
    os << ", ";
  }
  os << "], sourceConfs: [";
  for (auto const& conf : config.confs.source) {
    os << conf;
    os << ", ";
  }
  os << "]}";
  return os;
}

std::ostream& operator<<(std::ostream& os, const CodecConfigSetting& config) {
  os << "CodecConfigSetting{";
  os << ", id: " << config.id;
  os << ", codecSpecParams: " << config.params.GetAsCoreCodecConfig();
  os << ", bitsPerSample: " << (int)config.GetBitsPerSample();
  os << ", channelCountPerIsoStream: "
     << (int)config.GetChannelCountPerIsoStream();
  if (!config.vendor_params.empty()) {
    os << ", vendorParams: "
       << base::HexEncode(config.vendor_params.data(),
                          config.vendor_params.size());
  }
  os << "}";
  return os;
}

}  // namespace set_configurations

namespace types {
@@ -609,20 +665,21 @@ std::ostream& operator<<(std::ostream& os, const types::AseState& state) {
}

std::ostream& operator<<(std::ostream& os, const LeAudioCodecId& codec_id) {
  os << "LeAudioCodecId(CodingFormat=" << loghex(codec_id.coding_format)
     << ", CompanyId=" << loghex(codec_id.vendor_company_id)
     << ", CodecId=" << loghex(codec_id.vendor_codec_id) << ")";
  os << "LeAudioCodecId{CodingFormat: " << loghex(codec_id.coding_format)
     << ", CompanyId: " << loghex(codec_id.vendor_company_id)
     << ", CodecId: " << loghex(codec_id.vendor_codec_id) << "}";
  return os;
}

std::ostream& operator<<(std::ostream& os,
                         const types::LeAudioCoreCodecConfig& config) {
  os << " LeAudioCoreCodecConfig(SamplFreq="
  os << "LeAudioCoreCodecConfig{SamplFreq: "
     << loghex(*config.sampling_frequency)
     << ", FrameDur=" << loghex(*config.frame_duration)
     << ", OctetsPerFrame=" << int(*config.octets_per_codec_frame)
     << ", CodecFramesBlocksPerSDU=" << int(*config.codec_frames_blocks_per_sdu)
     << ", AudioChanLoc=" << loghex(*config.audio_channel_allocation) << ")";
     << ", FrameDur: " << loghex(*config.frame_duration)
     << ", OctetsPerFrame: " << int(*config.octets_per_codec_frame)
     << ", CodecFramesBlocksPerSDU: "
     << int(*config.codec_frames_blocks_per_sdu)
     << ", AudioChanLoc: " << loghex(*config.audio_channel_allocation) << "}";
  return os;
}

@@ -739,18 +796,18 @@ AudioLocations get_bidirectional(BidirectionalPair<AudioLocations> bidir) {

std::ostream& operator<<(
    std::ostream& os, const le_audio::types::IsoDataPathConfiguration& config) {
  os << "IsoDataPathCfg={codecId=" << config.codecId
     << ", isTransparent=" << config.isTransparent
     << ", controllerDelayUs=" << config.controllerDelayUs
     << ", configuration.size()=" << config.configuration.size() << "}";
  os << "IsoDataPathCfg{codecId: " << config.codecId
     << ", isTransparent: " << config.isTransparent
     << ", controllerDelayUs: " << config.controllerDelayUs
     << ", configuration.size: " << config.configuration.size() << "}";
  return os;
}

std::ostream& operator<<(std::ostream& os,
                         const le_audio::types::DataPathConfiguration& config) {
  os << "DataPathCfg={datapathId=" << +config.dataPathId
     << ", dataPathCfg.size()=" << +config.dataPathConfig.size()
     << ", isoDataPathCfg=" << config.isoDataPathConfig << "}";
  os << "DataPathCfg{datapathId: " << +config.dataPathId
     << ", dataPathCfg.size: " << +config.dataPathConfig.size()
     << ", isoDataPathCfg: " << config.isoDataPathConfig << "}";
  return os;
}

+8 −0
Original line number Diff line number Diff line
@@ -1158,6 +1158,8 @@ struct CodecConfigSetting {
   */
};

std::ostream& operator<<(std::ostream& os, const CodecConfigSetting& config);

struct QosConfigSetting {
  uint8_t target_latency;
  uint8_t retransmission_number;
@@ -1174,6 +1176,8 @@ struct QosConfigSetting {
  }
};

std::ostream& operator<<(std::ostream& os, const QosConfigSetting& config);

struct AseConfiguration {
  AseConfiguration(CodecConfigSetting codec,
                   QosConfigSetting qos = {.target_latency = 0,
@@ -1192,6 +1196,8 @@ struct AseConfiguration {
  }
};

std::ostream& operator<<(std::ostream& os, const AseConfiguration& config);

/* Defined audio scenarios */
struct AudioSetConfiguration {
  std::string name = "";
@@ -1208,6 +1214,8 @@ struct AudioSetConfiguration {
  }
};

std::ostream& operator<<(std::ostream& os, const AudioSetConfiguration& config);

using AudioSetConfigurations = std::vector<const AudioSetConfiguration*>;

const types::LeAudioCodecId LeAudioCodecIdLc3 = {