#include "pch.h" #include #include #include #include #include #include #include #include #include "UnityAudioDecoderFactory.h" using namespace ::webrtc; namespace unity { namespace webrtc { template struct StereoSupportDecoder { using Config = typename T::Config; static absl::optional SdpToConfig(const SdpAudioFormat& audio_format) { return T::SdpToConfig(audio_format); } static void AppendSupportedDecoders(std::vector* specs) { std::vector new_specs; T::AppendSupportedDecoders(&new_specs); RTC_DCHECK_EQ(new_specs.size(), 1); auto spec = new_specs[0]; if (spec.format.num_channels == 2) { if (spec.format.parameters.find("stereo") == spec.format.parameters.end()) spec.format.parameters.emplace("stereo", "1"); if (spec.format.parameters.find("sprop-stereo") == spec.format.parameters.end()) spec.format.parameters.emplace("sprop-stereo", "1"); spec.info.num_channels = 2; } specs->push_back(spec); } static std::unique_ptr MakeAudioDecoder(const Config& config, absl::optional codec_pair_id) { return T::MakeAudioDecoder(config, codec_pair_id); } }; rtc::scoped_refptr CreateAudioDecoderFactory() { return ::webrtc::CreateAudioDecoderFactory< StereoSupportDecoder, AudioDecoderMultiChannelOpus, AudioDecoderIlbc, AudioDecoderIsac, AudioDecoderG722, AudioDecoderG711, AudioDecoderL16>(); } } // end namespace webrtc } // end namespace unity