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

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

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: Created 5 years, 6 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
11 #include "webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h" 11 #include "webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h"
12 12
13 #include <assert.h> 13 #include <assert.h>
14 #include <stdlib.h> 14 #include <stdlib.h>
15 #include <vector> 15 #include <vector>
16 16
17 #include "webrtc/base/checks.h" 17 #include "webrtc/base/checks.h"
18 #include "webrtc/base/safe_conversions.h" 18 #include "webrtc/base/safe_conversions.h"
19 #include "webrtc/engine_configurations.h" 19 #include "webrtc/engine_configurations.h"
20 #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedef s.h" 20 #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedef s.h"
21 #include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" 21 #include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
22 #include "webrtc/modules/audio_coding/main/acm2/acm_resampler.h" 22 #include "webrtc/modules/audio_coding/main/acm2/acm_resampler.h"
23 #include "webrtc/modules/audio_coding/main/acm2/call_statistics.h" 23 #include "webrtc/modules/audio_coding/main/acm2/call_statistics.h"
24 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" 24 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
25 #include "webrtc/system_wrappers/interface/logging.h" 25 #include "webrtc/system_wrappers/interface/logging.h"
26 #include "webrtc/system_wrappers/interface/metrics.h"
27 #include "webrtc/system_wrappers/interface/rw_lock_wrapper.h" 26 #include "webrtc/system_wrappers/interface/rw_lock_wrapper.h"
28 #include "webrtc/system_wrappers/interface/trace.h" 27 #include "webrtc/system_wrappers/interface/trace.h"
29 #include "webrtc/typedefs.h" 28 #include "webrtc/typedefs.h"
30 29
31 namespace webrtc { 30 namespace webrtc {
32 31
33 namespace acm2 { 32 namespace acm2 {
34 33
35 enum { 34 enum {
36 kACMToneEnd = 999 35 kACMToneEnd = 999
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 121 }
123 } // namespace 122 } // namespace
124 123
125 AudioCodingModuleImpl::AudioCodingModuleImpl( 124 AudioCodingModuleImpl::AudioCodingModuleImpl(
126 const AudioCodingModule::Config& config) 125 const AudioCodingModule::Config& config)
127 : acm_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), 126 : acm_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
128 id_(config.id), 127 id_(config.id),
129 expected_codec_ts_(0xD87F3F9F), 128 expected_codec_ts_(0xD87F3F9F),
130 expected_in_ts_(0xD87F3F9F), 129 expected_in_ts_(0xD87F3F9F),
131 receiver_(config), 130 receiver_(config),
131 bitrate_logger_("WebRTC.Audio.TargetBitrateInKbps"),
132 codec_manager_(&bitrate_logger_),
132 previous_pltype_(255), 133 previous_pltype_(255),
133 aux_rtp_header_(NULL), 134 aux_rtp_header_(NULL),
134 receiver_initialized_(false), 135 receiver_initialized_(false),
135 first_10ms_data_(false), 136 first_10ms_data_(false),
136 first_frame_(true), 137 first_frame_(true),
137 callback_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), 138 callback_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
138 packetization_callback_(NULL), 139 packetization_callback_(NULL),
139 vad_callback_(NULL) { 140 vad_callback_(NULL) {
140 if (InitializeReceiverSafe() < 0) { 141 if (InitializeReceiverSafe() < 0) {
141 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, 142 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 static_cast<uint32_t>(rtc::CheckedDivExact( 179 static_cast<uint32_t>(rtc::CheckedDivExact(
179 audio_encoder->SampleRateHz(), 180 audio_encoder->SampleRateHz(),
180 audio_encoder->RtpTimestampRateHz()))); 181 audio_encoder->RtpTimestampRateHz())));
181 last_timestamp_ = input_data.input_timestamp; 182 last_timestamp_ = input_data.input_timestamp;
182 last_rtp_timestamp_ = rtp_timestamp; 183 last_rtp_timestamp_ = rtp_timestamp;
183 first_frame_ = false; 184 first_frame_ = false;
184 185
185 encoded_info = audio_encoder->Encode(rtp_timestamp, input_data.audio, 186 encoded_info = audio_encoder->Encode(rtp_timestamp, input_data.audio,
186 input_data.length_per_channel, 187 input_data.length_per_channel,
187 sizeof(stream), stream); 188 sizeof(stream), stream);
189 bitrate_logger_.MaybeLogValue();
kwiberg-webrtc 2015/06/25 09:42:44 Sorry to come with an alternate suggestion at this
188 if (encoded_info.encoded_bytes == 0 && !encoded_info.send_even_if_empty) { 190 if (encoded_info.encoded_bytes == 0 && !encoded_info.send_even_if_empty) {
189 // Not enough data. 191 // Not enough data.
190 return 0; 192 return 0;
191 } 193 }
192 previous_pltype = previous_pltype_; // Read it while we have the critsect. 194 previous_pltype = previous_pltype_; // Read it while we have the critsect.
193 195
194 RTPFragmentationHeader my_fragmentation; 196 RTPFragmentationHeader my_fragmentation;
195 ConvertEncodedInfoToFragmentationHeader(encoded_info, &my_fragmentation); 197 ConvertEncodedInfoToFragmentationHeader(encoded_info, &my_fragmentation);
196 FrameType frame_type; 198 FrameType frame_type;
197 if (encoded_info.encoded_bytes == 0 && encoded_info.send_even_if_empty) { 199 if (encoded_info.encoded_bytes == 0 && encoded_info.send_even_if_empty) {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 // WebRtcACMCodecParams encoder_param; 291 // WebRtcACMCodecParams encoder_param;
290 // codec_manager_.current_encoder()->EncoderParams(&encoder_param); 292 // codec_manager_.current_encoder()->EncoderParams(&encoder_param);
291 // 293 //
292 // return encoder_param.codec_inst.rate; 294 // return encoder_param.codec_inst.rate;
293 } 295 }
294 296
295 void AudioCodingModuleImpl::SetBitRate(int bitrate_bps) { 297 void AudioCodingModuleImpl::SetBitRate(int bitrate_bps) {
296 CriticalSectionScoped lock(acm_crit_sect_); 298 CriticalSectionScoped lock(acm_crit_sect_);
297 if (codec_manager_.CurrentEncoder()) { 299 if (codec_manager_.CurrentEncoder()) {
298 codec_manager_.CurrentEncoder()->SetTargetBitrate(bitrate_bps); 300 codec_manager_.CurrentEncoder()->SetTargetBitrate(bitrate_bps);
299 RTC_HISTOGRAM_COUNTS_100( 301 bitrate_logger_.SetValue(
300 HISTOGRAM_NAME_AUDIO_TARGET_BITRATE_IN_KBPS,
301 codec_manager_.CurrentEncoder()->GetTargetBitrate() / 1000); 302 codec_manager_.CurrentEncoder()->GetTargetBitrate() / 1000);
302 } 303 }
303 } 304 }
304 305
305 // Set available bandwidth, inform the encoder about the estimated bandwidth 306 // Set available bandwidth, inform the encoder about the estimated bandwidth
306 // received from the remote party. 307 // received from the remote party.
307 // TODO(henrik.lundin): Remove; not used. 308 // TODO(henrik.lundin): Remove; not used.
308 int AudioCodingModuleImpl::SetReceivedEstimatedBandwidth(int bw) { 309 int AudioCodingModuleImpl::SetReceivedEstimatedBandwidth(int bw) {
309 CriticalSectionScoped lock(acm_crit_sect_); 310 CriticalSectionScoped lock(acm_crit_sect_);
310 FATAL() << "Dead code?"; 311 FATAL() << "Dead code?";
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 *channels = 1; 1267 *channels = 1;
1267 break; 1268 break;
1268 #endif 1269 #endif
1269 default: 1270 default:
1270 FATAL() << "Codec type " << codec_type << " not supported."; 1271 FATAL() << "Codec type " << codec_type << " not supported.";
1271 } 1272 }
1272 return true; 1273 return true;
1273 } 1274 }
1274 1275
1275 } // namespace webrtc 1276 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698