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 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 rtc::CritScope lock(&encoder_settings_crit_); | 555 rtc::CritScope lock(&encoder_settings_crit_); |
556 if (pending_encoder_settings_) { | 556 if (pending_encoder_settings_) { |
557 encoder_settings = pending_encoder_settings_; | 557 encoder_settings = pending_encoder_settings_; |
558 pending_encoder_settings_ = rtc::Optional<EncoderSettings>(); | 558 pending_encoder_settings_ = rtc::Optional<EncoderSettings>(); |
559 } | 559 } |
560 } | 560 } |
561 if (encoder_settings) { | 561 if (encoder_settings) { |
562 encoder_settings->video_codec.startBitrate = | 562 encoder_settings->video_codec.startBitrate = |
563 bitrate_allocator_->AddObserver( | 563 bitrate_allocator_->AddObserver( |
564 this, encoder_settings->video_codec.minBitrate * 1000, | 564 this, encoder_settings->video_codec.minBitrate * 1000, |
565 encoder_settings->video_codec.maxBitrate * 1000) / | 565 encoder_settings->video_codec.maxBitrate * 1000, |
| 566 !config_.suspend_below_min_bitrate) / |
566 1000; | 567 1000; |
567 | 568 |
568 payload_router_.SetSendStreams(encoder_settings->streams); | 569 payload_router_.SetSendStreams(encoder_settings->streams); |
569 vie_encoder_.SetEncoder(encoder_settings->video_codec, | 570 vie_encoder_.SetEncoder(encoder_settings->video_codec, |
570 encoder_settings->min_transmit_bitrate_bps, | 571 encoder_settings->min_transmit_bitrate_bps, |
571 payload_router_.MaxPayloadLength(), this); | 572 payload_router_.MaxPayloadLength(), this); |
572 | 573 |
| 574 // vie_encoder_.SetEncoder must be called before this. |
| 575 if (config_.suspend_below_min_bitrate) |
| 576 video_sender_->SuspendBelowMinBitrate(); |
| 577 |
573 // Clear stats for disabled layers. | 578 // Clear stats for disabled layers. |
574 for (size_t i = encoder_settings->streams.size(); | 579 for (size_t i = encoder_settings->streams.size(); |
575 i < config_.rtp.ssrcs.size(); ++i) { | 580 i < config_.rtp.ssrcs.size(); ++i) { |
576 stats_proxy_.OnInactiveSsrc(config_.rtp.ssrcs[i]); | 581 stats_proxy_.OnInactiveSsrc(config_.rtp.ssrcs[i]); |
577 } | 582 } |
578 | 583 |
579 if (config_.suspend_below_min_bitrate) { | |
580 video_sender_->SuspendBelowMinBitrate(); | |
581 bitrate_allocator_->EnforceMinBitrate(false); | |
582 } | |
583 // We might've gotten new settings while configuring the encoder settings, | 584 // We might've gotten new settings while configuring the encoder settings, |
584 // restart from the top to see if that's the case before trying to encode | 585 // restart from the top to see if that's the case before trying to encode |
585 // a frame (which might correspond to the last frame size). | 586 // a frame (which might correspond to the last frame size). |
586 encoder_wakeup_event_.Set(); | 587 encoder_wakeup_event_.Set(); |
587 continue; | 588 continue; |
588 } | 589 } |
589 | 590 |
590 VideoFrame frame; | 591 VideoFrame frame; |
591 if (input_.GetVideoFrame(&frame)) { | 592 if (input_.GetVideoFrame(&frame)) { |
592 // TODO(perkj): |pre_encode_callback| is only used by tests. Tests should | 593 // TODO(perkj): |pre_encode_callback| is only used by tests. Tests should |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 &module_nack_rate); | 809 &module_nack_rate); |
809 *sent_video_rate_bps += module_video_rate; | 810 *sent_video_rate_bps += module_video_rate; |
810 *sent_nack_rate_bps += module_nack_rate; | 811 *sent_nack_rate_bps += module_nack_rate; |
811 *sent_fec_rate_bps += module_fec_rate; | 812 *sent_fec_rate_bps += module_fec_rate; |
812 } | 813 } |
813 return 0; | 814 return 0; |
814 } | 815 } |
815 | 816 |
816 } // namespace internal | 817 } // namespace internal |
817 } // namespace webrtc | 818 } // namespace webrtc |
OLD | NEW |