diff --git a/media/engine/webrtc_video_engine.cc b/media/engine/webrtc_video_engine.cc index b9c6c61ddf..a57af55409 100644 --- a/media/engine/webrtc_video_engine.cc +++ b/media/engine/webrtc_video_engine.cc @@ -1532,13 +1532,6 @@ bool WebRtcVideoSendChannel::AddSendStream(const StreamParams& sp) { bitrate_allocator_factory_; config.encoder_settings.encoder_switch_request_callback = this; - // TODO: bugs.webrtc.org/358039777 - Add test when this effectively does - // something. - if (webrtc::RtpExtension::FindHeaderExtensionByUri( - config.rtp.extensions, webrtc::RtpExtension::kCorruptionDetectionUri, - webrtc::RtpExtension::kRequireEncryptedExtension)) { - config.encoder_settings.enable_frame_instrumentation_generator = true; - } config.crypto_options = crypto_options_; config.rtp.extmap_allow_mixed = ExtmapAllowMixed(); config.rtcp_report_interval_ms = video_config_.rtcp_report_interval_ms; @@ -2621,6 +2614,13 @@ void WebRtcVideoSendChannel::WebRtcVideoSendStream::RecreateWebRtcStream() { } } } + + if (webrtc::RtpExtension::FindHeaderExtensionByUri( + config.rtp.extensions, webrtc::RtpExtension::kCorruptionDetectionUri, + webrtc::RtpExtension::kRequireEncryptedExtension)) { + config.encoder_settings.enable_frame_instrumentation_generator = true; + } + stream_ = call_->CreateVideoSendStream(std::move(config), parameters_.encoder_config.Copy()); diff --git a/media/engine/webrtc_video_engine_unittest.cc b/media/engine/webrtc_video_engine_unittest.cc index a27158463e..ea9f7034ea 100644 --- a/media/engine/webrtc_video_engine_unittest.cc +++ b/media/engine/webrtc_video_engine_unittest.cc @@ -3173,6 +3173,44 @@ TEST_F(WebRtcVideoChannelTest, RecvVideoRotationHeaderExtensions) { TestSetRecvRtpHeaderExtensions(RtpExtension::kVideoRotationUri); } +TEST_F(WebRtcVideoChannelTest, SendCorruptionDetectionHeaderExtensions) { + TestSetSendRtpHeaderExtensions(RtpExtension::kCorruptionDetectionUri); +} + +TEST_F(WebRtcVideoChannelTest, DisableFrameInstrumentationByDefault) { + EXPECT_TRUE(send_channel_->SetSenderParameters(send_parameters_)); + FakeVideoSendStream* send_stream = + AddSendStream(cricket::StreamParams::CreateLegacy(123)); + EXPECT_FALSE(send_stream->GetConfig() + .encoder_settings.enable_frame_instrumentation_generator); +} + +TEST_F(WebRtcVideoChannelTest, + EnableFrameInstrumentationWhenEncryptedExtensionIsPresent) { + cricket::VideoSenderParameters parameters = send_parameters_; + parameters.extensions.push_back(RtpExtension( + RtpExtension::kCorruptionDetectionUri, /*id=*/1, /*encrypt=*/true)); + EXPECT_TRUE(send_channel_->SetSenderParameters(parameters)); + + FakeVideoSendStream* send_stream = + AddSendStream(cricket::StreamParams::CreateLegacy(123)); + EXPECT_TRUE(send_stream->GetConfig() + .encoder_settings.enable_frame_instrumentation_generator); +} + +TEST_F(WebRtcVideoChannelTest, + DisableFrameInstrumentationWhenNoEncryptedExtensionIsPresent) { + cricket::VideoSenderParameters parameters = send_parameters_; + parameters.extensions.push_back(RtpExtension( + RtpExtension::kCorruptionDetectionUri, /*id=*/1, /*encrypt=*/false)); + EXPECT_TRUE(send_channel_->SetSenderParameters(parameters)); + + FakeVideoSendStream* send_stream = + AddSendStream(cricket::StreamParams::CreateLegacy(123)); + EXPECT_FALSE(send_stream->GetConfig() + .encoder_settings.enable_frame_instrumentation_generator); +} + TEST_F(WebRtcVideoChannelTest, IdenticalSendExtensionsDoesntRecreateStream) { const int kAbsSendTimeId = 1; const int kVideoRotationId = 2;