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

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

Issue 2248713003: Revert of Add task queue to Call. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@move_getpadding
Patch Set: Created 4 years, 4 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/bitrate_estimator_tests.cc ('k') | webrtc/call/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
11 #include <string.h> 11 #include <string.h>
12
12 #include <algorithm> 13 #include <algorithm>
13 #include <map> 14 #include <map>
14 #include <memory> 15 #include <memory>
15 #include <vector> 16 #include <vector>
16 17
17 #include "webrtc/audio/audio_receive_stream.h" 18 #include "webrtc/audio/audio_receive_stream.h"
18 #include "webrtc/audio/audio_send_stream.h" 19 #include "webrtc/audio/audio_send_stream.h"
19 #include "webrtc/audio/audio_state.h" 20 #include "webrtc/audio/audio_state.h"
20 #include "webrtc/audio/scoped_voe_interface.h" 21 #include "webrtc/audio/scoped_voe_interface.h"
21 #include "webrtc/base/checks.h" 22 #include "webrtc/base/checks.h"
22 #include "webrtc/base/constructormagic.h" 23 #include "webrtc/base/constructormagic.h"
23 #include "webrtc/base/logging.h" 24 #include "webrtc/base/logging.h"
24 #include "webrtc/base/task_queue.h"
25 #include "webrtc/base/thread_annotations.h" 25 #include "webrtc/base/thread_annotations.h"
26 #include "webrtc/base/thread_checker.h" 26 #include "webrtc/base/thread_checker.h"
27 #include "webrtc/base/trace_event.h" 27 #include "webrtc/base/trace_event.h"
28 #include "webrtc/call.h" 28 #include "webrtc/call.h"
29 #include "webrtc/call/bitrate_allocator.h" 29 #include "webrtc/call/bitrate_allocator.h"
30 #include "webrtc/call/rtc_event_log.h" 30 #include "webrtc/call/rtc_event_log.h"
31 #include "webrtc/config.h" 31 #include "webrtc/config.h"
32 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" 32 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
33 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" 33 #include "webrtc/modules/congestion_controller/include/congestion_controller.h"
34 #include "webrtc/modules/pacing/paced_sender.h" 34 #include "webrtc/modules/pacing/paced_sender.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 webrtc::AudioSendStream* CreateAudioSendStream( 67 webrtc::AudioSendStream* CreateAudioSendStream(
68 const webrtc::AudioSendStream::Config& config) override; 68 const webrtc::AudioSendStream::Config& config) override;
69 void DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) override; 69 void DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) override;
70 70
71 webrtc::AudioReceiveStream* CreateAudioReceiveStream( 71 webrtc::AudioReceiveStream* CreateAudioReceiveStream(
72 const webrtc::AudioReceiveStream::Config& config) override; 72 const webrtc::AudioReceiveStream::Config& config) override;
73 void DestroyAudioReceiveStream( 73 void DestroyAudioReceiveStream(
74 webrtc::AudioReceiveStream* receive_stream) override; 74 webrtc::AudioReceiveStream* receive_stream) override;
75 75
76 webrtc::VideoSendStream* CreateVideoSendStream( 76 webrtc::VideoSendStream* CreateVideoSendStream(
77 webrtc::VideoSendStream::Config config, 77 const webrtc::VideoSendStream::Config& config,
78 VideoEncoderConfig encoder_config) override; 78 const VideoEncoderConfig& encoder_config) override;
79 void DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) override; 79 void DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) override;
80 80
81 webrtc::VideoReceiveStream* CreateVideoReceiveStream( 81 webrtc::VideoReceiveStream* CreateVideoReceiveStream(
82 webrtc::VideoReceiveStream::Config configuration) override; 82 webrtc::VideoReceiveStream::Config configuration) override;
83 void DestroyVideoReceiveStream( 83 void DestroyVideoReceiveStream(
84 webrtc::VideoReceiveStream* receive_stream) override; 84 webrtc::VideoReceiveStream* receive_stream) override;
85 85
86 Stats GetStats() const override; 86 Stats GetStats() const override;
87 87
88 DeliveryStatus DeliverPacket(MediaType media_type, 88 DeliveryStatus DeliverPacket(MediaType media_type,
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 uint32_t min_allocated_send_bitrate_bps_ GUARDED_BY(&bitrate_crit_); 191 uint32_t min_allocated_send_bitrate_bps_ GUARDED_BY(&bitrate_crit_);
192 int64_t num_bitrate_updates_ GUARDED_BY(&bitrate_crit_); 192 int64_t num_bitrate_updates_ GUARDED_BY(&bitrate_crit_);
193 uint32_t configured_max_padding_bitrate_bps_ GUARDED_BY(&bitrate_crit_); 193 uint32_t configured_max_padding_bitrate_bps_ GUARDED_BY(&bitrate_crit_);
194 194
195 std::map<std::string, rtc::NetworkRoute> network_routes_; 195 std::map<std::string, rtc::NetworkRoute> network_routes_;
196 196
197 VieRemb remb_; 197 VieRemb remb_;
198 const std::unique_ptr<CongestionController> congestion_controller_; 198 const std::unique_ptr<CongestionController> congestion_controller_;
199 const std::unique_ptr<SendDelayStats> video_send_delay_stats_; 199 const std::unique_ptr<SendDelayStats> video_send_delay_stats_;
200 const int64_t start_ms_; 200 const int64_t start_ms_;
201 // TODO(perkj): |worker_queue_| is supposed to replace
202 // |module_process_thread_|.
203 // |worker_queue| is defined last to ensure all pending tasks are cancelled
204 // and deleted before any other members.
205 rtc::TaskQueue worker_queue_;
206 201
207 RTC_DISALLOW_COPY_AND_ASSIGN(Call); 202 RTC_DISALLOW_COPY_AND_ASSIGN(Call);
208 }; 203 };
209 } // namespace internal 204 } // namespace internal
210 205
211 std::string Call::Stats::ToString(int64_t time_ms) const { 206 std::string Call::Stats::ToString(int64_t time_ms) const {
212 std::stringstream ss; 207 std::stringstream ss;
213 ss << "Call stats: " << time_ms << ", {"; 208 ss << "Call stats: " << time_ms << ", {";
214 ss << "send_bw_bps: " << send_bandwidth_bps << ", "; 209 ss << "send_bw_bps: " << send_bandwidth_bps << ", ";
215 ss << "recv_bw_bps: " << recv_bandwidth_bps << ", "; 210 ss << "recv_bw_bps: " << recv_bandwidth_bps << ", ";
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 first_packet_sent_ms_(-1), 242 first_packet_sent_ms_(-1),
248 estimated_send_bitrate_sum_kbits_(0), 243 estimated_send_bitrate_sum_kbits_(0),
249 pacer_bitrate_sum_kbits_(0), 244 pacer_bitrate_sum_kbits_(0),
250 min_allocated_send_bitrate_bps_(0), 245 min_allocated_send_bitrate_bps_(0),
251 num_bitrate_updates_(0), 246 num_bitrate_updates_(0),
252 configured_max_padding_bitrate_bps_(0), 247 configured_max_padding_bitrate_bps_(0),
253 remb_(clock_), 248 remb_(clock_),
254 congestion_controller_( 249 congestion_controller_(
255 new CongestionController(clock_, this, &remb_, event_log_.get())), 250 new CongestionController(clock_, this, &remb_, event_log_.get())),
256 video_send_delay_stats_(new SendDelayStats(clock_)), 251 video_send_delay_stats_(new SendDelayStats(clock_)),
257 start_ms_(clock_->TimeInMilliseconds()), 252 start_ms_(clock_->TimeInMilliseconds()) {
258 worker_queue_("call_worker_queue") {
259 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 253 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
260 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); 254 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0);
261 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps, 255 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps,
262 config.bitrate_config.min_bitrate_bps); 256 config.bitrate_config.min_bitrate_bps);
263 if (config.bitrate_config.max_bitrate_bps != -1) { 257 if (config.bitrate_config.max_bitrate_bps != -1) {
264 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, 258 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps,
265 config.bitrate_config.start_bitrate_bps); 259 config.bitrate_config.start_bitrate_bps);
266 } 260 }
267 261
268 Trace::CreateTrace(); 262 Trace::CreateTrace();
269 call_stats_->RegisterStatsObserver(congestion_controller_.get()); 263 call_stats_->RegisterStatsObserver(congestion_controller_.get());
270 264
271 congestion_controller_->SetBweBitrates( 265 congestion_controller_->SetBweBitrates(
272 config_.bitrate_config.min_bitrate_bps, 266 config_.bitrate_config.min_bitrate_bps,
273 config_.bitrate_config.start_bitrate_bps, 267 config_.bitrate_config.start_bitrate_bps,
274 config_.bitrate_config.max_bitrate_bps); 268 config_.bitrate_config.max_bitrate_bps);
275 269
276 module_process_thread_->Start(); 270 module_process_thread_->Start();
277 module_process_thread_->RegisterModule(call_stats_.get()); 271 module_process_thread_->RegisterModule(call_stats_.get());
278 module_process_thread_->RegisterModule(congestion_controller_.get()); 272 module_process_thread_->RegisterModule(congestion_controller_.get());
279 pacer_thread_->RegisterModule(congestion_controller_->pacer()); 273 pacer_thread_->RegisterModule(congestion_controller_->pacer());
280 pacer_thread_->RegisterModule( 274 pacer_thread_->RegisterModule(
281 congestion_controller_->GetRemoteBitrateEstimator(true)); 275 congestion_controller_->GetRemoteBitrateEstimator(true));
282 pacer_thread_->Start(); 276 pacer_thread_->Start();
283 } 277 }
284 278
285 Call::~Call() { 279 Call::~Call() {
286 RTC_DCHECK(!remb_.InUse()); 280 RTC_DCHECK(!remb_.InUse());
287 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 281 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
288
289 RTC_CHECK(audio_send_ssrcs_.empty()); 282 RTC_CHECK(audio_send_ssrcs_.empty());
290 RTC_CHECK(video_send_ssrcs_.empty()); 283 RTC_CHECK(video_send_ssrcs_.empty());
291 RTC_CHECK(video_send_streams_.empty()); 284 RTC_CHECK(video_send_streams_.empty());
292 RTC_CHECK(audio_receive_ssrcs_.empty()); 285 RTC_CHECK(audio_receive_ssrcs_.empty());
293 RTC_CHECK(video_receive_ssrcs_.empty()); 286 RTC_CHECK(video_receive_ssrcs_.empty());
294 RTC_CHECK(video_receive_streams_.empty()); 287 RTC_CHECK(video_receive_streams_.empty());
295 288
296 pacer_thread_->Stop(); 289 pacer_thread_->Stop();
297 pacer_thread_->DeRegisterModule(congestion_controller_->pacer()); 290 pacer_thread_->DeRegisterModule(congestion_controller_->pacer());
298 pacer_thread_->DeRegisterModule( 291 pacer_thread_->DeRegisterModule(
299 congestion_controller_->GetRemoteBitrateEstimator(true)); 292 congestion_controller_->GetRemoteBitrateEstimator(true));
300 module_process_thread_->DeRegisterModule(congestion_controller_.get()); 293 module_process_thread_->DeRegisterModule(congestion_controller_.get());
301 module_process_thread_->DeRegisterModule(call_stats_.get()); 294 module_process_thread_->DeRegisterModule(call_stats_.get());
302 module_process_thread_->Stop(); 295 module_process_thread_->Stop();
303 call_stats_->DeregisterStatsObserver(congestion_controller_.get()); 296 call_stats_->DeregisterStatsObserver(congestion_controller_.get());
304 297
305 // Only update histograms after process threads have been shut down, so that 298 // Only update histograms after process threads have been shut down, so that
306 // they won't try to concurrently update stats. 299 // they won't try to concurrently update stats.
307 { 300 UpdateSendHistograms();
308 rtc::CritScope lock(&bitrate_crit_);
309 UpdateSendHistograms();
310 }
311 UpdateReceiveHistograms(); 301 UpdateReceiveHistograms();
312 UpdateHistograms(); 302 UpdateHistograms();
313 303
314 Trace::ReturnTrace(); 304 Trace::ReturnTrace();
315 } 305 }
316 306
317 void Call::UpdateHistograms() { 307 void Call::UpdateHistograms() {
318 RTC_LOGGED_HISTOGRAM_COUNTS_100000( 308 RTC_LOGGED_HISTOGRAM_COUNTS_100000(
319 "WebRTC.Call.LifetimeInSeconds", 309 "WebRTC.Call.LifetimeInSeconds",
320 (clock_->TimeInMilliseconds() - start_ms_) / 1000); 310 (clock_->TimeInMilliseconds() - start_ms_) / 1000);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 // thread. Re-enable once that is fixed. 362 // thread. Re-enable once that is fixed.
373 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 363 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
374 return this; 364 return this;
375 } 365 }
376 366
377 webrtc::AudioSendStream* Call::CreateAudioSendStream( 367 webrtc::AudioSendStream* Call::CreateAudioSendStream(
378 const webrtc::AudioSendStream::Config& config) { 368 const webrtc::AudioSendStream::Config& config) {
379 TRACE_EVENT0("webrtc", "Call::CreateAudioSendStream"); 369 TRACE_EVENT0("webrtc", "Call::CreateAudioSendStream");
380 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 370 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
381 AudioSendStream* send_stream = new AudioSendStream( 371 AudioSendStream* send_stream = new AudioSendStream(
382 config, config_.audio_state, &worker_queue_, congestion_controller_.get(), 372 config, config_.audio_state, congestion_controller_.get(),
383 bitrate_allocator_.get()); 373 bitrate_allocator_.get());
384 { 374 {
385 WriteLockScoped write_lock(*send_crit_); 375 WriteLockScoped write_lock(*send_crit_);
386 RTC_DCHECK(audio_send_ssrcs_.find(config.rtp.ssrc) == 376 RTC_DCHECK(audio_send_ssrcs_.find(config.rtp.ssrc) ==
387 audio_send_ssrcs_.end()); 377 audio_send_ssrcs_.end());
388 audio_send_ssrcs_[config.rtp.ssrc] = send_stream; 378 audio_send_ssrcs_[config.rtp.ssrc] = send_stream;
389 } 379 }
390 send_stream->SignalNetworkState(audio_network_state_); 380 send_stream->SignalNetworkState(audio_network_state_);
391 UpdateAggregateNetworkState(); 381 UpdateAggregateNetworkState();
392 return send_stream; 382 return send_stream;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 it->second == audio_receive_stream) { 438 it->second == audio_receive_stream) {
449 sync_stream_mapping_.erase(it); 439 sync_stream_mapping_.erase(it);
450 ConfigureSync(sync_group); 440 ConfigureSync(sync_group);
451 } 441 }
452 } 442 }
453 UpdateAggregateNetworkState(); 443 UpdateAggregateNetworkState();
454 delete audio_receive_stream; 444 delete audio_receive_stream;
455 } 445 }
456 446
457 webrtc::VideoSendStream* Call::CreateVideoSendStream( 447 webrtc::VideoSendStream* Call::CreateVideoSendStream(
458 webrtc::VideoSendStream::Config config, 448 const webrtc::VideoSendStream::Config& config,
459 VideoEncoderConfig encoder_config) { 449 const VideoEncoderConfig& encoder_config) {
460 TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream"); 450 TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream");
461 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 451 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
462 452
463 video_send_delay_stats_->AddSsrcs(config); 453 video_send_delay_stats_->AddSsrcs(config);
464 event_log_->LogVideoSendStreamConfig(config);
465
466 // TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if 454 // TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if
467 // the call has already started. 455 // the call has already started.
468 // Copy ssrcs from |config| since |config| is moved.
469 std::vector<uint32_t> ssrcs = config.rtp.ssrcs;
470 VideoSendStream* send_stream = new VideoSendStream( 456 VideoSendStream* send_stream = new VideoSendStream(
471 num_cpu_cores_, module_process_thread_.get(), &worker_queue_, 457 num_cpu_cores_, module_process_thread_.get(), call_stats_.get(),
472 call_stats_.get(), congestion_controller_.get(), bitrate_allocator_.get(), 458 congestion_controller_.get(), bitrate_allocator_.get(),
473 video_send_delay_stats_.get(), &remb_, event_log_.get(), 459 video_send_delay_stats_.get(), &remb_, event_log_.get(), config,
474 std::move(config), std::move(encoder_config), 460 encoder_config, suspended_video_send_ssrcs_);
475 suspended_video_send_ssrcs_);
476
477 { 461 {
478 WriteLockScoped write_lock(*send_crit_); 462 WriteLockScoped write_lock(*send_crit_);
479 for (uint32_t ssrc : ssrcs) { 463 for (uint32_t ssrc : config.rtp.ssrcs) {
480 RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); 464 RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end());
481 video_send_ssrcs_[ssrc] = send_stream; 465 video_send_ssrcs_[ssrc] = send_stream;
482 } 466 }
483 video_send_streams_.insert(send_stream); 467 video_send_streams_.insert(send_stream);
484 } 468 }
485 send_stream->SignalNetworkState(video_network_state_); 469 send_stream->SignalNetworkState(video_network_state_);
486 UpdateAggregateNetworkState(); 470 UpdateAggregateNetworkState();
487 471 event_log_->LogVideoSendStreamConfig(config);
488 return send_stream; 472 return send_stream;
489 } 473 }
490 474
491 void Call::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) { 475 void Call::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) {
492 TRACE_EVENT0("webrtc", "Call::DestroyVideoSendStream"); 476 TRACE_EVENT0("webrtc", "Call::DestroyVideoSendStream");
493 RTC_DCHECK(send_stream != nullptr); 477 RTC_DCHECK(send_stream != nullptr);
494 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 478 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
495 479
496 send_stream->Stop(); 480 send_stream->Stop();
497 481
498 VideoSendStream* send_stream_impl = nullptr; 482 VideoSendStream* send_stream_impl = nullptr;
499 { 483 {
500 WriteLockScoped write_lock(*send_crit_); 484 WriteLockScoped write_lock(*send_crit_);
501 auto it = video_send_ssrcs_.begin(); 485 auto it = video_send_ssrcs_.begin();
502 while (it != video_send_ssrcs_.end()) { 486 while (it != video_send_ssrcs_.end()) {
503 if (it->second == static_cast<VideoSendStream*>(send_stream)) { 487 if (it->second == static_cast<VideoSendStream*>(send_stream)) {
504 send_stream_impl = it->second; 488 send_stream_impl = it->second;
505 video_send_ssrcs_.erase(it++); 489 video_send_ssrcs_.erase(it++);
506 } else { 490 } else {
507 ++it; 491 ++it;
508 } 492 }
509 } 493 }
510 video_send_streams_.erase(send_stream_impl); 494 video_send_streams_.erase(send_stream_impl);
511 } 495 }
512 RTC_CHECK(send_stream_impl != nullptr); 496 RTC_CHECK(send_stream_impl != nullptr);
513 497
514 VideoSendStream::RtpStateMap rtp_state = 498 VideoSendStream::RtpStateMap rtp_state = send_stream_impl->GetRtpStates();
515 send_stream_impl->StopPermanentlyAndGetRtpStates();
516 499
517 for (VideoSendStream::RtpStateMap::iterator it = rtp_state.begin(); 500 for (VideoSendStream::RtpStateMap::iterator it = rtp_state.begin();
518 it != rtp_state.end(); ++it) { 501 it != rtp_state.end();
502 ++it) {
519 suspended_video_send_ssrcs_[it->first] = it->second; 503 suspended_video_send_ssrcs_[it->first] = it->second;
520 } 504 }
521 505
522 UpdateAggregateNetworkState(); 506 UpdateAggregateNetworkState();
523 delete send_stream_impl; 507 delete send_stream_impl;
524 } 508 }
525 509
526 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( 510 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream(
527 webrtc::VideoReceiveStream::Config configuration) { 511 webrtc::VideoReceiveStream::Config configuration) {
528 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); 512 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream");
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 void Call::OnSentPacket(const rtc::SentPacket& sent_packet) { 722 void Call::OnSentPacket(const rtc::SentPacket& sent_packet) {
739 if (first_packet_sent_ms_ == -1) 723 if (first_packet_sent_ms_ == -1)
740 first_packet_sent_ms_ = clock_->TimeInMilliseconds(); 724 first_packet_sent_ms_ = clock_->TimeInMilliseconds();
741 video_send_delay_stats_->OnSentPacket(sent_packet.packet_id, 725 video_send_delay_stats_->OnSentPacket(sent_packet.packet_id,
742 clock_->TimeInMilliseconds()); 726 clock_->TimeInMilliseconds());
743 congestion_controller_->OnSentPacket(sent_packet); 727 congestion_controller_->OnSentPacket(sent_packet);
744 } 728 }
745 729
746 void Call::OnNetworkChanged(uint32_t target_bitrate_bps, uint8_t fraction_loss, 730 void Call::OnNetworkChanged(uint32_t target_bitrate_bps, uint8_t fraction_loss,
747 int64_t rtt_ms) { 731 int64_t rtt_ms) {
748 // TODO(perkj): Consider making sure CongestionController operates on
749 // |worker_queue_|.
750 if (!worker_queue_.IsCurrent()) {
751 worker_queue_.PostTask([this, target_bitrate_bps, fraction_loss, rtt_ms] {
752 OnNetworkChanged(target_bitrate_bps, fraction_loss, rtt_ms);
753 });
754 return;
755 }
756 RTC_DCHECK_RUN_ON(&worker_queue_);
757 bitrate_allocator_->OnNetworkChanged(target_bitrate_bps, fraction_loss, 732 bitrate_allocator_->OnNetworkChanged(target_bitrate_bps, fraction_loss,
758 rtt_ms); 733 rtt_ms);
759 734
760 // Ignore updates where the bitrate is zero because the aggregate network 735 // Ignore updates where the bitrate is zero because the aggregate network
761 // state is down. 736 // state is down.
762 if (target_bitrate_bps > 0) { 737 if (target_bitrate_bps > 0) {
763 rtc::CritScope lock(&bitrate_crit_); 738 rtc::CritScope lock(&bitrate_crit_);
764 // We only update these stats if we have send streams, and assume that 739 // We only update these stats if we have send streams, and assume that
765 // OnNetworkChanged is called roughly with a fixed frequency. 740 // OnNetworkChanged is called roughly with a fixed frequency.
766 estimated_send_bitrate_sum_kbits_ += target_bitrate_bps / 1000; 741 estimated_send_bitrate_sum_kbits_ += target_bitrate_bps / 1000;
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 // thread. Then this check can be enabled. 901 // thread. Then this check can be enabled.
927 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); 902 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread());
928 if (RtpHeaderParser::IsRtcp(packet, length)) 903 if (RtpHeaderParser::IsRtcp(packet, length))
929 return DeliverRtcp(media_type, packet, length); 904 return DeliverRtcp(media_type, packet, length);
930 905
931 return DeliverRtp(media_type, packet, length, packet_time); 906 return DeliverRtp(media_type, packet, length, packet_time);
932 } 907 }
933 908
934 } // namespace internal 909 } // namespace internal
935 } // namespace webrtc 910 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/call/bitrate_estimator_tests.cc ('k') | webrtc/call/call_perf_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698