diff --git a/audio/audio_receive_stream.cc b/audio/audio_receive_stream.cc index 7e473ed23a..563e8a036a 100644 --- a/audio/audio_receive_stream.cc +++ b/audio/audio_receive_stream.cc @@ -73,7 +73,7 @@ std::unique_ptr CreateChannelAndProxy( return absl::make_unique( absl::make_unique( module_process_thread, internal_audio_state->audio_device_module(), - nullptr /* RtcpRttStats */, event_log, config.rtp.remote_ssrc, + config.rtcp_send_transport, event_log, config.rtp.remote_ssrc, config.jitter_buffer_max_packets, config.jitter_buffer_fast_accelerate, config.decoder_factory, config.codec_pair_id, config.frame_decryptor)); @@ -109,13 +109,12 @@ AudioReceiveStream::AudioReceiveStream( RTC_DCHECK(receiver_controller); RTC_DCHECK(packet_router); RTC_DCHECK(config.decoder_factory); + RTC_DCHECK(config.rtcp_send_transport); RTC_DCHECK(audio_state_); RTC_DCHECK(channel_proxy_); module_process_thread_checker_.DetachFromThread(); - channel_proxy_->RegisterTransport(config.rtcp_send_transport); - // Configure bandwidth estimation. channel_proxy_->RegisterReceiverCongestionControlObjects(packet_router); @@ -131,7 +130,6 @@ AudioReceiveStream::~AudioReceiveStream() { RTC_LOG(LS_INFO) << "~AudioReceiveStream: " << config_.rtp.remote_ssrc; Stop(); channel_proxy_->DisassociateSendChannel(); - channel_proxy_->RegisterTransport(nullptr); channel_proxy_->ResetReceiverCongestionControlObjects(); } diff --git a/audio/audio_receive_stream_unittest.cc b/audio/audio_receive_stream_unittest.cc index c5c53e5825..97c42c4383 100644 --- a/audio/audio_receive_stream_unittest.cc +++ b/audio/audio_receive_stream_unittest.cc @@ -25,6 +25,7 @@ #include "modules/rtp_rtcp/source/byte_io.h" #include "test/gtest.h" #include "test/mock_audio_decoder_factory.h" +#include "test/mock_transport.h" namespace webrtc { namespace test { @@ -89,7 +90,6 @@ struct ConfigHelper { .Times(1); EXPECT_CALL(*channel_proxy_, ResetReceiverCongestionControlObjects()) .Times(1); - EXPECT_CALL(*channel_proxy_, RegisterTransport(nullptr)).Times(2); EXPECT_CALL(*channel_proxy_, DisassociateSendChannel()).Times(1); EXPECT_CALL(*channel_proxy_, SetReceiveCodecs(_)) .WillRepeatedly(Invoke([](const std::map& codecs) { @@ -103,6 +103,7 @@ struct ConfigHelper { RtpExtension(RtpExtension::kAudioLevelUri, kAudioLevelId)); stream_config_.rtp.extensions.push_back(RtpExtension( RtpExtension::kTransportSequenceNumberUri, kTransportSequenceNumberId)); + stream_config_.rtcp_send_transport = &rtcp_send_transport_; stream_config_.decoder_factory = new rtc::RefCountedObject; } @@ -150,6 +151,7 @@ struct ConfigHelper { AudioReceiveStream::Config stream_config_; testing::StrictMock* channel_proxy_ = nullptr; RtpStreamReceiverController rtp_stream_receiver_controller_; + MockTransport rtcp_send_transport_; }; void BuildOneByteExtension(std::vector::iterator it, diff --git a/audio/channel_receive.cc b/audio/channel_receive.cc index 26213cc5b6..e9f7503474 100644 --- a/audio/channel_receive.cc +++ b/audio/channel_receive.cc @@ -52,30 +52,6 @@ constexpr int kVoiceEngineMaxMinPlayoutDelayMs = 10000; } // namespace -bool ChannelReceive::SendRtp(const uint8_t* data, - size_t len, - const PacketOptions& options) { - RTC_NOTREACHED(); - return false; -} - -bool ChannelReceive::SendRtcp(const uint8_t* data, size_t len) { - rtc::CritScope cs(&_callbackCritSect); - if (_transportPtr == NULL) { - RTC_DLOG(LS_ERROR) - << "ChannelReceive::SendRtcp() failed to send RTCP packet due to" - << " invalid transport object"; - return false; - } - - int n = _transportPtr->SendRtcp(data, len); - if (n < 0) { - RTC_DLOG(LS_ERROR) << "ChannelReceive::SendRtcp() transmission failed"; - return false; - } - return true; -} - int32_t ChannelReceive::OnReceivedPayloadData( const uint8_t* payloadData, size_t payloadSize, @@ -223,7 +199,7 @@ int ChannelReceive::PreferredSampleRate() const { ChannelReceive::ChannelReceive( ProcessThread* module_process_thread, AudioDeviceModule* audio_device_module, - RtcpRttStats* rtcp_rtt_stats, + Transport* rtcp_send_transport, RtcEventLog* rtc_event_log, uint32_t remote_ssrc, size_t jitter_buffer_max_packets, @@ -244,7 +220,6 @@ ChannelReceive::ChannelReceive( capture_start_ntp_time_ms_(-1), _moduleProcessThreadPtr(module_process_thread), _audioDeviceModulePtr(audio_device_module), - _transportPtr(NULL), _outputGain(1.0f), associated_send_channel_(nullptr), frame_decryptor_(frame_decryptor) { @@ -263,11 +238,13 @@ ChannelReceive::ChannelReceive( rtp_receive_statistics_->EnableRetransmitDetection(remote_ssrc_, true); RtpRtcp::Configuration configuration; configuration.audio = true; - configuration.outgoing_transport = this; + // TODO(nisse): Also set receiver_only = true, but that seems to break RTT + // estimation, resulting in test failures for + // PeerConnectionIntegrationTest.GetCaptureStartNtpTimeWithOldStatsApi + configuration.outgoing_transport = rtcp_send_transport; configuration.receive_statistics = rtp_receive_statistics_.get(); configuration.event_log = event_log_; - configuration.rtt_stats = rtcp_rtt_stats; _rtpRtcpModule.reset(RtpRtcp::CreateRtpRtcp(configuration)); _rtpRtcpModule->SetSendingMediaStatus(false); @@ -377,11 +354,6 @@ void ChannelReceive::SetReceiveCodecs( audio_coding_->SetReceiveCodecs(codecs); } -void ChannelReceive::RegisterTransport(Transport* transport) { - rtc::CritScope cs(&_callbackCritSect); - _transportPtr = transport; -} - // TODO(nisse): Move receive logic up to AudioReceiveStream. void ChannelReceive::OnRtpPacket(const RtpPacketReceived& packet) { int64_t now_ms = rtc::TimeMillis(); diff --git a/audio/channel_receive.h b/audio/channel_receive.h index 2e089b7159..82eb4dff0c 100644 --- a/audio/channel_receive.h +++ b/audio/channel_receive.h @@ -102,12 +102,12 @@ class ChannelReceiveState { State state_; }; -class ChannelReceive : public RtpData, public Transport { +class ChannelReceive : public RtpData { public: // Used for receive streams. ChannelReceive(ProcessThread* module_process_thread, AudioDeviceModule* audio_device_module, - RtcpRttStats* rtcp_rtt_stats, + Transport* rtcp_send_transport, RtcEventLog* rtc_event_log, uint32_t remote_ssrc, size_t jitter_buffer_max_packets, @@ -130,8 +130,6 @@ class ChannelReceive : public RtpData, public Transport { // Codecs int32_t GetRecCodec(CodecInst& codec); // NOLINT - // Network - void RegisterTransport(Transport* transport); // TODO(nisse, solenberg): Delete when VoENetwork is deleted. int32_t ReceivedRTCPPacket(const uint8_t* data, size_t length); void OnRtpPacket(const RtpPacketReceived& packet); @@ -170,12 +168,6 @@ class ChannelReceive : public RtpData, public Transport { size_t payloadSize, const WebRtcRTPHeader* rtpHeader) override; - // From Transport (called by the RTP/RTCP module) - bool SendRtp(const uint8_t* data, - size_t len, - const PacketOptions& packet_options) override; - bool SendRtcp(const uint8_t* data, size_t len) override; - // From AudioMixer::Source. AudioMixer::Source::AudioFrameInfo GetAudioFrameWithInfo( int sample_rate_hz, @@ -254,7 +246,6 @@ class ChannelReceive : public RtpData, public Transport { // uses ProcessThread* _moduleProcessThreadPtr; AudioDeviceModule* _audioDeviceModulePtr; - Transport* _transportPtr; // WebRtc socket or external transport float _outputGain RTC_GUARDED_BY(volume_settings_critsect_); // An associated send channel. diff --git a/audio/channel_receive_proxy.cc b/audio/channel_receive_proxy.cc index b68ab061dd..b1c1c45832 100644 --- a/audio/channel_receive_proxy.cc +++ b/audio/channel_receive_proxy.cc @@ -51,11 +51,6 @@ CallReceiveStatistics ChannelReceiveProxy::GetRTCPStatistics() const { return stats; } -void ChannelReceiveProxy::RegisterTransport(Transport* transport) { - RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); - channel_->RegisterTransport(transport); -} - bool ChannelReceiveProxy::ReceivedRTCPPacket(const uint8_t* packet, size_t length) { // May be called on either worker thread or network thread. diff --git a/audio/channel_receive_proxy.h b/audio/channel_receive_proxy.h index 2e65e7979e..8ebacc300d 100644 --- a/audio/channel_receive_proxy.h +++ b/audio/channel_receive_proxy.h @@ -50,7 +50,6 @@ class ChannelReceiveProxy : public RtpPacketSinkInterface { virtual void SetLocalSSRC(uint32_t ssrc); virtual void SetNACKStatus(bool enable, int max_packets); virtual CallReceiveStatistics GetRTCPStatistics() const; - virtual void RegisterTransport(Transport* transport); virtual bool ReceivedRTCPPacket(const uint8_t* packet, size_t length); virtual void RegisterReceiverCongestionControlObjects( diff --git a/audio/mock_voe_channel_proxy.h b/audio/mock_voe_channel_proxy.h index 88a50ea7b0..910858fe13 100644 --- a/audio/mock_voe_channel_proxy.h +++ b/audio/mock_voe_channel_proxy.h @@ -39,7 +39,6 @@ class MockChannelReceiveProxy : public voe::ChannelReceiveProxy { MOCK_CONST_METHOD0(GetTotalOutputDuration, double()); MOCK_CONST_METHOD0(GetDelayEstimate, uint32_t()); MOCK_METHOD1(SetSink, void(AudioSinkInterface* sink)); - MOCK_METHOD1(RegisterTransport, void(Transport* transport)); MOCK_METHOD1(OnRtpPacket, void(const RtpPacketReceived& packet)); MOCK_METHOD2(ReceivedRTCPPacket, bool(const uint8_t* packet, size_t length)); MOCK_METHOD1(SetChannelOutputVolumeScaling, void(float scaling)); diff --git a/call/call_perf_tests.cc b/call/call_perf_tests.cc index 8e9166557a..8fcd566f81 100644 --- a/call/call_perf_tests.cc +++ b/call/call_perf_tests.cc @@ -39,6 +39,7 @@ #include "test/frame_generator.h" #include "test/frame_generator_capturer.h" #include "test/gtest.h" +#include "test/null_transport.h" #include "test/rtp_rtcp_observer.h" #include "test/single_threaded_task_queue.h" #include "test/testsupport/fileutils.h" @@ -163,6 +164,7 @@ void CallPerfTest::TestAudioVideoSync(FecMode fec, std::unique_ptr audio_send_transport; std::unique_ptr video_send_transport; std::unique_ptr receive_transport; + test::NullTransport rtcp_send_transport; AudioSendStream* audio_send_stream; AudioReceiveStream* audio_receive_stream; @@ -250,6 +252,7 @@ void CallPerfTest::TestAudioVideoSync(FecMode fec, AudioReceiveStream::Config audio_recv_config; audio_recv_config.rtp.remote_ssrc = kAudioSendSsrc; audio_recv_config.rtp.local_ssrc = kAudioRecvSsrc; + audio_recv_config.rtcp_send_transport = &rtcp_send_transport; audio_recv_config.sync_group = kSyncGroup; audio_recv_config.decoder_factory = audio_decoder_factory_; audio_recv_config.decoder_map = { diff --git a/call/call_unittest.cc b/call/call_unittest.cc index 1084bcfb46..8ae04008f9 100644 --- a/call/call_unittest.cc +++ b/call/call_unittest.cc @@ -72,7 +72,9 @@ TEST(CallTest, CreateDestroy_AudioSendStream) { TEST(CallTest, CreateDestroy_AudioReceiveStream) { CallHelper call; AudioReceiveStream::Config config; + MockTransport rtcp_send_transport; config.rtp.remote_ssrc = 42; + config.rtcp_send_transport = &rtcp_send_transport; config.decoder_factory = new rtc::RefCountedObject(); AudioReceiveStream* stream = call->CreateAudioReceiveStream(config); @@ -105,6 +107,8 @@ TEST(CallTest, CreateDestroy_AudioSendStreams) { TEST(CallTest, CreateDestroy_AudioReceiveStreams) { CallHelper call; AudioReceiveStream::Config config; + MockTransport rtcp_send_transport; + config.rtcp_send_transport = &rtcp_send_transport; config.decoder_factory = new rtc::RefCountedObject(); std::list streams; @@ -129,8 +133,10 @@ TEST(CallTest, CreateDestroy_AudioReceiveStreams) { TEST(CallTest, CreateDestroy_AssociateAudioSendReceiveStreams_RecvFirst) { CallHelper call; AudioReceiveStream::Config recv_config; + MockTransport rtcp_send_transport; recv_config.rtp.remote_ssrc = 42; recv_config.rtp.local_ssrc = 777; + recv_config.rtcp_send_transport = &rtcp_send_transport; recv_config.decoder_factory = new rtc::RefCountedObject(); AudioReceiveStream* recv_stream = call->CreateAudioReceiveStream(recv_config); @@ -160,8 +166,10 @@ TEST(CallTest, CreateDestroy_AssociateAudioSendReceiveStreams_SendFirst) { EXPECT_NE(send_stream, nullptr); AudioReceiveStream::Config recv_config; + MockTransport rtcp_send_transport; recv_config.rtp.remote_ssrc = 42; recv_config.rtp.local_ssrc = 777; + recv_config.rtcp_send_transport = &rtcp_send_transport; recv_config.decoder_factory = new rtc::RefCountedObject(); AudioReceiveStream* recv_stream = call->CreateAudioReceiveStream(recv_config);