diff --git a/webrtc/api/BUILD.gn b/webrtc/api/BUILD.gn index c0e84cb2b4..2b1ca34576 100644 --- a/webrtc/api/BUILD.gn +++ b/webrtc/api/BUILD.gn @@ -47,7 +47,6 @@ rtc_static_library("libjingle_peerconnection_api") { "jsepsessiondescription.h", "mediaconstraintsinterface.cc", "mediaconstraintsinterface.h", - "mediacontroller.h", "mediastream.h", "mediastreaminterface.cc", "mediastreaminterface.h", diff --git a/webrtc/api/mediacontroller.h b/webrtc/api/mediacontroller.h deleted file mode 100644 index 9c2b708500..0000000000 --- a/webrtc/api/mediacontroller.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2015 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 WEBRTC_API_MEDIACONTROLLER_H_ -#define WEBRTC_API_MEDIACONTROLLER_H_ - -// Including this file is deprecated. It is no longer part of the public API. -// This only includes the file in its new location for backwards compatibility. -#include "webrtc/pc/mediacontroller.h" - -#endif // WEBRTC_API_MEDIACONTROLLER_H_ diff --git a/webrtc/ortc/rtptransportcontrolleradapter.cc b/webrtc/ortc/rtptransportcontrolleradapter.cc index ad5d8b5d68..b482e475fd 100644 --- a/webrtc/ortc/rtptransportcontrolleradapter.cc +++ b/webrtc/ortc/rtptransportcontrolleradapter.cc @@ -121,6 +121,10 @@ RtpTransportControllerAdapter::~RtpTransportControllerAdapter() { // been destroyed. This isn't safe (see error log above). DestroyVideoChannel(); } + // Call must be destroyed on the worker thread. + worker_thread_->Invoke( + RTC_FROM_HERE, + rtc::Bind(&RtpTransportControllerAdapter::Close_w, this)); } RTCErrorOr> @@ -584,14 +588,11 @@ RtpTransportControllerAdapter::RtpTransportControllerAdapter( rtc::Thread* worker_thread) : signaling_thread_(signaling_thread), worker_thread_(worker_thread), - media_controller_(MediaControllerInterface::Create(config, - worker_thread, - channel_manager, - event_log)) { + media_config_(config), + channel_manager_(channel_manager), + event_log_(event_log) { RTC_DCHECK_RUN_ON(signaling_thread_); - RTC_DCHECK(channel_manager); - // MediaControllerInterface::Create should never fail. - RTC_DCHECK(media_controller_); + RTC_DCHECK(channel_manager_); // Add "dummy" codecs to the descriptions, because the media engines // currently reject empty lists of codecs. Note that these codecs will never // actually be used, because when parameters are set, the dummy codecs will @@ -603,6 +604,33 @@ RtpTransportControllerAdapter::RtpTransportControllerAdapter( remote_audio_description_.AddCodec(dummy_audio); local_video_description_.AddCodec(dummy_video); remote_video_description_.AddCodec(dummy_video); + + worker_thread_->Invoke( + RTC_FROM_HERE, + rtc::Bind(&RtpTransportControllerAdapter::Init_w, this)); +} + +// TODO(nisse): Duplicates corresponding method in PeerConnection (used +// to be in MediaController). +void RtpTransportControllerAdapter::Init_w() { + RTC_DCHECK(worker_thread_->IsCurrent()); + RTC_DCHECK(!call_); + + const int kMinBandwidthBps = 30000; + const int kStartBandwidthBps = 300000; + const int kMaxBandwidthBps = 2000000; + + webrtc::Call::Config call_config(event_log_); + call_config.audio_state = channel_manager_->media_engine()->GetAudioState(); + call_config.bitrate_config.min_bitrate_bps = kMinBandwidthBps; + call_config.bitrate_config.start_bitrate_bps = kStartBandwidthBps; + call_config.bitrate_config.max_bitrate_bps = kMaxBandwidthBps; + + call_.reset(webrtc::Call::Create(call_config)); +} + +void RtpTransportControllerAdapter::Close_w() { + call_.reset(); } RTCError RtpTransportControllerAdapter::AttachAudioSender( @@ -818,8 +846,8 @@ void RtpTransportControllerAdapter::OnVideoReceiverDestroyed() { } void RtpTransportControllerAdapter::CreateVoiceChannel() { - voice_channel_ = media_controller_->channel_manager()->CreateVoiceChannel( - media_controller_.get(), + voice_channel_ = channel_manager_->CreateVoiceChannel( + call_.get(), media_config_, inner_audio_transport_->GetRtpPacketTransport()->GetInternal(), inner_audio_transport_->GetRtcpPacketTransport() ? inner_audio_transport_->GetRtcpPacketTransport()->GetInternal() @@ -830,8 +858,8 @@ void RtpTransportControllerAdapter::CreateVoiceChannel() { } void RtpTransportControllerAdapter::CreateVideoChannel() { - video_channel_ = media_controller_->channel_manager()->CreateVideoChannel( - media_controller_.get(), + video_channel_ = channel_manager_->CreateVideoChannel( + call_.get(), media_config_, inner_video_transport_->GetRtpPacketTransport()->GetInternal(), inner_video_transport_->GetRtcpPacketTransport() ? inner_video_transport_->GetRtcpPacketTransport()->GetInternal() @@ -843,14 +871,14 @@ void RtpTransportControllerAdapter::CreateVideoChannel() { void RtpTransportControllerAdapter::DestroyVoiceChannel() { RTC_DCHECK(voice_channel_); - media_controller_->channel_manager()->DestroyVoiceChannel(voice_channel_); + channel_manager_->DestroyVoiceChannel(voice_channel_); voice_channel_ = nullptr; inner_audio_transport_ = nullptr; } void RtpTransportControllerAdapter::DestroyVideoChannel() { RTC_DCHECK(video_channel_); - media_controller_->channel_manager()->DestroyVideoChannel(video_channel_); + channel_manager_->DestroyVideoChannel(video_channel_); video_channel_ = nullptr; inner_video_transport_ = nullptr; } diff --git a/webrtc/ortc/rtptransportcontrolleradapter.h b/webrtc/ortc/rtptransportcontrolleradapter.h index 902ec01c51..f0dca7af0c 100644 --- a/webrtc/ortc/rtptransportcontrolleradapter.h +++ b/webrtc/ortc/rtptransportcontrolleradapter.h @@ -27,7 +27,6 @@ #include "webrtc/logging/rtc_event_log/rtc_event_log.h" #include "webrtc/media/base/mediachannel.h" // For MediaConfig. #include "webrtc/pc/channelmanager.h" -#include "webrtc/pc/mediacontroller.h" namespace webrtc { @@ -130,6 +129,8 @@ class RtpTransportControllerAdapter : public RtpTransportControllerInterface, webrtc::RtcEventLog* event_log, rtc::Thread* signaling_thread, rtc::Thread* worker_thread); + void Init_w(); + void Close_w(); // These return an error if another of the same type of object is already // attached, or if |transport_proxy| can't be used with the sender/receiver @@ -191,7 +192,10 @@ class RtpTransportControllerAdapter : public RtpTransportControllerInterface, std::vector transport_proxies_; RtpTransportInterface* inner_audio_transport_ = nullptr; RtpTransportInterface* inner_video_transport_ = nullptr; - std::unique_ptr media_controller_; + const cricket::MediaConfig media_config_; + cricket::ChannelManager* channel_manager_; + webrtc::RtcEventLog* event_log_; + std::unique_ptr call_; // BaseChannel takes content descriptions as input, so we store them here // such that they can be updated when a new RtpSenderAdapter/ diff --git a/webrtc/pc/BUILD.gn b/webrtc/pc/BUILD.gn index 8e78cafdab..483485012d 100644 --- a/webrtc/pc/BUILD.gn +++ b/webrtc/pc/BUILD.gn @@ -95,8 +95,6 @@ rtc_static_library("libjingle_peerconnection") { "jsepsessiondescription.cc", "localaudiosource.cc", "localaudiosource.h", - "mediacontroller.cc", - "mediacontroller.h", "mediastream.cc", "mediastream.h", "mediastreamobserver.cc", @@ -283,7 +281,6 @@ if (rtc_include_tests) { sources = [ "datachannel_unittest.cc", "dtmfsender_unittest.cc", - "fakemediacontroller.h", "iceserverparsing_unittest.cc", "jsepsessiondescription_unittest.cc", "localaudiosource_unittest.cc", diff --git a/webrtc/pc/channelmanager.cc b/webrtc/pc/channelmanager.cc index 995a07bf05..af6e3c7e99 100644 --- a/webrtc/pc/channelmanager.cc +++ b/webrtc/pc/channelmanager.cc @@ -21,7 +21,6 @@ #include "webrtc/media/base/device.h" #include "webrtc/media/base/rtpdataengine.h" #include "webrtc/pc/srtpfilter.h" -#include "webrtc/pc/mediacontroller.h" namespace cricket { @@ -179,7 +178,8 @@ void ChannelManager::Terminate_w() { } VoiceChannel* ChannelManager::CreateVoiceChannel( - webrtc::MediaControllerInterface* media_controller, + webrtc::Call* call, + const cricket::MediaConfig& media_config, DtlsTransportInternal* rtp_transport, DtlsTransportInternal* rtcp_transport, rtc::Thread* signaling_thread, @@ -188,13 +188,14 @@ VoiceChannel* ChannelManager::CreateVoiceChannel( const AudioOptions& options) { return worker_thread_->Invoke( RTC_FROM_HERE, - Bind(&ChannelManager::CreateVoiceChannel_w, this, media_controller, + Bind(&ChannelManager::CreateVoiceChannel_w, this, call, media_config, rtp_transport, rtcp_transport, rtp_transport, rtcp_transport, signaling_thread, content_name, srtp_required, options)); } VoiceChannel* ChannelManager::CreateVoiceChannel( - webrtc::MediaControllerInterface* media_controller, + webrtc::Call* call, + const cricket::MediaConfig& media_config, rtc::PacketTransportInternal* rtp_transport, rtc::PacketTransportInternal* rtcp_transport, rtc::Thread* signaling_thread, @@ -203,13 +204,14 @@ VoiceChannel* ChannelManager::CreateVoiceChannel( const AudioOptions& options) { return worker_thread_->Invoke( RTC_FROM_HERE, - Bind(&ChannelManager::CreateVoiceChannel_w, this, media_controller, + Bind(&ChannelManager::CreateVoiceChannel_w, this, call, media_config, nullptr, nullptr, rtp_transport, rtcp_transport, signaling_thread, content_name, srtp_required, options)); } VoiceChannel* ChannelManager::CreateVoiceChannel_w( - webrtc::MediaControllerInterface* media_controller, + webrtc::Call* call, + const cricket::MediaConfig& media_config, DtlsTransportInternal* rtp_dtls_transport, DtlsTransportInternal* rtcp_dtls_transport, rtc::PacketTransportInternal* rtp_packet_transport, @@ -220,10 +222,10 @@ VoiceChannel* ChannelManager::CreateVoiceChannel_w( const AudioOptions& options) { RTC_DCHECK(initialized_); RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); - RTC_DCHECK(nullptr != media_controller); + RTC_DCHECK(nullptr != call); VoiceMediaChannel* media_channel = media_engine_->CreateChannel( - media_controller->call_w(), media_controller->config(), options); + call, media_config, options); if (!media_channel) return nullptr; @@ -265,7 +267,8 @@ void ChannelManager::DestroyVoiceChannel_w(VoiceChannel* voice_channel) { } VideoChannel* ChannelManager::CreateVideoChannel( - webrtc::MediaControllerInterface* media_controller, + webrtc::Call* call, + const cricket::MediaConfig& media_config, DtlsTransportInternal* rtp_transport, DtlsTransportInternal* rtcp_transport, rtc::Thread* signaling_thread, @@ -274,13 +277,14 @@ VideoChannel* ChannelManager::CreateVideoChannel( const VideoOptions& options) { return worker_thread_->Invoke( RTC_FROM_HERE, - Bind(&ChannelManager::CreateVideoChannel_w, this, media_controller, + Bind(&ChannelManager::CreateVideoChannel_w, this, call, media_config, rtp_transport, rtcp_transport, rtp_transport, rtcp_transport, signaling_thread, content_name, srtp_required, options)); } VideoChannel* ChannelManager::CreateVideoChannel( - webrtc::MediaControllerInterface* media_controller, + webrtc::Call* call, + const cricket::MediaConfig& media_config, rtc::PacketTransportInternal* rtp_transport, rtc::PacketTransportInternal* rtcp_transport, rtc::Thread* signaling_thread, @@ -289,13 +293,14 @@ VideoChannel* ChannelManager::CreateVideoChannel( const VideoOptions& options) { return worker_thread_->Invoke( RTC_FROM_HERE, - Bind(&ChannelManager::CreateVideoChannel_w, this, media_controller, + Bind(&ChannelManager::CreateVideoChannel_w, this, call, media_config, nullptr, nullptr, rtp_transport, rtcp_transport, signaling_thread, content_name, srtp_required, options)); } VideoChannel* ChannelManager::CreateVideoChannel_w( - webrtc::MediaControllerInterface* media_controller, + webrtc::Call* call, + const cricket::MediaConfig& media_config, DtlsTransportInternal* rtp_dtls_transport, DtlsTransportInternal* rtcp_dtls_transport, rtc::PacketTransportInternal* rtp_packet_transport, @@ -306,9 +311,9 @@ VideoChannel* ChannelManager::CreateVideoChannel_w( const VideoOptions& options) { RTC_DCHECK(initialized_); RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); - RTC_DCHECK(nullptr != media_controller); + RTC_DCHECK(nullptr != call); VideoMediaChannel* media_channel = media_engine_->CreateVideoChannel( - media_controller->call_w(), media_controller->config(), options); + call, media_config, options); if (media_channel == NULL) { return NULL; } @@ -350,7 +355,7 @@ void ChannelManager::DestroyVideoChannel_w(VideoChannel* video_channel) { } RtpDataChannel* ChannelManager::CreateRtpDataChannel( - webrtc::MediaControllerInterface* media_controller, + const cricket::MediaConfig& media_config, DtlsTransportInternal* rtp_transport, DtlsTransportInternal* rtcp_transport, rtc::Thread* signaling_thread, @@ -358,12 +363,12 @@ RtpDataChannel* ChannelManager::CreateRtpDataChannel( bool srtp_required) { return worker_thread_->Invoke( RTC_FROM_HERE, Bind(&ChannelManager::CreateRtpDataChannel_w, this, - media_controller, rtp_transport, rtcp_transport, + media_config, rtp_transport, rtcp_transport, signaling_thread, content_name, srtp_required)); } RtpDataChannel* ChannelManager::CreateRtpDataChannel_w( - webrtc::MediaControllerInterface* media_controller, + const cricket::MediaConfig& media_config, DtlsTransportInternal* rtp_transport, DtlsTransportInternal* rtcp_transport, rtc::Thread* signaling_thread, @@ -371,11 +376,8 @@ RtpDataChannel* ChannelManager::CreateRtpDataChannel_w( bool srtp_required) { // This is ok to alloc from a thread other than the worker thread. RTC_DCHECK(initialized_); - MediaConfig config; - if (media_controller) { - config = media_controller->config(); - } - DataMediaChannel* media_channel = data_media_engine_->CreateChannel(config); + DataMediaChannel* media_channel + = data_media_engine_->CreateChannel(media_config); if (!media_channel) { LOG(LS_WARNING) << "Failed to create RTP data channel."; return nullptr; diff --git a/webrtc/pc/channelmanager.h b/webrtc/pc/channelmanager.h index e62ad6fcd6..695b796e09 100644 --- a/webrtc/pc/channelmanager.h +++ b/webrtc/pc/channelmanager.h @@ -20,9 +20,6 @@ #include "webrtc/media/base/mediaengine.h" #include "webrtc/pc/voicechannel.h" -namespace webrtc { -class MediaControllerInterface; -} namespace cricket { class VoiceChannel; @@ -88,7 +85,8 @@ class ChannelManager { // The operations below all occur on the worker thread. // Creates a voice channel, to be associated with the specified session. VoiceChannel* CreateVoiceChannel( - webrtc::MediaControllerInterface* media_controller, + webrtc::Call* call, + const cricket::MediaConfig& media_config, DtlsTransportInternal* rtp_transport, DtlsTransportInternal* rtcp_transport, rtc::Thread* signaling_thread, @@ -97,7 +95,8 @@ class ChannelManager { const AudioOptions& options); // Version of the above that takes PacketTransportInternal. VoiceChannel* CreateVoiceChannel( - webrtc::MediaControllerInterface* media_controller, + webrtc::Call* call, + const cricket::MediaConfig& media_config, rtc::PacketTransportInternal* rtp_transport, rtc::PacketTransportInternal* rtcp_transport, rtc::Thread* signaling_thread, @@ -109,7 +108,8 @@ class ChannelManager { // Creates a video channel, synced with the specified voice channel, and // associated with the specified session. VideoChannel* CreateVideoChannel( - webrtc::MediaControllerInterface* media_controller, + webrtc::Call* call, + const cricket::MediaConfig& media_config, DtlsTransportInternal* rtp_transport, DtlsTransportInternal* rtcp_transport, rtc::Thread* signaling_thread, @@ -118,7 +118,8 @@ class ChannelManager { const VideoOptions& options); // Version of the above that takes PacketTransportInternal. VideoChannel* CreateVideoChannel( - webrtc::MediaControllerInterface* media_controller, + webrtc::Call* call, + const cricket::MediaConfig& media_config, rtc::PacketTransportInternal* rtp_transport, rtc::PacketTransportInternal* rtcp_transport, rtc::Thread* signaling_thread, @@ -128,7 +129,7 @@ class ChannelManager { // Destroys a video channel created with the Create API. void DestroyVideoChannel(VideoChannel* video_channel); RtpDataChannel* CreateRtpDataChannel( - webrtc::MediaControllerInterface* media_controller, + const cricket::MediaConfig& media_config, DtlsTransportInternal* rtp_transport, DtlsTransportInternal* rtcp_transport, rtc::Thread* signaling_thread, @@ -172,7 +173,8 @@ class ChannelManager { void DestructorDeletes_w(); void Terminate_w(); VoiceChannel* CreateVoiceChannel_w( - webrtc::MediaControllerInterface* media_controller, + webrtc::Call* call, + const cricket::MediaConfig& media_config, DtlsTransportInternal* rtp_dtls_transport, DtlsTransportInternal* rtcp_dtls_transport, rtc::PacketTransportInternal* rtp_packet_transport, @@ -183,7 +185,8 @@ class ChannelManager { const AudioOptions& options); void DestroyVoiceChannel_w(VoiceChannel* voice_channel); VideoChannel* CreateVideoChannel_w( - webrtc::MediaControllerInterface* media_controller, + webrtc::Call* call, + const cricket::MediaConfig& media_config, DtlsTransportInternal* rtp_dtls_transport, DtlsTransportInternal* rtcp_dtls_transport, rtc::PacketTransportInternal* rtp_packet_transport, @@ -194,7 +197,7 @@ class ChannelManager { const VideoOptions& options); void DestroyVideoChannel_w(VideoChannel* video_channel); RtpDataChannel* CreateRtpDataChannel_w( - webrtc::MediaControllerInterface* media_controller, + const cricket::MediaConfig& media_config, DtlsTransportInternal* rtp_transport, DtlsTransportInternal* rtcp_transport, rtc::Thread* signaling_thread, diff --git a/webrtc/pc/channelmanager_unittest.cc b/webrtc/pc/channelmanager_unittest.cc index 31991eaaa5..1919aae23c 100644 --- a/webrtc/pc/channelmanager_unittest.cc +++ b/webrtc/pc/channelmanager_unittest.cc @@ -20,7 +20,6 @@ #include "webrtc/media/engine/fakewebrtccall.h" #include "webrtc/p2p/base/faketransportcontroller.h" #include "webrtc/pc/channelmanager.h" -#include "webrtc/pc/fakemediacontroller.h" namespace { const bool kDefaultSrtpRequired = true; @@ -46,7 +45,6 @@ class ChannelManagerTest : public testing::Test { std::unique_ptr(fdme_), rtc::Thread::Current())), fake_call_(webrtc::Call::Config(&event_log_)), - fake_mc_(cm_.get(), &fake_call_), transport_controller_( new cricket::FakeTransportController(ICEROLE_CONTROLLING)) { fme_->SetAudioCodecs(MAKE_VECTOR(kAudioCodecs)); @@ -61,7 +59,6 @@ class ChannelManagerTest : public testing::Test { cricket::FakeDataEngine* fdme_; std::unique_ptr cm_; cricket::FakeCall fake_call_; - cricket::FakeMediaController fake_mc_; std::unique_ptr transport_controller_; }; @@ -101,17 +98,19 @@ TEST_F(ChannelManagerTest, CreateDestroyChannels) { transport_controller_->CreateDtlsTransport( cricket::CN_AUDIO, cricket::ICE_CANDIDATE_COMPONENT_RTP); cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel( - &fake_mc_, rtp_transport, nullptr /*rtcp_transport*/, + &fake_call_, cricket::MediaConfig(), + rtp_transport, nullptr /*rtcp_transport*/, rtc::Thread::Current(), cricket::CN_AUDIO, kDefaultSrtpRequired, AudioOptions()); EXPECT_TRUE(voice_channel != nullptr); cricket::VideoChannel* video_channel = cm_->CreateVideoChannel( - &fake_mc_, rtp_transport, nullptr /*rtcp_transport*/, + &fake_call_, cricket::MediaConfig(), + rtp_transport, nullptr /*rtcp_transport*/, rtc::Thread::Current(), cricket::CN_VIDEO, kDefaultSrtpRequired, VideoOptions()); EXPECT_TRUE(video_channel != nullptr); cricket::RtpDataChannel* rtp_data_channel = cm_->CreateRtpDataChannel( - &fake_mc_, rtp_transport, nullptr /*rtcp_transport*/, + cricket::MediaConfig(), rtp_transport, nullptr /*rtcp_transport*/, rtc::Thread::Current(), cricket::CN_DATA, kDefaultSrtpRequired); EXPECT_TRUE(rtp_data_channel != nullptr); cm_->DestroyVideoChannel(video_channel); @@ -133,17 +132,19 @@ TEST_F(ChannelManagerTest, CreateDestroyChannelsOnThread) { transport_controller_->CreateDtlsTransport( cricket::CN_AUDIO, cricket::ICE_CANDIDATE_COMPONENT_RTP); cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel( - &fake_mc_, rtp_transport, nullptr /*rtcp_transport*/, + &fake_call_, cricket::MediaConfig(), + rtp_transport, nullptr /*rtcp_transport*/, rtc::Thread::Current(), cricket::CN_AUDIO, kDefaultSrtpRequired, AudioOptions()); EXPECT_TRUE(voice_channel != nullptr); cricket::VideoChannel* video_channel = cm_->CreateVideoChannel( - &fake_mc_, rtp_transport, nullptr /*rtcp_transport*/, + &fake_call_, cricket::MediaConfig(), + rtp_transport, nullptr /*rtcp_transport*/, rtc::Thread::Current(), cricket::CN_VIDEO, kDefaultSrtpRequired, VideoOptions()); EXPECT_TRUE(video_channel != nullptr); cricket::RtpDataChannel* rtp_data_channel = cm_->CreateRtpDataChannel( - &fake_mc_, rtp_transport, nullptr /*rtcp_transport*/, + cricket::MediaConfig(), rtp_transport, nullptr /*rtcp_transport*/, rtc::Thread::Current(), cricket::CN_DATA, kDefaultSrtpRequired); EXPECT_TRUE(rtp_data_channel != nullptr); cm_->DestroyVideoChannel(video_channel); diff --git a/webrtc/pc/fakemediacontroller.h b/webrtc/pc/fakemediacontroller.h deleted file mode 100644 index 6d639ed18e..0000000000 --- a/webrtc/pc/fakemediacontroller.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2015 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 WEBRTC_PC_FAKEMEDIACONTROLLER_H_ -#define WEBRTC_PC_FAKEMEDIACONTROLLER_H_ - -#include "webrtc/base/checks.h" -#include "webrtc/media/base/mediachannel.h" -#include "webrtc/pc/mediacontroller.h" - -namespace cricket { - -class FakeMediaController : public webrtc::MediaControllerInterface { - public: - explicit FakeMediaController(cricket::ChannelManager* channel_manager, - webrtc::Call* call) - : channel_manager_(channel_manager), call_(call) { - RTC_DCHECK(nullptr != channel_manager_); - RTC_DCHECK(nullptr != call_); - } - ~FakeMediaController() override {} - void Close() override {} - webrtc::Call* call_w() override { return call_; } - cricket::ChannelManager* channel_manager() const override { - return channel_manager_; - } - const MediaConfig& config() const override { return media_config_; } - - private: - const MediaConfig media_config_ = MediaConfig(); - cricket::ChannelManager* channel_manager_; - webrtc::Call* call_; -}; -} // namespace cricket -#endif // WEBRTC_PC_FAKEMEDIACONTROLLER_H_ diff --git a/webrtc/pc/mediacontroller.cc b/webrtc/pc/mediacontroller.cc deleted file mode 100644 index fa8acadddc..0000000000 --- a/webrtc/pc/mediacontroller.cc +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2015 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. - */ - -#include "webrtc/pc/mediacontroller.h" - -#include - -#include "webrtc/base/bind.h" -#include "webrtc/base/checks.h" -#include "webrtc/base/constructormagic.h" -#include "webrtc/call/call.h" -#include "webrtc/pc/channelmanager.h" -#include "webrtc/media/base/mediachannel.h" - -namespace { - -const int kMinBandwidthBps = 30000; -const int kStartBandwidthBps = 300000; -const int kMaxBandwidthBps = 2000000; - -class MediaController : public webrtc::MediaControllerInterface, - public sigslot::has_slots<> { - public: - MediaController(const cricket::MediaConfig& media_config, - rtc::Thread* worker_thread, - cricket::ChannelManager* channel_manager, - webrtc::RtcEventLog* event_log) - : worker_thread_(worker_thread), - media_config_(media_config), - channel_manager_(channel_manager), - call_config_(event_log) { - RTC_DCHECK(worker_thread); - RTC_DCHECK(event_log); - worker_thread_->Invoke(RTC_FROM_HERE, - rtc::Bind(&MediaController::Construct_w, this, - channel_manager_->media_engine())); - } - ~MediaController() override { - Close(); - } - - // webrtc::MediaControllerInterface implementation. - void Close() override { - worker_thread_->Invoke(RTC_FROM_HERE, - rtc::Bind(&MediaController::Close_w, this)); - } - webrtc::Call* call_w() override { - RTC_DCHECK(worker_thread_->IsCurrent()); - if (!call_) { - call_.reset(webrtc::Call::Create(call_config_)); - } - return call_.get(); - } - cricket::ChannelManager* channel_manager() const override { - return channel_manager_; - } - const cricket::MediaConfig& config() const override { return media_config_; } - - private: - void Construct_w(cricket::MediaEngineInterface* media_engine) { - RTC_DCHECK(worker_thread_->IsCurrent()); - RTC_DCHECK(media_engine); - call_config_.audio_state = media_engine->GetAudioState(); - call_config_.bitrate_config.min_bitrate_bps = kMinBandwidthBps; - call_config_.bitrate_config.start_bitrate_bps = kStartBandwidthBps; - call_config_.bitrate_config.max_bitrate_bps = kMaxBandwidthBps; - } - void Close_w() { - RTC_DCHECK(worker_thread_->IsCurrent()); - call_.reset(); - } - - rtc::Thread* const worker_thread_; - const cricket::MediaConfig media_config_; - cricket::ChannelManager* const channel_manager_; - webrtc::Call::Config call_config_; - std::unique_ptr call_; - - RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(MediaController); -}; -} // namespace { - -namespace webrtc { - -MediaControllerInterface* MediaControllerInterface::Create( - const cricket::MediaConfig& config, - rtc::Thread* worker_thread, - cricket::ChannelManager* channel_manager, - webrtc::RtcEventLog* event_log) { - return new MediaController(config, worker_thread, channel_manager, event_log); -} -} // namespace webrtc diff --git a/webrtc/pc/mediacontroller.h b/webrtc/pc/mediacontroller.h deleted file mode 100644 index f5a9034918..0000000000 --- a/webrtc/pc/mediacontroller.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2015 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 WEBRTC_PC_MEDIACONTROLLER_H_ -#define WEBRTC_PC_MEDIACONTROLLER_H_ - -#include "webrtc/base/thread.h" - -namespace cricket { -class ChannelManager; -struct MediaConfig; -} // namespace cricket - -namespace webrtc { -class Call; -class VoiceEngine; -class RtcEventLog; - -// The MediaController currently owns shared state between media channels. -// Abstract interface is defined here such that it can be faked/mocked for -// tests, but no other real reason. -class MediaControllerInterface { - public: - // Will never return nullptr. - static MediaControllerInterface* Create( - const cricket::MediaConfig& config, - rtc::Thread* worker_thread, - cricket::ChannelManager* channel_manager, - webrtc::RtcEventLog* event_log); - - virtual ~MediaControllerInterface() {} - virtual void Close() = 0; - virtual webrtc::Call* call_w() = 0; - virtual cricket::ChannelManager* channel_manager() const = 0; - virtual const cricket::MediaConfig& config() const = 0; -}; -} // namespace webrtc - -#endif // WEBRTC_PC_MEDIACONTROLLER_H_ diff --git a/webrtc/pc/peerconnection.cc b/webrtc/pc/peerconnection.cc index a3981039e6..65203fdc73 100644 --- a/webrtc/pc/peerconnection.cc +++ b/webrtc/pc/peerconnection.cc @@ -426,7 +426,10 @@ PeerConnection::~PeerConnection() { session_.reset(nullptr); // port_allocator_ lives on the network thread and should be destroyed there. network_thread()->Invoke(RTC_FROM_HERE, - [this] { port_allocator_.reset(nullptr); }); + [this] { port_allocator_.reset(); }); + // call_ must be destroyed on the worker thread. + factory_->worker_thread()->Invoke(RTC_FROM_HERE, + [this] { call_.reset(); }); } bool PeerConnection::Initialize( @@ -457,11 +460,15 @@ bool PeerConnection::Initialize( return false; } - media_controller_.reset(factory_->CreateMediaController( - configuration.media_config, event_log_.get())); + // Call must be constructed on the worker thread. + factory_->worker_thread()->Invoke( + RTC_FROM_HERE, rtc::Bind(&PeerConnection::CreateCall_w, + this)); session_.reset(new WebRtcSession( - media_controller_.get(), factory_->network_thread(), + call_.get(), factory_->channel_manager(), configuration.media_config, + event_log_.get(), + factory_->network_thread(), factory_->worker_thread(), factory_->signaling_thread(), port_allocator_.get(), std::unique_ptr( @@ -1287,6 +1294,9 @@ void PeerConnection::Close() { RTC_FROM_HERE, rtc::Bind(&cricket::PortAllocator::DiscardCandidatePool, port_allocator_.get())); + + factory_->worker_thread()->Invoke(RTC_FROM_HERE, + [this] { call_.reset(); }); } void PeerConnection::OnSessionStateChange(WebRtcSession* /*session*/, @@ -2314,4 +2324,22 @@ void PeerConnection::StopRtcEventLog_w() { event_log_->StopLogging(); } } + +void PeerConnection::CreateCall_w() { + RTC_DCHECK(!call_); + + const int kMinBandwidthBps = 30000; + const int kStartBandwidthBps = 300000; + const int kMaxBandwidthBps = 2000000; + + webrtc::Call::Config call_config(event_log_.get()); + call_config.audio_state = + factory_->channel_manager() ->media_engine()->GetAudioState(); + call_config.bitrate_config.min_bitrate_bps = kMinBandwidthBps; + call_config.bitrate_config.start_bitrate_bps = kStartBandwidthBps; + call_config.bitrate_config.max_bitrate_bps = kMaxBandwidthBps; + + call_.reset(webrtc::Call::Create(call_config)); +} + } // namespace webrtc diff --git a/webrtc/pc/peerconnection.h b/webrtc/pc/peerconnection.h index 02f56f6c68..23e7e8e58b 100644 --- a/webrtc/pc/peerconnection.h +++ b/webrtc/pc/peerconnection.h @@ -390,6 +390,9 @@ class PeerConnection : public PeerConnectionInterface, // This function should only be called from the worker thread. void StopRtcEventLog_w(); + // Creates the |*call_| object. Must only be called from the worker thread. + void CreateCall_w(); + // Storing the factory as a scoped reference pointer ensures that the memory // in the PeerConnectionFactoryImpl remains available as long as the // PeerConnection is running. It is passed to PeerConnection as a raw pointer. @@ -405,9 +408,8 @@ class PeerConnection : public PeerConnectionInterface, PeerConnectionInterface::RTCConfiguration configuration_; std::unique_ptr port_allocator_; - // The EventLog needs to outlive the media controller. + // The EventLog needs to outlive |call_|. std::unique_ptr event_log_; - std::unique_ptr media_controller_; // One PeerConnection has only one RTCP CNAME. // https://tools.ietf.org/html/draft-ietf-rtcweb-rtp-usage-26#section-4.9 @@ -440,6 +442,7 @@ class PeerConnection : public PeerConnectionInterface, rtc::scoped_refptr>> receivers_; std::unique_ptr session_; + std::unique_ptr call_; std::unique_ptr stats_; rtc::scoped_refptr stats_collector_; }; diff --git a/webrtc/pc/peerconnectionfactory.cc b/webrtc/pc/peerconnectionfactory.cc index 2c3dd11fee..777bac1eb5 100644 --- a/webrtc/pc/peerconnectionfactory.cc +++ b/webrtc/pc/peerconnectionfactory.cc @@ -354,14 +354,6 @@ PeerConnectionFactory::CreateAudioTrack(const std::string& id, return AudioTrackProxy::Create(signaling_thread_, track); } -webrtc::MediaControllerInterface* PeerConnectionFactory::CreateMediaController( - const cricket::MediaConfig& config, - webrtc::RtcEventLog* event_log) const { - RTC_DCHECK(signaling_thread_->IsCurrent()); - return MediaControllerInterface::Create(config, worker_thread_, - channel_manager_.get(), event_log); -} - cricket::TransportController* PeerConnectionFactory::CreateTransportController( cricket::PortAllocator* port_allocator, bool redetermine_role_on_ice_restart) { @@ -371,6 +363,10 @@ cricket::TransportController* PeerConnectionFactory::CreateTransportController( redetermine_role_on_ice_restart, options_.crypto_options); } +cricket::ChannelManager* PeerConnectionFactory::channel_manager() { + return channel_manager_.get(); +} + rtc::Thread* PeerConnectionFactory::signaling_thread() { // This method can be called on a different thread when the factory is // created in CreatePeerConnectionFactory(). diff --git a/webrtc/pc/peerconnectionfactory.h b/webrtc/pc/peerconnectionfactory.h index 04583ce2cd..0bf05bd714 100644 --- a/webrtc/pc/peerconnectionfactory.h +++ b/webrtc/pc/peerconnectionfactory.h @@ -20,7 +20,6 @@ #include "webrtc/base/thread.h" #include "webrtc/base/rtccertificategenerator.h" #include "webrtc/pc/channelmanager.h" -#include "webrtc/pc/mediacontroller.h" namespace rtc { class BasicNetworkManager; @@ -96,12 +95,10 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface { // TODO(ivoc) Remove after Chrome is updated. void StopRtcEventLog() override {} - virtual webrtc::MediaControllerInterface* CreateMediaController( - const cricket::MediaConfig& config, - RtcEventLog* event_log) const; virtual cricket::TransportController* CreateTransportController( cricket::PortAllocator* port_allocator, bool redetermine_role_on_ice_restart); + virtual cricket::ChannelManager* channel_manager(); virtual rtc::Thread* signaling_thread(); virtual rtc::Thread* worker_thread(); virtual rtc::Thread* network_thread(); diff --git a/webrtc/pc/peerconnectioninterface_unittest.cc b/webrtc/pc/peerconnectioninterface_unittest.cc index 7fd76b1738..ae2c873a3f 100644 --- a/webrtc/pc/peerconnectioninterface_unittest.cc +++ b/webrtc/pc/peerconnectioninterface_unittest.cc @@ -645,18 +645,6 @@ class PeerConnectionFactoryForTest : public webrtc::PeerConnectionFactory { webrtc::CreateBuiltinAudioEncoderFactory(), webrtc::CreateBuiltinAudioDecoderFactory()) {} - webrtc::MediaControllerInterface* CreateMediaController( - const cricket::MediaConfig& config, - webrtc::RtcEventLog* event_log) const override { - create_media_controller_called_ = true; - create_media_controller_config_ = config; - - webrtc::MediaControllerInterface* mc = - PeerConnectionFactory::CreateMediaController(config, event_log); - EXPECT_TRUE(mc != nullptr); - return mc; - } - cricket::TransportController* CreateTransportController( cricket::PortAllocator* port_allocator, bool redetermine_role_on_ice_restart) override { @@ -667,9 +655,6 @@ class PeerConnectionFactoryForTest : public webrtc::PeerConnectionFactory { } cricket::TransportController* transport_controller; - // Mutable, so they can be modified in the above const-declared method. - mutable bool create_media_controller_called_ = false; - mutable cricket::MediaConfig create_media_controller_config_; }; class PeerConnectionInterfaceTest : public testing::Test { @@ -3318,16 +3303,14 @@ class PeerConnectionMediaConfigTest : public testing::Test { pcf_ = new rtc::RefCountedObject(); pcf_->Initialize(); } - const cricket::MediaConfig& TestCreatePeerConnection( + const cricket::MediaConfig TestCreatePeerConnection( const PeerConnectionInterface::RTCConfiguration& config, const MediaConstraintsInterface *constraints) { - pcf_->create_media_controller_called_ = false; rtc::scoped_refptr pc(pcf_->CreatePeerConnection( config, constraints, nullptr, nullptr, &observer_)); EXPECT_TRUE(pc.get()); - EXPECT_TRUE(pcf_->create_media_controller_called_); - return pcf_->create_media_controller_config_; + return pc->GetConfiguration().media_config; } rtc::scoped_refptr pcf_; diff --git a/webrtc/pc/rtcstatscollector_unittest.cc b/webrtc/pc/rtcstatscollector_unittest.cc index 8fd00c6178..1940da69da 100644 --- a/webrtc/pc/rtcstatscollector_unittest.cc +++ b/webrtc/pc/rtcstatscollector_unittest.cc @@ -281,12 +281,7 @@ class RTCStatsCollectorTestHelper : public SetSessionDescriptionObserver { std::unique_ptr(media_engine_), worker_thread_, network_thread_)), - media_controller_( - MediaControllerInterface::Create(cricket::MediaConfig(), - worker_thread_, - channel_manager_.get(), - &event_log_)), - session_(media_controller_.get()), + session_(channel_manager_.get(), cricket::MediaConfig()), pc_() { // Default return values for mocks. EXPECT_CALL(pc_, local_streams()).WillRepeatedly(Return(nullptr)); @@ -493,7 +488,6 @@ class RTCStatsCollectorTestHelper : public SetSessionDescriptionObserver { // |media_engine_| is actually owned by |channel_manager_|. cricket::FakeMediaEngine* media_engine_; std::unique_ptr channel_manager_; - std::unique_ptr media_controller_; MockWebRtcSession session_; MockPeerConnection pc_; diff --git a/webrtc/pc/rtpsenderreceiver_unittest.cc b/webrtc/pc/rtpsenderreceiver_unittest.cc index 5ddf6c4c81..994cf3d59e 100644 --- a/webrtc/pc/rtpsenderreceiver_unittest.cc +++ b/webrtc/pc/rtpsenderreceiver_unittest.cc @@ -21,7 +21,6 @@ #include "webrtc/p2p/base/faketransportcontroller.h" #include "webrtc/pc/audiotrack.h" #include "webrtc/pc/channelmanager.h" -#include "webrtc/pc/fakemediacontroller.h" #include "webrtc/pc/localaudiosource.h" #include "webrtc/pc/mediastream.h" #include "webrtc/pc/remoteaudiosource.h" @@ -49,7 +48,6 @@ static const uint32_t kVideoSsrc2 = 100; static const uint32_t kAudioSsrc = 99; static const uint32_t kAudioSsrc2 = 101; static const int kDefaultTimeout = 10000; // 10 seconds. - } // namespace namespace webrtc { @@ -66,7 +64,6 @@ class RtpSenderReceiverTest : public testing::Test, rtc::Thread::Current(), rtc::Thread::Current()), fake_call_(Call::Config(&event_log_)), - fake_media_controller_(&channel_manager_, &fake_call_), local_stream_(MediaStream::Create(kStreamLabel1)) { // Create channels to be used by the RtpSenders and RtpReceivers. channel_manager_.Init(); @@ -75,10 +72,12 @@ class RtpSenderReceiverTest : public testing::Test, fake_transport_controller_.CreateDtlsTransport( cricket::CN_AUDIO, cricket::ICE_CANDIDATE_COMPONENT_RTP); voice_channel_ = channel_manager_.CreateVoiceChannel( - &fake_media_controller_, rtp_transport, nullptr, rtc::Thread::Current(), + &fake_call_, cricket::MediaConfig(), + rtp_transport, nullptr, rtc::Thread::Current(), cricket::CN_AUDIO, srtp_required, cricket::AudioOptions()); video_channel_ = channel_manager_.CreateVideoChannel( - &fake_media_controller_, rtp_transport, nullptr, rtc::Thread::Current(), + &fake_call_, cricket::MediaConfig(), + rtp_transport, nullptr, rtc::Thread::Current(), cricket::CN_VIDEO, srtp_required, cricket::VideoOptions()); voice_channel_->Enable(true); video_channel_->Enable(true); @@ -251,7 +250,6 @@ class RtpSenderReceiverTest : public testing::Test, cricket::FakeTransportController fake_transport_controller_; cricket::ChannelManager channel_manager_; cricket::FakeCall fake_call_; - cricket::FakeMediaController fake_media_controller_; cricket::VoiceChannel* voice_channel_; cricket::VideoChannel* video_channel_; cricket::FakeVoiceMediaChannel* voice_media_channel_; diff --git a/webrtc/pc/statscollector_unittest.cc b/webrtc/pc/statscollector_unittest.cc index c9affa187e..7d75f65302 100644 --- a/webrtc/pc/statscollector_unittest.cc +++ b/webrtc/pc/statscollector_unittest.cc @@ -508,12 +508,8 @@ class StatsCollectorTest : public testing::Test { std::unique_ptr(media_engine_), worker_thread_, network_thread_)), - media_controller_( - webrtc::MediaControllerInterface::Create(cricket::MediaConfig(), - worker_thread_, - channel_manager_.get(), - &event_log_)), - session_(media_controller_.get()) { + + session_(channel_manager_.get(), cricket::MediaConfig()) { // By default, we ignore session GetStats calls. EXPECT_CALL(session_, GetStats(_)).WillRepeatedly(ReturnNull()); // Add default returns for mock classes. @@ -784,7 +780,6 @@ class StatsCollectorTest : public testing::Test { // |media_engine_| is actually owned by |channel_manager_|. cricket::FakeMediaEngine* media_engine_; std::unique_ptr channel_manager_; - std::unique_ptr media_controller_; MockWebRtcSession session_; MockPeerConnection pc_; FakeDataChannelProvider data_channel_provider_; diff --git a/webrtc/pc/test/mock_webrtcsession.h b/webrtc/pc/test/mock_webrtcsession.h index cf4253b1e0..999c692de8 100644 --- a/webrtc/pc/test/mock_webrtcsession.h +++ b/webrtc/pc/test/mock_webrtcsession.h @@ -26,9 +26,12 @@ class MockWebRtcSession : public webrtc::WebRtcSession { // methods don't use any override declarations, and we want to avoid // warnings from -Winconsistent-missing-override. See // http://crbug.com/428099. - explicit MockWebRtcSession(MediaControllerInterface* media_controller) - : WebRtcSession( - media_controller, + explicit MockWebRtcSession(cricket::ChannelManager* channel_manager, + const cricket::MediaConfig& media_config) + : WebRtcSession(nullptr /* Call */, + channel_manager, + media_config, + nullptr, // event_log rtc::Thread::Current(), rtc::Thread::Current(), rtc::Thread::Current(), diff --git a/webrtc/pc/webrtcsession.cc b/webrtc/pc/webrtcsession.cc index c6046e905f..cc424b222e 100644 --- a/webrtc/pc/webrtcsession.cc +++ b/webrtc/pc/webrtcsession.cc @@ -461,7 +461,10 @@ bool CheckForRemoteIceRestart(const SessionDescriptionInterface* old_desc, } WebRtcSession::WebRtcSession( - webrtc::MediaControllerInterface* media_controller, + Call* call, + cricket::ChannelManager* channel_manager, + const cricket::MediaConfig& media_config, + RtcEventLog* event_log, rtc::Thread* network_thread, rtc::Thread* worker_thread, rtc::Thread* signaling_thread, @@ -477,8 +480,10 @@ WebRtcSession::WebRtcSession( sid_(rtc::ToString(rtc::CreateRandomId64() & LLONG_MAX)), transport_controller_(std::move(transport_controller)), sctp_factory_(std::move(sctp_factory)), - media_controller_(media_controller), - channel_manager_(media_controller_->channel_manager()), + media_config_(media_config), + event_log_(event_log), + call_(call), + channel_manager_(channel_manager), ice_observer_(NULL), ice_connection_state_(PeerConnectionInterface::kIceConnectionNew), ice_connection_receiving_(true), @@ -630,7 +635,6 @@ void WebRtcSession::Close() { RTC_DCHECK(!video_channel_); RTC_DCHECK(!rtp_data_channel_); RTC_DCHECK(!sctp_transport_); - media_controller_->Close(); } cricket::BaseChannel* WebRtcSession::GetChannel( @@ -1757,7 +1761,7 @@ bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content, } voice_channel_.reset(channel_manager_->CreateVoiceChannel( - media_controller_, rtp_dtls_transport, rtcp_dtls_transport, + call_, media_config_, rtp_dtls_transport, rtcp_dtls_transport, transport_controller_->signaling_thread(), content->name, SrtpRequired(), audio_options_)); if (!voice_channel_) { @@ -1799,7 +1803,7 @@ bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content, } video_channel_.reset(channel_manager_->CreateVideoChannel( - media_controller_, rtp_dtls_transport, rtcp_dtls_transport, + call_, media_config_, rtp_dtls_transport, rtcp_dtls_transport, transport_controller_->signaling_thread(), content->name, SrtpRequired(), video_options_)); @@ -1864,7 +1868,7 @@ bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content, } rtp_data_channel_.reset(channel_manager_->CreateRtpDataChannel( - media_controller_, rtp_dtls_transport, rtcp_dtls_transport, + media_config_, rtp_dtls_transport, rtcp_dtls_transport, transport_controller_->signaling_thread(), content->name, SrtpRequired())); @@ -2313,7 +2317,7 @@ void WebRtcSession::ReportNegotiatedCiphers( void WebRtcSession::OnSentPacket_w(const rtc::SentPacket& sent_packet) { RTC_DCHECK(worker_thread()->IsCurrent()); - media_controller_->call_w()->OnSentPacket(sent_packet); + call_->OnSentPacket(sent_packet); } const std::string WebRtcSession::GetTransportName( diff --git a/webrtc/pc/webrtcsession.h b/webrtc/pc/webrtcsession.h index a1339cbd61..dd8398e933 100644 --- a/webrtc/pc/webrtcsession.h +++ b/webrtc/pc/webrtcsession.h @@ -27,7 +27,6 @@ #include "webrtc/p2p/base/candidate.h" #include "webrtc/p2p/base/transportcontroller.h" #include "webrtc/pc/datachannel.h" -#include "webrtc/pc/mediacontroller.h" #include "webrtc/pc/mediasession.h" #ifdef HAVE_QUIC @@ -55,6 +54,7 @@ namespace webrtc { class IceRestartAnswerLatch; class JsepIceCandidate; class MediaStreamSignaling; +class RtcEventLog; class WebRtcSessionDescriptionFactory; extern const char kBundleWithoutRtcpMux[]; @@ -159,7 +159,10 @@ class WebRtcSession : // |sctp_factory| may be null, in which case SCTP is treated as unsupported. WebRtcSession( - webrtc::MediaControllerInterface* media_controller, + Call* call, + cricket::ChannelManager* channel_manager, + const cricket::MediaConfig& media_config, + RtcEventLog* event_log, rtc::Thread* network_thread, rtc::Thread* worker_thread, rtc::Thread* signaling_thread, @@ -559,7 +562,9 @@ class WebRtcSession : const std::unique_ptr transport_controller_; const std::unique_ptr sctp_factory_; - MediaControllerInterface* media_controller_; + const cricket::MediaConfig media_config_; + RtcEventLog* event_log_; + Call* call_; std::unique_ptr voice_channel_; std::unique_ptr video_channel_; // |rtp_data_channel_| is used if in RTP data channel mode, |sctp_transport_| diff --git a/webrtc/pc/webrtcsession_unittest.cc b/webrtc/pc/webrtcsession_unittest.cc index 757e14e049..1a5f47da25 100644 --- a/webrtc/pc/webrtcsession_unittest.cc +++ b/webrtc/pc/webrtcsession_unittest.cc @@ -41,7 +41,6 @@ #include "webrtc/p2p/client/basicportallocator.h" #include "webrtc/pc/audiotrack.h" #include "webrtc/pc/channelmanager.h" -#include "webrtc/pc/fakemediacontroller.h" #include "webrtc/pc/mediasession.h" #include "webrtc/pc/peerconnection.h" #include "webrtc/pc/sctputils.h" @@ -255,7 +254,10 @@ class FakeSctpTransportFactory : public cricket::SctpTransportInternalFactory { class WebRtcSessionForTest : public webrtc::WebRtcSession { public: WebRtcSessionForTest( - webrtc::MediaControllerInterface* media_controller, + webrtc::Call* fake_call, + cricket::ChannelManager* channel_manager, + const cricket::MediaConfig& media_config, + webrtc::RtcEventLog* event_log, rtc::Thread* network_thread, rtc::Thread* worker_thread, rtc::Thread* signaling_thread, @@ -263,7 +265,7 @@ class WebRtcSessionForTest : public webrtc::WebRtcSession { webrtc::IceObserver* ice_observer, std::unique_ptr transport_controller, std::unique_ptr sctp_factory) - : WebRtcSession(media_controller, + : WebRtcSession(fake_call, channel_manager, media_config, event_log, network_thread, worker_thread, signaling_thread, @@ -375,11 +377,6 @@ class WebRtcSessionTest std::unique_ptr(data_engine_), rtc::Thread::Current())), fake_call_(webrtc::Call::Config(&event_log_)), - media_controller_( - webrtc::MediaControllerInterface::Create(cricket::MediaConfig(), - rtc::Thread::Current(), - channel_manager_.get(), - &event_log_)), tdesc_factory_(new cricket::TransportDescriptionFactory()), desc_factory_( new cricket::MediaSessionDescriptionFactory(channel_manager_.get(), @@ -424,8 +421,9 @@ class WebRtcSessionTest const rtc::CryptoOptions& crypto_options) { ASSERT_TRUE(session_.get() == NULL); fake_sctp_transport_factory_ = new FakeSctpTransportFactory(); - session_.reset(new WebRtcSessionForTest( - media_controller_.get(), rtc::Thread::Current(), rtc::Thread::Current(), + session_.reset(new WebRtcSessionForTest(&fake_call_, + channel_manager_.get(), cricket::MediaConfig(), &event_log_, + rtc::Thread::Current(), rtc::Thread::Current(), rtc::Thread::Current(), allocator_.get(), &observer_, std::unique_ptr( new cricket::TransportController( @@ -1380,8 +1378,6 @@ class WebRtcSessionTest } void TestPacketOptions() { - media_controller_.reset( - new cricket::FakeMediaController(channel_manager_.get(), &fake_call_)); LoopbackNetworkConfiguration config; LoopbackNetworkManager loopback_network_manager(this, config); @@ -1515,7 +1511,6 @@ class WebRtcSessionTest FakeSctpTransportFactory* fake_sctp_transport_factory_ = nullptr; std::unique_ptr channel_manager_; cricket::FakeCall fake_call_; - std::unique_ptr media_controller_; std::unique_ptr tdesc_factory_; std::unique_ptr desc_factory_; std::unique_ptr pss_;