diff --git a/media/base/media_channel.cc b/media/base/media_channel.cc index 5d59dba5b5..1b11fcc4e8 100644 --- a/media/base/media_channel.cc +++ b/media/base/media_channel.cc @@ -89,6 +89,11 @@ bool MediaChannel::ExtmapAllowMixed() const { return extmap_allow_mixed_; } +bool MediaChannel::HasNetworkInterface() const { + RTC_DCHECK_RUN_ON(network_thread_); + return network_interface_ != nullptr; +} + void MediaChannel::SetEncoderToPacketizerFrameTransformer( uint32_t ssrc, rtc::scoped_refptr frame_transformer) {} diff --git a/media/base/media_channel.h b/media/base/media_channel.h index 8f20616ebb..2b0ef81277 100644 --- a/media/base/media_channel.h +++ b/media/base/media_channel.h @@ -260,6 +260,10 @@ class MediaChannel { void SetExtmapAllowMixed(bool extmap_allow_mixed); bool ExtmapAllowMixed() const; + // Returns `true` if a non-null NetworkInterface pointer is held. + // Must be called on the network thread. + bool HasNetworkInterface() const; + virtual webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const = 0; virtual webrtc::RTCError SetRtpSendParameters( uint32_t ssrc, diff --git a/pc/channel.cc b/pc/channel.cc index e969d4c399..95e702667d 100644 --- a/pc/channel.cc +++ b/pc/channel.cc @@ -192,6 +192,7 @@ void BaseChannel::Init_w(webrtc::RtpTransportInternal* rtp_transport) { SetRtpTransport(rtp_transport); // Both RTP and RTCP channels should be set, we can call SetInterface on // the media channel and it can set network options. + RTC_DCHECK(!media_channel_->HasNetworkInterface()); media_channel_->SetInterface(this); }); } @@ -208,6 +209,7 @@ void BaseChannel::Deinit() { if (rtp_transport_) { DisconnectFromRtpTransport_n(); } + RTC_DCHECK(!network_initialized()); }); } @@ -797,6 +799,7 @@ bool BaseChannel::ClearHandledPayloadTypes() { void BaseChannel::SignalSentPacket_n(const rtc::SentPacket& sent_packet) { RTC_DCHECK_RUN_ON(network_thread()); + RTC_DCHECK(network_initialized()); media_channel()->OnPacketSent(sent_packet); } diff --git a/pc/channel.h b/pc/channel.h index 109e3491eb..6c2fa1d6e3 100644 --- a/pc/channel.h +++ b/pc/channel.h @@ -217,6 +217,10 @@ class BaseChannel : public ChannelInterface, return extensions_filter_; } + bool network_initialized() RTC_RUN_ON(network_thread()) { + return media_channel_->HasNetworkInterface(); + } + bool enabled() const RTC_RUN_ON(worker_thread()) { return enabled_; } rtc::Thread* signaling_thread() const { return signaling_thread_; }