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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 frag->fragmentationOffset[i] = offset; | 115 frag->fragmentationOffset[i] = offset; |
116 offset += info.redundant[i].encoded_bytes; | 116 offset += info.redundant[i].encoded_bytes; |
117 frag->fragmentationLength[i] = info.redundant[i].encoded_bytes; | 117 frag->fragmentationLength[i] = info.redundant[i].encoded_bytes; |
118 frag->fragmentationTimeDiff[i] = rtc::checked_cast<uint16_t>( | 118 frag->fragmentationTimeDiff[i] = rtc::checked_cast<uint16_t>( |
119 info.encoded_timestamp - info.redundant[i].encoded_timestamp); | 119 info.encoded_timestamp - info.redundant[i].encoded_timestamp); |
120 frag->fragmentationPlType[i] = info.redundant[i].payload_type; | 120 frag->fragmentationPlType[i] = info.redundant[i].payload_type; |
121 } | 121 } |
122 } | 122 } |
123 } // namespace | 123 } // namespace |
124 | 124 |
| 125 void AudioCodingModuleImpl::ChangeLogger::MaybeLog(int value) { |
| 126 if (value != last_value_ || first_time_) { |
| 127 first_time_ = false; |
| 128 last_value_ = value; |
| 129 RTC_HISTOGRAM_COUNTS_100(histogram_name_, value); |
| 130 } |
| 131 } |
| 132 |
125 AudioCodingModuleImpl::AudioCodingModuleImpl( | 133 AudioCodingModuleImpl::AudioCodingModuleImpl( |
126 const AudioCodingModule::Config& config) | 134 const AudioCodingModule::Config& config) |
127 : acm_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), | 135 : acm_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), |
128 id_(config.id), | 136 id_(config.id), |
129 expected_codec_ts_(0xD87F3F9F), | 137 expected_codec_ts_(0xD87F3F9F), |
130 expected_in_ts_(0xD87F3F9F), | 138 expected_in_ts_(0xD87F3F9F), |
131 receiver_(config), | 139 receiver_(config), |
| 140 bitrate_logger_("WebRTC.Audio.TargetBitrateInKbps"), |
132 previous_pltype_(255), | 141 previous_pltype_(255), |
133 aux_rtp_header_(NULL), | 142 aux_rtp_header_(NULL), |
134 receiver_initialized_(false), | 143 receiver_initialized_(false), |
135 first_10ms_data_(false), | 144 first_10ms_data_(false), |
136 first_frame_(true), | 145 first_frame_(true), |
137 callback_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), | 146 callback_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), |
138 packetization_callback_(NULL), | 147 packetization_callback_(NULL), |
139 vad_callback_(NULL) { | 148 vad_callback_(NULL) { |
140 if (InitializeReceiverSafe() < 0) { | 149 if (InitializeReceiverSafe() < 0) { |
141 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, | 150 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 static_cast<uint32_t>(rtc::CheckedDivExact( | 187 static_cast<uint32_t>(rtc::CheckedDivExact( |
179 audio_encoder->SampleRateHz(), | 188 audio_encoder->SampleRateHz(), |
180 audio_encoder->RtpTimestampRateHz()))); | 189 audio_encoder->RtpTimestampRateHz()))); |
181 last_timestamp_ = input_data.input_timestamp; | 190 last_timestamp_ = input_data.input_timestamp; |
182 last_rtp_timestamp_ = rtp_timestamp; | 191 last_rtp_timestamp_ = rtp_timestamp; |
183 first_frame_ = false; | 192 first_frame_ = false; |
184 | 193 |
185 encoded_info = audio_encoder->Encode(rtp_timestamp, input_data.audio, | 194 encoded_info = audio_encoder->Encode(rtp_timestamp, input_data.audio, |
186 input_data.length_per_channel, | 195 input_data.length_per_channel, |
187 sizeof(stream), stream); | 196 sizeof(stream), stream); |
| 197 bitrate_logger_.MaybeLog(audio_encoder->GetTargetBitrate() / 1000); |
188 if (encoded_info.encoded_bytes == 0 && !encoded_info.send_even_if_empty) { | 198 if (encoded_info.encoded_bytes == 0 && !encoded_info.send_even_if_empty) { |
189 // Not enough data. | 199 // Not enough data. |
190 return 0; | 200 return 0; |
191 } | 201 } |
192 previous_pltype = previous_pltype_; // Read it while we have the critsect. | 202 previous_pltype = previous_pltype_; // Read it while we have the critsect. |
193 | 203 |
194 RTPFragmentationHeader my_fragmentation; | 204 RTPFragmentationHeader my_fragmentation; |
195 ConvertEncodedInfoToFragmentationHeader(encoded_info, &my_fragmentation); | 205 ConvertEncodedInfoToFragmentationHeader(encoded_info, &my_fragmentation); |
196 FrameType frame_type; | 206 FrameType frame_type; |
197 if (encoded_info.encoded_bytes == 0 && encoded_info.send_even_if_empty) { | 207 if (encoded_info.encoded_bytes == 0 && encoded_info.send_even_if_empty) { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 // WebRtcACMCodecParams encoder_param; | 299 // WebRtcACMCodecParams encoder_param; |
290 // codec_manager_.current_encoder()->EncoderParams(&encoder_param); | 300 // codec_manager_.current_encoder()->EncoderParams(&encoder_param); |
291 // | 301 // |
292 // return encoder_param.codec_inst.rate; | 302 // return encoder_param.codec_inst.rate; |
293 } | 303 } |
294 | 304 |
295 void AudioCodingModuleImpl::SetBitRate(int bitrate_bps) { | 305 void AudioCodingModuleImpl::SetBitRate(int bitrate_bps) { |
296 CriticalSectionScoped lock(acm_crit_sect_); | 306 CriticalSectionScoped lock(acm_crit_sect_); |
297 if (codec_manager_.CurrentEncoder()) { | 307 if (codec_manager_.CurrentEncoder()) { |
298 codec_manager_.CurrentEncoder()->SetTargetBitrate(bitrate_bps); | 308 codec_manager_.CurrentEncoder()->SetTargetBitrate(bitrate_bps); |
299 RTC_HISTOGRAM_COUNTS_100( | |
300 HISTOGRAM_NAME_AUDIO_TARGET_BITRATE_IN_KBPS, | |
301 codec_manager_.CurrentEncoder()->GetTargetBitrate() / 1000); | |
302 } | 309 } |
303 } | 310 } |
304 | 311 |
305 // Set available bandwidth, inform the encoder about the estimated bandwidth | 312 // Set available bandwidth, inform the encoder about the estimated bandwidth |
306 // received from the remote party. | 313 // received from the remote party. |
307 // TODO(henrik.lundin): Remove; not used. | 314 // TODO(henrik.lundin): Remove; not used. |
308 int AudioCodingModuleImpl::SetReceivedEstimatedBandwidth(int bw) { | 315 int AudioCodingModuleImpl::SetReceivedEstimatedBandwidth(int bw) { |
309 CriticalSectionScoped lock(acm_crit_sect_); | 316 CriticalSectionScoped lock(acm_crit_sect_); |
310 FATAL() << "Dead code?"; | 317 FATAL() << "Dead code?"; |
311 return -1; | 318 return -1; |
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1266 *channels = 1; | 1273 *channels = 1; |
1267 break; | 1274 break; |
1268 #endif | 1275 #endif |
1269 default: | 1276 default: |
1270 FATAL() << "Codec type " << codec_type << " not supported."; | 1277 FATAL() << "Codec type " << codec_type << " not supported."; |
1271 } | 1278 } |
1272 return true; | 1279 return true; |
1273 } | 1280 } |
1274 | 1281 |
1275 } // namespace webrtc | 1282 } // namespace webrtc |
OLD | NEW |