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

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

Issue 1335923002: Add RTC_ prefix to (D)CHECKs and related macros. (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/video/bitrate_estimator_tests.cc ('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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 Call::Call(const Call::Config& config) 137 Call::Call(const Call::Config& config)
138 : num_cpu_cores_(CpuInfo::DetectNumberOfCores()), 138 : num_cpu_cores_(CpuInfo::DetectNumberOfCores()),
139 module_process_thread_(ProcessThread::Create("ModuleProcessThread")), 139 module_process_thread_(ProcessThread::Create("ModuleProcessThread")),
140 channel_group_(new ChannelGroup(module_process_thread_.get())), 140 channel_group_(new ChannelGroup(module_process_thread_.get())),
141 next_channel_id_(0), 141 next_channel_id_(0),
142 config_(config), 142 config_(config),
143 network_enabled_(true), 143 network_enabled_(true),
144 receive_crit_(RWLockWrapper::CreateRWLock()), 144 receive_crit_(RWLockWrapper::CreateRWLock()),
145 send_crit_(RWLockWrapper::CreateRWLock()), 145 send_crit_(RWLockWrapper::CreateRWLock()),
146 event_log_(nullptr) { 146 event_log_(nullptr) {
147 DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); 147 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0);
148 DCHECK_GE(config.bitrate_config.start_bitrate_bps, 148 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps,
149 config.bitrate_config.min_bitrate_bps); 149 config.bitrate_config.min_bitrate_bps);
150 if (config.bitrate_config.max_bitrate_bps != -1) { 150 if (config.bitrate_config.max_bitrate_bps != -1) {
151 DCHECK_GE(config.bitrate_config.max_bitrate_bps, 151 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps,
152 config.bitrate_config.start_bitrate_bps); 152 config.bitrate_config.start_bitrate_bps);
153 } 153 }
154 if (config.voice_engine) { 154 if (config.voice_engine) {
155 VoECodec* voe_codec = VoECodec::GetInterface(config.voice_engine); 155 VoECodec* voe_codec = VoECodec::GetInterface(config.voice_engine);
156 if (voe_codec) { 156 if (voe_codec) {
157 event_log_ = voe_codec->GetEventLog(); 157 event_log_ = voe_codec->GetEventLog();
158 voe_codec->Release(); 158 voe_codec->Release();
159 } 159 }
160 } 160 }
161 161
162 Trace::CreateTrace(); 162 Trace::CreateTrace();
163 module_process_thread_->Start(); 163 module_process_thread_->Start();
164 164
165 SetBitrateControllerConfig(config_.bitrate_config); 165 SetBitrateControllerConfig(config_.bitrate_config);
166 } 166 }
167 167
168 Call::~Call() { 168 Call::~Call() {
169 CHECK_EQ(0u, video_send_ssrcs_.size()); 169 RTC_CHECK_EQ(0u, video_send_ssrcs_.size());
170 CHECK_EQ(0u, video_send_streams_.size()); 170 RTC_CHECK_EQ(0u, video_send_streams_.size());
171 CHECK_EQ(0u, audio_receive_ssrcs_.size()); 171 RTC_CHECK_EQ(0u, audio_receive_ssrcs_.size());
172 CHECK_EQ(0u, video_receive_ssrcs_.size()); 172 RTC_CHECK_EQ(0u, video_receive_ssrcs_.size());
173 CHECK_EQ(0u, video_receive_streams_.size()); 173 RTC_CHECK_EQ(0u, video_receive_streams_.size());
174 174
175 module_process_thread_->Stop(); 175 module_process_thread_->Stop();
176 Trace::ReturnTrace(); 176 Trace::ReturnTrace();
177 } 177 }
178 178
179 PacketReceiver* Call::Receiver() { return this; } 179 PacketReceiver* Call::Receiver() { return this; }
180 180
181 webrtc::AudioSendStream* Call::CreateAudioSendStream( 181 webrtc::AudioSendStream* Call::CreateAudioSendStream(
182 const webrtc::AudioSendStream::Config& config) { 182 const webrtc::AudioSendStream::Config& config) {
183 return nullptr; 183 return nullptr;
184 } 184 }
185 185
186 void Call::DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) { 186 void Call::DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) {
187 } 187 }
188 188
189 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( 189 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream(
190 const webrtc::AudioReceiveStream::Config& config) { 190 const webrtc::AudioReceiveStream::Config& config) {
191 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); 191 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream");
192 LOG(LS_INFO) << "CreateAudioReceiveStream: " << config.ToString(); 192 LOG(LS_INFO) << "CreateAudioReceiveStream: " << config.ToString();
193 AudioReceiveStream* receive_stream = new AudioReceiveStream( 193 AudioReceiveStream* receive_stream = new AudioReceiveStream(
194 channel_group_->GetRemoteBitrateEstimator(), config); 194 channel_group_->GetRemoteBitrateEstimator(), config);
195 { 195 {
196 WriteLockScoped write_lock(*receive_crit_); 196 WriteLockScoped write_lock(*receive_crit_);
197 DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) == 197 RTC_DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) ==
198 audio_receive_ssrcs_.end()); 198 audio_receive_ssrcs_.end());
199 audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; 199 audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream;
200 ConfigureSync(config.sync_group); 200 ConfigureSync(config.sync_group);
201 } 201 }
202 return receive_stream; 202 return receive_stream;
203 } 203 }
204 204
205 void Call::DestroyAudioReceiveStream( 205 void Call::DestroyAudioReceiveStream(
206 webrtc::AudioReceiveStream* receive_stream) { 206 webrtc::AudioReceiveStream* receive_stream) {
207 TRACE_EVENT0("webrtc", "Call::DestroyAudioReceiveStream"); 207 TRACE_EVENT0("webrtc", "Call::DestroyAudioReceiveStream");
208 DCHECK(receive_stream != nullptr); 208 RTC_DCHECK(receive_stream != nullptr);
209 AudioReceiveStream* audio_receive_stream = 209 AudioReceiveStream* audio_receive_stream =
210 static_cast<AudioReceiveStream*>(receive_stream); 210 static_cast<AudioReceiveStream*>(receive_stream);
211 { 211 {
212 WriteLockScoped write_lock(*receive_crit_); 212 WriteLockScoped write_lock(*receive_crit_);
213 size_t num_deleted = audio_receive_ssrcs_.erase( 213 size_t num_deleted = audio_receive_ssrcs_.erase(
214 audio_receive_stream->config().rtp.remote_ssrc); 214 audio_receive_stream->config().rtp.remote_ssrc);
215 DCHECK(num_deleted == 1); 215 RTC_DCHECK(num_deleted == 1);
216 const std::string& sync_group = audio_receive_stream->config().sync_group; 216 const std::string& sync_group = audio_receive_stream->config().sync_group;
217 const auto it = sync_stream_mapping_.find(sync_group); 217 const auto it = sync_stream_mapping_.find(sync_group);
218 if (it != sync_stream_mapping_.end() && 218 if (it != sync_stream_mapping_.end() &&
219 it->second == audio_receive_stream) { 219 it->second == audio_receive_stream) {
220 sync_stream_mapping_.erase(it); 220 sync_stream_mapping_.erase(it);
221 ConfigureSync(sync_group); 221 ConfigureSync(sync_group);
222 } 222 }
223 } 223 }
224 delete audio_receive_stream; 224 delete audio_receive_stream;
225 } 225 }
226 226
227 webrtc::VideoSendStream* Call::CreateVideoSendStream( 227 webrtc::VideoSendStream* Call::CreateVideoSendStream(
228 const webrtc::VideoSendStream::Config& config, 228 const webrtc::VideoSendStream::Config& config,
229 const VideoEncoderConfig& encoder_config) { 229 const VideoEncoderConfig& encoder_config) {
230 TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream"); 230 TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream");
231 LOG(LS_INFO) << "CreateVideoSendStream: " << config.ToString(); 231 LOG(LS_INFO) << "CreateVideoSendStream: " << config.ToString();
232 DCHECK(!config.rtp.ssrcs.empty()); 232 RTC_DCHECK(!config.rtp.ssrcs.empty());
233 233
234 // TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if 234 // TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if
235 // the call has already started. 235 // the call has already started.
236 VideoSendStream* send_stream = new VideoSendStream(num_cpu_cores_, 236 VideoSendStream* send_stream = new VideoSendStream(num_cpu_cores_,
237 module_process_thread_.get(), channel_group_.get(), 237 module_process_thread_.get(), channel_group_.get(),
238 rtc::AtomicOps::Increment(&next_channel_id_), config, encoder_config, 238 rtc::AtomicOps::Increment(&next_channel_id_), config, encoder_config,
239 suspended_video_send_ssrcs_); 239 suspended_video_send_ssrcs_);
240 240
241 // This needs to be taken before send_crit_ as both locks need to be held 241 // This needs to be taken before send_crit_ as both locks need to be held
242 // while changing network state. 242 // while changing network state.
243 rtc::CritScope lock(&network_enabled_crit_); 243 rtc::CritScope lock(&network_enabled_crit_);
244 WriteLockScoped write_lock(*send_crit_); 244 WriteLockScoped write_lock(*send_crit_);
245 for (uint32_t ssrc : config.rtp.ssrcs) { 245 for (uint32_t ssrc : config.rtp.ssrcs) {
246 DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); 246 RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end());
247 video_send_ssrcs_[ssrc] = send_stream; 247 video_send_ssrcs_[ssrc] = send_stream;
248 } 248 }
249 video_send_streams_.insert(send_stream); 249 video_send_streams_.insert(send_stream);
250 250
251 if (event_log_) 251 if (event_log_)
252 event_log_->LogVideoSendStreamConfig(config); 252 event_log_->LogVideoSendStreamConfig(config);
253 253
254 if (!network_enabled_) 254 if (!network_enabled_)
255 send_stream->SignalNetworkState(kNetworkDown); 255 send_stream->SignalNetworkState(kNetworkDown);
256 return send_stream; 256 return send_stream;
257 } 257 }
258 258
259 void Call::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) { 259 void Call::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) {
260 TRACE_EVENT0("webrtc", "Call::DestroyVideoSendStream"); 260 TRACE_EVENT0("webrtc", "Call::DestroyVideoSendStream");
261 DCHECK(send_stream != nullptr); 261 RTC_DCHECK(send_stream != nullptr);
262 262
263 send_stream->Stop(); 263 send_stream->Stop();
264 264
265 VideoSendStream* send_stream_impl = nullptr; 265 VideoSendStream* send_stream_impl = nullptr;
266 { 266 {
267 WriteLockScoped write_lock(*send_crit_); 267 WriteLockScoped write_lock(*send_crit_);
268 auto it = video_send_ssrcs_.begin(); 268 auto it = video_send_ssrcs_.begin();
269 while (it != video_send_ssrcs_.end()) { 269 while (it != video_send_ssrcs_.end()) {
270 if (it->second == static_cast<VideoSendStream*>(send_stream)) { 270 if (it->second == static_cast<VideoSendStream*>(send_stream)) {
271 send_stream_impl = it->second; 271 send_stream_impl = it->second;
272 video_send_ssrcs_.erase(it++); 272 video_send_ssrcs_.erase(it++);
273 } else { 273 } else {
274 ++it; 274 ++it;
275 } 275 }
276 } 276 }
277 video_send_streams_.erase(send_stream_impl); 277 video_send_streams_.erase(send_stream_impl);
278 } 278 }
279 CHECK(send_stream_impl != nullptr); 279 RTC_CHECK(send_stream_impl != nullptr);
280 280
281 VideoSendStream::RtpStateMap rtp_state = send_stream_impl->GetRtpStates(); 281 VideoSendStream::RtpStateMap rtp_state = send_stream_impl->GetRtpStates();
282 282
283 for (VideoSendStream::RtpStateMap::iterator it = rtp_state.begin(); 283 for (VideoSendStream::RtpStateMap::iterator it = rtp_state.begin();
284 it != rtp_state.end(); 284 it != rtp_state.end();
285 ++it) { 285 ++it) {
286 suspended_video_send_ssrcs_[it->first] = it->second; 286 suspended_video_send_ssrcs_[it->first] = it->second;
287 } 287 }
288 288
289 delete send_stream_impl; 289 delete send_stream_impl;
290 } 290 }
291 291
292 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( 292 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream(
293 const webrtc::VideoReceiveStream::Config& config) { 293 const webrtc::VideoReceiveStream::Config& config) {
294 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); 294 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream");
295 LOG(LS_INFO) << "CreateVideoReceiveStream: " << config.ToString(); 295 LOG(LS_INFO) << "CreateVideoReceiveStream: " << config.ToString();
296 VideoReceiveStream* receive_stream = new VideoReceiveStream( 296 VideoReceiveStream* receive_stream = new VideoReceiveStream(
297 num_cpu_cores_, channel_group_.get(), 297 num_cpu_cores_, channel_group_.get(),
298 rtc::AtomicOps::Increment(&next_channel_id_), config, 298 rtc::AtomicOps::Increment(&next_channel_id_), config,
299 config_.voice_engine); 299 config_.voice_engine);
300 300
301 // This needs to be taken before receive_crit_ as both locks need to be held 301 // This needs to be taken before receive_crit_ as both locks need to be held
302 // while changing network state. 302 // while changing network state.
303 rtc::CritScope lock(&network_enabled_crit_); 303 rtc::CritScope lock(&network_enabled_crit_);
304 WriteLockScoped write_lock(*receive_crit_); 304 WriteLockScoped write_lock(*receive_crit_);
305 DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == 305 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) ==
306 video_receive_ssrcs_.end()); 306 video_receive_ssrcs_.end());
307 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; 307 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream;
308 // TODO(pbos): Configure different RTX payloads per receive payload. 308 // TODO(pbos): Configure different RTX payloads per receive payload.
309 VideoReceiveStream::Config::Rtp::RtxMap::const_iterator it = 309 VideoReceiveStream::Config::Rtp::RtxMap::const_iterator it =
310 config.rtp.rtx.begin(); 310 config.rtp.rtx.begin();
311 if (it != config.rtp.rtx.end()) 311 if (it != config.rtp.rtx.end())
312 video_receive_ssrcs_[it->second.ssrc] = receive_stream; 312 video_receive_ssrcs_[it->second.ssrc] = receive_stream;
313 video_receive_streams_.insert(receive_stream); 313 video_receive_streams_.insert(receive_stream);
314 314
315 ConfigureSync(config.sync_group); 315 ConfigureSync(config.sync_group);
316 316
317 if (!network_enabled_) 317 if (!network_enabled_)
318 receive_stream->SignalNetworkState(kNetworkDown); 318 receive_stream->SignalNetworkState(kNetworkDown);
319 319
320 if (event_log_) 320 if (event_log_)
321 event_log_->LogVideoReceiveStreamConfig(config); 321 event_log_->LogVideoReceiveStreamConfig(config);
322 322
323 return receive_stream; 323 return receive_stream;
324 } 324 }
325 325
326 void Call::DestroyVideoReceiveStream( 326 void Call::DestroyVideoReceiveStream(
327 webrtc::VideoReceiveStream* receive_stream) { 327 webrtc::VideoReceiveStream* receive_stream) {
328 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); 328 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream");
329 DCHECK(receive_stream != nullptr); 329 RTC_DCHECK(receive_stream != nullptr);
330 VideoReceiveStream* receive_stream_impl = nullptr; 330 VideoReceiveStream* receive_stream_impl = nullptr;
331 { 331 {
332 WriteLockScoped write_lock(*receive_crit_); 332 WriteLockScoped write_lock(*receive_crit_);
333 // Remove all ssrcs pointing to a receive stream. As RTX retransmits on a 333 // Remove all ssrcs pointing to a receive stream. As RTX retransmits on a
334 // separate SSRC there can be either one or two. 334 // separate SSRC there can be either one or two.
335 auto it = video_receive_ssrcs_.begin(); 335 auto it = video_receive_ssrcs_.begin();
336 while (it != video_receive_ssrcs_.end()) { 336 while (it != video_receive_ssrcs_.end()) {
337 if (it->second == static_cast<VideoReceiveStream*>(receive_stream)) { 337 if (it->second == static_cast<VideoReceiveStream*>(receive_stream)) {
338 if (receive_stream_impl != nullptr) 338 if (receive_stream_impl != nullptr)
339 DCHECK(receive_stream_impl == it->second); 339 RTC_DCHECK(receive_stream_impl == it->second);
340 receive_stream_impl = it->second; 340 receive_stream_impl = it->second;
341 video_receive_ssrcs_.erase(it++); 341 video_receive_ssrcs_.erase(it++);
342 } else { 342 } else {
343 ++it; 343 ++it;
344 } 344 }
345 } 345 }
346 video_receive_streams_.erase(receive_stream_impl); 346 video_receive_streams_.erase(receive_stream_impl);
347 CHECK(receive_stream_impl != nullptr); 347 RTC_CHECK(receive_stream_impl != nullptr);
348 ConfigureSync(receive_stream_impl->config().sync_group); 348 ConfigureSync(receive_stream_impl->config().sync_group);
349 } 349 }
350 delete receive_stream_impl; 350 delete receive_stream_impl;
351 } 351 }
352 352
353 Call::Stats Call::GetStats() const { 353 Call::Stats Call::GetStats() const {
354 Stats stats; 354 Stats stats;
355 // Fetch available send/receive bitrates. 355 // Fetch available send/receive bitrates.
356 uint32_t send_bandwidth = 0; 356 uint32_t send_bandwidth = 0;
357 channel_group_->GetBitrateController()->AvailableBandwidth(&send_bandwidth); 357 channel_group_->GetBitrateController()->AvailableBandwidth(&send_bandwidth);
(...skipping 11 matching lines...) Expand all
369 if (rtt_ms > 0) 369 if (rtt_ms > 0)
370 stats.rtt_ms = rtt_ms; 370 stats.rtt_ms = rtt_ms;
371 } 371 }
372 } 372 }
373 return stats; 373 return stats;
374 } 374 }
375 375
376 void Call::SetBitrateConfig( 376 void Call::SetBitrateConfig(
377 const webrtc::Call::Config::BitrateConfig& bitrate_config) { 377 const webrtc::Call::Config::BitrateConfig& bitrate_config) {
378 TRACE_EVENT0("webrtc", "Call::SetBitrateConfig"); 378 TRACE_EVENT0("webrtc", "Call::SetBitrateConfig");
379 DCHECK_GE(bitrate_config.min_bitrate_bps, 0); 379 RTC_DCHECK_GE(bitrate_config.min_bitrate_bps, 0);
380 if (bitrate_config.max_bitrate_bps != -1) 380 if (bitrate_config.max_bitrate_bps != -1)
381 DCHECK_GT(bitrate_config.max_bitrate_bps, 0); 381 RTC_DCHECK_GT(bitrate_config.max_bitrate_bps, 0);
382 if (config_.bitrate_config.min_bitrate_bps == 382 if (config_.bitrate_config.min_bitrate_bps ==
383 bitrate_config.min_bitrate_bps && 383 bitrate_config.min_bitrate_bps &&
384 (bitrate_config.start_bitrate_bps <= 0 || 384 (bitrate_config.start_bitrate_bps <= 0 ||
385 config_.bitrate_config.start_bitrate_bps == 385 config_.bitrate_config.start_bitrate_bps ==
386 bitrate_config.start_bitrate_bps) && 386 bitrate_config.start_bitrate_bps) &&
387 config_.bitrate_config.max_bitrate_bps == 387 config_.bitrate_config.max_bitrate_bps ==
388 bitrate_config.max_bitrate_bps) { 388 bitrate_config.max_bitrate_bps) {
389 // Nothing new to set, early abort to avoid encoder reconfigurations. 389 // Nothing new to set, early abort to avoid encoder reconfigurations.
390 return; 390 return;
391 } 391 }
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 size_t length, 543 size_t length,
544 const PacketTime& packet_time) { 544 const PacketTime& packet_time) {
545 if (RtpHeaderParser::IsRtcp(packet, length)) 545 if (RtpHeaderParser::IsRtcp(packet, length))
546 return DeliverRtcp(media_type, packet, length); 546 return DeliverRtcp(media_type, packet, length);
547 547
548 return DeliverRtp(media_type, packet, length, packet_time); 548 return DeliverRtp(media_type, packet, length, packet_time);
549 } 549 }
550 550
551 } // namespace internal 551 } // namespace internal
552 } // namespace webrtc 552 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/bitrate_estimator_tests.cc ('k') | webrtc/video/call_perf_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698