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

Side by Side Diff: talk/app/webrtc/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 Per's comments. 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
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2015 Google Inc. 3 * Copyright 2015 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 13 matching lines...) Expand all
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28 #include "talk/app/webrtc/mediacontroller.h" 28 #include "talk/app/webrtc/mediacontroller.h"
29 29
30 #include "talk/session/media/channelmanager.h" 30 #include "talk/session/media/channelmanager.h"
31 #include "webrtc/base/bind.h" 31 #include "webrtc/base/bind.h"
32 #include "webrtc/base/checks.h" 32 #include "webrtc/base/checks.h"
33 #include "webrtc/call.h" 33 #include "webrtc/call.h"
34 #include "webrtc/media/base/mediachannel.h"
34 35
35 namespace { 36 namespace {
36 37
37 const int kMinBandwidthBps = 30000; 38 const int kMinBandwidthBps = 30000;
38 const int kStartBandwidthBps = 300000; 39 const int kStartBandwidthBps = 300000;
39 const int kMaxBandwidthBps = 2000000; 40 const int kMaxBandwidthBps = 2000000;
40 41
41 class MediaController : public webrtc::MediaControllerInterface, 42 class MediaController : public webrtc::MediaControllerInterface,
42 public sigslot::has_slots<> { 43 public sigslot::has_slots<> {
43 public: 44 public:
44 MediaController(rtc::Thread* worker_thread, 45 MediaController(const cricket::MediaConfig& config,
46 rtc::Thread* worker_thread,
45 cricket::ChannelManager* channel_manager) 47 cricket::ChannelManager* channel_manager)
46 : worker_thread_(worker_thread), channel_manager_(channel_manager) { 48 : worker_thread_(worker_thread),
49 config_(config),
50 channel_manager_(channel_manager) {
47 RTC_DCHECK(nullptr != worker_thread); 51 RTC_DCHECK(nullptr != worker_thread);
48 worker_thread_->Invoke<void>( 52 worker_thread_->Invoke<void>(
49 rtc::Bind(&MediaController::Construct_w, this, 53 rtc::Bind(&MediaController::Construct_w, this,
50 channel_manager_->media_engine())); 54 channel_manager_->media_engine()));
51 } 55 }
52 ~MediaController() override { 56 ~MediaController() override {
53 worker_thread_->Invoke<void>(rtc::Bind(&MediaController::Destruct_w, this)); 57 worker_thread_->Invoke<void>(rtc::Bind(&MediaController::Destruct_w, this));
54 } 58 }
55 59
56 webrtc::Call* call_w() override { 60 webrtc::Call* call_w() override {
57 RTC_DCHECK(worker_thread_->IsCurrent()); 61 RTC_DCHECK(worker_thread_->IsCurrent());
58 return call_.get(); 62 return call_.get();
59 } 63 }
60 64
61 cricket::ChannelManager* channel_manager() const override { 65 cricket::ChannelManager* channel_manager() const override {
62 return channel_manager_; 66 return channel_manager_;
63 } 67 }
68 const cricket::MediaConfig& config() const override {
69 return config_;
70 }
64 71
65 private: 72 private:
66 void Construct_w(cricket::MediaEngineInterface* media_engine) { 73 void Construct_w(cricket::MediaEngineInterface* media_engine) {
67 RTC_DCHECK(worker_thread_->IsCurrent()); 74 RTC_DCHECK(worker_thread_->IsCurrent());
68 RTC_DCHECK(media_engine); 75 RTC_DCHECK(media_engine);
69 webrtc::Call::Config config; 76 webrtc::Call::Config config;
70 config.audio_state = media_engine->GetAudioState(); 77 config.audio_state = media_engine->GetAudioState();
71 config.bitrate_config.min_bitrate_bps = kMinBandwidthBps; 78 config.bitrate_config.min_bitrate_bps = kMinBandwidthBps;
72 config.bitrate_config.start_bitrate_bps = kStartBandwidthBps; 79 config.bitrate_config.start_bitrate_bps = kStartBandwidthBps;
73 config.bitrate_config.max_bitrate_bps = kMaxBandwidthBps; 80 config.bitrate_config.max_bitrate_bps = kMaxBandwidthBps;
74 call_.reset(webrtc::Call::Create(config)); 81 call_.reset(webrtc::Call::Create(config));
75 } 82 }
76 void Destruct_w() { 83 void Destruct_w() {
77 RTC_DCHECK(worker_thread_->IsCurrent()); 84 RTC_DCHECK(worker_thread_->IsCurrent());
78 call_.reset(); 85 call_.reset();
79 } 86 }
80 87
81 rtc::Thread* const worker_thread_; 88 rtc::Thread* const worker_thread_;
89 const cricket::MediaConfig config_;
82 cricket::ChannelManager* const channel_manager_; 90 cricket::ChannelManager* const channel_manager_;
83 rtc::scoped_ptr<webrtc::Call> call_; 91 rtc::scoped_ptr<webrtc::Call> call_;
84 92
85 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(MediaController); 93 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(MediaController);
86 }; 94 };
87 } // namespace { 95 } // namespace {
88 96
89 namespace webrtc { 97 namespace webrtc {
90 98
91 MediaControllerInterface* MediaControllerInterface::Create( 99 MediaControllerInterface* MediaControllerInterface::Create(
100 const cricket::MediaConfig& config,
92 rtc::Thread* worker_thread, 101 rtc::Thread* worker_thread,
93 cricket::ChannelManager* channel_manager) { 102 cricket::ChannelManager* channel_manager) {
94 return new MediaController(worker_thread, channel_manager); 103 return new MediaController(config, worker_thread, channel_manager);
95 } 104 }
96 } // namespace webrtc 105 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698