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

Side by Side Diff: webrtc/video/call.cc

Issue 1325263002: Make LoadObserver settable per video send stream. Gives client flexibility and makes the implementa… (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 years, 3 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/call.h ('k') | webrtc/video/call_perf_tests.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 (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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
(...skipping 23 matching lines...) Expand all
34 #include "webrtc/video/audio_receive_stream.h" 34 #include "webrtc/video/audio_receive_stream.h"
35 #include "webrtc/video/video_receive_stream.h" 35 #include "webrtc/video/video_receive_stream.h"
36 #include "webrtc/video/video_send_stream.h" 36 #include "webrtc/video/video_send_stream.h"
37 37
38 namespace webrtc { 38 namespace webrtc {
39 39
40 const int Call::Config::kDefaultStartBitrateBps = 300000; 40 const int Call::Config::kDefaultStartBitrateBps = 300000;
41 41
42 namespace internal { 42 namespace internal {
43 43
44 class CpuOveruseObserverProxy : public webrtc::CpuOveruseObserver {
45 public:
46 explicit CpuOveruseObserverProxy(LoadObserver* overuse_callback)
47 : overuse_callback_(overuse_callback) {
48 DCHECK(overuse_callback != nullptr);
49 }
50
51 virtual ~CpuOveruseObserverProxy() {}
52
53 void OveruseDetected() override {
54 rtc::CritScope lock(&crit_);
55 overuse_callback_->OnLoadUpdate(LoadObserver::kOveruse);
56 }
57
58 void NormalUsage() override {
59 rtc::CritScope lock(&crit_);
60 overuse_callback_->OnLoadUpdate(LoadObserver::kUnderuse);
61 }
62
63 private:
64 rtc::CriticalSection crit_;
65 LoadObserver* overuse_callback_ GUARDED_BY(crit_);
66 };
67
68 class Call : public webrtc::Call, public PacketReceiver { 44 class Call : public webrtc::Call, public PacketReceiver {
69 public: 45 public:
70 explicit Call(const Call::Config& config); 46 explicit Call(const Call::Config& config);
71 virtual ~Call(); 47 virtual ~Call();
72 48
73 PacketReceiver* Receiver() override; 49 PacketReceiver* Receiver() override;
74 50
75 webrtc::AudioSendStream* CreateAudioSendStream( 51 webrtc::AudioSendStream* CreateAudioSendStream(
76 const webrtc::AudioSendStream::Config& config) override; 52 const webrtc::AudioSendStream::Config& config) override;
77 void DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) override; 53 void DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) override;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 GUARDED_BY(receive_crit_); 107 GUARDED_BY(receive_crit_);
132 std::set<VideoReceiveStream*> video_receive_streams_ 108 std::set<VideoReceiveStream*> video_receive_streams_
133 GUARDED_BY(receive_crit_); 109 GUARDED_BY(receive_crit_);
134 std::map<std::string, AudioReceiveStream*> sync_stream_mapping_ 110 std::map<std::string, AudioReceiveStream*> sync_stream_mapping_
135 GUARDED_BY(receive_crit_); 111 GUARDED_BY(receive_crit_);
136 112
137 rtc::scoped_ptr<RWLockWrapper> send_crit_; 113 rtc::scoped_ptr<RWLockWrapper> send_crit_;
138 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_); 114 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_);
139 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_); 115 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_);
140 116
141 rtc::scoped_ptr<CpuOveruseObserverProxy> overuse_observer_proxy_;
142
143 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_; 117 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_;
144 118
145 DISALLOW_COPY_AND_ASSIGN(Call); 119 DISALLOW_COPY_AND_ASSIGN(Call);
146 }; 120 };
147 } // namespace internal 121 } // namespace internal
148 122
149 Call* Call::Create(const Call::Config& config) { 123 Call* Call::Create(const Call::Config& config) {
150 return new internal::Call(config); 124 return new internal::Call(config);
151 } 125 }
152 126
(...skipping 12 matching lines...) Expand all
165 DCHECK_GE(config.bitrate_config.start_bitrate_bps, 139 DCHECK_GE(config.bitrate_config.start_bitrate_bps,
166 config.bitrate_config.min_bitrate_bps); 140 config.bitrate_config.min_bitrate_bps);
167 if (config.bitrate_config.max_bitrate_bps != -1) { 141 if (config.bitrate_config.max_bitrate_bps != -1) {
168 DCHECK_GE(config.bitrate_config.max_bitrate_bps, 142 DCHECK_GE(config.bitrate_config.max_bitrate_bps,
169 config.bitrate_config.start_bitrate_bps); 143 config.bitrate_config.start_bitrate_bps);
170 } 144 }
171 145
172 Trace::CreateTrace(); 146 Trace::CreateTrace();
173 module_process_thread_->Start(); 147 module_process_thread_->Start();
174 148
175 if (config.overuse_callback) {
176 overuse_observer_proxy_.reset(
177 new CpuOveruseObserverProxy(config.overuse_callback));
178 }
179
180 SetBitrateControllerConfig(config_.bitrate_config); 149 SetBitrateControllerConfig(config_.bitrate_config);
181 } 150 }
182 151
183 Call::~Call() { 152 Call::~Call() {
184 CHECK_EQ(0u, video_send_ssrcs_.size()); 153 CHECK_EQ(0u, video_send_ssrcs_.size());
185 CHECK_EQ(0u, video_send_streams_.size()); 154 CHECK_EQ(0u, video_send_streams_.size());
186 CHECK_EQ(0u, audio_receive_ssrcs_.size()); 155 CHECK_EQ(0u, audio_receive_ssrcs_.size());
187 CHECK_EQ(0u, video_receive_ssrcs_.size()); 156 CHECK_EQ(0u, video_receive_ssrcs_.size());
188 CHECK_EQ(0u, video_receive_streams_.size()); 157 CHECK_EQ(0u, video_receive_streams_.size());
189 158
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 210
242 webrtc::VideoSendStream* Call::CreateVideoSendStream( 211 webrtc::VideoSendStream* Call::CreateVideoSendStream(
243 const webrtc::VideoSendStream::Config& config, 212 const webrtc::VideoSendStream::Config& config,
244 const VideoEncoderConfig& encoder_config) { 213 const VideoEncoderConfig& encoder_config) {
245 TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream"); 214 TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream");
246 LOG(LS_INFO) << "CreateVideoSendStream: " << config.ToString(); 215 LOG(LS_INFO) << "CreateVideoSendStream: " << config.ToString();
247 DCHECK(!config.rtp.ssrcs.empty()); 216 DCHECK(!config.rtp.ssrcs.empty());
248 217
249 // TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if 218 // TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if
250 // the call has already started. 219 // the call has already started.
251 VideoSendStream* send_stream = new VideoSendStream( 220 VideoSendStream* send_stream = new VideoSendStream(num_cpu_cores_,
252 overuse_observer_proxy_.get(), num_cpu_cores_,
253 module_process_thread_.get(), channel_group_.get(), 221 module_process_thread_.get(), channel_group_.get(),
254 rtc::AtomicOps::Increment(&next_channel_id_), config, encoder_config, 222 rtc::AtomicOps::Increment(&next_channel_id_), config, encoder_config,
255 suspended_video_send_ssrcs_); 223 suspended_video_send_ssrcs_);
256 224
257 // This needs to be taken before send_crit_ as both locks need to be held 225 // This needs to be taken before send_crit_ as both locks need to be held
258 // while changing network state. 226 // while changing network state.
259 rtc::CritScope lock(&network_enabled_crit_); 227 rtc::CritScope lock(&network_enabled_crit_);
260 WriteLockScoped write_lock(*send_crit_); 228 WriteLockScoped write_lock(*send_crit_);
261 for (uint32_t ssrc : config.rtp.ssrcs) { 229 for (uint32_t ssrc : config.rtp.ssrcs) {
262 DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); 230 DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end());
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 const uint8_t* packet, 504 const uint8_t* packet,
537 size_t length) { 505 size_t length) {
538 if (RtpHeaderParser::IsRtcp(packet, length)) 506 if (RtpHeaderParser::IsRtcp(packet, length))
539 return DeliverRtcp(media_type, packet, length); 507 return DeliverRtcp(media_type, packet, length);
540 508
541 return DeliverRtp(media_type, packet, length); 509 return DeliverRtp(media_type, packet, length);
542 } 510 }
543 511
544 } // namespace internal 512 } // namespace internal
545 } // namespace webrtc 513 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/call.h ('k') | webrtc/video/call_perf_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698