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