Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Unified Diff: webrtc/api/mediacontroller.cc

Issue 1713043002: Late initialize MediaController, for less resource i.e. ProcessThread, usage by PeerConnection. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Comment Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/api/mediacontroller.h ('k') | webrtc/api/statscollector.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/mediacontroller.cc
diff --git a/webrtc/api/mediacontroller.cc b/webrtc/api/mediacontroller.cc
index 341c013ed153c3d29efd03eb6b93a4a69460f30b..be42c201e5b84f85c0d79b5c98889cce64c88666 100644
--- a/webrtc/api/mediacontroller.cc
+++ b/webrtc/api/mediacontroller.cc
@@ -25,50 +25,55 @@ const int kMaxBandwidthBps = 2000000;
class MediaController : public webrtc::MediaControllerInterface,
public sigslot::has_slots<> {
public:
- MediaController(const cricket::MediaConfig& config,
+ MediaController(const cricket::MediaConfig& media_config,
rtc::Thread* worker_thread,
cricket::ChannelManager* channel_manager)
: worker_thread_(worker_thread),
- config_(config),
+ media_config_(media_config),
channel_manager_(channel_manager) {
- RTC_DCHECK(nullptr != worker_thread);
+ RTC_DCHECK(worker_thread);
worker_thread_->Invoke<void>(
rtc::Bind(&MediaController::Construct_w, this,
channel_manager_->media_engine()));
}
~MediaController() override {
- worker_thread_->Invoke<void>(rtc::Bind(&MediaController::Destruct_w, this));
+ Close();
+ }
+ void Close() override {
tommi 2016/03/01 09:57:41 nit: there's sometimes an empty line between metho
the sun 2016/03/01 10:52:29 I've now formatted like you would normally format
+ worker_thread_->Invoke<void>(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 config_; }
+ 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);
- webrtc::Call::Config config;
- config.audio_state = media_engine->GetAudioState();
- config.bitrate_config.min_bitrate_bps = kMinBandwidthBps;
- config.bitrate_config.start_bitrate_bps = kStartBandwidthBps;
- config.bitrate_config.max_bitrate_bps = kMaxBandwidthBps;
- call_.reset(webrtc::Call::Create(config));
+ 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 Destruct_w() {
+ void Close_w() {
RTC_DCHECK(worker_thread_->IsCurrent());
call_.reset();
}
rtc::Thread* const worker_thread_;
- const cricket::MediaConfig config_;
+ const cricket::MediaConfig media_config_;
cricket::ChannelManager* const channel_manager_;
+ webrtc::Call::Config call_config_;
rtc::scoped_ptr<webrtc::Call> call_;
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(MediaController);
« no previous file with comments | « webrtc/api/mediacontroller.h ('k') | webrtc/api/statscollector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698