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 |
11 #include "webrtc/modules/video_coding/main/source/media_optimization.h" | 11 #include "webrtc/modules/video_coding/main/source/media_optimization.h" |
12 | 12 |
13 #include "webrtc/modules/video_coding/main/source/content_metrics_processing.h" | 13 #include "webrtc/modules/video_coding/main/source/content_metrics_processing.h" |
14 #include "webrtc/modules/video_coding/main/source/qm_select.h" | 14 #include "webrtc/modules/video_coding/main/source/qm_select.h" |
15 #include "webrtc/modules/video_coding/utility/include/frame_dropper.h" | 15 #include "webrtc/modules/video_coding/utility/include/frame_dropper.h" |
16 #include "webrtc/system_wrappers/interface/clock.h" | 16 #include "webrtc/system_wrappers/interface/clock.h" |
17 #include "webrtc/system_wrappers/interface/logging.h" | 17 #include "webrtc/system_wrappers/interface/logging.h" |
18 #include "webrtc/system_wrappers/interface/metrics.h" | |
18 | 19 |
19 namespace webrtc { | 20 namespace webrtc { |
20 namespace media_optimization { | 21 namespace media_optimization { |
21 namespace { | 22 namespace { |
22 void UpdateProtectionCallback( | 23 void UpdateProtectionCallback( |
23 VCMProtectionMethod* selected_method, | 24 VCMProtectionMethod* selected_method, |
24 uint32_t* video_rate_bps, | 25 uint32_t* video_rate_bps, |
25 uint32_t* nack_overhead_rate_bps, | 26 uint32_t* nack_overhead_rate_bps, |
26 uint32_t* fec_overhead_rate_bps, | 27 uint32_t* fec_overhead_rate_bps, |
27 VCMProtectionCallback* video_protection_callback) { | 28 VCMProtectionCallback* video_protection_callback) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
97 key_frame_cnt_(0), | 98 key_frame_cnt_(0), |
98 delta_frame_cnt_(0), | 99 delta_frame_cnt_(0), |
99 content_(new VCMContentMetricsProcessing()), | 100 content_(new VCMContentMetricsProcessing()), |
100 qm_resolution_(new VCMQmResolution()), | 101 qm_resolution_(new VCMQmResolution()), |
101 last_qm_update_time_(0), | 102 last_qm_update_time_(0), |
102 last_change_time_(0), | 103 last_change_time_(0), |
103 num_layers_(0), | 104 num_layers_(0), |
104 suspension_enabled_(false), | 105 suspension_enabled_(false), |
105 video_suspended_(false), | 106 video_suspended_(false), |
106 suspension_threshold_bps_(0), | 107 suspension_threshold_bps_(0), |
107 suspension_window_bps_(0) { | 108 suspension_window_bps_(0), |
109 sent_frames_(0), | |
110 first_sent_frame_time_ms_(-1) { | |
108 memset(send_statistics_, 0, sizeof(send_statistics_)); | 111 memset(send_statistics_, 0, sizeof(send_statistics_)); |
109 memset(incoming_frame_times_, -1, sizeof(incoming_frame_times_)); | 112 memset(incoming_frame_times_, -1, sizeof(incoming_frame_times_)); |
110 } | 113 } |
111 | 114 |
112 MediaOptimization::~MediaOptimization(void) { | 115 MediaOptimization::~MediaOptimization(void) { |
116 UpdateHistograms(); | |
113 loss_prot_logic_->Release(); | 117 loss_prot_logic_->Release(); |
114 } | 118 } |
115 | 119 |
120 void MediaOptimization::UpdateHistograms() { | |
121 int fps = -1; | |
122 { | |
123 CriticalSectionScoped lock(crit_sect_.get()); | |
124 if (sent_frames_ > 0) { | |
125 int64_t elapsed_sec = | |
126 (clock_->TimeInMilliseconds() - first_sent_frame_time_ms_) / 1000; | |
127 if (elapsed_sec > metrics::kMinRunTimeInSeconds) { | |
128 fps = sent_frames_ / elapsed_sec; | |
129 } | |
130 } | |
131 } | |
132 if (fps != -1) { | |
133 RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.SentFramesPerSecond", fps); | |
pbos-webrtc
2015/06/09 12:49:01
Can you move these histograms to SendStatisticsPro
| |
134 } | |
135 } | |
136 | |
116 void MediaOptimization::Reset() { | 137 void MediaOptimization::Reset() { |
117 CriticalSectionScoped lock(crit_sect_.get()); | 138 CriticalSectionScoped lock(crit_sect_.get()); |
118 SetEncodingDataInternal( | 139 SetEncodingDataInternal( |
119 kVideoCodecUnknown, 0, 0, 0, 0, 0, 0, max_payload_size_); | 140 kVideoCodecUnknown, 0, 0, 0, 0, 0, 0, max_payload_size_); |
120 memset(incoming_frame_times_, -1, sizeof(incoming_frame_times_)); | 141 memset(incoming_frame_times_, -1, sizeof(incoming_frame_times_)); |
121 incoming_frame_rate_ = 0.0; | 142 incoming_frame_rate_ = 0.0; |
122 frame_dropper_->Reset(); | 143 frame_dropper_->Reset(); |
123 loss_prot_logic_->Reset(clock_->TimeInMilliseconds()); | 144 loss_prot_logic_->Reset(clock_->TimeInMilliseconds()); |
124 frame_dropper_->SetRates(0, 0); | 145 frame_dropper_->SetRates(0, 0); |
125 content_->Reset(); | 146 content_->Reset(); |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
374 if (encoded_frame_samples_.size() > 0 && | 395 if (encoded_frame_samples_.size() > 0 && |
375 encoded_frame_samples_.back().timestamp == timestamp) { | 396 encoded_frame_samples_.back().timestamp == timestamp) { |
376 // Frames having the same timestamp are generated from the same input | 397 // Frames having the same timestamp are generated from the same input |
377 // frame. We don't want to double count them, but only increment the | 398 // frame. We don't want to double count them, but only increment the |
378 // size_bytes. | 399 // size_bytes. |
379 encoded_frame_samples_.back().size_bytes += encoded_length; | 400 encoded_frame_samples_.back().size_bytes += encoded_length; |
380 encoded_frame_samples_.back().time_complete_ms = now_ms; | 401 encoded_frame_samples_.back().time_complete_ms = now_ms; |
381 } else { | 402 } else { |
382 encoded_frame_samples_.push_back( | 403 encoded_frame_samples_.push_back( |
383 EncodedFrameSample(encoded_length, timestamp, now_ms)); | 404 EncodedFrameSample(encoded_length, timestamp, now_ms)); |
405 ++sent_frames_; | |
406 if (first_sent_frame_time_ms_ == -1) | |
407 first_sent_frame_time_ms_ = now_ms; | |
384 } | 408 } |
385 UpdateSentBitrate(now_ms); | 409 UpdateSentBitrate(now_ms); |
386 UpdateSentFramerate(); | 410 UpdateSentFramerate(); |
387 if (encoded_length > 0) { | 411 if (encoded_length > 0) { |
388 const bool delta_frame = encoded_image._frameType != kKeyFrame; | 412 const bool delta_frame = encoded_image._frameType != kKeyFrame; |
389 | 413 |
390 frame_dropper_->Fill(encoded_length, delta_frame); | 414 frame_dropper_->Fill(encoded_length, delta_frame); |
391 if (max_payload_size_ > 0 && encoded_length > 0) { | 415 if (max_payload_size_ > 0 && encoded_length > 0) { |
392 const float min_packets_per_frame = | 416 const float min_packets_per_frame = |
393 encoded_length / static_cast<float>(max_payload_size_); | 417 encoded_length / static_cast<float>(max_payload_size_); |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
653 if (target_bit_rate_ > | 677 if (target_bit_rate_ > |
654 suspension_threshold_bps_ + suspension_window_bps_) { | 678 suspension_threshold_bps_ + suspension_window_bps_) { |
655 video_suspended_ = false; | 679 video_suspended_ = false; |
656 } | 680 } |
657 } | 681 } |
658 } | 682 } |
659 } | 683 } |
660 | 684 |
661 } // namespace media_optimization | 685 } // namespace media_optimization |
662 } // namespace webrtc | 686 } // namespace webrtc |
OLD | NEW |