diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/third_party/webrtc/audio | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/third_party/webrtc/audio')
23 files changed, 307 insertions, 217 deletions
diff --git a/chromium/third_party/webrtc/audio/BUILD.gn b/chromium/third_party/webrtc/audio/BUILD.gn index 725128bb1a8..7df741e9a78 100644 --- a/chromium/third_party/webrtc/audio/BUILD.gn +++ b/chromium/third_party/webrtc/audio/BUILD.gn @@ -71,6 +71,7 @@ rtc_library("audio") { "../modules/audio_coding:audio_coding_module_typedefs", "../modules/audio_coding:audio_encoder_cng", "../modules/audio_coding:audio_network_adaptor_config", + "../modules/audio_coding:red", "../modules/audio_device", "../modules/audio_processing", "../modules/audio_processing:api", @@ -95,6 +96,8 @@ rtc_library("audio") { "../system_wrappers:field_trial", "../system_wrappers:metrics", "utility:audio_frame_operations", + ] + absl_deps = [ "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/types:optional", ] diff --git a/chromium/third_party/webrtc/audio/audio_send_stream.cc b/chromium/third_party/webrtc/audio/audio_send_stream.cc index 8730c452582..42705aa99a5 100644 --- a/chromium/third_party/webrtc/audio/audio_send_stream.cc +++ b/chromium/third_party/webrtc/audio/audio_send_stream.cc @@ -31,6 +31,7 @@ #include "logging/rtc_event_log/events/rtc_event_audio_send_stream_config.h" #include "logging/rtc_event_log/rtc_stream_config.h" #include "modules/audio_coding/codecs/cng/audio_encoder_cng.h" +#include "modules/audio_coding/codecs/red/audio_encoder_copy_red.h" #include "modules/audio_processing/include/audio_processing.h" #include "modules/rtp_rtcp/source/rtp_header_extensions.h" #include "rtc_base/checks.h" @@ -544,10 +545,12 @@ void AudioSendStream::SetTransportOverhead( } void AudioSendStream::UpdateOverheadForEncoder() { - const size_t overhead_per_packet_bytes = GetPerPacketOverheadBytes(); - if (overhead_per_packet_bytes == 0) { - return; // Overhead is not known yet, do not tell the encoder. + size_t overhead_per_packet_bytes = GetPerPacketOverheadBytes(); + 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); }); @@ -644,7 +647,7 @@ bool AudioSendStream::SetupSendCodec(const Config& new_config) { } } - // Wrap the encoder in a an AudioEncoderCNG, if VAD is enabled. + // Wrap the encoder in an AudioEncoderCNG, if VAD is enabled. if (spec.cng_payload_type) { AudioEncoderCngConfig cng_config; cng_config.num_channels = encoder->NumChannels(); @@ -657,6 +660,14 @@ bool AudioSendStream::SetupSendCodec(const Config& new_config) { new_config.send_codec_spec->format.clockrate_hz); } + // Wrap the encoder in a RED encoder, if RED is enabled. + if (spec.red_payload_type) { + AudioEncoderCopyRed::Config red_config; + red_config.payload_type = *spec.red_payload_type; + red_config.speech_encoder = std::move(encoder); + encoder = std::make_unique<AudioEncoderCopyRed>(std::move(red_config)); + } + // Set currently known overhead (used in ANA, opus only). // If overhead changes later, it will be updated in UpdateOverheadForEncoder. { diff --git a/chromium/third_party/webrtc/audio/audio_send_stream.h b/chromium/third_party/webrtc/audio/audio_send_stream.h index 92e9a7fb165..13166d47e71 100644 --- a/chromium/third_party/webrtc/audio/audio_send_stream.h +++ b/chromium/third_party/webrtc/audio/audio_send_stream.h @@ -20,7 +20,7 @@ #include "call/audio_send_stream.h" #include "call/audio_state.h" #include "call/bitrate_allocator.h" -#include "modules/rtp_rtcp/include/rtp_rtcp.h" +#include "modules/rtp_rtcp/source/rtp_rtcp_interface.h" #include "rtc_base/constructor_magic.h" #include "rtc_base/experiments/struct_parameters_parser.h" #include "rtc_base/race_checker.h" @@ -175,7 +175,7 @@ class AudioSendStream final : public webrtc::AudioSendStream, RTC_GUARDED_BY(worker_queue_); RtpTransportControllerSendInterface* const rtp_transport_; - RtpRtcp* const rtp_rtcp_module_; + RtpRtcpInterface* const rtp_rtcp_module_; absl::optional<RtpState> const suspended_rtp_state_; // RFC 5285: Each distinct extension MUST have a unique ID. The value 0 is @@ -195,6 +195,7 @@ class AudioSendStream final : public webrtc::AudioSendStream, static int TransportSeqNumId(const Config& config); rtc::CriticalSection 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_ diff --git a/chromium/third_party/webrtc/audio/audio_send_stream_unittest.cc b/chromium/third_party/webrtc/audio/audio_send_stream_unittest.cc index 334fdf50f7d..d094198721d 100644 --- a/chromium/third_party/webrtc/audio/audio_send_stream_unittest.cc +++ b/chromium/third_party/webrtc/audio/audio_send_stream_unittest.cc @@ -89,7 +89,10 @@ const DataRate kMaxOverheadRate = kOverheadPerPacket / kMinFrameLength; class MockLimitObserver : public BitrateAllocator::LimitObserver { public: - MOCK_METHOD1(OnAllocationLimitsChanged, void(BitrateAllocationLimits)); + MOCK_METHOD(void, + OnAllocationLimitsChanged, + (BitrateAllocationLimits), + (override)); }; std::unique_ptr<MockAudioEncoder> SetupAudioEncoderMock( @@ -200,7 +203,7 @@ struct ConfigHelper { return *static_cast<MockAudioEncoderFactory*>( stream_config_.encoder_factory.get()); } - MockRtpRtcp* rtp_rtcp() { return &rtp_rtcp_; } + MockRtpRtcpInterface* rtp_rtcp() { return &rtp_rtcp_; } MockChannelSend* channel_send() { return channel_send_; } RtpTransportControllerSendInterface* transport() { return &rtp_transport_; } @@ -247,12 +250,12 @@ struct ConfigHelper { void SetupMockForSetupSendCodec(bool expect_set_encoder_call) { if (expect_set_encoder_call) { - EXPECT_CALL(*channel_send_, SetEncoderForMock(_, _)) - .WillOnce(Invoke( - [this](int payload_type, std::unique_ptr<AudioEncoder>* encoder) { - this->audio_encoder_ = std::move(*encoder); + EXPECT_CALL(*channel_send_, SetEncoder) + .WillOnce( + [this](int payload_type, std::unique_ptr<AudioEncoder> encoder) { + this->audio_encoder_ = std::move(encoder); return true; - })); + }); } } @@ -329,7 +332,7 @@ struct ConfigHelper { ::testing::StrictMock<MockRtcpBandwidthObserver> bandwidth_observer_; ::testing::NiceMock<MockRtcEventLog> event_log_; ::testing::NiceMock<MockRtpTransportControllerSend> rtp_transport_; - ::testing::NiceMock<MockRtpRtcp> rtp_rtcp_; + ::testing::NiceMock<MockRtpRtcpInterface> rtp_rtcp_; ::testing::NiceMock<MockLimitObserver> limit_observer_; BitrateAllocator bitrate_allocator_; // |worker_queue| is defined last to ensure all pending tasks are cancelled @@ -368,6 +371,7 @@ TEST(AudioSendStreamTest, ConfigToString) { config.send_codec_spec->nack_enabled = true; config.send_codec_spec->transport_cc_enabled = false; config.send_codec_spec->cng_payload_type = 42; + config.send_codec_spec->red_payload_type = 43; config.encoder_factory = MockAudioEncoderFactory::CreateUnusedFactory(); config.rtp.extmap_allow_mixed = true; config.rtp.extensions.push_back( @@ -380,7 +384,7 @@ TEST(AudioSendStreamTest, ConfigToString) { "send_transport: null, " "min_bitrate_bps: 12000, max_bitrate_bps: 34000, " "send_codec_spec: {nack_enabled: true, transport_cc_enabled: false, " - "cng_payload_type: 42, payload_type: 103, " + "cng_payload_type: 42, red_payload_type: 43, payload_type: 103, " "format: {name: isac, clockrate_hz: 16000, num_channels: 1, " "parameters: {}}}}", config.ToString()); @@ -473,7 +477,7 @@ TEST(AudioSendStreamTest, GetStatsAudioLevel) { ConfigHelper helper(false, true, use_null_audio_processing); auto send_stream = helper.CreateAudioSendStream(); helper.SetupMockForGetStats(use_null_audio_processing); - EXPECT_CALL(*helper.channel_send(), ProcessAndEncodeAudioForMock(_)) + EXPECT_CALL(*helper.channel_send(), ProcessAndEncodeAudio) .Times(AnyNumber()); constexpr int kSampleRateHz = 48000; @@ -558,15 +562,13 @@ TEST(AudioSendStreamTest, SendCodecCanApplyVad) { helper.config().send_codec_spec = AudioSendStream::Config::SendCodecSpec(9, kG722Format); helper.config().send_codec_spec->cng_payload_type = 105; - using ::testing::Invoke; std::unique_ptr<AudioEncoder> stolen_encoder; - EXPECT_CALL(*helper.channel_send(), SetEncoderForMock(_, _)) - .WillOnce( - Invoke([&stolen_encoder](int payload_type, - std::unique_ptr<AudioEncoder>* encoder) { - stolen_encoder = std::move(*encoder); - return true; - })); + EXPECT_CALL(*helper.channel_send(), SetEncoder) + .WillOnce([&stolen_encoder](int payload_type, + std::unique_ptr<AudioEncoder> encoder) { + stolen_encoder = std::move(encoder); + return true; + }); EXPECT_CALL(*helper.channel_send(), RegisterCngPayloadType(105, 8000)); auto send_stream = helper.CreateAudioSendStream(); @@ -748,8 +750,7 @@ TEST(AudioSendStreamTest, DontRecreateEncoder) { // test to be correct, it's instead set-up manually here. Otherwise a simple // change to ConfigHelper (say to WillRepeatedly) would silently make this // test useless. - EXPECT_CALL(*helper.channel_send(), SetEncoderForMock(_, _)) - .WillOnce(Return()); + EXPECT_CALL(*helper.channel_send(), SetEncoder).WillOnce(Return()); EXPECT_CALL(*helper.channel_send(), RegisterCngPayloadType(105, 8000)); @@ -794,7 +795,7 @@ TEST(AudioSendStreamTest, OnTransportOverheadChanged) { auto new_config = helper.config(); // CallEncoder will be called on overhead change. - EXPECT_CALL(*helper.channel_send(), CallEncoder(::testing::_)).Times(1); + EXPECT_CALL(*helper.channel_send(), CallEncoder); const size_t transport_overhead_per_packet_bytes = 333; send_stream->SetTransportOverhead(transport_overhead_per_packet_bytes); @@ -804,6 +805,27 @@ TEST(AudioSendStreamTest, OnTransportOverheadChanged) { } } +TEST(AudioSendStreamTest, DoesntCallEncoderWhenOverheadUnchanged) { + for (bool use_null_audio_processing : {false, true}) { + ConfigHelper helper(false, true, use_null_audio_processing); + auto send_stream = helper.CreateAudioSendStream(); + auto new_config = helper.config(); + + // CallEncoder will be called on overhead change. + EXPECT_CALL(*helper.channel_send(), CallEncoder); + const size_t transport_overhead_per_packet_bytes = 333; + send_stream->SetTransportOverhead(transport_overhead_per_packet_bytes); + + // Set the same overhead again, CallEncoder should not be called again. + EXPECT_CALL(*helper.channel_send(), CallEncoder).Times(0); + send_stream->SetTransportOverhead(transport_overhead_per_packet_bytes); + + // New overhead, call CallEncoder again + EXPECT_CALL(*helper.channel_send(), CallEncoder); + send_stream->SetTransportOverhead(transport_overhead_per_packet_bytes + 1); + } +} + TEST(AudioSendStreamTest, AudioOverheadChanged) { for (bool use_null_audio_processing : {false, true}) { ConfigHelper helper(false, true, use_null_audio_processing); diff --git a/chromium/third_party/webrtc/audio/audio_state_unittest.cc b/chromium/third_party/webrtc/audio/audio_state_unittest.cc index 76e08c549c2..2bbe0fb0b70 100644 --- a/chromium/third_party/webrtc/audio/audio_state_unittest.cc +++ b/chromium/third_party/webrtc/audio/audio_state_unittest.cc @@ -60,8 +60,10 @@ class FakeAudioSource : public AudioMixer::Source { int PreferredSampleRate() const /*override*/ { return kSampleRate; } - MOCK_METHOD2(GetAudioFrameWithInfo, - AudioFrameInfo(int sample_rate_hz, AudioFrame* audio_frame)); + MOCK_METHOD(AudioFrameInfo, + GetAudioFrameWithInfo, + (int sample_rate_hz, AudioFrame*), + (override)); }; std::vector<int16_t> Create10msTestData(int sample_rate_hz, diff --git a/chromium/third_party/webrtc/audio/channel_receive.cc b/chromium/third_party/webrtc/audio/channel_receive.cc index 66b4bb11f58..34b6d097afa 100644 --- a/chromium/third_party/webrtc/audio/channel_receive.cc +++ b/chromium/third_party/webrtc/audio/channel_receive.cc @@ -33,11 +33,11 @@ #include "modules/pacing/packet_router.h" #include "modules/rtp_rtcp/include/receive_statistics.h" #include "modules/rtp_rtcp/include/remote_ntp_time_estimator.h" -#include "modules/rtp_rtcp/include/rtp_rtcp.h" #include "modules/rtp_rtcp/source/absolute_capture_time_receiver.h" #include "modules/rtp_rtcp/source/rtp_header_extensions.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" #include "modules/rtp_rtcp/source/rtp_rtcp_config.h" +#include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h" #include "modules/utility/include/process_thread.h" #include "rtc_base/checks.h" #include "rtc_base/critical_section.h" @@ -216,7 +216,7 @@ class ChannelReceive : public ChannelReceiveInterface { std::map<uint8_t, int> payload_type_frequencies_; std::unique_ptr<ReceiveStatistics> rtp_receive_statistics_; - std::unique_ptr<RtpRtcp> _rtpRtcpModule; + std::unique_ptr<ModuleRtpRtcpImpl2> rtp_rtcp_; const uint32_t remote_ssrc_; // Info for GetSyncInfo is updated on network or worker thread, and queried on @@ -297,7 +297,7 @@ void ChannelReceive::OnReceivedPayloadData( } int64_t round_trip_time = 0; - _rtpRtcpModule->RTT(remote_ssrc_, &round_trip_time, NULL, NULL, NULL); + rtp_rtcp_->RTT(remote_ssrc_, &round_trip_time, NULL, NULL, NULL); std::vector<uint16_t> nack_list = acm_receiver_.GetNackList(round_trip_time); if (!nack_list.empty()) { @@ -495,7 +495,7 @@ ChannelReceive::ChannelReceive( _outputAudioLevel.ResetLevelFullRange(); rtp_receive_statistics_->EnableRetransmitDetection(remote_ssrc_, true); - RtpRtcp::Configuration configuration; + RtpRtcpInterface::Configuration configuration; configuration.clock = clock; configuration.audio = true; configuration.receiver_only = true; @@ -507,14 +507,14 @@ ChannelReceive::ChannelReceive( if (frame_transformer) InitFrameTransformerDelegate(std::move(frame_transformer)); - _rtpRtcpModule = RtpRtcp::Create(configuration); - _rtpRtcpModule->SetSendingMediaStatus(false); - _rtpRtcpModule->SetRemoteSSRC(remote_ssrc_); + rtp_rtcp_ = ModuleRtpRtcpImpl2::Create(configuration); + rtp_rtcp_->SetSendingMediaStatus(false); + rtp_rtcp_->SetRemoteSSRC(remote_ssrc_); - _moduleProcessThreadPtr->RegisterModule(_rtpRtcpModule.get(), RTC_FROM_HERE); + _moduleProcessThreadPtr->RegisterModule(rtp_rtcp_.get(), RTC_FROM_HERE); // Ensure that RTCP is enabled for the created channel. - _rtpRtcpModule->SetRTCPStatus(RtcpMode::kCompound); + rtp_rtcp_->SetRTCPStatus(RtcpMode::kCompound); } ChannelReceive::~ChannelReceive() { @@ -527,7 +527,7 @@ ChannelReceive::~ChannelReceive() { StopPlayout(); if (_moduleProcessThreadPtr) - _moduleProcessThreadPtr->DeRegisterModule(_rtpRtcpModule.get()); + _moduleProcessThreadPtr->DeRegisterModule(rtp_rtcp_.get()); } void ChannelReceive::SetSink(AudioSinkInterface* sink) { @@ -659,7 +659,7 @@ void ChannelReceive::ReceivedRTCPPacket(const uint8_t* data, size_t length) { UpdatePlayoutTimestamp(true, rtc::TimeMillis()); // Deliver RTCP packet to RTP/RTCP module for parsing - _rtpRtcpModule->IncomingRtcpPacket(data, length); + rtp_rtcp_->IncomingRtcpPacket(data, length); int64_t rtt = GetRTT(); if (rtt == 0) { @@ -670,8 +670,8 @@ void ChannelReceive::ReceivedRTCPPacket(const uint8_t* data, size_t length) { uint32_t ntp_secs = 0; uint32_t ntp_frac = 0; uint32_t rtp_timestamp = 0; - if (0 != _rtpRtcpModule->RemoteNTP(&ntp_secs, &ntp_frac, NULL, NULL, - &rtp_timestamp)) { + if (0 != + rtp_rtcp_->RemoteNTP(&ntp_secs, &ntp_frac, NULL, NULL, &rtp_timestamp)) { // Waiting for RTCP. return; } @@ -709,14 +709,14 @@ void ChannelReceive::RegisterReceiverCongestionControlObjects( RTC_DCHECK(packet_router); RTC_DCHECK(!packet_router_); constexpr bool remb_candidate = false; - packet_router->AddReceiveRtpModule(_rtpRtcpModule.get(), remb_candidate); + packet_router->AddReceiveRtpModule(rtp_rtcp_.get(), remb_candidate); packet_router_ = packet_router; } void ChannelReceive::ResetReceiverCongestionControlObjects() { RTC_DCHECK(worker_thread_checker_.IsCurrent()); RTC_DCHECK(packet_router_); - packet_router_->RemoveReceiveRtpModule(_rtpRtcpModule.get()); + packet_router_->RemoveReceiveRtpModule(rtp_rtcp_.get()); packet_router_ = nullptr; } @@ -781,7 +781,7 @@ void ChannelReceive::SetNACKStatus(bool enable, int max_packets) { // Called when we are missing one or more packets. int ChannelReceive::ResendPackets(const uint16_t* sequence_numbers, int length) { - return _rtpRtcpModule->SendNACK(sequence_numbers, length); + return rtp_rtcp_->SendNACK(sequence_numbers, length); } void ChannelReceive::SetAssociatedSendChannel( @@ -877,9 +877,9 @@ int ChannelReceive::GetBaseMinimumPlayoutDelayMs() const { absl::optional<Syncable::Info> ChannelReceive::GetSyncInfo() const { RTC_DCHECK(module_process_thread_checker_.IsCurrent()); Syncable::Info info; - if (_rtpRtcpModule->RemoteNTP(&info.capture_time_ntp_secs, - &info.capture_time_ntp_frac, nullptr, nullptr, - &info.capture_time_source_clock) != 0) { + if (rtp_rtcp_->RemoteNTP(&info.capture_time_ntp_secs, + &info.capture_time_ntp_frac, nullptr, nullptr, + &info.capture_time_source_clock) != 0) { return absl::nullopt; } { @@ -942,7 +942,7 @@ int ChannelReceive::GetRtpTimestampRateHz() const { int64_t ChannelReceive::GetRTT() const { std::vector<RTCPReportBlock> report_blocks; - _rtpRtcpModule->RemoteRTCPStat(&report_blocks); + rtp_rtcp_->RemoteRTCPStat(&report_blocks); // TODO(nisse): Could we check the return value from the ->RTT() call below, // instead of checking if we have any report blocks? @@ -961,8 +961,7 @@ int64_t ChannelReceive::GetRTT() const { int64_t min_rtt = 0; // TODO(nisse): This method computes RTT based on sender reports, even though // a receive stream is not supposed to do that. - if (_rtpRtcpModule->RTT(remote_ssrc_, &rtt, &avg_rtt, &min_rtt, &max_rtt) != - 0) { + if (rtp_rtcp_->RTT(remote_ssrc_, &rtt, &avg_rtt, &min_rtt, &max_rtt) != 0) { return 0; } return rtt; diff --git a/chromium/third_party/webrtc/audio/channel_send.cc b/chromium/third_party/webrtc/audio/channel_send.cc index 3387f271ba0..16d1da648c9 100644 --- a/chromium/third_party/webrtc/audio/channel_send.cc +++ b/chromium/third_party/webrtc/audio/channel_send.cc @@ -29,6 +29,7 @@ #include "modules/audio_coding/include/audio_coding_module.h" #include "modules/audio_processing/rms_level.h" #include "modules/pacing/packet_router.h" +#include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h" #include "modules/utility/include/process_thread.h" #include "rtc_base/checks.h" #include "rtc_base/event.h" @@ -106,7 +107,7 @@ class ChannelSend : public ChannelSendInterface, ANAStats GetANAStatistics() const override; // Used by AudioSendStream. - RtpRtcp* GetRtpRtcp() const override; + RtpRtcpInterface* GetRtpRtcp() const override; void RegisterCngPayloadType(int payload_type, int payload_frequency) override; @@ -191,7 +192,7 @@ class ChannelSend : public ChannelSendInterface, RtcEventLog* const event_log_; - std::unique_ptr<RtpRtcp> _rtpRtcpModule; + std::unique_ptr<ModuleRtpRtcpImpl2> rtp_rtcp_; std::unique_ptr<RTPSenderAudio> rtp_sender_audio_; std::unique_ptr<AudioCodingModule> audio_coding_; @@ -388,9 +389,9 @@ int32_t ChannelSend::SendData(AudioFrameType frameType, // Asynchronously transform the payload before sending it. After the payload // is transformed, the delegate will call SendRtpAudio to send it. frame_transformer_delegate_->Transform( - frameType, payloadType, rtp_timestamp, _rtpRtcpModule->StartTimestamp(), + frameType, payloadType, rtp_timestamp, rtp_rtcp_->StartTimestamp(), payloadData, payloadSize, absolute_capture_timestamp_ms, - _rtpRtcpModule->SSRC()); + rtp_rtcp_->SSRC()); return 0; } return SendRtpAudio(frameType, payloadType, rtp_timestamp, payload, @@ -427,7 +428,7 @@ int32_t ChannelSend::SendRtpAudio(AudioFrameType frameType, // Encrypt the audio payload into the buffer. size_t bytes_written = 0; int encrypt_status = frame_encryptor_->Encrypt( - cricket::MEDIA_TYPE_AUDIO, _rtpRtcpModule->SSRC(), + cricket::MEDIA_TYPE_AUDIO, rtp_rtcp_->SSRC(), /*additional_data=*/nullptr, payload, encrypted_audio_payload, &bytes_written); if (encrypt_status != 0) { @@ -449,12 +450,12 @@ int32_t ChannelSend::SendRtpAudio(AudioFrameType frameType, // Push data from ACM to RTP/RTCP-module to deliver audio frame for // packetization. - if (!_rtpRtcpModule->OnSendingRtpFrame(rtp_timestamp, - // Leaving the time when this frame was - // received from the capture device as - // undefined for voice for now. - -1, payloadType, - /*force_sender_report=*/false)) { + if (!rtp_rtcp_->OnSendingRtpFrame(rtp_timestamp, + // Leaving the time when this frame was + // received from the capture device as + // undefined for voice for now. + -1, payloadType, + /*force_sender_report=*/false)) { return -1; } @@ -466,9 +467,8 @@ int32_t ChannelSend::SendRtpAudio(AudioFrameType frameType, // This call will trigger Transport::SendPacket() from the RTP/RTCP module. if (!rtp_sender_audio_->SendAudio( - frameType, payloadType, - rtp_timestamp + _rtpRtcpModule->StartTimestamp(), payload.data(), - payload.size(), absolute_capture_timestamp_ms)) { + frameType, payloadType, rtp_timestamp + rtp_rtcp_->StartTimestamp(), + payload.data(), payload.size(), absolute_capture_timestamp_ms)) { RTC_DLOG(LS_ERROR) << "ChannelSend::SendData() failed to send data to RTP/RTCP module"; return -1; @@ -512,7 +512,7 @@ ChannelSend::ChannelSend( audio_coding_.reset(AudioCodingModule::Create(AudioCodingModule::Config())); - RtpRtcp::Configuration configuration; + RtpRtcpInterface::Configuration configuration; configuration.bandwidth_callback = rtcp_observer_.get(); configuration.transport_feedback_callback = feedback_observer_proxy_.get(); configuration.clock = (clock ? clock : Clock::GetRealTimeClock()); @@ -530,16 +530,16 @@ ChannelSend::ChannelSend( configuration.local_media_ssrc = ssrc; - _rtpRtcpModule = RtpRtcp::Create(configuration); - _rtpRtcpModule->SetSendingMediaStatus(false); + rtp_rtcp_ = ModuleRtpRtcpImpl2::Create(configuration); + rtp_rtcp_->SetSendingMediaStatus(false); - rtp_sender_audio_ = std::make_unique<RTPSenderAudio>( - configuration.clock, _rtpRtcpModule->RtpSender()); + rtp_sender_audio_ = std::make_unique<RTPSenderAudio>(configuration.clock, + rtp_rtcp_->RtpSender()); - _moduleProcessThreadPtr->RegisterModule(_rtpRtcpModule.get(), RTC_FROM_HERE); + _moduleProcessThreadPtr->RegisterModule(rtp_rtcp_.get(), RTC_FROM_HERE); // Ensure that RTCP is enabled by default for the created channel. - _rtpRtcpModule->SetRTCPStatus(RtcpMode::kCompound); + rtp_rtcp_->SetRTCPStatus(RtcpMode::kCompound); int error = audio_coding_->RegisterTransportCallback(this); RTC_DCHECK_EQ(0, error); @@ -559,7 +559,7 @@ ChannelSend::~ChannelSend() { RTC_DCHECK_EQ(0, error); if (_moduleProcessThreadPtr) - _moduleProcessThreadPtr->DeRegisterModule(_rtpRtcpModule.get()); + _moduleProcessThreadPtr->DeRegisterModule(rtp_rtcp_.get()); } void ChannelSend::StartSend() { @@ -567,8 +567,8 @@ void ChannelSend::StartSend() { RTC_DCHECK(!sending_); sending_ = true; - _rtpRtcpModule->SetSendingMediaStatus(true); - int ret = _rtpRtcpModule->SetSendingStatus(true); + rtp_rtcp_->SetSendingMediaStatus(true); + int ret = rtp_rtcp_->SetSendingStatus(true); RTC_DCHECK_EQ(0, ret); // It is now OK to start processing on the encoder task queue. encoder_queue_.PostTask([this] { @@ -594,10 +594,10 @@ void ChannelSend::StopSend() { // Reset sending SSRC and sequence number and triggers direct transmission // of RTCP BYE - if (_rtpRtcpModule->SetSendingStatus(false) == -1) { + if (rtp_rtcp_->SetSendingStatus(false) == -1) { RTC_DLOG(LS_ERROR) << "StartSend() RTP/RTCP failed to stop sending"; } - _rtpRtcpModule->SetSendingMediaStatus(false); + rtp_rtcp_->SetSendingMediaStatus(false); } void ChannelSend::SetEncoder(int payload_type, @@ -608,8 +608,8 @@ void ChannelSend::SetEncoder(int payload_type, // The RTP/RTCP module needs to know the RTP timestamp rate (i.e. clockrate) // as well as some other things, so we collect this info and send it along. - _rtpRtcpModule->RegisterSendPayloadFrequency(payload_type, - encoder->RtpTimestampRateHz()); + rtp_rtcp_->RegisterSendPayloadFrequency(payload_type, + encoder->RtpTimestampRateHz()); rtp_sender_audio_->RegisterAudioPayload("audio", payload_type, encoder->RtpTimestampRateHz(), encoder->NumChannels(), 0); @@ -664,7 +664,7 @@ void ChannelSend::OnUplinkPacketLossRate(float packet_loss_rate) { void ChannelSend::ReceivedRTCPPacket(const uint8_t* data, size_t length) { // Deliver RTCP packet to RTP/RTCP module for parsing - _rtpRtcpModule->IncomingRtcpPacket(data, length); + rtp_rtcp_->IncomingRtcpPacket(data, length); int64_t rtt = GetRTT(); if (rtt == 0) { @@ -713,7 +713,7 @@ bool ChannelSend::SendTelephoneEventOutband(int event, int duration_ms) { void ChannelSend::RegisterCngPayloadType(int payload_type, int payload_frequency) { - _rtpRtcpModule->RegisterSendPayloadFrequency(payload_type, payload_frequency); + rtp_rtcp_->RegisterSendPayloadFrequency(payload_type, payload_frequency); rtp_sender_audio_->RegisterAudioPayload("CN", payload_type, payload_frequency, 1, 0); } @@ -723,7 +723,7 @@ void ChannelSend::SetSendTelephoneEventPayloadType(int payload_type, RTC_DCHECK_RUN_ON(&worker_thread_checker_); RTC_DCHECK_LE(0, payload_type); RTC_DCHECK_GE(127, payload_type); - _rtpRtcpModule->RegisterSendPayloadFrequency(payload_type, payload_frequency); + rtp_rtcp_->RegisterSendPayloadFrequency(payload_type, payload_frequency); rtp_sender_audio_->RegisterAudioPayload("telephone-event", payload_type, payload_frequency, 0, 0); } @@ -732,9 +732,9 @@ void ChannelSend::SetSendAudioLevelIndicationStatus(bool enable, int id) { RTC_DCHECK_RUN_ON(&worker_thread_checker_); _includeAudioLevelIndication = enable; if (enable) { - _rtpRtcpModule->RegisterRtpHeaderExtension(AudioLevel::kUri, id); + rtp_rtcp_->RegisterRtpHeaderExtension(AudioLevel::kUri, id); } else { - _rtpRtcpModule->DeregisterSendRtpHeaderExtension(AudioLevel::kUri); + rtp_rtcp_->DeregisterSendRtpHeaderExtension(AudioLevel::kUri); } } @@ -755,19 +755,19 @@ void ChannelSend::RegisterSenderCongestionControlObjects( feedback_observer_proxy_->SetTransportFeedbackObserver( transport_feedback_observer); rtp_packet_pacer_proxy_->SetPacketPacer(rtp_packet_pacer); - _rtpRtcpModule->SetStorePacketsStatus(true, 600); + rtp_rtcp_->SetStorePacketsStatus(true, 600); constexpr bool remb_candidate = false; - packet_router->AddSendRtpModule(_rtpRtcpModule.get(), remb_candidate); + packet_router->AddSendRtpModule(rtp_rtcp_.get(), remb_candidate); packet_router_ = packet_router; } void ChannelSend::ResetSenderCongestionControlObjects() { RTC_DCHECK_RUN_ON(&worker_thread_checker_); RTC_DCHECK(packet_router_); - _rtpRtcpModule->SetStorePacketsStatus(false, 600); + rtp_rtcp_->SetStorePacketsStatus(false, 600); rtcp_observer_->SetBandwidthObserver(nullptr); feedback_observer_proxy_->SetTransportFeedbackObserver(nullptr); - packet_router_->RemoveSendRtpModule(_rtpRtcpModule.get()); + packet_router_->RemoveSendRtpModule(rtp_rtcp_.get()); packet_router_ = nullptr; rtp_packet_pacer_proxy_->SetPacketPacer(nullptr); } @@ -776,7 +776,7 @@ void ChannelSend::SetRTCP_CNAME(absl::string_view c_name) { RTC_DCHECK_RUN_ON(&worker_thread_checker_); // Note: SetCNAME() accepts a c string of length at most 255. const std::string c_name_limited(c_name.substr(0, 255)); - int ret = _rtpRtcpModule->SetCNAME(c_name_limited.c_str()) != 0; + int ret = rtp_rtcp_->SetCNAME(c_name_limited.c_str()) != 0; RTC_DCHECK_EQ(0, ret) << "SetRTCP_CNAME() failed to set RTCP CNAME"; } @@ -787,7 +787,7 @@ std::vector<ReportBlock> ChannelSend::GetRemoteRTCPReportBlocks() const { // report block according to RFC 3550. std::vector<RTCPReportBlock> rtcp_report_blocks; - int ret = _rtpRtcpModule->RemoteRTCPStat(&rtcp_report_blocks); + int ret = rtp_rtcp_->RemoteRTCPStat(&rtcp_report_blocks); RTC_DCHECK_EQ(0, ret); std::vector<ReportBlock> report_blocks; @@ -816,7 +816,7 @@ CallSendStatistics ChannelSend::GetRTCPStatistics() const { StreamDataCounters rtp_stats; StreamDataCounters rtx_stats; - _rtpRtcpModule->GetSendStreamDataCounters(&rtp_stats, &rtx_stats); + rtp_rtcp_->GetSendStreamDataCounters(&rtp_stats, &rtx_stats); stats.payload_bytes_sent = rtp_stats.transmitted.payload_bytes + rtx_stats.transmitted.payload_bytes; stats.header_and_padding_bytes_sent = @@ -829,7 +829,7 @@ CallSendStatistics ChannelSend::GetRTCPStatistics() const { stats.packetsSent = rtp_stats.transmitted.packets + rtx_stats.transmitted.packets; stats.retransmitted_packets_sent = rtp_stats.retransmitted.packets; - stats.report_block_datas = _rtpRtcpModule->GetLatestReportBlockData(); + stats.report_block_datas = rtp_rtcp_->GetLatestReportBlockData(); return stats; } @@ -894,14 +894,14 @@ ANAStats ChannelSend::GetANAStatistics() const { return audio_coding_->GetANAStats(); } -RtpRtcp* ChannelSend::GetRtpRtcp() const { +RtpRtcpInterface* ChannelSend::GetRtpRtcp() const { RTC_DCHECK(module_process_thread_checker_.IsCurrent()); - return _rtpRtcpModule.get(); + return rtp_rtcp_.get(); } int64_t ChannelSend::GetRTT() const { std::vector<RTCPReportBlock> report_blocks; - _rtpRtcpModule->RemoteRTCPStat(&report_blocks); + rtp_rtcp_->RemoteRTCPStat(&report_blocks); if (report_blocks.empty()) { return 0; @@ -913,8 +913,8 @@ int64_t ChannelSend::GetRTT() const { int64_t min_rtt = 0; // We don't know in advance the remote ssrc used by the other end's receiver // reports, so use the SSRC of the first report block for calculating the RTT. - if (_rtpRtcpModule->RTT(report_blocks[0].sender_ssrc, &rtt, &avg_rtt, - &min_rtt, &max_rtt) != 0) { + if (rtp_rtcp_->RTT(report_blocks[0].sender_ssrc, &rtt, &avg_rtt, &min_rtt, + &max_rtt) != 0) { return 0; } return rtt; diff --git a/chromium/third_party/webrtc/audio/channel_send.h b/chromium/third_party/webrtc/audio/channel_send.h index cb3b99287ba..56fea97f9c2 100644 --- a/chromium/third_party/webrtc/audio/channel_send.h +++ b/chromium/third_party/webrtc/audio/channel_send.h @@ -22,7 +22,7 @@ #include "api/function_view.h" #include "api/task_queue/task_queue_factory.h" #include "modules/rtp_rtcp/include/report_block_data.h" -#include "modules/rtp_rtcp/include/rtp_rtcp.h" +#include "modules/rtp_rtcp/source/rtp_rtcp_interface.h" #include "modules/rtp_rtcp/source/rtp_sender_audio.h" namespace webrtc { @@ -30,7 +30,6 @@ namespace webrtc { class FrameEncryptorInterface; class ProcessThread; class RtcEventLog; -class RtpRtcp; class RtpTransportControllerSendInterface; struct CallSendStatistics { @@ -97,7 +96,7 @@ class ChannelSendInterface { virtual void ProcessAndEncodeAudio( std::unique_ptr<AudioFrame> audio_frame) = 0; - virtual RtpRtcp* GetRtpRtcp() const = 0; + virtual RtpRtcpInterface* GetRtpRtcp() const = 0; // In RTP we currently rely on RTCP packets (|ReceivedRTCPPacket|) to inform // about RTT. diff --git a/chromium/third_party/webrtc/audio/mock_voe_channel_proxy.h b/chromium/third_party/webrtc/audio/mock_voe_channel_proxy.h index 38ad208e1a8..542358f6870 100644 --- a/chromium/third_party/webrtc/audio/mock_voe_channel_proxy.h +++ b/chromium/third_party/webrtc/audio/mock_voe_channel_proxy.h @@ -28,102 +28,144 @@ namespace test { class MockChannelReceive : public voe::ChannelReceiveInterface { public: - MOCK_METHOD2(SetNACKStatus, void(bool enable, int max_packets)); - MOCK_METHOD1(RegisterReceiverCongestionControlObjects, - void(PacketRouter* packet_router)); - MOCK_METHOD0(ResetReceiverCongestionControlObjects, void()); - MOCK_CONST_METHOD0(GetRTCPStatistics, CallReceiveStatistics()); - MOCK_CONST_METHOD0(GetNetworkStatistics, NetworkStatistics()); - MOCK_CONST_METHOD0(GetDecodingCallStatistics, AudioDecodingCallStats()); - MOCK_CONST_METHOD0(GetSpeechOutputLevelFullRange, int()); - MOCK_CONST_METHOD0(GetTotalOutputEnergy, double()); - MOCK_CONST_METHOD0(GetTotalOutputDuration, double()); - MOCK_CONST_METHOD0(GetDelayEstimate, uint32_t()); - MOCK_METHOD1(SetSink, void(AudioSinkInterface* sink)); - MOCK_METHOD1(OnRtpPacket, void(const RtpPacketReceived& packet)); - MOCK_METHOD2(ReceivedRTCPPacket, void(const uint8_t* packet, size_t length)); - MOCK_METHOD1(SetChannelOutputVolumeScaling, void(float scaling)); - MOCK_METHOD2(GetAudioFrameWithInfo, - AudioMixer::Source::AudioFrameInfo(int sample_rate_hz, - AudioFrame* audio_frame)); - MOCK_CONST_METHOD0(PreferredSampleRate, int()); - MOCK_METHOD1(SetAssociatedSendChannel, - void(const voe::ChannelSendInterface* send_channel)); - MOCK_CONST_METHOD2(GetPlayoutRtpTimestamp, - bool(uint32_t* rtp_timestamp, int64_t* time_ms)); - MOCK_METHOD2(SetEstimatedPlayoutNtpTimestampMs, - void(int64_t ntp_timestamp_ms, int64_t time_ms)); - MOCK_CONST_METHOD1(GetCurrentEstimatedPlayoutNtpTimestampMs, - absl::optional<int64_t>(int64_t now_ms)); - MOCK_CONST_METHOD0(GetSyncInfo, absl::optional<Syncable::Info>()); - MOCK_METHOD1(SetMinimumPlayoutDelay, void(int delay_ms)); - MOCK_METHOD1(SetBaseMinimumPlayoutDelayMs, bool(int delay_ms)); - MOCK_CONST_METHOD0(GetBaseMinimumPlayoutDelayMs, int()); - MOCK_CONST_METHOD0(GetReceiveCodec, - absl::optional<std::pair<int, SdpAudioFormat>>()); - MOCK_METHOD1(SetReceiveCodecs, - void(const std::map<int, SdpAudioFormat>& codecs)); - MOCK_CONST_METHOD0(GetSources, std::vector<RtpSource>()); - MOCK_METHOD0(StartPlayout, void()); - MOCK_METHOD0(StopPlayout, void()); - MOCK_METHOD1(SetDepacketizerToDecoderFrameTransformer, - void(rtc::scoped_refptr<webrtc::FrameTransformerInterface> - frame_transformer)); + MOCK_METHOD(void, SetNACKStatus, (bool enable, int max_packets), (override)); + MOCK_METHOD(void, + RegisterReceiverCongestionControlObjects, + (PacketRouter*), + (override)); + MOCK_METHOD(void, ResetReceiverCongestionControlObjects, (), (override)); + MOCK_METHOD(CallReceiveStatistics, GetRTCPStatistics, (), (const, override)); + MOCK_METHOD(NetworkStatistics, GetNetworkStatistics, (), (const, override)); + MOCK_METHOD(AudioDecodingCallStats, + GetDecodingCallStatistics, + (), + (const, override)); + MOCK_METHOD(int, GetSpeechOutputLevelFullRange, (), (const, override)); + MOCK_METHOD(double, GetTotalOutputEnergy, (), (const, override)); + MOCK_METHOD(double, GetTotalOutputDuration, (), (const, override)); + MOCK_METHOD(uint32_t, GetDelayEstimate, (), (const, override)); + MOCK_METHOD(void, SetSink, (AudioSinkInterface*), (override)); + MOCK_METHOD(void, OnRtpPacket, (const RtpPacketReceived& packet), (override)); + MOCK_METHOD(void, + ReceivedRTCPPacket, + (const uint8_t*, size_t length), + (override)); + MOCK_METHOD(void, SetChannelOutputVolumeScaling, (float scaling), (override)); + MOCK_METHOD(AudioMixer::Source::AudioFrameInfo, + GetAudioFrameWithInfo, + (int sample_rate_hz, AudioFrame*), + (override)); + MOCK_METHOD(int, PreferredSampleRate, (), (const, override)); + MOCK_METHOD(void, + SetAssociatedSendChannel, + (const voe::ChannelSendInterface*), + (override)); + MOCK_METHOD(bool, + GetPlayoutRtpTimestamp, + (uint32_t*, int64_t*), + (const, override)); + MOCK_METHOD(void, + SetEstimatedPlayoutNtpTimestampMs, + (int64_t ntp_timestamp_ms, int64_t time_ms), + (override)); + MOCK_METHOD(absl::optional<int64_t>, + GetCurrentEstimatedPlayoutNtpTimestampMs, + (int64_t now_ms), + (const, override)); + MOCK_METHOD(absl::optional<Syncable::Info>, + GetSyncInfo, + (), + (const, override)); + MOCK_METHOD(void, SetMinimumPlayoutDelay, (int delay_ms), (override)); + MOCK_METHOD(bool, SetBaseMinimumPlayoutDelayMs, (int delay_ms), (override)); + MOCK_METHOD(int, GetBaseMinimumPlayoutDelayMs, (), (const, override)); + MOCK_METHOD((absl::optional<std::pair<int, SdpAudioFormat>>), + GetReceiveCodec, + (), + (const, override)); + MOCK_METHOD(void, + SetReceiveCodecs, + ((const std::map<int, SdpAudioFormat>& codecs)), + (override)); + MOCK_METHOD(void, StartPlayout, (), (override)); + MOCK_METHOD(void, StopPlayout, (), (override)); + MOCK_METHOD( + void, + SetDepacketizerToDecoderFrameTransformer, + (rtc::scoped_refptr<webrtc::FrameTransformerInterface> frame_transformer), + (override)); }; class MockChannelSend : public voe::ChannelSendInterface { public: - // GMock doesn't like move-only types, like std::unique_ptr. - virtual void SetEncoder(int payload_type, - std::unique_ptr<AudioEncoder> encoder) { - return SetEncoderForMock(payload_type, &encoder); - } - MOCK_METHOD2(SetEncoderForMock, - void(int payload_type, std::unique_ptr<AudioEncoder>* encoder)); - MOCK_METHOD1( + MOCK_METHOD(void, + SetEncoder, + (int payload_type, std::unique_ptr<AudioEncoder> encoder), + (override)); + MOCK_METHOD( + void, ModifyEncoder, - void(rtc::FunctionView<void(std::unique_ptr<AudioEncoder>*)> modifier)); - MOCK_METHOD1(CallEncoder, - void(rtc::FunctionView<void(AudioEncoder*)> modifier)); - MOCK_METHOD1(SetRTCP_CNAME, void(absl::string_view c_name)); - MOCK_METHOD2(SetSendAudioLevelIndicationStatus, void(bool enable, int id)); - MOCK_METHOD2(RegisterSenderCongestionControlObjects, - void(RtpTransportControllerSendInterface* transport, - RtcpBandwidthObserver* bandwidth_observer)); - MOCK_METHOD0(ResetSenderCongestionControlObjects, void()); - MOCK_CONST_METHOD0(GetRTCPStatistics, CallSendStatistics()); - MOCK_CONST_METHOD0(GetRemoteRTCPReportBlocks, std::vector<ReportBlock>()); - MOCK_CONST_METHOD0(GetANAStatistics, ANAStats()); - MOCK_METHOD2(RegisterCngPayloadType, - void(int payload_type, int payload_frequency)); - MOCK_METHOD2(SetSendTelephoneEventPayloadType, - void(int payload_type, int payload_frequency)); - MOCK_METHOD2(SendTelephoneEventOutband, bool(int event, int duration_ms)); - MOCK_METHOD1(OnBitrateAllocation, void(BitrateAllocationUpdate update)); - MOCK_METHOD1(SetInputMute, void(bool muted)); - MOCK_METHOD2(ReceivedRTCPPacket, void(const uint8_t* packet, size_t length)); - // GMock doesn't like move-only types, like std::unique_ptr. - virtual void ProcessAndEncodeAudio(std::unique_ptr<AudioFrame> audio_frame) { - ProcessAndEncodeAudioForMock(&audio_frame); - } - MOCK_METHOD1(ProcessAndEncodeAudioForMock, - void(std::unique_ptr<AudioFrame>* audio_frame)); - MOCK_METHOD1(SetTransportOverhead, - void(size_t transport_overhead_per_packet)); - MOCK_CONST_METHOD0(GetRtpRtcp, RtpRtcp*()); - MOCK_CONST_METHOD0(GetBitrate, int()); - MOCK_METHOD1(OnTwccBasedUplinkPacketLossRate, void(float packet_loss_rate)); - MOCK_METHOD1(OnRecoverableUplinkPacketLossRate, - void(float recoverable_packet_loss_rate)); - MOCK_CONST_METHOD0(GetRTT, int64_t()); - MOCK_METHOD0(StartSend, void()); - MOCK_METHOD0(StopSend, void()); - MOCK_METHOD1( - SetFrameEncryptor, - void(rtc::scoped_refptr<FrameEncryptorInterface> frame_encryptor)); - MOCK_METHOD1(SetEncoderToPacketizerFrameTransformer, - void(rtc::scoped_refptr<webrtc::FrameTransformerInterface> - frame_transformer)); + (rtc::FunctionView<void(std::unique_ptr<AudioEncoder>*)> modifier), + (override)); + MOCK_METHOD(void, + CallEncoder, + (rtc::FunctionView<void(AudioEncoder*)> modifier), + (override)); + MOCK_METHOD(void, SetRTCP_CNAME, (absl::string_view c_name), (override)); + MOCK_METHOD(void, + SetSendAudioLevelIndicationStatus, + (bool enable, int id), + (override)); + MOCK_METHOD(void, + RegisterSenderCongestionControlObjects, + (RtpTransportControllerSendInterface*, RtcpBandwidthObserver*), + (override)); + MOCK_METHOD(void, ResetSenderCongestionControlObjects, (), (override)); + MOCK_METHOD(CallSendStatistics, GetRTCPStatistics, (), (const, override)); + MOCK_METHOD(std::vector<ReportBlock>, + GetRemoteRTCPReportBlocks, + (), + (const, override)); + MOCK_METHOD(ANAStats, GetANAStatistics, (), (const, override)); + MOCK_METHOD(void, + RegisterCngPayloadType, + (int payload_type, int payload_frequency), + (override)); + MOCK_METHOD(void, + SetSendTelephoneEventPayloadType, + (int payload_type, int payload_frequency), + (override)); + MOCK_METHOD(bool, + SendTelephoneEventOutband, + (int event, int duration_ms), + (override)); + MOCK_METHOD(void, + OnBitrateAllocation, + (BitrateAllocationUpdate update), + (override)); + MOCK_METHOD(void, SetInputMute, (bool muted), (override)); + MOCK_METHOD(void, + ReceivedRTCPPacket, + (const uint8_t*, size_t length), + (override)); + MOCK_METHOD(void, + ProcessAndEncodeAudio, + (std::unique_ptr<AudioFrame>), + (override)); + MOCK_METHOD(RtpRtcpInterface*, GetRtpRtcp, (), (const, override)); + MOCK_METHOD(int, GetBitrate, (), (const, override)); + MOCK_METHOD(int64_t, GetRTT, (), (const, override)); + MOCK_METHOD(void, StartSend, (), (override)); + MOCK_METHOD(void, StopSend, (), (override)); + MOCK_METHOD(void, + SetFrameEncryptor, + (rtc::scoped_refptr<FrameEncryptorInterface> frame_encryptor), + (override)); + MOCK_METHOD( + void, + SetEncoderToPacketizerFrameTransformer, + (rtc::scoped_refptr<webrtc::FrameTransformerInterface> frame_transformer), + (override)); }; } // namespace test } // namespace webrtc diff --git a/chromium/third_party/webrtc/audio/null_audio_poller.cc b/chromium/third_party/webrtc/audio/null_audio_poller.cc index 22f575d8bba..16d267fb466 100644 --- a/chromium/third_party/webrtc/audio/null_audio_poller.cc +++ b/chromium/third_party/webrtc/audio/null_audio_poller.cc @@ -31,7 +31,8 @@ constexpr size_t kNumSamples = kSamplesPerSecond / 100; // 10ms of samples } // namespace NullAudioPoller::NullAudioPoller(AudioTransport* audio_transport) - : audio_transport_(audio_transport), + : MessageHandler(false), + audio_transport_(audio_transport), reschedule_at_(rtc::TimeMillis() + kPollDelayMs) { RTC_DCHECK(audio_transport); OnMessage(nullptr); // Start the poll loop. diff --git a/chromium/third_party/webrtc/audio/test/low_bandwidth_audio_test.cc b/chromium/third_party/webrtc/audio/test/low_bandwidth_audio_test.cc index 049b5e51505..50cf4999202 100644 --- a/chromium/third_party/webrtc/audio/test/low_bandwidth_audio_test.cc +++ b/chromium/third_party/webrtc/audio/test/low_bandwidth_audio_test.cc @@ -8,6 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include "absl/flags/declare.h" #include "absl/flags/flag.h" #include "api/test/simulated_network.h" #include "audio/test/audio_end_to_end_test.h" diff --git a/chromium/third_party/webrtc/audio/test/pc_low_bandwidth_audio_test.cc b/chromium/third_party/webrtc/audio/test/pc_low_bandwidth_audio_test.cc index aafb65f15d2..dbc23760692 100644 --- a/chromium/third_party/webrtc/audio/test/pc_low_bandwidth_audio_test.cc +++ b/chromium/third_party/webrtc/audio/test/pc_low_bandwidth_audio_test.cc @@ -10,6 +10,7 @@ #include <memory> +#include "absl/flags/declare.h" #include "absl/flags/flag.h" #include "api/test/create_network_emulation_manager.h" #include "api/test/create_peerconnection_quality_test_fixture.h" diff --git a/chromium/third_party/webrtc/audio/utility/audio_frame_operations_unittest.cc b/chromium/third_party/webrtc/audio/utility/audio_frame_operations_unittest.cc index 1d38875add3..1a2c16e45f5 100644 --- a/chromium/third_party/webrtc/audio/utility/audio_frame_operations_unittest.cc +++ b/chromium/third_party/webrtc/audio/utility/audio_frame_operations_unittest.cc @@ -27,6 +27,8 @@ class AudioFrameOperationsTest : public ::testing::Test { AudioFrame frame_; }; +class AudioFrameOperationsDeathTest : public AudioFrameOperationsTest {}; + void SetFrameData(int16_t ch1, int16_t ch2, int16_t ch3, @@ -105,7 +107,7 @@ void VerifyFrameDataBounds(const AudioFrame& frame, } #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) -TEST_F(AudioFrameOperationsTest, MonoToStereoFailsWithBadParameters) { +TEST_F(AudioFrameOperationsDeathTest, MonoToStereoFailsWithBadParameters) { EXPECT_DEATH(AudioFrameOperations::UpmixChannels(2, &frame_), ""); frame_.samples_per_channel_ = AudioFrame::kMaxDataSizeSamples; frame_.num_channels_ = 1; @@ -136,7 +138,7 @@ TEST_F(AudioFrameOperationsTest, MonoToStereoMuted) { } #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) -TEST_F(AudioFrameOperationsTest, StereoToMonoFailsWithBadParameters) { +TEST_F(AudioFrameOperationsDeathTest, StereoToMonoFailsWithBadParameters) { frame_.num_channels_ = 1; EXPECT_DEATH(AudioFrameOperations::DownmixChannels(1, &frame_), ""); } diff --git a/chromium/third_party/webrtc/audio/voip/BUILD.gn b/chromium/third_party/webrtc/audio/voip/BUILD.gn index 60232d5144c..84a0ad7ab0f 100644 --- a/chromium/third_party/webrtc/audio/voip/BUILD.gn +++ b/chromium/third_party/webrtc/audio/voip/BUILD.gn @@ -26,8 +26,8 @@ rtc_library("voip_core") { "../../modules/utility:utility", "../../rtc_base:criticalsection", "../../rtc_base:logging", - "//third_party/abseil-cpp/absl/types:optional", ] + absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } rtc_library("audio_channel") { diff --git a/chromium/third_party/webrtc/audio/voip/audio_channel.cc b/chromium/third_party/webrtc/audio/voip/audio_channel.cc index b9ce7accd1b..ee08e0590fe 100644 --- a/chromium/third_party/webrtc/audio/voip/audio_channel.cc +++ b/chromium/third_party/webrtc/audio/voip/audio_channel.cc @@ -16,6 +16,7 @@ #include "api/audio_codecs/audio_format.h" #include "api/task_queue/task_queue_factory.h" #include "modules/rtp_rtcp/include/receive_statistics.h" +#include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h" #include "rtc_base/critical_section.h" #include "rtc_base/location.h" #include "rtc_base/logging.h" @@ -43,7 +44,7 @@ AudioChannel::AudioChannel( Clock* clock = Clock::GetRealTimeClock(); receive_statistics_ = ReceiveStatistics::Create(clock); - RtpRtcp::Configuration rtp_config; + RtpRtcpInterface::Configuration rtp_config; rtp_config.clock = clock; rtp_config.audio = true; rtp_config.receive_statistics = receive_statistics_.get(); @@ -51,7 +52,7 @@ AudioChannel::AudioChannel( rtp_config.outgoing_transport = transport; rtp_config.local_media_ssrc = local_ssrc; - rtp_rtcp_ = RtpRtcp::Create(rtp_config); + rtp_rtcp_ = ModuleRtpRtcpImpl2::Create(rtp_config); rtp_rtcp_->SetSendingMediaStatus(false); rtp_rtcp_->SetRTCPStatus(RtcpMode::kCompound); diff --git a/chromium/third_party/webrtc/audio/voip/audio_channel.h b/chromium/third_party/webrtc/audio/voip/audio_channel.h index 8b6f1a8e59c..b305215ef6a 100644 --- a/chromium/third_party/webrtc/audio/voip/audio_channel.h +++ b/chromium/third_party/webrtc/audio/voip/audio_channel.h @@ -20,7 +20,7 @@ #include "api/voip/voip_base.h" #include "audio/voip/audio_egress.h" #include "audio/voip/audio_ingress.h" -#include "modules/rtp_rtcp/include/rtp_rtcp.h" +#include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h" #include "modules/utility/include/process_thread.h" #include "rtc_base/critical_section.h" #include "rtc_base/ref_count.h" @@ -88,7 +88,7 @@ class AudioChannel : public rtc::RefCountInterface { // Listed in order for safe destruction of AudioChannel object. // Synchronization for these are handled internally. std::unique_ptr<ReceiveStatistics> receive_statistics_; - std::unique_ptr<RtpRtcp> rtp_rtcp_; + std::unique_ptr<ModuleRtpRtcpImpl2> rtp_rtcp_; std::unique_ptr<AudioIngress> ingress_; std::unique_ptr<AudioEgress> egress_; }; diff --git a/chromium/third_party/webrtc/audio/voip/audio_egress.cc b/chromium/third_party/webrtc/audio/voip/audio_egress.cc index a7bc202a41f..305f7126244 100644 --- a/chromium/third_party/webrtc/audio/voip/audio_egress.cc +++ b/chromium/third_party/webrtc/audio/voip/audio_egress.cc @@ -17,7 +17,7 @@ namespace webrtc { -AudioEgress::AudioEgress(RtpRtcp* rtp_rtcp, +AudioEgress::AudioEgress(RtpRtcpInterface* rtp_rtcp, Clock* clock, TaskQueueFactory* task_queue_factory) : rtp_rtcp_(rtp_rtcp), diff --git a/chromium/third_party/webrtc/audio/voip/audio_egress.h b/chromium/third_party/webrtc/audio/voip/audio_egress.h index e5632cde325..20b0bac02f9 100644 --- a/chromium/third_party/webrtc/audio/voip/audio_egress.h +++ b/chromium/third_party/webrtc/audio/voip/audio_egress.h @@ -20,7 +20,7 @@ #include "call/audio_sender.h" #include "modules/audio_coding/include/audio_coding_module.h" #include "modules/rtp_rtcp/include/report_block_data.h" -#include "modules/rtp_rtcp/include/rtp_rtcp.h" +#include "modules/rtp_rtcp/source/rtp_rtcp_interface.h" #include "modules/rtp_rtcp/source/rtp_sender_audio.h" #include "rtc_base/task_queue.h" #include "rtc_base/thread_checker.h" @@ -43,7 +43,7 @@ namespace webrtc { // smaller footprint. class AudioEgress : public AudioSender, public AudioPacketizationCallback { public: - AudioEgress(RtpRtcp* rtp_rtcp, + AudioEgress(RtpRtcpInterface* rtp_rtcp, Clock* clock, TaskQueueFactory* task_queue_factory); ~AudioEgress() override; @@ -109,7 +109,7 @@ class AudioEgress : public AudioSender, public AudioPacketizationCallback { absl::optional<SdpAudioFormat> encoder_format_ RTC_GUARDED_BY(lock_); // Synchronization is handled internally by RtpRtcp. - RtpRtcp* const rtp_rtcp_; + RtpRtcpInterface* const rtp_rtcp_; // Synchronization is handled internally by RTPSenderAudio. RTPSenderAudio rtp_sender_audio_; diff --git a/chromium/third_party/webrtc/audio/voip/audio_ingress.cc b/chromium/third_party/webrtc/audio/voip/audio_ingress.cc index fb43fcd7539..68864eb2e1d 100644 --- a/chromium/third_party/webrtc/audio/voip/audio_ingress.cc +++ b/chromium/third_party/webrtc/audio/voip/audio_ingress.cc @@ -36,7 +36,7 @@ AudioCodingModule::Config CreateAcmConfig( } // namespace AudioIngress::AudioIngress( - RtpRtcp* rtp_rtcp, + RtpRtcpInterface* rtp_rtcp, Clock* clock, ReceiveStatistics* receive_statistics, rtc::scoped_refptr<AudioDecoderFactory> decoder_factory) diff --git a/chromium/third_party/webrtc/audio/voip/audio_ingress.h b/chromium/third_party/webrtc/audio/voip/audio_ingress.h index 99766741d63..15f7900617a 100644 --- a/chromium/third_party/webrtc/audio/voip/audio_ingress.h +++ b/chromium/third_party/webrtc/audio/voip/audio_ingress.h @@ -26,8 +26,8 @@ #include "modules/audio_coding/include/audio_coding_module.h" #include "modules/rtp_rtcp/include/receive_statistics.h" #include "modules/rtp_rtcp/include/remote_ntp_time_estimator.h" -#include "modules/rtp_rtcp/include/rtp_rtcp.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" +#include "modules/rtp_rtcp/source/rtp_rtcp_interface.h" #include "rtc_base/critical_section.h" #include "rtc_base/time_utils.h" @@ -44,7 +44,7 @@ namespace webrtc { // smaller footprint. class AudioIngress : public AudioMixer::Source { public: - AudioIngress(RtpRtcp* rtp_rtcp, + AudioIngress(RtpRtcpInterface* rtp_rtcp, Clock* clock, ReceiveStatistics* receive_statistics, rtc::scoped_refptr<AudioDecoderFactory> decoder_factory); @@ -122,8 +122,8 @@ class AudioIngress : public AudioMixer::Source { // Synchronizaton is handled internally by ReceiveStatistics. ReceiveStatistics* const rtp_receive_statistics_; - // Synchronizaton is handled internally by RtpRtcp. - RtpRtcp* const rtp_rtcp_; + // Synchronizaton is handled internally by RtpRtcpInterface. + RtpRtcpInterface* const rtp_rtcp_; // Synchronizaton is handled internally by acm2::AcmReceiver. acm2::AcmReceiver acm_receiver_; diff --git a/chromium/third_party/webrtc/audio/voip/test/BUILD.gn b/chromium/third_party/webrtc/audio/voip/test/BUILD.gn index 39f100a3aab..d698b3321d0 100644 --- a/chromium/third_party/webrtc/audio/voip/test/BUILD.gn +++ b/chromium/third_party/webrtc/audio/voip/test/BUILD.gn @@ -36,6 +36,7 @@ if (rtc_include_tests) { "../../../api/task_queue:default_task_queue_factory", "../../../modules/audio_mixer:audio_mixer_impl", "../../../modules/audio_mixer:audio_mixer_test_utils", + "../../../modules/rtp_rtcp:rtp_rtcp", "../../../modules/rtp_rtcp:rtp_rtcp_format", "../../../modules/utility", "../../../rtc_base:logging", @@ -56,6 +57,7 @@ if (rtc_include_tests) { "../../../api/audio_codecs:builtin_audio_encoder_factory", "../../../api/task_queue:default_task_queue_factory", "../../../modules/audio_mixer:audio_mixer_test_utils", + "../../../modules/rtp_rtcp:rtp_rtcp", "../../../rtc_base:logging", "../../../rtc_base:rtc_event", "../../../test:mock_transport", @@ -72,6 +74,7 @@ if (rtc_include_tests) { "../../../api/audio_codecs:builtin_audio_encoder_factory", "../../../api/task_queue:default_task_queue_factory", "../../../modules/audio_mixer:audio_mixer_test_utils", + "../../../modules/rtp_rtcp:rtp_rtcp", "../../../modules/rtp_rtcp:rtp_rtcp_format", "../../../rtc_base:logging", "../../../rtc_base:rtc_event", diff --git a/chromium/third_party/webrtc/audio/voip/test/audio_egress_unittest.cc b/chromium/third_party/webrtc/audio/voip/test/audio_egress_unittest.cc index 33912658804..70fb6dcf367 100644 --- a/chromium/third_party/webrtc/audio/voip/test/audio_egress_unittest.cc +++ b/chromium/third_party/webrtc/audio/voip/test/audio_egress_unittest.cc @@ -14,6 +14,7 @@ #include "api/task_queue/default_task_queue_factory.h" #include "modules/audio_mixer/sine_wave_generator.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" +#include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h" #include "rtc_base/event.h" #include "rtc_base/logging.h" #include "test/gmock.h" @@ -27,16 +28,16 @@ using ::testing::Invoke; using ::testing::NiceMock; using ::testing::Unused; -std::unique_ptr<RtpRtcp> CreateRtpStack(Clock* clock, - Transport* transport, - uint32_t remote_ssrc) { - RtpRtcp::Configuration rtp_config; +std::unique_ptr<ModuleRtpRtcpImpl2> CreateRtpStack(Clock* clock, + Transport* transport, + uint32_t remote_ssrc) { + RtpRtcpInterface::Configuration rtp_config; rtp_config.clock = clock; rtp_config.audio = true; rtp_config.rtcp_report_interval_ms = 5000; rtp_config.outgoing_transport = transport; rtp_config.local_media_ssrc = remote_ssrc; - auto rtp_rtcp = RtpRtcp::Create(rtp_config); + auto rtp_rtcp = ModuleRtpRtcpImpl2::Create(rtp_config); rtp_rtcp->SetSendingMediaStatus(false); rtp_rtcp->SetRTCPStatus(RtcpMode::kCompound); return rtp_rtcp; @@ -100,7 +101,7 @@ class AudioEgressTest : public ::testing::Test { SimulatedClock fake_clock_; NiceMock<MockTransport> transport_; SineWaveGenerator wave_generator_; - std::unique_ptr<RtpRtcp> rtp_rtcp_; + std::unique_ptr<ModuleRtpRtcpImpl2> rtp_rtcp_; std::unique_ptr<TaskQueueFactory> task_queue_factory_; rtc::scoped_refptr<AudioEncoderFactory> encoder_factory_; std::unique_ptr<AudioEgress> egress_; diff --git a/chromium/third_party/webrtc/audio/voip/test/audio_ingress_unittest.cc b/chromium/third_party/webrtc/audio/voip/test/audio_ingress_unittest.cc index bedb82e211a..3a2a66a3255 100644 --- a/chromium/third_party/webrtc/audio/voip/test/audio_ingress_unittest.cc +++ b/chromium/third_party/webrtc/audio/voip/test/audio_ingress_unittest.cc @@ -15,6 +15,7 @@ #include "api/task_queue/default_task_queue_factory.h" #include "audio/voip/audio_egress.h" #include "modules/audio_mixer/sine_wave_generator.h" +#include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h" #include "rtc_base/event.h" #include "rtc_base/logging.h" #include "test/gmock.h" @@ -38,14 +39,14 @@ class AudioIngressTest : public ::testing::Test { : fake_clock_(123456789), wave_generator_(1000.0, kAudioLevel) { receive_statistics_ = ReceiveStatistics::Create(&fake_clock_); - RtpRtcp::Configuration rtp_config; + RtpRtcpInterface::Configuration rtp_config; rtp_config.clock = &fake_clock_; rtp_config.audio = true; rtp_config.receive_statistics = receive_statistics_.get(); rtp_config.rtcp_report_interval_ms = 5000; rtp_config.outgoing_transport = &transport_; rtp_config.local_media_ssrc = 0xdeadc0de; - rtp_rtcp_ = RtpRtcp::Create(rtp_config); + rtp_rtcp_ = ModuleRtpRtcpImpl2::Create(rtp_config); rtp_rtcp_->SetSendingMediaStatus(false); rtp_rtcp_->SetRTCPStatus(RtcpMode::kCompound); @@ -94,7 +95,7 @@ class AudioIngressTest : public ::testing::Test { SineWaveGenerator wave_generator_; NiceMock<MockTransport> transport_; std::unique_ptr<ReceiveStatistics> receive_statistics_; - std::unique_ptr<RtpRtcp> rtp_rtcp_; + std::unique_ptr<ModuleRtpRtcpImpl2> rtp_rtcp_; rtc::scoped_refptr<AudioEncoderFactory> encoder_factory_; rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_; std::unique_ptr<TaskQueueFactory> task_queue_factory_; |