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 12 matching lines...) Expand all Loading... |
23 #include "webrtc/modules/video_coding/include/video_coding_defines.h" | 23 #include "webrtc/modules/video_coding/include/video_coding_defines.h" |
24 #include "webrtc/system_wrappers/include/metrics.h" | 24 #include "webrtc/system_wrappers/include/metrics.h" |
25 #include "webrtc/video/overuse_frame_detector.h" | 25 #include "webrtc/video/overuse_frame_detector.h" |
26 #include "webrtc/video/send_statistics_proxy.h" | 26 #include "webrtc/video/send_statistics_proxy.h" |
27 #include "webrtc/video_frame.h" | 27 #include "webrtc/video_frame.h" |
28 | 28 |
29 namespace webrtc { | 29 namespace webrtc { |
30 | 30 |
31 static const float kStopPaddingThresholdMs = 2000; | 31 static const float kStopPaddingThresholdMs = 2000; |
32 | 32 |
33 class QMVideoSettingsCallback : public VCMQMSettingsCallback { | |
34 public: | |
35 explicit QMVideoSettingsCallback(VideoProcessing* vpm); | |
36 | |
37 ~QMVideoSettingsCallback(); | |
38 | |
39 // Update VPM with QM (quality modes: frame size & frame rate) settings. | |
40 int32_t SetVideoQMSettings(const uint32_t frame_rate, | |
41 const uint32_t width, | |
42 const uint32_t height); | |
43 | |
44 private: | |
45 VideoProcessing* vp_; | |
46 }; | |
47 | |
48 ViEEncoder::ViEEncoder(uint32_t number_of_cores, | 33 ViEEncoder::ViEEncoder(uint32_t number_of_cores, |
49 ProcessThread* module_process_thread, | 34 ProcessThread* module_process_thread, |
50 SendStatisticsProxy* stats_proxy, | 35 SendStatisticsProxy* stats_proxy, |
51 OveruseFrameDetector* overuse_detector) | 36 OveruseFrameDetector* overuse_detector) |
52 : number_of_cores_(number_of_cores), | 37 : number_of_cores_(number_of_cores), |
53 vp_(VideoProcessing::Create()), | 38 vp_(VideoProcessing::Create()), |
54 qm_callback_(new QMVideoSettingsCallback(vp_.get())), | 39 video_sender_(Clock::GetRealTimeClock(), this, this, this), |
55 video_sender_(Clock::GetRealTimeClock(), | |
56 this, | |
57 this, | |
58 qm_callback_.get(), | |
59 this), | |
60 stats_proxy_(stats_proxy), | 40 stats_proxy_(stats_proxy), |
61 overuse_detector_(overuse_detector), | 41 overuse_detector_(overuse_detector), |
62 time_of_last_frame_activity_ms_(0), | 42 time_of_last_frame_activity_ms_(0), |
63 encoder_config_(), | 43 encoder_config_(), |
64 min_transmit_bitrate_bps_(0), | 44 min_transmit_bitrate_bps_(0), |
65 last_observed_bitrate_bps_(0), | 45 last_observed_bitrate_bps_(0), |
66 network_is_transmitting_(true), | 46 network_is_transmitting_(true), |
67 encoder_paused_(true), | 47 encoder_paused_(true), |
68 encoder_paused_and_dropped_frame_(false), | 48 encoder_paused_and_dropped_frame_(false), |
69 module_process_thread_(module_process_thread), | 49 module_process_thread_(module_process_thread), |
70 has_received_sli_(false), | 50 has_received_sli_(false), |
71 picture_id_sli_(0), | 51 picture_id_sli_(0), |
72 has_received_rpsi_(false), | 52 has_received_rpsi_(false), |
73 picture_id_rpsi_(0), | 53 picture_id_rpsi_(0), |
74 video_suspended_(false) { | 54 video_suspended_(false) { |
75 module_process_thread_->RegisterModule(&video_sender_); | 55 module_process_thread_->RegisterModule(&video_sender_); |
76 vp_->EnableTemporalDecimation(true); | 56 vp_->EnableTemporalDecimation(true); |
77 | |
78 // Enable/disable content analysis: off by default for now. | |
79 vp_->EnableContentAnalysis(false); | |
80 } | 57 } |
81 | 58 |
82 vcm::VideoSender* ViEEncoder::video_sender() { | 59 vcm::VideoSender* ViEEncoder::video_sender() { |
83 return &video_sender_; | 60 return &video_sender_; |
84 } | 61 } |
85 | 62 |
86 ViEEncoder::~ViEEncoder() { | 63 ViEEncoder::~ViEEncoder() { |
87 module_process_thread_->DeRegisterModule(&video_sender_); | 64 module_process_thread_->DeRegisterModule(&video_sender_); |
88 } | 65 } |
89 | 66 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 codec_specific_info.codecSpecific.VP8.hasReceivedSLI = | 261 codec_specific_info.codecSpecific.VP8.hasReceivedSLI = |
285 has_received_sli_; | 262 has_received_sli_; |
286 codec_specific_info.codecSpecific.VP8.pictureIdRPSI = | 263 codec_specific_info.codecSpecific.VP8.pictureIdRPSI = |
287 picture_id_rpsi_; | 264 picture_id_rpsi_; |
288 codec_specific_info.codecSpecific.VP8.pictureIdSLI = | 265 codec_specific_info.codecSpecific.VP8.pictureIdSLI = |
289 picture_id_sli_; | 266 picture_id_sli_; |
290 has_received_sli_ = false; | 267 has_received_sli_ = false; |
291 has_received_rpsi_ = false; | 268 has_received_rpsi_ = false; |
292 } | 269 } |
293 | 270 |
294 video_sender_.AddVideoFrame(*frame_to_send, vp_->GetContentMetrics(), | 271 video_sender_.AddVideoFrame(*frame_to_send, &codec_specific_info); |
295 &codec_specific_info); | |
296 return; | 272 return; |
297 } | 273 } |
298 video_sender_.AddVideoFrame(*frame_to_send, nullptr, nullptr); | 274 video_sender_.AddVideoFrame(*frame_to_send, nullptr); |
299 } | 275 } |
300 | 276 |
301 void ViEEncoder::SendKeyFrame() { | 277 void ViEEncoder::SendKeyFrame() { |
302 video_sender_.IntraFrameRequest(0); | 278 video_sender_.IntraFrameRequest(0); |
303 } | 279 } |
304 | 280 |
305 void ViEEncoder::SetProtectionMethod(bool nack, bool fec) { | 281 void ViEEncoder::SetProtectionMethod(bool nack, bool fec) { |
306 // Set Video Protection for VCM. | 282 // Set Video Protection for VCM. |
307 VCMVideoProtection protection_mode; | 283 VCMVideoProtection protection_mode; |
308 if (fec) { | 284 if (fec) { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 | 360 |
385 if (!video_suspension_changed) | 361 if (!video_suspension_changed) |
386 return; | 362 return; |
387 // Video suspend-state changed, inform codec observer. | 363 // Video suspend-state changed, inform codec observer. |
388 LOG(LS_INFO) << "Video suspend state changed " << video_is_suspended; | 364 LOG(LS_INFO) << "Video suspend state changed " << video_is_suspended; |
389 | 365 |
390 if (stats_proxy_) | 366 if (stats_proxy_) |
391 stats_proxy_->OnSuspendChange(video_is_suspended); | 367 stats_proxy_->OnSuspendChange(video_is_suspended); |
392 } | 368 } |
393 | 369 |
394 QMVideoSettingsCallback::QMVideoSettingsCallback(VideoProcessing* vpm) | |
395 : vp_(vpm) { | |
396 } | |
397 | |
398 QMVideoSettingsCallback::~QMVideoSettingsCallback() { | |
399 } | |
400 | |
401 int32_t QMVideoSettingsCallback::SetVideoQMSettings( | |
402 const uint32_t frame_rate, | |
403 const uint32_t width, | |
404 const uint32_t height) { | |
405 return vp_->SetTargetResolution(width, height, frame_rate); | |
406 } | |
407 | |
408 } // namespace webrtc | 370 } // namespace webrtc |
OLD | NEW |