diff --git a/webrtc/api/rtcstatscollector_unittest.cc b/webrtc/api/rtcstatscollector_unittest.cc index 4d17003269..a9426622fb 100644 --- a/webrtc/api/rtcstatscollector_unittest.cc +++ b/webrtc/api/rtcstatscollector_unittest.cc @@ -101,7 +101,7 @@ void PrintTo(const RTCTransportStats& stats, ::std::ostream* os) { namespace { const int64_t kGetStatsReportTimeoutMs = 1000; -const bool kDefaultRtcpEnabled = false; +const bool kDefaultRtcpMuxRequired = true; const bool kDefaultSrtpRequired = true; struct CertificateInfo { @@ -598,12 +598,12 @@ TEST_F(RTCStatsCollectorTest, CollectRTCCodecStats) { cricket::VoiceChannel voice_channel( test_->worker_thread(), test_->network_thread(), nullptr, test_->media_engine(), voice_media_channel, "VoiceContentName", - kDefaultRtcpEnabled, kDefaultSrtpRequired); + kDefaultRtcpMuxRequired, kDefaultSrtpRequired); MockVideoMediaChannel* video_media_channel = new MockVideoMediaChannel(); cricket::VideoChannel video_channel( test_->worker_thread(), test_->network_thread(), nullptr, - video_media_channel, "VideoContentName", kDefaultRtcpEnabled, + video_media_channel, "VideoContentName", kDefaultRtcpMuxRequired, kDefaultSrtpRequired); // Audio @@ -1446,7 +1446,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Audio) { cricket::VoiceChannel voice_channel( test_->worker_thread(), test_->network_thread(), nullptr, test_->media_engine(), voice_media_channel, "VoiceContentName", - kDefaultRtcpEnabled, kDefaultSrtpRequired); + kDefaultRtcpMuxRequired, kDefaultSrtpRequired); cricket::VoiceMediaInfo voice_media_info; @@ -1518,7 +1518,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Video) { MockVideoMediaChannel* video_media_channel = new MockVideoMediaChannel(); cricket::VideoChannel video_channel( test_->worker_thread(), test_->network_thread(), nullptr, - video_media_channel, "VideoContentName", kDefaultRtcpEnabled, + video_media_channel, "VideoContentName", kDefaultRtcpMuxRequired, kDefaultSrtpRequired); cricket::VideoMediaInfo video_media_info; @@ -1598,7 +1598,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Audio) { cricket::VoiceChannel voice_channel( test_->worker_thread(), test_->network_thread(), nullptr, test_->media_engine(), voice_media_channel, "VoiceContentName", - kDefaultRtcpEnabled, kDefaultSrtpRequired); + kDefaultRtcpMuxRequired, kDefaultSrtpRequired); cricket::VoiceMediaInfo voice_media_info; @@ -1665,7 +1665,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Video) { MockVideoMediaChannel* video_media_channel = new MockVideoMediaChannel(); cricket::VideoChannel video_channel( test_->worker_thread(), test_->network_thread(), nullptr, - video_media_channel, "VideoContentName", kDefaultRtcpEnabled, + video_media_channel, "VideoContentName", kDefaultRtcpMuxRequired, kDefaultSrtpRequired); cricket::VideoMediaInfo video_media_info; @@ -1744,11 +1744,11 @@ TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Default) { cricket::VoiceChannel voice_channel( test_->worker_thread(), test_->network_thread(), nullptr, test_->media_engine(), voice_media_channel, "VoiceContentName", - kDefaultRtcpEnabled, kDefaultSrtpRequired); + kDefaultRtcpMuxRequired, kDefaultSrtpRequired); MockVideoMediaChannel* video_media_channel = new MockVideoMediaChannel(); cricket::VideoChannel video_channel( test_->worker_thread(), test_->network_thread(), nullptr, - video_media_channel, "VideoContentName", kDefaultRtcpEnabled, + video_media_channel, "VideoContentName", kDefaultRtcpMuxRequired, kDefaultSrtpRequired); cricket::VoiceMediaInfo voice_media_info; diff --git a/webrtc/api/rtpsenderreceiver_unittest.cc b/webrtc/api/rtpsenderreceiver_unittest.cc index b6c51841bd..7f6cb3a49f 100644 --- a/webrtc/api/rtpsenderreceiver_unittest.cc +++ b/webrtc/api/rtpsenderreceiver_unittest.cc @@ -62,18 +62,18 @@ class RtpSenderReceiverTest : public testing::Test { stream_(MediaStream::Create(kStreamLabel1)) { // Create channels to be used by the RtpSenders and RtpReceivers. channel_manager_.Init(); - bool rtcp_enabled = false; + bool rtcp_mux_required = true; bool srtp_required = true; cricket::TransportChannel* rtp_transport = fake_transport_controller_.CreateTransportChannel( cricket::CN_AUDIO, cricket::ICE_CANDIDATE_COMPONENT_RTP); voice_channel_ = channel_manager_.CreateVoiceChannel( &fake_media_controller_, rtp_transport, nullptr, rtc::Thread::Current(), - cricket::CN_AUDIO, nullptr, rtcp_enabled, srtp_required, + cricket::CN_AUDIO, nullptr, rtcp_mux_required, srtp_required, cricket::AudioOptions()); video_channel_ = channel_manager_.CreateVideoChannel( &fake_media_controller_, rtp_transport, nullptr, rtc::Thread::Current(), - cricket::CN_VIDEO, nullptr, rtcp_enabled, srtp_required, + cricket::CN_VIDEO, nullptr, rtcp_mux_required, srtp_required, cricket::VideoOptions()); voice_media_channel_ = media_engine_->GetVoiceChannel(0); video_media_channel_ = media_engine_->GetVideoChannel(0); diff --git a/webrtc/api/statscollector_unittest.cc b/webrtc/api/statscollector_unittest.cc index 5cabaaf675..5a0614ee41 100644 --- a/webrtc/api/statscollector_unittest.cc +++ b/webrtc/api/statscollector_unittest.cc @@ -51,7 +51,7 @@ using webrtc::StatsReport; using webrtc::StatsReports; namespace { -const bool kDefaultRtcpEnabled = false; +const bool kDefaultRtcpMuxRequired = true; const bool kDefaultSrtpRequired = true; } @@ -867,7 +867,7 @@ TEST_F(StatsCollectorTest, BytesCounterHandles64Bits) { MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); cricket::VideoChannel video_channel( worker_thread_, network_thread_, nullptr, media_channel, - kVideoChannelName, kDefaultRtcpEnabled, kDefaultSrtpRequired); + kVideoChannelName, kDefaultRtcpMuxRequired, kDefaultSrtpRequired); StatsReports reports; // returned values. cricket::VideoSenderInfo video_sender_info; cricket::VideoMediaInfo stats_read; @@ -916,7 +916,7 @@ TEST_F(StatsCollectorTest, BandwidthEstimationInfoIsReported) { MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); cricket::VideoChannel video_channel( worker_thread_, network_thread_, nullptr, media_channel, - kVideoChannelName, kDefaultRtcpEnabled, kDefaultSrtpRequired); + kVideoChannelName, kDefaultRtcpMuxRequired, kDefaultSrtpRequired); StatsReports reports; // returned values. cricket::VideoSenderInfo video_sender_info; @@ -992,7 +992,7 @@ TEST_F(StatsCollectorTest, TrackObjectExistsWithoutUpdateStats) { MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); cricket::VideoChannel video_channel( worker_thread_, network_thread_, nullptr, media_channel, "video", - kDefaultRtcpEnabled, kDefaultSrtpRequired); + kDefaultRtcpMuxRequired, kDefaultSrtpRequired); AddOutgoingVideoTrackStats(); stats.AddStream(stream_); @@ -1031,7 +1031,7 @@ TEST_F(StatsCollectorTest, TrackAndSsrcObjectExistAfterUpdateSsrcStats) { MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); cricket::VideoChannel video_channel( worker_thread_, network_thread_, nullptr, media_channel, - kVideoChannelName, kDefaultRtcpEnabled, kDefaultSrtpRequired); + kVideoChannelName, kDefaultRtcpMuxRequired, kDefaultSrtpRequired); AddOutgoingVideoTrackStats(); stats.AddStream(stream_); @@ -1100,7 +1100,7 @@ TEST_F(StatsCollectorTest, TransportObjectLinkedFromSsrcObject) { const std::string kVcName("vcname"); cricket::VideoChannel video_channel( worker_thread_, network_thread_, nullptr, media_channel, kVcName, - kDefaultRtcpEnabled, kDefaultSrtpRequired); + kDefaultRtcpMuxRequired, kDefaultSrtpRequired); AddOutgoingVideoTrackStats(); stats.AddStream(stream_); @@ -1161,7 +1161,7 @@ TEST_F(StatsCollectorTest, RemoteSsrcInfoIsAbsent) { const std::string kVcName("vcname"); cricket::VideoChannel video_channel( worker_thread_, network_thread_, nullptr, media_channel, kVcName, - kDefaultRtcpEnabled, kDefaultSrtpRequired); + kDefaultRtcpMuxRequired, kDefaultSrtpRequired); AddOutgoingVideoTrackStats(); stats.AddStream(stream_); @@ -1188,7 +1188,7 @@ TEST_F(StatsCollectorTest, RemoteSsrcInfoIsPresent) { const std::string kVcName("vcname"); cricket::VideoChannel video_channel( worker_thread_, network_thread_, nullptr, media_channel, kVcName, - kDefaultRtcpEnabled, kDefaultSrtpRequired); + kDefaultRtcpMuxRequired, kDefaultSrtpRequired); AddOutgoingVideoTrackStats(); stats.AddStream(stream_); @@ -1248,7 +1248,7 @@ TEST_F(StatsCollectorTest, ReportsFromRemoteTrack) { MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); cricket::VideoChannel video_channel( worker_thread_, network_thread_, nullptr, media_channel, - kVideoChannelName, kDefaultRtcpEnabled, kDefaultSrtpRequired); + kVideoChannelName, kDefaultRtcpMuxRequired, kDefaultSrtpRequired); AddIncomingVideoTrackStats(); stats.AddStream(stream_); @@ -1561,7 +1561,7 @@ TEST_F(StatsCollectorTest, FilterOutNegativeInitialValues) { const std::string kVcName("vcname"); cricket::VoiceChannel voice_channel( worker_thread_, network_thread_, nullptr, media_engine_, media_channel, - kVcName, kDefaultRtcpEnabled, kDefaultSrtpRequired); + kVcName, kDefaultRtcpMuxRequired, kDefaultSrtpRequired); // Create a local stream with a local audio track and adds it to the stats. if (stream_ == NULL) @@ -1671,7 +1671,7 @@ TEST_F(StatsCollectorTest, GetStatsFromLocalAudioTrack) { const std::string kVcName("vcname"); cricket::VoiceChannel voice_channel( worker_thread_, network_thread_, nullptr, media_engine_, media_channel, - kVcName, kDefaultRtcpEnabled, kDefaultSrtpRequired); + kVcName, kDefaultRtcpMuxRequired, kDefaultSrtpRequired); AddOutgoingAudioTrackStats(); stats.AddStream(stream_); stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); @@ -1707,7 +1707,7 @@ TEST_F(StatsCollectorTest, GetStatsFromRemoteStream) { const std::string kVcName("vcname"); cricket::VoiceChannel voice_channel( worker_thread_, network_thread_, nullptr, media_engine_, media_channel, - kVcName, kDefaultRtcpEnabled, kDefaultSrtpRequired); + kVcName, kDefaultRtcpMuxRequired, kDefaultSrtpRequired); AddIncomingAudioTrackStats(); stats.AddStream(stream_); @@ -1737,7 +1737,7 @@ TEST_F(StatsCollectorTest, GetStatsAfterRemoveAudioStream) { const std::string kVcName("vcname"); cricket::VoiceChannel voice_channel( worker_thread_, network_thread_, nullptr, media_engine_, media_channel, - kVcName, kDefaultRtcpEnabled, kDefaultSrtpRequired); + kVcName, kDefaultRtcpMuxRequired, kDefaultSrtpRequired); AddOutgoingAudioTrackStats(); stats.AddStream(stream_); stats.AddLocalAudioTrack(audio_track_.get(), kSsrcOfTrack); @@ -1801,7 +1801,7 @@ TEST_F(StatsCollectorTest, LocalAndRemoteTracksWithSameSsrc) { const std::string kVcName("vcname"); cricket::VoiceChannel voice_channel( worker_thread_, network_thread_, nullptr, media_engine_, media_channel, - kVcName, kDefaultRtcpEnabled, kDefaultSrtpRequired); + kVcName, kDefaultRtcpMuxRequired, kDefaultSrtpRequired); // Create a local stream with a local audio track and adds it to the stats. AddOutgoingAudioTrackStats(); @@ -1891,7 +1891,7 @@ TEST_F(StatsCollectorTest, TwoLocalTracksWithSameSsrc) { const std::string kVcName("vcname"); cricket::VoiceChannel voice_channel( worker_thread_, network_thread_, nullptr, media_engine_, media_channel, - kVcName, kDefaultRtcpEnabled, kDefaultSrtpRequired); + kVcName, kDefaultRtcpMuxRequired, kDefaultSrtpRequired); // Create a local stream with a local audio track and adds it to the stats. AddOutgoingAudioTrackStats(); @@ -1951,7 +1951,7 @@ TEST_F(StatsCollectorTest, VerifyVideoSendSsrcStats) { MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); cricket::VideoChannel video_channel( worker_thread_, network_thread_, nullptr, media_channel, - kVideoChannelName, kDefaultRtcpEnabled, kDefaultSrtpRequired); + kVideoChannelName, kDefaultRtcpMuxRequired, kDefaultSrtpRequired); StatsReports reports; // returned values. cricket::VideoSenderInfo video_sender_info; cricket::VideoMediaInfo stats_read; @@ -1999,7 +1999,7 @@ TEST_F(StatsCollectorTest, VerifyVideoReceiveSsrcStats) { MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); cricket::VideoChannel video_channel( worker_thread_, network_thread_, nullptr, media_channel, - kVideoChannelName, kDefaultRtcpEnabled, kDefaultSrtpRequired); + kVideoChannelName, kDefaultRtcpMuxRequired, kDefaultSrtpRequired); StatsReports reports; // returned values. cricket::VideoReceiverInfo video_receiver_info; cricket::VideoMediaInfo stats_read; diff --git a/webrtc/api/webrtcsession.cc b/webrtc/api/webrtcsession.cc index aa172cef37..30a0a7c25e 100644 --- a/webrtc/api/webrtcsession.cc +++ b/webrtc/api/webrtcsession.cc @@ -1787,7 +1787,6 @@ bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content, const std::string* bundle_transport) { bool require_rtcp_mux = rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire; - bool create_rtcp_transport_channel = !require_rtcp_mux; std::string transport_name = bundle_transport ? *bundle_transport : content->name; @@ -1796,7 +1795,7 @@ bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content, transport_controller_->CreateTransportChannel( transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); cricket::TransportChannel* rtcp_transport = nullptr; - if (create_rtcp_transport_channel) { + if (!require_rtcp_mux) { rtcp_transport = transport_controller_->CreateTransportChannel( transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP); } @@ -1804,18 +1803,13 @@ bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content, voice_channel_.reset(channel_manager_->CreateVoiceChannel( media_controller_, rtp_transport, rtcp_transport, transport_controller_->signaling_thread(), content->name, - bundle_transport, create_rtcp_transport_channel, SrtpRequired(), - audio_options_)); + bundle_transport, require_rtcp_mux, SrtpRequired(), audio_options_)); if (!voice_channel_) { return false; } - voice_channel_->SignalDestroyRtcpTransport.connect( - this, &WebRtcSession::OnDestroyRtcpTransport_n); - if (require_rtcp_mux) { - voice_channel_->ActivateRtcpMux(); - } - + voice_channel_->SignalRtcpMuxFullyActive.connect( + this, &WebRtcSession::DestroyRtcpTransport_n); voice_channel_->SignalDtlsSrtpSetupFailure.connect( this, &WebRtcSession::OnDtlsSrtpSetupFailure); @@ -1829,7 +1823,6 @@ bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content, const std::string* bundle_transport) { bool require_rtcp_mux = rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire; - bool create_rtcp_transport_channel = !require_rtcp_mux; std::string transport_name = bundle_transport ? *bundle_transport : content->name; @@ -1838,7 +1831,7 @@ bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content, transport_controller_->CreateTransportChannel( transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); cricket::TransportChannel* rtcp_transport = nullptr; - if (create_rtcp_transport_channel) { + if (!require_rtcp_mux) { rtcp_transport = transport_controller_->CreateTransportChannel( transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP); } @@ -1846,18 +1839,14 @@ bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content, video_channel_.reset(channel_manager_->CreateVideoChannel( media_controller_, rtp_transport, rtcp_transport, transport_controller_->signaling_thread(), content->name, - bundle_transport, create_rtcp_transport_channel, SrtpRequired(), - video_options_)); + bundle_transport, require_rtcp_mux, SrtpRequired(), video_options_)); if (!video_channel_) { return false; } - video_channel_->SignalDestroyRtcpTransport.connect( - this, &WebRtcSession::OnDestroyRtcpTransport_n); - if (require_rtcp_mux) { - video_channel_->ActivateRtcpMux(); - } + video_channel_->SignalRtcpMuxFullyActive.connect( + this, &WebRtcSession::DestroyRtcpTransport_n); video_channel_->SignalDtlsSrtpSetupFailure.connect( this, &WebRtcSession::OnDtlsSrtpSetupFailure); @@ -1894,7 +1883,6 @@ bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content, } else { bool require_rtcp_mux = rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire; - bool create_rtcp_transport_channel = !sctp && !require_rtcp_mux; std::string transport_name = bundle_transport ? *bundle_transport : content->name; @@ -1902,7 +1890,7 @@ bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content, transport_controller_->CreateTransportChannel( transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); cricket::TransportChannel* rtcp_transport = nullptr; - if (create_rtcp_transport_channel) { + if (!require_rtcp_mux) { rtcp_transport = transport_controller_->CreateTransportChannel( transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP); } @@ -1910,18 +1898,14 @@ bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content, rtp_data_channel_.reset(channel_manager_->CreateRtpDataChannel( media_controller_, rtp_transport, rtcp_transport, transport_controller_->signaling_thread(), content->name, - bundle_transport, create_rtcp_transport_channel, SrtpRequired())); + bundle_transport, require_rtcp_mux, SrtpRequired())); if (!rtp_data_channel_) { return false; } - rtp_data_channel_->SignalDestroyRtcpTransport.connect( - this, &WebRtcSession::OnDestroyRtcpTransport_n); - - if (require_rtcp_mux) { - rtp_data_channel_->ActivateRtcpMux(); - } + rtp_data_channel_->SignalRtcpMuxFullyActive.connect( + this, &WebRtcSession::DestroyRtcpTransport_n); rtp_data_channel_->SignalDtlsSrtpSetupFailure.connect( this, &WebRtcSession::OnDtlsSrtpSetupFailure); rtp_data_channel_->SignalSentPacket.connect(this, @@ -2389,8 +2373,7 @@ void WebRtcSession::DestroyTransport(const std::string& transport_name, transport_controller_.get(), transport_name, component)); } -void WebRtcSession::OnDestroyRtcpTransport_n( - const std::string& transport_name) { +void WebRtcSession::DestroyRtcpTransport_n(const std::string& transport_name) { ASSERT(network_thread()->IsCurrent()); transport_controller_->DestroyTransportChannel_n( transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP); diff --git a/webrtc/api/webrtcsession.h b/webrtc/api/webrtcsession.h index 42e0e4bc0d..f75328f5bb 100644 --- a/webrtc/api/webrtcsession.h +++ b/webrtc/api/webrtcsession.h @@ -554,7 +554,7 @@ class WebRtcSession : const std::string GetTransportName(const std::string& content_name); void DestroyTransport(const std::string& transport_name, int component); - void OnDestroyRtcpTransport_n(const std::string& transport_name); + void DestroyRtcpTransport_n(const std::string& transport_name); void DestroyVideoChannel(); void DestroyVoiceChannel(); void DestroyDataChannel(); diff --git a/webrtc/pc/channel.cc b/webrtc/pc/channel.cc index 182d4cafcd..942e8267cb 100644 --- a/webrtc/pc/channel.cc +++ b/webrtc/pc/channel.cc @@ -163,13 +163,13 @@ BaseChannel::BaseChannel(rtc::Thread* worker_thread, rtc::Thread* signaling_thread, MediaChannel* media_channel, const std::string& content_name, - bool rtcp, + bool rtcp_mux_required, bool srtp_required) : worker_thread_(worker_thread), network_thread_(network_thread), signaling_thread_(signaling_thread), content_name_(content_name), - rtcp_enabled_(rtcp), + rtcp_mux_required_(rtcp_mux_required), srtp_required_(srtp_required), media_channel_(media_channel), selected_candidate_pair_(nullptr) { @@ -240,6 +240,9 @@ bool BaseChannel::InitNetwork_n(TransportChannel* rtp_transport, if (rtcp_transport_ && !SetDtlsSrtpCryptoSuites_n(rtcp_transport_, true)) { return false; } + if (rtcp_mux_required_) { + rtcp_mux_filter_.SetActive(); + } return true; } @@ -291,8 +294,8 @@ bool BaseChannel::SetTransport_n(TransportChannel* rtp_transport, srtp_filter_.ResetParams(); } - // If this BaseChannel uses RTCP and we haven't fully negotiated RTCP mux, - // we need an RTCP channel. + // If this BaseChannel doesn't require RTCP mux and we haven't fully + // negotiated RTCP mux, we need an RTCP transport. if (NeedsRtcpTransport()) { LOG(LS_INFO) << "Setting RTCP Transport for " << content_name() << " on " << transport_name() << " transport " << rtcp_transport; @@ -452,7 +455,9 @@ bool BaseChannel::GetConnectionStats(ConnectionInfos* infos) { } bool BaseChannel::NeedsRtcpTransport() { - return rtcp_enabled_ && !rtcp_mux_filter_.IsFullyActive(); + // If this BaseChannel doesn't require RTCP mux and we haven't fully + // negotiated RTCP mux, we need an RTCP transport. + return !rtcp_mux_required_ && !rtcp_mux_filter_.IsFullyActive(); } bool BaseChannel::IsReadyToReceiveMedia_w() const { @@ -1157,26 +1162,6 @@ bool BaseChannel::SetSrtp_n(const std::vector& cryptos, return true; } -void BaseChannel::ActivateRtcpMux() { - network_thread_->Invoke(RTC_FROM_HERE, - Bind(&BaseChannel::ActivateRtcpMux_n, this)); -} - -void BaseChannel::ActivateRtcpMux_n() { - if (!rtcp_mux_filter_.IsActive()) { - rtcp_mux_filter_.SetActive(); - bool need_to_delete_rtcp = (rtcp_transport() != nullptr); - SetTransportChannel_n(true, nullptr); - if (need_to_delete_rtcp) { - SignalDestroyRtcpTransport(rtp_transport()->transport_name()); - } - // Update aggregate writable/ready-to-send state between RTP and RTCP upon - // removing channel. - UpdateWritableState_n(); - SetTransportChannelReadyToSend(true, false); - } -} - bool BaseChannel::SetRtcpMux_n(bool enable, ContentAction action, ContentSource src, @@ -1198,10 +1183,9 @@ bool BaseChannel::SetRtcpMux_n(bool enable, LOG(LS_INFO) << "Enabling rtcp-mux for " << content_name() << " by destroying RTCP transport channel for " << transport_name(); - bool need_to_delete_rtcp = (rtcp_transport() != nullptr); - SetTransportChannel_n(true, nullptr); - if (need_to_delete_rtcp) { - SignalDestroyRtcpTransport(rtp_transport()->transport_name()); + if (rtcp_transport()) { + SetTransportChannel_n(true, nullptr); + SignalRtcpMuxFullyActive(rtp_transport()->transport_name()); } UpdateWritableState_n(); SetTransportChannelReadyToSend(true, false); @@ -1462,14 +1446,14 @@ VoiceChannel::VoiceChannel(rtc::Thread* worker_thread, MediaEngineInterface* media_engine, VoiceMediaChannel* media_channel, const std::string& content_name, - bool rtcp, + bool rtcp_mux_required, bool srtp_required) : BaseChannel(worker_thread, network_thread, signaling_thread, media_channel, content_name, - rtcp, + rtcp_mux_required, srtp_required), media_engine_(media_engine), received_media_(false) {} @@ -1875,14 +1859,14 @@ VideoChannel::VideoChannel(rtc::Thread* worker_thread, rtc::Thread* signaling_thread, VideoMediaChannel* media_channel, const std::string& content_name, - bool rtcp, + bool rtcp_mux_required, bool srtp_required) : BaseChannel(worker_thread, network_thread, signaling_thread, media_channel, content_name, - rtcp, + rtcp_mux_required, srtp_required) {} bool VideoChannel::Init_w(TransportChannel* rtp_transport, @@ -2136,14 +2120,14 @@ RtpDataChannel::RtpDataChannel(rtc::Thread* worker_thread, rtc::Thread* signaling_thread, DataMediaChannel* media_channel, const std::string& content_name, - bool rtcp, + bool rtcp_mux_required, bool srtp_required) : BaseChannel(worker_thread, network_thread, signaling_thread, media_channel, content_name, - rtcp, + rtcp_mux_required, srtp_required) {} RtpDataChannel::~RtpDataChannel() { diff --git a/webrtc/pc/channel.h b/webrtc/pc/channel.h index e5180ca26f..c7749a9715 100644 --- a/webrtc/pc/channel.h +++ b/webrtc/pc/channel.h @@ -83,7 +83,7 @@ class BaseChannel rtc::Thread* signaling_thread, MediaChannel* channel, const std::string& content_name, - bool rtcp, + bool rtcp_mux_required, bool srtp_required); virtual ~BaseChannel(); bool Init_w(TransportChannel* rtp_transport, @@ -107,11 +107,6 @@ class BaseChannel bool writable() const { return writable_; } - // Activate RTCP mux, regardless of the state so far. Once - // activated, it can not be deactivated, and if the remote - // description doesn't support RTCP mux, setting the remote - // description will fail. - void ActivateRtcpMux(); bool SetTransport(TransportChannel* rtp_transport, TransportChannel* rtcp_transport); bool PushdownLocalDescription(const SessionDescription* local_desc, @@ -161,9 +156,10 @@ class BaseChannel // Forward TransportChannel SignalSentPacket to worker thread. sigslot::signal1 SignalSentPacket; - // Emitted whenever the rtcp-mux is active and the rtcp-transport can be - // destroyed. - sigslot::signal1 SignalDestroyRtcpTransport; + // Emitted whenever rtcp-mux is fully negotiated and the rtcp-transport can + // be destroyed. + // Fired on the network thread. + sigslot::signal1 SignalRtcpMuxFullyActive; TransportChannel* rtp_transport() const { return rtp_transport_; } TransportChannel* rtcp_transport() const { return rtcp_transport_; } @@ -335,7 +331,6 @@ class BaseChannel ContentAction action, ContentSource src, std::string* error_desc); - void ActivateRtcpMux_n(); bool SetRtcpMux_n(bool enable, ContentAction action, ContentSource src, @@ -382,10 +377,9 @@ class BaseChannel std::unique_ptr connection_monitor_; std::string transport_name_; - // Is RTCP used at all by this type of channel? - // Expected to be true (as of typing this) for everything except data - // channels. - const bool rtcp_enabled_; + // True if RTCP-multiplexing is required. In other words, no standalone RTCP + // transport will ever be used for this channel. + const bool rtcp_mux_required_; // TODO(johan): Replace TransportChannel* with rtc::PacketTransportInterface*. TransportChannel* rtp_transport_ = nullptr; std::vector > socket_options_; @@ -428,7 +422,7 @@ class VoiceChannel : public BaseChannel { MediaEngineInterface* media_engine, VoiceMediaChannel* channel, const std::string& content_name, - bool rtcp, + bool rtcp_mux_required, bool srtp_required); ~VoiceChannel(); bool Init_w(TransportChannel* rtp_transport, @@ -547,7 +541,7 @@ class VideoChannel : public BaseChannel { rtc::Thread* signaling_thread, VideoMediaChannel* channel, const std::string& content_name, - bool rtcp, + bool rtcp_mux_required, bool srtp_required); ~VideoChannel(); bool Init_w(TransportChannel* rtp_transport, @@ -627,7 +621,7 @@ class RtpDataChannel : public BaseChannel { rtc::Thread* signaling_thread, DataMediaChannel* channel, const std::string& content_name, - bool rtcp, + bool rtcp_mux_required, bool srtp_required); ~RtpDataChannel(); bool Init_w(TransportChannel* rtp_transport, diff --git a/webrtc/pc/channel_unittest.cc b/webrtc/pc/channel_unittest.cc index f8346c9a8e..3970588e83 100644 --- a/webrtc/pc/channel_unittest.cc +++ b/webrtc/pc/channel_unittest.cc @@ -95,8 +95,14 @@ class DataTraits : public Traits class ChannelTest : public testing::Test, public sigslot::has_slots<> { public: - enum Flags { RTCP = 0x1, RTCP_MUX = 0x2, SECURE = 0x4, SSRC_MUX = 0x8, - DTLS = 0x10, GCM_CIPHER = 0x20 }; + enum Flags { + RTCP_MUX = 0x1, + RTCP_MUX_REQUIRED = 0x2, + SECURE = 0x4, + SSRC_MUX = 0x8, + DTLS = 0x10, + GCM_CIPHER = 0x20 + }; ChannelTest(bool verify_playout, rtc::ArrayView rtp_data, @@ -132,6 +138,9 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { typename T::MediaChannel* ch2, int flags1, int flags2) { + // Make sure RTCP_MUX_REQUIRED isn't set without RTCP_MUX. + ASSERT_NE(RTCP_MUX_REQUIRED, flags1 & (RTCP_MUX | RTCP_MUX_REQUIRED)); + ASSERT_NE(RTCP_MUX_REQUIRED, flags2 & (RTCP_MUX | RTCP_MUX_REQUIRED)); rtc::Thread* worker_thread = rtc::Thread::Current(); media_channel1_ = ch1; media_channel2_ = ch2; @@ -145,10 +154,10 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { &ChannelTest::OnMediaMonitor1); channel2_->SignalMediaMonitor.connect(this, &ChannelTest::OnMediaMonitor2); - channel1_->SignalDestroyRtcpTransport.connect( + channel1_->SignalRtcpMuxFullyActive.connect( transport_controller1_.get(), &cricket::FakeTransportController::DestroyRtcpTransport); - channel2_->SignalDestroyRtcpTransport.connect( + channel2_->SignalRtcpMuxFullyActive.connect( transport_controller2_.get(), &cricket::FakeTransportController::DestroyRtcpTransport); if ((flags1 & DTLS) && (flags2 & DTLS)) { @@ -201,7 +210,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { : nullptr; typename T::Channel* channel = new typename T::Channel( worker_thread, network_thread, signaling_thread, engine, ch, - cricket::CN_AUDIO, (flags & RTCP) != 0, (flags & SECURE) != 0); + cricket::CN_AUDIO, (flags & RTCP_MUX_REQUIRED) != 0, + (flags & SECURE) != 0); rtc::CryptoOptions crypto_options; crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; channel->SetCryptoOptions(crypto_options); @@ -529,7 +539,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { // Test that SetLocalContent and SetRemoteContent properly set RTCP // mux. void TestSetContentsRtcpMux() { - CreateChannels(RTCP, RTCP); + CreateChannels(0, 0); EXPECT_TRUE(channel1_->rtcp_transport() != NULL); EXPECT_TRUE(channel2_->rtcp_transport() != NULL); typename T::Content content; @@ -549,7 +559,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { // Test that SetLocalContent and SetRemoteContent properly set RTCP // mux when a provisional answer is received. void TestSetContentsRtcpMuxWithPrAnswer() { - CreateChannels(RTCP, RTCP); + CreateChannels(0, 0); EXPECT_TRUE(channel1_->rtcp_transport() != NULL); EXPECT_TRUE(channel2_->rtcp_transport() != NULL); typename T::Content content; @@ -573,9 +583,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { void TestSetRemoteContentUpdate() { CreateChannels(0, 0); typename T::Content content; - CreateContent(RTCP | RTCP_MUX | SECURE, - kPcmuCodec, kH264Codec, - &content); + CreateContent(RTCP_MUX | SECURE, kPcmuCodec, kH264Codec, &content); EXPECT_EQ(0U, media_channel1_->codecs().size()); EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); @@ -1024,7 +1032,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { } }; CreateChannels(new LastWordMediaChannel(), new LastWordMediaChannel(), - RTCP | RTCP_MUX, RTCP | RTCP_MUX); + RTCP_MUX, RTCP_MUX); EXPECT_TRUE(SendInitiate()); EXPECT_TRUE(SendAccept()); EXPECT_TRUE(SendTerminate()); @@ -1032,7 +1040,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { // Send voice RTP data to the other side and ensure it gets there. void SendRtpToRtp() { - CreateChannels(0, 0); + CreateChannels(RTCP_MUX | RTCP_MUX_REQUIRED, RTCP_MUX | RTCP_MUX_REQUIRED); EXPECT_TRUE(SendInitiate()); EXPECT_TRUE(SendAccept()); EXPECT_EQ(1U, GetChannels1().size()); @@ -1047,7 +1055,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { } void TestDeinit() { - CreateChannels(RTCP, RTCP); + CreateChannels(0, 0); EXPECT_TRUE(SendInitiate()); EXPECT_TRUE(SendAccept()); SendRtp1(); @@ -1059,51 +1067,9 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { channel2_.reset(nullptr); } - // Check that RTCP is not transmitted if both sides don't support RTCP. - void SendNoRtcpToNoRtcp() { - CreateChannels(0, 0); - EXPECT_TRUE(SendInitiate()); - EXPECT_TRUE(SendAccept()); - EXPECT_EQ(1U, GetChannels1().size()); - EXPECT_EQ(1U, GetChannels2().size()); - SendRtcp1(); - SendRtcp2(); - WaitForThreads(); - EXPECT_TRUE(CheckNoRtcp1()); - EXPECT_TRUE(CheckNoRtcp2()); - } - - // Check that RTCP is not transmitted if the callee doesn't support RTCP. - void SendNoRtcpToRtcp() { - CreateChannels(0, RTCP); - EXPECT_TRUE(SendInitiate()); - EXPECT_TRUE(SendAccept()); - EXPECT_EQ(1U, GetChannels1().size()); - EXPECT_EQ(2U, GetChannels2().size()); - SendRtcp1(); - SendRtcp2(); - WaitForThreads(); - EXPECT_TRUE(CheckNoRtcp1()); - EXPECT_TRUE(CheckNoRtcp2()); - } - - // Check that RTCP is not transmitted if the caller doesn't support RTCP. - void SendRtcpToNoRtcp() { - CreateChannels(RTCP, 0); - EXPECT_TRUE(SendInitiate()); - EXPECT_TRUE(SendAccept()); - EXPECT_EQ(2U, GetChannels1().size()); - EXPECT_EQ(1U, GetChannels2().size()); - SendRtcp1(); - SendRtcp2(); - WaitForThreads(); - EXPECT_TRUE(CheckNoRtcp1()); - EXPECT_TRUE(CheckNoRtcp2()); - } - - // Check that RTCP is transmitted if both sides support RTCP. + // Check that RTCP can be transmitted between both sides. void SendRtcpToRtcp() { - CreateChannels(RTCP, RTCP); + CreateChannels(0, 0); EXPECT_TRUE(SendInitiate()); EXPECT_TRUE(SendAccept()); EXPECT_EQ(2U, GetChannels1().size()); @@ -1119,7 +1085,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { // Check that RTCP is transmitted if only the initiator supports mux. void SendRtcpMuxToRtcp() { - CreateChannels(RTCP | RTCP_MUX, RTCP); + CreateChannels(RTCP_MUX, 0); EXPECT_TRUE(SendInitiate()); EXPECT_TRUE(SendAccept()); EXPECT_EQ(2U, GetChannels1().size()); @@ -1135,7 +1101,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { // Check that RTP and RTCP are transmitted ok when both sides support mux. void SendRtcpMuxToRtcpMux() { - CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); + CreateChannels(RTCP_MUX, RTCP_MUX); EXPECT_TRUE(SendInitiate()); EXPECT_EQ(2U, GetChannels1().size()); EXPECT_EQ(1U, GetChannels2().size()); @@ -1159,8 +1125,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { // Check that RTP and RTCP are transmitted ok when both sides // support mux and one the offerer requires mux. void SendRequireRtcpMuxToRtcpMux() { - CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); - channel1_->ActivateRtcpMux(); + CreateChannels(RTCP_MUX | RTCP_MUX_REQUIRED, RTCP_MUX); EXPECT_TRUE(SendInitiate()); EXPECT_EQ(1U, GetChannels1().size()); EXPECT_EQ(1U, GetChannels2().size()); @@ -1181,10 +1146,9 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { } // Check that RTP and RTCP are transmitted ok when both sides - // support mux and one the answerer requires rtcp mux. + // support mux and only the answerer requires rtcp mux. void SendRtcpMuxToRequireRtcpMux() { - CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); - channel2_->ActivateRtcpMux(); + CreateChannels(RTCP_MUX, RTCP_MUX | RTCP_MUX_REQUIRED); EXPECT_TRUE(SendInitiate()); EXPECT_EQ(2U, GetChannels1().size()); EXPECT_EQ(1U, GetChannels2().size()); @@ -1208,9 +1172,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { // Check that RTP and RTCP are transmitted ok when both sides // require mux. void SendRequireRtcpMuxToRequireRtcpMux() { - CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); - channel1_->ActivateRtcpMux(); - channel2_->ActivateRtcpMux(); + CreateChannels(RTCP_MUX | RTCP_MUX_REQUIRED, RTCP_MUX | RTCP_MUX_REQUIRED); EXPECT_TRUE(SendInitiate()); EXPECT_EQ(1U, GetChannels1().size()); EXPECT_EQ(1U, GetChannels2().size()); @@ -1234,8 +1196,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { // Check that SendAccept fails if the answerer doesn't support mux // and the offerer requires it. void SendRequireRtcpMuxToNoRtcpMux() { - CreateChannels(RTCP | RTCP_MUX, RTCP); - channel1_->ActivateRtcpMux(); + CreateChannels(RTCP_MUX | RTCP_MUX_REQUIRED, 0); EXPECT_TRUE(SendInitiate()); EXPECT_EQ(1U, GetChannels1().size()); EXPECT_EQ(2U, GetChannels2().size()); @@ -1244,7 +1205,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { // Check that RTCP data sent by the initiator before the accept is not muxed. void SendEarlyRtcpMuxToRtcp() { - CreateChannels(RTCP | RTCP_MUX, RTCP); + CreateChannels(RTCP_MUX, 0); EXPECT_TRUE(SendInitiate()); EXPECT_EQ(2U, GetChannels1().size()); EXPECT_EQ(2U, GetChannels2().size()); @@ -1277,7 +1238,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { // but that we properly demux before we get the accept message, since there // is a race between RTP data and the jingle accept. void SendEarlyRtcpMuxToRtcpMux() { - CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); + CreateChannels(RTCP_MUX, RTCP_MUX); EXPECT_TRUE(SendInitiate()); EXPECT_EQ(2U, GetChannels1().size()); EXPECT_EQ(1U, GetChannels2().size()); @@ -1310,8 +1271,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { ASSERT((flags1_in & ~(RTCP_MUX | DTLS | GCM_CIPHER)) == 0); ASSERT((flags2_in & ~(RTCP_MUX | DTLS | GCM_CIPHER)) == 0); - int flags1 = RTCP | SECURE | flags1_in; - int flags2 = RTCP | SECURE | flags2_in; + int flags1 = SECURE | flags1_in; + int flags2 = SECURE | flags2_in; bool dtls1 = !!(flags1_in & DTLS); bool dtls2 = !!(flags2_in & DTLS); CreateChannels(flags1, flags2); @@ -1351,7 +1312,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { // Test that we properly handling SRTP negotiating down to RTP. void SendSrtpToRtp() { - CreateChannels(RTCP | SECURE, RTCP); + CreateChannels(SECURE, 0); EXPECT_FALSE(channel1_->secure()); EXPECT_FALSE(channel2_->secure()); EXPECT_TRUE(SendInitiate()); @@ -1378,8 +1339,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { void SendEarlyMediaUsingRtcpMuxSrtp() { int sequence_number1_1 = 0, sequence_number2_2 = 0; - CreateChannels(SSRC_MUX | RTCP | RTCP_MUX | SECURE, - SSRC_MUX | RTCP | RTCP_MUX | SECURE); + CreateChannels(SSRC_MUX | RTCP_MUX | SECURE, + SSRC_MUX | RTCP_MUX | SECURE); EXPECT_TRUE(SendOffer()); EXPECT_TRUE(SendProvisionalAnswer()); EXPECT_TRUE(channel1_->secure()); @@ -1419,7 +1380,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { // Test that we properly send RTP without SRTP from a thread. void SendRtpToRtpOnThread() { - CreateChannels(RTCP, RTCP); + CreateChannels(0, 0); EXPECT_TRUE(SendInitiate()); EXPECT_TRUE(SendAccept()); ScopedCallThread send_rtp1([this] { SendRtp1(); }); @@ -1442,7 +1403,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { // Test that we properly send SRTP with RTCP from a thread. void SendSrtpToSrtpOnThread() { - CreateChannels(RTCP | SECURE, RTCP | SECURE); + CreateChannels(SECURE, SECURE); EXPECT_TRUE(SendInitiate()); EXPECT_TRUE(SendAccept()); ScopedCallThread send_rtp1([this] { SendRtp1(); }); @@ -1466,7 +1427,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { // Test that the mediachannel retains its sending state after the transport // becomes non-writable. void SendWithWritabilityLoss() { - CreateChannels(0, 0); + CreateChannels(RTCP_MUX | RTCP_MUX_REQUIRED, RTCP_MUX | RTCP_MUX_REQUIRED); EXPECT_TRUE(SendInitiate()); EXPECT_TRUE(SendAccept()); EXPECT_EQ(1U, GetChannels1().size()); @@ -1534,7 +1495,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { // and |channel2_|. int pl_type1 = pl_types[0]; int pl_type2 = pl_types[1]; - int flags = SSRC_MUX | RTCP; + int flags = SSRC_MUX; if (secure) flags |= SECURE; uint32_t expected_channels = 2U; if (rtcp_mux) { @@ -1724,7 +1685,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { } void TestFlushRtcp() { - CreateChannels(RTCP, RTCP); + CreateChannels(0, 0); EXPECT_TRUE(SendInitiate()); EXPECT_TRUE(SendAccept()); EXPECT_EQ(2U, GetChannels1().size()); @@ -1779,7 +1740,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { // TODO(deadbeef): Fix this. fake_clock.AdvanceTime(rtc::TimeDelta::FromSeconds(1)); - CreateChannels(RTCP | SECURE, RTCP | SECURE); + CreateChannels(SECURE, SECURE); EXPECT_FALSE(channel1_->secure()); EXPECT_FALSE(channel2_->secure()); EXPECT_TRUE(SendInitiate()); @@ -1832,7 +1793,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { } void TestOnReadyToSend() { - CreateChannels(RTCP, RTCP); + CreateChannels(0, 0); TransportChannel* rtp = channel1_->rtp_transport(); TransportChannel* rtcp = channel1_->rtcp_transport(); EXPECT_FALSE(media_channel1_->ready_to_send()); @@ -1877,7 +1838,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { } void TestOnReadyToSendWithRtcpMux() { - CreateChannels(RTCP, RTCP); + CreateChannels(0, 0); typename T::Content content; CreateContent(0, kPcmuCodec, kH264Codec, &content); // Both sides agree on mux. Should no longer be a separate RTCP channel. @@ -2060,7 +2021,7 @@ cricket::VideoChannel* ChannelTest::CreateChannel( transport_controller ? transport_controller->signaling_thread() : nullptr; cricket::VideoChannel* channel = new cricket::VideoChannel( worker_thread, network_thread, signaling_thread, ch, cricket::CN_VIDEO, - (flags & RTCP) != 0, (flags & SECURE) != 0); + (flags & RTCP_MUX_REQUIRED) != 0, (flags & SECURE) != 0); rtc::CryptoOptions crypto_options; crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; channel->SetCryptoOptions(crypto_options); @@ -2228,18 +2189,6 @@ TEST_F(VoiceChannelSingleThreadTest, SendRtpToRtp) { Base::SendRtpToRtp(); } -TEST_F(VoiceChannelSingleThreadTest, SendNoRtcpToNoRtcp) { - Base::SendNoRtcpToNoRtcp(); -} - -TEST_F(VoiceChannelSingleThreadTest, SendNoRtcpToRtcp) { - Base::SendNoRtcpToRtcp(); -} - -TEST_F(VoiceChannelSingleThreadTest, SendRtcpToNoRtcp) { - Base::SendRtcpToNoRtcp(); -} - TEST_F(VoiceChannelSingleThreadTest, SendRtcpToRtcp) { Base::SendRtcpToRtcp(); } @@ -2396,7 +2345,7 @@ TEST_F(VoiceChannelSingleThreadTest, TestOnReadyToSendWithRtcpMux) { // Test that we can scale the output volume properly for 1:1 calls. TEST_F(VoiceChannelSingleThreadTest, TestScaleVolume1to1Call) { - CreateChannels(RTCP, RTCP); + CreateChannels(0, 0); EXPECT_TRUE(SendInitiate()); EXPECT_TRUE(SendAccept()); double volume; @@ -2420,7 +2369,7 @@ TEST_F(VoiceChannelSingleThreadTest, TestScaleVolume1to1Call) { // Test that we can scale the output volume properly for multiway calls. TEST_F(VoiceChannelSingleThreadTest, TestScaleVolumeMultiwayCall) { - CreateChannels(RTCP, RTCP); + CreateChannels(0, 0); EXPECT_TRUE(SendInitiate()); EXPECT_TRUE(SendAccept()); EXPECT_TRUE(AddStream1(1)); @@ -2573,18 +2522,6 @@ TEST_F(VoiceChannelDoubleThreadTest, SendRtpToRtp) { Base::SendRtpToRtp(); } -TEST_F(VoiceChannelDoubleThreadTest, SendNoRtcpToNoRtcp) { - Base::SendNoRtcpToNoRtcp(); -} - -TEST_F(VoiceChannelDoubleThreadTest, SendNoRtcpToRtcp) { - Base::SendNoRtcpToRtcp(); -} - -TEST_F(VoiceChannelDoubleThreadTest, SendRtcpToNoRtcp) { - Base::SendRtcpToNoRtcp(); -} - TEST_F(VoiceChannelDoubleThreadTest, SendRtcpToRtcp) { Base::SendRtcpToRtcp(); } @@ -2741,7 +2678,7 @@ TEST_F(VoiceChannelDoubleThreadTest, TestOnReadyToSendWithRtcpMux) { // Test that we can scale the output volume properly for 1:1 calls. TEST_F(VoiceChannelDoubleThreadTest, TestScaleVolume1to1Call) { - CreateChannels(RTCP, RTCP); + CreateChannels(0, 0); EXPECT_TRUE(SendInitiate()); EXPECT_TRUE(SendAccept()); double volume; @@ -2765,7 +2702,7 @@ TEST_F(VoiceChannelDoubleThreadTest, TestScaleVolume1to1Call) { // Test that we can scale the output volume properly for multiway calls. TEST_F(VoiceChannelDoubleThreadTest, TestScaleVolumeMultiwayCall) { - CreateChannels(RTCP, RTCP); + CreateChannels(0, 0); EXPECT_TRUE(SendInitiate()); EXPECT_TRUE(SendAccept()); EXPECT_TRUE(AddStream1(1)); @@ -2914,18 +2851,6 @@ TEST_F(VideoChannelSingleThreadTest, SendRtpToRtp) { Base::SendRtpToRtp(); } -TEST_F(VideoChannelSingleThreadTest, SendNoRtcpToNoRtcp) { - Base::SendNoRtcpToNoRtcp(); -} - -TEST_F(VideoChannelSingleThreadTest, SendNoRtcpToRtcp) { - Base::SendNoRtcpToRtcp(); -} - -TEST_F(VideoChannelSingleThreadTest, SendRtcpToNoRtcp) { - Base::SendRtcpToNoRtcp(); -} - TEST_F(VideoChannelSingleThreadTest, SendRtcpToRtcp) { Base::SendRtcpToRtcp(); } @@ -3158,18 +3083,6 @@ TEST_F(VideoChannelDoubleThreadTest, SendRtpToRtp) { Base::SendRtpToRtp(); } -TEST_F(VideoChannelDoubleThreadTest, SendNoRtcpToNoRtcp) { - Base::SendNoRtcpToNoRtcp(); -} - -TEST_F(VideoChannelDoubleThreadTest, SendNoRtcpToRtcp) { - Base::SendNoRtcpToRtcp(); -} - -TEST_F(VideoChannelDoubleThreadTest, SendRtcpToNoRtcp) { - Base::SendRtcpToNoRtcp(); -} - TEST_F(VideoChannelDoubleThreadTest, SendRtcpToRtcp) { Base::SendRtcpToRtcp(); } @@ -3342,7 +3255,7 @@ cricket::RtpDataChannel* ChannelTest::CreateChannel( transport_controller ? transport_controller->signaling_thread() : nullptr; cricket::RtpDataChannel* channel = new cricket::RtpDataChannel( worker_thread, network_thread, signaling_thread, ch, cricket::CN_DATA, - (flags & RTCP) != 0, (flags & SECURE) != 0); + (flags & RTCP_MUX_REQUIRED) != 0, (flags & SECURE) != 0); rtc::CryptoOptions crypto_options; crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; channel->SetCryptoOptions(crypto_options); @@ -3466,18 +3379,6 @@ TEST_F(RtpDataChannelSingleThreadTest, SendRtpToRtp) { Base::SendRtpToRtp(); } -TEST_F(RtpDataChannelSingleThreadTest, SendNoRtcpToNoRtcp) { - Base::SendNoRtcpToNoRtcp(); -} - -TEST_F(RtpDataChannelSingleThreadTest, SendNoRtcpToRtcp) { - Base::SendNoRtcpToRtcp(); -} - -TEST_F(RtpDataChannelSingleThreadTest, SendRtcpToNoRtcp) { - Base::SendRtcpToNoRtcp(); -} - TEST_F(RtpDataChannelSingleThreadTest, SendRtcpToRtcp) { Base::SendRtcpToRtcp(); } @@ -3610,18 +3511,6 @@ TEST_F(RtpDataChannelDoubleThreadTest, SendRtpToRtp) { Base::SendRtpToRtp(); } -TEST_F(RtpDataChannelDoubleThreadTest, SendNoRtcpToNoRtcp) { - Base::SendNoRtcpToNoRtcp(); -} - -TEST_F(RtpDataChannelDoubleThreadTest, SendNoRtcpToRtcp) { - Base::SendNoRtcpToRtcp(); -} - -TEST_F(RtpDataChannelDoubleThreadTest, SendRtcpToNoRtcp) { - Base::SendRtcpToNoRtcp(); -} - TEST_F(RtpDataChannelDoubleThreadTest, SendRtcpToRtcp) { Base::SendRtcpToRtcp(); } diff --git a/webrtc/pc/channelmanager.cc b/webrtc/pc/channelmanager.cc index f8ed7702d7..02a53f8877 100644 --- a/webrtc/pc/channelmanager.cc +++ b/webrtc/pc/channelmanager.cc @@ -212,14 +212,14 @@ VoiceChannel* ChannelManager::CreateVoiceChannel( rtc::Thread* signaling_thread, const std::string& content_name, const std::string* bundle_transport_name, - bool rtcp, + bool rtcp_mux_required, bool srtp_required, const AudioOptions& options) { return worker_thread_->Invoke( RTC_FROM_HERE, Bind(&ChannelManager::CreateVoiceChannel_w, this, media_controller, rtp_transport, rtcp_transport, signaling_thread, content_name, - bundle_transport_name, rtcp, srtp_required, options)); + bundle_transport_name, rtcp_mux_required, srtp_required, options)); } VoiceChannel* ChannelManager::CreateVoiceChannel_w( @@ -229,7 +229,7 @@ VoiceChannel* ChannelManager::CreateVoiceChannel_w( rtc::Thread* signaling_thread, const std::string& content_name, const std::string* bundle_transport_name, - bool rtcp, + bool rtcp_mux_required, bool srtp_required, const AudioOptions& options) { RTC_DCHECK(initialized_); @@ -243,7 +243,7 @@ VoiceChannel* ChannelManager::CreateVoiceChannel_w( VoiceChannel* voice_channel = new VoiceChannel( worker_thread_, network_thread_, signaling_thread, media_engine_.get(), - media_channel, content_name, rtcp, srtp_required); + media_channel, content_name, rtcp_mux_required, srtp_required); voice_channel->SetCryptoOptions(crypto_options_); if (!voice_channel->Init_w(rtp_transport, rtcp_transport)) { @@ -284,14 +284,14 @@ VideoChannel* ChannelManager::CreateVideoChannel( rtc::Thread* signaling_thread, const std::string& content_name, const std::string* bundle_transport_name, - bool rtcp, + bool rtcp_mux_required, bool srtp_required, const VideoOptions& options) { return worker_thread_->Invoke( RTC_FROM_HERE, Bind(&ChannelManager::CreateVideoChannel_w, this, media_controller, rtp_transport, rtcp_transport, signaling_thread, content_name, - bundle_transport_name, rtcp, srtp_required, options)); + bundle_transport_name, rtcp_mux_required, srtp_required, options)); } VideoChannel* ChannelManager::CreateVideoChannel_w( @@ -301,7 +301,7 @@ VideoChannel* ChannelManager::CreateVideoChannel_w( rtc::Thread* signaling_thread, const std::string& content_name, const std::string* bundle_transport_name, - bool rtcp, + bool rtcp_mux_required, bool srtp_required, const VideoOptions& options) { RTC_DCHECK(initialized_); @@ -313,9 +313,9 @@ VideoChannel* ChannelManager::CreateVideoChannel_w( return NULL; } - VideoChannel* video_channel = - new VideoChannel(worker_thread_, network_thread_, signaling_thread, - media_channel, content_name, rtcp, srtp_required); + VideoChannel* video_channel = new VideoChannel( + worker_thread_, network_thread_, signaling_thread, media_channel, + content_name, rtcp_mux_required, srtp_required); video_channel->SetCryptoOptions(crypto_options_); if (!video_channel->Init_w(rtp_transport, rtcp_transport)) { delete video_channel; @@ -356,13 +356,13 @@ RtpDataChannel* ChannelManager::CreateRtpDataChannel( rtc::Thread* signaling_thread, const std::string& content_name, const std::string* bundle_transport_name, - bool rtcp, + bool rtcp_mux_required, bool srtp_required) { return worker_thread_->Invoke( RTC_FROM_HERE, Bind(&ChannelManager::CreateRtpDataChannel_w, this, media_controller, rtp_transport, rtcp_transport, signaling_thread, content_name, - bundle_transport_name, rtcp, srtp_required)); + bundle_transport_name, rtcp_mux_required, srtp_required)); } RtpDataChannel* ChannelManager::CreateRtpDataChannel_w( @@ -372,7 +372,7 @@ RtpDataChannel* ChannelManager::CreateRtpDataChannel_w( rtc::Thread* signaling_thread, const std::string& content_name, const std::string* bundle_transport_name, - bool rtcp, + bool rtcp_mux_required, bool srtp_required) { // This is ok to alloc from a thread other than the worker thread. RTC_DCHECK(initialized_); @@ -386,9 +386,9 @@ RtpDataChannel* ChannelManager::CreateRtpDataChannel_w( return nullptr; } - RtpDataChannel* data_channel = - new RtpDataChannel(worker_thread_, network_thread_, signaling_thread, - media_channel, content_name, rtcp, srtp_required); + RtpDataChannel* data_channel = new RtpDataChannel( + worker_thread_, network_thread_, signaling_thread, media_channel, + content_name, rtcp_mux_required, srtp_required); data_channel->SetCryptoOptions(crypto_options_); if (!data_channel->Init_w(rtp_transport, rtcp_transport)) { LOG(LS_WARNING) << "Failed to init data channel."; diff --git a/webrtc/pc/channelmanager.h b/webrtc/pc/channelmanager.h index 89af44afee..2ee7227080 100644 --- a/webrtc/pc/channelmanager.h +++ b/webrtc/pc/channelmanager.h @@ -95,7 +95,7 @@ class ChannelManager { rtc::Thread* signaling_thread, const std::string& content_name, const std::string* bundle_transport_name, - bool rtcp, + bool rtcp_mux_required, bool srtp_required, const AudioOptions& options); // Destroys a voice channel created with the Create API. @@ -109,7 +109,7 @@ class ChannelManager { rtc::Thread* signaling_thread, const std::string& content_name, const std::string* bundle_transport_name, - bool rtcp, + bool rtcp_mux_required, bool srtp_required, const VideoOptions& options); // Destroys a video channel created with the Create API. @@ -121,7 +121,7 @@ class ChannelManager { rtc::Thread* signaling_thread, const std::string& content_name, const std::string* bundle_transport_name, - bool rtcp, + bool rtcp_mux_required, bool srtp_required); // Destroys a data channel created with the Create API. void DestroyRtpDataChannel(RtpDataChannel* data_channel); @@ -172,7 +172,7 @@ class ChannelManager { rtc::Thread* signaling_thread, const std::string& content_name, const std::string* bundle_transport_name, - bool rtcp, + bool rtcp_mux_required, bool srtp_required, const AudioOptions& options); void DestroyVoiceChannel_w(VoiceChannel* voice_channel); @@ -183,7 +183,7 @@ class ChannelManager { rtc::Thread* signaling_thread, const std::string& content_name, const std::string* bundle_transport_name, - bool rtcp, + bool rtcp_mux_required, bool srtp_required, const VideoOptions& options); void DestroyVideoChannel_w(VideoChannel* video_channel); @@ -194,7 +194,7 @@ class ChannelManager { rtc::Thread* signaling_thread, const std::string& content_name, const std::string* bundle_transport_name, - bool rtcp, + bool rtcp_mux_required, bool srtp_required); void DestroyRtpDataChannel_w(RtpDataChannel* data_channel); diff --git a/webrtc/pc/channelmanager_unittest.cc b/webrtc/pc/channelmanager_unittest.cc index 34d9108cff..84a8375a6f 100644 --- a/webrtc/pc/channelmanager_unittest.cc +++ b/webrtc/pc/channelmanager_unittest.cc @@ -21,7 +21,7 @@ #include "webrtc/pc/channelmanager.h" namespace cricket { -const bool kDefaultRtcpEnabled = false; +const bool kDefaultRtcpMuxRequired = true; const bool kDefaultSrtpRequired = true; } @@ -107,18 +107,18 @@ TEST_F(ChannelManagerTest, CreateDestroyChannels) { cricket::CN_AUDIO, cricket::ICE_CANDIDATE_COMPONENT_RTP); cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel( &fake_mc_, rtp_transport, nullptr /*rtcp_transport*/, - rtc::Thread::Current(), cricket::CN_AUDIO, nullptr, kDefaultRtcpEnabled, - kDefaultSrtpRequired, AudioOptions()); + rtc::Thread::Current(), cricket::CN_AUDIO, nullptr, + kDefaultRtcpMuxRequired, kDefaultSrtpRequired, AudioOptions()); EXPECT_TRUE(voice_channel != nullptr); cricket::VideoChannel* video_channel = cm_->CreateVideoChannel( &fake_mc_, rtp_transport, nullptr /*rtcp_transport*/, - rtc::Thread::Current(), cricket::CN_VIDEO, nullptr, kDefaultRtcpEnabled, - kDefaultSrtpRequired, VideoOptions()); + rtc::Thread::Current(), cricket::CN_VIDEO, nullptr, + kDefaultRtcpMuxRequired, kDefaultSrtpRequired, VideoOptions()); EXPECT_TRUE(video_channel != nullptr); cricket::RtpDataChannel* rtp_data_channel = cm_->CreateRtpDataChannel( &fake_mc_, rtp_transport, nullptr /*rtcp_transport*/, - rtc::Thread::Current(), cricket::CN_DATA, nullptr, kDefaultRtcpEnabled, - kDefaultSrtpRequired); + rtc::Thread::Current(), cricket::CN_DATA, nullptr, + kDefaultRtcpMuxRequired, kDefaultSrtpRequired); EXPECT_TRUE(rtp_data_channel != nullptr); cm_->DestroyVideoChannel(video_channel); cm_->DestroyVoiceChannel(voice_channel); @@ -141,18 +141,18 @@ TEST_F(ChannelManagerTest, CreateDestroyChannelsOnThread) { cricket::CN_AUDIO, cricket::ICE_CANDIDATE_COMPONENT_RTP); cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel( &fake_mc_, rtp_transport, nullptr /*rtcp_transport*/, - rtc::Thread::Current(), cricket::CN_AUDIO, nullptr, kDefaultRtcpEnabled, - kDefaultSrtpRequired, AudioOptions()); + rtc::Thread::Current(), cricket::CN_AUDIO, nullptr, + kDefaultRtcpMuxRequired, kDefaultSrtpRequired, AudioOptions()); EXPECT_TRUE(voice_channel != nullptr); cricket::VideoChannel* video_channel = cm_->CreateVideoChannel( &fake_mc_, rtp_transport, nullptr /*rtcp_transport*/, - rtc::Thread::Current(), cricket::CN_VIDEO, nullptr, kDefaultRtcpEnabled, - kDefaultSrtpRequired, VideoOptions()); + rtc::Thread::Current(), cricket::CN_VIDEO, nullptr, + kDefaultRtcpMuxRequired, kDefaultSrtpRequired, VideoOptions()); EXPECT_TRUE(video_channel != nullptr); cricket::RtpDataChannel* rtp_data_channel = cm_->CreateRtpDataChannel( &fake_mc_, rtp_transport, nullptr /*rtcp_transport*/, - rtc::Thread::Current(), cricket::CN_DATA, nullptr, kDefaultRtcpEnabled, - kDefaultSrtpRequired); + rtc::Thread::Current(), cricket::CN_DATA, nullptr, + kDefaultRtcpMuxRequired, kDefaultSrtpRequired); EXPECT_TRUE(rtp_data_channel != nullptr); cm_->DestroyVideoChannel(video_channel); cm_->DestroyVoiceChannel(voice_channel);