diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
commit | 8dd16259287f58f9273002717ec4d27e97127719 (patch) | |
tree | 3863e62a53829a84037444beab3abd4ed9dfc7d0 /third_party/libwebrtc/video | |
parent | Releasing progress-linux version 126.0.1-1~progress7.99u1. (diff) | |
download | firefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz firefox-8dd16259287f58f9273002717ec4d27e97127719.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/video')
13 files changed, 270 insertions, 181 deletions
diff --git a/third_party/libwebrtc/video/BUILD.gn b/third_party/libwebrtc/video/BUILD.gn index 2d6d8ab10c..b97d4af5bb 100644 --- a/third_party/libwebrtc/video/BUILD.gn +++ b/third_party/libwebrtc/video/BUILD.gn @@ -519,6 +519,7 @@ if (rtc_include_tests) { "../api:rtc_event_log_output_file", "../api:test_dependency_factory", "../api:video_quality_test_fixture_api", + "../api/environment", "../api/numerics", "../api/rtc_event_log:rtc_event_log_factory", "../api/task_queue", @@ -830,6 +831,7 @@ if (rtc_include_tests) { "../api:libjingle_peerconnection_api", "../api:mock_fec_controller_override", "../api:mock_frame_decryptor", + "../api:mock_frame_transformer", "../api:mock_video_codec_factory", "../api:mock_video_decoder", "../api:mock_video_encoder", @@ -947,7 +949,6 @@ if (rtc_include_tests) { "../test:fileutils", "../test:frame_generator_capturer", "../test:frame_utils", - "../test:mock_frame_transformer", "../test:mock_transport", "../test:null_transport", "../test:rtp_test_utils", diff --git a/third_party/libwebrtc/video/end_to_end_tests/codec_tests.cc b/third_party/libwebrtc/video/end_to_end_tests/codec_tests.cc index 60a0bc8a15..e9ec7d541f 100644 --- a/third_party/libwebrtc/video/end_to_end_tests/codec_tests.cc +++ b/third_party/libwebrtc/video/end_to_end_tests/codec_tests.cc @@ -196,9 +196,11 @@ TEST_F(CodecEndToEndTest, SendsAndReceivesMultiplex) { &internal_encoder_factory, SdpVideoFormat(cricket::kVp9CodecName)); }); test::FunctionVideoDecoderFactory decoder_factory( - [&internal_decoder_factory]() { + [&internal_decoder_factory](const Environment& env, + const SdpVideoFormat& /*format*/) { return std::make_unique<MultiplexDecoderAdapter>( - &internal_decoder_factory, SdpVideoFormat(cricket::kVp9CodecName)); + env, &internal_decoder_factory, + SdpVideoFormat(cricket::kVp9CodecName)); }); CodecObserver test(5, kVideoRotation_0, absl::nullopt, "multiplex", @@ -215,9 +217,11 @@ TEST_F(CodecEndToEndTest, SendsAndReceivesMultiplexVideoRotation90) { &internal_encoder_factory, SdpVideoFormat(cricket::kVp9CodecName)); }); test::FunctionVideoDecoderFactory decoder_factory( - [&internal_decoder_factory]() { + [&internal_decoder_factory](const Environment& env, + const SdpVideoFormat& /*format*/) { return std::make_unique<MultiplexDecoderAdapter>( - &internal_decoder_factory, SdpVideoFormat(cricket::kVp9CodecName)); + env, &internal_decoder_factory, + SdpVideoFormat(cricket::kVp9CodecName)); }); CodecObserver test(5, kVideoRotation_90, absl::nullopt, "multiplex", &encoder_factory, &decoder_factory); diff --git a/third_party/libwebrtc/video/end_to_end_tests/multi_codec_receive_tests.cc b/third_party/libwebrtc/video/end_to_end_tests/multi_codec_receive_tests.cc index 307b5085c9..e236af007b 100644 --- a/third_party/libwebrtc/video/end_to_end_tests/multi_codec_receive_tests.cc +++ b/third_party/libwebrtc/video/end_to_end_tests/multi_codec_receive_tests.cc @@ -213,7 +213,8 @@ void MultiCodecReceiveTest::RunTestWithCodecs( return nullptr; }); test::FunctionVideoDecoderFactory decoder_factory( - [](const SdpVideoFormat& format) -> std::unique_ptr<VideoDecoder> { + [](const Environment& env, + const SdpVideoFormat& format) -> std::unique_ptr<VideoDecoder> { if (format.name == "VP8") { return VP8Decoder::Create(); } diff --git a/third_party/libwebrtc/video/rtp_video_stream_receiver2.cc b/third_party/libwebrtc/video/rtp_video_stream_receiver2.cc index 077f522d41..ae78ef8eef 100644 --- a/third_party/libwebrtc/video/rtp_video_stream_receiver2.cc +++ b/third_party/libwebrtc/video/rtp_video_stream_receiver2.cc @@ -302,8 +302,12 @@ RtpVideoStreamReceiver2::RtpVideoStreamReceiver2( frames_decryptable_(false), absolute_capture_time_interpolator_(clock) { packet_sequence_checker_.Detach(); - if (packet_router_) - packet_router_->AddReceiveRtpModule(rtp_rtcp_.get(), config_.rtp.remb); + if (packet_router_) { + // Do not register as REMB candidate, this is only done when starting to + // receive. + packet_router_->AddReceiveRtpModule(rtp_rtcp_.get(), + /*remb_candidate=*/false); + } RTC_DCHECK(config_.rtp.rtcp_mode != RtcpMode::kOff) << "A stream should not be configured with RTCP disabled. This value is " @@ -814,6 +818,7 @@ void RtpVideoStreamReceiver2::OnInsertedPacket( if (packet->is_last_packet_in_frame()) { auto depacketizer_it = payload_type_map_.find(first_packet->payload_type); RTC_CHECK(depacketizer_it != payload_type_map_.end()); + RTC_CHECK(depacketizer_it->second); rtc::scoped_refptr<EncodedImageBuffer> bitstream = depacketizer_it->second->AssembleFrame(payloads); @@ -1278,11 +1283,23 @@ void RtpVideoStreamReceiver2::SignalNetworkState(NetworkState state) { void RtpVideoStreamReceiver2::StartReceive() { RTC_DCHECK_RUN_ON(&packet_sequence_checker_); + if (!receiving_ && packet_router_) { + // Change REMB candidate egibility. + packet_router_->RemoveReceiveRtpModule(rtp_rtcp_.get()); + packet_router_->AddReceiveRtpModule(rtp_rtcp_.get(), + /*remb_candidate=*/config_.rtp.remb); + } receiving_ = true; } void RtpVideoStreamReceiver2::StopReceive() { RTC_DCHECK_RUN_ON(&packet_sequence_checker_); + if (receiving_ && packet_router_) { + // Change REMB candidate egibility. + packet_router_->RemoveReceiveRtpModule(rtp_rtcp_.get()); + packet_router_->AddReceiveRtpModule(rtp_rtcp_.get(), + /*remb_candidate=*/false); + } receiving_ = false; } diff --git a/third_party/libwebrtc/video/rtp_video_stream_receiver2_unittest.cc b/third_party/libwebrtc/video/rtp_video_stream_receiver2_unittest.cc index f039bf29b1..6962540152 100644 --- a/third_party/libwebrtc/video/rtp_video_stream_receiver2_unittest.cc +++ b/third_party/libwebrtc/video/rtp_video_stream_receiver2_unittest.cc @@ -14,6 +14,7 @@ #include <utility> #include "api/task_queue/task_queue_base.h" +#include "api/test/mock_frame_transformer.h" #include "api/video/video_codec_type.h" #include "api/video/video_frame_type.h" #include "call/test/mock_rtp_packet_sink_interface.h" @@ -35,7 +36,6 @@ #include "system_wrappers/include/clock.h" #include "test/gmock.h" #include "test/gtest.h" -#include "test/mock_frame_transformer.h" #include "test/mock_transport.h" #include "test/rtcp_packet_parser.h" #include "test/scoped_key_value_config.h" diff --git a/third_party/libwebrtc/video/video_quality_test.cc b/third_party/libwebrtc/video/video_quality_test.cc index 99b722322a..c8331bffec 100644 --- a/third_party/libwebrtc/video/video_quality_test.cc +++ b/third_party/libwebrtc/video/video_quality_test.cc @@ -294,15 +294,16 @@ void PressEnterToContinue(TaskQueueBase* /*task_queue*/) { } // namespace std::unique_ptr<VideoDecoder> VideoQualityTest::CreateVideoDecoder( + const Environment& env, const SdpVideoFormat& format) { std::unique_ptr<VideoDecoder> decoder; if (format.name == "multiplex") { decoder = std::make_unique<MultiplexDecoderAdapter>( - decoder_factory_.get(), SdpVideoFormat(cricket::kVp9CodecName)); + env, decoder_factory_.get(), SdpVideoFormat(cricket::kVp9CodecName)); } else if (format.name == "FakeCodec") { decoder = webrtc::FakeVideoDecoderFactory::CreateVideoDecoder(); } else { - decoder = decoder_factory_->CreateVideoDecoder(format); + decoder = decoder_factory_->Create(env, format); } if (!params_.logging.encoded_frame_base_path.empty()) { rtc::StringBuilder str; @@ -375,9 +376,10 @@ VideoQualityTest::VideoQualityTest( std::unique_ptr<InjectionComponents> injection_components) : clock_(Clock::GetRealTimeClock()), task_queue_factory_(CreateDefaultTaskQueueFactory()), - video_decoder_factory_([this](const SdpVideoFormat& format) { - return this->CreateVideoDecoder(format); - }), + video_decoder_factory_( + [this](const Environment& env, const SdpVideoFormat& format) { + return this->CreateVideoDecoder(env, format); + }), video_encoder_factory_([this](const SdpVideoFormat& format) { return this->CreateVideoEncoder(format, nullptr); }), diff --git a/third_party/libwebrtc/video/video_quality_test.h b/third_party/libwebrtc/video/video_quality_test.h index 63fa4813f0..c5e63ddf48 100644 --- a/third_party/libwebrtc/video/video_quality_test.h +++ b/third_party/libwebrtc/video/video_quality_test.h @@ -15,6 +15,7 @@ #include <string> #include <vector> +#include "api/environment/environment.h" #include "api/fec_controller.h" #include "api/rtc_event_log/rtc_event_log_factory.h" #include "api/task_queue/task_queue_base.h" @@ -79,6 +80,7 @@ class VideoQualityTest : public test::CallTest, size_t video_idx); void SetupThumbnailCapturers(size_t num_thumbnail_streams); std::unique_ptr<VideoDecoder> CreateVideoDecoder( + const Environment& env, const SdpVideoFormat& format); std::unique_ptr<VideoEncoder> CreateVideoEncoder(const SdpVideoFormat& format, VideoAnalyzer* analyzer); diff --git a/third_party/libwebrtc/video/video_receive_stream2.cc b/third_party/libwebrtc/video/video_receive_stream2.cc index 8675ab9979..ce65ec4186 100644 --- a/third_party/libwebrtc/video/video_receive_stream2.cc +++ b/third_party/libwebrtc/video/video_receive_stream2.cc @@ -520,7 +520,7 @@ void VideoReceiveStream2::CreateAndRegisterExternalDecoder( TRACE_EVENT0("webrtc", "VideoReceiveStream2::CreateAndRegisterExternalDecoder"); std::unique_ptr<VideoDecoder> video_decoder = - config_.decoder_factory->CreateVideoDecoder(decoder.video_format); + config_.decoder_factory->Create(env_, decoder.video_format); // If we still have no valid decoder, we have to create a "Null" decoder // that ignores all calls. The reason we can get into this state is that the // old decoder factory interface doesn't have a way to query supported diff --git a/third_party/libwebrtc/video/video_receive_stream2_unittest.cc b/third_party/libwebrtc/video/video_receive_stream2_unittest.cc index 50e00aa31b..221d17b5be 100644 --- a/third_party/libwebrtc/video/video_receive_stream2_unittest.cc +++ b/third_party/libwebrtc/video/video_receive_stream2_unittest.cc @@ -205,10 +205,9 @@ class VideoReceiveStream2Test : public ::testing::TestWithParam<bool> { time_controller_.GetMainThread()), h264_decoder_factory_(&mock_decoder_) { // By default, mock decoder factory is backed by VideoDecoderProxyFactory. - ON_CALL(mock_h264_decoder_factory_, CreateVideoDecoder) - .WillByDefault( - Invoke(&h264_decoder_factory_, - &test::VideoDecoderProxyFactory::CreateVideoDecoder)); + ON_CALL(mock_h264_decoder_factory_, Create) + .WillByDefault(Invoke(&h264_decoder_factory_, + &test::VideoDecoderProxyFactory::Create)); // By default, mock decode will wrap the fake decoder. ON_CALL(mock_decoder_, Configure) @@ -459,7 +458,7 @@ TEST_P(VideoReceiveStream2Test, LazyDecoderCreation) { rtppacket.SetTimestamp(0); // No decoders are created by default. - EXPECT_CALL(mock_h264_decoder_factory_, CreateVideoDecoder(_)).Times(0); + EXPECT_CALL(mock_h264_decoder_factory_, Create).Times(0); video_receive_stream_->Start(); time_controller_.AdvanceTime(TimeDelta::Zero()); @@ -467,9 +466,8 @@ TEST_P(VideoReceiveStream2Test, LazyDecoderCreation) { testing::Mock::VerifyAndClearExpectations(&mock_h264_decoder_factory_)); // Verify that the decoder is created when we receive payload data and tries // to decode a frame. - EXPECT_CALL( - mock_h264_decoder_factory_, - CreateVideoDecoder(Field(&SdpVideoFormat::name, testing::Eq("H264")))); + EXPECT_CALL(mock_h264_decoder_factory_, + Create(_, Field(&SdpVideoFormat::name, Eq("H264")))); EXPECT_CALL(mock_decoder_, Configure); EXPECT_CALL(mock_decoder_, RegisterDecodeCompleteCallback); EXPECT_CALL(mock_decoder_, Decode(_, _)); diff --git a/third_party/libwebrtc/video/video_send_stream_impl.cc b/third_party/libwebrtc/video/video_send_stream_impl.cc index 23dbb7177f..ec63b51816 100644 --- a/third_party/libwebrtc/video/video_send_stream_impl.cc +++ b/third_party/libwebrtc/video/video_send_stream_impl.cc @@ -362,6 +362,15 @@ std::unique_ptr<VideoStreamEncoderInterface> CreateVideoStreamEncoder( encoder_selector); } +bool HasActiveEncodings(const VideoEncoderConfig& config) { + for (const VideoStream& stream : config.simulcast_layers) { + if (stream.active) { + return true; + } + } + return false; +} + } // namespace PacingConfig::PacingConfig(const FieldTrialsView& field_trials) @@ -438,6 +447,7 @@ VideoSendStreamImpl::VideoSendStreamImpl( timed_out_(false), bitrate_allocator_(bitrate_allocator), + has_active_encodings_(HasActiveEncodings(encoder_config)), disable_padding_(true), max_padding_bitrate_(0), encoder_min_bitrate_bps_(0), @@ -512,6 +522,7 @@ VideoSendStreamImpl::~VideoSendStreamImpl() { RTC_DCHECK_RUN_ON(&thread_checker_); RTC_LOG(LS_INFO) << "~VideoSendStreamImpl: " << config_.ToString(); RTC_DCHECK(!started()); + RTC_DCHECK(!IsRunning()); transport_->DestroyRtpVideoSender(rtp_video_sender_); } @@ -545,6 +556,13 @@ void VideoSendStreamImpl::ReconfigureVideoEncoder( RTC_DCHECK_EQ(content_type_, config.content_type); RTC_LOG(LS_VERBOSE) << "Encoder config: " << config.ToString() << " VideoSendStream config: " << config_.ToString(); + + has_active_encodings_ = HasActiveEncodings(config); + if (has_active_encodings_ && rtp_video_sender_->IsActive() && !IsRunning()) { + StartupVideoSendStream(); + } else if (!has_active_encodings_ && IsRunning()) { + StopVideoSendStream(); + } video_stream_encoder_->ConfigureEncoder( std::move(config), config_.rtp.max_packet_size - CalculateMaxHeaderSize(config_.rtp), @@ -609,40 +627,24 @@ bool VideoSendStreamImpl::started() { } void VideoSendStreamImpl::Start() { - const std::vector<bool> active_layers(config_.rtp.ssrcs.size(), true); - StartPerRtpStream(active_layers); -} - -void VideoSendStreamImpl::StartPerRtpStream( - const std::vector<bool> active_layers) { RTC_DCHECK_RUN_ON(&thread_checker_); - - rtc::StringBuilder active_layers_string; - active_layers_string << "{"; - for (size_t i = 0; i < active_layers.size(); ++i) { - if (active_layers[i]) { - active_layers_string << "1"; - } else { - active_layers_string << "0"; - } - if (i < active_layers.size() - 1) { - active_layers_string << ", "; - } - } - active_layers_string << "}"; - RTC_LOG(LS_INFO) << "StartPerRtpStream: " << active_layers_string.str(); - - bool previously_active = rtp_video_sender_->IsActive(); - rtp_video_sender_->SetActiveModules(active_layers); - if (!rtp_video_sender_->IsActive() && previously_active) { - StopVideoSendStream(); - } else if (rtp_video_sender_->IsActive() && !previously_active) { + // This sender is allowed to send RTP packets. Start monitoring and allocating + // a rate if there is also active encodings. (has_active_encodings_). + rtp_video_sender_->SetSending(true); + if (!IsRunning() && has_active_encodings_) { StartupVideoSendStream(); } } +bool VideoSendStreamImpl::IsRunning() const { + RTC_DCHECK_RUN_ON(&thread_checker_); + return check_encoder_activity_task_.Running(); +} + void VideoSendStreamImpl::StartupVideoSendStream() { RTC_DCHECK_RUN_ON(&thread_checker_); + RTC_DCHECK(rtp_video_sender_->IsActive()); + RTC_DCHECK(has_active_encodings_); bitrate_allocator_->AddObserver(this, GetAllocationConfig()); // Start monitoring encoder activity. @@ -679,8 +681,10 @@ void VideoSendStreamImpl::Stop() { return; TRACE_EVENT_INSTANT0("webrtc", "VideoSendStream::Stop"); - rtp_video_sender_->Stop(); - StopVideoSendStream(); + rtp_video_sender_->SetSending(false); + if (IsRunning()) { + StopVideoSendStream(); + } } void VideoSendStreamImpl::StopVideoSendStream() { @@ -761,7 +765,7 @@ void VideoSendStreamImpl::OnVideoLayersAllocationUpdated( void VideoSendStreamImpl::SignalEncoderActive() { RTC_DCHECK_RUN_ON(&thread_checker_); - if (rtp_video_sender_->IsActive()) { + if (IsRunning()) { RTC_LOG(LS_INFO) << "SignalEncoderActive, Encoder is active."; bitrate_allocator_->AddObserver(this, GetAllocationConfig()); } @@ -805,7 +809,9 @@ void VideoSendStreamImpl::OnEncoderConfigurationChanged( double stream_bitrate_priority_sum = 0; for (const auto& stream : streams) { // We don't want to allocate more bitrate than needed to inactive streams. - encoder_max_bitrate_bps_ += stream.active ? stream.max_bitrate_bps : 0; + if (stream.active) { + encoder_max_bitrate_bps_ += stream.max_bitrate_bps; + } if (stream.bitrate_priority) { RTC_DCHECK_GT(*stream.bitrate_priority, 0); stream_bitrate_priority_sum += *stream.bitrate_priority; @@ -833,7 +839,7 @@ void VideoSendStreamImpl::OnEncoderConfigurationChanged( rtp_video_sender_->SetEncodingData(streams[0].width, streams[0].height, num_temporal_layers); - if (rtp_video_sender_->IsActive()) { + if (IsRunning()) { // The send stream is started already. Update the allocator with new // bitrate limits. bitrate_allocator_->AddObserver(this, GetAllocationConfig()); diff --git a/third_party/libwebrtc/video/video_send_stream_impl.h b/third_party/libwebrtc/video/video_send_stream_impl.h index 758e12c095..8cff4b8822 100644 --- a/third_party/libwebrtc/video/video_send_stream_impl.h +++ b/third_party/libwebrtc/video/video_send_stream_impl.h @@ -96,7 +96,6 @@ class VideoSendStreamImpl : public webrtc::VideoSendStream, // webrtc::VideoSendStream implementation. void Start() override; - void StartPerRtpStream(std::vector<bool> active_layers) override; void Stop() override; bool started() override; @@ -182,6 +181,9 @@ class VideoSendStreamImpl : public webrtc::VideoSendStream, void ConfigureSsrcs(); void SignalEncoderTimedOut(); void SignalEncoderActive(); + // A video send stream is running if VideoSendStream::Start has been invoked + // and there is an active encoding. + bool IsRunning() const; MediaStreamAllocationConfig GetAllocationConfig() const RTC_RUN_ON(thread_checker_); @@ -212,6 +214,7 @@ class VideoSendStreamImpl : public webrtc::VideoSendStream, BitrateAllocatorInterface* const bitrate_allocator_; + bool has_active_encodings_ RTC_GUARDED_BY(thread_checker_); bool disable_padding_ RTC_GUARDED_BY(thread_checker_); int max_padding_bitrate_ RTC_GUARDED_BY(thread_checker_); int encoder_min_bitrate_bps_ RTC_GUARDED_BY(thread_checker_); diff --git a/third_party/libwebrtc/video/video_send_stream_impl_unittest.cc b/third_party/libwebrtc/video/video_send_stream_impl_unittest.cc index ba492ae66f..f6b43cb958 100644 --- a/third_party/libwebrtc/video/video_send_stream_impl_unittest.cc +++ b/third_party/libwebrtc/video/video_send_stream_impl_unittest.cc @@ -54,6 +54,7 @@ #include "video/send_delay_stats.h" #include "video/send_statistics_proxy.h" #include "video/test/mock_video_stream_encoder.h" +#include "video/video_stream_encoder.h" #include "video/video_stream_encoder_interface.h" namespace webrtc { @@ -69,10 +70,13 @@ namespace internal { namespace { using ::testing::_; using ::testing::AllOf; +using ::testing::AnyNumber; using ::testing::Field; using ::testing::Invoke; +using ::testing::Mock; using ::testing::NiceMock; using ::testing::Return; +using ::testing::SaveArg; constexpr int64_t kDefaultInitialBitrateBps = 333000; const double kDefaultBitratePriority = 0.5; @@ -85,8 +89,7 @@ std::string GetAlrProbingExperimentString() { } class MockRtpVideoSender : public RtpVideoSenderInterface { public: - MOCK_METHOD(void, SetActiveModules, (const std::vector<bool>&), (override)); - MOCK_METHOD(void, Stop, (), (override)); + MOCK_METHOD(void, SetSending, (bool sending), (override)); MOCK_METHOD(bool, IsActive, (), (override)); MOCK_METHOD(void, OnNetworkAvailability, (bool), (override)); MOCK_METHOD((std::map<uint32_t, RtpState>), @@ -156,37 +159,31 @@ class VideoSendStreamImplTest : public ::testing::Test { .WillRepeatedly(Return(&packet_router_)); EXPECT_CALL(transport_controller_, CreateRtpVideoSender) .WillRepeatedly(Return(&rtp_video_sender_)); - ON_CALL(rtp_video_sender_, Stop()).WillByDefault(::testing::Invoke([&] { - active_modules_.clear(); + ON_CALL(rtp_video_sender_, IsActive()).WillByDefault(Invoke([&]() { + return rtp_sending_; })); - ON_CALL(rtp_video_sender_, IsActive()) - .WillByDefault(::testing::Invoke([&]() { - for (bool enabled : active_modules_) { - if (enabled) - return true; - } - return false; - })); - ON_CALL(rtp_video_sender_, SetActiveModules) - .WillByDefault(::testing::SaveArg<0>(&active_modules_)); + ON_CALL(rtp_video_sender_, SetSending) + .WillByDefault(SaveArg<0>(&rtp_sending_)); } ~VideoSendStreamImplTest() {} - std::unique_ptr<VideoSendStreamImpl> CreateVideoSendStreamImpl( - int initial_encoder_max_bitrate, - double initial_encoder_bitrate_priority, - VideoEncoderConfig::ContentType content_type, - absl::optional<std::string> codec = std::nullopt) { - EXPECT_CALL(bitrate_allocator_, GetStartBitrate(_)) - .WillOnce(Return(123000)); - + VideoEncoderConfig TestVideoEncoderConfig( + VideoEncoderConfig::ContentType content_type = + VideoEncoderConfig::ContentType::kRealtimeVideo, + int initial_encoder_max_bitrate = kDefaultInitialBitrateBps, + double initial_encoder_bitrate_priority = kDefaultBitratePriority) { VideoEncoderConfig encoder_config; encoder_config.max_bitrate_bps = initial_encoder_max_bitrate; encoder_config.bitrate_priority = initial_encoder_bitrate_priority; encoder_config.content_type = content_type; - if (codec) { - config_.rtp.payload_name = *codec; - } + encoder_config.simulcast_layers.push_back(VideoStream()); + encoder_config.simulcast_layers.back().active = true; + return encoder_config; + } + + std::unique_ptr<VideoSendStreamImpl> CreateVideoSendStreamImpl( + VideoEncoderConfig encoder_config) { + EXPECT_CALL(bitrate_allocator_, GetStartBitrate).WillOnce(Return(123000)); std::map<uint32_t, RtpState> suspended_ssrcs; std::map<uint32_t, RtpPayloadState> suspended_payload_states; @@ -200,7 +197,7 @@ class VideoSendStreamImplTest : public ::testing::Test { /*num_cpu_cores=*/1, time_controller_.GetTaskQueueFactory(), /*call_stats=*/nullptr, &transport_controller_, /*metronome=*/nullptr, &bitrate_allocator_, &send_delay_stats_, - /*event_log=*/nullptr, config_.Copy(), encoder_config.Copy(), + /*event_log=*/nullptr, config_.Copy(), std::move(encoder_config), suspended_ssrcs, suspended_payload_states, /*fec_controller=*/nullptr, field_trials_, std::move(video_stream_encoder)); @@ -221,7 +218,7 @@ class VideoSendStreamImplTest : public ::testing::Test { NiceMock<MockBitrateAllocator> bitrate_allocator_; NiceMock<MockVideoStreamEncoder>* video_stream_encoder_ = nullptr; NiceMock<MockRtpVideoSender> rtp_video_sender_; - std::vector<bool> active_modules_; + bool rtp_sending_ = false; RtcEventLogNull event_log_; VideoSendStream::Config config_; @@ -231,23 +228,97 @@ class VideoSendStreamImplTest : public ::testing::Test { PacketRouter packet_router_; }; -TEST_F(VideoSendStreamImplTest, RegistersAsBitrateObserverOnStart) { - auto vss_impl = CreateVideoSendStreamImpl( - kDefaultInitialBitrateBps, kDefaultBitratePriority, - VideoEncoderConfig::ContentType::kRealtimeVideo); - const bool kSuspend = false; - config_.suspend_below_min_bitrate = kSuspend; +TEST_F(VideoSendStreamImplTest, + NotRegistersAsBitrateObserverOnStartIfNoActiveEncodings) { + VideoEncoderConfig encoder_config = TestVideoEncoderConfig(); + encoder_config.simulcast_layers[0].active = false; + auto vss_impl = CreateVideoSendStreamImpl(std::move(encoder_config)); + EXPECT_CALL(bitrate_allocator_, AddObserver(vss_impl.get(), _)).Times(0); + EXPECT_CALL(bitrate_allocator_, RemoveObserver(vss_impl.get())).Times(0); + + vss_impl->Start(); + time_controller_.AdvanceTime(TimeDelta::Zero()); + vss_impl->Stop(); +} + +TEST_F(VideoSendStreamImplTest, + RegistersAsBitrateObserverOnStartIfHasActiveEncodings) { + auto vss_impl = CreateVideoSendStreamImpl(TestVideoEncoderConfig()); + + EXPECT_CALL(bitrate_allocator_, AddObserver(vss_impl.get(), _)); + vss_impl->Start(); + time_controller_.AdvanceTime(TimeDelta::Zero()); + + EXPECT_CALL(bitrate_allocator_, RemoveObserver(vss_impl.get())).Times(1); + vss_impl->Stop(); +} + +TEST_F(VideoSendStreamImplTest, + DeRegistersAsBitrateObserverIfNoActiveEncodings) { + auto vss_impl = CreateVideoSendStreamImpl(TestVideoEncoderConfig()); + EXPECT_CALL(bitrate_allocator_, AddObserver(vss_impl.get(), _)); + vss_impl->Start(); + time_controller_.AdvanceTime(TimeDelta::Zero()); + + EXPECT_CALL(bitrate_allocator_, RemoveObserver(vss_impl.get())).Times(1); + VideoEncoderConfig no_active_encodings = TestVideoEncoderConfig(); + no_active_encodings.simulcast_layers[0].active = false; + + vss_impl->ReconfigureVideoEncoder(std::move(no_active_encodings)); + + time_controller_.AdvanceTime(TimeDelta::Zero()); + ::testing::Mock::VerifyAndClearExpectations(&bitrate_allocator_); + + vss_impl->Stop(); +} + +TEST_F(VideoSendStreamImplTest, + DoNotRegistersAsBitrateObserverOnStrayEncodedImage) { + auto vss_impl = CreateVideoSendStreamImpl(TestVideoEncoderConfig()); + + EncodedImage encoded_image; + CodecSpecificInfo codec_specific; + ON_CALL(rtp_video_sender_, OnEncodedImage) + .WillByDefault(Return( + EncodedImageCallback::Result(EncodedImageCallback::Result::OK))); + EXPECT_CALL(bitrate_allocator_, AddObserver(vss_impl.get(), _)) - .WillOnce(Invoke( - [&](BitrateAllocatorObserver*, MediaStreamAllocationConfig config) { - EXPECT_EQ(config.min_bitrate_bps, 0u); - EXPECT_EQ(config.max_bitrate_bps, kDefaultInitialBitrateBps); - EXPECT_EQ(config.pad_up_bitrate_bps, 0u); - EXPECT_EQ(config.enforce_min_bitrate, !kSuspend); - EXPECT_EQ(config.bitrate_priority, kDefaultBitratePriority); - })); - vss_impl->StartPerRtpStream({true}); + .Times(AnyNumber()); + vss_impl->Start(); + time_controller_.AdvanceTime(TimeDelta::Zero()); + + // VideoSendStreamImpl gets an allocated bitrate. + const uint32_t kBitrateBps = 100000; + EXPECT_CALL(rtp_video_sender_, GetPayloadBitrateBps()) + .Times(1) + .WillOnce(Return(kBitrateBps)); + static_cast<BitrateAllocatorObserver*>(vss_impl.get()) + ->OnBitrateUpdated(CreateAllocation(kBitrateBps)); + // A frame is encoded. + encoder_queue_->PostTask([&] { + static_cast<EncodedImageCallback*>(vss_impl.get()) + ->OnEncodedImage(encoded_image, &codec_specific); + }); + + // Expect allocation to be removed if encoder stop producing frames. EXPECT_CALL(bitrate_allocator_, RemoveObserver(vss_impl.get())).Times(1); + time_controller_.AdvanceTime(TimeDelta::Seconds(5)); + Mock::VerifyAndClearExpectations(&bitrate_allocator_); + + EXPECT_CALL(bitrate_allocator_, AddObserver(vss_impl.get(), _)).Times(0); + + VideoEncoderConfig no_active_encodings = TestVideoEncoderConfig(); + no_active_encodings.simulcast_layers[0].active = false; + vss_impl->ReconfigureVideoEncoder(std::move(no_active_encodings)); + + // Expect that allocation in not resumed if a stray encoded image is received. + encoder_queue_->PostTask([&] { + static_cast<EncodedImageCallback*>(vss_impl.get()) + ->OnEncodedImage(encoded_image, &codec_specific); + }); + + time_controller_.AdvanceTime(TimeDelta::Zero()); + vss_impl->Stop(); } @@ -259,11 +330,9 @@ TEST_F(VideoSendStreamImplTest, UpdatesObserverOnConfigurationChange) { config_.rtp.ssrcs.emplace_back(1); config_.rtp.ssrcs.emplace_back(2); - auto vss_impl = CreateVideoSendStreamImpl( - kDefaultInitialBitrateBps, kDefaultBitratePriority, - VideoEncoderConfig::ContentType::kRealtimeVideo); + auto vss_impl = CreateVideoSendStreamImpl(TestVideoEncoderConfig()); - vss_impl->StartPerRtpStream({true}); + vss_impl->Start(); // QVGA + VGA configuration matching defaults in // media/engine/simulcast.cc. @@ -326,9 +395,8 @@ TEST_F(VideoSendStreamImplTest, UpdatesObserverOnConfigurationChangeWithAlr) { config_.rtp.ssrcs.emplace_back(2); auto vss_impl = CreateVideoSendStreamImpl( - kDefaultInitialBitrateBps, kDefaultBitratePriority, - VideoEncoderConfig::ContentType::kScreen); - vss_impl->StartPerRtpStream({true}); + TestVideoEncoderConfig(VideoEncoderConfig::ContentType::kScreen)); + vss_impl->Start(); // Simulcast screenshare. VideoStream low_stream; @@ -388,11 +456,9 @@ TEST_F(VideoSendStreamImplTest, config_.rtp.ssrcs.emplace_back(1); config_.rtp.ssrcs.emplace_back(2); - auto vss_impl = CreateVideoSendStreamImpl( - kDefaultInitialBitrateBps, kDefaultBitratePriority, - VideoEncoderConfig::ContentType::kRealtimeVideo); + auto vss_impl = CreateVideoSendStreamImpl(TestVideoEncoderConfig()); - vss_impl->StartPerRtpStream({true}); + vss_impl->Start(); // 2-layer video simulcast. VideoStream low_stream; low_stream.width = 320; @@ -451,31 +517,28 @@ TEST_F(VideoSendStreamImplTest, SetsScreensharePacingFactorWithFeedback) { SetPacingFactor(kAlrProbingExperimentPaceMultiplier)) .Times(1); auto vss_impl = CreateVideoSendStreamImpl( - kDefaultInitialBitrateBps, kDefaultBitratePriority, - VideoEncoderConfig::ContentType::kScreen); - vss_impl->StartPerRtpStream({true}); + TestVideoEncoderConfig(VideoEncoderConfig::ContentType::kScreen)); + vss_impl->Start(); vss_impl->Stop(); } TEST_F(VideoSendStreamImplTest, DoesNotSetPacingFactorWithoutFeedback) { test::ScopedFieldTrials alr_experiment(GetAlrProbingExperimentString()); auto vss_impl = CreateVideoSendStreamImpl( - kDefaultInitialBitrateBps, kDefaultBitratePriority, - VideoEncoderConfig::ContentType::kScreen); + TestVideoEncoderConfig(VideoEncoderConfig::ContentType::kScreen)); EXPECT_CALL(transport_controller_, SetPacingFactor(_)).Times(0); - vss_impl->StartPerRtpStream({true}); + vss_impl->Start(); vss_impl->Stop(); } TEST_F(VideoSendStreamImplTest, ForwardsVideoBitrateAllocationWhenEnabled) { auto vss_impl = CreateVideoSendStreamImpl( - kDefaultInitialBitrateBps, kDefaultBitratePriority, - VideoEncoderConfig::ContentType::kScreen); + TestVideoEncoderConfig(VideoEncoderConfig::ContentType::kScreen)); EXPECT_CALL(transport_controller_, SetPacingFactor(_)).Times(0); VideoStreamEncoderInterface::EncoderSink* const sink = static_cast<VideoStreamEncoderInterface::EncoderSink*>(vss_impl.get()); - vss_impl->StartPerRtpStream({true}); + vss_impl->Start(); // Populate a test instance of video bitrate allocation. VideoBitrateAllocation alloc; alloc.SetBitrate(0, 0, 10000); @@ -515,9 +578,8 @@ TEST_F(VideoSendStreamImplTest, ForwardsVideoBitrateAllocationWhenEnabled) { TEST_F(VideoSendStreamImplTest, ThrottlesVideoBitrateAllocationWhenTooSimilar) { auto vss_impl = CreateVideoSendStreamImpl( - kDefaultInitialBitrateBps, kDefaultBitratePriority, - VideoEncoderConfig::ContentType::kScreen); - vss_impl->StartPerRtpStream({true}); + TestVideoEncoderConfig(VideoEncoderConfig::ContentType::kScreen)); + vss_impl->Start(); // Unpause encoder, to allows allocations to be passed through. const uint32_t kBitrateBps = 100000; EXPECT_CALL(rtp_video_sender_, GetPayloadBitrateBps()) @@ -574,10 +636,9 @@ TEST_F(VideoSendStreamImplTest, ThrottlesVideoBitrateAllocationWhenTooSimilar) { TEST_F(VideoSendStreamImplTest, ForwardsVideoBitrateAllocationOnLayerChange) { auto vss_impl = CreateVideoSendStreamImpl( - kDefaultInitialBitrateBps, kDefaultBitratePriority, - VideoEncoderConfig::ContentType::kScreen); + TestVideoEncoderConfig(VideoEncoderConfig::ContentType::kScreen)); - vss_impl->StartPerRtpStream({true}); + vss_impl->Start(); // Unpause encoder, to allows allocations to be passed through. const uint32_t kBitrateBps = 100000; EXPECT_CALL(rtp_video_sender_, GetPayloadBitrateBps()) @@ -616,9 +677,8 @@ TEST_F(VideoSendStreamImplTest, ForwardsVideoBitrateAllocationOnLayerChange) { TEST_F(VideoSendStreamImplTest, ForwardsVideoBitrateAllocationAfterTimeout) { auto vss_impl = CreateVideoSendStreamImpl( - kDefaultInitialBitrateBps, kDefaultBitratePriority, - VideoEncoderConfig::ContentType::kScreen); - vss_impl->StartPerRtpStream({true}); + TestVideoEncoderConfig(VideoEncoderConfig::ContentType::kScreen)); + vss_impl->Start(); const uint32_t kBitrateBps = 100000; // Unpause encoder, to allows allocations to be passed through. EXPECT_CALL(rtp_video_sender_, GetPayloadBitrateBps()) @@ -720,15 +780,13 @@ TEST_F(VideoSendStreamImplTest, ForwardsVideoBitrateAllocationAfterTimeout) { } TEST_F(VideoSendStreamImplTest, PriorityBitrateConfigInactiveByDefault) { - auto vss_impl = CreateVideoSendStreamImpl( - kDefaultInitialBitrateBps, kDefaultBitratePriority, - VideoEncoderConfig::ContentType::kRealtimeVideo); + auto vss_impl = CreateVideoSendStreamImpl(TestVideoEncoderConfig()); EXPECT_CALL( bitrate_allocator_, AddObserver( vss_impl.get(), Field(&MediaStreamAllocationConfig::priority_bitrate_bps, 0))); - vss_impl->StartPerRtpStream({true}); + vss_impl->Start(); EXPECT_CALL(bitrate_allocator_, RemoveObserver(vss_impl.get())).Times(1); vss_impl->Stop(); } @@ -736,15 +794,14 @@ TEST_F(VideoSendStreamImplTest, PriorityBitrateConfigInactiveByDefault) { TEST_F(VideoSendStreamImplTest, PriorityBitrateConfigAffectsAV1) { test::ScopedFieldTrials override_priority_bitrate( "WebRTC-AV1-OverridePriorityBitrate/bitrate:20000/"); - auto vss_impl = CreateVideoSendStreamImpl( - kDefaultInitialBitrateBps, kDefaultBitratePriority, - VideoEncoderConfig::ContentType::kRealtimeVideo, "AV1"); + config_.rtp.payload_name = "AV1"; + auto vss_impl = CreateVideoSendStreamImpl(TestVideoEncoderConfig()); EXPECT_CALL( bitrate_allocator_, AddObserver( vss_impl.get(), Field(&MediaStreamAllocationConfig::priority_bitrate_bps, 20000))); - vss_impl->StartPerRtpStream({true}); + vss_impl->Start(); EXPECT_CALL(bitrate_allocator_, RemoveObserver(vss_impl.get())).Times(1); vss_impl->Stop(); } @@ -765,16 +822,15 @@ TEST_F(VideoSendStreamImplTest, test::ScopedFieldTrials override_priority_bitrate( "WebRTC-AV1-OverridePriorityBitrate/bitrate:20000/"); - auto vss_impl = CreateVideoSendStreamImpl( - kDefaultInitialBitrateBps, kDefaultBitratePriority, - VideoEncoderConfig::ContentType::kRealtimeVideo, "AV1"); + config_.rtp.payload_name = "AV1"; + auto vss_impl = CreateVideoSendStreamImpl(TestVideoEncoderConfig()); EXPECT_CALL( bitrate_allocator_, AddObserver( vss_impl.get(), Field(&MediaStreamAllocationConfig::priority_bitrate_bps, 20000))) .Times(2); - vss_impl->StartPerRtpStream({true}); + vss_impl->Start(); encoder_queue_->PostTask([&] { static_cast<VideoStreamEncoderInterface::EncoderSink*>(vss_impl.get()) @@ -794,10 +850,9 @@ TEST_F(VideoSendStreamImplTest, CallsVideoStreamEncoderOnBitrateUpdate) { config_.suspend_below_min_bitrate = kSuspend; config_.rtp.extensions.emplace_back(RtpExtension::kTransportSequenceNumberUri, 1); - auto vss_impl = CreateVideoSendStreamImpl( - kDefaultInitialBitrateBps, kDefaultBitratePriority, - VideoEncoderConfig::ContentType::kRealtimeVideo); - vss_impl->StartPerRtpStream({true}); + auto vss_impl = CreateVideoSendStreamImpl(TestVideoEncoderConfig()); + + vss_impl->Start(); VideoStream qvga_stream; qvga_stream.width = 320; qvga_stream.height = 180; @@ -893,9 +948,7 @@ TEST_F(VideoSendStreamImplTest, CallsVideoStreamEncoderOnBitrateUpdate) { TEST_F(VideoSendStreamImplTest, DisablesPaddingOnPausedEncoder) { int padding_bitrate = 0; - std::unique_ptr<VideoSendStreamImpl> vss_impl = CreateVideoSendStreamImpl( - kDefaultInitialBitrateBps, kDefaultBitratePriority, - VideoEncoderConfig::ContentType::kRealtimeVideo); + auto vss_impl = CreateVideoSendStreamImpl(TestVideoEncoderConfig()); // Capture padding bitrate for testing. EXPECT_CALL(bitrate_allocator_, AddObserver(vss_impl.get(), _)) @@ -928,7 +981,7 @@ TEST_F(VideoSendStreamImplTest, DisablesPaddingOnPausedEncoder) { int min_transmit_bitrate_bps = 30000; config_.rtp.ssrcs.emplace_back(1); - vss_impl->StartPerRtpStream({true}); + vss_impl->Start(); // Starts without padding. EXPECT_EQ(0, padding_bitrate); encoder_queue_->PostTask([&] { @@ -972,11 +1025,9 @@ TEST_F(VideoSendStreamImplTest, DisablesPaddingOnPausedEncoder) { } TEST_F(VideoSendStreamImplTest, KeepAliveOnDroppedFrame) { - std::unique_ptr<VideoSendStreamImpl> vss_impl = CreateVideoSendStreamImpl( - kDefaultInitialBitrateBps, kDefaultBitratePriority, - VideoEncoderConfig::ContentType::kRealtimeVideo); + auto vss_impl = CreateVideoSendStreamImpl(TestVideoEncoderConfig()); EXPECT_CALL(bitrate_allocator_, RemoveObserver(vss_impl.get())).Times(0); - vss_impl->StartPerRtpStream({true}); + vss_impl->Start(); const uint32_t kBitrateBps = 100000; EXPECT_CALL(rtp_video_sender_, GetPayloadBitrateBps()) .Times(1) @@ -1015,13 +1066,12 @@ TEST_F(VideoSendStreamImplTest, ConfiguresBitratesForSvc) { config_.rtp.extensions.emplace_back( RtpExtension::kTransportSequenceNumberUri, 1); config_.periodic_alr_bandwidth_probing = test_config.alr; - auto vss_impl = CreateVideoSendStreamImpl( - kDefaultInitialBitrateBps, kDefaultBitratePriority, + auto vss_impl = CreateVideoSendStreamImpl(TestVideoEncoderConfig( test_config.screenshare ? VideoEncoderConfig::ContentType::kScreen - : VideoEncoderConfig::ContentType::kRealtimeVideo); + : VideoEncoderConfig::ContentType::kRealtimeVideo)); - vss_impl->StartPerRtpStream({true}); + vss_impl->Start(); // Svc VideoStream stream; @@ -1100,7 +1150,7 @@ TEST_F(VideoSendStreamImplTest, ConfiguresBitratesForSvc) { ->OnEncodedImage(encoded_image, &codec_specific); }); time_controller_.AdvanceTime(TimeDelta::Zero()); - ::testing::Mock::VerifyAndClearExpectations(&bitrate_allocator_); + Mock::VerifyAndClearExpectations(&bitrate_allocator_); vss_impl->Stop(); } diff --git a/third_party/libwebrtc/video/video_stream_encoder.cc b/third_party/libwebrtc/video/video_stream_encoder.cc index d74f440996..afefa0b33f 100644 --- a/third_party/libwebrtc/video/video_stream_encoder.cc +++ b/third_party/libwebrtc/video/video_stream_encoder.cc @@ -937,6 +937,8 @@ void VideoStreamEncoder::ConfigureEncoder(VideoEncoderConfig config, void VideoStreamEncoder::ReconfigureEncoder() { // Running on the encoder queue. RTC_DCHECK(pending_encoder_reconfiguration_); + RTC_LOG(LS_INFO) << "[VSE] " << __func__ + << " [encoder_config=" << encoder_config_.ToString() << "]"; bool encoder_reset_required = false; if (pending_encoder_creation_) { @@ -1154,37 +1156,38 @@ void VideoStreamEncoder::ReconfigureEncoder() { char log_stream_buf[4 * 1024]; rtc::SimpleStringBuilder log_stream(log_stream_buf); - log_stream << "ReconfigureEncoder:\n"; - log_stream << "Simulcast streams:\n"; + log_stream << "ReconfigureEncoder: simulcast streams: "; for (size_t i = 0; i < codec.numberOfSimulcastStreams; ++i) { - log_stream << i << ": " << codec.simulcastStream[i].width << "x" - << codec.simulcastStream[i].height - << " min_kbps: " << codec.simulcastStream[i].minBitrate - << " target_kbps: " << codec.simulcastStream[i].targetBitrate - << " max_kbps: " << codec.simulcastStream[i].maxBitrate - << " max_fps: " << codec.simulcastStream[i].maxFramerate - << " max_qp: " << codec.simulcastStream[i].qpMax - << " num_tl: " << codec.simulcastStream[i].numberOfTemporalLayers - << " active: " - << (codec.simulcastStream[i].active ? "true" : "false") << "\n"; + log_stream << "{" << i << ": " << codec.simulcastStream[i].width << "x" + << codec.simulcastStream[i].height << " " + << ScalabilityModeToString( + codec.simulcastStream[i].GetScalabilityMode()) + << ", min_kbps: " << codec.simulcastStream[i].minBitrate + << ", target_kbps: " << codec.simulcastStream[i].targetBitrate + << ", max_kbps: " << codec.simulcastStream[i].maxBitrate + << ", max_fps: " << codec.simulcastStream[i].maxFramerate + << ", max_qp: " << codec.simulcastStream[i].qpMax << ", num_tl: " + << codec.simulcastStream[i].numberOfTemporalLayers + << ", active: " + << (codec.simulcastStream[i].active ? "true" : "false") << "}"; } if (encoder_config_.codec_type == kVideoCodecVP9 || encoder_config_.codec_type == kVideoCodecAV1) { - log_stream << "Spatial layers:\n"; + log_stream << ", spatial layers: "; for (int i = 0; i < GetNumSpatialLayers(codec); ++i) { - log_stream << i << ": " << codec.spatialLayers[i].width << "x" + log_stream << "{" << i << ": " << codec.spatialLayers[i].width << "x" << codec.spatialLayers[i].height - << " min_kbps: " << codec.spatialLayers[i].minBitrate - << " target_kbps: " << codec.spatialLayers[i].targetBitrate - << " max_kbps: " << codec.spatialLayers[i].maxBitrate - << " max_fps: " << codec.spatialLayers[i].maxFramerate - << " max_qp: " << codec.spatialLayers[i].qpMax - << " num_tl: " << codec.spatialLayers[i].numberOfTemporalLayers - << " active: " - << (codec.spatialLayers[i].active ? "true" : "false") << "\n"; + << ", min_kbps: " << codec.spatialLayers[i].minBitrate + << ", target_kbps: " << codec.spatialLayers[i].targetBitrate + << ", max_kbps: " << codec.spatialLayers[i].maxBitrate + << ", max_fps: " << codec.spatialLayers[i].maxFramerate + << ", max_qp: " << codec.spatialLayers[i].qpMax << ", num_tl: " + << codec.spatialLayers[i].numberOfTemporalLayers + << ", active: " + << (codec.spatialLayers[i].active ? "true" : "false") << "}"; } } - RTC_LOG(LS_INFO) << log_stream.str(); + RTC_LOG(LS_INFO) << "[VSE] " << log_stream.str(); codec.startBitrate = std::max(encoder_target_bitrate_bps_.value_or(0) / 1000, codec.minBitrate); @@ -1319,7 +1322,7 @@ void VideoStreamEncoder::ReconfigureEncoder() { << " max frame rate " << codec.maxFramerate << " max payload size " << max_data_payload_length_; } else { - RTC_LOG(LS_ERROR) << "Failed to configure encoder."; + RTC_LOG(LS_ERROR) << "[VSE] Failed to configure encoder."; rate_allocator_ = nullptr; } @@ -1917,7 +1920,7 @@ void VideoStreamEncoder::EncodeVideoFrame(const VideoFrame& video_frame, stream_resource_manager_.ConfigureQualityScaler(info); stream_resource_manager_.ConfigureBandwidthQualityScaler(info); - RTC_LOG(LS_INFO) << "Encoder info changed to " << info.ToString(); + RTC_LOG(LS_INFO) << "[VSE] Encoder info changed to " << info.ToString(); } if (bitrate_adjuster_) { @@ -2102,6 +2105,8 @@ EncodedImage VideoStreamEncoder::AugmentEncodedImage( .Parse(codec_type, stream_idx, image_copy.data(), image_copy.size()) .value_or(-1); } + TRACE_EVENT2("webrtc", "VideoStreamEncoder::AugmentEncodedImage", + "stream_idx", stream_idx, "qp", image_copy.qp_); RTC_LOG(LS_VERBOSE) << __func__ << " ntp time " << encoded_image.NtpTimeMs() << " stream_idx " << stream_idx << " qp " << image_copy.qp_; |