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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 network_is_transmitting_(true), | 130 network_is_transmitting_(true), |
131 encoder_paused_(false), | 131 encoder_paused_(false), |
132 encoder_paused_and_dropped_frame_(false), | 132 encoder_paused_and_dropped_frame_(false), |
133 fec_enabled_(false), | 133 fec_enabled_(false), |
134 nack_enabled_(false), | 134 nack_enabled_(false), |
135 module_process_thread_(module_process_thread), | 135 module_process_thread_(module_process_thread), |
136 has_received_sli_(false), | 136 has_received_sli_(false), |
137 picture_id_sli_(0), | 137 picture_id_sli_(0), |
138 has_received_rpsi_(false), | 138 has_received_rpsi_(false), |
139 picture_id_rpsi_(0), | 139 picture_id_rpsi_(0), |
140 video_suspended_(false), | 140 video_suspended_(false) { |
141 start_ms_(Clock::GetRealTimeClock()->TimeInMilliseconds()) { | |
142 bitrate_observer_.reset(new ViEBitrateObserver(this)); | 141 bitrate_observer_.reset(new ViEBitrateObserver(this)); |
143 } | 142 } |
144 | 143 |
145 bool ViEEncoder::Init() { | 144 bool ViEEncoder::Init() { |
146 vpm_->EnableTemporalDecimation(true); | 145 vpm_->EnableTemporalDecimation(true); |
147 | 146 |
148 // Enable/disable content analysis: off by default for now. | 147 // Enable/disable content analysis: off by default for now. |
149 vpm_->EnableContentAnalysis(false); | 148 vpm_->EnableContentAnalysis(false); |
150 | 149 |
151 if (vcm_->RegisterTransportCallback(this) != 0) { | 150 if (vcm_->RegisterTransportCallback(this) != 0) { |
(...skipping 16 matching lines...) Expand all Loading... |
168 } | 167 } |
169 | 168 |
170 void ViEEncoder::StopThreadsAndRemoveSharedMembers() { | 169 void ViEEncoder::StopThreadsAndRemoveSharedMembers() { |
171 if (bitrate_allocator_) | 170 if (bitrate_allocator_) |
172 bitrate_allocator_->RemoveBitrateObserver(bitrate_observer_.get()); | 171 bitrate_allocator_->RemoveBitrateObserver(bitrate_observer_.get()); |
173 module_process_thread_->DeRegisterModule(vcm_.get()); | 172 module_process_thread_->DeRegisterModule(vcm_.get()); |
174 module_process_thread_->DeRegisterModule(vpm_.get()); | 173 module_process_thread_->DeRegisterModule(vpm_.get()); |
175 } | 174 } |
176 | 175 |
177 ViEEncoder::~ViEEncoder() { | 176 ViEEncoder::~ViEEncoder() { |
178 UpdateHistograms(); | |
179 } | |
180 | |
181 void ViEEncoder::UpdateHistograms() { | |
182 int64_t elapsed_sec = | |
183 (Clock::GetRealTimeClock()->TimeInMilliseconds() - start_ms_) / 1000; | |
184 if (elapsed_sec < metrics::kMinRunTimeInSeconds) { | |
185 return; | |
186 } | |
187 webrtc::VCMFrameCount frames; | |
188 if (vcm_->SentFrameCount(frames) != VCM_OK) { | |
189 return; | |
190 } | |
191 uint32_t total_frames = frames.numKeyFrames + frames.numDeltaFrames; | |
192 if (total_frames > 0) { | |
193 RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.KeyFramesSentInPermille", | |
194 static_cast<int>( | |
195 (frames.numKeyFrames * 1000.0f / total_frames) + 0.5f)); | |
196 } | |
197 } | 177 } |
198 | 178 |
199 int ViEEncoder::Owner() const { | 179 int ViEEncoder::Owner() const { |
200 return channel_id_; | 180 return channel_id_; |
201 } | 181 } |
202 | 182 |
203 void ViEEncoder::SetNetworkTransmissionState(bool is_transmitting) { | 183 void ViEEncoder::SetNetworkTransmissionState(bool is_transmitting) { |
204 { | 184 { |
205 CriticalSectionScoped cs(data_cs_.get()); | 185 CriticalSectionScoped cs(data_cs_.get()); |
206 network_is_transmitting_ = is_transmitting; | 186 network_is_transmitting_ = is_transmitting; |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 return; | 466 return; |
487 } | 467 } |
488 #endif | 468 #endif |
489 vcm_->AddVideoFrame(*output_frame); | 469 vcm_->AddVideoFrame(*output_frame); |
490 } | 470 } |
491 | 471 |
492 int ViEEncoder::SendKeyFrame() { | 472 int ViEEncoder::SendKeyFrame() { |
493 return vcm_->IntraFrameRequest(0); | 473 return vcm_->IntraFrameRequest(0); |
494 } | 474 } |
495 | 475 |
496 int32_t ViEEncoder::SendCodecStatistics( | |
497 uint32_t* num_key_frames, uint32_t* num_delta_frames) { | |
498 webrtc::VCMFrameCount sent_frames; | |
499 if (vcm_->SentFrameCount(sent_frames) != VCM_OK) { | |
500 return -1; | |
501 } | |
502 *num_key_frames = sent_frames.numKeyFrames; | |
503 *num_delta_frames = sent_frames.numDeltaFrames; | |
504 return 0; | |
505 } | |
506 | |
507 uint32_t ViEEncoder::LastObservedBitrateBps() const { | 476 uint32_t ViEEncoder::LastObservedBitrateBps() const { |
508 CriticalSectionScoped cs(data_cs_.get()); | 477 CriticalSectionScoped cs(data_cs_.get()); |
509 return last_observed_bitrate_bps_; | 478 return last_observed_bitrate_bps_; |
510 } | 479 } |
511 | 480 |
512 int ViEEncoder::CodecTargetBitrate(uint32_t* bitrate) const { | 481 int ViEEncoder::CodecTargetBitrate(uint32_t* bitrate) const { |
513 if (vcm_->Bitrate(bitrate) != 0) | 482 if (vcm_->Bitrate(bitrate) != 0) |
514 return -1; | 483 return -1; |
515 return 0; | 484 return 0; |
516 } | 485 } |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 const uint32_t width, | 723 const uint32_t width, |
755 const uint32_t height) { | 724 const uint32_t height) { |
756 return vpm_->SetTargetResolution(width, height, frame_rate); | 725 return vpm_->SetTargetResolution(width, height, frame_rate); |
757 } | 726 } |
758 | 727 |
759 void QMVideoSettingsCallback::SetTargetFramerate(int frame_rate) { | 728 void QMVideoSettingsCallback::SetTargetFramerate(int frame_rate) { |
760 vpm_->SetTargetFramerate(frame_rate); | 729 vpm_->SetTargetFramerate(frame_rate); |
761 } | 730 } |
762 | 731 |
763 } // namespace webrtc | 732 } // namespace webrtc |
OLD | NEW |