From 8dd16259287f58f9273002717ec4d27e97127719 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:43:14 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- third_party/libwebrtc/audio/BUILD.gn | 6 +- third_party/libwebrtc/audio/audio_send_stream.cc | 118 ++++++++------------- third_party/libwebrtc/audio/audio_send_stream.h | 28 ++--- .../libwebrtc/audio/audio_send_stream_unittest.cc | 71 ++++++++++++- third_party/libwebrtc/audio/channel_receive.cc | 7 -- ..._receive_frame_transformer_delegate_unittest.cc | 4 +- .../libwebrtc/audio/channel_receive_unittest.cc | 2 +- .../channel_send_frame_transformer_delegate.cc | 14 ++- ...nel_send_frame_transformer_delegate_unittest.cc | 10 +- .../libwebrtc/audio/channel_send_unittest.cc | 2 +- 10 files changed, 139 insertions(+), 123 deletions(-) (limited to 'third_party/libwebrtc/audio') diff --git a/third_party/libwebrtc/audio/BUILD.gn b/third_party/libwebrtc/audio/BUILD.gn index 7ece107407..8679790903 100644 --- a/third_party/libwebrtc/audio/BUILD.gn +++ b/third_party/libwebrtc/audio/BUILD.gn @@ -167,6 +167,8 @@ if (rtc_include_tests) { "../api:mock_audio_mixer", "../api:mock_frame_decryptor", "../api:mock_frame_encryptor", + "../api:mock_frame_transformer", + "../api:mock_transformable_audio_frame", "../api:scoped_refptr", "../api/audio:audio_frame_api", "../api/audio_codecs:audio_codecs_api", @@ -210,8 +212,6 @@ if (rtc_include_tests) { "../system_wrappers", "../test:audio_codec_mocks", "../test:field_trial", - "../test:mock_frame_transformer", - "../test:mock_transformable_frame", "../test:mock_transport", "../test:rtp_test_utils", "../test:run_loop", @@ -234,6 +234,7 @@ if (rtc_include_tests) { sources = [ "channel_receive_unittest.cc" ] deps = [ ":audio", + "../api:mock_frame_transformer", "../api/audio_codecs:builtin_audio_decoder_factory", "../api/crypto:frame_decryptor_interface", "../api/task_queue:default_task_queue_factory", @@ -245,7 +246,6 @@ if (rtc_include_tests) { "../rtc_base:logging", "../rtc_base:threading", "../test:audio_codec_mocks", - "../test:mock_frame_transformer", "../test:mock_transport", "../test:test_support", "../test/time_controller", diff --git a/third_party/libwebrtc/audio/audio_send_stream.cc b/third_party/libwebrtc/audio/audio_send_stream.cc index 8dc78b18fa..64bc15ab4e 100644 --- a/third_party/libwebrtc/audio/audio_send_stream.cc +++ b/third_party/libwebrtc/audio/audio_send_stream.cc @@ -157,6 +157,8 @@ AudioSendStream::AudioSendStream( event_log_(event_log), use_legacy_overhead_calculation_( field_trials_.IsEnabled("WebRTC-Audio-LegacyOverhead")), + enable_priority_bitrate_( + !field_trials_.IsDisabled("WebRTC-Audio-PriorityBitrate")), bitrate_allocator_(bitrate_allocator), rtp_transport_(rtp_transport), rtp_rtcp_module_(channel_send_->GetRtpRtcp()), @@ -171,7 +173,6 @@ AudioSendStream::AudioSendStream( RTC_DCHECK_RUN_ON(&worker_thread_checker_); ConfigureStream(config, true, nullptr); - UpdateCachedTargetAudioBitrateConstraints(); } AudioSendStream::~AudioSendStream() { @@ -324,10 +325,7 @@ void AudioSendStream::ConfigureStream( } // Set currently known overhead (used in ANA, opus only). - { - MutexLock lock(&overhead_per_packet_lock_); - UpdateOverheadForEncoder(); - } + UpdateOverheadPerPacket(); channel_send_->CallEncoder([this](AudioEncoder* encoder) { RTC_DCHECK_RUN_ON(&worker_thread_checker_); @@ -335,7 +333,7 @@ void AudioSendStream::ConfigureStream( return; } frame_length_range_ = encoder->GetFrameLengthRange(); - UpdateCachedTargetAudioBitrateConstraints(); + bitrate_range_ = encoder->GetBitrateRange(); }); if (sending_) { @@ -343,9 +341,6 @@ void AudioSendStream::ConfigureStream( } config_ = new_config; - if (!first_time) { - UpdateCachedTargetAudioBitrateConstraints(); - } webrtc::InvokeSetParametersCallback(callback, webrtc::RTCError::OK()); } @@ -489,30 +484,23 @@ webrtc::AudioSendStream::Stats AudioSendStream::GetStats( void AudioSendStream::DeliverRtcp(const uint8_t* packet, size_t length) { RTC_DCHECK_RUN_ON(&worker_thread_checker_); channel_send_->ReceivedRTCPPacket(packet, length); - - { - // Poll if overhead has changed, which it can do if ack triggers us to stop - // sending mid/rid. - MutexLock lock(&overhead_per_packet_lock_); - UpdateOverheadForEncoder(); - } - UpdateCachedTargetAudioBitrateConstraints(); + // Poll if overhead has changed, which it can do if ack triggers us to stop + // sending mid/rid. + UpdateOverheadPerPacket(); } uint32_t AudioSendStream::OnBitrateUpdated(BitrateAllocationUpdate update) { RTC_DCHECK_RUN_ON(&worker_thread_checker_); - // Pick a target bitrate between the constraints. Overrules the allocator if // it 1) allocated a bitrate of zero to disable the stream or 2) allocated a // higher than max to allow for e.g. extra FEC. - RTC_DCHECK(cached_constraints_.has_value()); - update.target_bitrate.Clamp(cached_constraints_->min, - cached_constraints_->max); - update.stable_target_bitrate.Clamp(cached_constraints_->min, - cached_constraints_->max); - + absl::optional constraints = + GetMinMaxBitrateConstraints(); + if (constraints) { + update.target_bitrate.Clamp(constraints->min, constraints->max); + update.stable_target_bitrate.Clamp(constraints->min, constraints->max); + } channel_send_->OnBitrateAllocation(update); - // The amount of audio protection is not exposed by the encoder, hence // always returning 0. return 0; @@ -521,41 +509,30 @@ uint32_t AudioSendStream::OnBitrateUpdated(BitrateAllocationUpdate update) { void AudioSendStream::SetTransportOverhead( int transport_overhead_per_packet_bytes) { RTC_DCHECK_RUN_ON(&worker_thread_checker_); - { - MutexLock lock(&overhead_per_packet_lock_); - transport_overhead_per_packet_bytes_ = transport_overhead_per_packet_bytes; - UpdateOverheadForEncoder(); - } - UpdateCachedTargetAudioBitrateConstraints(); + transport_overhead_per_packet_bytes_ = transport_overhead_per_packet_bytes; + UpdateOverheadPerPacket(); } -void AudioSendStream::UpdateOverheadForEncoder() { +void AudioSendStream::UpdateOverheadPerPacket() { RTC_DCHECK_RUN_ON(&worker_thread_checker_); - size_t overhead_per_packet_bytes = GetPerPacketOverheadBytes(); + size_t overhead_per_packet_bytes = + transport_overhead_per_packet_bytes_ + + rtp_rtcp_module_->ExpectedPerPacketOverhead(); if (overhead_per_packet_ == overhead_per_packet_bytes) { return; } overhead_per_packet_ = overhead_per_packet_bytes; - channel_send_->CallEncoder([&](AudioEncoder* encoder) { encoder->OnReceivedOverhead(overhead_per_packet_bytes); }); - if (total_packet_overhead_bytes_ != overhead_per_packet_bytes) { - total_packet_overhead_bytes_ = overhead_per_packet_bytes; - if (registered_with_allocator_) { - ConfigureBitrateObserver(); - } + if (registered_with_allocator_) { + ConfigureBitrateObserver(); } } size_t AudioSendStream::TestOnlyGetPerPacketOverheadBytes() const { - MutexLock lock(&overhead_per_packet_lock_); - return GetPerPacketOverheadBytes(); -} - -size_t AudioSendStream::GetPerPacketOverheadBytes() const { - return transport_overhead_per_packet_bytes_ + - rtp_rtcp_module_->ExpectedPerPacketOverhead(); + RTC_DCHECK_RUN_ON(&worker_thread_checker_); + return overhead_per_packet_; } RtpState AudioSendStream::GetRtpState() const { @@ -649,13 +626,9 @@ bool AudioSendStream::SetupSendCodec(const Config& new_config) { } // Set currently known overhead (used in ANA, opus only). - // If overhead changes later, it will be updated in UpdateOverheadForEncoder. - { - MutexLock lock(&overhead_per_packet_lock_); - size_t overhead = GetPerPacketOverheadBytes(); - if (overhead > 0) { - encoder->OnReceivedOverhead(overhead); - } + // If overhead changes later, it will be updated in UpdateOverheadPerPacket. + if (overhead_per_packet_ > 0) { + encoder->OnReceivedOverhead(overhead_per_packet_); } StoreEncoderProperties(encoder->SampleRateHz(), encoder->NumChannels()); @@ -717,18 +690,14 @@ void AudioSendStream::ReconfigureANA(const Config& new_config) { return; } if (new_config.audio_network_adaptor_config) { - // This lock needs to be acquired before CallEncoder, since it aquires - // another lock and we need to maintain the same order at all call sites to - // avoid deadlock. - MutexLock lock(&overhead_per_packet_lock_); - size_t overhead = GetPerPacketOverheadBytes(); channel_send_->CallEncoder([&](AudioEncoder* encoder) { + RTC_DCHECK_RUN_ON(&worker_thread_checker_); if (encoder->EnableAudioNetworkAdaptor( *new_config.audio_network_adaptor_config, event_log_)) { RTC_LOG(LS_INFO) << "Audio network adaptor enabled on SSRC " << new_config.rtp.ssrc; - if (overhead > 0) { - encoder->OnReceivedOverhead(overhead); + if (overhead_per_packet_ > 0) { + encoder->OnReceivedOverhead(overhead_per_packet_); } } else { RTC_LOG(LS_INFO) << "Failed to enable Audio network adaptor on SSRC " @@ -833,8 +802,7 @@ void AudioSendStream::ConfigureBitrateObserver() { priority_bitrate += max_overhead; } else { RTC_DCHECK(frame_length_range_); - const DataSize overhead_per_packet = - DataSize::Bytes(total_packet_overhead_bytes_); + const DataSize overhead_per_packet = DataSize::Bytes(overhead_per_packet_); DataRate min_overhead = overhead_per_packet / frame_length_range_->second; priority_bitrate += min_overhead; } @@ -843,6 +811,10 @@ void AudioSendStream::ConfigureBitrateObserver() { priority_bitrate = *allocation_settings_.priority_bitrate_raw; } + if (!enable_priority_bitrate_) { + priority_bitrate = DataRate::BitsPerSec(0); + } + bitrate_allocator_->AddObserver( this, MediaStreamAllocationConfig{ @@ -878,6 +850,12 @@ AudioSendStream::GetMinMaxBitrateConstraints() const { if (allocation_settings_.max_bitrate) constraints.max = *allocation_settings_.max_bitrate; + // Use encoder defined bitrate range if available. + if (bitrate_range_) { + constraints.min = bitrate_range_->first; + constraints.max = bitrate_range_->second; + } + RTC_DCHECK_GE(constraints.min, DataRate::Zero()); RTC_DCHECK_GE(constraints.max, DataRate::Zero()); if (constraints.max < constraints.min) { @@ -898,10 +876,9 @@ AudioSendStream::GetMinMaxBitrateConstraints() const { RTC_LOG(LS_WARNING) << "frame_length_range_ is not set"; return absl::nullopt; } - const DataSize kOverheadPerPacket = - DataSize::Bytes(total_packet_overhead_bytes_); - constraints.min += kOverheadPerPacket / frame_length_range_->second; - constraints.max += kOverheadPerPacket / frame_length_range_->first; + const DataSize overhead_per_packet = DataSize::Bytes(overhead_per_packet_); + constraints.min += overhead_per_packet / frame_length_range_->second; + constraints.max += overhead_per_packet / frame_length_range_->first; } return constraints; } @@ -911,14 +888,5 @@ void AudioSendStream::RegisterCngPayloadType(int payload_type, channel_send_->RegisterCngPayloadType(payload_type, clockrate_hz); } -void AudioSendStream::UpdateCachedTargetAudioBitrateConstraints() { - absl::optional - new_constraints = GetMinMaxBitrateConstraints(); - if (!new_constraints.has_value()) { - return; - } - cached_constraints_ = new_constraints; -} - } // namespace internal } // namespace webrtc diff --git a/third_party/libwebrtc/audio/audio_send_stream.h b/third_party/libwebrtc/audio/audio_send_stream.h index 09fd712d40..a37c8fd452 100644 --- a/third_party/libwebrtc/audio/audio_send_stream.h +++ b/third_party/libwebrtc/audio/audio_send_stream.h @@ -110,8 +110,7 @@ class AudioSendStream final : public webrtc::AudioSendStream, const voe::ChannelSendInterface* GetChannel() const; // Returns combined per-packet overhead. - size_t TestOnlyGetPerPacketOverheadBytes() const - RTC_LOCKS_EXCLUDED(overhead_per_packet_lock_); + size_t TestOnlyGetPerPacketOverheadBytes() const; private: class TimedTransport; @@ -152,19 +151,11 @@ class AudioSendStream final : public webrtc::AudioSendStream, // Sets per-packet overhead on encoded (for ANA) based on current known values // of transport and packetization overheads. - void UpdateOverheadForEncoder() - RTC_EXCLUSIVE_LOCKS_REQUIRED(overhead_per_packet_lock_); - - // Returns combined per-packet overhead. - size_t GetPerPacketOverheadBytes() const - RTC_EXCLUSIVE_LOCKS_REQUIRED(overhead_per_packet_lock_); + void UpdateOverheadPerPacket(); void RegisterCngPayloadType(int payload_type, int clockrate_hz) RTC_RUN_ON(worker_thread_checker_); - void UpdateCachedTargetAudioBitrateConstraints() - RTC_RUN_ON(worker_thread_checker_); - Clock* clock_; const FieldTrialsView& field_trials_; @@ -182,6 +173,7 @@ class AudioSendStream final : public webrtc::AudioSendStream, const std::unique_ptr channel_send_; RtcEventLog* const event_log_; const bool use_legacy_overhead_calculation_; + const bool enable_priority_bitrate_; int encoder_sample_rate_hz_ RTC_GUARDED_BY(worker_thread_checker_) = 0; size_t encoder_num_channels_ RTC_GUARDED_BY(worker_thread_checker_) = 0; @@ -193,9 +185,6 @@ class AudioSendStream final : public webrtc::AudioSendStream, BitrateAllocatorInterface* const bitrate_allocator_ RTC_GUARDED_BY(worker_thread_checker_); - absl::optional - cached_constraints_ RTC_GUARDED_BY(worker_thread_checker_) = - absl::nullopt; RtpTransportControllerSendInterface* const rtp_transport_; RtpRtcpInterface* const rtp_rtcp_module_; @@ -217,19 +206,18 @@ class AudioSendStream final : public webrtc::AudioSendStream, const std::vector& extensions); static int TransportSeqNumId(const Config& config); - mutable Mutex overhead_per_packet_lock_; - size_t overhead_per_packet_ RTC_GUARDED_BY(overhead_per_packet_lock_) = 0; - // Current transport overhead (ICE, TURN, etc.) size_t transport_overhead_per_packet_bytes_ - RTC_GUARDED_BY(overhead_per_packet_lock_) = 0; + RTC_GUARDED_BY(worker_thread_checker_) = 0; + // Total overhead, including transport and RTP headers. + size_t overhead_per_packet_ RTC_GUARDED_BY(worker_thread_checker_) = 0; bool registered_with_allocator_ RTC_GUARDED_BY(worker_thread_checker_) = false; - size_t total_packet_overhead_bytes_ RTC_GUARDED_BY(worker_thread_checker_) = - 0; absl::optional> frame_length_range_ RTC_GUARDED_BY(worker_thread_checker_); + absl::optional> bitrate_range_ + RTC_GUARDED_BY(worker_thread_checker_); }; } // namespace internal } // namespace webrtc diff --git a/third_party/libwebrtc/audio/audio_send_stream_unittest.cc b/third_party/libwebrtc/audio/audio_send_stream_unittest.cc index c854f734b5..60d87eb080 100644 --- a/third_party/libwebrtc/audio/audio_send_stream_unittest.cc +++ b/third_party/libwebrtc/audio/audio_send_stream_unittest.cc @@ -21,6 +21,7 @@ #include "audio/audio_state.h" #include "audio/conversion.h" #include "audio/mock_voe_channel_proxy.h" +#include "call/test/mock_bitrate_allocator.h" #include "call/test/mock_rtp_transport_controller_send.h" #include "logging/rtc_event_log/mock/mock_rtc_event_log.h" #include "modules/audio_device/include/mock_audio_device.h" @@ -155,7 +156,6 @@ struct ConfigHelper { use_null_audio_processing ? nullptr : rtc::make_ref_counted>()), - bitrate_allocator_(&limit_observer_), audio_encoder_(nullptr) { using ::testing::Invoke; @@ -203,6 +203,7 @@ struct ConfigHelper { MockRtpRtcpInterface* rtp_rtcp() { return &rtp_rtcp_; } MockChannelSend* channel_send() { return channel_send_; } RtpTransportControllerSendInterface* transport() { return &rtp_transport_; } + MockBitrateAllocator* bitrate_allocator() { return &bitrate_allocator_; } static void AddBweToConfig(AudioSendStream::Config* config) { config->rtp.extensions.push_back(RtpExtension( @@ -328,7 +329,7 @@ struct ConfigHelper { ::testing::NiceMock rtp_transport_; ::testing::NiceMock rtp_rtcp_; ::testing::NiceMock limit_observer_; - BitrateAllocator bitrate_allocator_; + ::testing::NiceMock bitrate_allocator_; std::unique_ptr audio_encoder_; }; @@ -560,8 +561,7 @@ TEST(AudioSendStreamTest, AudioNetworkAdaptorReceivesOverhead) { InSequence s; EXPECT_CALL( *mock_encoder, - OnReceivedOverhead(Eq(kOverheadPerPacket.bytes()))) - .Times(2); + OnReceivedOverhead(Eq(kOverheadPerPacket.bytes()))); EXPECT_CALL(*mock_encoder, EnableAudioNetworkAdaptor(StrEq(kAnaConfigString), _)) .WillOnce(Return(true)); @@ -847,7 +847,6 @@ TEST(AudioSendStreamTest, AudioOverheadChanged) { EXPECT_CALL(*helper.rtp_rtcp(), ExpectedPerPacketOverhead) .WillRepeatedly(Return(audio_overhead_per_packet_bytes)); auto send_stream = helper.CreateAudioSendStream(); - auto new_config = helper.config(); BitrateAllocationUpdate update; update.target_bitrate = @@ -861,6 +860,8 @@ TEST(AudioSendStreamTest, AudioOverheadChanged) { EXPECT_CALL(*helper.rtp_rtcp(), ExpectedPerPacketOverhead) .WillRepeatedly(Return(audio_overhead_per_packet_bytes + 20)); + // RTP overhead can only change in response to RTCP or configuration change. + send_stream->Reconfigure(helper.config(), nullptr); EXPECT_CALL(*helper.channel_send(), OnBitrateAllocation); send_stream->OnBitrateUpdated(update); @@ -924,5 +925,65 @@ TEST(AudioSendStreamTest, ReconfigureWithFrameEncryptor) { send_stream->Reconfigure(new_config, nullptr); } } + +TEST(AudioSendStreamTest, DefaultsHonorsPriorityBitrate) { + ConfigHelper helper(true, true, true); + ScopedKeyValueConfig field_trials(helper.field_trials, + "WebRTC-Audio-Allocation/prio_rate:20/"); + auto send_stream = helper.CreateAudioSendStream(); + EXPECT_CALL(*helper.bitrate_allocator(), AddObserver(send_stream.get(), _)) + .WillOnce(Invoke( + [&](BitrateAllocatorObserver*, MediaStreamAllocationConfig config) { + EXPECT_EQ(config.priority_bitrate_bps, 20000); + })); + EXPECT_CALL(*helper.channel_send(), StartSend()); + send_stream->Start(); + EXPECT_CALL(*helper.channel_send(), StopSend()); + send_stream->Stop(); +} + +TEST(AudioSendStreamTest, OverridesPriorityBitrate) { + ConfigHelper helper(true, true, true); + ScopedKeyValueConfig field_trials(helper.field_trials, + "WebRTC-Audio-Allocation/prio_rate:20/" + "WebRTC-Audio-PriorityBitrate/Disabled/"); + auto send_stream = helper.CreateAudioSendStream(); + EXPECT_CALL(*helper.bitrate_allocator(), AddObserver(send_stream.get(), _)) + .WillOnce(Invoke( + [&](BitrateAllocatorObserver*, MediaStreamAllocationConfig config) { + EXPECT_EQ(config.priority_bitrate_bps, 0); + })); + EXPECT_CALL(*helper.channel_send(), StartSend()); + send_stream->Start(); + EXPECT_CALL(*helper.channel_send(), StopSend()); + send_stream->Stop(); +} + +TEST(AudioSendStreamTest, UseEncoderBitrateRange) { + ConfigHelper helper(true, true, true); + std::pair bitrate_range{DataRate::BitsPerSec(5000), + DataRate::BitsPerSec(10000)}; + EXPECT_CALL(helper.mock_encoder_factory(), MakeAudioEncoderMock(_, _, _, _)) + .WillOnce(Invoke([&](int payload_type, const SdpAudioFormat& format, + absl::optional codec_pair_id, + std::unique_ptr* return_value) { + auto mock_encoder = SetupAudioEncoderMock(payload_type, format); + EXPECT_CALL(*mock_encoder, GetBitrateRange()) + .WillRepeatedly(Return(bitrate_range)); + *return_value = std::move(mock_encoder); + })); + auto send_stream = helper.CreateAudioSendStream(); + EXPECT_CALL(*helper.bitrate_allocator(), AddObserver(send_stream.get(), _)) + .WillOnce(Invoke( + [&](BitrateAllocatorObserver*, MediaStreamAllocationConfig config) { + EXPECT_EQ(config.min_bitrate_bps, bitrate_range.first.bps()); + EXPECT_EQ(config.max_bitrate_bps, bitrate_range.second.bps()); + })); + EXPECT_CALL(*helper.channel_send(), StartSend()); + send_stream->Start(); + EXPECT_CALL(*helper.channel_send(), StopSend()); + send_stream->Stop(); +} + } // namespace test } // namespace webrtc diff --git a/third_party/libwebrtc/audio/channel_receive.cc b/third_party/libwebrtc/audio/channel_receive.cc index aff21fa72a..b743b550ba 100644 --- a/third_party/libwebrtc/audio/channel_receive.cc +++ b/third_party/libwebrtc/audio/channel_receive.cc @@ -571,13 +571,6 @@ ChannelReceive::ChannelReceive( network_thread_checker_.Detach(); - acm_receiver_.ResetInitialDelay(); - acm_receiver_.SetMinimumDelay(0); - acm_receiver_.SetMaximumDelay(0); - acm_receiver_.FlushBuffers(); - - _outputAudioLevel.ResetLevelFullRange(); - rtp_receive_statistics_->EnableRetransmitDetection(remote_ssrc_, true); RtpRtcpInterface::Configuration configuration; configuration.clock = clock; diff --git a/third_party/libwebrtc/audio/channel_receive_frame_transformer_delegate_unittest.cc b/third_party/libwebrtc/audio/channel_receive_frame_transformer_delegate_unittest.cc index 8bdf217d5a..a206a09f99 100644 --- a/third_party/libwebrtc/audio/channel_receive_frame_transformer_delegate_unittest.cc +++ b/third_party/libwebrtc/audio/channel_receive_frame_transformer_delegate_unittest.cc @@ -13,11 +13,11 @@ #include #include +#include "api/test/mock_frame_transformer.h" +#include "api/test/mock_transformable_audio_frame.h" #include "audio/channel_send_frame_transformer_delegate.h" #include "test/gmock.h" #include "test/gtest.h" -#include "test/mock_frame_transformer.h" -#include "test/mock_transformable_frame.h" namespace webrtc { namespace { diff --git a/third_party/libwebrtc/audio/channel_receive_unittest.cc b/third_party/libwebrtc/audio/channel_receive_unittest.cc index aab8a95d8b..8ca1e9e32b 100644 --- a/third_party/libwebrtc/audio/channel_receive_unittest.cc +++ b/third_party/libwebrtc/audio/channel_receive_unittest.cc @@ -14,6 +14,7 @@ #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/crypto/frame_decryptor_interface.h" #include "api/task_queue/default_task_queue_factory.h" +#include "api/test/mock_frame_transformer.h" #include "logging/rtc_event_log/mock/mock_rtc_event_log.h" #include "modules/audio_device/include/audio_device.h" #include "modules/audio_device/include/mock_audio_device.h" @@ -29,7 +30,6 @@ #include "test/gmock.h" #include "test/gtest.h" #include "test/mock_audio_decoder_factory.h" -#include "test/mock_frame_transformer.h" #include "test/mock_transport.h" #include "test/time_controller/simulated_time_controller.h" diff --git a/third_party/libwebrtc/audio/channel_send_frame_transformer_delegate.cc b/third_party/libwebrtc/audio/channel_send_frame_transformer_delegate.cc index ac32410aed..6d3c011862 100644 --- a/third_party/libwebrtc/audio/channel_send_frame_transformer_delegate.cc +++ b/third_party/libwebrtc/audio/channel_send_frame_transformer_delegate.cc @@ -58,7 +58,8 @@ class TransformableOutgoingAudioFrame absl::optional absolute_capture_timestamp_ms, uint32_t ssrc, std::vector csrcs, - const std::string& codec_mime_type) + const std::string& codec_mime_type, + absl::optional sequence_number) : frame_type_(frame_type), payload_type_(payload_type), rtp_timestamp_with_offset_(rtp_timestamp_with_offset), @@ -66,7 +67,8 @@ class TransformableOutgoingAudioFrame absolute_capture_timestamp_ms_(absolute_capture_timestamp_ms), ssrc_(ssrc), csrcs_(std::move(csrcs)), - codec_mime_type_(codec_mime_type) {} + codec_mime_type_(codec_mime_type), + sequence_number_(sequence_number) {} ~TransformableOutgoingAudioFrame() override = default; rtc::ArrayView GetData() const override { return payload_; } void SetData(rtc::ArrayView data) override { @@ -88,7 +90,7 @@ class TransformableOutgoingAudioFrame } const absl::optional SequenceNumber() const override { - return absl::nullopt; + return sequence_number_; } void SetRTPTimestamp(uint32_t rtp_timestamp_with_offset) override { @@ -108,6 +110,7 @@ class TransformableOutgoingAudioFrame uint32_t ssrc_; std::vector csrcs_; std::string codec_mime_type_; + absl::optional sequence_number_; }; } // namespace @@ -155,7 +158,8 @@ void ChannelSendFrameTransformerDelegate::Transform( std::make_unique( frame_type, payload_type, rtp_timestamp, payload_data, payload_size, absolute_capture_timestamp_ms, ssrc, - /*csrcs=*/std::vector(), codec_mimetype)); + /*csrcs=*/std::vector(), codec_mimetype, + /*sequence_number=*/absl::nullopt)); } void ChannelSendFrameTransformerDelegate::OnTransformedFrame( @@ -203,7 +207,7 @@ std::unique_ptr CloneSenderAudioFrame( original->GetPayloadType(), original->GetTimestamp(), original->GetData().data(), original->GetData().size(), original->AbsoluteCaptureTimestamp(), original->GetSsrc(), - std::move(csrcs), original->GetMimeType()); + std::move(csrcs), original->GetMimeType(), original->SequenceNumber()); } } // namespace webrtc diff --git a/third_party/libwebrtc/audio/channel_send_frame_transformer_delegate_unittest.cc b/third_party/libwebrtc/audio/channel_send_frame_transformer_delegate_unittest.cc index 483a2cce78..5c025bb345 100644 --- a/third_party/libwebrtc/audio/channel_send_frame_transformer_delegate_unittest.cc +++ b/third_party/libwebrtc/audio/channel_send_frame_transformer_delegate_unittest.cc @@ -15,11 +15,11 @@ #include #include "absl/memory/memory.h" +#include "api/test/mock_frame_transformer.h" +#include "api/test/mock_transformable_audio_frame.h" #include "rtc_base/task_queue_for_test.h" #include "test/gmock.h" #include "test/gtest.h" -#include "test/mock_frame_transformer.h" -#include "test/mock_transformable_frame.h" namespace webrtc { namespace { @@ -59,7 +59,7 @@ class MockChannelSend { }; std::unique_ptr CreateMockReceiverFrame( - std::vector csrcs) { + const std::vector& csrcs) { std::unique_ptr mock_frame = std::make_unique>(); rtc::ArrayView payload(mock_data); @@ -68,6 +68,7 @@ std::unique_ptr CreateMockReceiverFrame( ON_CALL(*mock_frame, GetDirection) .WillByDefault(Return(TransformableFrameInterface::Direction::kReceiver)); ON_CALL(*mock_frame, GetContributingSources).WillByDefault(Return(csrcs)); + ON_CALL(*mock_frame, SequenceNumber).WillByDefault(Return(987654321)); return mock_frame; } @@ -167,7 +168,7 @@ TEST(ChannelSendFrameTransformerDelegateTest, delegate->Init(); ASSERT_TRUE(callback); - std::vector csrcs = {123, 234, 345, 456}; + const std::vector csrcs = {123, 234, 345, 456}; EXPECT_CALL(mock_channel, SendFrame).Times(0); EXPECT_CALL(mock_channel, SendFrame(_, 0, 0, ElementsAreArray(mock_data), _, ElementsAreArray(csrcs))); @@ -252,6 +253,7 @@ TEST(ChannelSendFrameTransformerDelegateTest, CloningReceiverFrameWithCsrcs) { ASSERT_NE(frame->GetContributingSources().size(), 0u); EXPECT_THAT(cloned_frame->GetContributingSources(), ElementsAreArray(frame->GetContributingSources())); + EXPECT_EQ(cloned_frame->SequenceNumber(), frame->SequenceNumber()); } } // namespace diff --git a/third_party/libwebrtc/audio/channel_send_unittest.cc b/third_party/libwebrtc/audio/channel_send_unittest.cc index c86dcefadc..77d8479519 100644 --- a/third_party/libwebrtc/audio/channel_send_unittest.cc +++ b/third_party/libwebrtc/audio/channel_send_unittest.cc @@ -17,12 +17,12 @@ #include "api/environment/environment.h" #include "api/environment/environment_factory.h" #include "api/scoped_refptr.h" +#include "api/test/mock_frame_transformer.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" #include "call/rtp_transport_controller_send.h" #include "rtc_base/gunit.h" #include "test/gtest.h" -#include "test/mock_frame_transformer.h" #include "test/mock_transport.h" #include "test/scoped_key_value_config.h" #include "test/time_controller/simulated_time_controller.h" -- cgit v1.2.3