#pragma once #include #include #include namespace unity { namespace webrtc { using namespace ::webrtc; class UnityAudioTrackSource : public LocalAudioSource { public: static rtc::scoped_refptr Create(); static rtc::scoped_refptr Create(const cricket::AudioOptions& audio_options); const cricket::AudioOptions options() const override { return _options; } void AddSink(AudioTrackSinkInterface* sink) override; void RemoveSink(AudioTrackSinkInterface* sink) override; void PushAudioData(const float* pAudioData, int nSampleRate, size_t nNumChannels, size_t nNumFrames); protected: UnityAudioTrackSource(); UnityAudioTrackSource(const cricket::AudioOptions& audio_options); ~UnityAudioTrackSource() override; private: std::vector _convertedAudioData; std::vector _arrSink; std::mutex _mutex; cricket::AudioOptions _options; int _sampleRate = 0; size_t _numChannels = 0; size_t _numFrames = 0; }; } // end namespace webrtc } // end namespace unity