| 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 |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 suspended_ssrcs_(suspended_ssrcs), | 390 suspended_ssrcs_(suspended_ssrcs), |
| 391 module_process_thread_(module_process_thread), | 391 module_process_thread_(module_process_thread), |
| 392 call_stats_(call_stats), | 392 call_stats_(call_stats), |
| 393 congestion_controller_(congestion_controller), | 393 congestion_controller_(congestion_controller), |
| 394 bitrate_allocator_(bitrate_allocator), | 394 bitrate_allocator_(bitrate_allocator), |
| 395 remb_(remb), | 395 remb_(remb), |
| 396 encoder_thread_(EncoderThreadFunction, this, "EncoderThread"), | 396 encoder_thread_(EncoderThreadFunction, this, "EncoderThread"), |
| 397 encoder_wakeup_event_(false, false), | 397 encoder_wakeup_event_(false, false), |
| 398 stop_encoder_thread_(0), | 398 stop_encoder_thread_(0), |
| 399 encoder_max_bitrate_bps_(0), | 399 encoder_max_bitrate_bps_(0), |
| 400 encoder_target_rate_bps_(0), |
| 400 state_(State::kStopped), | 401 state_(State::kStopped), |
| 401 overuse_detector_( | 402 overuse_detector_( |
| 402 Clock::GetRealTimeClock(), | 403 Clock::GetRealTimeClock(), |
| 403 GetCpuOveruseOptions(config.encoder_settings.full_overuse_time), | 404 GetCpuOveruseOptions(config.encoder_settings.full_overuse_time), |
| 404 this, | 405 this, |
| 405 config.post_encode_callback, | 406 config.post_encode_callback, |
| 406 &stats_proxy_), | 407 &stats_proxy_), |
| 407 vie_encoder_(num_cpu_cores, | 408 vie_encoder_(num_cpu_cores, |
| 408 module_process_thread_, | 409 module_process_thread_, |
| 409 &stats_proxy_, | 410 &stats_proxy_, |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 } | 521 } |
| 521 } | 522 } |
| 522 | 523 |
| 523 bool VideoSendStream::DeliverRtcp(const uint8_t* packet, size_t length) { | 524 bool VideoSendStream::DeliverRtcp(const uint8_t* packet, size_t length) { |
| 524 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | 525 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) |
| 525 rtp_rtcp->IncomingRtcpPacket(packet, length); | 526 rtp_rtcp->IncomingRtcpPacket(packet, length); |
| 526 return true; | 527 return true; |
| 527 } | 528 } |
| 528 | 529 |
| 529 void VideoSendStream::Start() { | 530 void VideoSendStream::Start() { |
| 531 LOG(LS_INFO) << "VideoSendStream::Start"; |
| 530 if (payload_router_.active()) | 532 if (payload_router_.active()) |
| 531 return; | 533 return; |
| 532 TRACE_EVENT_INSTANT0("webrtc", "VideoSendStream::Start"); | 534 TRACE_EVENT_INSTANT0("webrtc", "VideoSendStream::Start"); |
| 533 payload_router_.set_active(true); | 535 payload_router_.set_active(true); |
| 534 { | 536 { |
| 535 rtc::CritScope lock(&encoder_settings_crit_); | 537 rtc::CritScope lock(&encoder_settings_crit_); |
| 536 pending_state_change_ = rtc::Optional<State>(State::kStarted); | 538 pending_state_change_ = rtc::Optional<State>(State::kStarted); |
| 537 } | 539 } |
| 538 encoder_wakeup_event_.Set(); | 540 encoder_wakeup_event_.Set(); |
| 539 } | 541 } |
| 540 | 542 |
| 541 void VideoSendStream::Stop() { | 543 void VideoSendStream::Stop() { |
| 544 LOG(LS_INFO) << "VideoSendStream::Stop"; |
| 542 if (!payload_router_.active()) | 545 if (!payload_router_.active()) |
| 543 return; | 546 return; |
| 544 TRACE_EVENT_INSTANT0("webrtc", "VideoSendStream::Stop"); | 547 TRACE_EVENT_INSTANT0("webrtc", "VideoSendStream::Stop"); |
| 545 payload_router_.set_active(false); | 548 payload_router_.set_active(false); |
| 546 { | 549 { |
| 547 rtc::CritScope lock(&encoder_settings_crit_); | 550 rtc::CritScope lock(&encoder_settings_crit_); |
| 548 pending_state_change_ = rtc::Optional<State>(State::kStopped); | 551 pending_state_change_ = rtc::Optional<State>(State::kStopped); |
| 549 } | 552 } |
| 550 encoder_wakeup_event_.Set(); | 553 encoder_wakeup_event_.Set(); |
| 551 } | 554 } |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 uint32_t encoder_target_rate_bps = | 891 uint32_t encoder_target_rate_bps = |
| 889 protection_bitrate_calculator_.SetTargetRates( | 892 protection_bitrate_calculator_.SetTargetRates( |
| 890 bitrate_bps, stats_proxy_.GetSendFrameRate(), fraction_loss, rtt); | 893 bitrate_bps, stats_proxy_.GetSendFrameRate(), fraction_loss, rtt); |
| 891 | 894 |
| 892 uint32_t protection_bitrate = bitrate_bps - encoder_target_rate_bps; | 895 uint32_t protection_bitrate = bitrate_bps - encoder_target_rate_bps; |
| 893 { | 896 { |
| 894 // Limit the target bitrate to the configured max bitrate. | 897 // Limit the target bitrate to the configured max bitrate. |
| 895 rtc::CritScope lock(&encoder_settings_crit_); | 898 rtc::CritScope lock(&encoder_settings_crit_); |
| 896 encoder_target_rate_bps = | 899 encoder_target_rate_bps = |
| 897 std::min(encoder_max_bitrate_bps_, encoder_target_rate_bps); | 900 std::min(encoder_max_bitrate_bps_, encoder_target_rate_bps); |
| 901 if ((encoder_target_rate_bps_ == 0 && encoder_target_rate_bps > 0) || |
| 902 (encoder_target_rate_bps_ > 0 && encoder_target_rate_bps == 0)) { |
| 903 LOG(LS_INFO) |
| 904 << "OnBitrateUpdated: Encoder state changed, target bitrate " |
| 905 << encoder_target_rate_bps << " bps."; |
| 906 } |
| 907 encoder_target_rate_bps_ = encoder_target_rate_bps; |
| 898 } | 908 } |
| 899 vie_encoder_.OnBitrateUpdated(encoder_target_rate_bps, fraction_loss, rtt); | 909 vie_encoder_.OnBitrateUpdated(encoder_target_rate_bps, fraction_loss, rtt); |
| 900 stats_proxy_.OnSetEncoderTargetRate(encoder_target_rate_bps); | 910 stats_proxy_.OnSetEncoderTargetRate(encoder_target_rate_bps); |
| 901 | 911 |
| 902 return protection_bitrate; | 912 return protection_bitrate; |
| 903 } | 913 } |
| 904 | 914 |
| 905 int VideoSendStream::ProtectionRequest(const FecProtectionParams* delta_params, | 915 int VideoSendStream::ProtectionRequest(const FecProtectionParams* delta_params, |
| 906 const FecProtectionParams* key_params, | 916 const FecProtectionParams* key_params, |
| 907 uint32_t* sent_video_rate_bps, | 917 uint32_t* sent_video_rate_bps, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 920 &module_nack_rate); | 930 &module_nack_rate); |
| 921 *sent_video_rate_bps += module_video_rate; | 931 *sent_video_rate_bps += module_video_rate; |
| 922 *sent_nack_rate_bps += module_nack_rate; | 932 *sent_nack_rate_bps += module_nack_rate; |
| 923 *sent_fec_rate_bps += module_fec_rate; | 933 *sent_fec_rate_bps += module_fec_rate; |
| 924 } | 934 } |
| 925 return 0; | 935 return 0; |
| 926 } | 936 } |
| 927 | 937 |
| 928 } // namespace internal | 938 } // namespace internal |
| 929 } // namespace webrtc | 939 } // namespace webrtc |
| OLD | NEW |