From f92cc6d7b42d29efcb27161a53544eb2a149114b Mon Sep 17 00:00:00 2001 From: Artem Titov Date: Thu, 29 Jun 2023 14:56:59 +0200 Subject: [PATCH] Reland: FrameGeneratorCapturer: don't generate video before Start is called MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is partial reland, which adds call to Start() to all relevant places, but doesn't actually switches frame generator to not produce frames from the moment it was created. Bug: b/272350185 Change-Id: I6e3bd7af6f5cd8d9baff79c2aada7b2ddfae1c8d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/310782 Reviewed-by: Mirko Bonadei Reviewed-by: Ilya Nikolaevskiy Reviewed-by: Florent Castelli Commit-Queue: Artem Titov Reviewed-by: Erik Språng Cr-Commit-Position: refs/heads/main@{#40379} --- call/bitrate_estimator_tests.cc | 1 + pc/peer_connection_field_trial_tests.cc | 1 + pc/test/frame_generator_capturer_video_track_source.h | 10 ++++++++-- test/BUILD.gn | 1 + test/call_test.cc | 7 +++++++ test/call_test.h | 5 +++-- test/peer_scenario/peer_scenario_client.cc | 1 + test/scenario/video_stream.cc | 1 + video/end_to_end_tests/multi_codec_receive_tests.cc | 1 + video/end_to_end_tests/rtp_rtcp_tests.cc | 1 + 10 files changed, 25 insertions(+), 4 deletions(-) diff --git a/call/bitrate_estimator_tests.cc b/call/bitrate_estimator_tests.cc index f44cdfd509..f17a037ed2 100644 --- a/call/bitrate_estimator_tests.cc +++ b/call/bitrate_estimator_tests.cc @@ -186,6 +186,7 @@ class BitrateEstimatorTest : public test::CallTest { test::VideoTestConstants::kDefaultFramerate, *test->task_queue_factory_); frame_generator_capturer_->Init(); + frame_generator_capturer_->Start(); send_stream_->SetSource(frame_generator_capturer_.get(), DegradationPreference::MAINTAIN_FRAMERATE); send_stream_->Start(); diff --git a/pc/peer_connection_field_trial_tests.cc b/pc/peer_connection_field_trial_tests.cc index c3b3a2db7f..7799c9d6e3 100644 --- a/pc/peer_connection_field_trial_tests.cc +++ b/pc/peer_connection_field_trial_tests.cc @@ -237,6 +237,7 @@ TEST_F(PeerConnectionFieldTrialTest, ApplyFakeNetworkConfig) { auto video_track_source = rtc::make_ref_counted( config, clock_, /*is_screencast=*/false); + video_track_source->Start(); caller->AddTrack(pc_factory_->CreateVideoTrack(video_track_source, "v")); WrapperPtr callee = CreatePeerConnection(); diff --git a/pc/test/frame_generator_capturer_video_track_source.h b/pc/test/frame_generator_capturer_video_track_source.h index 50a3d26c2e..79a5b3474a 100644 --- a/pc/test/frame_generator_capturer_video_track_source.h +++ b/pc/test/frame_generator_capturer_video_track_source.h @@ -64,9 +64,15 @@ class FrameGeneratorCapturerVideoTrackSource : public VideoTrackSource { ~FrameGeneratorCapturerVideoTrackSource() = default; - void Start() { SetState(kLive); } + void Start() { + SetState(kLive); + video_capturer_->Start(); + } - void Stop() { SetState(kMuted); } + void Stop() { + SetState(kMuted); + video_capturer_->Stop(); + } bool is_screencast() const override { return is_screencast_; } diff --git a/test/BUILD.gn b/test/BUILD.gn index 3a0a35926f..5187205a0a 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -1260,6 +1260,7 @@ if (!build_with_chromium) { ":run_loop", ":scoped_key_value_config", ":test_support", + ":test_video_capturer", ":video_test_common", ":video_test_constants", "../api:array_view", diff --git a/test/call_test.cc b/test/call_test.cc index 7a1bbd2969..b8a1cd76b8 100644 --- a/test/call_test.cc +++ b/test/call_test.cc @@ -634,7 +634,14 @@ void CallTest::Start() { audio_recv_stream->Start(); } +void CallTest::StartVideoSources() { + for (size_t i = 0; i < video_sources_.size(); ++i) { + video_sources_[i]->Start(); + } +} + void CallTest::StartVideoStreams() { + StartVideoSources(); for (size_t i = 0; i < video_send_streams_.size(); ++i) { std::vector active_rtp_streams( video_send_configs_[i].rtp.ssrcs.size(), true); diff --git a/test/call_test.h b/test/call_test.h index 41db9cefd1..08d0e49a68 100644 --- a/test/call_test.h +++ b/test/call_test.h @@ -36,6 +36,7 @@ #include "test/rtp_rtcp_observer.h" #include "test/run_loop.h" #include "test/scoped_key_value_config.h" +#include "test/test_video_capturer.h" #include "test/video_test_constants.h" namespace webrtc { @@ -162,6 +163,7 @@ class CallTest : public ::testing::Test, public RtpPacketSinkInterface { void ConnectVideoSourcesToStreams(); void Start(); + void StartVideoSources(); void StartVideoStreams(); void Stop(); void StopVideoStreams(); @@ -210,8 +212,7 @@ class CallTest : public ::testing::Test, public RtpPacketSinkInterface { std::vector flexfec_receive_streams_; test::FrameGeneratorCapturer* frame_generator_capturer_; - std::vector>> - video_sources_; + std::vector> video_sources_; DegradationPreference degradation_preference_ = DegradationPreference::MAINTAIN_FRAMERATE; diff --git a/test/peer_scenario/peer_scenario_client.cc b/test/peer_scenario/peer_scenario_client.cc index 3419b9e069..697bf055a7 100644 --- a/test/peer_scenario/peer_scenario_client.cc +++ b/test/peer_scenario/peer_scenario_client.cc @@ -338,6 +338,7 @@ PeerScenarioClient::VideoSendTrack PeerScenarioClient::CreateVideo( capturer->Init(); res.source = rtc::make_ref_counted( std::move(capturer), config.screencast); + res.source->Start(); auto track = pc_factory_->CreateVideoTrack(res.source, track_id); res.track = track.get(); res.sender = diff --git a/test/scenario/video_stream.cc b/test/scenario/video_stream.cc index ec139763c8..e082aa37c6 100644 --- a/test/scenario/video_stream.cc +++ b/test/scenario/video_stream.cc @@ -419,6 +419,7 @@ SendVideoStream::SendVideoStream(CallClient* sender, send_config.suspend_below_min_bitrate = config.encoder.suspend_below_min_bitrate; + video_capturer_->Start(); sender_->SendTask([&] { if (config.stream.fec_controller_factory) { send_stream_ = sender_->call_->CreateVideoSendStream( diff --git a/video/end_to_end_tests/multi_codec_receive_tests.cc b/video/end_to_end_tests/multi_codec_receive_tests.cc index 377209b8a5..2d8bf0586d 100644 --- a/video/end_to_end_tests/multi_codec_receive_tests.cc +++ b/video/end_to_end_tests/multi_codec_receive_tests.cc @@ -254,6 +254,7 @@ void MultiCodecReceiveTest::RunTestWithCodecs( GetVideoSendStream()->Start(); CreateFrameGeneratorCapturer(kFps, kWidth / 2, kHeight / 2); ConnectVideoSourcesToStreams(); + StartVideoSources(); }); EXPECT_TRUE(observer_.Wait()) << "Timed out waiting for frames."; } diff --git a/video/end_to_end_tests/rtp_rtcp_tests.cc b/video/end_to_end_tests/rtp_rtcp_tests.cc index 009a3878fb..fbd8585907 100644 --- a/video/end_to_end_tests/rtp_rtcp_tests.cc +++ b/video/end_to_end_tests/rtp_rtcp_tests.cc @@ -339,6 +339,7 @@ void RtpRtcpEndToEndTest::TestRtpStatePreservation( ->SendRtcp(packet.data(), packet.size()); } CreateFrameGeneratorCapturer(30, 1280, 720); + StartVideoSources(); }); observer.ResetExpectedSsrcs(1);