From 48a4d33719390b7bcaf8445a1581a00825f67bfb Mon Sep 17 00:00:00 2001 From: Mirko Bonadei Date: Mon, 3 May 2021 12:41:10 +0000 Subject: [PATCH] Revert "Remove Invoke from VideoChannel::FillBitrateInfo." This reverts commit 1a1795768e1bdb65054ebe15aa238c6edc78dd14. Reason for revert: Speculative revert (breaks downstream project). Original change's description: > Remove Invoke from VideoChannel::FillBitrateInfo. > > The method is relied upon by StatsCollector where it was called from the > signaling thread in a loop. Now there's at most one invoke (not N). > > Uncommenting thread checks and removing TODOs in SendStatisticsProxy, > VideoSendStream. Updating all related tests that fetched stats from > the wrong context. > > Bug: webrtc:12726 > Change-Id: Ia7db1afd7e103ec4f9816f5647203c4e2495586e > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/216688 > Commit-Queue: Tommi > Reviewed-by: Niels Moller > Reviewed-by: Ilya Nikolaevskiy > Cr-Commit-Position: refs/heads/master@{#33894} TBR=ilnik@webrtc.org,nisse@webrtc.org,tommi@webrtc.org,webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com Change-Id: I2520957cdb33492d187f04320c7416788fd0f820 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:12726 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/217240 Reviewed-by: Mirko Bonadei Commit-Queue: Mirko Bonadei Cr-Commit-Position: refs/heads/master@{#33898} --- call/call_perf_tests.cc | 54 ++++++++------------ call/rampup_tests.cc | 5 +- common_video/h264/h264_bitstream_parser.cc | 6 +-- pc/channel.cc | 4 +- pc/stats_collector.cc | 17 ++----- test/scenario/scenario_unittest.cc | 6 +-- test/scenario/stats_collection_unittest.cc | 10 +--- test/scenario/video_stream_unittest.cc | 10 ++-- video/end_to_end_tests/ssrc_tests.cc | 15 ++---- video/end_to_end_tests/stats_tests.cc | 5 +- video/send_statistics_proxy.cc | 1 - video/video_send_stream.cc | 14 ++++-- video/video_send_stream_tests.cc | 58 +++++++--------------- 13 files changed, 71 insertions(+), 134 deletions(-) diff --git a/call/call_perf_tests.cc b/call/call_perf_tests.cc index c163ab2fe7..47d6e90159 100644 --- a/call/call_perf_tests.cc +++ b/call/call_perf_tests.cc @@ -654,8 +654,7 @@ void CallPerfTest::TestMinTransmitBitrate(bool pad_to_min_bitrate) { static const int kAcceptableBitrateErrorMargin = 15; // +- 7 class BitrateObserver : public test::EndToEndTest { public: - explicit BitrateObserver(bool using_min_transmit_bitrate, - TaskQueueBase* task_queue) + explicit BitrateObserver(bool using_min_transmit_bitrate) : EndToEndTest(kLongTimeoutMs), send_stream_(nullptr), converged_(false), @@ -668,31 +667,27 @@ void CallPerfTest::TestMinTransmitBitrate(bool pad_to_min_bitrate) { ? kMaxAcceptableTransmitBitrate : (kMaxEncodeBitrateKbps + kAcceptableBitrateErrorMargin / 2)), - num_bitrate_observations_in_range_(0), - task_queue_(task_queue) {} + num_bitrate_observations_in_range_(0) {} private: // TODO(holmer): Run this with a timer instead of once per packet. Action OnSendRtp(const uint8_t* packet, size_t length) override { - task_queue_->PostTask(ToQueuedTask([this]() { - VideoSendStream::Stats stats = send_stream_->GetStats(); - - if (!stats.substreams.empty()) { - RTC_DCHECK_EQ(1, stats.substreams.size()); - int bitrate_kbps = - stats.substreams.begin()->second.total_bitrate_bps / 1000; - if (bitrate_kbps > min_acceptable_bitrate_ && - bitrate_kbps < max_acceptable_bitrate_) { - converged_ = true; - ++num_bitrate_observations_in_range_; - if (num_bitrate_observations_in_range_ == - kNumBitrateObservationsInRange) - observation_complete_.Set(); - } - if (converged_) - bitrate_kbps_list_.push_back(bitrate_kbps); + VideoSendStream::Stats stats = send_stream_->GetStats(); + if (!stats.substreams.empty()) { + RTC_DCHECK_EQ(1, stats.substreams.size()); + int bitrate_kbps = + stats.substreams.begin()->second.total_bitrate_bps / 1000; + if (bitrate_kbps > min_acceptable_bitrate_ && + bitrate_kbps < max_acceptable_bitrate_) { + converged_ = true; + ++num_bitrate_observations_in_range_; + if (num_bitrate_observations_in_range_ == + kNumBitrateObservationsInRange) + observation_complete_.Set(); } - })); + if (converged_) + bitrate_kbps_list_.push_back(bitrate_kbps); + } return SEND_PACKET; } @@ -729,8 +724,7 @@ void CallPerfTest::TestMinTransmitBitrate(bool pad_to_min_bitrate) { const int max_acceptable_bitrate_; int num_bitrate_observations_in_range_; std::vector bitrate_kbps_list_; - TaskQueueBase* task_queue_; - } test(pad_to_min_bitrate, task_queue()); + } test(pad_to_min_bitrate); fake_encoder_max_bitrate_ = kMaxEncodeBitrateKbps; RunBaseTest(&test); @@ -781,7 +775,7 @@ TEST_F(CallPerfTest, MAYBE_KeepsHighBitrateWhenReconfiguringSender) { class BitrateObserver : public test::EndToEndTest, public test::FakeEncoder { public: - explicit BitrateObserver(TaskQueueBase* task_queue) + BitrateObserver() : EndToEndTest(kDefaultTimeoutMs), FakeEncoder(Clock::GetRealTimeClock()), encoder_inits_(0), @@ -790,8 +784,7 @@ TEST_F(CallPerfTest, MAYBE_KeepsHighBitrateWhenReconfiguringSender) { frame_generator_(nullptr), encoder_factory_(this), bitrate_allocator_factory_( - CreateBuiltinVideoBitrateAllocatorFactory()), - task_queue_(task_queue) {} + CreateBuiltinVideoBitrateAllocatorFactory()) {} int32_t InitEncode(const VideoCodec* config, const VideoEncoder::Settings& settings) override { @@ -861,9 +854,7 @@ TEST_F(CallPerfTest, MAYBE_KeepsHighBitrateWhenReconfiguringSender) { ASSERT_TRUE(time_to_reconfigure_.Wait(kDefaultTimeoutMs)) << "Timed out before receiving an initial high bitrate."; frame_generator_->ChangeResolution(kDefaultWidth * 2, kDefaultHeight * 2); - SendTask(RTC_FROM_HERE, task_queue_, [&]() { - send_stream_->ReconfigureVideoEncoder(encoder_config_.Copy()); - }); + send_stream_->ReconfigureVideoEncoder(encoder_config_.Copy()); EXPECT_TRUE(Wait()) << "Timed out while waiting for a couple of high bitrate estimates " "after reconfiguring the send stream."; @@ -878,8 +869,7 @@ TEST_F(CallPerfTest, MAYBE_KeepsHighBitrateWhenReconfiguringSender) { test::VideoEncoderProxyFactory encoder_factory_; std::unique_ptr bitrate_allocator_factory_; VideoEncoderConfig encoder_config_; - TaskQueueBase* task_queue_; - } test(task_queue()); + } test; RunBaseTest(&test); } diff --git a/call/rampup_tests.cc b/call/rampup_tests.cc index 37e3e6c7f6..e2ea55b8da 100644 --- a/call/rampup_tests.cc +++ b/call/rampup_tests.cc @@ -370,10 +370,7 @@ void RampUpTester::TriggerTestDone() { if (!send_stream_) return; - VideoSendStream::Stats send_stats; - SendTask(RTC_FROM_HERE, task_queue_, - [&] { send_stats = send_stream_->GetStats(); }); - + VideoSendStream::Stats send_stats = send_stream_->GetStats(); send_stream_ = nullptr; // To avoid dereferencing a bad pointer. size_t total_packets_sent = 0; diff --git a/common_video/h264/h264_bitstream_parser.cc b/common_video/h264/h264_bitstream_parser.cc index f0bc8bb5bf..b0ada92d74 100644 --- a/common_video/h264/h264_bitstream_parser.cc +++ b/common_video/h264/h264_bitstream_parser.cc @@ -275,14 +275,14 @@ void H264BitstreamParser::ParseSlice(const uint8_t* slice, size_t length) { sps_ = SpsParser::ParseSps(slice + H264::kNaluTypeSize, length - H264::kNaluTypeSize); if (!sps_) - RTC_DLOG(LS_WARNING) << "Unable to parse SPS from H264 bitstream."; + RTC_LOG(LS_WARNING) << "Unable to parse SPS from H264 bitstream."; break; } case H264::NaluType::kPps: { pps_ = PpsParser::ParsePps(slice + H264::kNaluTypeSize, length - H264::kNaluTypeSize); if (!pps_) - RTC_DLOG(LS_WARNING) << "Unable to parse PPS from H264 bitstream."; + RTC_LOG(LS_WARNING) << "Unable to parse PPS from H264 bitstream."; break; } case H264::NaluType::kAud: @@ -291,7 +291,7 @@ void H264BitstreamParser::ParseSlice(const uint8_t* slice, size_t length) { default: Result res = ParseNonParameterSetNalu(slice, length, nalu_type); if (res != kOk) - RTC_DLOG(LS_INFO) << "Failed to parse bitstream. Error: " << res; + RTC_LOG(LS_INFO) << "Failed to parse bitstream. Error: " << res; break; } } diff --git a/pc/channel.cc b/pc/channel.cc index 089b189ed6..0ed5665dae 100644 --- a/pc/channel.cc +++ b/pc/channel.cc @@ -1067,9 +1067,9 @@ void VideoChannel::UpdateMediaSendRecvState_w() { } void VideoChannel::FillBitrateInfo(BandwidthEstimationInfo* bwe_info) { - RTC_DCHECK_RUN_ON(worker_thread()); VideoMediaChannel* mc = media_channel(); - mc->FillBitrateInfo(bwe_info); + InvokeOnWorker(RTC_FROM_HERE, + [mc, bwe_info] { mc->FillBitrateInfo(bwe_info); }); } bool VideoChannel::SetLocalContent_w(const MediaContentDescription* content, diff --git a/pc/stats_collector.cc b/pc/stats_collector.cc index 864876435d..8955729192 100644 --- a/pc/stats_collector.cc +++ b/pc/stats_collector.cc @@ -1026,25 +1026,16 @@ void StatsCollector::ExtractBweInfo() { // Fill in target encoder bitrate, actual encoder bitrate, rtx bitrate, etc. // TODO(holmer): Also fill this in for audio. - auto transceivers = pc_->GetTransceiversInternal(); - std::vector video_channels; - for (const auto& transceiver : transceivers) { + for (const auto& transceiver : pc_->GetTransceiversInternal()) { if (transceiver->media_type() != cricket::MEDIA_TYPE_VIDEO) { continue; } auto* video_channel = static_cast(transceiver->internal()->channel()); - if (video_channel) { - video_channels.push_back(video_channel); + if (!video_channel) { + continue; } - } - - if (!video_channels.empty()) { - pc_->worker_thread()->Invoke(RTC_FROM_HERE, [&] { - for (const auto& channel : video_channels) { - channel->FillBitrateInfo(&bwe_info); - } - }); + video_channel->FillBitrateInfo(&bwe_info); } StatsReport::Id report_id(StatsReport::NewBandwidthEstimationId()); diff --git a/test/scenario/scenario_unittest.cc b/test/scenario/scenario_unittest.cc index 6861151a2d..fc370fba77 100644 --- a/test/scenario/scenario_unittest.cc +++ b/test/scenario/scenario_unittest.cc @@ -182,11 +182,7 @@ TEST(ScenarioTest, s.RunFor(TimeDelta::Seconds(10)); // Make sure retransmissions have happened. int retransmit_packets = 0; - - VideoSendStream::Stats stats; - alice->SendTask([&]() { stats = video->send()->GetStats(); }); - - for (const auto& substream : stats.substreams) { + for (const auto& substream : video->send()->GetStats().substreams) { retransmit_packets += substream.second.rtp_stats.retransmitted.packets; } EXPECT_GT(retransmit_packets, 0); diff --git a/test/scenario/stats_collection_unittest.cc b/test/scenario/stats_collection_unittest.cc index 96b2830c76..593cecdaae 100644 --- a/test/scenario/stats_collection_unittest.cc +++ b/test/scenario/stats_collection_unittest.cc @@ -33,14 +33,8 @@ void CreateAnalyzedStream(Scenario* s, auto* audio = s->CreateAudioStream(route->forward(), AudioStreamConfig()); s->Every(TimeDelta::Seconds(1), [=] { collectors->call.AddStats(caller->GetStats()); - - VideoSendStream::Stats send_stats; - caller->SendTask([&]() { send_stats = video->send()->GetStats(); }); - collectors->video_send.AddStats(send_stats, s->Now()); - - AudioReceiveStream::Stats receive_stats; - caller->SendTask([&]() { receive_stats = audio->receive()->GetStats(); }); - collectors->audio_receive.AddStats(receive_stats); + collectors->video_send.AddStats(video->send()->GetStats(), s->Now()); + collectors->audio_receive.AddStats(audio->receive()->GetStats()); // Querying the video stats from within the expected runtime environment // (i.e. the TQ that belongs to the CallClient, not the Scenario TQ that diff --git a/test/scenario/video_stream_unittest.cc b/test/scenario/video_stream_unittest.cc index c1649a39b3..95936c763f 100644 --- a/test/scenario/video_stream_unittest.cc +++ b/test/scenario/video_stream_unittest.cc @@ -130,9 +130,7 @@ TEST(VideoStreamTest, SendsNacksOnLoss) { auto video = s.CreateVideoStream(route->forward(), VideoStreamConfig()); s.RunFor(TimeDelta::Seconds(1)); int retransmit_packets = 0; - VideoSendStream::Stats stats; - route->first()->SendTask([&]() { stats = video->send()->GetStats(); }); - for (const auto& substream : stats.substreams) { + for (const auto& substream : video->send()->GetStats().substreams) { retransmit_packets += substream.second.rtp_stats.retransmitted.packets; } EXPECT_GT(retransmit_packets, 0); @@ -154,8 +152,7 @@ TEST(VideoStreamTest, SendsFecWithUlpFec) { c->stream.use_ulpfec = true; }); s.RunFor(TimeDelta::Seconds(5)); - VideoSendStream::Stats video_stats; - route->first()->SendTask([&]() { video_stats = video->send()->GetStats(); }); + VideoSendStream::Stats video_stats = video->send()->GetStats(); EXPECT_GT(video_stats.substreams.begin()->second.rtp_stats.fec.packets, 0u); } TEST(VideoStreamTest, SendsFecWithFlexFec) { @@ -172,8 +169,7 @@ TEST(VideoStreamTest, SendsFecWithFlexFec) { c->stream.use_flexfec = true; }); s.RunFor(TimeDelta::Seconds(5)); - VideoSendStream::Stats video_stats; - route->first()->SendTask([&]() { video_stats = video->send()->GetStats(); }); + VideoSendStream::Stats video_stats = video->send()->GetStats(); EXPECT_GT(video_stats.substreams.begin()->second.rtp_stats.fec.packets, 0u); } diff --git a/video/end_to_end_tests/ssrc_tests.cc b/video/end_to_end_tests/ssrc_tests.cc index 0c26311e92..cedae3934d 100644 --- a/video/end_to_end_tests/ssrc_tests.cc +++ b/video/end_to_end_tests/ssrc_tests.cc @@ -132,15 +132,13 @@ void SsrcEndToEndTest::TestSendsSetSsrcs(size_t num_ssrcs, public: SendsSetSsrcs(const uint32_t* ssrcs, size_t num_ssrcs, - bool send_single_ssrc_first, - TaskQueueBase* task_queue) + bool send_single_ssrc_first) : EndToEndTest(kDefaultTimeoutMs), num_ssrcs_(num_ssrcs), send_single_ssrc_first_(send_single_ssrc_first), ssrcs_to_observe_(num_ssrcs), expect_single_ssrc_(send_single_ssrc_first), - send_stream_(nullptr), - task_queue_(task_queue) { + send_stream_(nullptr) { for (size_t i = 0; i < num_ssrcs; ++i) valid_ssrcs_[ssrcs[i]] = true; } @@ -202,10 +200,8 @@ void SsrcEndToEndTest::TestSendsSetSsrcs(size_t num_ssrcs, if (send_single_ssrc_first_) { // Set full simulcast and continue with the rest of the SSRCs. - SendTask(RTC_FROM_HERE, task_queue_, [&]() { - send_stream_->ReconfigureVideoEncoder( - std::move(video_encoder_config_all_streams_)); - }); + send_stream_->ReconfigureVideoEncoder( + std::move(video_encoder_config_all_streams_)); EXPECT_TRUE(Wait()) << "Timed out while waiting on additional SSRCs."; } } @@ -222,8 +218,7 @@ void SsrcEndToEndTest::TestSendsSetSsrcs(size_t num_ssrcs, VideoSendStream* send_stream_; VideoEncoderConfig video_encoder_config_all_streams_; - TaskQueueBase* task_queue_; - } test(kVideoSendSsrcs, num_ssrcs, send_single_ssrc_first, task_queue()); + } test(kVideoSendSsrcs, num_ssrcs, send_single_ssrc_first); RunBaseTest(&test); } diff --git a/video/end_to_end_tests/stats_tests.cc b/video/end_to_end_tests/stats_tests.cc index 349f5510e9..ae0532b9a3 100644 --- a/video/end_to_end_tests/stats_tests.cc +++ b/video/end_to_end_tests/stats_tests.cc @@ -154,10 +154,7 @@ TEST_F(StatsEndToEndTest, GetStats) { bool CheckSendStats() { RTC_DCHECK(send_stream_); - - VideoSendStream::Stats stats; - SendTask(RTC_FROM_HERE, task_queue_, - [&]() { stats = send_stream_->GetStats(); }); + VideoSendStream::Stats stats = send_stream_->GetStats(); size_t expected_num_streams = kNumSimulcastStreams + expected_send_ssrcs_.size(); diff --git a/video/send_statistics_proxy.cc b/video/send_statistics_proxy.cc index 6752abe11c..686b756776 100644 --- a/video/send_statistics_proxy.cc +++ b/video/send_statistics_proxy.cc @@ -670,7 +670,6 @@ void SendStatisticsProxy::UmaSamplesContainer::UpdateHistograms( void SendStatisticsProxy::OnEncoderReconfigured( const VideoEncoderConfig& config, const std::vector& streams) { - // Called on VideoStreamEncoder's encoder_queue_. MutexLock lock(&mutex_); if (content_type_ != config.content_type) { diff --git a/video/video_send_stream.cc b/video/video_send_stream.cc index 386a7177cb..91c246c66e 100644 --- a/video/video_send_stream.cc +++ b/video/video_send_stream.cc @@ -169,7 +169,7 @@ void VideoSendStream::UpdateActiveSimulcastLayers( void VideoSendStream::Start() { RTC_DCHECK_RUN_ON(&thread_checker_); - RTC_DLOG(LS_INFO) << "VideoSendStream::Start"; + RTC_LOG(LS_INFO) << "VideoSendStream::Start"; VideoSendStreamImpl* send_stream = send_stream_.get(); worker_queue_->PostTask([this, send_stream] { send_stream->Start(); @@ -184,7 +184,7 @@ void VideoSendStream::Start() { void VideoSendStream::Stop() { RTC_DCHECK_RUN_ON(&thread_checker_); - RTC_DLOG(LS_INFO) << "VideoSendStream::Stop"; + RTC_LOG(LS_INFO) << "VideoSendStream::Stop"; VideoSendStreamImpl* send_stream = send_stream_.get(); worker_queue_->PostTask([send_stream] { send_stream->Stop(); }); } @@ -209,15 +209,19 @@ void VideoSendStream::SetSource( } void VideoSendStream::ReconfigureVideoEncoder(VideoEncoderConfig config) { - RTC_DCHECK_RUN_ON(&thread_checker_); - RTC_DCHECK_EQ(content_type_, config.content_type); + // TODO(perkj): Some test cases in VideoSendStreamTest call + // ReconfigureVideoEncoder from the network thread. + // RTC_DCHECK_RUN_ON(&thread_checker_); + RTC_DCHECK(content_type_ == config.content_type); video_stream_encoder_->ConfigureEncoder( std::move(config), config_.rtp.max_packet_size - CalculateMaxHeaderSize(config_.rtp)); } VideoSendStream::Stats VideoSendStream::GetStats() { - RTC_DCHECK_RUN_ON(&thread_checker_); + // TODO(perkj, solenberg): Some test cases in EndToEndTest call GetStats from + // a network thread. See comment in Call::GetStats(). + // RTC_DCHECK_RUN_ON(&thread_checker_); return stats_proxy_.GetStats(); } diff --git a/video/video_send_stream_tests.cc b/video/video_send_stream_tests.cc index 78265cc7dc..ba24441c06 100644 --- a/video/video_send_stream_tests.cc +++ b/video/video_send_stream_tests.cc @@ -1474,9 +1474,7 @@ TEST_F(VideoSendStreamTest, MinTransmitBitrateRespectsRemb) { if (!rtp_packet.Parse(packet, length)) return DROP_PACKET; RTC_DCHECK(stream_); - VideoSendStream::Stats stats; - SendTask(RTC_FROM_HERE, task_queue_, - [&]() { stats = stream_->GetStats(); }); + VideoSendStream::Stats stats = stream_->GetStats(); if (!stats.substreams.empty()) { EXPECT_EQ(1u, stats.substreams.size()); int total_bitrate_bps = @@ -2424,16 +2422,14 @@ class VideoCodecConfigObserver : public test::SendTest, public test::FakeEncoder { public: VideoCodecConfigObserver(VideoCodecType video_codec_type, - const char* codec_name, - TaskQueueBase* task_queue) + const char* codec_name) : SendTest(VideoSendStreamTest::kDefaultTimeoutMs), FakeEncoder(Clock::GetRealTimeClock()), video_codec_type_(video_codec_type), codec_name_(codec_name), num_initializations_(0), stream_(nullptr), - encoder_factory_(this), - task_queue_(task_queue) { + encoder_factory_(this) { InitCodecSpecifics(); } @@ -2481,9 +2477,7 @@ class VideoCodecConfigObserver : public test::SendTest, // Change encoder settings to actually trigger reconfiguration. encoder_settings_.frameDroppingOn = !encoder_settings_.frameDroppingOn; encoder_config_.encoder_specific_settings = GetEncoderSpecificSettings(); - SendTask(RTC_FROM_HERE, task_queue_, [&]() { - stream_->ReconfigureVideoEncoder(std::move(encoder_config_)); - }); + stream_->ReconfigureVideoEncoder(std::move(encoder_config_)); ASSERT_TRUE( init_encode_event_.Wait(VideoSendStreamTest::kDefaultTimeoutMs)); EXPECT_EQ(2u, num_initializations_) @@ -2505,7 +2499,6 @@ class VideoCodecConfigObserver : public test::SendTest, VideoSendStream* stream_; test::VideoEncoderProxyFactory encoder_factory_; VideoEncoderConfig encoder_config_; - TaskQueueBase* task_queue_; }; template <> @@ -2611,14 +2604,12 @@ VideoCodecConfigObserver::GetEncoderSpecificSettings() const { } TEST_F(VideoSendStreamTest, EncoderSetupPropagatesVp8Config) { - VideoCodecConfigObserver test(kVideoCodecVP8, "VP8", - task_queue()); + VideoCodecConfigObserver test(kVideoCodecVP8, "VP8"); RunBaseTest(&test); } TEST_F(VideoSendStreamTest, EncoderSetupPropagatesVp9Config) { - VideoCodecConfigObserver test(kVideoCodecVP9, "VP9", - task_queue()); + VideoCodecConfigObserver test(kVideoCodecVP9, "VP9"); RunBaseTest(&test); } @@ -2630,8 +2621,7 @@ TEST_F(VideoSendStreamTest, EncoderSetupPropagatesVp9Config) { #define MAYBE_EncoderSetupPropagatesH264Config EncoderSetupPropagatesH264Config #endif TEST_F(VideoSendStreamTest, MAYBE_EncoderSetupPropagatesH264Config) { - VideoCodecConfigObserver test(kVideoCodecH264, "H264", - task_queue()); + VideoCodecConfigObserver test(kVideoCodecH264, "H264"); RunBaseTest(&test); } @@ -2914,9 +2904,7 @@ TEST_F(VideoSendStreamTest, ReconfigureBitratesSetsEncoderBitratesCorrectly) { // Encoder rate is capped by EncoderConfig max_bitrate_bps. WaitForSetRates(kMaxBitrateKbps); encoder_config_.max_bitrate_bps = kLowerMaxBitrateKbps * 1000; - SendTask(RTC_FROM_HERE, task_queue_, [&]() { - send_stream_->ReconfigureVideoEncoder(encoder_config_.Copy()); - }); + send_stream_->ReconfigureVideoEncoder(encoder_config_.Copy()); ASSERT_TRUE(create_rate_allocator_event_.Wait( VideoSendStreamTest::kDefaultTimeoutMs)); EXPECT_EQ(2, num_rate_allocator_creations_) @@ -2926,9 +2914,7 @@ TEST_F(VideoSendStreamTest, ReconfigureBitratesSetsEncoderBitratesCorrectly) { EXPECT_EQ(1, num_encoder_initializations_); encoder_config_.max_bitrate_bps = kIncreasedMaxBitrateKbps * 1000; - SendTask(RTC_FROM_HERE, task_queue_, [&]() { - send_stream_->ReconfigureVideoEncoder(encoder_config_.Copy()); - }); + send_stream_->ReconfigureVideoEncoder(encoder_config_.Copy()); ASSERT_TRUE(create_rate_allocator_event_.Wait( VideoSendStreamTest::kDefaultTimeoutMs)); EXPECT_EQ(3, num_rate_allocator_creations_) @@ -2969,12 +2955,11 @@ TEST_F(VideoSendStreamTest, ReportsSentResolution) { class ScreencastTargetBitrateTest : public test::SendTest, public test::FakeEncoder { public: - explicit ScreencastTargetBitrateTest(TaskQueueBase* task_queue) + ScreencastTargetBitrateTest() : SendTest(kDefaultTimeoutMs), test::FakeEncoder(Clock::GetRealTimeClock()), send_stream_(nullptr), - encoder_factory_(this), - task_queue_(task_queue) {} + encoder_factory_(this) {} private: int32_t Encode(const VideoFrame& input_image, @@ -3022,9 +3007,7 @@ TEST_F(VideoSendStreamTest, ReportsSentResolution) { void PerformTest() override { EXPECT_TRUE(Wait()) << "Timed out while waiting for the encoder to send one frame."; - VideoSendStream::Stats stats; - SendTask(RTC_FROM_HERE, task_queue_, - [&]() { stats = send_stream_->GetStats(); }); + VideoSendStream::Stats stats = send_stream_->GetStats(); for (size_t i = 0; i < kNumStreams; ++i) { ASSERT_TRUE(stats.substreams.find(kVideoSendSsrcs[i]) != @@ -3046,8 +3029,7 @@ TEST_F(VideoSendStreamTest, ReportsSentResolution) { VideoSendStream* send_stream_; test::VideoEncoderProxyFactory encoder_factory_; - TaskQueueBase* const task_queue_; - } test(task_queue()); + } test; RunBaseTest(&test); } @@ -3818,15 +3800,14 @@ class ContentSwitchTest : public test::SendTest { }; static const uint32_t kMinPacketsToSend = 50; - explicit ContentSwitchTest(T* stream_reset_fun, TaskQueueBase* task_queue) + explicit ContentSwitchTest(T* stream_reset_fun) : SendTest(test::CallTest::kDefaultTimeoutMs), call_(nullptr), state_(StreamState::kBeforeSwitch), send_stream_(nullptr), send_stream_config_(nullptr), packets_sent_(0), - stream_resetter_(stream_reset_fun), - task_queue_(task_queue) { + stream_resetter_(stream_reset_fun) { RTC_DCHECK(stream_resetter_); } @@ -3860,10 +3841,8 @@ class ContentSwitchTest : public test::SendTest { float pacing_factor = internal_send_peer.GetPacingFactorOverride().value_or(0.0f); float expected_pacing_factor = 1.1; // Strict pacing factor. - VideoSendStream::Stats stats; - SendTask(RTC_FROM_HERE, task_queue_, - [&stats, stream = send_stream_]() { stats = stream->GetStats(); }); - if (stats.content_type == webrtc::VideoContentType::SCREENSHARE) { + if (send_stream_->GetStats().content_type == + webrtc::VideoContentType::SCREENSHARE) { expected_pacing_factor = 1.0f; // Currently used pacing factor in ALR. } @@ -3931,7 +3910,6 @@ class ContentSwitchTest : public test::SendTest { VideoEncoderConfig encoder_config_; uint32_t packets_sent_ RTC_GUARDED_BY(mutex_); T* stream_resetter_; - TaskQueueBase* task_queue_; }; TEST_F(VideoSendStreamTest, SwitchesToScreenshareAndBack) { @@ -3951,7 +3929,7 @@ TEST_F(VideoSendStreamTest, SwitchesToScreenshareAndBack) { Start(); }); }; - ContentSwitchTest test(&reset_fun, task_queue()); + ContentSwitchTest test(&reset_fun); RunBaseTest(&test); }