Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2022 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | #include <aidl/Gtest.h> |
| 17 | #include <aidl/Vintf.h> |
| 18 | #include <aidl/android/hardware/bluetooth/audio/BnBluetoothAudioPort.h> |
| 19 | #include <aidl/android/hardware/bluetooth/audio/IBluetoothAudioPort.h> |
| 20 | #include <aidl/android/hardware/bluetooth/audio/IBluetoothAudioProviderFactory.h> |
| 21 | #include <android/binder_auto_utils.h> |
| 22 | #include <android/binder_manager.h> |
| 23 | #include <android/binder_process.h> |
| 24 | #include <binder/IServiceManager.h> |
| 25 | #include <binder/ProcessState.h> |
| 26 | #include <fmq/AidlMessageQueue.h> |
| 27 | |
| 28 | #include <cstdint> |
| 29 | #include <future> |
| 30 | #include <unordered_set> |
| 31 | #include <vector> |
| 32 | |
| 33 | using aidl::android::hardware::audio::common::SinkMetadata; |
| 34 | using aidl::android::hardware::audio::common::SourceMetadata; |
| 35 | using aidl::android::hardware::bluetooth::audio::AacCapabilities; |
| 36 | using aidl::android::hardware::bluetooth::audio::AacConfiguration; |
| 37 | using aidl::android::hardware::bluetooth::audio::AptxCapabilities; |
| 38 | using aidl::android::hardware::bluetooth::audio::AptxConfiguration; |
| 39 | using aidl::android::hardware::bluetooth::audio::AudioCapabilities; |
| 40 | using aidl::android::hardware::bluetooth::audio::AudioConfiguration; |
| 41 | using aidl::android::hardware::bluetooth::audio::BnBluetoothAudioPort; |
Alice Kuo | 336d90c | 2022-02-16 09:09:59 +0800 | [diff] [blame] | 42 | using aidl::android::hardware::bluetooth::audio::BroadcastCapability; |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 43 | using aidl::android::hardware::bluetooth::audio::ChannelMode; |
| 44 | using aidl::android::hardware::bluetooth::audio::CodecCapabilities; |
| 45 | using aidl::android::hardware::bluetooth::audio::CodecConfiguration; |
| 46 | using aidl::android::hardware::bluetooth::audio::CodecType; |
| 47 | using aidl::android::hardware::bluetooth::audio::IBluetoothAudioPort; |
| 48 | using aidl::android::hardware::bluetooth::audio::IBluetoothAudioProvider; |
| 49 | using aidl::android::hardware::bluetooth::audio::IBluetoothAudioProviderFactory; |
| 50 | using aidl::android::hardware::bluetooth::audio::LatencyMode; |
| 51 | using aidl::android::hardware::bluetooth::audio::Lc3Capabilities; |
| 52 | using aidl::android::hardware::bluetooth::audio::Lc3Configuration; |
| 53 | using aidl::android::hardware::bluetooth::audio::LdacCapabilities; |
| 54 | using aidl::android::hardware::bluetooth::audio::LdacConfiguration; |
Alice Kuo | 336d90c | 2022-02-16 09:09:59 +0800 | [diff] [blame] | 55 | using aidl::android::hardware::bluetooth::audio::LeAudioBroadcastConfiguration; |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 56 | using aidl::android::hardware::bluetooth::audio:: |
| 57 | LeAudioCodecCapabilitiesSetting; |
| 58 | using aidl::android::hardware::bluetooth::audio::LeAudioCodecConfiguration; |
| 59 | using aidl::android::hardware::bluetooth::audio::LeAudioConfiguration; |
Omer Osman | a2587da | 2022-05-01 03:54:11 +0000 | [diff] [blame^] | 60 | using aidl::android::hardware::bluetooth::audio::OpusCapabilities; |
| 61 | using aidl::android::hardware::bluetooth::audio::OpusConfiguration; |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 62 | using aidl::android::hardware::bluetooth::audio::PcmConfiguration; |
| 63 | using aidl::android::hardware::bluetooth::audio::PresentationPosition; |
| 64 | using aidl::android::hardware::bluetooth::audio::SbcAllocMethod; |
| 65 | using aidl::android::hardware::bluetooth::audio::SbcCapabilities; |
| 66 | using aidl::android::hardware::bluetooth::audio::SbcChannelMode; |
| 67 | using aidl::android::hardware::bluetooth::audio::SbcConfiguration; |
| 68 | using aidl::android::hardware::bluetooth::audio::SessionType; |
| 69 | using aidl::android::hardware::bluetooth::audio::UnicastCapability; |
| 70 | using aidl::android::hardware::common::fmq::MQDescriptor; |
| 71 | using aidl::android::hardware::common::fmq::SynchronizedReadWrite; |
| 72 | using android::AidlMessageQueue; |
| 73 | using android::ProcessState; |
| 74 | using android::String16; |
| 75 | using ndk::ScopedAStatus; |
| 76 | using ndk::SpAIBinder; |
| 77 | |
| 78 | using MqDataType = int8_t; |
| 79 | using MqDataMode = SynchronizedReadWrite; |
| 80 | using DataMQ = AidlMessageQueue<MqDataType, MqDataMode>; |
| 81 | using DataMQDesc = MQDescriptor<MqDataType, MqDataMode>; |
| 82 | |
| 83 | // Constants |
| 84 | |
| 85 | static constexpr int32_t a2dp_sample_rates[] = {0, 44100, 48000, 88200, 96000}; |
| 86 | static constexpr int8_t a2dp_bits_per_samples[] = {0, 16, 24, 32}; |
| 87 | static constexpr ChannelMode a2dp_channel_modes[] = { |
| 88 | ChannelMode::UNKNOWN, ChannelMode::MONO, ChannelMode::STEREO}; |
| 89 | static constexpr CodecType a2dp_codec_types[] = { |
| 90 | CodecType::UNKNOWN, CodecType::SBC, CodecType::AAC, |
| 91 | CodecType::APTX, CodecType::APTX_HD, CodecType::LDAC, |
| 92 | CodecType::LC3, CodecType::APTX_ADAPTIVE}; |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 93 | static std::vector<LatencyMode> latency_modes = {LatencyMode::FREE}; |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 94 | // Helpers |
| 95 | |
| 96 | template <typename T> |
| 97 | struct identity { |
| 98 | typedef T type; |
| 99 | }; |
| 100 | |
| 101 | template <class T> |
| 102 | bool contained_in_vector(const std::vector<T>& vector, |
| 103 | const typename identity<T>::type& target) { |
| 104 | return std::find(vector.begin(), vector.end(), target) != vector.end(); |
| 105 | } |
| 106 | |
| 107 | void copy_codec_specific(CodecConfiguration::CodecSpecific& dst, |
| 108 | const CodecConfiguration::CodecSpecific& src) { |
| 109 | switch (src.getTag()) { |
| 110 | case CodecConfiguration::CodecSpecific::sbcConfig: |
| 111 | dst.set<CodecConfiguration::CodecSpecific::sbcConfig>( |
| 112 | src.get<CodecConfiguration::CodecSpecific::sbcConfig>()); |
| 113 | break; |
| 114 | case CodecConfiguration::CodecSpecific::aacConfig: |
| 115 | dst.set<CodecConfiguration::CodecSpecific::aacConfig>( |
| 116 | src.get<CodecConfiguration::CodecSpecific::aacConfig>()); |
| 117 | break; |
| 118 | case CodecConfiguration::CodecSpecific::ldacConfig: |
| 119 | dst.set<CodecConfiguration::CodecSpecific::ldacConfig>( |
| 120 | src.get<CodecConfiguration::CodecSpecific::ldacConfig>()); |
| 121 | break; |
| 122 | case CodecConfiguration::CodecSpecific::aptxConfig: |
| 123 | dst.set<CodecConfiguration::CodecSpecific::aptxConfig>( |
| 124 | src.get<CodecConfiguration::CodecSpecific::aptxConfig>()); |
| 125 | break; |
Omer Osman | a2587da | 2022-05-01 03:54:11 +0000 | [diff] [blame^] | 126 | case CodecConfiguration::CodecSpecific::opusConfig: |
| 127 | dst.set<CodecConfiguration::CodecSpecific::opusConfig>( |
| 128 | src.get<CodecConfiguration::CodecSpecific::opusConfig>()); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 129 | break; |
| 130 | case CodecConfiguration::CodecSpecific::aptxAdaptiveConfig: |
| 131 | dst.set<CodecConfiguration::CodecSpecific::aptxAdaptiveConfig>( |
| 132 | src.get<CodecConfiguration::CodecSpecific::aptxAdaptiveConfig>()); |
| 133 | break; |
| 134 | default: |
| 135 | break; |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | class BluetoothAudioPort : public BnBluetoothAudioPort { |
| 140 | public: |
| 141 | BluetoothAudioPort() {} |
| 142 | |
Chen Chen | 0a68a92 | 2022-02-15 18:43:26 -0800 | [diff] [blame] | 143 | ndk::ScopedAStatus startStream(bool) { return ScopedAStatus::ok(); } |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 144 | |
| 145 | ndk::ScopedAStatus suspendStream() { return ScopedAStatus::ok(); } |
| 146 | |
| 147 | ndk::ScopedAStatus stopStream() { return ScopedAStatus::ok(); } |
| 148 | |
| 149 | ndk::ScopedAStatus getPresentationPosition(PresentationPosition*) { |
| 150 | return ScopedAStatus::ok(); |
| 151 | } |
| 152 | |
| 153 | ndk::ScopedAStatus updateSourceMetadata(const SourceMetadata&) { |
| 154 | return ScopedAStatus::ok(); |
| 155 | } |
| 156 | |
| 157 | ndk::ScopedAStatus updateSinkMetadata(const SinkMetadata&) { |
| 158 | return ScopedAStatus::ok(); |
| 159 | } |
| 160 | |
| 161 | ndk::ScopedAStatus setLatencyMode(const LatencyMode) { |
| 162 | return ScopedAStatus::ok(); |
| 163 | } |
| 164 | |
| 165 | ndk::ScopedAStatus setCodecType(const CodecType) { |
| 166 | return ScopedAStatus::ok(); |
| 167 | } |
| 168 | |
| 169 | protected: |
| 170 | virtual ~BluetoothAudioPort() = default; |
| 171 | }; |
| 172 | |
| 173 | class BluetoothAudioProviderFactoryAidl |
| 174 | : public testing::TestWithParam<std::string> { |
| 175 | public: |
| 176 | virtual void SetUp() override { |
| 177 | provider_factory_ = IBluetoothAudioProviderFactory::fromBinder( |
| 178 | SpAIBinder(AServiceManager_getService(GetParam().c_str()))); |
| 179 | audio_provider_ = nullptr; |
| 180 | ASSERT_NE(provider_factory_, nullptr); |
| 181 | } |
| 182 | |
| 183 | virtual void TearDown() override { provider_factory_ = nullptr; } |
| 184 | |
| 185 | void GetProviderCapabilitiesHelper(const SessionType& session_type) { |
| 186 | temp_provider_capabilities_.clear(); |
| 187 | auto aidl_retval = provider_factory_->getProviderCapabilities( |
| 188 | session_type, &temp_provider_capabilities_); |
| 189 | // AIDL calls should not be failed and callback has to be executed |
| 190 | ASSERT_TRUE(aidl_retval.isOk()); |
| 191 | switch (session_type) { |
| 192 | case SessionType::UNKNOWN: { |
| 193 | ASSERT_TRUE(temp_provider_capabilities_.empty()); |
| 194 | } break; |
| 195 | case SessionType::A2DP_SOFTWARE_ENCODING_DATAPATH: |
| 196 | case SessionType::HEARING_AID_SOFTWARE_ENCODING_DATAPATH: |
| 197 | case SessionType::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH: |
| 198 | case SessionType::LE_AUDIO_SOFTWARE_DECODING_DATAPATH: |
| 199 | case SessionType::LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH: { |
| 200 | // All software paths are mandatory and must have exact 1 |
| 201 | // "PcmParameters" |
| 202 | ASSERT_EQ(temp_provider_capabilities_.size(), 1); |
| 203 | ASSERT_EQ(temp_provider_capabilities_[0].getTag(), |
| 204 | AudioCapabilities::pcmCapabilities); |
| 205 | } break; |
Alice Kuo | adcceec | 2022-03-28 13:28:43 +0800 | [diff] [blame] | 206 | case SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH: |
| 207 | case SessionType::A2DP_HARDWARE_OFFLOAD_DECODING_DATAPATH: { |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 208 | std::unordered_set<CodecType> codec_types; |
| 209 | // empty capability means offload is unsupported |
| 210 | for (auto& audio_capability : temp_provider_capabilities_) { |
| 211 | ASSERT_EQ(audio_capability.getTag(), |
| 212 | AudioCapabilities::a2dpCapabilities); |
| 213 | const auto& codec_capabilities = |
| 214 | audio_capability.get<AudioCapabilities::a2dpCapabilities>(); |
| 215 | // Every codec can present once at most |
| 216 | ASSERT_EQ(codec_types.count(codec_capabilities.codecType), 0); |
| 217 | switch (codec_capabilities.codecType) { |
| 218 | case CodecType::SBC: |
| 219 | ASSERT_EQ(codec_capabilities.capabilities.getTag(), |
| 220 | CodecCapabilities::Capabilities::sbcCapabilities); |
| 221 | break; |
| 222 | case CodecType::AAC: |
| 223 | ASSERT_EQ(codec_capabilities.capabilities.getTag(), |
| 224 | CodecCapabilities::Capabilities::aacCapabilities); |
| 225 | break; |
| 226 | case CodecType::APTX: |
| 227 | case CodecType::APTX_HD: |
| 228 | ASSERT_EQ(codec_capabilities.capabilities.getTag(), |
| 229 | CodecCapabilities::Capabilities::aptxCapabilities); |
| 230 | break; |
| 231 | case CodecType::LDAC: |
| 232 | ASSERT_EQ(codec_capabilities.capabilities.getTag(), |
| 233 | CodecCapabilities::Capabilities::ldacCapabilities); |
| 234 | break; |
Omer Osman | a2587da | 2022-05-01 03:54:11 +0000 | [diff] [blame^] | 235 | case CodecType::OPUS: |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 236 | ASSERT_EQ(codec_capabilities.capabilities.getTag(), |
Omer Osman | a2587da | 2022-05-01 03:54:11 +0000 | [diff] [blame^] | 237 | CodecCapabilities::Capabilities::opusCapabilities); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 238 | break; |
| 239 | case CodecType::APTX_ADAPTIVE: |
Omer Osman | a2587da | 2022-05-01 03:54:11 +0000 | [diff] [blame^] | 240 | case CodecType::LC3: |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 241 | case CodecType::VENDOR: |
| 242 | case CodecType::UNKNOWN: |
| 243 | break; |
| 244 | } |
| 245 | codec_types.insert(codec_capabilities.codecType); |
| 246 | } |
| 247 | } break; |
| 248 | case SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH: |
| 249 | case SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH: |
| 250 | case SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH: { |
| 251 | ASSERT_FALSE(temp_provider_capabilities_.empty()); |
| 252 | for (auto audio_capability : temp_provider_capabilities_) { |
| 253 | ASSERT_EQ(audio_capability.getTag(), |
| 254 | AudioCapabilities::leAudioCapabilities); |
| 255 | } |
| 256 | } break; |
Alice Kuo | adcceec | 2022-03-28 13:28:43 +0800 | [diff] [blame] | 257 | case SessionType::A2DP_SOFTWARE_DECODING_DATAPATH: { |
| 258 | if (!temp_provider_capabilities_.empty()) { |
| 259 | ASSERT_EQ(temp_provider_capabilities_.size(), 1); |
| 260 | ASSERT_EQ(temp_provider_capabilities_[0].getTag(), |
| 261 | AudioCapabilities::pcmCapabilities); |
| 262 | } |
| 263 | } break; |
| 264 | default: { |
| 265 | ASSERT_TRUE(temp_provider_capabilities_.empty()); |
| 266 | } |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 267 | } |
| 268 | } |
| 269 | |
| 270 | /*** |
| 271 | * This helps to open the specified provider and check the openProvider() |
| 272 | * has corruct return values. BUT, to keep it simple, it does not consider |
| 273 | * the capability, and please do so at the SetUp of each session's test. |
| 274 | ***/ |
| 275 | void OpenProviderHelper(const SessionType& session_type) { |
| 276 | auto aidl_retval = |
| 277 | provider_factory_->openProvider(session_type, &audio_provider_); |
| 278 | if (aidl_retval.isOk()) { |
| 279 | ASSERT_NE(session_type, SessionType::UNKNOWN); |
| 280 | ASSERT_NE(audio_provider_, nullptr); |
| 281 | audio_port_ = ndk::SharedRefBase::make<BluetoothAudioPort>(); |
| 282 | } else { |
Alice Kuo | adcceec | 2022-03-28 13:28:43 +0800 | [diff] [blame] | 283 | // optional session type |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 284 | ASSERT_TRUE( |
| 285 | session_type == SessionType::UNKNOWN || |
| 286 | session_type == |
| 287 | SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH || |
| 288 | session_type == |
| 289 | SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH || |
| 290 | session_type == |
| 291 | SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH || |
| 292 | session_type == |
| 293 | SessionType:: |
Alice Kuo | adcceec | 2022-03-28 13:28:43 +0800 | [diff] [blame] | 294 | LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH || |
| 295 | session_type == |
| 296 | SessionType::A2DP_HARDWARE_OFFLOAD_DECODING_DATAPATH || |
| 297 | session_type == SessionType::A2DP_SOFTWARE_DECODING_DATAPATH); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 298 | ASSERT_EQ(audio_provider_, nullptr); |
| 299 | } |
| 300 | } |
| 301 | |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 302 | void GetA2dpOffloadCapabilityHelper(const CodecType& codec_type) { |
| 303 | temp_codec_capabilities_ = nullptr; |
Josh Wu | 4d2938f | 2022-02-15 09:21:10 -0800 | [diff] [blame] | 304 | for (auto& codec_capability : temp_provider_capabilities_) { |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 305 | auto& a2dp_capabilities = |
| 306 | codec_capability.get<AudioCapabilities::a2dpCapabilities>(); |
| 307 | if (a2dp_capabilities.codecType != codec_type) { |
| 308 | continue; |
| 309 | } |
| 310 | temp_codec_capabilities_ = &a2dp_capabilities; |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | std::vector<CodecConfiguration::CodecSpecific> |
| 315 | GetSbcCodecSpecificSupportedList(bool supported) { |
| 316 | std::vector<CodecConfiguration::CodecSpecific> sbc_codec_specifics; |
| 317 | if (!supported) { |
| 318 | SbcConfiguration sbc_config{.sampleRateHz = 0, .bitsPerSample = 0}; |
| 319 | sbc_codec_specifics.push_back( |
| 320 | CodecConfiguration::CodecSpecific(sbc_config)); |
| 321 | return sbc_codec_specifics; |
| 322 | } |
| 323 | GetA2dpOffloadCapabilityHelper(CodecType::SBC); |
| 324 | if (temp_codec_capabilities_ == nullptr || |
| 325 | temp_codec_capabilities_->codecType != CodecType::SBC) { |
| 326 | return sbc_codec_specifics; |
| 327 | } |
| 328 | // parse the capability |
| 329 | auto& sbc_capability = |
| 330 | temp_codec_capabilities_->capabilities |
| 331 | .get<CodecCapabilities::Capabilities::sbcCapabilities>(); |
| 332 | if (sbc_capability.minBitpool > sbc_capability.maxBitpool) { |
| 333 | return sbc_codec_specifics; |
| 334 | } |
| 335 | |
| 336 | // combine those parameters into one list of |
| 337 | // CodecConfiguration::CodecSpecific |
| 338 | for (int32_t sample_rate : sbc_capability.sampleRateHz) { |
| 339 | for (int8_t block_length : sbc_capability.blockLength) { |
| 340 | for (int8_t num_subbands : sbc_capability.numSubbands) { |
| 341 | for (int8_t bits_per_sample : sbc_capability.bitsPerSample) { |
| 342 | for (auto channel_mode : sbc_capability.channelMode) { |
| 343 | for (auto alloc_method : sbc_capability.allocMethod) { |
| 344 | SbcConfiguration sbc_data = { |
| 345 | .sampleRateHz = sample_rate, |
| 346 | .channelMode = channel_mode, |
| 347 | .blockLength = block_length, |
| 348 | .numSubbands = num_subbands, |
| 349 | .allocMethod = alloc_method, |
| 350 | .bitsPerSample = bits_per_sample, |
| 351 | .minBitpool = sbc_capability.minBitpool, |
| 352 | .maxBitpool = sbc_capability.maxBitpool}; |
| 353 | sbc_codec_specifics.push_back( |
| 354 | CodecConfiguration::CodecSpecific(sbc_data)); |
| 355 | } |
| 356 | } |
| 357 | } |
| 358 | } |
| 359 | } |
| 360 | } |
| 361 | return sbc_codec_specifics; |
| 362 | } |
| 363 | |
| 364 | std::vector<CodecConfiguration::CodecSpecific> |
| 365 | GetAacCodecSpecificSupportedList(bool supported) { |
| 366 | std::vector<CodecConfiguration::CodecSpecific> aac_codec_specifics; |
| 367 | if (!supported) { |
| 368 | AacConfiguration aac_config{.sampleRateHz = 0, .bitsPerSample = 0}; |
| 369 | aac_codec_specifics.push_back( |
| 370 | CodecConfiguration::CodecSpecific(aac_config)); |
| 371 | return aac_codec_specifics; |
| 372 | } |
| 373 | GetA2dpOffloadCapabilityHelper(CodecType::AAC); |
| 374 | if (temp_codec_capabilities_ == nullptr || |
| 375 | temp_codec_capabilities_->codecType != CodecType::AAC) { |
| 376 | return aac_codec_specifics; |
| 377 | } |
| 378 | // parse the capability |
| 379 | auto& aac_capability = |
| 380 | temp_codec_capabilities_->capabilities |
| 381 | .get<CodecCapabilities::Capabilities::aacCapabilities>(); |
| 382 | |
| 383 | std::vector<bool> variable_bit_rate_enableds = {false}; |
| 384 | if (aac_capability.variableBitRateSupported) { |
| 385 | variable_bit_rate_enableds.push_back(true); |
| 386 | } |
| 387 | |
| 388 | // combine those parameters into one list of |
| 389 | // CodecConfiguration::CodecSpecific |
| 390 | for (auto object_type : aac_capability.objectType) { |
| 391 | for (int32_t sample_rate : aac_capability.sampleRateHz) { |
| 392 | for (auto channel_mode : aac_capability.channelMode) { |
| 393 | for (int8_t bits_per_sample : aac_capability.bitsPerSample) { |
| 394 | for (auto variable_bit_rate_enabled : variable_bit_rate_enableds) { |
| 395 | AacConfiguration aac_data{ |
| 396 | .objectType = object_type, |
| 397 | .sampleRateHz = sample_rate, |
| 398 | .channelMode = channel_mode, |
| 399 | .variableBitRateEnabled = variable_bit_rate_enabled, |
| 400 | .bitsPerSample = bits_per_sample}; |
| 401 | aac_codec_specifics.push_back( |
| 402 | CodecConfiguration::CodecSpecific(aac_data)); |
| 403 | } |
| 404 | } |
| 405 | } |
| 406 | } |
| 407 | } |
| 408 | return aac_codec_specifics; |
| 409 | } |
| 410 | |
| 411 | std::vector<CodecConfiguration::CodecSpecific> |
| 412 | GetLdacCodecSpecificSupportedList(bool supported) { |
| 413 | std::vector<CodecConfiguration::CodecSpecific> ldac_codec_specifics; |
| 414 | if (!supported) { |
| 415 | LdacConfiguration ldac_config{.sampleRateHz = 0, .bitsPerSample = 0}; |
| 416 | ldac_codec_specifics.push_back( |
| 417 | CodecConfiguration::CodecSpecific(ldac_config)); |
| 418 | return ldac_codec_specifics; |
| 419 | } |
| 420 | GetA2dpOffloadCapabilityHelper(CodecType::LDAC); |
| 421 | if (temp_codec_capabilities_ == nullptr || |
| 422 | temp_codec_capabilities_->codecType != CodecType::LDAC) { |
| 423 | return ldac_codec_specifics; |
| 424 | } |
| 425 | // parse the capability |
| 426 | auto& ldac_capability = |
| 427 | temp_codec_capabilities_->capabilities |
| 428 | .get<CodecCapabilities::Capabilities::ldacCapabilities>(); |
| 429 | |
| 430 | // combine those parameters into one list of |
| 431 | // CodecConfiguration::CodecSpecific |
| 432 | for (int32_t sample_rate : ldac_capability.sampleRateHz) { |
| 433 | for (int8_t bits_per_sample : ldac_capability.bitsPerSample) { |
| 434 | for (auto channel_mode : ldac_capability.channelMode) { |
| 435 | for (auto quality_index : ldac_capability.qualityIndex) { |
| 436 | LdacConfiguration ldac_data{.sampleRateHz = sample_rate, |
| 437 | .channelMode = channel_mode, |
| 438 | .qualityIndex = quality_index, |
| 439 | .bitsPerSample = bits_per_sample}; |
| 440 | ldac_codec_specifics.push_back( |
| 441 | CodecConfiguration::CodecSpecific(ldac_data)); |
| 442 | } |
| 443 | } |
| 444 | } |
| 445 | } |
| 446 | return ldac_codec_specifics; |
| 447 | } |
| 448 | |
| 449 | std::vector<CodecConfiguration::CodecSpecific> |
| 450 | GetAptxCodecSpecificSupportedList(bool is_hd, bool supported) { |
| 451 | std::vector<CodecConfiguration::CodecSpecific> aptx_codec_specifics; |
| 452 | if (!supported) { |
| 453 | AptxConfiguration aptx_config{.sampleRateHz = 0, .bitsPerSample = 0}; |
| 454 | aptx_codec_specifics.push_back( |
| 455 | CodecConfiguration::CodecSpecific(aptx_config)); |
| 456 | return aptx_codec_specifics; |
| 457 | } |
| 458 | GetA2dpOffloadCapabilityHelper( |
| 459 | (is_hd ? CodecType::APTX_HD : CodecType::APTX)); |
| 460 | if (temp_codec_capabilities_ == nullptr) { |
| 461 | return aptx_codec_specifics; |
| 462 | } |
| 463 | if ((is_hd && temp_codec_capabilities_->codecType != CodecType::APTX_HD) || |
| 464 | (!is_hd && temp_codec_capabilities_->codecType != CodecType::APTX)) { |
| 465 | return aptx_codec_specifics; |
| 466 | } |
| 467 | |
| 468 | // parse the capability |
| 469 | auto& aptx_capability = |
| 470 | temp_codec_capabilities_->capabilities |
| 471 | .get<CodecCapabilities::Capabilities::aptxCapabilities>(); |
| 472 | |
| 473 | // combine those parameters into one list of |
| 474 | // CodecConfiguration::CodecSpecific |
| 475 | for (int8_t bits_per_sample : aptx_capability.bitsPerSample) { |
| 476 | for (int32_t sample_rate : aptx_capability.sampleRateHz) { |
| 477 | for (auto channel_mode : aptx_capability.channelMode) { |
| 478 | AptxConfiguration aptx_data{.sampleRateHz = sample_rate, |
| 479 | .channelMode = channel_mode, |
| 480 | .bitsPerSample = bits_per_sample}; |
| 481 | aptx_codec_specifics.push_back( |
| 482 | CodecConfiguration::CodecSpecific(aptx_data)); |
| 483 | } |
| 484 | } |
| 485 | } |
| 486 | return aptx_codec_specifics; |
| 487 | } |
| 488 | |
| 489 | std::vector<CodecConfiguration::CodecSpecific> |
Omer Osman | a2587da | 2022-05-01 03:54:11 +0000 | [diff] [blame^] | 490 | GetOpusCodecSpecificSupportedList(bool supported) { |
| 491 | std::vector<CodecConfiguration::CodecSpecific> opus_codec_specifics; |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 492 | if (!supported) { |
Omer Osman | a2587da | 2022-05-01 03:54:11 +0000 | [diff] [blame^] | 493 | OpusConfiguration opus_config{.samplingFrequencyHz = 0, |
| 494 | .frameDurationUs = 0}; |
| 495 | opus_codec_specifics.push_back( |
| 496 | CodecConfiguration::CodecSpecific(opus_config)); |
| 497 | return opus_codec_specifics; |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 498 | } |
Omer Osman | a2587da | 2022-05-01 03:54:11 +0000 | [diff] [blame^] | 499 | GetA2dpOffloadCapabilityHelper(CodecType::OPUS); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 500 | if (temp_codec_capabilities_ == nullptr || |
Omer Osman | a2587da | 2022-05-01 03:54:11 +0000 | [diff] [blame^] | 501 | temp_codec_capabilities_->codecType != CodecType::OPUS) { |
| 502 | return opus_codec_specifics; |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 503 | } |
| 504 | // parse the capability |
Omer Osman | a2587da | 2022-05-01 03:54:11 +0000 | [diff] [blame^] | 505 | auto& opus_capability = |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 506 | temp_codec_capabilities_->capabilities |
Omer Osman | a2587da | 2022-05-01 03:54:11 +0000 | [diff] [blame^] | 507 | .get<CodecCapabilities::Capabilities::opusCapabilities>(); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 508 | |
| 509 | // combine those parameters into one list of |
| 510 | // CodecConfiguration::CodecSpecific |
Omer Osman | a2587da | 2022-05-01 03:54:11 +0000 | [diff] [blame^] | 511 | for (int32_t samplingFrequencyHz : opus_capability->samplingFrequencyHz) { |
| 512 | for (int32_t frameDurationUs : opus_capability->frameDurationUs) { |
| 513 | for (auto channel_mode : opus_capability->channelMode) { |
| 514 | OpusConfiguration opus_data{ |
| 515 | .samplingFrequencyHz = samplingFrequencyHz, |
| 516 | .channelMode = channel_mode, |
| 517 | .frameDurationUs = frameDurationUs}; |
| 518 | opus_codec_specifics.push_back( |
| 519 | CodecConfiguration::CodecSpecific(opus_data)); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 520 | } |
| 521 | } |
| 522 | } |
Omer Osman | a2587da | 2022-05-01 03:54:11 +0000 | [diff] [blame^] | 523 | return opus_codec_specifics; |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 524 | } |
| 525 | |
Alice Kuo | adcceec | 2022-03-28 13:28:43 +0800 | [diff] [blame] | 526 | bool IsPcmConfigSupported(const PcmConfiguration& pcm_config) { |
| 527 | if (temp_provider_capabilities_.size() != 1 || |
| 528 | temp_provider_capabilities_[0].getTag() != |
| 529 | AudioCapabilities::pcmCapabilities) { |
| 530 | return false; |
| 531 | } |
| 532 | auto pcm_capability = temp_provider_capabilities_[0] |
| 533 | .get<AudioCapabilities::pcmCapabilities>(); |
| 534 | return (contained_in_vector(pcm_capability.channelMode, |
| 535 | pcm_config.channelMode) && |
| 536 | contained_in_vector(pcm_capability.sampleRateHz, |
| 537 | pcm_config.sampleRateHz) && |
| 538 | contained_in_vector(pcm_capability.bitsPerSample, |
| 539 | pcm_config.bitsPerSample)); |
| 540 | } |
| 541 | |
| 542 | std::shared_ptr<IBluetoothAudioProviderFactory> provider_factory_; |
| 543 | std::shared_ptr<IBluetoothAudioProvider> audio_provider_; |
| 544 | std::shared_ptr<IBluetoothAudioPort> audio_port_; |
| 545 | std::vector<AudioCapabilities> temp_provider_capabilities_; |
| 546 | |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 547 | // temp storage saves the specified codec capability by |
| 548 | // GetOffloadCodecCapabilityHelper() |
| 549 | CodecCapabilities* temp_codec_capabilities_; |
Alice Kuo | adcceec | 2022-03-28 13:28:43 +0800 | [diff] [blame] | 550 | |
| 551 | static constexpr SessionType kSessionTypes[] = { |
| 552 | SessionType::UNKNOWN, |
| 553 | SessionType::A2DP_SOFTWARE_ENCODING_DATAPATH, |
| 554 | SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH, |
| 555 | SessionType::HEARING_AID_SOFTWARE_ENCODING_DATAPATH, |
| 556 | SessionType::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH, |
| 557 | SessionType::LE_AUDIO_SOFTWARE_DECODING_DATAPATH, |
| 558 | SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH, |
| 559 | SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH, |
| 560 | SessionType::LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH, |
| 561 | SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH, |
| 562 | SessionType::A2DP_SOFTWARE_DECODING_DATAPATH, |
| 563 | SessionType::A2DP_HARDWARE_OFFLOAD_DECODING_DATAPATH, |
| 564 | }; |
| 565 | }; |
| 566 | |
| 567 | /** |
| 568 | * Test whether we can get the FactoryService from HIDL |
| 569 | */ |
| 570 | TEST_P(BluetoothAudioProviderFactoryAidl, GetProviderFactoryService) {} |
| 571 | |
| 572 | /** |
| 573 | * Test whether we can open a provider for each provider returned by |
| 574 | * getProviderCapabilities() with non-empty capabalities |
| 575 | */ |
| 576 | TEST_P(BluetoothAudioProviderFactoryAidl, |
| 577 | OpenProviderAndCheckCapabilitiesBySession) { |
| 578 | for (auto session_type : kSessionTypes) { |
| 579 | GetProviderCapabilitiesHelper(session_type); |
| 580 | OpenProviderHelper(session_type); |
| 581 | // We must be able to open a provider if its getProviderCapabilities() |
| 582 | // returns non-empty list. |
| 583 | EXPECT_TRUE(temp_provider_capabilities_.empty() || |
| 584 | audio_provider_ != nullptr); |
| 585 | } |
| 586 | } |
| 587 | |
| 588 | /** |
| 589 | * openProvider A2DP_SOFTWARE_ENCODING_DATAPATH |
| 590 | */ |
| 591 | class BluetoothAudioProviderA2dpEncodingSoftwareAidl |
| 592 | : public BluetoothAudioProviderFactoryAidl { |
| 593 | public: |
| 594 | virtual void SetUp() override { |
| 595 | BluetoothAudioProviderFactoryAidl::SetUp(); |
| 596 | GetProviderCapabilitiesHelper(SessionType::A2DP_SOFTWARE_ENCODING_DATAPATH); |
| 597 | OpenProviderHelper(SessionType::A2DP_SOFTWARE_ENCODING_DATAPATH); |
| 598 | ASSERT_NE(audio_provider_, nullptr); |
| 599 | } |
| 600 | |
| 601 | virtual void TearDown() override { |
| 602 | audio_port_ = nullptr; |
| 603 | audio_provider_ = nullptr; |
| 604 | BluetoothAudioProviderFactoryAidl::TearDown(); |
| 605 | } |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 606 | }; |
| 607 | |
| 608 | /** |
| 609 | * Test whether we can open a provider of type |
| 610 | */ |
Alice Kuo | adcceec | 2022-03-28 13:28:43 +0800 | [diff] [blame] | 611 | TEST_P(BluetoothAudioProviderA2dpEncodingSoftwareAidl, |
| 612 | OpenA2dpEncodingSoftwareProvider) {} |
| 613 | |
| 614 | /** |
| 615 | * Test whether each provider of type |
| 616 | * SessionType::A2DP_SOFTWARE_ENCODING_DATAPATH can be started and stopped with |
| 617 | * different PCM config |
| 618 | */ |
| 619 | TEST_P(BluetoothAudioProviderA2dpEncodingSoftwareAidl, |
| 620 | StartAndEndA2dpEncodingSoftwareSessionWithPossiblePcmConfig) { |
| 621 | for (auto sample_rate : a2dp_sample_rates) { |
| 622 | for (auto bits_per_sample : a2dp_bits_per_samples) { |
| 623 | for (auto channel_mode : a2dp_channel_modes) { |
| 624 | PcmConfiguration pcm_config{ |
| 625 | .sampleRateHz = sample_rate, |
| 626 | .bitsPerSample = bits_per_sample, |
| 627 | .channelMode = channel_mode, |
| 628 | }; |
| 629 | bool is_codec_config_valid = IsPcmConfigSupported(pcm_config); |
| 630 | DataMQDesc mq_desc; |
| 631 | auto aidl_retval = audio_provider_->startSession( |
| 632 | audio_port_, AudioConfiguration(pcm_config), latency_modes, |
| 633 | &mq_desc); |
| 634 | DataMQ data_mq(mq_desc); |
| 635 | |
| 636 | EXPECT_EQ(aidl_retval.isOk(), is_codec_config_valid); |
| 637 | if (is_codec_config_valid) { |
| 638 | EXPECT_TRUE(data_mq.isValid()); |
| 639 | } |
| 640 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 641 | } |
| 642 | } |
| 643 | } |
| 644 | } |
| 645 | |
| 646 | /** |
| 647 | * openProvider A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH |
| 648 | */ |
| 649 | class BluetoothAudioProviderA2dpEncodingHardwareAidl |
| 650 | : public BluetoothAudioProviderFactoryAidl { |
| 651 | public: |
| 652 | virtual void SetUp() override { |
| 653 | BluetoothAudioProviderFactoryAidl::SetUp(); |
| 654 | GetProviderCapabilitiesHelper( |
| 655 | SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH); |
| 656 | OpenProviderHelper(SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH); |
| 657 | ASSERT_TRUE(temp_provider_capabilities_.empty() || |
| 658 | audio_provider_ != nullptr); |
| 659 | } |
| 660 | |
| 661 | virtual void TearDown() override { |
| 662 | audio_port_ = nullptr; |
| 663 | audio_provider_ = nullptr; |
| 664 | BluetoothAudioProviderFactoryAidl::TearDown(); |
| 665 | } |
| 666 | |
| 667 | bool IsOffloadSupported() { return (temp_provider_capabilities_.size() > 0); } |
| 668 | }; |
| 669 | |
| 670 | /** |
| 671 | * Test whether we can open a provider of type |
| 672 | */ |
| 673 | TEST_P(BluetoothAudioProviderA2dpEncodingHardwareAidl, |
| 674 | OpenA2dpEncodingHardwareProvider) {} |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 675 | |
| 676 | /** |
| 677 | * Test whether each provider of type |
| 678 | * SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with |
| 679 | * SBC hardware encoding config |
| 680 | */ |
Alice Kuo | adcceec | 2022-03-28 13:28:43 +0800 | [diff] [blame] | 681 | TEST_P(BluetoothAudioProviderA2dpEncodingHardwareAidl, |
| 682 | StartAndEndA2dpSbcEncodingHardwareSession) { |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 683 | if (!IsOffloadSupported()) { |
| 684 | return; |
| 685 | } |
| 686 | |
| 687 | CodecConfiguration codec_config = { |
| 688 | .codecType = CodecType::SBC, |
| 689 | .encodedAudioBitrate = 328000, |
| 690 | .peerMtu = 1005, |
| 691 | .isScmstEnabled = false, |
| 692 | }; |
| 693 | auto sbc_codec_specifics = GetSbcCodecSpecificSupportedList(true); |
| 694 | |
| 695 | for (auto& codec_specific : sbc_codec_specifics) { |
| 696 | copy_codec_specific(codec_config.config, codec_specific); |
| 697 | DataMQDesc mq_desc; |
| 698 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 699 | audio_port_, AudioConfiguration(codec_config), latency_modes, &mq_desc); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 700 | |
| 701 | ASSERT_TRUE(aidl_retval.isOk()); |
| 702 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 703 | } |
| 704 | } |
| 705 | |
| 706 | /** |
| 707 | * Test whether each provider of type |
| 708 | * SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with |
| 709 | * AAC hardware encoding config |
| 710 | */ |
Alice Kuo | adcceec | 2022-03-28 13:28:43 +0800 | [diff] [blame] | 711 | TEST_P(BluetoothAudioProviderA2dpEncodingHardwareAidl, |
| 712 | StartAndEndA2dpAacEncodingHardwareSession) { |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 713 | if (!IsOffloadSupported()) { |
| 714 | return; |
| 715 | } |
| 716 | |
| 717 | CodecConfiguration codec_config = { |
| 718 | .codecType = CodecType::AAC, |
| 719 | .encodedAudioBitrate = 320000, |
| 720 | .peerMtu = 1005, |
| 721 | .isScmstEnabled = false, |
| 722 | }; |
| 723 | auto aac_codec_specifics = GetAacCodecSpecificSupportedList(true); |
| 724 | |
| 725 | for (auto& codec_specific : aac_codec_specifics) { |
| 726 | copy_codec_specific(codec_config.config, codec_specific); |
| 727 | DataMQDesc mq_desc; |
| 728 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 729 | audio_port_, AudioConfiguration(codec_config), latency_modes, &mq_desc); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 730 | |
| 731 | ASSERT_TRUE(aidl_retval.isOk()); |
| 732 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 733 | } |
| 734 | } |
| 735 | |
| 736 | /** |
| 737 | * Test whether each provider of type |
| 738 | * SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with |
| 739 | * LDAC hardware encoding config |
| 740 | */ |
Alice Kuo | adcceec | 2022-03-28 13:28:43 +0800 | [diff] [blame] | 741 | TEST_P(BluetoothAudioProviderA2dpEncodingHardwareAidl, |
| 742 | StartAndEndA2dpLdacEncodingHardwareSession) { |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 743 | if (!IsOffloadSupported()) { |
| 744 | return; |
| 745 | } |
| 746 | |
| 747 | CodecConfiguration codec_config = { |
| 748 | .codecType = CodecType::LDAC, |
| 749 | .encodedAudioBitrate = 990000, |
| 750 | .peerMtu = 1005, |
| 751 | .isScmstEnabled = false, |
| 752 | }; |
| 753 | auto ldac_codec_specifics = GetLdacCodecSpecificSupportedList(true); |
| 754 | |
| 755 | for (auto& codec_specific : ldac_codec_specifics) { |
| 756 | copy_codec_specific(codec_config.config, codec_specific); |
| 757 | DataMQDesc mq_desc; |
| 758 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 759 | audio_port_, AudioConfiguration(codec_config), latency_modes, &mq_desc); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 760 | |
| 761 | ASSERT_TRUE(aidl_retval.isOk()); |
| 762 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 763 | } |
| 764 | } |
| 765 | |
| 766 | /** |
| 767 | * Test whether each provider of type |
| 768 | * SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with |
Omer Osman | a2587da | 2022-05-01 03:54:11 +0000 | [diff] [blame^] | 769 | * Opus hardware encoding config |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 770 | */ |
Alice Kuo | adcceec | 2022-03-28 13:28:43 +0800 | [diff] [blame] | 771 | TEST_P(BluetoothAudioProviderA2dpEncodingHardwareAidl, |
Omer Osman | a2587da | 2022-05-01 03:54:11 +0000 | [diff] [blame^] | 772 | StartAndEndA2dpOpusEncodingHardwareSession) { |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 773 | if (!IsOffloadSupported()) { |
| 774 | return; |
| 775 | } |
| 776 | |
| 777 | CodecConfiguration codec_config = { |
Omer Osman | a2587da | 2022-05-01 03:54:11 +0000 | [diff] [blame^] | 778 | .codecType = CodecType::OPUS, |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 779 | .encodedAudioBitrate = 990000, |
| 780 | .peerMtu = 1005, |
| 781 | .isScmstEnabled = false, |
| 782 | }; |
Omer Osman | a2587da | 2022-05-01 03:54:11 +0000 | [diff] [blame^] | 783 | auto opus_codec_specifics = GetOpusCodecSpecificSupportedList(true); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 784 | |
Omer Osman | a2587da | 2022-05-01 03:54:11 +0000 | [diff] [blame^] | 785 | for (auto& codec_specific : opus_codec_specifics) { |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 786 | copy_codec_specific(codec_config.config, codec_specific); |
| 787 | DataMQDesc mq_desc; |
| 788 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 789 | audio_port_, AudioConfiguration(codec_config), latency_modes, &mq_desc); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 790 | |
| 791 | ASSERT_TRUE(aidl_retval.isOk()); |
| 792 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 793 | } |
| 794 | } |
| 795 | |
| 796 | /** |
| 797 | * Test whether each provider of type |
| 798 | * SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with |
| 799 | * AptX hardware encoding config |
| 800 | */ |
Alice Kuo | adcceec | 2022-03-28 13:28:43 +0800 | [diff] [blame] | 801 | TEST_P(BluetoothAudioProviderA2dpEncodingHardwareAidl, |
| 802 | StartAndEndA2dpAptxEncodingHardwareSession) { |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 803 | if (!IsOffloadSupported()) { |
| 804 | return; |
| 805 | } |
| 806 | |
| 807 | for (auto codec_type : {CodecType::APTX, CodecType::APTX_HD}) { |
| 808 | CodecConfiguration codec_config = { |
| 809 | .codecType = codec_type, |
| 810 | .encodedAudioBitrate = |
| 811 | (codec_type == CodecType::APTX ? 352000 : 576000), |
| 812 | .peerMtu = 1005, |
| 813 | .isScmstEnabled = false, |
| 814 | }; |
| 815 | |
| 816 | auto aptx_codec_specifics = GetAptxCodecSpecificSupportedList( |
| 817 | (codec_type == CodecType::APTX_HD ? true : false), true); |
| 818 | |
| 819 | for (auto& codec_specific : aptx_codec_specifics) { |
| 820 | copy_codec_specific(codec_config.config, codec_specific); |
| 821 | DataMQDesc mq_desc; |
| 822 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 823 | audio_port_, AudioConfiguration(codec_config), latency_modes, |
| 824 | &mq_desc); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 825 | |
| 826 | ASSERT_TRUE(aidl_retval.isOk()); |
| 827 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 828 | } |
| 829 | } |
| 830 | } |
| 831 | |
| 832 | /** |
| 833 | * Test whether each provider of type |
| 834 | * SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with |
| 835 | * an invalid codec config |
| 836 | */ |
Alice Kuo | adcceec | 2022-03-28 13:28:43 +0800 | [diff] [blame] | 837 | TEST_P(BluetoothAudioProviderA2dpEncodingHardwareAidl, |
| 838 | StartAndEndA2dpEncodingHardwareSessionInvalidCodecConfig) { |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 839 | if (!IsOffloadSupported()) { |
| 840 | return; |
| 841 | } |
| 842 | ASSERT_NE(audio_provider_, nullptr); |
| 843 | |
| 844 | std::vector<CodecConfiguration::CodecSpecific> codec_specifics; |
| 845 | for (auto codec_type : a2dp_codec_types) { |
| 846 | switch (codec_type) { |
| 847 | case CodecType::SBC: |
| 848 | codec_specifics = GetSbcCodecSpecificSupportedList(false); |
| 849 | break; |
| 850 | case CodecType::AAC: |
| 851 | codec_specifics = GetAacCodecSpecificSupportedList(false); |
| 852 | break; |
| 853 | case CodecType::LDAC: |
| 854 | codec_specifics = GetLdacCodecSpecificSupportedList(false); |
| 855 | break; |
| 856 | case CodecType::APTX: |
| 857 | codec_specifics = GetAptxCodecSpecificSupportedList(false, false); |
| 858 | break; |
| 859 | case CodecType::APTX_HD: |
| 860 | codec_specifics = GetAptxCodecSpecificSupportedList(true, false); |
| 861 | break; |
Omer Osman | a2587da | 2022-05-01 03:54:11 +0000 | [diff] [blame^] | 862 | case CodecType::OPUS: |
| 863 | codec_specifics = GetOpusCodecSpecificSupportedList(false); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 864 | continue; |
| 865 | case CodecType::APTX_ADAPTIVE: |
Omer Osman | a2587da | 2022-05-01 03:54:11 +0000 | [diff] [blame^] | 866 | case CodecType::LC3: |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 867 | case CodecType::VENDOR: |
| 868 | case CodecType::UNKNOWN: |
| 869 | codec_specifics.clear(); |
| 870 | break; |
| 871 | } |
| 872 | if (codec_specifics.empty()) { |
| 873 | continue; |
| 874 | } |
| 875 | |
| 876 | CodecConfiguration codec_config = { |
| 877 | .codecType = codec_type, |
| 878 | .encodedAudioBitrate = 328000, |
| 879 | .peerMtu = 1005, |
| 880 | .isScmstEnabled = false, |
| 881 | }; |
| 882 | for (auto codec_specific : codec_specifics) { |
| 883 | copy_codec_specific(codec_config.config, codec_specific); |
| 884 | DataMQDesc mq_desc; |
| 885 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 886 | audio_port_, AudioConfiguration(codec_config), latency_modes, |
| 887 | &mq_desc); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 888 | |
| 889 | // AIDL call should fail on invalid codec |
| 890 | ASSERT_FALSE(aidl_retval.isOk()); |
| 891 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 892 | } |
| 893 | } |
| 894 | } |
| 895 | |
| 896 | /** |
| 897 | * openProvider HEARING_AID_SOFTWARE_ENCODING_DATAPATH |
| 898 | */ |
| 899 | class BluetoothAudioProviderHearingAidSoftwareAidl |
| 900 | : public BluetoothAudioProviderFactoryAidl { |
| 901 | public: |
| 902 | virtual void SetUp() override { |
| 903 | BluetoothAudioProviderFactoryAidl::SetUp(); |
| 904 | GetProviderCapabilitiesHelper( |
| 905 | SessionType::HEARING_AID_SOFTWARE_ENCODING_DATAPATH); |
| 906 | OpenProviderHelper(SessionType::HEARING_AID_SOFTWARE_ENCODING_DATAPATH); |
| 907 | ASSERT_NE(audio_provider_, nullptr); |
| 908 | } |
| 909 | |
| 910 | virtual void TearDown() override { |
| 911 | audio_port_ = nullptr; |
| 912 | audio_provider_ = nullptr; |
| 913 | BluetoothAudioProviderFactoryAidl::TearDown(); |
| 914 | } |
| 915 | |
| 916 | static constexpr int32_t hearing_aid_sample_rates_[] = {0, 16000, 24000}; |
| 917 | static constexpr int8_t hearing_aid_bits_per_samples_[] = {0, 16, 24}; |
| 918 | static constexpr ChannelMode hearing_aid_channel_modes_[] = { |
| 919 | ChannelMode::UNKNOWN, ChannelMode::MONO, ChannelMode::STEREO}; |
| 920 | }; |
| 921 | |
| 922 | /** |
| 923 | * Test whether we can open a provider of type |
| 924 | */ |
| 925 | TEST_P(BluetoothAudioProviderHearingAidSoftwareAidl, |
| 926 | OpenHearingAidSoftwareProvider) {} |
| 927 | |
| 928 | /** |
| 929 | * Test whether each provider of type |
| 930 | * SessionType::HEARING_AID_SOFTWARE_ENCODING_DATAPATH can be started and |
| 931 | * stopped with different PCM config |
| 932 | */ |
| 933 | TEST_P(BluetoothAudioProviderHearingAidSoftwareAidl, |
| 934 | StartAndEndHearingAidSessionWithPossiblePcmConfig) { |
| 935 | for (int32_t sample_rate : hearing_aid_sample_rates_) { |
| 936 | for (int8_t bits_per_sample : hearing_aid_bits_per_samples_) { |
| 937 | for (auto channel_mode : hearing_aid_channel_modes_) { |
| 938 | PcmConfiguration pcm_config{ |
| 939 | .sampleRateHz = sample_rate, |
| 940 | .bitsPerSample = bits_per_sample, |
| 941 | .channelMode = channel_mode, |
| 942 | }; |
| 943 | bool is_codec_config_valid = IsPcmConfigSupported(pcm_config); |
| 944 | DataMQDesc mq_desc; |
| 945 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 946 | audio_port_, AudioConfiguration(pcm_config), latency_modes, |
| 947 | &mq_desc); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 948 | DataMQ data_mq(mq_desc); |
| 949 | |
| 950 | EXPECT_EQ(aidl_retval.isOk(), is_codec_config_valid); |
| 951 | if (is_codec_config_valid) { |
| 952 | EXPECT_TRUE(data_mq.isValid()); |
| 953 | } |
| 954 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 955 | } |
| 956 | } |
| 957 | } |
| 958 | } |
| 959 | |
| 960 | /** |
| 961 | * openProvider LE_AUDIO_SOFTWARE_ENCODING_DATAPATH |
| 962 | */ |
| 963 | class BluetoothAudioProviderLeAudioOutputSoftwareAidl |
| 964 | : public BluetoothAudioProviderFactoryAidl { |
| 965 | public: |
| 966 | virtual void SetUp() override { |
| 967 | BluetoothAudioProviderFactoryAidl::SetUp(); |
| 968 | GetProviderCapabilitiesHelper( |
| 969 | SessionType::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH); |
| 970 | OpenProviderHelper(SessionType::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH); |
| 971 | ASSERT_NE(audio_provider_, nullptr); |
| 972 | } |
| 973 | |
| 974 | virtual void TearDown() override { |
| 975 | audio_port_ = nullptr; |
| 976 | audio_provider_ = nullptr; |
| 977 | BluetoothAudioProviderFactoryAidl::TearDown(); |
| 978 | } |
| 979 | |
| 980 | static constexpr int32_t le_audio_output_sample_rates_[] = { |
| 981 | 0, 8000, 16000, 24000, 32000, 44100, 48000, |
| 982 | }; |
| 983 | static constexpr int8_t le_audio_output_bits_per_samples_[] = {0, 16, 24}; |
| 984 | static constexpr ChannelMode le_audio_output_channel_modes_[] = { |
| 985 | ChannelMode::UNKNOWN, ChannelMode::MONO, ChannelMode::STEREO}; |
| 986 | static constexpr int32_t le_audio_output_data_interval_us_[] = { |
| 987 | 0 /* Invalid */, 10000 /* Valid 10ms */}; |
| 988 | }; |
| 989 | |
| 990 | /** |
| 991 | * Test whether each provider of type |
| 992 | * SessionType::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH can be started and |
| 993 | * stopped |
| 994 | */ |
| 995 | TEST_P(BluetoothAudioProviderLeAudioOutputSoftwareAidl, |
| 996 | OpenLeAudioOutputSoftwareProvider) {} |
| 997 | |
| 998 | /** |
| 999 | * Test whether each provider of type |
| 1000 | * SessionType::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH can be started and |
| 1001 | * stopped with different PCM config |
| 1002 | */ |
| 1003 | TEST_P(BluetoothAudioProviderLeAudioOutputSoftwareAidl, |
| 1004 | StartAndEndLeAudioOutputSessionWithPossiblePcmConfig) { |
| 1005 | for (auto sample_rate : le_audio_output_sample_rates_) { |
| 1006 | for (auto bits_per_sample : le_audio_output_bits_per_samples_) { |
| 1007 | for (auto channel_mode : le_audio_output_channel_modes_) { |
| 1008 | for (auto data_interval_us : le_audio_output_data_interval_us_) { |
| 1009 | PcmConfiguration pcm_config{ |
| 1010 | .sampleRateHz = sample_rate, |
| 1011 | .bitsPerSample = bits_per_sample, |
| 1012 | .channelMode = channel_mode, |
| 1013 | .dataIntervalUs = data_interval_us, |
| 1014 | }; |
Josh Wu | 8a1be76 | 2022-02-15 09:37:29 -0800 | [diff] [blame] | 1015 | bool is_codec_config_valid = |
| 1016 | IsPcmConfigSupported(pcm_config) && pcm_config.dataIntervalUs > 0; |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1017 | DataMQDesc mq_desc; |
| 1018 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 1019 | audio_port_, AudioConfiguration(pcm_config), latency_modes, |
| 1020 | &mq_desc); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1021 | DataMQ data_mq(mq_desc); |
| 1022 | |
| 1023 | EXPECT_EQ(aidl_retval.isOk(), is_codec_config_valid); |
| 1024 | if (is_codec_config_valid) { |
| 1025 | EXPECT_TRUE(data_mq.isValid()); |
| 1026 | } |
| 1027 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 1028 | } |
| 1029 | } |
| 1030 | } |
| 1031 | } |
| 1032 | } |
| 1033 | |
| 1034 | /** |
Alice Kuo | 04a399a | 2022-02-16 09:19:56 +0800 | [diff] [blame] | 1035 | * openProvider LE_AUDIO_SOFTWARE_DECODING_DATAPATH |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1036 | */ |
| 1037 | class BluetoothAudioProviderLeAudioInputSoftwareAidl |
| 1038 | : public BluetoothAudioProviderFactoryAidl { |
| 1039 | public: |
| 1040 | virtual void SetUp() override { |
| 1041 | BluetoothAudioProviderFactoryAidl::SetUp(); |
| 1042 | GetProviderCapabilitiesHelper( |
| 1043 | SessionType::LE_AUDIO_SOFTWARE_DECODING_DATAPATH); |
| 1044 | OpenProviderHelper(SessionType::LE_AUDIO_SOFTWARE_DECODING_DATAPATH); |
| 1045 | ASSERT_NE(audio_provider_, nullptr); |
| 1046 | } |
| 1047 | |
| 1048 | virtual void TearDown() override { |
| 1049 | audio_port_ = nullptr; |
| 1050 | audio_provider_ = nullptr; |
| 1051 | BluetoothAudioProviderFactoryAidl::TearDown(); |
| 1052 | } |
| 1053 | |
| 1054 | static constexpr int32_t le_audio_input_sample_rates_[] = { |
| 1055 | 0, 8000, 16000, 24000, 32000, 44100, 48000}; |
| 1056 | static constexpr int8_t le_audio_input_bits_per_samples_[] = {0, 16, 24}; |
| 1057 | static constexpr ChannelMode le_audio_input_channel_modes_[] = { |
| 1058 | ChannelMode::UNKNOWN, ChannelMode::MONO, ChannelMode::STEREO}; |
| 1059 | static constexpr int32_t le_audio_input_data_interval_us_[] = { |
| 1060 | 0 /* Invalid */, 10000 /* Valid 10ms */}; |
| 1061 | }; |
| 1062 | |
| 1063 | /** |
| 1064 | * Test whether each provider of type |
Alice Kuo | 04a399a | 2022-02-16 09:19:56 +0800 | [diff] [blame] | 1065 | * SessionType::LE_AUDIO_SOFTWARE_DECODING_DATAPATH can be started and |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1066 | * stopped |
| 1067 | */ |
| 1068 | TEST_P(BluetoothAudioProviderLeAudioInputSoftwareAidl, |
| 1069 | OpenLeAudioInputSoftwareProvider) {} |
| 1070 | |
| 1071 | /** |
| 1072 | * Test whether each provider of type |
Alice Kuo | 04a399a | 2022-02-16 09:19:56 +0800 | [diff] [blame] | 1073 | * SessionType::LE_AUDIO_SOFTWARE_DECODING_DATAPATH can be started and |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1074 | * stopped with different PCM config |
| 1075 | */ |
| 1076 | TEST_P(BluetoothAudioProviderLeAudioInputSoftwareAidl, |
| 1077 | StartAndEndLeAudioInputSessionWithPossiblePcmConfig) { |
| 1078 | for (auto sample_rate : le_audio_input_sample_rates_) { |
| 1079 | for (auto bits_per_sample : le_audio_input_bits_per_samples_) { |
| 1080 | for (auto channel_mode : le_audio_input_channel_modes_) { |
| 1081 | for (auto data_interval_us : le_audio_input_data_interval_us_) { |
| 1082 | PcmConfiguration pcm_config{ |
| 1083 | .sampleRateHz = sample_rate, |
| 1084 | .bitsPerSample = bits_per_sample, |
| 1085 | .channelMode = channel_mode, |
| 1086 | .dataIntervalUs = data_interval_us, |
| 1087 | }; |
Josh Wu | 8a1be76 | 2022-02-15 09:37:29 -0800 | [diff] [blame] | 1088 | bool is_codec_config_valid = |
| 1089 | IsPcmConfigSupported(pcm_config) && pcm_config.dataIntervalUs > 0; |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1090 | DataMQDesc mq_desc; |
| 1091 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 1092 | audio_port_, AudioConfiguration(pcm_config), latency_modes, |
| 1093 | &mq_desc); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1094 | DataMQ data_mq(mq_desc); |
| 1095 | |
| 1096 | EXPECT_EQ(aidl_retval.isOk(), is_codec_config_valid); |
| 1097 | if (is_codec_config_valid) { |
| 1098 | EXPECT_TRUE(data_mq.isValid()); |
| 1099 | } |
| 1100 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 1101 | } |
| 1102 | } |
| 1103 | } |
| 1104 | } |
| 1105 | } |
| 1106 | |
| 1107 | /** |
Alice Kuo | 04a399a | 2022-02-16 09:19:56 +0800 | [diff] [blame] | 1108 | * openProvider LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1109 | */ |
| 1110 | class BluetoothAudioProviderLeAudioOutputHardwareAidl |
| 1111 | : public BluetoothAudioProviderFactoryAidl { |
| 1112 | public: |
| 1113 | virtual void SetUp() override { |
| 1114 | BluetoothAudioProviderFactoryAidl::SetUp(); |
| 1115 | GetProviderCapabilitiesHelper( |
| 1116 | SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH); |
| 1117 | OpenProviderHelper( |
| 1118 | SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH); |
| 1119 | ASSERT_TRUE(temp_provider_capabilities_.empty() || |
| 1120 | audio_provider_ != nullptr); |
| 1121 | } |
| 1122 | |
| 1123 | virtual void TearDown() override { |
| 1124 | audio_port_ = nullptr; |
| 1125 | audio_provider_ = nullptr; |
| 1126 | BluetoothAudioProviderFactoryAidl::TearDown(); |
| 1127 | } |
| 1128 | |
| 1129 | bool IsOffloadOutputSupported() { |
| 1130 | for (auto& capability : temp_provider_capabilities_) { |
| 1131 | if (capability.getTag() != AudioCapabilities::leAudioCapabilities) { |
| 1132 | continue; |
| 1133 | } |
| 1134 | auto& le_audio_capability = |
| 1135 | capability.get<AudioCapabilities::leAudioCapabilities>(); |
| 1136 | if (le_audio_capability.unicastEncodeCapability.codecType != |
| 1137 | CodecType::UNKNOWN) |
| 1138 | return true; |
| 1139 | } |
| 1140 | return false; |
| 1141 | } |
| 1142 | |
| 1143 | std::vector<Lc3Configuration> GetUnicastLc3SupportedList(bool decoding, |
| 1144 | bool supported) { |
| 1145 | std::vector<Lc3Configuration> le_audio_codec_configs; |
| 1146 | if (!supported) { |
| 1147 | Lc3Configuration lc3_config{.samplingFrequencyHz = 0, .pcmBitDepth = 0}; |
| 1148 | le_audio_codec_configs.push_back(lc3_config); |
| 1149 | return le_audio_codec_configs; |
| 1150 | } |
| 1151 | |
| 1152 | // There might be more than one LeAudioCodecCapabilitiesSetting |
| 1153 | std::vector<Lc3Capabilities> lc3_capabilities; |
| 1154 | for (auto& capability : temp_provider_capabilities_) { |
| 1155 | if (capability.getTag() != AudioCapabilities::leAudioCapabilities) { |
| 1156 | continue; |
| 1157 | } |
| 1158 | auto& le_audio_capability = |
| 1159 | capability.get<AudioCapabilities::leAudioCapabilities>(); |
| 1160 | auto& unicast_capability = |
| 1161 | decoding ? le_audio_capability.unicastDecodeCapability |
| 1162 | : le_audio_capability.unicastEncodeCapability; |
| 1163 | if (unicast_capability.codecType != CodecType::LC3) { |
| 1164 | continue; |
| 1165 | } |
| 1166 | auto& lc3_capability = unicast_capability.leAudioCodecCapabilities.get< |
| 1167 | UnicastCapability::LeAudioCodecCapabilities::lc3Capabilities>(); |
| 1168 | lc3_capabilities.push_back(lc3_capability); |
| 1169 | } |
| 1170 | |
| 1171 | // Combine those parameters into one list of LeAudioCodecConfiguration |
| 1172 | // This seems horrible, but usually each Lc3Capability only contains a |
| 1173 | // single Lc3Configuration, which means every array has a length of 1. |
| 1174 | for (auto& lc3_capability : lc3_capabilities) { |
| 1175 | for (int32_t samplingFrequencyHz : lc3_capability.samplingFrequencyHz) { |
| 1176 | for (int32_t frameDurationUs : lc3_capability.frameDurationUs) { |
| 1177 | for (int32_t octetsPerFrame : lc3_capability.octetsPerFrame) { |
| 1178 | Lc3Configuration lc3_config = { |
| 1179 | .samplingFrequencyHz = samplingFrequencyHz, |
| 1180 | .frameDurationUs = frameDurationUs, |
| 1181 | .octetsPerFrame = octetsPerFrame, |
| 1182 | }; |
| 1183 | le_audio_codec_configs.push_back(lc3_config); |
| 1184 | } |
| 1185 | } |
| 1186 | } |
| 1187 | } |
| 1188 | |
| 1189 | return le_audio_codec_configs; |
| 1190 | } |
| 1191 | |
| 1192 | LeAudioCodecCapabilitiesSetting temp_le_audio_capabilities_; |
| 1193 | }; |
| 1194 | |
| 1195 | /** |
| 1196 | * Test whether each provider of type |
| 1197 | * SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH can be started and |
| 1198 | * stopped |
| 1199 | */ |
| 1200 | TEST_P(BluetoothAudioProviderLeAudioOutputHardwareAidl, |
| 1201 | OpenLeAudioOutputHardwareProvider) {} |
| 1202 | |
| 1203 | /** |
| 1204 | * Test whether each provider of type |
| 1205 | * SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH can be started and |
| 1206 | * stopped with Unicast hardware encoding config |
| 1207 | */ |
| 1208 | TEST_P(BluetoothAudioProviderLeAudioOutputHardwareAidl, |
| 1209 | StartAndEndLeAudioOutputSessionWithPossibleUnicastConfig) { |
| 1210 | if (!IsOffloadOutputSupported()) { |
| 1211 | return; |
| 1212 | } |
| 1213 | |
| 1214 | auto lc3_codec_configs = |
| 1215 | GetUnicastLc3SupportedList(false /* decoding */, true /* supported */); |
| 1216 | LeAudioConfiguration le_audio_config = { |
| 1217 | .codecType = CodecType::LC3, |
| 1218 | .peerDelayUs = 0, |
| 1219 | }; |
| 1220 | |
| 1221 | for (auto& lc3_config : lc3_codec_configs) { |
| 1222 | le_audio_config.leAudioCodecConfig |
| 1223 | .set<LeAudioCodecConfiguration::lc3Config>(lc3_config); |
| 1224 | DataMQDesc mq_desc; |
| 1225 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 1226 | audio_port_, AudioConfiguration(le_audio_config), latency_modes, |
| 1227 | &mq_desc); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1228 | |
| 1229 | ASSERT_TRUE(aidl_retval.isOk()); |
| 1230 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 1231 | } |
| 1232 | } |
| 1233 | |
| 1234 | /** |
| 1235 | * Test whether each provider of type |
| 1236 | * SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH can be started and |
| 1237 | * stopped with Unicast hardware encoding config |
| 1238 | * |
| 1239 | * Disabled since offload codec checking is not ready |
| 1240 | */ |
| 1241 | TEST_P(BluetoothAudioProviderLeAudioOutputHardwareAidl, |
| 1242 | DISABLED_StartAndEndLeAudioOutputSessionWithInvalidAudioConfiguration) { |
| 1243 | if (!IsOffloadOutputSupported()) { |
| 1244 | return; |
| 1245 | } |
| 1246 | |
| 1247 | auto lc3_codec_configs = |
| 1248 | GetUnicastLc3SupportedList(false /* decoding */, false /* supported */); |
| 1249 | LeAudioConfiguration le_audio_config = { |
| 1250 | .codecType = CodecType::LC3, |
| 1251 | .peerDelayUs = 0, |
| 1252 | }; |
| 1253 | |
| 1254 | for (auto& lc3_config : lc3_codec_configs) { |
| 1255 | le_audio_config.leAudioCodecConfig |
| 1256 | .set<LeAudioCodecConfiguration::lc3Config>(lc3_config); |
| 1257 | DataMQDesc mq_desc; |
| 1258 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 1259 | audio_port_, AudioConfiguration(le_audio_config), latency_modes, |
| 1260 | &mq_desc); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1261 | |
| 1262 | // AIDL call should fail on invalid codec |
| 1263 | ASSERT_FALSE(aidl_retval.isOk()); |
| 1264 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 1265 | } |
| 1266 | } |
| 1267 | |
| 1268 | /** |
| 1269 | * openProvider LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH |
| 1270 | */ |
| 1271 | class BluetoothAudioProviderLeAudioInputHardwareAidl |
| 1272 | : public BluetoothAudioProviderLeAudioOutputHardwareAidl { |
| 1273 | public: |
| 1274 | virtual void SetUp() override { |
| 1275 | BluetoothAudioProviderFactoryAidl::SetUp(); |
| 1276 | GetProviderCapabilitiesHelper( |
| 1277 | SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH); |
| 1278 | OpenProviderHelper( |
| 1279 | SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH); |
| 1280 | ASSERT_TRUE(temp_provider_capabilities_.empty() || |
| 1281 | audio_provider_ != nullptr); |
| 1282 | } |
| 1283 | |
| 1284 | bool IsOffloadInputSupported() { |
| 1285 | for (auto& capability : temp_provider_capabilities_) { |
| 1286 | if (capability.getTag() != AudioCapabilities::leAudioCapabilities) { |
| 1287 | continue; |
| 1288 | } |
| 1289 | auto& le_audio_capability = |
| 1290 | capability.get<AudioCapabilities::leAudioCapabilities>(); |
| 1291 | if (le_audio_capability.unicastDecodeCapability.codecType != |
| 1292 | CodecType::UNKNOWN) |
| 1293 | return true; |
| 1294 | } |
| 1295 | return false; |
| 1296 | } |
| 1297 | |
| 1298 | virtual void TearDown() override { |
| 1299 | audio_port_ = nullptr; |
| 1300 | audio_provider_ = nullptr; |
| 1301 | BluetoothAudioProviderFactoryAidl::TearDown(); |
| 1302 | } |
| 1303 | }; |
| 1304 | |
| 1305 | /** |
| 1306 | * Test whether each provider of type |
| 1307 | * SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH can be started and |
| 1308 | * stopped |
| 1309 | */ |
| 1310 | TEST_P(BluetoothAudioProviderLeAudioInputHardwareAidl, |
| 1311 | OpenLeAudioInputHardwareProvider) {} |
| 1312 | |
| 1313 | /** |
| 1314 | * Test whether each provider of type |
| 1315 | * SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH can be started and |
| 1316 | * stopped with Unicast hardware encoding config |
| 1317 | */ |
| 1318 | TEST_P(BluetoothAudioProviderLeAudioInputHardwareAidl, |
| 1319 | StartAndEndLeAudioInputSessionWithPossibleUnicastConfig) { |
| 1320 | if (!IsOffloadInputSupported()) { |
| 1321 | return; |
| 1322 | } |
| 1323 | |
| 1324 | auto lc3_codec_configs = |
| 1325 | GetUnicastLc3SupportedList(true /* decoding */, true /* supported */); |
| 1326 | LeAudioConfiguration le_audio_config = { |
| 1327 | .codecType = CodecType::LC3, |
| 1328 | .peerDelayUs = 0, |
| 1329 | }; |
| 1330 | |
| 1331 | for (auto& lc3_config : lc3_codec_configs) { |
| 1332 | le_audio_config.leAudioCodecConfig |
| 1333 | .set<LeAudioCodecConfiguration::lc3Config>(lc3_config); |
| 1334 | DataMQDesc mq_desc; |
| 1335 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 1336 | audio_port_, AudioConfiguration(le_audio_config), latency_modes, |
| 1337 | &mq_desc); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1338 | |
| 1339 | ASSERT_TRUE(aidl_retval.isOk()); |
| 1340 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 1341 | } |
| 1342 | } |
| 1343 | |
| 1344 | /** |
| 1345 | * Test whether each provider of type |
| 1346 | * SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH can be started and |
| 1347 | * stopped with Unicast hardware encoding config |
| 1348 | * |
| 1349 | * Disabled since offload codec checking is not ready |
| 1350 | */ |
| 1351 | TEST_P(BluetoothAudioProviderLeAudioInputHardwareAidl, |
| 1352 | DISABLED_StartAndEndLeAudioInputSessionWithInvalidAudioConfiguration) { |
| 1353 | if (!IsOffloadInputSupported()) { |
| 1354 | return; |
| 1355 | } |
| 1356 | |
| 1357 | auto lc3_codec_configs = |
| 1358 | GetUnicastLc3SupportedList(true /* decoding */, false /* supported */); |
| 1359 | LeAudioConfiguration le_audio_config = { |
| 1360 | .codecType = CodecType::LC3, |
| 1361 | .peerDelayUs = 0, |
| 1362 | }; |
| 1363 | |
| 1364 | for (auto& lc3_config : lc3_codec_configs) { |
| 1365 | le_audio_config.leAudioCodecConfig |
| 1366 | .set<LeAudioCodecConfiguration::lc3Config>(lc3_config); |
| 1367 | |
| 1368 | DataMQDesc mq_desc; |
| 1369 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 1370 | audio_port_, AudioConfiguration(le_audio_config), latency_modes, |
| 1371 | &mq_desc); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1372 | |
| 1373 | // AIDL call should fail on invalid codec |
| 1374 | ASSERT_FALSE(aidl_retval.isOk()); |
| 1375 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 1376 | } |
| 1377 | } |
| 1378 | |
| 1379 | /** |
| 1380 | * openProvider LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH |
| 1381 | */ |
| 1382 | class BluetoothAudioProviderLeAudioBroadcastSoftwareAidl |
| 1383 | : public BluetoothAudioProviderFactoryAidl { |
| 1384 | public: |
| 1385 | virtual void SetUp() override { |
| 1386 | BluetoothAudioProviderFactoryAidl::SetUp(); |
| 1387 | GetProviderCapabilitiesHelper( |
| 1388 | SessionType::LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH); |
| 1389 | OpenProviderHelper( |
| 1390 | SessionType::LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH); |
| 1391 | ASSERT_NE(audio_provider_, nullptr); |
| 1392 | } |
| 1393 | |
| 1394 | virtual void TearDown() override { |
| 1395 | audio_port_ = nullptr; |
| 1396 | audio_provider_ = nullptr; |
| 1397 | BluetoothAudioProviderFactoryAidl::TearDown(); |
| 1398 | } |
| 1399 | |
| 1400 | static constexpr int32_t le_audio_output_sample_rates_[] = { |
| 1401 | 0, 8000, 16000, 24000, 32000, 44100, 48000, |
| 1402 | }; |
| 1403 | static constexpr int8_t le_audio_output_bits_per_samples_[] = {0, 16, 24}; |
| 1404 | static constexpr ChannelMode le_audio_output_channel_modes_[] = { |
| 1405 | ChannelMode::UNKNOWN, ChannelMode::MONO, ChannelMode::STEREO}; |
| 1406 | static constexpr int32_t le_audio_output_data_interval_us_[] = { |
| 1407 | 0 /* Invalid */, 10000 /* Valid 10ms */}; |
| 1408 | }; |
| 1409 | |
| 1410 | /** |
| 1411 | * Test whether each provider of type |
| 1412 | * SessionType::LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH can be started and |
| 1413 | * stopped |
| 1414 | */ |
| 1415 | TEST_P(BluetoothAudioProviderLeAudioBroadcastSoftwareAidl, |
Josh Wu | 3202eab | 2022-02-17 18:09:05 -0800 | [diff] [blame] | 1416 | OpenLeAudioOutputSoftwareProvider) {} |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1417 | |
| 1418 | /** |
| 1419 | * Test whether each provider of type |
| 1420 | * SessionType::LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH can be started and |
| 1421 | * stopped with different PCM config |
| 1422 | */ |
| 1423 | TEST_P(BluetoothAudioProviderLeAudioBroadcastSoftwareAidl, |
Josh Wu | 3202eab | 2022-02-17 18:09:05 -0800 | [diff] [blame] | 1424 | StartAndEndLeAudioOutputSessionWithPossiblePcmConfig) { |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1425 | for (auto sample_rate : le_audio_output_sample_rates_) { |
| 1426 | for (auto bits_per_sample : le_audio_output_bits_per_samples_) { |
| 1427 | for (auto channel_mode : le_audio_output_channel_modes_) { |
| 1428 | for (auto data_interval_us : le_audio_output_data_interval_us_) { |
| 1429 | PcmConfiguration pcm_config{ |
| 1430 | .sampleRateHz = sample_rate, |
| 1431 | .bitsPerSample = bits_per_sample, |
| 1432 | .channelMode = channel_mode, |
| 1433 | .dataIntervalUs = data_interval_us, |
| 1434 | }; |
Josh Wu | 8a1be76 | 2022-02-15 09:37:29 -0800 | [diff] [blame] | 1435 | bool is_codec_config_valid = |
| 1436 | IsPcmConfigSupported(pcm_config) && pcm_config.dataIntervalUs > 0; |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1437 | DataMQDesc mq_desc; |
| 1438 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 1439 | audio_port_, AudioConfiguration(pcm_config), latency_modes, |
| 1440 | &mq_desc); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1441 | DataMQ data_mq(mq_desc); |
| 1442 | |
| 1443 | EXPECT_EQ(aidl_retval.isOk(), is_codec_config_valid); |
| 1444 | if (is_codec_config_valid) { |
| 1445 | EXPECT_TRUE(data_mq.isValid()); |
| 1446 | } |
| 1447 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 1448 | } |
| 1449 | } |
| 1450 | } |
| 1451 | } |
| 1452 | } |
| 1453 | |
Alice Kuo | 336d90c | 2022-02-16 09:09:59 +0800 | [diff] [blame] | 1454 | /** |
| 1455 | * openProvider LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH |
| 1456 | */ |
| 1457 | class BluetoothAudioProviderLeAudioBroadcastHardwareAidl |
| 1458 | : public BluetoothAudioProviderFactoryAidl { |
| 1459 | public: |
| 1460 | virtual void SetUp() override { |
| 1461 | BluetoothAudioProviderFactoryAidl::SetUp(); |
| 1462 | GetProviderCapabilitiesHelper( |
| 1463 | SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH); |
| 1464 | OpenProviderHelper( |
| 1465 | SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH); |
| 1466 | ASSERT_TRUE(temp_provider_capabilities_.empty() || |
| 1467 | audio_provider_ != nullptr); |
| 1468 | } |
| 1469 | |
| 1470 | virtual void TearDown() override { |
| 1471 | audio_port_ = nullptr; |
| 1472 | audio_provider_ = nullptr; |
| 1473 | BluetoothAudioProviderFactoryAidl::TearDown(); |
| 1474 | } |
| 1475 | |
| 1476 | bool IsBroadcastOffloadSupported() { |
| 1477 | for (auto& capability : temp_provider_capabilities_) { |
| 1478 | if (capability.getTag() != AudioCapabilities::leAudioCapabilities) { |
| 1479 | continue; |
| 1480 | } |
| 1481 | auto& le_audio_capability = |
| 1482 | capability.get<AudioCapabilities::leAudioCapabilities>(); |
| 1483 | if (le_audio_capability.broadcastCapability.codecType != |
| 1484 | CodecType::UNKNOWN) |
| 1485 | return true; |
| 1486 | } |
| 1487 | return false; |
| 1488 | } |
| 1489 | |
| 1490 | std::vector<Lc3Configuration> GetBroadcastLc3SupportedList(bool supported) { |
| 1491 | std::vector<Lc3Configuration> le_audio_codec_configs; |
| 1492 | if (!supported) { |
| 1493 | Lc3Configuration lc3_config{.samplingFrequencyHz = 0, .pcmBitDepth = 0}; |
| 1494 | le_audio_codec_configs.push_back(lc3_config); |
| 1495 | return le_audio_codec_configs; |
| 1496 | } |
| 1497 | |
| 1498 | // There might be more than one LeAudioCodecCapabilitiesSetting |
| 1499 | std::vector<Lc3Capabilities> lc3_capabilities; |
| 1500 | for (auto& capability : temp_provider_capabilities_) { |
| 1501 | if (capability.getTag() != AudioCapabilities::leAudioCapabilities) { |
| 1502 | continue; |
| 1503 | } |
| 1504 | auto& le_audio_capability = |
| 1505 | capability.get<AudioCapabilities::leAudioCapabilities>(); |
| 1506 | auto& broadcast_capability = le_audio_capability.broadcastCapability; |
| 1507 | if (broadcast_capability.codecType != CodecType::LC3) { |
| 1508 | continue; |
| 1509 | } |
| 1510 | auto& lc3_capability = broadcast_capability.leAudioCodecCapabilities.get< |
| 1511 | BroadcastCapability::LeAudioCodecCapabilities::lc3Capabilities>(); |
| 1512 | for (int idx = 0; idx < lc3_capability->size(); idx++) |
| 1513 | lc3_capabilities.push_back(*lc3_capability->at(idx)); |
| 1514 | } |
| 1515 | |
| 1516 | // Combine those parameters into one list of LeAudioCodecConfiguration |
| 1517 | // This seems horrible, but usually each Lc3Capability only contains a |
| 1518 | // single Lc3Configuration, which means every array has a length of 1. |
| 1519 | for (auto& lc3_capability : lc3_capabilities) { |
| 1520 | for (int32_t samplingFrequencyHz : lc3_capability.samplingFrequencyHz) { |
| 1521 | for (int32_t frameDurationUs : lc3_capability.frameDurationUs) { |
| 1522 | for (int32_t octetsPerFrame : lc3_capability.octetsPerFrame) { |
| 1523 | Lc3Configuration lc3_config = { |
| 1524 | .samplingFrequencyHz = samplingFrequencyHz, |
| 1525 | .frameDurationUs = frameDurationUs, |
| 1526 | .octetsPerFrame = octetsPerFrame, |
| 1527 | }; |
| 1528 | le_audio_codec_configs.push_back(lc3_config); |
| 1529 | } |
| 1530 | } |
| 1531 | } |
| 1532 | } |
| 1533 | |
| 1534 | return le_audio_codec_configs; |
| 1535 | } |
| 1536 | |
| 1537 | LeAudioCodecCapabilitiesSetting temp_le_audio_capabilities_; |
| 1538 | }; |
| 1539 | |
| 1540 | /** |
| 1541 | * Test whether each provider of type |
| 1542 | * SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH can be |
| 1543 | * started and stopped |
| 1544 | */ |
| 1545 | TEST_P(BluetoothAudioProviderLeAudioBroadcastHardwareAidl, |
| 1546 | OpenLeAudioOutputHardwareProvider) {} |
| 1547 | |
| 1548 | /** |
| 1549 | * Test whether each provider of type |
| 1550 | * SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH can be |
| 1551 | * started and stopped with broadcast hardware encoding config |
| 1552 | */ |
| 1553 | TEST_P(BluetoothAudioProviderLeAudioBroadcastHardwareAidl, |
| 1554 | StartAndEndLeAudioBroadcastSessionWithPossibleBroadcastConfig) { |
| 1555 | if (!IsBroadcastOffloadSupported()) { |
| 1556 | return; |
| 1557 | } |
| 1558 | |
| 1559 | auto lc3_codec_configs = GetBroadcastLc3SupportedList(true /* supported */); |
| 1560 | LeAudioBroadcastConfiguration le_audio_broadcast_config = { |
| 1561 | .codecType = CodecType::LC3, |
| 1562 | .streamMap = {}, |
| 1563 | }; |
| 1564 | |
| 1565 | for (auto& lc3_config : lc3_codec_configs) { |
| 1566 | le_audio_broadcast_config.streamMap[0] |
| 1567 | .leAudioCodecConfig.set<LeAudioCodecConfiguration::lc3Config>( |
| 1568 | lc3_config); |
| 1569 | DataMQDesc mq_desc; |
| 1570 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | 60d52e4 | 2022-02-16 12:19:12 -0800 | [diff] [blame] | 1571 | audio_port_, AudioConfiguration(le_audio_broadcast_config), |
| 1572 | latency_modes, &mq_desc); |
Alice Kuo | 336d90c | 2022-02-16 09:09:59 +0800 | [diff] [blame] | 1573 | |
| 1574 | ASSERT_TRUE(aidl_retval.isOk()); |
| 1575 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 1576 | } |
| 1577 | } |
| 1578 | |
| 1579 | /** |
| 1580 | * Test whether each provider of type |
| 1581 | * SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH can be |
| 1582 | * started and stopped with Broadcast hardware encoding config |
| 1583 | * |
| 1584 | * Disabled since offload codec checking is not ready |
| 1585 | */ |
| 1586 | TEST_P( |
| 1587 | BluetoothAudioProviderLeAudioBroadcastHardwareAidl, |
| 1588 | DISABLED_StartAndEndLeAudioBroadcastSessionWithInvalidAudioConfiguration) { |
| 1589 | if (!IsBroadcastOffloadSupported()) { |
| 1590 | return; |
| 1591 | } |
| 1592 | |
| 1593 | auto lc3_codec_configs = GetBroadcastLc3SupportedList(false /* supported */); |
| 1594 | LeAudioBroadcastConfiguration le_audio_broadcast_config = { |
| 1595 | .codecType = CodecType::LC3, |
| 1596 | .streamMap = {}, |
| 1597 | }; |
| 1598 | |
| 1599 | for (auto& lc3_config : lc3_codec_configs) { |
| 1600 | le_audio_broadcast_config.streamMap[0] |
| 1601 | .leAudioCodecConfig.set<LeAudioCodecConfiguration::lc3Config>( |
| 1602 | lc3_config); |
| 1603 | DataMQDesc mq_desc; |
| 1604 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | 60d52e4 | 2022-02-16 12:19:12 -0800 | [diff] [blame] | 1605 | audio_port_, AudioConfiguration(le_audio_broadcast_config), |
| 1606 | latency_modes, &mq_desc); |
Alice Kuo | 336d90c | 2022-02-16 09:09:59 +0800 | [diff] [blame] | 1607 | |
| 1608 | // AIDL call should fail on invalid codec |
| 1609 | ASSERT_FALSE(aidl_retval.isOk()); |
| 1610 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 1611 | } |
| 1612 | } |
| 1613 | |
Alice Kuo | adcceec | 2022-03-28 13:28:43 +0800 | [diff] [blame] | 1614 | /** |
| 1615 | * openProvider A2DP_SOFTWARE_DECODING_DATAPATH |
| 1616 | */ |
| 1617 | class BluetoothAudioProviderA2dpDecodingSoftwareAidl |
| 1618 | : public BluetoothAudioProviderFactoryAidl { |
| 1619 | public: |
| 1620 | virtual void SetUp() override { |
| 1621 | BluetoothAudioProviderFactoryAidl::SetUp(); |
| 1622 | GetProviderCapabilitiesHelper(SessionType::A2DP_SOFTWARE_DECODING_DATAPATH); |
| 1623 | OpenProviderHelper(SessionType::A2DP_SOFTWARE_DECODING_DATAPATH); |
| 1624 | ASSERT_TRUE(temp_provider_capabilities_.empty() || |
| 1625 | audio_provider_ != nullptr); |
| 1626 | } |
| 1627 | |
| 1628 | virtual void TearDown() override { |
| 1629 | audio_port_ = nullptr; |
| 1630 | audio_provider_ = nullptr; |
| 1631 | BluetoothAudioProviderFactoryAidl::TearDown(); |
| 1632 | } |
| 1633 | }; |
| 1634 | |
| 1635 | /** |
| 1636 | * Test whether we can open a provider of type |
| 1637 | */ |
| 1638 | TEST_P(BluetoothAudioProviderA2dpDecodingSoftwareAidl, |
| 1639 | OpenA2dpDecodingSoftwareProvider) {} |
| 1640 | |
| 1641 | /** |
| 1642 | * Test whether each provider of type |
| 1643 | * SessionType::A2DP_SOFTWARE_DECODING_DATAPATH can be started and stopped with |
| 1644 | * different PCM config |
| 1645 | */ |
| 1646 | TEST_P(BluetoothAudioProviderA2dpDecodingSoftwareAidl, |
| 1647 | StartAndEndA2dpDecodingSoftwareSessionWithPossiblePcmConfig) { |
| 1648 | for (auto sample_rate : a2dp_sample_rates) { |
| 1649 | for (auto bits_per_sample : a2dp_bits_per_samples) { |
| 1650 | for (auto channel_mode : a2dp_channel_modes) { |
| 1651 | PcmConfiguration pcm_config{ |
| 1652 | .sampleRateHz = sample_rate, |
| 1653 | .bitsPerSample = bits_per_sample, |
| 1654 | .channelMode = channel_mode, |
| 1655 | }; |
| 1656 | bool is_codec_config_valid = IsPcmConfigSupported(pcm_config); |
| 1657 | DataMQDesc mq_desc; |
| 1658 | auto aidl_retval = audio_provider_->startSession( |
| 1659 | audio_port_, AudioConfiguration(pcm_config), latency_modes, |
| 1660 | &mq_desc); |
| 1661 | DataMQ data_mq(mq_desc); |
| 1662 | |
| 1663 | EXPECT_EQ(aidl_retval.isOk(), is_codec_config_valid); |
| 1664 | if (is_codec_config_valid) { |
| 1665 | EXPECT_TRUE(data_mq.isValid()); |
| 1666 | } |
| 1667 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 1668 | } |
| 1669 | } |
| 1670 | } |
| 1671 | } |
| 1672 | |
| 1673 | /** |
| 1674 | * openProvider A2DP_HARDWARE_OFFLOAD_DECODING_DATAPATH |
| 1675 | */ |
| 1676 | class BluetoothAudioProviderA2dpDecodingHardwareAidl |
| 1677 | : public BluetoothAudioProviderFactoryAidl { |
| 1678 | public: |
| 1679 | virtual void SetUp() override { |
| 1680 | BluetoothAudioProviderFactoryAidl::SetUp(); |
| 1681 | GetProviderCapabilitiesHelper( |
| 1682 | SessionType::A2DP_HARDWARE_OFFLOAD_DECODING_DATAPATH); |
| 1683 | OpenProviderHelper(SessionType::A2DP_HARDWARE_OFFLOAD_DECODING_DATAPATH); |
| 1684 | ASSERT_TRUE(temp_provider_capabilities_.empty() || |
| 1685 | audio_provider_ != nullptr); |
| 1686 | } |
| 1687 | |
| 1688 | virtual void TearDown() override { |
| 1689 | audio_port_ = nullptr; |
| 1690 | audio_provider_ = nullptr; |
| 1691 | BluetoothAudioProviderFactoryAidl::TearDown(); |
| 1692 | } |
| 1693 | |
| 1694 | bool IsOffloadSupported() { return (temp_provider_capabilities_.size() > 0); } |
| 1695 | }; |
| 1696 | |
| 1697 | /** |
| 1698 | * Test whether we can open a provider of type |
| 1699 | */ |
| 1700 | TEST_P(BluetoothAudioProviderA2dpDecodingHardwareAidl, |
| 1701 | OpenA2dpDecodingHardwareProvider) {} |
| 1702 | |
| 1703 | /** |
| 1704 | * Test whether each provider of type |
| 1705 | * SessionType::A2DP_HARDWARE_DECODING_DATAPATH can be started and stopped with |
| 1706 | * SBC hardware encoding config |
| 1707 | */ |
| 1708 | TEST_P(BluetoothAudioProviderA2dpDecodingHardwareAidl, |
| 1709 | StartAndEndA2dpSbcDecodingHardwareSession) { |
| 1710 | if (!IsOffloadSupported()) { |
| 1711 | return; |
| 1712 | } |
| 1713 | |
| 1714 | CodecConfiguration codec_config = { |
| 1715 | .codecType = CodecType::SBC, |
| 1716 | .encodedAudioBitrate = 328000, |
| 1717 | .peerMtu = 1005, |
| 1718 | .isScmstEnabled = false, |
| 1719 | }; |
| 1720 | auto sbc_codec_specifics = GetSbcCodecSpecificSupportedList(true); |
| 1721 | |
| 1722 | for (auto& codec_specific : sbc_codec_specifics) { |
| 1723 | copy_codec_specific(codec_config.config, codec_specific); |
| 1724 | DataMQDesc mq_desc; |
| 1725 | auto aidl_retval = audio_provider_->startSession( |
| 1726 | audio_port_, AudioConfiguration(codec_config), latency_modes, &mq_desc); |
| 1727 | |
| 1728 | ASSERT_TRUE(aidl_retval.isOk()); |
| 1729 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 1730 | } |
| 1731 | } |
| 1732 | |
| 1733 | /** |
| 1734 | * Test whether each provider of type |
| 1735 | * SessionType::A2DP_HARDWARE_DECODING_DATAPATH can be started and stopped with |
| 1736 | * AAC hardware encoding config |
| 1737 | */ |
| 1738 | TEST_P(BluetoothAudioProviderA2dpDecodingHardwareAidl, |
| 1739 | StartAndEndA2dpAacDecodingHardwareSession) { |
| 1740 | if (!IsOffloadSupported()) { |
| 1741 | return; |
| 1742 | } |
| 1743 | |
| 1744 | CodecConfiguration codec_config = { |
| 1745 | .codecType = CodecType::AAC, |
| 1746 | .encodedAudioBitrate = 320000, |
| 1747 | .peerMtu = 1005, |
| 1748 | .isScmstEnabled = false, |
| 1749 | }; |
| 1750 | auto aac_codec_specifics = GetAacCodecSpecificSupportedList(true); |
| 1751 | |
| 1752 | for (auto& codec_specific : aac_codec_specifics) { |
| 1753 | copy_codec_specific(codec_config.config, codec_specific); |
| 1754 | DataMQDesc mq_desc; |
| 1755 | auto aidl_retval = audio_provider_->startSession( |
| 1756 | audio_port_, AudioConfiguration(codec_config), latency_modes, &mq_desc); |
| 1757 | |
| 1758 | ASSERT_TRUE(aidl_retval.isOk()); |
| 1759 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 1760 | } |
| 1761 | } |
| 1762 | |
| 1763 | /** |
| 1764 | * Test whether each provider of type |
| 1765 | * SessionType::A2DP_HARDWARE_DECODING_DATAPATH can be started and stopped with |
| 1766 | * LDAC hardware encoding config |
| 1767 | */ |
| 1768 | TEST_P(BluetoothAudioProviderA2dpDecodingHardwareAidl, |
| 1769 | StartAndEndA2dpLdacDecodingHardwareSession) { |
| 1770 | if (!IsOffloadSupported()) { |
| 1771 | return; |
| 1772 | } |
| 1773 | |
| 1774 | CodecConfiguration codec_config = { |
| 1775 | .codecType = CodecType::LDAC, |
| 1776 | .encodedAudioBitrate = 990000, |
| 1777 | .peerMtu = 1005, |
| 1778 | .isScmstEnabled = false, |
| 1779 | }; |
| 1780 | auto ldac_codec_specifics = GetLdacCodecSpecificSupportedList(true); |
| 1781 | |
| 1782 | for (auto& codec_specific : ldac_codec_specifics) { |
| 1783 | copy_codec_specific(codec_config.config, codec_specific); |
| 1784 | DataMQDesc mq_desc; |
| 1785 | auto aidl_retval = audio_provider_->startSession( |
| 1786 | audio_port_, AudioConfiguration(codec_config), latency_modes, &mq_desc); |
| 1787 | |
| 1788 | ASSERT_TRUE(aidl_retval.isOk()); |
| 1789 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 1790 | } |
| 1791 | } |
| 1792 | |
| 1793 | /** |
| 1794 | * Test whether each provider of type |
| 1795 | * SessionType::A2DP_HARDWARE_DECODING_DATAPATH can be started and stopped with |
Omer Osman | a2587da | 2022-05-01 03:54:11 +0000 | [diff] [blame^] | 1796 | * Opus hardware encoding config |
Alice Kuo | adcceec | 2022-03-28 13:28:43 +0800 | [diff] [blame] | 1797 | */ |
| 1798 | TEST_P(BluetoothAudioProviderA2dpDecodingHardwareAidl, |
Omer Osman | a2587da | 2022-05-01 03:54:11 +0000 | [diff] [blame^] | 1799 | StartAndEndA2dpOpusDecodingHardwareSession) { |
Alice Kuo | adcceec | 2022-03-28 13:28:43 +0800 | [diff] [blame] | 1800 | if (!IsOffloadSupported()) { |
| 1801 | return; |
| 1802 | } |
| 1803 | |
| 1804 | CodecConfiguration codec_config = { |
Omer Osman | a2587da | 2022-05-01 03:54:11 +0000 | [diff] [blame^] | 1805 | .codecType = CodecType::OPUS, |
Alice Kuo | adcceec | 2022-03-28 13:28:43 +0800 | [diff] [blame] | 1806 | .encodedAudioBitrate = 990000, |
| 1807 | .peerMtu = 1005, |
| 1808 | .isScmstEnabled = false, |
| 1809 | }; |
Omer Osman | a2587da | 2022-05-01 03:54:11 +0000 | [diff] [blame^] | 1810 | auto opus_codec_specifics = GetOpusCodecSpecificSupportedList(true); |
Alice Kuo | adcceec | 2022-03-28 13:28:43 +0800 | [diff] [blame] | 1811 | |
Omer Osman | a2587da | 2022-05-01 03:54:11 +0000 | [diff] [blame^] | 1812 | for (auto& codec_specific : opus_codec_specifics) { |
Alice Kuo | adcceec | 2022-03-28 13:28:43 +0800 | [diff] [blame] | 1813 | copy_codec_specific(codec_config.config, codec_specific); |
| 1814 | DataMQDesc mq_desc; |
| 1815 | auto aidl_retval = audio_provider_->startSession( |
| 1816 | audio_port_, AudioConfiguration(codec_config), latency_modes, &mq_desc); |
| 1817 | |
| 1818 | ASSERT_TRUE(aidl_retval.isOk()); |
| 1819 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 1820 | } |
| 1821 | } |
| 1822 | |
| 1823 | /** |
| 1824 | * Test whether each provider of type |
| 1825 | * SessionType::A2DP_HARDWARE_DECODING_DATAPATH can be started and stopped with |
| 1826 | * AptX hardware encoding config |
| 1827 | */ |
| 1828 | TEST_P(BluetoothAudioProviderA2dpDecodingHardwareAidl, |
| 1829 | StartAndEndA2dpAptxDecodingHardwareSession) { |
| 1830 | if (!IsOffloadSupported()) { |
| 1831 | return; |
| 1832 | } |
| 1833 | |
| 1834 | for (auto codec_type : {CodecType::APTX, CodecType::APTX_HD}) { |
| 1835 | CodecConfiguration codec_config = { |
| 1836 | .codecType = codec_type, |
| 1837 | .encodedAudioBitrate = |
| 1838 | (codec_type == CodecType::APTX ? 352000 : 576000), |
| 1839 | .peerMtu = 1005, |
| 1840 | .isScmstEnabled = false, |
| 1841 | }; |
| 1842 | |
| 1843 | auto aptx_codec_specifics = GetAptxCodecSpecificSupportedList( |
| 1844 | (codec_type == CodecType::APTX_HD ? true : false), true); |
| 1845 | |
| 1846 | for (auto& codec_specific : aptx_codec_specifics) { |
| 1847 | copy_codec_specific(codec_config.config, codec_specific); |
| 1848 | DataMQDesc mq_desc; |
| 1849 | auto aidl_retval = audio_provider_->startSession( |
| 1850 | audio_port_, AudioConfiguration(codec_config), latency_modes, |
| 1851 | &mq_desc); |
| 1852 | |
| 1853 | ASSERT_TRUE(aidl_retval.isOk()); |
| 1854 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 1855 | } |
| 1856 | } |
| 1857 | } |
| 1858 | |
| 1859 | /** |
| 1860 | * Test whether each provider of type |
| 1861 | * SessionType::A2DP_HARDWARE_DECODING_DATAPATH can be started and stopped with |
| 1862 | * an invalid codec config |
| 1863 | */ |
| 1864 | TEST_P(BluetoothAudioProviderA2dpDecodingHardwareAidl, |
| 1865 | StartAndEndA2dpDecodingHardwareSessionInvalidCodecConfig) { |
| 1866 | if (!IsOffloadSupported()) { |
| 1867 | return; |
| 1868 | } |
| 1869 | ASSERT_NE(audio_provider_, nullptr); |
| 1870 | |
| 1871 | std::vector<CodecConfiguration::CodecSpecific> codec_specifics; |
| 1872 | for (auto codec_type : a2dp_codec_types) { |
| 1873 | switch (codec_type) { |
| 1874 | case CodecType::SBC: |
| 1875 | codec_specifics = GetSbcCodecSpecificSupportedList(false); |
| 1876 | break; |
| 1877 | case CodecType::AAC: |
| 1878 | codec_specifics = GetAacCodecSpecificSupportedList(false); |
| 1879 | break; |
| 1880 | case CodecType::LDAC: |
| 1881 | codec_specifics = GetLdacCodecSpecificSupportedList(false); |
| 1882 | break; |
| 1883 | case CodecType::APTX: |
| 1884 | codec_specifics = GetAptxCodecSpecificSupportedList(false, false); |
| 1885 | break; |
| 1886 | case CodecType::APTX_HD: |
| 1887 | codec_specifics = GetAptxCodecSpecificSupportedList(true, false); |
| 1888 | break; |
Omer Osman | a2587da | 2022-05-01 03:54:11 +0000 | [diff] [blame^] | 1889 | case CodecType::OPUS: |
| 1890 | codec_specifics = GetOpusCodecSpecificSupportedList(false); |
Alice Kuo | adcceec | 2022-03-28 13:28:43 +0800 | [diff] [blame] | 1891 | continue; |
| 1892 | case CodecType::APTX_ADAPTIVE: |
Omer Osman | a2587da | 2022-05-01 03:54:11 +0000 | [diff] [blame^] | 1893 | case CodecType::LC3: |
Alice Kuo | adcceec | 2022-03-28 13:28:43 +0800 | [diff] [blame] | 1894 | case CodecType::VENDOR: |
| 1895 | case CodecType::UNKNOWN: |
| 1896 | codec_specifics.clear(); |
| 1897 | break; |
| 1898 | } |
| 1899 | if (codec_specifics.empty()) { |
| 1900 | continue; |
| 1901 | } |
| 1902 | |
| 1903 | CodecConfiguration codec_config = { |
| 1904 | .codecType = codec_type, |
| 1905 | .encodedAudioBitrate = 328000, |
| 1906 | .peerMtu = 1005, |
| 1907 | .isScmstEnabled = false, |
| 1908 | }; |
| 1909 | for (auto codec_specific : codec_specifics) { |
| 1910 | copy_codec_specific(codec_config.config, codec_specific); |
| 1911 | DataMQDesc mq_desc; |
| 1912 | auto aidl_retval = audio_provider_->startSession( |
| 1913 | audio_port_, AudioConfiguration(codec_config), latency_modes, |
| 1914 | &mq_desc); |
| 1915 | |
| 1916 | // AIDL call should fail on invalid codec |
| 1917 | ASSERT_FALSE(aidl_retval.isOk()); |
| 1918 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 1919 | } |
| 1920 | } |
| 1921 | } |
| 1922 | |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1923 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST( |
| 1924 | BluetoothAudioProviderFactoryAidl); |
| 1925 | INSTANTIATE_TEST_SUITE_P(PerInstance, BluetoothAudioProviderFactoryAidl, |
| 1926 | testing::ValuesIn(android::getAidlHalInstanceNames( |
| 1927 | IBluetoothAudioProviderFactory::descriptor)), |
| 1928 | android::PrintInstanceNameToString); |
| 1929 | |
| 1930 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST( |
Alice Kuo | adcceec | 2022-03-28 13:28:43 +0800 | [diff] [blame] | 1931 | BluetoothAudioProviderA2dpEncodingSoftwareAidl); |
| 1932 | INSTANTIATE_TEST_SUITE_P(PerInstance, |
| 1933 | BluetoothAudioProviderA2dpEncodingSoftwareAidl, |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1934 | testing::ValuesIn(android::getAidlHalInstanceNames( |
| 1935 | IBluetoothAudioProviderFactory::descriptor)), |
| 1936 | android::PrintInstanceNameToString); |
| 1937 | |
| 1938 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST( |
Alice Kuo | adcceec | 2022-03-28 13:28:43 +0800 | [diff] [blame] | 1939 | BluetoothAudioProviderA2dpEncodingHardwareAidl); |
| 1940 | INSTANTIATE_TEST_SUITE_P(PerInstance, |
| 1941 | BluetoothAudioProviderA2dpEncodingHardwareAidl, |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1942 | testing::ValuesIn(android::getAidlHalInstanceNames( |
| 1943 | IBluetoothAudioProviderFactory::descriptor)), |
| 1944 | android::PrintInstanceNameToString); |
| 1945 | |
| 1946 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST( |
| 1947 | BluetoothAudioProviderHearingAidSoftwareAidl); |
| 1948 | INSTANTIATE_TEST_SUITE_P(PerInstance, |
| 1949 | BluetoothAudioProviderHearingAidSoftwareAidl, |
| 1950 | testing::ValuesIn(android::getAidlHalInstanceNames( |
| 1951 | IBluetoothAudioProviderFactory::descriptor)), |
| 1952 | android::PrintInstanceNameToString); |
| 1953 | |
| 1954 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST( |
| 1955 | BluetoothAudioProviderLeAudioOutputSoftwareAidl); |
| 1956 | INSTANTIATE_TEST_SUITE_P(PerInstance, |
| 1957 | BluetoothAudioProviderLeAudioOutputSoftwareAidl, |
| 1958 | testing::ValuesIn(android::getAidlHalInstanceNames( |
| 1959 | IBluetoothAudioProviderFactory::descriptor)), |
| 1960 | android::PrintInstanceNameToString); |
| 1961 | |
| 1962 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST( |
| 1963 | BluetoothAudioProviderLeAudioInputSoftwareAidl); |
| 1964 | INSTANTIATE_TEST_SUITE_P(PerInstance, |
| 1965 | BluetoothAudioProviderLeAudioInputSoftwareAidl, |
| 1966 | testing::ValuesIn(android::getAidlHalInstanceNames( |
| 1967 | IBluetoothAudioProviderFactory::descriptor)), |
| 1968 | android::PrintInstanceNameToString); |
| 1969 | |
| 1970 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST( |
| 1971 | BluetoothAudioProviderLeAudioOutputHardwareAidl); |
| 1972 | INSTANTIATE_TEST_SUITE_P(PerInstance, |
| 1973 | BluetoothAudioProviderLeAudioOutputHardwareAidl, |
| 1974 | testing::ValuesIn(android::getAidlHalInstanceNames( |
| 1975 | IBluetoothAudioProviderFactory::descriptor)), |
| 1976 | android::PrintInstanceNameToString); |
| 1977 | |
| 1978 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST( |
| 1979 | BluetoothAudioProviderLeAudioInputHardwareAidl); |
| 1980 | INSTANTIATE_TEST_SUITE_P(PerInstance, |
| 1981 | BluetoothAudioProviderLeAudioInputHardwareAidl, |
| 1982 | testing::ValuesIn(android::getAidlHalInstanceNames( |
| 1983 | IBluetoothAudioProviderFactory::descriptor)), |
| 1984 | android::PrintInstanceNameToString); |
| 1985 | |
| 1986 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST( |
| 1987 | BluetoothAudioProviderLeAudioBroadcastSoftwareAidl); |
| 1988 | INSTANTIATE_TEST_SUITE_P(PerInstance, |
| 1989 | BluetoothAudioProviderLeAudioBroadcastSoftwareAidl, |
| 1990 | testing::ValuesIn(android::getAidlHalInstanceNames( |
| 1991 | IBluetoothAudioProviderFactory::descriptor)), |
| 1992 | android::PrintInstanceNameToString); |
| 1993 | |
Alice Kuo | 336d90c | 2022-02-16 09:09:59 +0800 | [diff] [blame] | 1994 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST( |
| 1995 | BluetoothAudioProviderLeAudioBroadcastHardwareAidl); |
| 1996 | INSTANTIATE_TEST_SUITE_P(PerInstance, |
| 1997 | BluetoothAudioProviderLeAudioBroadcastHardwareAidl, |
| 1998 | testing::ValuesIn(android::getAidlHalInstanceNames( |
| 1999 | IBluetoothAudioProviderFactory::descriptor)), |
| 2000 | android::PrintInstanceNameToString); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 2001 | |
Alice Kuo | adcceec | 2022-03-28 13:28:43 +0800 | [diff] [blame] | 2002 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST( |
| 2003 | BluetoothAudioProviderA2dpDecodingSoftwareAidl); |
| 2004 | INSTANTIATE_TEST_SUITE_P(PerInstance, |
| 2005 | BluetoothAudioProviderA2dpDecodingSoftwareAidl, |
| 2006 | testing::ValuesIn(android::getAidlHalInstanceNames( |
| 2007 | IBluetoothAudioProviderFactory::descriptor)), |
| 2008 | android::PrintInstanceNameToString); |
| 2009 | |
| 2010 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST( |
| 2011 | BluetoothAudioProviderA2dpDecodingHardwareAidl); |
| 2012 | INSTANTIATE_TEST_SUITE_P(PerInstance, |
| 2013 | BluetoothAudioProviderA2dpDecodingHardwareAidl, |
| 2014 | testing::ValuesIn(android::getAidlHalInstanceNames( |
| 2015 | IBluetoothAudioProviderFactory::descriptor)), |
| 2016 | android::PrintInstanceNameToString); |
| 2017 | |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 2018 | int main(int argc, char** argv) { |
| 2019 | ::testing::InitGoogleTest(&argc, argv); |
| 2020 | ABinderProcess_setThreadPoolMaxThreadCount(1); |
| 2021 | ABinderProcess_startThreadPool(); |
| 2022 | return RUN_ALL_TESTS(); |
| 2023 | } |