From e97719974bdd29917e4bdc97b6a5218f8ad095d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Mon, 26 Nov 2018 10:55:07 +0100 Subject: [PATCH] Delete ChannelSend::RegisterTransport, replacing by construction argument Bug: webrtc:9719 Change-Id: If3960de660cfa7a65c8bf9375ceb0af0a67d376c Reviewed-on: https://webrtc-review.googlesource.com/c/111256 Reviewed-by: Fredrik Solenberg Reviewed-by: Sam Zackrisson Commit-Queue: Niels Moller Cr-Commit-Position: refs/heads/master@{#25784} --- audio/audio_send_stream.cc | 10 +++++----- audio/audio_send_stream_unittest.cc | 1 - audio/channel_send.cc | 20 ++++++++------------ audio/channel_send.h | 2 +- audio/mock_voe_channel_proxy.h | 1 - 5 files changed, 14 insertions(+), 20 deletions(-) diff --git a/audio/audio_send_stream.cc b/audio/audio_send_stream.cc index 082c557d87..75e6efb9e8 100644 --- a/audio/audio_send_stream.cc +++ b/audio/audio_send_stream.cc @@ -111,6 +111,7 @@ AudioSendStream::AudioSendStream( voe::CreateChannelSend(worker_queue, module_process_thread, config.media_transport, + config.send_transport, rtcp_rtt_stats, event_log, config.frame_encryptor, @@ -171,7 +172,6 @@ AudioSendStream::~AudioSendStream() { RTC_DCHECK(!sending_); if (rtp_transport_) { rtp_transport_->DeRegisterPacketFeedbackObserver(this); - channel_send_->RegisterTransport(nullptr); channel_send_->ResetSenderCongestionControlObjects(); } } @@ -214,6 +214,10 @@ void AudioSendStream::ConfigureStream( const auto& channel_send = stream->channel_send_; const auto& old_config = stream->config_; + // Configuration parameters which cannot be changed. + RTC_DCHECK(first_time || + old_config.send_transport == new_config.send_transport); + if (first_time || old_config.rtp.ssrc != new_config.rtp.ssrc) { channel_send->SetLocalSSRC(new_config.rtp.ssrc); if (stream->suspended_rtp_state_) { @@ -224,10 +228,6 @@ void AudioSendStream::ConfigureStream( channel_send->SetRTCP_CNAME(new_config.rtp.c_name); } - if (first_time || new_config.send_transport != old_config.send_transport) { - channel_send->RegisterTransport(new_config.send_transport); - } - // Enable the frame encryptor if a new frame encryptor has been provided. if (first_time || new_config.frame_encryptor != old_config.frame_encryptor) { channel_send->SetFrameEncryptor(new_config.frame_encryptor); diff --git a/audio/audio_send_stream_unittest.cc b/audio/audio_send_stream_unittest.cc index 13e588448e..e400ada0e5 100644 --- a/audio/audio_send_stream_unittest.cc +++ b/audio/audio_send_stream_unittest.cc @@ -211,7 +211,6 @@ struct ConfigHelper { .Times(1); } EXPECT_CALL(*channel_send_, ResetSenderCongestionControlObjects()).Times(1); - EXPECT_CALL(*channel_send_, RegisterTransport(nullptr)).Times(2); } void SetupMockForSetupSendCodec(bool expect_set_encoder_call) { diff --git a/audio/channel_send.cc b/audio/channel_send.cc index 31fe25f6ea..c458fe465b 100644 --- a/audio/channel_send.cc +++ b/audio/channel_send.cc @@ -91,6 +91,7 @@ class ChannelSend ChannelSend(rtc::TaskQueue* encoder_queue, ProcessThread* module_process_thread, MediaTransportInterface* media_transport, + Transport* rtp_transport, RtcpRttStats* rtcp_rtt_stats, RtcEventLog* rtc_event_log, FrameEncryptorInterface* frame_encryptor, @@ -115,7 +116,6 @@ class ChannelSend int GetBitrate() const override; // Network - void RegisterTransport(Transport* transport) override; bool ReceivedRTCPPacket(const uint8_t* data, size_t length) override; // Muting, Volume and Level. @@ -254,7 +254,7 @@ class ChannelSend // uses ProcessThread* const _moduleProcessThreadPtr; - Transport* _transportPtr; // WebRtc socket or external transport + Transport* const _transportPtr; // WebRtc socket or external transport RmsLevel rms_level_ RTC_GUARDED_BY(encoder_queue_); bool input_mute_ RTC_GUARDED_BY(volume_settings_critsect_); bool previous_frame_muted_ RTC_GUARDED_BY(encoder_queue_); @@ -683,6 +683,7 @@ bool ChannelSend::SendRtcp(const uint8_t* data, size_t len) { ChannelSend::ChannelSend(rtc::TaskQueue* encoder_queue, ProcessThread* module_process_thread, MediaTransportInterface* media_transport, + Transport* rtp_transport, RtcpRttStats* rtcp_rtt_stats, RtcEventLog* rtc_event_log, FrameEncryptorInterface* frame_encryptor, @@ -694,7 +695,7 @@ ChannelSend::ChannelSend(rtc::TaskQueue* encoder_queue, // random offset send_sequence_number_(0), _moduleProcessThreadPtr(module_process_thread), - _transportPtr(NULL), + _transportPtr(rtp_transport), input_mute_(false), previous_frame_muted_(false), _includeAudioLevelIndication(false), @@ -953,12 +954,6 @@ void ChannelSend::OnUplinkPacketLossRate(float packet_loss_rate) { }); } -void ChannelSend::RegisterTransport(Transport* transport) { - RTC_DCHECK_RUN_ON(&worker_thread_checker_); - rtc::CritScope cs(&_callbackCritSect); - _transportPtr = transport; -} - // TODO(nisse): Delete always-true return value. bool ChannelSend::ReceivedRTCPPacket(const uint8_t* data, size_t length) { // May be called on either worker thread or network thread. @@ -1344,6 +1339,7 @@ std::unique_ptr CreateChannelSend( rtc::TaskQueue* encoder_queue, ProcessThread* module_process_thread, MediaTransportInterface* media_transport, + Transport* rtp_transport, RtcpRttStats* rtcp_rtt_stats, RtcEventLog* rtc_event_log, FrameEncryptorInterface* frame_encryptor, @@ -1351,9 +1347,9 @@ std::unique_ptr CreateChannelSend( bool extmap_allow_mixed, int rtcp_report_interval_ms) { return absl::make_unique( - encoder_queue, module_process_thread, media_transport, rtcp_rtt_stats, - rtc_event_log, frame_encryptor, crypto_options, extmap_allow_mixed, - rtcp_report_interval_ms); + encoder_queue, module_process_thread, media_transport, rtp_transport, + rtcp_rtt_stats, rtc_event_log, frame_encryptor, crypto_options, + extmap_allow_mixed, rtcp_report_interval_ms); } } // namespace voe diff --git a/audio/channel_send.h b/audio/channel_send.h index 231fda674f..083e9a6029 100644 --- a/audio/channel_send.h +++ b/audio/channel_send.h @@ -55,7 +55,6 @@ class ChannelSendInterface { public: virtual ~ChannelSendInterface() = default; - virtual void RegisterTransport(Transport* transport) = 0; virtual bool ReceivedRTCPPacket(const uint8_t* packet, size_t length) = 0; virtual CallSendStatistics GetRTCPStatistics() const = 0; @@ -115,6 +114,7 @@ std::unique_ptr CreateChannelSend( rtc::TaskQueue* encoder_queue, ProcessThread* module_process_thread, MediaTransportInterface* media_transport, + Transport* rtp_transport, RtcpRttStats* rtcp_rtt_stats, RtcEventLog* rtc_event_log, FrameEncryptorInterface* frame_encryptor, diff --git a/audio/mock_voe_channel_proxy.h b/audio/mock_voe_channel_proxy.h index fe49359880..eee25c5a2d 100644 --- a/audio/mock_voe_channel_proxy.h +++ b/audio/mock_voe_channel_proxy.h @@ -90,7 +90,6 @@ class MockChannelSend : public voe::ChannelSendInterface { MOCK_METHOD2(SendTelephoneEventOutband, bool(int event, int duration_ms)); MOCK_METHOD1(OnBitrateAllocation, void(BitrateAllocationUpdate update)); MOCK_METHOD1(SetInputMute, void(bool muted)); - MOCK_METHOD1(RegisterTransport, void(Transport* transport)); MOCK_METHOD2(ReceivedRTCPPacket, bool(const uint8_t* packet, size_t length)); // GMock doesn't like move-only types, like std::unique_ptr. virtual void ProcessAndEncodeAudio(std::unique_ptr audio_frame) {