Remove VideoChannel and VoiceChannel classes They were thin wrappers around BaseChannel with no added functionality. Test fakes in fake_peer_connection_for_stats.h were combined into ChannelForTesting. Bug: webrtc:42224170 Change-Id: I3841625c7100d6b38ec2ed7a5028c69d1b566dcb Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/466360 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org> Cr-Commit-Position: refs/heads/main@{#47543}
diff --git a/pc/channel.cc b/pc/channel.cc index 6edacf4..3a35007 100644 --- a/pc/channel.cc +++ b/pc/channel.cc
@@ -1073,50 +1073,4 @@ media_send_channel()->OnPacketSent(sent_packet); } -VoiceChannel::VoiceChannel( - TaskQueueBase* worker_thread, - Thread* network_thread, - TaskQueueBase* signaling_thread, - std::unique_ptr<VoiceMediaSendChannelInterface> media_send_channel, - std::unique_ptr<VoiceMediaReceiveChannelInterface> media_receive_channel, - absl::string_view mid, - bool srtp_required, - CryptoOptions crypto_options, - UniqueRandomIdGenerator* ssrc_generator, - ChannelCallbacks callbacks) - : BaseChannel(worker_thread, - network_thread, - signaling_thread, - std::move(media_send_channel), - std::move(media_receive_channel), - mid, - MediaType::AUDIO, - srtp_required, - crypto_options, - ssrc_generator, - std::move(callbacks)) {} - -VideoChannel::VideoChannel( - TaskQueueBase* worker_thread, - Thread* network_thread, - TaskQueueBase* signaling_thread, - std::unique_ptr<VideoMediaSendChannelInterface> media_send_channel, - std::unique_ptr<VideoMediaReceiveChannelInterface> media_receive_channel, - absl::string_view mid, - bool srtp_required, - CryptoOptions crypto_options, - UniqueRandomIdGenerator* ssrc_generator, - ChannelCallbacks callbacks) - : BaseChannel(worker_thread, - network_thread, - signaling_thread, - std::move(media_send_channel), - std::move(media_receive_channel), - mid, - MediaType::VIDEO, - srtp_required, - crypto_options, - ssrc_generator, - std::move(callbacks)) {} - } // namespace webrtc
diff --git a/pc/channel.h b/pc/channel.h index 27d34d0..5dad62e 100644 --- a/pc/channel.h +++ b/pc/channel.h
@@ -66,9 +66,6 @@ // and methods with _s suffix on signaling thread. // Network and worker threads may be the same thread. // -class VideoChannel; -class VoiceChannel; - class BaseChannel : public ChannelInterface, public MediaChannelNetworkInterface, public RtpPacketSinkInterface { @@ -352,43 +349,6 @@ UniqueRandomIdGenerator* const ssrc_generator_; }; -// VoiceChannel is a specialization that adds support for early media, DTMF, -// and input/output level monitoring. -class VoiceChannel : public BaseChannel { - public: - VoiceChannel( - TaskQueueBase* worker_thread, - Thread* network_thread, - TaskQueueBase* signaling_thread, - std::unique_ptr<VoiceMediaSendChannelInterface> send_channel_impl, - std::unique_ptr<VoiceMediaReceiveChannelInterface> receive_channel_impl, - absl::string_view mid, - bool srtp_required, - CryptoOptions crypto_options, - UniqueRandomIdGenerator* ssrc_generator, - ChannelCallbacks callbacks = {}); - - ~VoiceChannel() override = default; -}; - -// VideoChannel is a specialization for video. -class VideoChannel : public BaseChannel { - public: - VideoChannel( - TaskQueueBase* worker_thread, - Thread* network_thread, - TaskQueueBase* signaling_thread, - std::unique_ptr<VideoMediaSendChannelInterface> media_send_channel, - std::unique_ptr<VideoMediaReceiveChannelInterface> media_receive_channel, - absl::string_view mid, - bool srtp_required, - CryptoOptions crypto_options, - UniqueRandomIdGenerator* ssrc_generator, - ChannelCallbacks callbacks = {}); - ~VideoChannel() override = default; -}; - } // namespace webrtc - #endif // PC_CHANNEL_H_
diff --git a/pc/channel_unittest.cc b/pc/channel_unittest.cc index ceb916e..11bebc3 100644 --- a/pc/channel_unittest.cc +++ b/pc/channel_unittest.cc
@@ -24,6 +24,7 @@ #include "api/crypto/crypto_options.h" #include "api/field_trials.h" #include "api/jsep.h" +#include "api/media_types.h" #include "api/rtc_error.h" #include "api/rtp_headers.h" #include "api/rtp_parameters.h" @@ -120,7 +121,7 @@ using Options = OptionsT; }; -class VoiceTraits : public Traits<webrtc::VoiceChannel, +class VoiceTraits : public Traits<webrtc::BaseChannel, webrtc::FakeVoiceMediaSendChannel, webrtc::FakeVoiceMediaReceiveChannel, webrtc::VoiceMediaSendChannelInterface, @@ -129,7 +130,7 @@ webrtc::VoiceMediaInfo, webrtc::AudioOptions> {}; -class VideoTraits : public Traits<webrtc::VideoChannel, +class VideoTraits : public Traits<webrtc::BaseChannel, webrtc::FakeVideoMediaSendChannel, webrtc::FakeVideoMediaReceiveChannel, webrtc::VideoMediaSendChannelInterface, @@ -1702,7 +1703,7 @@ }; template <> -std::unique_ptr<webrtc::VoiceChannel> ChannelTest<VoiceTraits>::CreateChannel( +std::unique_ptr<webrtc::BaseChannel> ChannelTest<VoiceTraits>::CreateChannel( webrtc::Thread* worker_thread, webrtc::Thread* network_thread, std::unique_ptr<webrtc::FakeVoiceMediaSendChannel> send_ch, @@ -1710,10 +1711,10 @@ webrtc::RtpTransportInternal* rtp_transport, int flags) { webrtc::Thread* signaling_thread = webrtc::Thread::Current(); - auto channel = std::make_unique<webrtc::VoiceChannel>( + auto channel = std::make_unique<webrtc::BaseChannel>( worker_thread, network_thread, signaling_thread, std::move(send_ch), - std::move(receive_ch), kAudioMid, (flags & DTLS) != 0, - webrtc::CryptoOptions(), &ssrc_generator_); + std::move(receive_ch), kAudioMid, webrtc::MediaType::AUDIO, + (flags & DTLS) != 0, webrtc::CryptoOptions(), &ssrc_generator_); SendTask(network_thread, [&]() { RTC_DCHECK_RUN_ON(channel->network_thread()); channel->SetRtpTransport(rtp_transport); @@ -1782,7 +1783,7 @@ // override to add NULL parameter template <> -std::unique_ptr<webrtc::VideoChannel> ChannelTest<VideoTraits>::CreateChannel( +std::unique_ptr<webrtc::BaseChannel> ChannelTest<VideoTraits>::CreateChannel( webrtc::Thread* worker_thread, webrtc::Thread* network_thread, std::unique_ptr<webrtc::FakeVideoMediaSendChannel> send_ch, @@ -1790,10 +1791,10 @@ webrtc::RtpTransportInternal* rtp_transport, int flags) { webrtc::Thread* signaling_thread = webrtc::Thread::Current(); - auto channel = std::make_unique<webrtc::VideoChannel>( + auto channel = std::make_unique<webrtc::BaseChannel>( worker_thread, network_thread, signaling_thread, std::move(send_ch), - std::move(receive_ch), kVideoMid, (flags & DTLS) != 0, - webrtc::CryptoOptions(), &ssrc_generator_); + std::move(receive_ch), kVideoMid, webrtc::MediaType::VIDEO, + (flags & DTLS) != 0, webrtc::CryptoOptions(), &ssrc_generator_); SendTask(network_thread, [&]() { RTC_DCHECK_RUN_ON(channel->network_thread()); channel->SetRtpTransport(rtp_transport);
diff --git a/pc/rtp_transceiver.cc b/pc/rtp_transceiver.cc index bc2a937..c8bf45c 100644 --- a/pc/rtp_transceiver.cc +++ b/pc/rtp_transceiver.cc
@@ -262,26 +262,6 @@ env, call, media_config, video_options, crypto_options)}; } -// Helper template to wrap the construction of either a VoiceChannel -// or VideoChannel object from a given send and receive channel objects. -template <typename Channel, typename Send, typename Receive> -std::unique_ptr<ChannelInterface> CreateMediaChannel( - ConnectionContext* context, - std::unique_ptr<MediaSendChannelInterface>& send, - std::unique_ptr<MediaReceiveChannelInterface>& receive, - absl::string_view mid, - bool srtp_required, - CryptoOptions crypto_options, - ChannelCallbacks callbacks) { - return std::make_unique<Channel>( - context->worker_thread(), context->network_thread(), - context->signaling_thread(), - std::unique_ptr<Send>(static_cast<Send*>(send.release())), - std::unique_ptr<Receive>(static_cast<Receive*>(receive.release())), mid, - srtp_required, crypto_options, context->ssrc_generator(), - std::move(callbacks)); -} - std::vector<absl::AnyInvocable<void() &&>> DetachAndGetStopTasksForSenders( std::vector<scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>>>& senders) { @@ -562,20 +542,13 @@ media_receive_channel.get()); } - std::unique_ptr<ChannelInterface> new_channel; - if (media_type() == MediaType::AUDIO) { - new_channel = - CreateMediaChannel<VoiceChannel, VoiceMediaSendChannelInterface, - VoiceMediaReceiveChannelInterface>( - context(), media_send_channel, media_receive_channel, mid_str, - srtp_required, crypto_options, std::move(callbacks)); - } else { - new_channel = - CreateMediaChannel<VideoChannel, VideoMediaSendChannelInterface, - VideoMediaReceiveChannelInterface>( - context(), media_send_channel, media_receive_channel, mid_str, - srtp_required, crypto_options, std::move(callbacks)); - } + std::unique_ptr<ChannelInterface> new_channel = + std::make_unique<BaseChannel>( + context()->worker_thread(), context()->network_thread(), + context()->signaling_thread(), std::move(media_send_channel), + std::move(media_receive_channel), mid_str, media_type(), + srtp_required, crypto_options, context()->ssrc_generator(), + std::move(callbacks)); return ScopedOperationsBatcher::FinalizerTask( [this, new_channel = std::move(new_channel)]() mutable {
diff --git a/pc/test/fake_peer_connection_for_stats.h b/pc/test/fake_peer_connection_for_stats.h index 96f1dfb..c351e54 100644 --- a/pc/test/fake_peer_connection_for_stats.h +++ b/pc/test/fake_peer_connection_for_stats.h
@@ -264,60 +264,30 @@ constexpr bool kDefaultRtcpMuxRequired = true; constexpr bool kDefaultSrtpRequired = true; -class VoiceChannelForTesting : public VoiceChannel { +class ChannelForTesting : public BaseChannel { public: - VoiceChannelForTesting( + ChannelForTesting( Thread* worker_thread, Thread* network_thread, Thread* signaling_thread, - std::unique_ptr<VoiceMediaSendChannelInterface> send_channel, - std::unique_ptr<VoiceMediaReceiveChannelInterface> receive_channel, + std::unique_ptr<MediaSendChannelInterface> send_channel, + std::unique_ptr<MediaReceiveChannelInterface> receive_channel, const std::string& content_name, + MediaType media_type, bool srtp_required, CryptoOptions crypto_options, UniqueRandomIdGenerator* ssrc_generator, std::string transport_name) - : VoiceChannel(worker_thread, - network_thread, - signaling_thread, - std::move(send_channel), - std::move(receive_channel), - content_name, - srtp_required, - std::move(crypto_options), - ssrc_generator), - test_transport_name_(std::move(transport_name)) {} - - private: - absl::string_view transport_name() const override { - return test_transport_name_; - } - - const std::string test_transport_name_; -}; - -class VideoChannelForTesting : public VideoChannel { - public: - VideoChannelForTesting( - Thread* worker_thread, - Thread* network_thread, - Thread* signaling_thread, - std::unique_ptr<VideoMediaSendChannelInterface> send_channel, - std::unique_ptr<VideoMediaReceiveChannelInterface> receive_channel, - const std::string& content_name, - bool srtp_required, - CryptoOptions crypto_options, - UniqueRandomIdGenerator* ssrc_generator, - std::string transport_name) - : VideoChannel(worker_thread, - network_thread, - signaling_thread, - std::move(send_channel), - std::move(receive_channel), - content_name, - srtp_required, - std::move(crypto_options), - ssrc_generator), + : BaseChannel(worker_thread, + network_thread, + signaling_thread, + std::move(send_channel), + std::move(receive_channel), + content_name, + media_type, + srtp_required, + std::move(crypto_options), + ssrc_generator), test_transport_name_(std::move(transport_name)) {} private: @@ -447,11 +417,12 @@ std::make_unique<FakeVoiceMediaReceiveChannelForStats>(network_thread_); auto* voice_media_send_channel_ptr = voice_media_send_channel.get(); auto* voice_media_receive_channel_ptr = voice_media_receive_channel.get(); - auto voice_channel = std::make_unique<VoiceChannelForTesting>( + auto voice_channel = std::make_unique<ChannelForTesting>( worker_thread_, network_thread_, signaling_thread_, std::move(voice_media_send_channel), - std::move(voice_media_receive_channel), mid, kDefaultSrtpRequired, - CryptoOptions(), context_->ssrc_generator(), transport_name); + std::move(voice_media_receive_channel), mid, MediaType::AUDIO, + kDefaultSrtpRequired, CryptoOptions(), context_->ssrc_generator(), + transport_name); auto transceiver = GetOrCreateFirstTransceiverOfType(webrtc::MediaType::AUDIO, mid) ->internal(); @@ -485,11 +456,12 @@ std::make_unique<FakeVideoMediaReceiveChannelForStats>(network_thread_); auto video_media_send_channel_ptr = video_media_send_channel.get(); auto video_media_receive_channel_ptr = video_media_receive_channel.get(); - auto video_channel = std::make_unique<VideoChannelForTesting>( + auto video_channel = std::make_unique<ChannelForTesting>( worker_thread_, network_thread_, signaling_thread_, std::move(video_media_send_channel), - std::move(video_media_receive_channel), mid, kDefaultSrtpRequired, - CryptoOptions(), context_->ssrc_generator(), transport_name); + std::move(video_media_receive_channel), mid, MediaType::VIDEO, + kDefaultSrtpRequired, CryptoOptions(), context_->ssrc_generator(), + transport_name); auto transceiver = GetOrCreateFirstTransceiverOfType(webrtc::MediaType::VIDEO, mid) ->internal();