diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:37 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:37 +0000 |
commit | a90a5cba08fdf6c0ceb95101c275108a152a3aed (patch) | |
tree | 532507288f3defd7f4dcf1af49698bcb76034855 /third_party/libwebrtc/media | |
parent | Adding debian version 126.0.1-1. (diff) | |
download | firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.tar.xz firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/media')
16 files changed, 76 insertions, 213 deletions
diff --git a/third_party/libwebrtc/media/BUILD.gn b/third_party/libwebrtc/media/BUILD.gn index 44638d562e..7a489f0c43 100644 --- a/third_party/libwebrtc/media/BUILD.gn +++ b/third_party/libwebrtc/media/BUILD.gn @@ -395,6 +395,7 @@ rtc_library("rtc_internal_video_codecs") { ":media_constants", ":rtc_media_base", ":rtc_simulcast_encoder_adapter", + "../api/environment", "../api/video:encoded_image", "../api/video:video_bitrate_allocation", "../api/video:video_frame", @@ -615,6 +616,7 @@ rtc_source_set("rtc_data_sctp_transport_internal") { "../api:rtc_error", "../api/transport:datagram_transport_interface", "../media:rtc_media_base", + "../p2p:packet_transport_internal", "../p2p:rtc_p2p", "../rtc_base:copy_on_write_buffer", "../rtc_base:threading", @@ -639,6 +641,7 @@ if (rtc_build_dcsctp) { "../net/dcsctp/public:types", "../net/dcsctp/public:utils", "../net/dcsctp/timer:task_queue_timeout", + "../p2p:packet_transport_internal", "../p2p:rtc_p2p", "../rtc_base:checks", "../rtc_base:copy_on_write_buffer", diff --git a/third_party/libwebrtc/media/base/codec_unittest.cc b/third_party/libwebrtc/media/base/codec_unittest.cc index 4dc3b18c21..e1e69eb082 100644 --- a/third_party/libwebrtc/media/base/codec_unittest.cc +++ b/third_party/libwebrtc/media/base/codec_unittest.cc @@ -228,11 +228,11 @@ TEST(CodecTest, TestAV1CodecMatches) { VideoCodec c_no_profile = cricket::CreateVideoCodec(95, cricket::kAv1CodecName); VideoCodec c_profile0 = cricket::CreateVideoCodec(95, cricket::kAv1CodecName); - c_profile0.params[webrtc::kAV1FmtpProfile] = kProfile0; + c_profile0.params[cricket::kAv1FmtpProfile] = kProfile0; VideoCodec c_profile1 = cricket::CreateVideoCodec(95, cricket::kAv1CodecName); - c_profile1.params[webrtc::kAV1FmtpProfile] = kProfile1; + c_profile1.params[cricket::kAv1FmtpProfile] = kProfile1; VideoCodec c_profile2 = cricket::CreateVideoCodec(95, cricket::kAv1CodecName); - c_profile2.params[webrtc::kAV1FmtpProfile] = kProfile2; + c_profile2.params[cricket::kAv1FmtpProfile] = kProfile2; // An AV1 entry with no profile specified should be treated as profile-0. EXPECT_TRUE(c_profile0.Matches(c_no_profile)); @@ -248,7 +248,7 @@ TEST(CodecTest, TestAV1CodecMatches) { // Two AV1 entries with profile 0 specified are treated as duplicates. VideoCodec c_profile0_eq = cricket::CreateVideoCodec(95, cricket::kAv1CodecName); - c_profile0_eq.params[webrtc::kAV1FmtpProfile] = kProfile0; + c_profile0_eq.params[cricket::kAv1FmtpProfile] = kProfile0; EXPECT_TRUE(c_profile0.Matches(c_profile0_eq)); } @@ -256,7 +256,7 @@ TEST(CodecTest, TestAV1CodecMatches) { // Two AV1 entries with profile 1 specified are treated as duplicates. VideoCodec c_profile1_eq = cricket::CreateVideoCodec(95, cricket::kAv1CodecName); - c_profile1_eq.params[webrtc::kAV1FmtpProfile] = kProfile1; + c_profile1_eq.params[cricket::kAv1FmtpProfile] = kProfile1; EXPECT_TRUE(c_profile1.Matches(c_profile1_eq)); } diff --git a/third_party/libwebrtc/media/base/media_constants.cc b/third_party/libwebrtc/media/base/media_constants.cc index 2af0295a5a..1a7561aa52 100644 --- a/third_party/libwebrtc/media/base/media_constants.cc +++ b/third_party/libwebrtc/media/base/media_constants.cc @@ -124,8 +124,14 @@ const char kH265FmtpProfileCompatibilityIndicator[] = const char kH265FmtpInteropConstraints[] = "interop-constraints"; const char kH265FmtpTxMode[] = "tx-mode"; +// draft-ietf-payload-vp9 const char kVP9ProfileId[] = "profile-id"; +// https://aomediacodec.github.io/av1-rtp-spec/ +const char kAv1FmtpProfile[] = "profile"; +const char kAv1FmtpLevelIdx[] = "level-idx"; +const char kAv1FmtpTier[] = "tier"; + const int kDefaultVideoMaxFramerate = 60; // Max encode quantizer for VP8/9 and AV1 encoders assuming libvpx/libaom API // range [0, 63] diff --git a/third_party/libwebrtc/media/base/media_constants.h b/third_party/libwebrtc/media/base/media_constants.h index 877cc7a296..d5af17eb2a 100644 --- a/third_party/libwebrtc/media/base/media_constants.h +++ b/third_party/libwebrtc/media/base/media_constants.h @@ -147,8 +147,14 @@ RTC_EXPORT extern const char kH265FmtpProfileCompatibilityIndicator[]; RTC_EXPORT extern const char kH265FmtpInteropConstraints[]; RTC_EXPORT extern const char kH265FmtpTxMode[]; +// draft-ietf-payload-vp9 extern const char kVP9ProfileId[]; +// https://aomediacodec.github.io/av1-rtp-spec/ +extern const char kAv1FmtpProfile[]; +extern const char kAv1FmtpLevelIdx[]; +extern const char kAv1FmtpTier[]; + extern const int kDefaultVideoMaxFramerate; extern const int kDefaultVideoMaxQpVpx; extern const int kDefaultVideoMaxQpH26x; diff --git a/third_party/libwebrtc/media/engine/fake_webrtc_call.cc b/third_party/libwebrtc/media/engine/fake_webrtc_call.cc index 16e7169b21..2536c9dd85 100644 --- a/third_party/libwebrtc/media/engine/fake_webrtc_call.cc +++ b/third_party/libwebrtc/media/engine/fake_webrtc_call.cc @@ -339,17 +339,6 @@ void FakeVideoSendStream::ReconfigureVideoEncoder( webrtc::InvokeSetParametersCallback(callback, webrtc::RTCError::OK()); } -void FakeVideoSendStream::StartPerRtpStream( - const std::vector<bool> active_layers) { - sending_ = false; - for (const bool active_layer : active_layers) { - if (active_layer) { - sending_ = true; - break; - } - } -} - void FakeVideoSendStream::Start() { sending_ = true; } diff --git a/third_party/libwebrtc/media/engine/fake_webrtc_call.h b/third_party/libwebrtc/media/engine/fake_webrtc_call.h index 3dd6bdf397..d67a7ee452 100644 --- a/third_party/libwebrtc/media/engine/fake_webrtc_call.h +++ b/third_party/libwebrtc/media/engine/fake_webrtc_call.h @@ -199,7 +199,6 @@ class FakeVideoSendStream final void OnFrame(const webrtc::VideoFrame& frame) override; // webrtc::VideoSendStream implementation. - void StartPerRtpStream(std::vector<bool> active_layers) override; void Start() override; void Stop() override; bool started() override { return IsSending(); } diff --git a/third_party/libwebrtc/media/engine/internal_decoder_factory.cc b/third_party/libwebrtc/media/engine/internal_decoder_factory.cc index 001c666313..139f49d420 100644 --- a/third_party/libwebrtc/media/engine/internal_decoder_factory.cc +++ b/third_party/libwebrtc/media/engine/internal_decoder_factory.cc @@ -52,9 +52,10 @@ std::vector<SdpVideoFormat> InternalDecoderFactory::GetSupportedFormats() #if !defined(WEBRTC_MOZILLA_BUILD) if (kDav1dIsIncluded) { formats.push_back(SdpVideoFormat(cricket::kAv1CodecName)); - formats.push_back(SdpVideoFormat( - cricket::kAv1CodecName, - {{kAV1FmtpProfile, AV1ProfileToString(AV1Profile::kProfile1).data()}})); + formats.push_back( + SdpVideoFormat(cricket::kAv1CodecName, + {{cricket::kAv1FmtpProfile, + AV1ProfileToString(AV1Profile::kProfile1).data()}})); } #endif diff --git a/third_party/libwebrtc/media/engine/internal_decoder_factory_unittest.cc b/third_party/libwebrtc/media/engine/internal_decoder_factory_unittest.cc index 51d6a94dd6..e06b4c3d77 100644 --- a/third_party/libwebrtc/media/engine/internal_decoder_factory_unittest.cc +++ b/third_party/libwebrtc/media/engine/internal_decoder_factory_unittest.cc @@ -121,7 +121,7 @@ TEST(InternalDecoderFactoryTest, Av1Profile1_Dav1dDecoderTrialEnabled) { InternalDecoderFactory factory; std::unique_ptr<VideoDecoder> decoder = factory.CreateVideoDecoder( SdpVideoFormat(cricket::kAv1CodecName, - {{kAV1FmtpProfile, + {{cricket::kAv1FmtpProfile, AV1ProfileToString(AV1Profile::kProfile1).data()}})); EXPECT_EQ(static_cast<bool>(decoder), kDav1dIsIncluded); } diff --git a/third_party/libwebrtc/media/engine/multiplex_codec_factory.cc b/third_party/libwebrtc/media/engine/multiplex_codec_factory.cc index 90df02a77e..cf17b46d7d 100644 --- a/third_party/libwebrtc/media/engine/multiplex_codec_factory.cc +++ b/third_party/libwebrtc/media/engine/multiplex_codec_factory.cc @@ -11,10 +11,12 @@ #include "media/engine/multiplex_codec_factory.h" #include <map> +#include <memory> #include <string> #include <utility> #include "absl/strings/match.h" +#include "api/environment/environment.h" #include "api/video_codecs/sdp_video_format.h" #include "media/base/codec.h" #include "media/base/media_constants.h" @@ -95,20 +97,21 @@ std::vector<SdpVideoFormat> MultiplexDecoderFactory::GetSupportedFormats() return augmented_formats; } -std::unique_ptr<VideoDecoder> MultiplexDecoderFactory::CreateVideoDecoder( +std::unique_ptr<VideoDecoder> MultiplexDecoderFactory::Create( + const Environment& env, const SdpVideoFormat& format) { - if (!IsMultiplexCodec(cricket::CreateVideoCodec(format))) - return factory_->CreateVideoDecoder(format); - const auto& it = - format.parameters.find(cricket::kCodecParamAssociatedCodecName); + if (!IsMultiplexCodec(cricket::CreateVideoCodec(format))) { + return factory_->Create(env, format); + } + auto it = format.parameters.find(cricket::kCodecParamAssociatedCodecName); if (it == format.parameters.end()) { RTC_LOG(LS_ERROR) << "No assicated codec for multiplex."; return nullptr; } SdpVideoFormat associated_format = format; associated_format.name = it->second; - return std::unique_ptr<VideoDecoder>(new MultiplexDecoderAdapter( - factory_.get(), associated_format, supports_augmenting_data_)); + return std::make_unique<MultiplexDecoderAdapter>( + env, factory_.get(), associated_format, supports_augmenting_data_); } } // namespace webrtc diff --git a/third_party/libwebrtc/media/engine/multiplex_codec_factory.h b/third_party/libwebrtc/media/engine/multiplex_codec_factory.h index a4272a2eb2..164164f3ee 100644 --- a/third_party/libwebrtc/media/engine/multiplex_codec_factory.h +++ b/third_party/libwebrtc/media/engine/multiplex_codec_factory.h @@ -14,6 +14,7 @@ #include <memory> #include <vector> +#include "api/environment/environment.h" #include "api/video_codecs/sdp_video_format.h" #include "api/video_codecs/video_decoder.h" #include "api/video_codecs/video_decoder_factory.h" @@ -66,8 +67,8 @@ class RTC_EXPORT MultiplexDecoderFactory : public VideoDecoderFactory { bool supports_augmenting_data = false); std::vector<SdpVideoFormat> GetSupportedFormats() const override; - std::unique_ptr<VideoDecoder> CreateVideoDecoder( - const SdpVideoFormat& format) override; + std::unique_ptr<VideoDecoder> Create(const Environment& env, + const SdpVideoFormat& format) override; private: std::unique_ptr<VideoDecoderFactory> factory_; diff --git a/third_party/libwebrtc/media/engine/multiplex_codec_factory_unittest.cc b/third_party/libwebrtc/media/engine/multiplex_codec_factory_unittest.cc index 1cde2f37d8..7f0a418d4d 100644 --- a/third_party/libwebrtc/media/engine/multiplex_codec_factory_unittest.cc +++ b/third_party/libwebrtc/media/engine/multiplex_codec_factory_unittest.cc @@ -10,8 +10,10 @@ #include "media/engine/multiplex_codec_factory.h" +#include <memory> #include <utility> +#include "api/environment/environment_factory.h" #include "api/video_codecs/sdp_video_format.h" #include "api/video_codecs/video_decoder.h" #include "api/video_codecs/video_encoder.h" @@ -22,12 +24,13 @@ namespace webrtc { -TEST(MultiplexDecoderFactory, CreateVideoDecoder) { - std::unique_ptr<VideoDecoderFactory> internal_factory( - new InternalDecoderFactory()); +TEST(MultiplexDecoderFactoryTest, CreateVideoDecoder) { + std::unique_ptr<VideoDecoderFactory> internal_factory = + std::make_unique<InternalDecoderFactory>(); MultiplexDecoderFactory factory(std::move(internal_factory)); - std::unique_ptr<VideoDecoder> decoder = - factory.CreateVideoDecoder(SdpVideoFormat( + std::unique_ptr<VideoDecoder> decoder = factory.Create( + CreateEnvironment(), + SdpVideoFormat( cricket::kMultiplexCodecName, {{cricket::kCodecParamAssociatedCodecName, cricket::kVp9CodecName}})); EXPECT_TRUE(decoder); diff --git a/third_party/libwebrtc/media/engine/simulcast_encoder_adapter.cc b/third_party/libwebrtc/media/engine/simulcast_encoder_adapter.cc index 4853e68996..642fe31e90 100644 --- a/third_party/libwebrtc/media/engine/simulcast_encoder_adapter.cc +++ b/third_party/libwebrtc/media/engine/simulcast_encoder_adapter.cc @@ -32,6 +32,7 @@ #include "media/base/media_constants.h" #include "media/base/video_common.h" #include "modules/video_coding/include/video_error_codes.h" +#include "modules/video_coding/include/video_error_codes_utils.h" #include "modules/video_coding/utility/simulcast_rate_allocator.h" #include "rtc_base/checks.h" #include "rtc_base/experiments/rate_control_settings.h" @@ -360,8 +361,14 @@ int SimulcastEncoderAdapter::InitEncode( bool separate_encoders_needed = !encoder_context->encoder().GetEncoderInfo().supports_simulcast || active_streams_count == 1; + RTC_LOG(LS_INFO) << "[SEA] InitEncode: total_streams_count: " + << total_streams_count_ + << ", active_streams_count: " << active_streams_count + << ", separate_encoders_needed: " + << (separate_encoders_needed ? "true" : "false"); // Singlecast or simulcast with simulcast-capable underlaying encoder. if (total_streams_count_ == 1 || !separate_encoders_needed) { + RTC_LOG(LS_INFO) << "[SEA] InitEncode: Single-encoder mode"; int ret = encoder_context->encoder().InitEncode(&codec_, settings); if (ret >= 0) { stream_contexts_.emplace_back( @@ -377,7 +384,8 @@ int SimulcastEncoderAdapter::InitEncode( encoder_context->Release(); if (total_streams_count_ == 1) { - // Failed to initialize singlecast encoder. + RTC_LOG(LS_ERROR) << "[SEA] InitEncode: failed with error code: " + << WebRtcVideoCodecErrorToString(ret); return ret; } } @@ -405,10 +413,16 @@ int SimulcastEncoderAdapter::InitEncode( /*is_lowest_quality_stream=*/stream_idx == lowest_quality_stream_idx, /*is_highest_quality_stream=*/stream_idx == highest_quality_stream_idx); + RTC_LOG(LS_INFO) << "[SEA] Multi-encoder mode: initializing stream: " + << stream_idx << ", active: " + << (codec_.simulcastStream[stream_idx].active ? "true" + : "false"); int ret = encoder_context->encoder().InitEncode(&stream_codec, settings); if (ret < 0) { encoder_context.reset(); Release(); + RTC_LOG(LS_ERROR) << "[SEA] InitEncode: failed with error code: " + << WebRtcVideoCodecErrorToString(ret); return ret; } diff --git a/third_party/libwebrtc/media/engine/webrtc_video_engine.cc b/third_party/libwebrtc/media/engine/webrtc_video_engine.cc index a5b46d3344..a313407f2d 100644 --- a/third_party/libwebrtc/media/engine/webrtc_video_engine.cc +++ b/third_party/libwebrtc/media/engine/webrtc_video_engine.cc @@ -811,6 +811,8 @@ std::vector<VideoCodec> WebRtcVideoEngine::recv_codecs(bool include_rtx) const { std::vector<webrtc::RtpHeaderExtensionCapability> WebRtcVideoEngine::GetRtpHeaderExtensions() const { std::vector<webrtc::RtpHeaderExtensionCapability> result; + // id is *not* incremented for non-default extensions, UsedIds needs to + // resolve conflicts. int id = 1; for (const auto& uri : {webrtc::RtpExtension::kTimestampOffsetUri, @@ -825,27 +827,26 @@ WebRtcVideoEngine::GetRtpHeaderExtensions() const { result.emplace_back(uri, id++, webrtc::RtpTransceiverDirection::kSendRecv); } for (const auto& uri : {webrtc::RtpExtension::kAbsoluteCaptureTimeUri}) { - result.emplace_back(uri, id++, webrtc::RtpTransceiverDirection::kStopped); + result.emplace_back(uri, id, webrtc::RtpTransceiverDirection::kStopped); } - result.emplace_back(webrtc::RtpExtension::kGenericFrameDescriptorUri00, id++, + result.emplace_back(webrtc::RtpExtension::kGenericFrameDescriptorUri00, id, IsEnabled(trials_, "WebRTC-GenericDescriptorAdvertised") ? webrtc::RtpTransceiverDirection::kSendRecv : webrtc::RtpTransceiverDirection::kStopped); result.emplace_back( - webrtc::RtpExtension::kDependencyDescriptorUri, id++, + webrtc::RtpExtension::kDependencyDescriptorUri, id, IsEnabled(trials_, "WebRTC-DependencyDescriptorAdvertised") ? webrtc::RtpTransceiverDirection::kSendRecv : webrtc::RtpTransceiverDirection::kStopped); - result.emplace_back( - webrtc::RtpExtension::kVideoLayersAllocationUri, id++, + webrtc::RtpExtension::kVideoLayersAllocationUri, id, IsEnabled(trials_, "WebRTC-VideoLayersAllocationAdvertised") ? webrtc::RtpTransceiverDirection::kSendRecv : webrtc::RtpTransceiverDirection::kStopped); // VideoFrameTrackingId is a test-only extension. if (IsEnabled(trials_, "WebRTC-VideoFrameTrackingIdAdvertised")) { - result.emplace_back(webrtc::RtpExtension::kVideoFrameTrackingIdUri, id++, + result.emplace_back(webrtc::RtpExtension::kVideoFrameTrackingIdUri, id, webrtc::RtpTransceiverDirection::kSendRecv); } return result; @@ -2013,6 +2014,7 @@ WebRtcVideoSendChannel::WebRtcVideoSendStream::SetRtpParameters( new_send_state = true; } } + rtp_parameters_ = new_parameters; // Codecs are currently handled at the WebRtcVideoSendChannel level. rtp_parameters_.codecs.clear(); @@ -2021,9 +2023,6 @@ WebRtcVideoSendChannel::WebRtcVideoSendStream::SetRtpParameters( ReconfigureEncoder(std::move(callback)); callback = nullptr; } - if (new_send_state) { - UpdateSendState(); - } if (new_degradation_preference) { if (source_ && stream_) { stream_->SetSource(source_, GetDegradationPreference()); @@ -2082,27 +2081,9 @@ void WebRtcVideoSendChannel::WebRtcVideoSendStream::UpdateSendState() { RTC_DCHECK_RUN_ON(&thread_checker_); if (sending_) { RTC_DCHECK(stream_ != nullptr); - size_t num_layers = rtp_parameters_.encodings.size(); - if (parameters_.encoder_config.number_of_streams == 1) { - // SVC is used. Only one simulcast layer is present. - num_layers = 1; - } - std::vector<bool> active_layers(num_layers); - for (size_t i = 0; i < num_layers; ++i) { - active_layers[i] = IsLayerActive(rtp_parameters_.encodings[i]); - } - if (parameters_.encoder_config.number_of_streams == 1 && - rtp_parameters_.encodings.size() > 1) { - // SVC is used. - // The only present simulcast layer should be active if any of the - // configured SVC layers is active. - active_layers[0] = - absl::c_any_of(rtp_parameters_.encodings, - [](const auto& encoding) { return encoding.active; }); - } - // This updates what simulcast layers are sending, and possibly starts - // or stops the VideoSendStream. - stream_->StartPerRtpStream(active_layers); + // This allows the the Stream to be used. Ie, DTLS is connected and the + // RtpTransceiver direction allows sending. + stream_->Start(); } else { if (stream_ != nullptr) { stream_->Stop(); diff --git a/third_party/libwebrtc/media/engine/webrtc_video_engine.h b/third_party/libwebrtc/media/engine/webrtc_video_engine.h index e4b1b2765b..d370a5445b 100644 --- a/third_party/libwebrtc/media/engine/webrtc_video_engine.h +++ b/third_party/libwebrtc/media/engine/webrtc_video_engine.h @@ -250,10 +250,6 @@ class WebRtcVideoSendChannel : public MediaChannelUtil, ADAPTREASON_BANDWIDTH = 2, }; - // TODO(webrtc:14852): Update downstream projects to use - // cricket::kDefaultVideoMaxQpVpx/H26x and remove. - static constexpr int kDefaultQpMax = 56; - // Implements webrtc::EncoderSwitchRequestCallback. void RequestEncoderFallback() override; void RequestEncoderSwitch(const webrtc::SdpVideoFormat& format, @@ -402,8 +398,7 @@ class WebRtcVideoSendChannel : public MediaChannelUtil, const VideoCodec& codec) const; void ReconfigureEncoder(webrtc::SetParametersCallback callback); - // Calls Start or Stop according to whether or not `sending_` is true, - // and whether or not the encoding in `rtp_parameters_` is active. + // Calls Start or Stop according to whether or not `sending_` is true. void UpdateSendState(); webrtc::DegradationPreference GetDegradationPreference() const diff --git a/third_party/libwebrtc/media/engine/webrtc_video_engine_unittest.cc b/third_party/libwebrtc/media/engine/webrtc_video_engine_unittest.cc index 148223f497..4493c9c616 100644 --- a/third_party/libwebrtc/media/engine/webrtc_video_engine_unittest.cc +++ b/third_party/libwebrtc/media/engine/webrtc_video_engine_unittest.cc @@ -9078,105 +9078,6 @@ TEST_F(WebRtcVideoChannelTest, DefaultMinAndMaxBitratePropagatedToEncoder) { stream->GetVideoStreams()[0].target_bitrate_bps); } -// Test that a stream will not be sending if its encoding is made inactive -// through SetRtpSendParameters. -TEST_F(WebRtcVideoChannelTest, SetRtpSendParametersOneEncodingActive) { - FakeVideoSendStream* stream = AddSendStream(); - EXPECT_TRUE(send_channel_->SetSend(true)); - EXPECT_TRUE(stream->IsSending()); - - // Get current parameters and change "active" to false. - webrtc::RtpParameters parameters = - send_channel_->GetRtpSendParameters(last_ssrc_); - ASSERT_EQ(1u, parameters.encodings.size()); - ASSERT_TRUE(parameters.encodings[0].active); - parameters.encodings[0].active = false; - EXPECT_TRUE(send_channel_->SetRtpSendParameters(last_ssrc_, parameters).ok()); - EXPECT_FALSE(stream->IsSending()); - - // Now change it back to active and verify we resume sending. - parameters.encodings[0].active = true; - EXPECT_TRUE(send_channel_->SetRtpSendParameters(last_ssrc_, parameters).ok()); - EXPECT_TRUE(stream->IsSending()); -} - -// Tests that when active is updated for any simulcast layer then the send -// stream's sending state will be updated and it will be reconfigured with the -// new appropriate active simulcast streams. -TEST_F(WebRtcVideoChannelTest, SetRtpSendParametersMultipleEncodingsActive) { - // Create the stream params with multiple ssrcs for simulcast. - const size_t kNumSimulcastStreams = 3; - std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3); - StreamParams stream_params = CreateSimStreamParams("cname", ssrcs); - FakeVideoSendStream* fake_video_send_stream = AddSendStream(stream_params); - uint32_t primary_ssrc = stream_params.first_ssrc(); - - // Using the FrameForwarder, we manually send a full size - // frame. This allows us to test that ReconfigureEncoder is called - // appropriately. - webrtc::test::FrameForwarder frame_forwarder; - VideoOptions options; - EXPECT_TRUE( - send_channel_->SetVideoSend(primary_ssrc, &options, &frame_forwarder)); - send_channel_->SetSend(true); - frame_forwarder.IncomingCapturedFrame(frame_source_.GetFrame( - 1920, 1080, webrtc::VideoRotation::kVideoRotation_0, - rtc::kNumMicrosecsPerSec / 30)); - - // Check that all encodings are initially active. - webrtc::RtpParameters parameters = - send_channel_->GetRtpSendParameters(primary_ssrc); - EXPECT_EQ(kNumSimulcastStreams, parameters.encodings.size()); - EXPECT_TRUE(parameters.encodings[0].active); - EXPECT_TRUE(parameters.encodings[1].active); - EXPECT_TRUE(parameters.encodings[2].active); - EXPECT_TRUE(fake_video_send_stream->IsSending()); - - // Only turn on only the middle stream. - parameters.encodings[0].active = false; - parameters.encodings[1].active = true; - parameters.encodings[2].active = false; - EXPECT_TRUE( - send_channel_->SetRtpSendParameters(primary_ssrc, parameters).ok()); - // Verify that the active fields are set on the VideoChannel. - parameters = send_channel_->GetRtpSendParameters(primary_ssrc); - EXPECT_EQ(kNumSimulcastStreams, parameters.encodings.size()); - EXPECT_FALSE(parameters.encodings[0].active); - EXPECT_TRUE(parameters.encodings[1].active); - EXPECT_FALSE(parameters.encodings[2].active); - // Check that the VideoSendStream is updated appropriately. This means its - // send state was updated and it was reconfigured. - EXPECT_TRUE(fake_video_send_stream->IsSending()); - std::vector<webrtc::VideoStream> simulcast_streams = - fake_video_send_stream->GetVideoStreams(); - EXPECT_EQ(kNumSimulcastStreams, simulcast_streams.size()); - EXPECT_FALSE(simulcast_streams[0].active); - EXPECT_TRUE(simulcast_streams[1].active); - EXPECT_FALSE(simulcast_streams[2].active); - - // Turn off all streams. - parameters.encodings[0].active = false; - parameters.encodings[1].active = false; - parameters.encodings[2].active = false; - EXPECT_TRUE( - send_channel_->SetRtpSendParameters(primary_ssrc, parameters).ok()); - // Verify that the active fields are set on the VideoChannel. - parameters = send_channel_->GetRtpSendParameters(primary_ssrc); - EXPECT_EQ(kNumSimulcastStreams, parameters.encodings.size()); - EXPECT_FALSE(parameters.encodings[0].active); - EXPECT_FALSE(parameters.encodings[1].active); - EXPECT_FALSE(parameters.encodings[2].active); - // Check that the VideoSendStream is off. - EXPECT_FALSE(fake_video_send_stream->IsSending()); - simulcast_streams = fake_video_send_stream->GetVideoStreams(); - EXPECT_EQ(kNumSimulcastStreams, simulcast_streams.size()); - EXPECT_FALSE(simulcast_streams[0].active); - EXPECT_FALSE(simulcast_streams[1].active); - EXPECT_FALSE(simulcast_streams[2].active); - - EXPECT_TRUE(send_channel_->SetVideoSend(primary_ssrc, nullptr, nullptr)); -} - // Tests that when some streams are disactivated then the lowest // stream min_bitrate would be reused for the first active stream. TEST_F(WebRtcVideoChannelTest, @@ -9232,47 +9133,6 @@ TEST_F(WebRtcVideoChannelTest, EXPECT_TRUE(send_channel_->SetVideoSend(primary_ssrc, nullptr, nullptr)); } -// Test that if a stream is reconfigured (due to a codec change or other -// change) while its encoding is still inactive, it doesn't start sending. -TEST_F(WebRtcVideoChannelTest, - InactiveStreamDoesntStartSendingWhenReconfigured) { - // Set an initial codec list, which will be modified later. - cricket::VideoSenderParameters parameters1; - parameters1.codecs.push_back(GetEngineCodec("VP8")); - parameters1.codecs.push_back(GetEngineCodec("VP9")); - EXPECT_TRUE(send_channel_->SetSenderParameters(parameters1)); - - FakeVideoSendStream* stream = AddSendStream(); - EXPECT_TRUE(send_channel_->SetSend(true)); - EXPECT_TRUE(stream->IsSending()); - - // Get current parameters and change "active" to false. - webrtc::RtpParameters parameters = - send_channel_->GetRtpSendParameters(last_ssrc_); - ASSERT_EQ(1u, parameters.encodings.size()); - ASSERT_TRUE(parameters.encodings[0].active); - parameters.encodings[0].active = false; - EXPECT_EQ(1u, GetFakeSendStreams().size()); - EXPECT_EQ(1, fake_call_->GetNumCreatedSendStreams()); - EXPECT_TRUE(send_channel_->SetRtpSendParameters(last_ssrc_, parameters).ok()); - EXPECT_FALSE(stream->IsSending()); - - // Reorder the codec list, causing the stream to be reconfigured. - cricket::VideoSenderParameters parameters2; - parameters2.codecs.push_back(GetEngineCodec("VP9")); - parameters2.codecs.push_back(GetEngineCodec("VP8")); - EXPECT_TRUE(send_channel_->SetSenderParameters(parameters2)); - auto new_streams = GetFakeSendStreams(); - // Assert that a new underlying stream was created due to the codec change. - // Otherwise, this test isn't testing what it set out to test. - EXPECT_EQ(1u, GetFakeSendStreams().size()); - EXPECT_EQ(2, fake_call_->GetNumCreatedSendStreams()); - - // Verify that we still are not sending anything, due to the inactive - // encoding. - EXPECT_FALSE(new_streams[0]->IsSending()); -} - // Test that GetRtpSendParameters returns the currently configured codecs. TEST_F(WebRtcVideoChannelTest, GetRtpSendParametersCodecs) { AddSendStream(); diff --git a/third_party/libwebrtc/media/engine/webrtc_voice_engine.cc b/third_party/libwebrtc/media/engine/webrtc_voice_engine.cc index fcc2703f98..23a1b1927c 100644 --- a/third_party/libwebrtc/media/engine/webrtc_voice_engine.cc +++ b/third_party/libwebrtc/media/engine/webrtc_voice_engine.cc @@ -643,6 +643,8 @@ std::vector<webrtc::RtpHeaderExtensionCapability> WebRtcVoiceEngine::GetRtpHeaderExtensions() const { RTC_DCHECK(signal_thread_checker_.IsCurrent()); std::vector<webrtc::RtpHeaderExtensionCapability> result; + // id is *not* incremented for non-default extensions, UsedIds needs to + // resolve conflicts. int id = 1; for (const auto& uri : {webrtc::RtpExtension::kAudioLevelUri, webrtc::RtpExtension::kAbsSendTimeUri, @@ -651,7 +653,7 @@ WebRtcVoiceEngine::GetRtpHeaderExtensions() const { result.emplace_back(uri, id++, webrtc::RtpTransceiverDirection::kSendRecv); } for (const auto& uri : {webrtc::RtpExtension::kAbsoluteCaptureTimeUri}) { - result.emplace_back(uri, id++, webrtc::RtpTransceiverDirection::kStopped); + result.emplace_back(uri, id, webrtc::RtpTransceiverDirection::kStopped); } return result; } |