OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 25 matching lines...) Expand all Loading... |
36 OveruseFrameDetector* overuse_detector) | 36 OveruseFrameDetector* overuse_detector) |
37 : number_of_cores_(number_of_cores), | 37 : number_of_cores_(number_of_cores), |
38 vp_(VideoProcessing::Create()), | 38 vp_(VideoProcessing::Create()), |
39 video_sender_(Clock::GetRealTimeClock(), this, this, this), | 39 video_sender_(Clock::GetRealTimeClock(), this, this, this), |
40 stats_proxy_(stats_proxy), | 40 stats_proxy_(stats_proxy), |
41 overuse_detector_(overuse_detector), | 41 overuse_detector_(overuse_detector), |
42 time_of_last_frame_activity_ms_(0), | 42 time_of_last_frame_activity_ms_(0), |
43 encoder_config_(), | 43 encoder_config_(), |
44 min_transmit_bitrate_bps_(0), | 44 min_transmit_bitrate_bps_(0), |
45 last_observed_bitrate_bps_(0), | 45 last_observed_bitrate_bps_(0), |
46 network_is_transmitting_(true), | |
47 encoder_paused_(true), | 46 encoder_paused_(true), |
48 encoder_paused_and_dropped_frame_(false), | 47 encoder_paused_and_dropped_frame_(false), |
49 module_process_thread_(module_process_thread), | 48 module_process_thread_(module_process_thread), |
50 has_received_sli_(false), | 49 has_received_sli_(false), |
51 picture_id_sli_(0), | 50 picture_id_sli_(0), |
52 has_received_rpsi_(false), | 51 has_received_rpsi_(false), |
53 picture_id_rpsi_(0), | 52 picture_id_rpsi_(0), |
54 video_suspended_(false) { | 53 video_suspended_(false) { |
55 module_process_thread_->RegisterModule(&video_sender_); | 54 module_process_thread_->RegisterModule(&video_sender_); |
56 vp_->EnableTemporalDecimation(true); | 55 vp_->EnableTemporalDecimation(true); |
57 } | 56 } |
58 | 57 |
59 vcm::VideoSender* ViEEncoder::video_sender() { | 58 vcm::VideoSender* ViEEncoder::video_sender() { |
60 return &video_sender_; | 59 return &video_sender_; |
61 } | 60 } |
62 | 61 |
63 ViEEncoder::~ViEEncoder() { | 62 ViEEncoder::~ViEEncoder() { |
64 module_process_thread_->DeRegisterModule(&video_sender_); | 63 module_process_thread_->DeRegisterModule(&video_sender_); |
65 } | 64 } |
66 | 65 |
67 void ViEEncoder::SetNetworkTransmissionState(bool is_transmitting) { | |
68 { | |
69 rtc::CritScope lock(&data_cs_); | |
70 network_is_transmitting_ = is_transmitting; | |
71 } | |
72 } | |
73 | |
74 void ViEEncoder::Pause() { | 66 void ViEEncoder::Pause() { |
75 rtc::CritScope lock(&data_cs_); | 67 rtc::CritScope lock(&data_cs_); |
76 encoder_paused_ = true; | 68 encoder_paused_ = true; |
77 } | 69 } |
78 | 70 |
79 void ViEEncoder::Start() { | 71 void ViEEncoder::Start() { |
80 rtc::CritScope lock(&data_cs_); | 72 rtc::CritScope lock(&data_cs_); |
81 encoder_paused_ = false; | 73 encoder_paused_ = false; |
82 } | 74 } |
83 | 75 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 // Padding may never exceed bitrate estimate. | 184 // Padding may never exceed bitrate estimate. |
193 if (pad_up_to_bitrate_bps > bitrate_bps) | 185 if (pad_up_to_bitrate_bps > bitrate_bps) |
194 pad_up_to_bitrate_bps = bitrate_bps; | 186 pad_up_to_bitrate_bps = bitrate_bps; |
195 | 187 |
196 return pad_up_to_bitrate_bps; | 188 return pad_up_to_bitrate_bps; |
197 } | 189 } |
198 | 190 |
199 bool ViEEncoder::EncoderPaused() const { | 191 bool ViEEncoder::EncoderPaused() const { |
200 // Pause video if paused by caller or as long as the network is down or the | 192 // Pause video if paused by caller or as long as the network is down or the |
201 // pacer queue has grown too large in buffered mode. | 193 // pacer queue has grown too large in buffered mode. |
202 if (encoder_paused_) { | 194 // If the pacer queue has grown to large or the network is down, |
203 return true; | 195 // last_observed_bitrate_bps_ will be 0. |
204 } | 196 return encoder_paused_ || video_suspended_ || last_observed_bitrate_bps_ == 0; |
205 if (video_suspended_ || last_observed_bitrate_bps_ == 0) { | |
206 return true; | |
207 } | |
208 return !network_is_transmitting_; | |
209 } | 197 } |
210 | 198 |
211 void ViEEncoder::TraceFrameDropStart() { | 199 void ViEEncoder::TraceFrameDropStart() { |
212 // Start trace event only on the first frame after encoder is paused. | 200 // Start trace event only on the first frame after encoder is paused. |
213 if (!encoder_paused_and_dropped_frame_) { | 201 if (!encoder_paused_and_dropped_frame_) { |
214 TRACE_EVENT_ASYNC_BEGIN0("webrtc", "EncoderPaused", this); | 202 TRACE_EVENT_ASYNC_BEGIN0("webrtc", "EncoderPaused", this); |
215 } | 203 } |
216 encoder_paused_and_dropped_frame_ = true; | 204 encoder_paused_and_dropped_frame_ = true; |
217 return; | 205 return; |
218 } | 206 } |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 if (!video_suspension_changed) | 349 if (!video_suspension_changed) |
362 return; | 350 return; |
363 // Video suspend-state changed, inform codec observer. | 351 // Video suspend-state changed, inform codec observer. |
364 LOG(LS_INFO) << "Video suspend state changed " << video_is_suspended; | 352 LOG(LS_INFO) << "Video suspend state changed " << video_is_suspended; |
365 | 353 |
366 if (stats_proxy_) | 354 if (stats_proxy_) |
367 stats_proxy_->OnSuspendChange(video_is_suspended); | 355 stats_proxy_->OnSuspendChange(video_is_suspended); |
368 } | 356 } |
369 | 357 |
370 } // namespace webrtc | 358 } // namespace webrtc |
OLD | NEW |