diff --git a/pc/channel.cc b/pc/channel.cc index 187c83236e..ad2979cb63 100644 --- a/pc/channel.cc +++ b/pc/channel.cc @@ -196,8 +196,12 @@ void BaseChannel::Init_w(DtlsTransportInternal* rtp_dtls_transport, rtc::PacketTransportInternal* rtcp_packet_transport) { RTC_DCHECK_RUN_ON(worker_thread_); network_thread_->Invoke(RTC_FROM_HERE, [&] { - return InitNetwork_n(rtp_dtls_transport, rtcp_dtls_transport, - rtp_packet_transport, rtcp_packet_transport); + SetTransports_n(rtp_dtls_transport, rtcp_dtls_transport, + rtp_packet_transport, rtcp_packet_transport); + + if (rtcp_mux_required_) { + rtcp_mux_filter_.SetActive(); + } }); // Both RTP and RTCP channels should be set, we can call SetInterface on @@ -205,18 +209,19 @@ void BaseChannel::Init_w(DtlsTransportInternal* rtp_dtls_transport, media_channel_->SetInterface(this); } -void BaseChannel::InitNetwork_n( - DtlsTransportInternal* rtp_dtls_transport, - DtlsTransportInternal* rtcp_dtls_transport, - rtc::PacketTransportInternal* rtp_packet_transport, - rtc::PacketTransportInternal* rtcp_packet_transport) { - RTC_DCHECK(network_thread_->IsCurrent()); - SetTransports_n(rtp_dtls_transport, rtcp_dtls_transport, rtp_packet_transport, - rtcp_packet_transport); +void BaseChannel::Init_w(webrtc::RtpTransportInternal* rtp_transport) { + RTC_DCHECK_RUN_ON(worker_thread_); + network_thread_->Invoke(RTC_FROM_HERE, [&] { + SetRtpTransport(rtp_transport); - if (rtcp_mux_required_) { - rtcp_mux_filter_.SetActive(); - } + if (rtcp_mux_required_) { + rtcp_mux_filter_.SetActive(); + } + }); + + // Both RTP and RTCP channels should be set, we can call SetInterface on + // the media channel and it can set network options. + media_channel_->SetInterface(this); } void BaseChannel::Deinit() { @@ -240,6 +245,26 @@ void BaseChannel::Deinit() { }); } +void BaseChannel::SetRtpTransport(webrtc::RtpTransportInternal* rtp_transport) { + if (!network_thread_->IsCurrent()) { + network_thread_->Invoke(RTC_FROM_HERE, [&] { + SetRtpTransport(rtp_transport); + return; + }); + } + + RTC_DCHECK(rtp_transport); + + if (rtp_transport_) { + DisconnectFromRtpTransport(); + } + rtp_transport_ = rtp_transport; + RTC_LOG(LS_INFO) << "Setting the RtpTransport for " << content_name(); + ConnectToRtpTransport(); + + UpdateWritableState_n(); +} + void BaseChannel::SetTransports(DtlsTransportInternal* rtp_dtls_transport, DtlsTransportInternal* rtcp_dtls_transport) { network_thread_->Invoke( @@ -780,14 +805,12 @@ void BaseChannel::EnableSdes_n() { // time. RTC_DCHECK(!dtls_srtp_transport_); RTC_DCHECK(unencrypted_rtp_transport_); - DisconnectFromRtpTransport(); sdes_transport_ = rtc::MakeUnique( - std::move(unencrypted_rtp_transport_), content_name_); + std::move(unencrypted_rtp_transport_)); #if defined(ENABLE_EXTERNAL_AUTH) sdes_transport_->EnableExternalAuth(); #endif - rtp_transport_ = sdes_transport_.get(); - ConnectToRtpTransport(); + SetRtpTransport(sdes_transport_.get()); RTC_LOG(LS_INFO) << "Wrapping RtpTransport in SrtpTransport."; } @@ -799,18 +822,16 @@ void BaseChannel::EnableDtlsSrtp_n() { // time. RTC_DCHECK(!sdes_transport_); RTC_DCHECK(unencrypted_rtp_transport_); - DisconnectFromRtpTransport(); auto srtp_transport = rtc::MakeUnique( - std::move(unencrypted_rtp_transport_), content_name_); + std::move(unencrypted_rtp_transport_)); #if defined(ENABLE_EXTERNAL_AUTH) srtp_transport->EnableExternalAuth(); #endif dtls_srtp_transport_ = rtc::MakeUnique(std::move(srtp_transport)); - rtp_transport_ = dtls_srtp_transport_.get(); - ConnectToRtpTransport(); + SetRtpTransport(dtls_srtp_transport_.get()); if (cached_send_extension_ids_) { dtls_srtp_transport_->UpdateSendEncryptedHeaderExtensionIds( *cached_send_extension_ids_); @@ -1853,6 +1874,14 @@ void RtpDataChannel::Init_w( this, &RtpDataChannel::OnDataChannelReadyToSend); } +void RtpDataChannel::Init_w(webrtc::RtpTransportInternal* rtp_transport) { + BaseChannel::Init_w(rtp_transport); + media_channel()->SignalDataReceived.connect(this, + &RtpDataChannel::OnDataReceived); + media_channel()->SignalReadyToSend.connect( + this, &RtpDataChannel::OnDataChannelReadyToSend); +} + bool RtpDataChannel::SendData(const SendDataParams& params, const rtc::CopyOnWriteBuffer& payload, SendDataResult* result) { diff --git a/pc/channel.h b/pc/channel.h index 1c4e50a016..d7db63a612 100644 --- a/pc/channel.h +++ b/pc/channel.h @@ -86,10 +86,14 @@ class BaseChannel bool rtcp_mux_required, bool srtp_required); virtual ~BaseChannel(); + // TODO(zhihuang): Remove this once the RtpTransport can be shared between + // BaseChannels. void Init_w(DtlsTransportInternal* rtp_dtls_transport, DtlsTransportInternal* rtcp_dtls_transport, rtc::PacketTransportInternal* rtp_packet_transport, rtc::PacketTransportInternal* rtcp_packet_transport); + void Init_w(webrtc::RtpTransportInternal* rtp_transport); + // Deinit may be called multiple times and is simply ignored if it's already // done. void Deinit(); @@ -114,6 +118,12 @@ class BaseChannel bool writable() const { return writable_; } + // Set an RTP level transport which could be an RtpTransport without + // encryption, an SrtpTransport for SDES or a DtlsSrtpTransport for DTLS-SRTP. + // This can be called from any thread and it hops to the network thread + // internally. It would replace the |SetTransports| and its variants. + void SetRtpTransport(webrtc::RtpTransportInternal* rtp_transport); + // Set the transport(s), and update writability and "ready-to-send" state. // |rtp_transport| must be non-null. // |rtcp_transport| must be supplied if NeedsRtcpTransport() is true (meaning @@ -122,6 +132,8 @@ class BaseChannel // well. // Can not start with "rtc::PacketTransportInternal" and switch to // "DtlsTransportInternal", or vice-versa. + // TODO(zhihuang): Remove these two once the RtpTransport can be shared + // between BaseChannels. void SetTransports(DtlsTransportInternal* rtp_dtls_transport, DtlsTransportInternal* rtcp_dtls_transport); void SetTransports(rtc::PacketTransportInternal* rtp_packet_transport, @@ -205,6 +217,8 @@ class BaseChannel // This does not update writability or "ready-to-send" state; it just // disconnects from the old channel and connects to the new one. + // TODO(zhihuang): Remove this once the RtpTransport can be shared between + // BaseChannels. void SetTransport_n(bool rtcp, DtlsTransportInternal* new_dtls_transport, rtc::PacketTransportInternal* new_packet_transport); @@ -349,10 +363,6 @@ class BaseChannel private: void ConnectToRtpTransport(); void DisconnectFromRtpTransport(); - void InitNetwork_n(DtlsTransportInternal* rtp_dtls_transport, - DtlsTransportInternal* rtcp_dtls_transport, - rtc::PacketTransportInternal* rtp_packet_transport, - rtc::PacketTransportInternal* rtcp_packet_transport); void SignalSentPacket_n(const rtc::SentPacket& sent_packet); void SignalSentPacket_w(const rtc::SentPacket& sent_packet); bool IsReadyToSendMedia_n() const; @@ -635,10 +645,13 @@ class RtpDataChannel : public BaseChannel { bool rtcp_mux_required, bool srtp_required); ~RtpDataChannel(); + // TODO(zhihuang): Remove this once the RtpTransport can be shared between + // BaseChannels. void Init_w(DtlsTransportInternal* rtp_dtls_transport, DtlsTransportInternal* rtcp_dtls_transport, rtc::PacketTransportInternal* rtp_packet_transport, rtc::PacketTransportInternal* rtcp_packet_transport); + void Init_w(webrtc::RtpTransportInternal* rtp_transport); virtual bool SendData(const SendDataParams& params, const rtc::CopyOnWriteBuffer& payload, diff --git a/pc/channelmanager.cc b/pc/channelmanager.cc index 2d7c79a07d..ead1da9cdd 100644 --- a/pc/channelmanager.cc +++ b/pc/channelmanager.cc @@ -184,6 +184,47 @@ VoiceChannel* ChannelManager::CreateVoiceChannel( }); } +VoiceChannel* ChannelManager::CreateVoiceChannel( + webrtc::Call* call, + const cricket::MediaConfig& media_config, + webrtc::RtpTransportInternal* rtp_transport, + rtc::Thread* signaling_thread, + const std::string& content_name, + bool srtp_required, + const AudioOptions& options) { + if (!worker_thread_->IsCurrent()) { + return worker_thread_->Invoke(RTC_FROM_HERE, [&] { + return CreateVoiceChannel(call, media_config, rtp_transport, + signaling_thread, content_name, srtp_required, + options); + }); + } + + RTC_DCHECK_RUN_ON(worker_thread_); + RTC_DCHECK(initialized_); + RTC_DCHECK(call); + if (!media_engine_) { + return nullptr; + } + + VoiceMediaChannel* media_channel = + media_engine_->CreateChannel(call, media_config, options); + if (!media_channel) { + return nullptr; + } + + auto voice_channel = rtc::MakeUnique( + worker_thread_, network_thread_, signaling_thread, media_engine_.get(), + rtc::WrapUnique(media_channel), content_name, + rtp_transport->rtcp_packet_transport() == nullptr, srtp_required); + + voice_channel->Init_w(rtp_transport); + + VoiceChannel* voice_channel_ptr = voice_channel.get(); + voice_channels_.push_back(std::move(voice_channel)); + return voice_channel_ptr; +} + VoiceChannel* ChannelManager::CreateVoiceChannel_w( webrtc::Call* call, const cricket::MediaConfig& media_config, @@ -277,6 +318,46 @@ VideoChannel* ChannelManager::CreateVideoChannel( }); } +VideoChannel* ChannelManager::CreateVideoChannel( + webrtc::Call* call, + const cricket::MediaConfig& media_config, + webrtc::RtpTransportInternal* rtp_transport, + rtc::Thread* signaling_thread, + const std::string& content_name, + bool srtp_required, + const VideoOptions& options) { + if (!worker_thread_->IsCurrent()) { + return worker_thread_->Invoke(RTC_FROM_HERE, [&] { + return CreateVideoChannel(call, media_config, rtp_transport, + signaling_thread, content_name, srtp_required, + options); + }); + } + + RTC_DCHECK_RUN_ON(worker_thread_); + RTC_DCHECK(initialized_); + RTC_DCHECK(call); + if (!media_engine_) { + return nullptr; + } + + VideoMediaChannel* media_channel = + media_engine_->CreateVideoChannel(call, media_config, options); + if (!media_channel) { + return nullptr; + } + + auto video_channel = rtc::MakeUnique( + worker_thread_, network_thread_, signaling_thread, + rtc::WrapUnique(media_channel), content_name, + rtp_transport->rtcp_packet_transport() == nullptr, srtp_required); + video_channel->Init_w(rtp_transport); + + VideoChannel* video_channel_ptr = video_channel.get(); + video_channels_.push_back(std::move(video_channel)); + return video_channel_ptr; +} + VideoChannel* ChannelManager::CreateVideoChannel_w( webrtc::Call* call, const cricket::MediaConfig& media_config, @@ -291,7 +372,9 @@ VideoChannel* ChannelManager::CreateVideoChannel_w( RTC_DCHECK_RUN_ON(worker_thread_); RTC_DCHECK(initialized_); RTC_DCHECK(call); - RTC_DCHECK(media_engine_); + if (!media_engine_) { + return nullptr; + } VideoMediaChannel* media_channel = media_engine_->CreateVideoChannel( call, media_config, options); @@ -371,6 +454,38 @@ RtpDataChannel* ChannelManager::CreateRtpDataChannel( return data_channel_ptr; } +RtpDataChannel* ChannelManager::CreateRtpDataChannel( + const cricket::MediaConfig& media_config, + webrtc::RtpTransportInternal* rtp_transport, + rtc::Thread* signaling_thread, + const std::string& content_name, + bool srtp_required) { + if (!worker_thread_->IsCurrent()) { + return worker_thread_->Invoke(RTC_FROM_HERE, [&] { + return CreateRtpDataChannel(media_config, rtp_transport, signaling_thread, + content_name, srtp_required); + }); + } + + // This is ok to alloc from a thread other than the worker thread. + RTC_DCHECK(initialized_); + DataMediaChannel* media_channel = data_engine_->CreateChannel(media_config); + if (!media_channel) { + RTC_LOG(LS_WARNING) << "Failed to create RTP data channel."; + return nullptr; + } + + auto data_channel = rtc::MakeUnique( + worker_thread_, network_thread_, signaling_thread, + rtc::WrapUnique(media_channel), content_name, + rtp_transport->rtcp_packet_transport() == nullptr, srtp_required); + data_channel->Init_w(rtp_transport); + + RtpDataChannel* data_channel_ptr = data_channel.get(); + data_channels_.push_back(std::move(data_channel)); + return data_channel_ptr; +} + void ChannelManager::DestroyRtpDataChannel(RtpDataChannel* data_channel) { TRACE_EVENT0("webrtc", "ChannelManager::DestroyRtpDataChannel"); if (!data_channel) { diff --git a/pc/channelmanager.h b/pc/channelmanager.h index 9f55f0e29c..72d218a228 100644 --- a/pc/channelmanager.h +++ b/pc/channelmanager.h @@ -80,6 +80,8 @@ class ChannelManager final { // call the appropriate Destroy*Channel method when done. // Creates a voice channel, to be associated with the specified session. + // TODO(zhihuang): Replace this with the method taking an + // RtpTransportInternal*; VoiceChannel* CreateVoiceChannel( webrtc::Call* call, const cricket::MediaConfig& media_config, @@ -90,6 +92,8 @@ class ChannelManager final { bool srtp_required, const AudioOptions& options); // Version of the above that takes PacketTransportInternal. + // TODO(zhihuang): Replace this with the method taking an + // RtpTransportInternal*; VoiceChannel* CreateVoiceChannel( webrtc::Call* call, const cricket::MediaConfig& media_config, @@ -99,11 +103,21 @@ class ChannelManager final { const std::string& content_name, bool srtp_required, const AudioOptions& options); + + VoiceChannel* CreateVoiceChannel(webrtc::Call* call, + const cricket::MediaConfig& media_config, + webrtc::RtpTransportInternal* rtp_transport, + rtc::Thread* signaling_thread, + const std::string& content_name, + bool srtp_required, + const AudioOptions& options); // Destroys a voice channel created by CreateVoiceChannel. void DestroyVoiceChannel(VoiceChannel* voice_channel); // Creates a video channel, synced with the specified voice channel, and // associated with the specified session. + // TODO(zhihuang): Replace this with the method taking an + // RtpTransportInternal*; VideoChannel* CreateVideoChannel( webrtc::Call* call, const cricket::MediaConfig& media_config, @@ -114,6 +128,8 @@ class ChannelManager final { bool srtp_required, const VideoOptions& options); // Version of the above that takes PacketTransportInternal. + // TODO(zhihuang): Replace this with the method taking an + // RtpTransportInternal*; VideoChannel* CreateVideoChannel( webrtc::Call* call, const cricket::MediaConfig& media_config, @@ -123,9 +139,18 @@ class ChannelManager final { const std::string& content_name, bool srtp_required, const VideoOptions& options); + VideoChannel* CreateVideoChannel(webrtc::Call* call, + const cricket::MediaConfig& media_config, + webrtc::RtpTransportInternal* rtp_transport, + rtc::Thread* signaling_thread, + const std::string& content_name, + bool srtp_required, + const VideoOptions& options); // Destroys a video channel created by CreateVideoChannel. void DestroyVideoChannel(VideoChannel* video_channel); + // TODO(zhihuang): Replace this with the method taking an + // RtpTransportInternal*; RtpDataChannel* CreateRtpDataChannel( const cricket::MediaConfig& media_config, DtlsTransportInternal* rtp_transport, @@ -133,6 +158,12 @@ class ChannelManager final { rtc::Thread* signaling_thread, const std::string& content_name, bool srtp_required); + RtpDataChannel* CreateRtpDataChannel( + const cricket::MediaConfig& media_config, + webrtc::RtpTransportInternal* rtp_transport, + rtc::Thread* signaling_thread, + const std::string& content_name, + bool srtp_required); // Destroys a data channel created by CreateRtpDataChannel. void DestroyRtpDataChannel(RtpDataChannel* data_channel); diff --git a/pc/channelmanager_unittest.cc b/pc/channelmanager_unittest.cc index 4b7636153d..18f84752f7 100644 --- a/pc/channelmanager_unittest.cc +++ b/pc/channelmanager_unittest.cc @@ -9,6 +9,7 @@ */ #include +#include #include "logging/rtc_event_log/rtc_event_log.h" #include "media/base/fakemediaengine.h" @@ -186,4 +187,89 @@ TEST_F(ChannelManagerTest, SetVideoRtxEnabled) { EXPECT_TRUE(ContainsMatchingCodec(codecs, rtx_codec)); } +enum class RTPTransportType { kRtp, kSrtp, kDtlsSrtp }; + +class ChannelManagerTestWithRtpTransport + : public ChannelManagerTest, + public ::testing::WithParamInterface { + public: + std::unique_ptr CreateRtpTransport() { + RTPTransportType type = GetParam(); + switch (type) { + case RTPTransportType::kRtp: + return CreatePlainRtpTransport(); + case RTPTransportType::kSrtp: + return CreateSrtpTransport(); + case RTPTransportType::kDtlsSrtp: + return CreateDtlsSrtpTransport(); + } + return nullptr; + } + + void TestCreateDestroyChannels(webrtc::RtpTransportInternal* rtp_transport) { + cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel( + &fake_call_, cricket::MediaConfig(), rtp_transport, + rtc::Thread::Current(), cricket::CN_AUDIO, kDefaultSrtpRequired, + AudioOptions()); + EXPECT_TRUE(voice_channel != nullptr); + cricket::VideoChannel* video_channel = cm_->CreateVideoChannel( + &fake_call_, cricket::MediaConfig(), rtp_transport, + rtc::Thread::Current(), cricket::CN_VIDEO, kDefaultSrtpRequired, + VideoOptions()); + EXPECT_TRUE(video_channel != nullptr); + cricket::RtpDataChannel* rtp_data_channel = cm_->CreateRtpDataChannel( + cricket::MediaConfig(), rtp_transport, rtc::Thread::Current(), + cricket::CN_DATA, kDefaultSrtpRequired); + EXPECT_TRUE(rtp_data_channel != nullptr); + cm_->DestroyVideoChannel(video_channel); + cm_->DestroyVoiceChannel(voice_channel); + cm_->DestroyRtpDataChannel(rtp_data_channel); + cm_->Terminate(); + } + + private: + std::unique_ptr CreatePlainRtpTransport() { + return rtc::MakeUnique(/*rtcp_mux_required=*/true); + } + + std::unique_ptr CreateSrtpTransport() { + auto rtp_transport = + rtc::MakeUnique(/*rtcp_mux_required=*/true); + auto srtp_transport = + rtc::MakeUnique(std::move(rtp_transport)); + return srtp_transport; + } + + std::unique_ptr CreateDtlsSrtpTransport() { + auto rtp_transport = + rtc::MakeUnique(/*rtcp_mux_required=*/true); + auto srtp_transport = + rtc::MakeUnique(std::move(rtp_transport)); + auto dtls_srtp_transport_ = + rtc::MakeUnique(std::move(srtp_transport)); + return dtls_srtp_transport_; + } +}; + +TEST_P(ChannelManagerTestWithRtpTransport, CreateDestroyChannels) { + EXPECT_TRUE(cm_->Init()); + auto rtp_transport = CreateRtpTransport(); + TestCreateDestroyChannels(rtp_transport.get()); +} + +TEST_P(ChannelManagerTestWithRtpTransport, CreateDestroyChannelsOnThread) { + network_->Start(); + worker_->Start(); + EXPECT_TRUE(cm_->set_worker_thread(worker_.get())); + EXPECT_TRUE(cm_->set_network_thread(network_.get())); + EXPECT_TRUE(cm_->Init()); + auto rtp_transport = CreateRtpTransport(); + TestCreateDestroyChannels(rtp_transport.get()); +} + +INSTANTIATE_TEST_CASE_P(ChannelManagerTest, + ChannelManagerTestWithRtpTransport, + ::testing::Values(RTPTransportType::kRtp, + RTPTransportType::kSrtp, + RTPTransportType::kDtlsSrtp)); } // namespace cricket diff --git a/pc/dtlssrtptransport_unittest.cc b/pc/dtlssrtptransport_unittest.cc index 77c59026ca..08a8151ee7 100644 --- a/pc/dtlssrtptransport_unittest.cc +++ b/pc/dtlssrtptransport_unittest.cc @@ -74,7 +74,7 @@ class DtlsSrtpTransportTest : public testing::Test, rtp_transport->AddHandledPayloadType(0xc9); auto srtp_transport = - rtc::MakeUnique(std::move(rtp_transport), "content"); + rtc::MakeUnique(std::move(rtp_transport)); auto dtls_srtp_transport = rtc::MakeUnique(std::move(srtp_transport)); diff --git a/pc/srtptransport.cc b/pc/srtptransport.cc index 32e5a00618..149651cdda 100644 --- a/pc/srtptransport.cc +++ b/pc/srtptransport.cc @@ -24,10 +24,8 @@ namespace webrtc { -SrtpTransport::SrtpTransport(bool rtcp_mux_enabled, - const std::string& content_name) - : RtpTransportInternalAdapter(new RtpTransport(rtcp_mux_enabled)), - content_name_(content_name) { +SrtpTransport::SrtpTransport(bool rtcp_mux_enabled) + : RtpTransportInternalAdapter(new RtpTransport(rtcp_mux_enabled)) { // Own the raw pointer |transport| from the base class. rtp_transport_.reset(transport_); RTC_DCHECK(rtp_transport_); @@ -35,10 +33,8 @@ SrtpTransport::SrtpTransport(bool rtcp_mux_enabled, } SrtpTransport::SrtpTransport( - std::unique_ptr rtp_transport, - const std::string& content_name) + std::unique_ptr rtp_transport) : RtpTransportInternalAdapter(rtp_transport.get()), - content_name_(content_name), rtp_transport_(std::move(rtp_transport)) { RTC_DCHECK(rtp_transport_); ConnectToRtpTransport(); @@ -120,9 +116,8 @@ bool SrtpTransport::SendPacket(bool rtcp, uint32_t ssrc = 0; cricket::GetRtpSeqNum(data, len, &seq_num); cricket::GetRtpSsrc(data, len, &ssrc); - RTC_LOG(LS_ERROR) << "Failed to protect " << content_name_ - << " RTP packet: size=" << len << ", seqnum=" << seq_num - << ", SSRC=" << ssrc; + RTC_LOG(LS_ERROR) << "Failed to protect RTP packet: size=" << len + << ", seqnum=" << seq_num << ", SSRC=" << ssrc; return false; } } else { @@ -130,8 +125,8 @@ bool SrtpTransport::SendPacket(bool rtcp, if (!res) { int type = -1; cricket::GetRtcpType(data, len, &type); - RTC_LOG(LS_ERROR) << "Failed to protect " << content_name_ - << " RTCP packet: size=" << len << ", type=" << type; + RTC_LOG(LS_ERROR) << "Failed to protect RTCP packet: size=" << len + << ", type=" << type; return false; } } @@ -162,9 +157,8 @@ void SrtpTransport::OnPacketReceived(bool rtcp, uint32_t ssrc = 0; cricket::GetRtpSeqNum(data, len, &seq_num); cricket::GetRtpSsrc(data, len, &ssrc); - RTC_LOG(LS_ERROR) << "Failed to unprotect " << content_name_ - << " RTP packet: size=" << len << ", seqnum=" << seq_num - << ", SSRC=" << ssrc; + RTC_LOG(LS_ERROR) << "Failed to unprotect RTP packet: size=" << len + << ", seqnum=" << seq_num << ", SSRC=" << ssrc; return; } } else { @@ -172,8 +166,8 @@ void SrtpTransport::OnPacketReceived(bool rtcp, if (!res) { int type = -1; cricket::GetRtcpType(data, len, &type); - RTC_LOG(LS_ERROR) << "Failed to unprotect " << content_name_ - << " RTCP packet: size=" << len << ", type=" << type; + RTC_LOG(LS_ERROR) << "Failed to unprotect RTCP packet: size=" << len + << ", type=" << type; return; } } diff --git a/pc/srtptransport.h b/pc/srtptransport.h index d098cd8317..d8b0dbd35a 100644 --- a/pc/srtptransport.h +++ b/pc/srtptransport.h @@ -28,10 +28,9 @@ namespace webrtc { // that protects and unprotects sent and received RTP packets. class SrtpTransport : public RtpTransportInternalAdapter { public: - SrtpTransport(bool rtcp_mux_enabled, const std::string& content_name); + explicit SrtpTransport(bool rtcp_mux_enabled); - SrtpTransport(std::unique_ptr rtp_transport, - const std::string& content_name); + explicit SrtpTransport(std::unique_ptr rtp_transport); bool SendRtpPacket(rtc::CopyOnWriteBuffer* packet, const rtc::PacketOptions& options, diff --git a/pc/srtptransport_unittest.cc b/pc/srtptransport_unittest.cc index d93ea131e2..e0b2302e6f 100644 --- a/pc/srtptransport_unittest.cc +++ b/pc/srtptransport_unittest.cc @@ -64,9 +64,9 @@ class SrtpTransportTest : public testing::Test, public sigslot::has_slots<> { rtp_transport2->AddHandledPayloadType(0xc9); srtp_transport1_ = - rtc::MakeUnique(std::move(rtp_transport1), "content"); + rtc::MakeUnique(std::move(rtp_transport1)); srtp_transport2_ = - rtc::MakeUnique(std::move(rtp_transport2), "content"); + rtc::MakeUnique(std::move(rtp_transport2)); srtp_transport1_->SignalPacketReceived.connect( this, &SrtpTransportTest::OnPacketReceived1);