Eliminate channel.h from rtp_transmission_manager.cc

This also hides the existence of the classes VideoChannel and
VoiceChannel from anything that does not include "channel.h".

Bug: webrtc:13931
Change-Id: I080a692b6acfd5d2d0401ec20d59c3a684eddb05
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/260944
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36746}
This commit is contained in:
Harald Alvestrand 2022-05-03 13:44:34 +00:00 committed by WebRTC LUCI CQ
parent 00579e8bce
commit 25adc8e36b
7 changed files with 98 additions and 33 deletions

View File

@ -118,6 +118,19 @@ rtc_source_set("channel_interface") {
absl_deps = [ "//third_party/abseil-cpp/absl/strings" ]
}
rtc_source_set("channel_factory_interface") {
visibility = [ ":*" ]
sources = [ "channel_factory_interface.h" ]
deps = [
"../api:audio_options_api",
"../api/crypto:options",
"../api/video:video_bitrate_allocator_factory",
"../call:call_interfaces",
"../media:rtc_media_base",
"../media:rtc_media_config",
]
}
rtc_source_set("channel_manager") {
visibility = [ ":*" ]
sources = [
@ -126,6 +139,7 @@ rtc_source_set("channel_manager") {
]
deps = [
":channel",
":channel_factory_interface",
":channel_interface",
":session_description",
"../api:audio_options_api",
@ -1611,6 +1625,7 @@ rtc_library("rtp_transmission_manager") {
deps = [
":audio_rtp_receiver",
":channel",
":channel_interface",
":channel_manager",
":rtp_receiver",
":rtp_receiver_proxy",

View File

@ -158,6 +158,14 @@ class BaseChannel : public ChannelInterface,
MediaChannel* media_channel() const override {
return media_channel_.get();
}
VideoMediaChannel* video_media_channel() const override {
RTC_CHECK(false) << "Attempt to fetch video channel from non-video";
return nullptr;
}
VoiceMediaChannel* voice_media_channel() const override {
RTC_CHECK(false) << "Attempt to fetch voice channel from non-voice";
return nullptr;
}
protected:
void set_local_content_direction(webrtc::RtpTransceiverDirection direction)
@ -364,6 +372,10 @@ class VoiceChannel : public BaseChannel {
return static_cast<VoiceMediaChannel*>(BaseChannel::media_channel());
}
VoiceMediaChannel* voice_media_channel() const override {
return static_cast<VoiceMediaChannel*>(media_channel());
}
cricket::MediaType media_type() const override {
return cricket::MEDIA_TYPE_AUDIO;
}
@ -406,6 +418,10 @@ class VideoChannel : public BaseChannel {
return static_cast<VideoMediaChannel*>(BaseChannel::media_channel());
}
VideoMediaChannel* video_media_channel() const override {
return static_cast<cricket::VideoMediaChannel*>(media_channel());
}
cricket::MediaType media_type() const override {
return cricket::MEDIA_TYPE_VIDEO;
}

View File

@ -0,0 +1,55 @@
/*
* Copyright 2004 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef PC_CHANNEL_FACTORY_INTERFACE_H_
#define PC_CHANNEL_FACTORY_INTERFACE_H_
#include <memory>
#include <string>
#include "api/audio_options.h"
#include "api/crypto/crypto_options.h"
#include "api/video/video_bitrate_allocator_factory.h"
#include "call/call.h"
#include "media/base/media_channel.h"
#include "media/base/media_config.h"
namespace cricket {
class VideoChannel;
class VoiceChannel;
class ChannelFactoryInterface {
public:
virtual std::unique_ptr<VideoChannel> CreateVideoChannel(
webrtc::Call* call,
const MediaConfig& media_config,
const std::string& mid,
bool srtp_required,
const webrtc::CryptoOptions& crypto_options,
const VideoOptions& options,
webrtc::VideoBitrateAllocatorFactory*
video_bitrate_allocator_factory) = 0;
virtual std::unique_ptr<VoiceChannel> CreateVoiceChannel(
webrtc::Call* call,
const MediaConfig& media_config,
const std::string& mid,
bool srtp_required,
const webrtc::CryptoOptions& crypto_options,
const AudioOptions& options) = 0;
protected:
virtual ~ChannelFactoryInterface() = default;
};
} // namespace cricket
#endif // PC_CHANNEL_FACTORY_INTERFACE_H_

View File

@ -29,8 +29,6 @@ class VideoBitrateAllocatorFactory;
namespace cricket {
class MediaContentDescription;
class VideoChannel;
class VoiceChannel;
struct MediaConfig;
// A Channel is a construct that groups media streams of the same type
@ -50,6 +48,10 @@ class ChannelInterface {
virtual cricket::MediaType media_type() const = 0;
virtual MediaChannel* media_channel() const = 0;
// Typecasts of media_channel(). Will cause an exception if the
// channel is of the wrong type.
virtual VideoMediaChannel* video_media_channel() const = 0;
virtual VoiceMediaChannel* voice_media_channel() const = 0;
// Returns a string view for the transport name. Fetching the transport name
// must be done on the network thread only and note that the lifetime of
@ -88,30 +90,6 @@ class ChannelInterface {
virtual bool SetRtpTransport(webrtc::RtpTransportInternal* rtp_transport) = 0;
};
class ChannelFactoryInterface {
public:
virtual std::unique_ptr<VideoChannel> CreateVideoChannel(
webrtc::Call* call,
const MediaConfig& media_config,
const std::string& mid,
bool srtp_required,
const webrtc::CryptoOptions& crypto_options,
const VideoOptions& options,
webrtc::VideoBitrateAllocatorFactory*
video_bitrate_allocator_factory) = 0;
virtual std::unique_ptr<VoiceChannel> CreateVoiceChannel(
webrtc::Call* call,
const MediaConfig& media_config,
const std::string& mid,
bool srtp_required,
const webrtc::CryptoOptions& crypto_options,
const AudioOptions& options) = 0;
protected:
virtual ~ChannelFactoryInterface() = default;
};
} // namespace cricket
#endif // PC_CHANNEL_INTERFACE_H_

View File

@ -26,6 +26,7 @@
#include "media/base/media_channel.h"
#include "media/base/media_config.h"
#include "media/base/media_engine.h"
#include "pc/channel_factory_interface.h"
#include "pc/channel_interface.h"
#include "pc/session_description.h"
#include "rtc_base/system/file_wrapper.h"

View File

@ -17,7 +17,7 @@
#include "api/peer_connection_interface.h"
#include "api/rtp_transceiver_direction.h"
#include "pc/audio_rtp_receiver.h"
#include "pc/channel.h"
#include "pc/channel_interface.h"
#include "pc/stats_collector_interface.h"
#include "pc/video_rtp_receiver.h"
#include "rtc_base/checks.h"
@ -81,10 +81,9 @@ cricket::VoiceMediaChannel* RtpTransmissionManager::voice_media_channel()
const {
RTC_DCHECK_RUN_ON(signaling_thread());
RTC_DCHECK(!IsUnifiedPlan());
auto* voice_channel = static_cast<cricket::VoiceChannel*>(
GetAudioTransceiver()->internal()->channel());
auto* voice_channel = GetAudioTransceiver()->internal()->channel();
if (voice_channel) {
return voice_channel->media_channel();
return voice_channel->voice_media_channel();
} else {
return nullptr;
}
@ -94,10 +93,9 @@ cricket::VideoMediaChannel* RtpTransmissionManager::video_media_channel()
const {
RTC_DCHECK_RUN_ON(signaling_thread());
RTC_DCHECK(!IsUnifiedPlan());
auto* video_channel = static_cast<cricket::VideoChannel*>(
GetVideoTransceiver()->internal()->channel());
auto* video_channel = GetVideoTransceiver()->internal()->channel();
if (video_channel) {
return video_channel->media_channel();
return video_channel->video_media_channel();
} else {
return nullptr;
}

View File

@ -26,6 +26,8 @@ class MockChannelInterface : public cricket::ChannelInterface {
public:
MOCK_METHOD(cricket::MediaType, media_type, (), (const, override));
MOCK_METHOD(MediaChannel*, media_channel, (), (const, override));
MOCK_METHOD(VoiceMediaChannel*, voice_media_channel, (), (const, override));
MOCK_METHOD(VideoMediaChannel*, video_media_channel, (), (const, override));
MOCK_METHOD(absl::string_view, transport_name, (), (const, override));
MOCK_METHOD(const std::string&, mid, (), (const, override));
MOCK_METHOD(void, Enable, (bool), (override));