Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(482)

Side by Side Diff: webrtc/modules/video_coding/media_optimization.cc

Issue 2993703002: Remove unused members in MediaOptimization. (Closed)
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 19 matching lines...) Expand all
30 time_complete_ms(time_complete_ms) {} 30 time_complete_ms(time_complete_ms) {}
31 31
32 size_t size_bytes; 32 size_t size_bytes;
33 uint32_t timestamp; 33 uint32_t timestamp;
34 int64_t time_complete_ms; 34 int64_t time_complete_ms;
35 }; 35 };
36 36
37 MediaOptimization::MediaOptimization(Clock* clock) 37 MediaOptimization::MediaOptimization(Clock* clock)
38 : clock_(clock), 38 : clock_(clock),
39 max_bit_rate_(0), 39 max_bit_rate_(0),
40 codec_width_(0),
41 codec_height_(0),
42 user_frame_rate_(0), 40 user_frame_rate_(0),
43 frame_dropper_(new FrameDropper), 41 frame_dropper_(new FrameDropper),
44 send_statistics_zero_encode_(0),
45 max_payload_size_(1460),
46 video_target_bitrate_(0), 42 video_target_bitrate_(0),
47 incoming_frame_rate_(0), 43 incoming_frame_rate_(0),
48 encoded_frame_samples_(), 44 encoded_frame_samples_(),
49 avg_sent_framerate_(0), 45 avg_sent_framerate_(0) {
50 num_layers_(0) {
51 memset(send_statistics_, 0, sizeof(send_statistics_));
52 memset(incoming_frame_times_, -1, sizeof(incoming_frame_times_)); 46 memset(incoming_frame_times_, -1, sizeof(incoming_frame_times_));
53 } 47 }
54 48
55 MediaOptimization::~MediaOptimization(void) { 49 MediaOptimization::~MediaOptimization(void) {
56 } 50 }
57 51
58 void MediaOptimization::Reset() { 52 void MediaOptimization::Reset() {
59 rtc::CritScope lock(&crit_sect_); 53 rtc::CritScope lock(&crit_sect_);
60 SetEncodingDataInternal(0, 0, 0, 0, 0, 0, max_payload_size_); 54 SetEncodingDataInternal(0, 0, 0);
61 memset(incoming_frame_times_, -1, sizeof(incoming_frame_times_)); 55 memset(incoming_frame_times_, -1, sizeof(incoming_frame_times_));
62 incoming_frame_rate_ = 0.0; 56 incoming_frame_rate_ = 0.0;
63 frame_dropper_->Reset(); 57 frame_dropper_->Reset();
64 frame_dropper_->SetRates(0, 0); 58 frame_dropper_->SetRates(0, 0);
65 send_statistics_zero_encode_ = 0;
66 video_target_bitrate_ = 0; 59 video_target_bitrate_ = 0;
67 codec_width_ = 0;
68 codec_height_ = 0;
69 user_frame_rate_ = 0; 60 user_frame_rate_ = 0;
70 encoded_frame_samples_.clear(); 61 encoded_frame_samples_.clear();
71 num_layers_ = 1;
72 } 62 }
73 63
74 void MediaOptimization::SetEncodingData(int32_t max_bit_rate, 64 void MediaOptimization::SetEncodingData(int32_t max_bit_rate,
75 uint32_t target_bitrate, 65 uint32_t target_bitrate,
76 uint16_t width, 66 uint32_t frame_rate) {
77 uint16_t height,
78 uint32_t frame_rate,
79 int num_layers,
80 int32_t mtu) {
81 rtc::CritScope lock(&crit_sect_); 67 rtc::CritScope lock(&crit_sect_);
82 SetEncodingDataInternal(max_bit_rate, frame_rate, target_bitrate, width, 68 SetEncodingDataInternal(max_bit_rate, frame_rate, target_bitrate);
83 height, num_layers, mtu);
84 } 69 }
85 70
86 void MediaOptimization::SetEncodingDataInternal(int32_t max_bit_rate, 71 void MediaOptimization::SetEncodingDataInternal(int32_t max_bit_rate,
87 uint32_t frame_rate, 72 uint32_t frame_rate,
88 uint32_t target_bitrate, 73 uint32_t target_bitrate) {
89 uint16_t width,
90 uint16_t height,
91 int num_layers,
92 int32_t mtu) {
93 // Everything codec specific should be reset here since this means the codec 74 // Everything codec specific should be reset here since this means the codec
94 // has changed. 75 // has changed.
95
96 max_bit_rate_ = max_bit_rate; 76 max_bit_rate_ = max_bit_rate;
97 video_target_bitrate_ = target_bitrate; 77 video_target_bitrate_ = target_bitrate;
98 float target_bitrate_kbps = static_cast<float>(target_bitrate) / 1000.0f; 78 float target_bitrate_kbps = static_cast<float>(target_bitrate) / 1000.0f;
99 frame_dropper_->Reset(); 79 frame_dropper_->Reset();
100 frame_dropper_->SetRates(target_bitrate_kbps, static_cast<float>(frame_rate)); 80 frame_dropper_->SetRates(target_bitrate_kbps, static_cast<float>(frame_rate));
101 user_frame_rate_ = static_cast<float>(frame_rate); 81 user_frame_rate_ = static_cast<float>(frame_rate);
102 codec_width_ = width;
103 codec_height_ = height;
104 num_layers_ = (num_layers <= 1) ? 1 : num_layers; // Can also be zero.
105 max_payload_size_ = mtu;
106 } 82 }
107 83
108 uint32_t MediaOptimization::SetTargetRates(uint32_t target_bitrate) { 84 uint32_t MediaOptimization::SetTargetRates(uint32_t target_bitrate) {
109 rtc::CritScope lock(&crit_sect_); 85 rtc::CritScope lock(&crit_sect_);
110 86
111 video_target_bitrate_ = target_bitrate; 87 video_target_bitrate_ = target_bitrate;
112 88
113 // Cap target video bitrate to codec maximum. 89 // Cap target video bitrate to codec maximum.
114 if (max_bit_rate_ > 0 && video_target_bitrate_ > max_bit_rate_) { 90 if (max_bit_rate_ > 0 && video_target_bitrate_ > max_bit_rate_) {
115 video_target_bitrate_ = max_bit_rate_; 91 video_target_bitrate_ = max_bit_rate_;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 avg_sent_framerate_ = encoded_frame_samples_.size(); 216 avg_sent_framerate_ = encoded_frame_samples_.size();
241 } 217 }
242 } 218 }
243 219
244 // Allowing VCM to keep track of incoming frame rate. 220 // Allowing VCM to keep track of incoming frame rate.
245 void MediaOptimization::ProcessIncomingFrameRate(int64_t now) { 221 void MediaOptimization::ProcessIncomingFrameRate(int64_t now) {
246 int32_t num = 0; 222 int32_t num = 0;
247 int32_t nr_of_frames = 0; 223 int32_t nr_of_frames = 0;
248 for (num = 1; num < (kFrameCountHistorySize - 1); ++num) { 224 for (num = 1; num < (kFrameCountHistorySize - 1); ++num) {
249 if (incoming_frame_times_[num] <= 0 || 225 if (incoming_frame_times_[num] <= 0 ||
250 // don't use data older than 2 s 226 // Don't use data older than 2 s.
251 now - incoming_frame_times_[num] > kFrameHistoryWinMs) { 227 now - incoming_frame_times_[num] > kFrameHistoryWinMs) {
252 break; 228 break;
253 } else { 229 } else {
254 nr_of_frames++; 230 nr_of_frames++;
255 } 231 }
256 } 232 }
257 if (num > 1) { 233 if (num > 1) {
258 const int64_t diff = 234 const int64_t diff =
259 incoming_frame_times_[0] - incoming_frame_times_[num - 1]; 235 incoming_frame_times_[0] - incoming_frame_times_[num - 1];
260 incoming_frame_rate_ = 0.0; // No frame rate estimate available. 236 incoming_frame_rate_ = 0.0; // No frame rate estimate available.
261 if (diff > 0) { 237 if (diff > 0) {
262 incoming_frame_rate_ = nr_of_frames * 1000.0f / static_cast<float>(diff); 238 incoming_frame_rate_ = nr_of_frames * 1000.0f / static_cast<float>(diff);
263 } 239 }
264 } 240 }
265 } 241 }
266 } // namespace media_optimization 242 } // namespace media_optimization
267 } // namespace webrtc 243 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/media_optimization.h ('k') | webrtc/modules/video_coding/video_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698