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}
diff --git a/media/base/media_channel.h b/media/base/media_channel.h
index 578c0a2..dbcb30c 100644
--- a/media/base/media_channel.h
+++ b/media/base/media_channel.h
@@ -183,58 +183,14 @@
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 @@
// 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 @@
// 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 @@
// 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 @@
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:
diff --git a/media/base/media_channel_impl.h b/media/base/media_channel_impl.h
index 57d9a4e..35e0124 100644
--- a/media/base/media_channel_impl.h
+++ b/media/base/media_channel_impl.h
@@ -369,9 +369,6 @@
// 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 @@
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 @@
// 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 @@
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 @@
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);
}
diff --git a/media/engine/webrtc_video_engine_unittest.cc b/media/engine/webrtc_video_engine_unittest.cc
index 7958987..e63199d 100644
--- a/media/engine/webrtc_video_engine_unittest.cc
+++ b/media/engine/webrtc_video_engine_unittest.cc
@@ -937,7 +937,7 @@
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.
diff --git a/pc/channel.cc b/pc/channel.cc
index d5c02f8..bf98278 100644
--- a/pc/channel.cc
+++ b/pc/channel.cc
@@ -245,7 +245,6 @@
}
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 @@
// 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(