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

Side by Side Diff: webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h

Issue 1203803004: Adding a new ChangeLogger class to handle UMA logging of bitrates (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing a typo Created 5 years, 5 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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 struct InputData { 243 struct InputData {
244 uint32_t input_timestamp; 244 uint32_t input_timestamp;
245 const int16_t* audio; 245 const int16_t* audio;
246 uint16_t length_per_channel; 246 uint16_t length_per_channel;
247 uint8_t audio_channel; 247 uint8_t audio_channel;
248 // If a re-mix is required (up or down), this buffer will store a re-mixed 248 // If a re-mix is required (up or down), this buffer will store a re-mixed
249 // version of the input. 249 // version of the input.
250 int16_t buffer[WEBRTC_10MS_PCM_AUDIO]; 250 int16_t buffer[WEBRTC_10MS_PCM_AUDIO];
251 }; 251 };
252 252
253 // This member class writes values to the named UMA histogram, but only if
254 // the value has changed since the last time (and always for the first call).
255 class ChangeLogger {
256 public:
257 explicit ChangeLogger(const std::string& histogram_name)
258 : histogram_name_(histogram_name) {}
259 // Logs the new value if it is different from the last logged value, or if
260 // this is the first call.
261 void MaybeLog(int value);
262
263 private:
264 int last_value_ = 0;
265 int first_time_ = true;
266 const std::string histogram_name_;
267 };
268
253 int Add10MsDataInternal(const AudioFrame& audio_frame, InputData* input_data) 269 int Add10MsDataInternal(const AudioFrame& audio_frame, InputData* input_data)
254 EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_); 270 EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_);
255 int Encode(const InputData& input_data) 271 int Encode(const InputData& input_data)
256 EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_); 272 EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_);
257 273
258 int InitializeReceiverSafe() EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_); 274 int InitializeReceiverSafe() EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_);
259 275
260 bool HaveValidEncoder(const char* caller_name) const 276 bool HaveValidEncoder(const char* caller_name) const
261 EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_); 277 EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_);
262 278
(...skipping 15 matching lines...) Expand all
278 // Change required states after starting to receive the codec corresponding 294 // Change required states after starting to receive the codec corresponding
279 // to |index|. 295 // to |index|.
280 int UpdateUponReceivingCodec(int index); 296 int UpdateUponReceivingCodec(int index);
281 297
282 CriticalSectionWrapper* acm_crit_sect_; 298 CriticalSectionWrapper* acm_crit_sect_;
283 int id_; // TODO(henrik.lundin) Make const. 299 int id_; // TODO(henrik.lundin) Make const.
284 uint32_t expected_codec_ts_ GUARDED_BY(acm_crit_sect_); 300 uint32_t expected_codec_ts_ GUARDED_BY(acm_crit_sect_);
285 uint32_t expected_in_ts_ GUARDED_BY(acm_crit_sect_); 301 uint32_t expected_in_ts_ GUARDED_BY(acm_crit_sect_);
286 ACMResampler resampler_ GUARDED_BY(acm_crit_sect_); 302 ACMResampler resampler_ GUARDED_BY(acm_crit_sect_);
287 AcmReceiver receiver_; // AcmReceiver has it's own internal lock. 303 AcmReceiver receiver_; // AcmReceiver has it's own internal lock.
304 ChangeLogger bitrate_logger_ GUARDED_BY(acm_crit_sect_);
288 CodecManager codec_manager_ GUARDED_BY(acm_crit_sect_); 305 CodecManager codec_manager_ GUARDED_BY(acm_crit_sect_);
289 306
290 // This is to keep track of CN instances where we can send DTMFs. 307 // This is to keep track of CN instances where we can send DTMFs.
291 uint8_t previous_pltype_ GUARDED_BY(acm_crit_sect_); 308 uint8_t previous_pltype_ GUARDED_BY(acm_crit_sect_);
292 309
293 // Used when payloads are pushed into ACM without any RTP info 310 // Used when payloads are pushed into ACM without any RTP info
294 // One example is when pre-encoded bit-stream is pushed from 311 // One example is when pre-encoded bit-stream is pushed from
295 // a file. 312 // a file.
296 // IMPORTANT: this variable is only used in IncomingPayload(), therefore, 313 // IMPORTANT: this variable is only used in IncomingPayload(), therefore,
297 // no lock acquired when interacting with this variable. If it is going to 314 // no lock acquired when interacting with this variable. If it is going to
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 int playout_frequency_hz_; 400 int playout_frequency_hz_;
384 // TODO(henrik.lundin): All members below this line are temporary and should 401 // TODO(henrik.lundin): All members below this line are temporary and should
385 // be removed after refactoring is completed. 402 // be removed after refactoring is completed.
386 rtc::scoped_ptr<acm2::AudioCodingModuleImpl> acm_old_; 403 rtc::scoped_ptr<acm2::AudioCodingModuleImpl> acm_old_;
387 CodecInst current_send_codec_; 404 CodecInst current_send_codec_;
388 }; 405 };
389 406
390 } // namespace webrtc 407 } // namespace webrtc
391 408
392 #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_AUDIO_CODING_MODULE_IMPL_H_ 409 #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_AUDIO_CODING_MODULE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698