#include "pch.h" #include #include #include #include #include #include #include #include #include "UnityAudioEncoderFactory.h" using namespace ::webrtc; namespace unity { namespace webrtc { template struct StereoSupportEncoder { using Config = typename T::Config; static absl::optional SdpToConfig(const SdpAudioFormat& audio_format) { return T::SdpToConfig(audio_format); } static void AppendSupportedEncoders(std::vector* specs) { std::vector new_specs; T::AppendSupportedEncoders(&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 AudioCodecInfo QueryAudioEncoder(const Config& config) { return T::QueryAudioEncoder(config); } static std::unique_ptr MakeAudioEncoder( const Config& config, int payload_type, absl::optional codec_pair_id = absl::nullopt) { return T::MakeAudioEncoder(config, payload_type, codec_pair_id); } }; rtc::scoped_refptr CreateAudioEncoderFactory() { return ::webrtc::CreateAudioEncoderFactory< StereoSupportEncoder, AudioEncoderMultiChannelOpus, AudioEncoderIlbc, AudioEncoderIsac, AudioEncoderG722, AudioEncoderG711, AudioEncoderL16>(); } } // end namespace webrtc } // end namespace unity