Delete MediaBaseChannel class

There are no common functions between MediaSendChannelInterface
and MediaReceiveChannelInterface except media_type().
This allows us to remove the common superclass for the two interfaces,
making for a simpler class structure.

Bug: webrtc:13931
Change-Id: I82a12ca31f0dc62d7bd97bdda34ca37e59a5fd55
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/306660
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40154}
This commit is contained in:
Harald Alvestrand 2023-05-26 08:26:13 +00:00 committed by WebRTC LUCI CQ
parent 4f1dcbb1ac
commit 5f32fa47a7
4 changed files with 41 additions and 91 deletions

View File

@ -183,58 +183,14 @@ class MediaChannelNetworkInterface {
virtual ~MediaChannelNetworkInterface() {}
};
// Functions shared across all MediaChannel interfaces.
// Because there are implementation types that implement multiple
// interfaces, this is not a base class (no diamond inheritance).
template <class T>
class MediaBaseChannelInterface {
public:
virtual ~MediaBaseChannelInterface() = default;
virtual cricket::MediaType media_type() const = 0;
// Networking functions. We assume that both the send channel and the
// receive channel send RTP packets (RTCP packets in the case of a receive
// channel).
// Called on the network when an RTP packet is received.
virtual void OnPacketReceived(const webrtc::RtpPacketReceived& packet) = 0;
// Called on the network thread after a transport has finished sending a
// packet.
virtual void OnPacketSent(const rtc::SentPacket& sent_packet) = 0;
// Called when the socket's ability to send has changed.
virtual void OnReadyToSend(bool ready) = 0;
// Called when the network route used for sending packets changed.
virtual void OnNetworkRouteChanged(
absl::string_view transport_name,
const rtc::NetworkRoute& network_route) = 0;
// Corresponds to the SDP attribute extmap-allow-mixed, see RFC8285.
// Set to true if it's allowed to mix one- and two-byte RTP header extensions
// in the same stream. The setter and getter must only be called from
// worker_thread.
virtual void SetExtmapAllowMixed(bool extmap_allow_mixed) = 0;
virtual bool ExtmapAllowMixed() const = 0;
// Sets the abstract interface class for sending RTP/RTCP data.
virtual void SetInterface(MediaChannelNetworkInterface* iface) = 0;
// Returns `true` if a non-null MediaChannelNetworkInterface pointer is held.
// Must be called on the network thread.
virtual bool HasNetworkInterface() const = 0;
// Get the underlying send/receive implementation channel for testing.
// TODO(bugs.webrtc.org/13931): Remove method and the fakes that depend on it.
virtual MediaChannel* ImplForTesting() = 0;
};
class MediaSendChannelInterface
: public MediaBaseChannelInterface<MediaSendChannelInterface> {
class MediaSendChannelInterface {
public:
virtual ~MediaSendChannelInterface() = default;
virtual VideoMediaSendChannelInterface* AsVideoSendChannel() = 0;
virtual VoiceMediaSendChannelInterface* AsVoiceSendChannel() = 0;
virtual cricket::MediaType media_type() const = 0;
// Creates a new outgoing media stream with SSRCs and CNAME as described
// by sp.
@ -244,6 +200,29 @@ class MediaSendChannelInterface
// multiple SSRCs. In the case of an ssrc of 0, the possibly cached
// StreamParams is removed.
virtual bool RemoveSendStream(uint32_t ssrc) = 0;
// Called on the network thread after a transport has finished sending a
// packet.
virtual void OnPacketSent(const rtc::SentPacket& sent_packet) = 0;
// Called when the socket's ability to send has changed.
virtual void OnReadyToSend(bool ready) = 0;
// Called when the network route used for sending packets changed.
virtual void OnNetworkRouteChanged(
absl::string_view transport_name,
const rtc::NetworkRoute& network_route) = 0;
// Sets the abstract interface class for sending RTP/RTCP data.
virtual void SetInterface(MediaChannelNetworkInterface* iface) = 0;
// Returns `true` if a non-null MediaChannelNetworkInterface pointer is held.
// Must be called on the network thread.
virtual bool HasNetworkInterface() const = 0;
// Corresponds to the SDP attribute extmap-allow-mixed, see RFC8285.
// Set to true if it's allowed to mix one- and two-byte RTP header extensions
// in the same stream. The setter and getter must only be called from
// worker_thread.
virtual void SetExtmapAllowMixed(bool extmap_allow_mixed) = 0;
virtual bool ExtmapAllowMixed() const = 0;
// Set the frame encryptor to use on all outgoing frames. This is optional.
// This pointers lifetime is managed by the set of RtpSender it is attached
// to.
@ -271,17 +250,19 @@ class MediaSendChannelInterface
// Called whenever the list of sending SSRCs changes.
virtual void SetSsrcListChangedCallback(
absl::AnyInvocable<void(const std::set<uint32_t>&)> callback) = 0;
// Get the underlying send/receive implementation channel for testing.
// TODO(bugs.webrtc.org/13931): Remove method and the fakes that depend on it.
virtual MediaChannel* ImplForTesting() = 0;
};
class MediaReceiveChannelInterface
: public MediaBaseChannelInterface<MediaReceiveChannelInterface>,
public Delayable {
class MediaReceiveChannelInterface : public Delayable {
public:
virtual ~MediaReceiveChannelInterface() = default;
virtual VideoMediaReceiveChannelInterface* AsVideoReceiveChannel() = 0;
virtual VoiceMediaReceiveChannelInterface* AsVoiceReceiveChannel() = 0;
virtual cricket::MediaType media_type() const = 0;
// Creates a new incoming media stream with SSRCs, CNAME as described
// by sp. In the case of a sp without SSRCs, the unsignaled sp is cached
// to be used later for unsignaled streams received.
@ -293,6 +274,10 @@ class MediaReceiveChannelInterface
// Resets any cached StreamParams for an unsignaled RecvStream, and removes
// any existing unsignaled streams.
virtual void ResetUnsignaledRecvStream() = 0;
// Sets the abstract interface class for sending RTP/RTCP data.
virtual void SetInterface(MediaChannelNetworkInterface* iface) = 0;
// Called on the network when an RTP packet is received.
virtual void OnPacketReceived(const webrtc::RtpPacketReceived& packet) = 0;
// Gets the current unsignaled receive stream's SSRC, if there is one.
virtual absl::optional<uint32_t> GetUnsignaledSsrc() const = 0;
// Sets the local SSRC for listening to incoming RTCP reports.
@ -322,6 +307,9 @@ class MediaReceiveChannelInterface
uint32_t ssrc,
rtc::scoped_refptr<webrtc::FrameTransformerInterface>
frame_transformer) = 0;
// Get the underlying send/receive implementation channel for testing.
// TODO(bugs.webrtc.org/13931): Remove method and the fakes that depend on it.
virtual MediaChannel* ImplForTesting() = 0;
};
// The stats information is structured as follows:

View File

@ -369,9 +369,6 @@ class VoiceMediaSendChannel : public VoiceMediaSendChannelInterface {
// Implementation of MediaBaseChannelInterface
cricket::MediaType media_type() const override { return MEDIA_TYPE_AUDIO; }
void OnPacketReceived(const webrtc::RtpPacketReceived& packet) override {
impl()->OnPacketReceived(packet);
}
void OnPacketSent(const rtc::SentPacket& sent_packet) override {
impl()->OnPacketSent(sent_packet);
}
@ -475,24 +472,9 @@ class VoiceMediaReceiveChannel : public VoiceMediaReceiveChannelInterface {
void OnPacketReceived(const webrtc::RtpPacketReceived& packet) override {
impl()->OnPacketReceived(packet);
}
void OnPacketSent(const rtc::SentPacket& sent_packet) override {
impl()->OnPacketSent(sent_packet);
}
void OnReadyToSend(bool ready) override { impl()->OnReadyToSend(ready); }
void OnNetworkRouteChanged(absl::string_view transport_name,
const rtc::NetworkRoute& network_route) override {
impl()->OnNetworkRouteChanged(transport_name, network_route);
}
void SetExtmapAllowMixed(bool extmap_allow_mixed) override {
impl()->SetExtmapAllowMixed(extmap_allow_mixed);
}
bool ExtmapAllowMixed() const override { return impl()->ExtmapAllowMixed(); }
void SetInterface(MediaChannelNetworkInterface* iface) override {
return impl()->SetInterface(iface);
}
bool HasNetworkInterface() const override {
return impl()->HasNetworkInterface();
}
// Implementation of Delayable
bool SetBaseMinimumPlayoutDelayMs(uint32_t ssrc, int delay_ms) override {
return impl()->SetBaseMinimumPlayoutDelayMs(ssrc, delay_ms);
@ -592,9 +574,6 @@ class VideoMediaSendChannel : public VideoMediaSendChannelInterface {
// Implementation of MediaBaseChannelInterface
cricket::MediaType media_type() const override { return MEDIA_TYPE_VIDEO; }
void OnPacketReceived(const webrtc::RtpPacketReceived& packet) override {
impl()->OnPacketReceived(packet);
}
void OnPacketSent(const rtc::SentPacket& sent_packet) override {
impl()->OnPacketSent(sent_packet);
}
@ -713,24 +692,6 @@ class VideoMediaReceiveChannel : public VideoMediaReceiveChannelInterface {
void OnPacketReceived(const webrtc::RtpPacketReceived& packet) override {
impl()->OnPacketReceived(packet);
}
void OnPacketSent(const rtc::SentPacket& sent_packet) override {
impl()->OnPacketSent(sent_packet);
}
void OnReadyToSend(bool ready) override { impl()->OnReadyToSend(ready); }
void OnNetworkRouteChanged(absl::string_view transport_name,
const rtc::NetworkRoute& network_route) override {
impl()->OnNetworkRouteChanged(transport_name, network_route);
}
void SetExtmapAllowMixed(bool extmap_allow_mixed) override {
impl()->SetExtmapAllowMixed(extmap_allow_mixed);
}
bool ExtmapAllowMixed() const override { return impl()->ExtmapAllowMixed(); }
void SetInterface(MediaChannelNetworkInterface* iface) override {
return impl()->SetInterface(iface);
}
bool HasNetworkInterface() const override {
return impl()->HasNetworkInterface();
}
// Implementation of Delayable
bool SetBaseMinimumPlayoutDelayMs(uint32_t ssrc, int delay_ms) override {
return impl()->SetBaseMinimumPlayoutDelayMs(ssrc, delay_ms);
@ -740,6 +701,9 @@ class VideoMediaReceiveChannel : public VideoMediaReceiveChannelInterface {
return impl()->GetBaseMinimumPlayoutDelayMs(ssrc);
}
// Implementation of MediaReceiveChannelInterface
void SetInterface(MediaChannelNetworkInterface* iface) override {
return impl()->SetInterface(iface);
}
bool AddRecvStream(const StreamParams& sp) override {
return impl()->AddRecvStream(sp);
}

View File

@ -937,7 +937,7 @@ TEST_F(WebRtcVideoEngineTest, SendsFeedbackAfterUnsignaledRtxPacket) {
RtpExtension::kTransportSequenceNumberUri, kTransportSeqExtensionId));
ASSERT_TRUE(channel->SetRecvParameters(parameters));
channel->SetInterface(&network);
channel->AsVideoReceiveChannel()->OnReadyToSend(true);
channel->AsVideoSendChannel()->OnReadyToSend(true);
channel->AsVideoReceiveChannel()->SetReceive(true);
// Inject a RTX packet.

View File

@ -245,7 +245,6 @@ bool BaseChannel::SetRtpTransport(webrtc::RtpTransportInternal* rtp_transport) {
}
RTC_DCHECK(!media_send_channel()->HasNetworkInterface());
RTC_DCHECK(!media_receive_channel()->HasNetworkInterface());
media_send_channel()->SetInterface(this);
media_receive_channel()->SetInterface(this);
@ -379,7 +378,6 @@ void BaseChannel::OnNetworkRouteChanged(
// work correctly. Intentionally leave it broken to simplify the code and
// encourage the users to stop using non-muxing RTCP.
media_send_channel()->OnNetworkRouteChanged(transport_name(), new_route);
media_receive_channel()->OnNetworkRouteChanged(transport_name(), new_route);
}
void BaseChannel::SetFirstPacketReceivedCallback(