Add utility method for consistency checking in BaseChannel classes.

This is a simple check for upcoming changes for media channels to
be able to check if the state on the network thread is consistent.

Bug: webrtc:11992
Change-Id: I8ed2d091ecf3869a66970fc4733aebf209c4ef82
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/246681
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35706}
This commit is contained in:
Tomas Gunnarsson
2022-01-16 20:44:25 +01:00
committed by WebRTC LUCI CQ
parent a49942af17
commit cc9b7ec740
4 changed files with 16 additions and 0 deletions

View File

@ -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<FrameTransformerInterface> frame_transformer) {}

View File

@ -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,

View File

@ -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);
}

View File

@ -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_; }