#pragma once #include #include "VcmCapturer.h" #include "rtspvideocapturer.h" #include "rtspaudiocapturer.h" #include "pc/video_track_source.h" template class TrackSource : public webrtc::VideoTrackSource { public: static rtc::scoped_refptr Create(const std::string & videourl, std::unique_ptr& videoDecoderFactory) { std::unique_ptr capturer = absl::WrapUnique(T::Create(videourl, videoDecoderFactory)); if (!capturer) { return nullptr; } return new rtc::RefCountedObject(std::move(capturer)); } protected: explicit TrackSource(std::unique_ptr capturer) : webrtc::VideoTrackSource(/*remote=*/false), capturer_(std::move(capturer)) {} private: rtc::VideoSourceInterface* source() override { return capturer_.get(); } std::unique_ptr capturer_; }; class CapturerFactory { public: static rtc::scoped_refptr CreateVideoSource(const std::string & videourl, std::unique_ptr& videoDecoderFactory) { rtc::scoped_refptr videoSource; videoSource = TrackSource::Create(videourl, videoDecoderFactory); return videoSource; } static rtc::scoped_refptr CreateAudioSource(const std::string & audiourl, const std::map & opts, rtc::scoped_refptr peer_connection_factory, rtc::scoped_refptr audioDecoderfactory, rtc::scoped_refptr audioDeviceModule) { rtc::scoped_refptr audioSource; audioDeviceModule->Terminate(); audioSource = RTSPAudioSource::Create(audioDecoderfactory, audiourl); return audioSource; } };