Set ChannelReceive transport at construction time.
Followup to cl https://webrtc-review.googlesource.com/c/src/+/103640.
Set the rtcp_send_transport at construction time, delete
RegisterTransport, and the proxying of transport methods.
In addition, delete the unused RtcpRtpStats argument from the
constructor.
Bug: webrtc:9801
Change-Id: I80f25bc08dc2130386053568ddce4ef91654caeb
Reviewed-on: https://webrtc-review.googlesource.com/c/103803
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25010}
diff --git a/audio/audio_receive_stream.cc b/audio/audio_receive_stream.cc
index 7e473ed..563e8a0 100644
--- a/audio/audio_receive_stream.cc
+++ b/audio/audio_receive_stream.cc
@@ -73,7 +73,7 @@
return absl::make_unique<voe::ChannelReceiveProxy>(
absl::make_unique<voe::ChannelReceive>(
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 @@
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 @@
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 c5c53e5..97c42c4 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 @@
.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<int, SdpAudioFormat>& codecs) {
@@ -103,6 +103,7 @@
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<MockAudioDecoderFactory>;
}
@@ -150,6 +151,7 @@
AudioReceiveStream::Config stream_config_;
testing::StrictMock<MockChannelReceiveProxy>* channel_proxy_ = nullptr;
RtpStreamReceiverController rtp_stream_receiver_controller_;
+ MockTransport rtcp_send_transport_;
};
void BuildOneByteExtension(std::vector<uint8_t>::iterator it,
diff --git a/audio/channel_receive.cc b/audio/channel_receive.cc
index 26213cc..e9f7503 100644
--- a/audio/channel_receive.cc
+++ b/audio/channel_receive.cc
@@ -52,30 +52,6 @@
} // 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 @@
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 @@
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 @@
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 @@
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 2e089b7..82eb4df 100644
--- a/audio/channel_receive.h
+++ b/audio/channel_receive.h
@@ -102,12 +102,12 @@
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 @@
// 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 @@
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 @@
// 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 b68ab06..b1c1c45 100644
--- a/audio/channel_receive_proxy.cc
+++ b/audio/channel_receive_proxy.cc
@@ -51,11 +51,6 @@
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 2e65e79..8ebacc3 100644
--- a/audio/channel_receive_proxy.h
+++ b/audio/channel_receive_proxy.h
@@ -50,7 +50,6 @@
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 88a50ea..910858f 100644
--- a/audio/mock_voe_channel_proxy.h
+++ b/audio/mock_voe_channel_proxy.h
@@ -39,7 +39,6 @@
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 8e91665..8fcd566 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 @@
std::unique_ptr<test::PacketTransport> audio_send_transport;
std::unique_ptr<test::PacketTransport> video_send_transport;
std::unique_ptr<test::PacketTransport> receive_transport;
+ test::NullTransport rtcp_send_transport;
AudioSendStream* audio_send_stream;
AudioReceiveStream* audio_receive_stream;
@@ -250,6 +252,7 @@
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 1084bcf..8ae0400 100644
--- a/call/call_unittest.cc
+++ b/call/call_unittest.cc
@@ -72,7 +72,9 @@
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<webrtc::MockAudioDecoderFactory>();
AudioReceiveStream* stream = call->CreateAudioReceiveStream(config);
@@ -105,6 +107,8 @@
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<webrtc::MockAudioDecoderFactory>();
std::list<AudioReceiveStream*> streams;
@@ -129,8 +133,10 @@
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<webrtc::MockAudioDecoderFactory>();
AudioReceiveStream* recv_stream = call->CreateAudioReceiveStream(recv_config);
@@ -160,8 +166,10 @@
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<webrtc::MockAudioDecoderFactory>();
AudioReceiveStream* recv_stream = call->CreateAudioReceiveStream(recv_config);