diff --git a/api/video/video_source_interface.h b/api/video/video_source_interface.h index 2bf73704bf..9d1641cd0d 100644 --- a/api/video/video_source_interface.h +++ b/api/video/video_source_interface.h @@ -47,15 +47,13 @@ struct RTC_EXPORT VideoSinkWants { template class VideoSourceInterface { public: + virtual ~VideoSourceInterface() = default; + virtual void AddOrUpdateSink(VideoSinkInterface* sink, const VideoSinkWants& wants) = 0; // RemoveSink must guarantee that at the time the method returns, // there is no current and no future calls to VideoSinkInterface::OnFrame. virtual void RemoveSink(VideoSinkInterface* sink) = 0; - - protected: - // Non-public, since one shouldn't own sources via this interface. - virtual ~VideoSourceInterface() {} }; } // namespace rtc diff --git a/test/call_test.cc b/test/call_test.cc index 7a010790d8..80b86f00c8 100644 --- a/test/call_test.cc +++ b/test/call_test.cc @@ -63,7 +63,7 @@ CallTest::~CallTest() { task_queue_.SendTask([this]() { fake_send_audio_device_ = nullptr; fake_recv_audio_device_ = nullptr; - video_capturers_.clear(); + video_sources_.clear(); }); } @@ -454,12 +454,10 @@ void CallTest::CreateFrameGeneratorCapturerWithDrift(Clock* clock, int width, int height) { video_sources_.clear(); - video_capturers_.clear(); frame_generator_capturer_ = test::FrameGeneratorCapturer::Create( width, height, absl::nullopt, absl::nullopt, framerate * speed, clock); - video_capturers_.emplace_back( + video_sources_.emplace_back( std::unique_ptr(frame_generator_capturer_)); - video_sources_.push_back(video_capturers_.back().get()); ConnectVideoSourcesToStreams(); } @@ -467,12 +465,10 @@ void CallTest::CreateFrameGeneratorCapturer(int framerate, int width, int height) { video_sources_.clear(); - video_capturers_.clear(); frame_generator_capturer_ = test::FrameGeneratorCapturer::Create( width, height, absl::nullopt, absl::nullopt, framerate, clock_); - video_capturers_.emplace_back( + video_sources_.emplace_back( std::unique_ptr(frame_generator_capturer_)); - video_sources_.push_back(video_capturers_.back().get()); ConnectVideoSourcesToStreams(); } @@ -560,7 +556,7 @@ void CallTest::CreateFlexfecStreams() { void CallTest::ConnectVideoSourcesToStreams() { for (size_t i = 0; i < video_sources_.size(); ++i) - video_send_streams_[i]->SetSource(video_sources_[i], + video_send_streams_[i]->SetSource(video_sources_[i].get(), degradation_preference_); } diff --git a/test/call_test.h b/test/call_test.h index edd7712b7c..220900bd4b 100644 --- a/test/call_test.h +++ b/test/call_test.h @@ -192,8 +192,8 @@ class CallTest : public ::testing::Test { std::vector flexfec_receive_streams_; test::FrameGeneratorCapturer* frame_generator_capturer_; - std::vector*> video_sources_; - std::vector> video_capturers_; + std::vector>> + video_sources_; DegradationPreference degradation_preference_ = DegradationPreference::MAINTAIN_FRAMERATE; diff --git a/video/BUILD.gn b/video/BUILD.gn index 5df2c027db..a1d17fdc8f 100644 --- a/video/BUILD.gn +++ b/video/BUILD.gn @@ -240,8 +240,10 @@ if (rtc_include_tests) { "../api:video_quality_test_fixture_api", "../api/video:builtin_video_bitrate_allocator_factory", "../api/video:video_bitrate_allocator_factory", + "../api/video:video_frame", "../call:fake_network", "../call:simulated_network", + "../common_video", "../logging:rtc_event_log_api", "../logging:rtc_event_log_impl_output", "../media:rtc_audio_video", diff --git a/video/video_analyzer.cc b/video/video_analyzer.cc index 1fd22ff806..950cf680b7 100644 --- a/video/video_analyzer.cc +++ b/video/video_analyzer.cc @@ -12,6 +12,7 @@ #include #include +#include "common_video/libyuv/include/webrtc_libyuv.h" #include "modules/rtp_rtcp/source/rtp_format.h" #include "modules/rtp_rtcp/source/rtp_utility.h" #include "rtc_base/cpu_time.h" @@ -138,12 +139,13 @@ void VideoAnalyzer::SetReceiver(PacketReceiver* receiver) { receiver_ = receiver; } -void VideoAnalyzer::SetSource(test::TestVideoCapturer* video_capturer, - bool respect_sink_wants) { +void VideoAnalyzer::SetSource( + rtc::VideoSourceInterface* video_source, + bool respect_sink_wants) { if (respect_sink_wants) - captured_frame_forwarder_.SetSource(video_capturer); + captured_frame_forwarder_.SetSource(video_source); rtc::VideoSinkWants wants; - video_capturer->AddOrUpdateSink(InputInterface(), wants); + video_source->AddOrUpdateSink(InputInterface(), wants); } void VideoAnalyzer::SetCall(Call* call) { @@ -841,12 +843,12 @@ VideoAnalyzer::CapturedFrameForwarder::CapturedFrameForwarder( Clock* clock) : analyzer_(analyzer), send_stream_input_(nullptr), - video_capturer_(nullptr), + video_source_(nullptr), clock_(clock) {} void VideoAnalyzer::CapturedFrameForwarder::SetSource( - test::TestVideoCapturer* video_capturer) { - video_capturer_ = video_capturer; + VideoSourceInterface* video_source) { + video_source_ = video_source; } void VideoAnalyzer::CapturedFrameForwarder::OnFrame( @@ -872,8 +874,8 @@ void VideoAnalyzer::CapturedFrameForwarder::AddOrUpdateSink( RTC_DCHECK(!send_stream_input_ || send_stream_input_ == sink); send_stream_input_ = sink; } - if (video_capturer_) { - video_capturer_->AddOrUpdateSink(this, wants); + if (video_source_) { + video_source_->AddOrUpdateSink(this, wants); } } diff --git a/video/video_analyzer.h b/video/video_analyzer.h index d2c4fa84cd..fffc784cf2 100644 --- a/video/video_analyzer.h +++ b/video/video_analyzer.h @@ -16,10 +16,10 @@ #include #include +#include "api/video/video_source_interface.h" #include "test/layer_filtering_transport.h" #include "test/rtp_file_writer.h" #include "test/statistics.h" -#include "test/vcm_capturer.h" namespace webrtc { @@ -45,7 +45,7 @@ class VideoAnalyzer : public PacketReceiver, ~VideoAnalyzer(); virtual void SetReceiver(PacketReceiver* receiver); - void SetSource(test::TestVideoCapturer* video_capturer, + void SetSource(rtc::VideoSourceInterface* video_source, bool respect_sink_wants); void SetCall(Call* call); void SetSendStream(VideoSendStream* stream); @@ -136,7 +136,7 @@ class VideoAnalyzer : public PacketReceiver, public rtc::VideoSourceInterface { public: explicit CapturedFrameForwarder(VideoAnalyzer* analyzer, Clock* clock); - void SetSource(test::TestVideoCapturer* video_capturer); + void SetSource(rtc::VideoSourceInterface* video_source); private: void OnFrame(const VideoFrame& video_frame) override; @@ -152,7 +152,7 @@ class VideoAnalyzer : public PacketReceiver, rtc::CriticalSection crit_; rtc::VideoSinkInterface* send_stream_input_ RTC_GUARDED_BY(crit_); - test::TestVideoCapturer* video_capturer_; + VideoSourceInterface* video_source_; Clock* clock_; }; diff --git a/video/video_quality_test.cc b/video/video_quality_test.cc index 0f0fa95b62..274388a4d0 100644 --- a/video/video_quality_test.cc +++ b/video/video_quality_test.cc @@ -36,6 +36,7 @@ #include "rtc_base/strings/string_builder.h" #include "test/run_loop.h" #include "test/testsupport/fileutils.h" +#include "test/vcm_capturer.h" #include "test/video_renderer.h" #include "video/frame_dumping_decoder.h" #ifdef WEBRTC_WIN @@ -823,9 +824,9 @@ void VideoQualityTest::DestroyThumbnailStreams() { } thumbnail_send_streams_.clear(); thumbnail_receive_streams_.clear(); - for (std::unique_ptr& video_caputurer : + for (std::unique_ptr>& video_capturer : thumbnail_capturers_) { - video_caputurer.reset(); + video_capturer.reset(); } } @@ -887,8 +888,7 @@ std::unique_ptr VideoQualityTest::CreateFrameGenerator( void VideoQualityTest::CreateCapturers() { RTC_DCHECK(video_sources_.empty()); - RTC_DCHECK(video_capturers_.empty()); - video_capturers_.resize(num_video_streams_); + video_sources_.resize(num_video_streams_); for (size_t video_idx = 0; video_idx < num_video_streams_; ++video_idx) { if (params_.screenshare[video_idx].enabled) { std::unique_ptr frame_generator = @@ -897,53 +897,50 @@ void VideoQualityTest::CreateCapturers() { new test::FrameGeneratorCapturer(clock_, std::move(frame_generator), params_.video[video_idx].fps); EXPECT_TRUE(frame_generator_capturer->Init()); - video_capturers_[video_idx].reset(frame_generator_capturer); + video_sources_[video_idx].reset(frame_generator_capturer); } else { if (params_.video[video_idx].clip_name == "Generator") { - video_capturers_[video_idx].reset(test::FrameGeneratorCapturer::Create( + video_sources_[video_idx].reset(test::FrameGeneratorCapturer::Create( static_cast(params_.video[video_idx].width), static_cast(params_.video[video_idx].height), absl::nullopt, absl::nullopt, params_.video[video_idx].fps, clock_)); } else if (params_.video[video_idx].clip_name == "GeneratorI420A") { - video_capturers_[video_idx].reset(test::FrameGeneratorCapturer::Create( + video_sources_[video_idx].reset(test::FrameGeneratorCapturer::Create( static_cast(params_.video[video_idx].width), static_cast(params_.video[video_idx].height), test::FrameGenerator::OutputType::I420A, absl::nullopt, params_.video[video_idx].fps, clock_)); } else if (params_.video[video_idx].clip_name == "GeneratorI010") { - video_capturers_[video_idx].reset(test::FrameGeneratorCapturer::Create( + video_sources_[video_idx].reset(test::FrameGeneratorCapturer::Create( static_cast(params_.video[video_idx].width), static_cast(params_.video[video_idx].height), test::FrameGenerator::OutputType::I010, absl::nullopt, params_.video[video_idx].fps, clock_)); } else if (params_.video[video_idx].clip_name.empty()) { - video_capturers_[video_idx].reset(test::VcmCapturer::Create( + video_sources_[video_idx].reset(test::VcmCapturer::Create( params_.video[video_idx].width, params_.video[video_idx].height, params_.video[video_idx].fps, params_.video[video_idx].capture_device_index)); - if (!video_capturers_[video_idx]) { + if (!video_sources_[video_idx]) { // Failed to get actual camera, use chroma generator as backup. - video_capturers_[video_idx].reset( - test::FrameGeneratorCapturer::Create( - static_cast(params_.video[video_idx].width), - static_cast(params_.video[video_idx].height), - absl::nullopt, absl::nullopt, params_.video[video_idx].fps, - clock_)); + video_sources_[video_idx].reset(test::FrameGeneratorCapturer::Create( + static_cast(params_.video[video_idx].width), + static_cast(params_.video[video_idx].height), absl::nullopt, + absl::nullopt, params_.video[video_idx].fps, clock_)); } } else { - video_capturers_[video_idx].reset( + video_sources_[video_idx].reset( test::FrameGeneratorCapturer::CreateFromYuvFile( test::ResourcePath(params_.video[video_idx].clip_name, "yuv"), params_.video[video_idx].width, params_.video[video_idx].height, params_.video[video_idx].fps, clock_)); - ASSERT_TRUE(video_capturers_[video_idx]) + ASSERT_TRUE(video_sources_[video_idx]) << "Could not create capturer for " << params_.video[video_idx].clip_name << ".yuv. Is this resource file present?"; } } - RTC_DCHECK(video_capturers_[video_idx].get()); - video_sources_.push_back(video_capturers_[video_idx].get()); + RTC_DCHECK(video_sources_[video_idx]); } } @@ -1102,12 +1099,11 @@ void VideoQualityTest::RunWithAnalyzer(const Params& params) { CreateCapturers(); - analyzer_->SetSource(video_capturers_[0].get(), - params_.ss[0].infer_streams); + analyzer_->SetSource(video_sources_[0].get(), params_.ss[0].infer_streams); for (size_t video_idx = 1; video_idx < num_video_streams_; ++video_idx) { - video_send_streams_[video_idx]->SetSource( - video_capturers_[video_idx].get(), degradation_preference_); + video_send_streams_[video_idx]->SetSource(video_sources_[video_idx].get(), + degradation_preference_); } if (params_.audio.enabled) { @@ -1132,7 +1128,7 @@ void VideoQualityTest::RunWithAnalyzer(const Params& params) { if (graph_data_output_file) fclose(graph_data_output_file); - video_capturers_.clear(); + video_sources_.clear(); send_transport.reset(); recv_transport.reset(); @@ -1350,7 +1346,7 @@ void VideoQualityTest::RunWithRenderers(const Params& params) { Stop(); DestroyStreams(); - video_capturers_.clear(); + video_sources_.clear(); send_transport.reset(); recv_transport.reset(); diff --git a/video/video_quality_test.h b/video/video_quality_test.h index ab6ef2d477..51686ec3cb 100644 --- a/video/video_quality_test.h +++ b/video/video_quality_test.h @@ -97,7 +97,8 @@ class VideoQualityTest : virtual std::unique_ptr CreateSendTransport(); virtual std::unique_ptr CreateReceiveTransport(); - std::vector> thumbnail_capturers_; + std::vector>> + thumbnail_capturers_; Clock* const clock_; test::FunctionVideoDecoderFactory video_decoder_factory_;