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

Side by Side Diff: webrtc/api/mediacontroller.cc

Issue 1670153003: Introduce struct MediaConfig, with construction-time settings. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed test nit; use reference. 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 unified diff | Download patch
« no previous file with comments | « webrtc/api/mediacontroller.h ('k') | webrtc/api/peerconnection.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/api/mediacontroller.h" 11 #include "webrtc/api/mediacontroller.h"
12 12
13 #include "webrtc/base/bind.h" 13 #include "webrtc/base/bind.h"
14 #include "webrtc/base/checks.h" 14 #include "webrtc/base/checks.h"
15 #include "webrtc/call.h" 15 #include "webrtc/call.h"
16 #include "webrtc/pc/channelmanager.h" 16 #include "webrtc/pc/channelmanager.h"
17 #include "webrtc/media/base/mediachannel.h"
17 18
18 namespace { 19 namespace {
19 20
20 const int kMinBandwidthBps = 30000; 21 const int kMinBandwidthBps = 30000;
21 const int kStartBandwidthBps = 300000; 22 const int kStartBandwidthBps = 300000;
22 const int kMaxBandwidthBps = 2000000; 23 const int kMaxBandwidthBps = 2000000;
23 24
24 class MediaController : public webrtc::MediaControllerInterface, 25 class MediaController : public webrtc::MediaControllerInterface,
25 public sigslot::has_slots<> { 26 public sigslot::has_slots<> {
26 public: 27 public:
27 MediaController(rtc::Thread* worker_thread, 28 MediaController(const cricket::MediaConfig& config,
29 rtc::Thread* worker_thread,
28 cricket::ChannelManager* channel_manager) 30 cricket::ChannelManager* channel_manager)
29 : worker_thread_(worker_thread), channel_manager_(channel_manager) { 31 : worker_thread_(worker_thread),
32 config_(config),
33 channel_manager_(channel_manager) {
30 RTC_DCHECK(nullptr != worker_thread); 34 RTC_DCHECK(nullptr != worker_thread);
31 worker_thread_->Invoke<void>( 35 worker_thread_->Invoke<void>(
32 rtc::Bind(&MediaController::Construct_w, this, 36 rtc::Bind(&MediaController::Construct_w, this,
33 channel_manager_->media_engine())); 37 channel_manager_->media_engine()));
34 } 38 }
35 ~MediaController() override { 39 ~MediaController() override {
36 worker_thread_->Invoke<void>(rtc::Bind(&MediaController::Destruct_w, this)); 40 worker_thread_->Invoke<void>(rtc::Bind(&MediaController::Destruct_w, this));
37 } 41 }
38 42
39 webrtc::Call* call_w() override { 43 webrtc::Call* call_w() override {
40 RTC_DCHECK(worker_thread_->IsCurrent()); 44 RTC_DCHECK(worker_thread_->IsCurrent());
41 return call_.get(); 45 return call_.get();
42 } 46 }
43 47
44 cricket::ChannelManager* channel_manager() const override { 48 cricket::ChannelManager* channel_manager() const override {
45 return channel_manager_; 49 return channel_manager_;
46 } 50 }
51 const cricket::MediaConfig& config() const override { return config_; }
47 52
48 private: 53 private:
49 void Construct_w(cricket::MediaEngineInterface* media_engine) { 54 void Construct_w(cricket::MediaEngineInterface* media_engine) {
50 RTC_DCHECK(worker_thread_->IsCurrent()); 55 RTC_DCHECK(worker_thread_->IsCurrent());
51 RTC_DCHECK(media_engine); 56 RTC_DCHECK(media_engine);
52 webrtc::Call::Config config; 57 webrtc::Call::Config config;
53 config.audio_state = media_engine->GetAudioState(); 58 config.audio_state = media_engine->GetAudioState();
54 config.bitrate_config.min_bitrate_bps = kMinBandwidthBps; 59 config.bitrate_config.min_bitrate_bps = kMinBandwidthBps;
55 config.bitrate_config.start_bitrate_bps = kStartBandwidthBps; 60 config.bitrate_config.start_bitrate_bps = kStartBandwidthBps;
56 config.bitrate_config.max_bitrate_bps = kMaxBandwidthBps; 61 config.bitrate_config.max_bitrate_bps = kMaxBandwidthBps;
57 call_.reset(webrtc::Call::Create(config)); 62 call_.reset(webrtc::Call::Create(config));
58 } 63 }
59 void Destruct_w() { 64 void Destruct_w() {
60 RTC_DCHECK(worker_thread_->IsCurrent()); 65 RTC_DCHECK(worker_thread_->IsCurrent());
61 call_.reset(); 66 call_.reset();
62 } 67 }
63 68
64 rtc::Thread* const worker_thread_; 69 rtc::Thread* const worker_thread_;
70 const cricket::MediaConfig config_;
65 cricket::ChannelManager* const channel_manager_; 71 cricket::ChannelManager* const channel_manager_;
66 rtc::scoped_ptr<webrtc::Call> call_; 72 rtc::scoped_ptr<webrtc::Call> call_;
67 73
68 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(MediaController); 74 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(MediaController);
69 }; 75 };
70 } // namespace { 76 } // namespace {
71 77
72 namespace webrtc { 78 namespace webrtc {
73 79
74 MediaControllerInterface* MediaControllerInterface::Create( 80 MediaControllerInterface* MediaControllerInterface::Create(
81 const cricket::MediaConfig& config,
75 rtc::Thread* worker_thread, 82 rtc::Thread* worker_thread,
76 cricket::ChannelManager* channel_manager) { 83 cricket::ChannelManager* channel_manager) {
77 return new MediaController(worker_thread, channel_manager); 84 return new MediaController(config, worker_thread, channel_manager);
78 } 85 }
79 } // namespace webrtc 86 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/api/mediacontroller.h ('k') | webrtc/api/peerconnection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698