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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 const std::vector<uint32_t>& ssrcs, | 57 const std::vector<uint32_t>& ssrcs, |
58 ProcessThread* module_process_thread, | 58 ProcessThread* module_process_thread, |
59 SendStatisticsProxy* stats_proxy, | 59 SendStatisticsProxy* stats_proxy, |
60 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback, | 60 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback, |
61 OveruseFrameDetector* overuse_detector, | 61 OveruseFrameDetector* overuse_detector, |
62 PacedSender* pacer) | 62 PacedSender* pacer) |
63 : number_of_cores_(number_of_cores), | 63 : number_of_cores_(number_of_cores), |
64 ssrcs_(ssrcs), | 64 ssrcs_(ssrcs), |
65 vp_(VideoProcessing::Create()), | 65 vp_(VideoProcessing::Create()), |
66 qm_callback_(new QMVideoSettingsCallback(vp_.get())), | 66 qm_callback_(new QMVideoSettingsCallback(vp_.get())), |
67 video_sender_(Clock::GetRealTimeClock(), this, this, qm_callback_.get()), | 67 video_sender_(Clock::GetRealTimeClock(), |
| 68 this, |
| 69 this, |
| 70 qm_callback_.get(), |
| 71 this), |
68 stats_proxy_(stats_proxy), | 72 stats_proxy_(stats_proxy), |
69 pre_encode_callback_(pre_encode_callback), | 73 pre_encode_callback_(pre_encode_callback), |
70 overuse_detector_(overuse_detector), | 74 overuse_detector_(overuse_detector), |
71 pacer_(pacer), | 75 pacer_(pacer), |
72 time_of_last_frame_activity_ms_(0), | 76 time_of_last_frame_activity_ms_(0), |
73 encoder_config_(), | 77 encoder_config_(), |
74 min_transmit_bitrate_bps_(0), | 78 min_transmit_bitrate_bps_(0), |
75 last_observed_bitrate_bps_(0), | 79 last_observed_bitrate_bps_(0), |
76 network_is_transmitting_(true), | 80 network_is_transmitting_(true), |
77 encoder_paused_(true), | 81 encoder_paused_(true), |
78 encoder_paused_and_dropped_frame_(false), | 82 encoder_paused_and_dropped_frame_(false), |
79 time_last_intra_request_ms_(ssrcs.size(), -1), | 83 time_last_intra_request_ms_(ssrcs.size(), -1), |
80 module_process_thread_(module_process_thread), | 84 module_process_thread_(module_process_thread), |
81 has_received_sli_(false), | 85 has_received_sli_(false), |
82 picture_id_sli_(0), | 86 picture_id_sli_(0), |
83 has_received_rpsi_(false), | 87 has_received_rpsi_(false), |
84 picture_id_rpsi_(0), | 88 picture_id_rpsi_(0), |
85 video_suspended_(false) { | 89 video_suspended_(false) { |
86 module_process_thread_->RegisterModule(&video_sender_); | 90 module_process_thread_->RegisterModule(&video_sender_); |
87 } | |
88 | |
89 bool ViEEncoder::Init() { | |
90 vp_->EnableTemporalDecimation(true); | 91 vp_->EnableTemporalDecimation(true); |
91 | 92 |
92 // Enable/disable content analysis: off by default for now. | 93 // Enable/disable content analysis: off by default for now. |
93 vp_->EnableContentAnalysis(false); | 94 vp_->EnableContentAnalysis(false); |
94 | |
95 // TODO(perkj): Remove |RegisterTransportCallback| as soon as we don't use | |
96 // VCMPacketizationCallback::OnEncoderImplementationName. | |
97 if (video_sender_.RegisterTransportCallback(this) != 0) { | |
98 return false; | |
99 } | |
100 if (video_sender_.RegisterSendStatisticsCallback(this) != 0) { | |
101 return false; | |
102 } | |
103 return true; | |
104 } | 95 } |
105 | 96 |
106 vcm::VideoSender* ViEEncoder::video_sender() { | 97 vcm::VideoSender* ViEEncoder::video_sender() { |
107 return &video_sender_; | 98 return &video_sender_; |
108 } | 99 } |
109 | 100 |
110 ViEEncoder::~ViEEncoder() { | 101 ViEEncoder::~ViEEncoder() { |
111 module_process_thread_->DeRegisterModule(&video_sender_); | 102 module_process_thread_->DeRegisterModule(&video_sender_); |
112 } | 103 } |
113 | 104 |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 protection_mode = nack ? kProtectionNack : kProtectionNone; | 337 protection_mode = nack ? kProtectionNack : kProtectionNone; |
347 } | 338 } |
348 video_sender_.SetVideoProtection(protection_mode); | 339 video_sender_.SetVideoProtection(protection_mode); |
349 } | 340 } |
350 | 341 |
351 void ViEEncoder::OnSetRates(uint32_t bitrate_bps, int framerate) { | 342 void ViEEncoder::OnSetRates(uint32_t bitrate_bps, int framerate) { |
352 if (stats_proxy_) | 343 if (stats_proxy_) |
353 stats_proxy_->OnSetRates(bitrate_bps, framerate); | 344 stats_proxy_->OnSetRates(bitrate_bps, framerate); |
354 } | 345 } |
355 | 346 |
356 void ViEEncoder::OnEncoderImplementationName(const char* implementation_name) { | |
357 if (stats_proxy_) | |
358 stats_proxy_->OnEncoderImplementationName(implementation_name); | |
359 } | |
360 | |
361 int32_t ViEEncoder::Encoded(const EncodedImage& encoded_image, | 347 int32_t ViEEncoder::Encoded(const EncodedImage& encoded_image, |
362 const CodecSpecificInfo* codec_specific_info, | 348 const CodecSpecificInfo* codec_specific_info, |
363 const RTPFragmentationHeader* fragmentation) { | 349 const RTPFragmentationHeader* fragmentation) { |
364 { | 350 { |
365 rtc::CritScope lock(&data_cs_); | 351 rtc::CritScope lock(&data_cs_); |
366 time_of_last_frame_activity_ms_ = TickTime::MillisecondTimestamp(); | 352 time_of_last_frame_activity_ms_ = TickTime::MillisecondTimestamp(); |
367 } | 353 } |
368 if (stats_proxy_) { | 354 if (stats_proxy_) { |
369 stats_proxy_->OnSendEncodedImage(encoded_image, codec_specific_info); | 355 stats_proxy_->OnSendEncodedImage(encoded_image, codec_specific_info); |
370 } | 356 } |
(...skipping 25 matching lines...) Expand all Loading... |
396 } | 382 } |
397 if (file_writer) { | 383 if (file_writer) { |
398 bool ok = file_writer->WriteFrame(encoded_image); | 384 bool ok = file_writer->WriteFrame(encoded_image); |
399 RTC_DCHECK(ok); | 385 RTC_DCHECK(ok); |
400 } | 386 } |
401 } | 387 } |
402 | 388 |
403 return success; | 389 return success; |
404 } | 390 } |
405 | 391 |
406 int32_t ViEEncoder::SendStatistics(const uint32_t bit_rate, | 392 void ViEEncoder::SendStatistics(uint32_t bit_rate, |
407 const uint32_t frame_rate) { | 393 uint32_t frame_rate, |
| 394 const std::string& encoder_name) { |
408 if (stats_proxy_) | 395 if (stats_proxy_) |
409 stats_proxy_->OnOutgoingRate(frame_rate, bit_rate); | 396 stats_proxy_->OnEncoderStatsUpdate(frame_rate, bit_rate, encoder_name); |
410 return 0; | |
411 } | 397 } |
412 | 398 |
413 void ViEEncoder::OnReceivedSLI(uint32_t /*ssrc*/, | 399 void ViEEncoder::OnReceivedSLI(uint32_t /*ssrc*/, |
414 uint8_t picture_id) { | 400 uint8_t picture_id) { |
415 rtc::CritScope lock(&data_cs_); | 401 rtc::CritScope lock(&data_cs_); |
416 picture_id_sli_ = picture_id; | 402 picture_id_sli_ = picture_id; |
417 has_received_sli_ = true; | 403 has_received_sli_ = true; |
418 } | 404 } |
419 | 405 |
420 void ViEEncoder::OnReceivedRPSI(uint32_t /*ssrc*/, | 406 void ViEEncoder::OnReceivedRPSI(uint32_t /*ssrc*/, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 } | 466 } |
481 | 467 |
482 int32_t QMVideoSettingsCallback::SetVideoQMSettings( | 468 int32_t QMVideoSettingsCallback::SetVideoQMSettings( |
483 const uint32_t frame_rate, | 469 const uint32_t frame_rate, |
484 const uint32_t width, | 470 const uint32_t width, |
485 const uint32_t height) { | 471 const uint32_t height) { |
486 return vp_->SetTargetResolution(width, height, frame_rate); | 472 return vp_->SetTargetResolution(width, height, frame_rate); |
487 } | 473 } |
488 | 474 |
489 } // namespace webrtc | 475 } // namespace webrtc |
OLD | NEW |