Index: webrtc/modules/audio_coding/acm2/audio_coding_module_impl.cc |
diff --git a/webrtc/modules/audio_coding/acm2/audio_coding_module_impl.cc b/webrtc/modules/audio_coding/acm2/audio_coding_module_impl.cc |
index 1a1ae37a8a38da869caa30fc78539ccb49c11028..39ce83c031da415f059660ee8dd178c87d4dc8c2 100644 |
--- a/webrtc/modules/audio_coding/acm2/audio_coding_module_impl.cc |
+++ b/webrtc/modules/audio_coding/acm2/audio_coding_module_impl.cc |
@@ -26,9 +26,22 @@ |
#include "webrtc/system_wrappers/include/rw_lock_wrapper.h" |
#include "webrtc/system_wrappers/include/trace.h" |
#include "webrtc/typedefs.h" |
+#include "webrtc/modules/audio_coding/codecs/audio_encoder.h" |
namespace webrtc { |
+namespace { |
+ |
+// Adds a codec usage sample to the histogram. |
+void UpdateCodecTypeHistogram(size_t codec_type) { |
+ RTC_HISTOGRAM_ENUMERATION( |
+ "WebRTC.Audio.Encoder.CodecType", codec_type, |
+ static_cast<size_t>( |
+ webrtc::AudioEncoder::CodecType::kMaxLoggedAudioCodecNames)); |
+} |
+ |
+} // namespace |
+ |
namespace acm2 { |
struct EncoderFactory { |
@@ -185,7 +198,9 @@ AudioCodingModuleImpl::AudioCodingModuleImpl( |
first_10ms_data_(false), |
first_frame_(true), |
packetization_callback_(NULL), |
- vad_callback_(NULL) { |
+ vad_callback_(NULL), |
+ codec_histogram_bins_log_(), |
+ number_of_consecutive_empty_packets_(0) { |
if (InitializeReceiverSafe() < 0) { |
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, |
"Cannot initialize receiver"); |
@@ -231,6 +246,20 @@ int32_t AudioCodingModuleImpl::Encode(const InputData& input_data) { |
} |
previous_pltype = previous_pltype_; // Read it while we have the critsect. |
+ // Log codec type to histogram once every 500 packets. |
+ if (encoded_info.encoded_bytes == 0) { |
+ ++number_of_consecutive_empty_packets_; |
+ } else { |
+ size_t codec_type = static_cast<size_t>(encoded_info.encoder_type); |
+ codec_histogram_bins_log_[codec_type] += |
+ number_of_consecutive_empty_packets_ + 1; |
+ number_of_consecutive_empty_packets_ = 0; |
+ if (codec_histogram_bins_log_[codec_type] >= 500) { |
+ codec_histogram_bins_log_[codec_type] -= 500; |
+ UpdateCodecTypeHistogram(codec_type); |
+ } |
+ } |
+ |
RTPFragmentationHeader my_fragmentation; |
ConvertEncodedInfoToFragmentationHeader(encoded_info, &my_fragmentation); |
FrameType frame_type; |