summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorfischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-08 00:34:23 +0000
committerfischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-08 00:34:23 +0000
commitb0b258f31f50eebfbaffdb98f8e36a9a8f86ca19 (patch)
tree758887d391d4ef2c278c4b5d40528ef3b9a05320 /media
parentf2c971f82ea27b15c674e1f9cbf3513b92636e86 (diff)
downloadchromium_src-b0b258f31f50eebfbaffdb98f8e36a9a8f86ca19.zip
chromium_src-b0b258f31f50eebfbaffdb98f8e36a9a8f86ca19.tar.gz
chromium_src-b0b258f31f50eebfbaffdb98f8e36a9a8f86ca19.tar.bz2
First cut at UMA-exposing histograms of media data in the wild.
BUG=102589 TEST=manual inspection of chrome://histograms/Media Review URL: http://codereview.chromium.org/8439062 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108951 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/base/audio_decoder_config.cc45
-rw-r--r--media/base/audio_decoder_config.h7
-rw-r--r--media/base/pipeline_impl.cc16
-rw-r--r--media/base/pipeline_impl.h3
-rw-r--r--media/base/video_decoder_config.cc28
-rw-r--r--media/base/video_decoder_config.h8
6 files changed, 101 insertions, 6 deletions
diff --git a/media/base/audio_decoder_config.cc b/media/base/audio_decoder_config.cc
index 80b23e2..243c4c5 100644
--- a/media/base/audio_decoder_config.cc
+++ b/media/base/audio_decoder_config.cc
@@ -5,6 +5,7 @@
#include "media/base/audio_decoder_config.h"
#include "base/logging.h"
+#include "base/metrics/histogram.h"
#include "media/base/limits.h"
namespace media {
@@ -27,6 +28,36 @@ AudioDecoderConfig::AudioDecoderConfig(AudioCodec codec,
extra_data, extra_data_size);
}
+// Helper enum used only for histogramming samples-per-second. Put
+// commonly-used rates here to get accurate reporting. Uncommon rates are
+// reported in a separate, bucketized, histogram.
+enum AudioSamplesPerSecond {
+ k8000Hz,
+ k16000Hz,
+ k32000Hz,
+ k48000Hz,
+ k96000Hz,
+ k11025Hz,
+ k22050Hz,
+ k44100Hz,
+ kUnexpected // Must always be last!
+};
+
+// Helper method to convert integral values to their respective enum values
+// above, or kUnexpected if no match exists.
+static AudioSamplesPerSecond AsAudioSamplesPerSecond(int samples_per_second) {
+ switch (samples_per_second) {
+ case 8000: return k8000Hz;
+ case 16000: return k16000Hz;
+ case 32000: return k32000Hz;
+ case 48000: return k48000Hz;
+ case 11025: return k11025Hz;
+ case 22050: return k22050Hz;
+ case 44100: return k44100Hz;
+ default: return kUnexpected;
+ }
+}
+
void AudioDecoderConfig::Initialize(AudioCodec codec,
int bits_per_channel,
ChannelLayout channel_layout,
@@ -35,6 +66,20 @@ void AudioDecoderConfig::Initialize(AudioCodec codec,
size_t extra_data_size) {
CHECK((extra_data_size != 0) == (extra_data != NULL));
+ UMA_HISTOGRAM_ENUMERATION("Media.AudioCodec", codec, kAudioCodecMax + 1);
+ // Fake enum histogram to get exact integral buckets. Expect to never see
+ // any values over 32 and even that is huge.
+ UMA_HISTOGRAM_ENUMERATION("Media.AudioBitsPerChannel", bits_per_channel, 40);
+ UMA_HISTOGRAM_ENUMERATION(
+ "Media.AudioChannelLayout", channel_layout, CHANNEL_LAYOUT_MAX);
+ AudioSamplesPerSecond asps = AsAudioSamplesPerSecond(samples_per_second);
+ if (asps != kUnexpected) {
+ UMA_HISTOGRAM_ENUMERATION("Media.AudioSamplesPerSecond", asps, kUnexpected);
+ } else {
+ UMA_HISTOGRAM_COUNTS(
+ "Media.AudioSamplesPerSecondUnexpected", samples_per_second);
+ }
+
codec_ = codec;
bits_per_channel_ = bits_per_channel;
channel_layout_ = channel_layout;
diff --git a/media/base/audio_decoder_config.h b/media/base/audio_decoder_config.h
index e4891fa..168a941 100644
--- a/media/base/audio_decoder_config.h
+++ b/media/base/audio_decoder_config.h
@@ -13,7 +13,10 @@
namespace media {
enum AudioCodec {
- kUnknownAudioCodec,
+ // These values are histogrammed over time; do not change their ordinal
+ // values. When deleting a codec replace it with a dummy value; when adding a
+ // codec, do so at the bottom (and update kAudioCodecMax).
+ kUnknownAudioCodec = 0,
kCodecAAC,
kCodecMP3,
kCodecPCM,
@@ -28,6 +31,8 @@ enum AudioCodec {
//
// The only acceptable time to add a new codec is if there is production code
// that uses said codec in the same CL.
+
+ kAudioCodecMax = kCodecPCM_MULAW // Must equal the last "real" codec above.
};
class MEDIA_EXPORT AudioDecoderConfig {
diff --git a/media/base/pipeline_impl.cc b/media/base/pipeline_impl.cc
index d62b0fc..e0d8270 100644
--- a/media/base/pipeline_impl.cc
+++ b/media/base/pipeline_impl.cc
@@ -12,6 +12,7 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/compiler_specific.h"
+#include "base/metrics/histogram.h"
#include "base/stl_util.h"
#include "base/string_util.h"
#include "base/synchronization/condition_variable.h"
@@ -67,7 +68,8 @@ PipelineImpl::PipelineImpl(MessageLoop* message_loop, MediaLog* media_log)
clock_(new Clock(&base::Time::Now)),
waiting_for_clock_update_(false),
state_(kCreated),
- current_bytes_(0) {
+ current_bytes_(0),
+ creation_time_(base::Time::Now()) {
media_log_->AddEvent(media_log_->CreatePipelineStateChangedEvent(kCreated));
ResetState();
media_log_->AddEvent(
@@ -372,6 +374,12 @@ void PipelineImpl::ResetState() {
}
void PipelineImpl::SetState(State next_state) {
+ if (state_ != kStarted && next_state == kStarted &&
+ !creation_time_.is_null()) {
+ UMA_HISTOGRAM_TIMES(
+ "Media.TimeToPipelineStarted", base::Time::Now() - creation_time_);
+ creation_time_ = base::Time();
+ }
state_ = next_state;
media_log_->AddEvent(media_log_->CreatePipelineStateChangedEvent(next_state));
}
@@ -491,6 +499,7 @@ void PipelineImpl::SetDuration(base::TimeDelta duration) {
media_log_->AddEvent(
media_log_->CreateTimeEvent(
MediaLogEvent::DURATION_SET, "duration", duration));
+ UMA_HISTOGRAM_LONG_TIMES("Media.Duration", duration);
base::AutoLock auto_lock(lock_);
duration_ = duration;
@@ -507,6 +516,11 @@ void PipelineImpl::SetTotalBytes(int64 total_bytes) {
media_log_->AddEvent(
media_log_->CreateIntegerEvent(
MediaLogEvent::TOTAL_BYTES_SET, "total_bytes", total_bytes));
+ int64 total_mbytes = total_bytes >> 20;
+ if (total_mbytes > kint32max)
+ total_mbytes = kint32max;
+ UMA_HISTOGRAM_CUSTOM_COUNTS(
+ "Media.TotalMBytes", static_cast<int32>(total_mbytes), 1, kint32max, 50);
base::AutoLock auto_lock(lock_);
total_bytes_ = total_bytes;
diff --git a/media/base/pipeline_impl.h b/media/base/pipeline_impl.h
index f2329f1..084e1cd 100644
--- a/media/base/pipeline_impl.h
+++ b/media/base/pipeline_impl.h
@@ -475,6 +475,9 @@ class MEDIA_EXPORT PipelineImpl : public Pipeline, public FilterHost {
// Statistics.
PipelineStatistics statistics_;
+ // Time of pipeline creation; is non-zero only until the pipeline first
+ // reaches "kStarted", at which point it is used & zeroed out.
+ base::Time creation_time_;
FRIEND_TEST_ALL_PREFIXES(PipelineImplTest, GetBufferedTime);
diff --git a/media/base/video_decoder_config.cc b/media/base/video_decoder_config.cc
index 6a7add8..06f4664 100644
--- a/media/base/video_decoder_config.cc
+++ b/media/base/video_decoder_config.cc
@@ -7,6 +7,7 @@
#include <cmath>
#include "base/logging.h"
+#include "base/metrics/histogram.h"
#include "media/base/limits.h"
namespace media {
@@ -39,8 +40,25 @@ VideoDecoderConfig::VideoDecoderConfig(VideoCodec codec,
VideoDecoderConfig::~VideoDecoderConfig() {}
-void VideoDecoderConfig::Initialize(VideoCodec codec,
- VideoFrame::Format format,
+// Common aspect ratios (multiplied by 100 and truncated) used for histogramming
+// video sizes. These were taken on 20111103 from
+// http://wikipedia.org/wiki/Aspect_ratio_(image)#Previous_and_currently_used_aspect_ratios
+static const int kCommonAspectRatios100[] = {
+ 100, 115, 133, 137, 143, 150, 155, 160, 166, 175, 177, 185, 200, 210, 220,
+ 221, 235, 237, 240, 255, 259, 266, 276, 293, 400, 1200,
+};
+
+template<class T> // T has int width() & height() methods.
+static void UmaHistogramAspectRatio(const char* name, const T& size) {
+ UMA_HISTOGRAM_CUSTOM_ENUMERATION(
+ name,
+ // Intentionally use integer division to truncate the result.
+ (size.width() * 100) / size.height(),
+ base::CustomHistogram::ArrayToCustomRanges(
+ kCommonAspectRatios100, arraysize(kCommonAspectRatios100)));
+}
+
+void VideoDecoderConfig::Initialize(VideoCodec codec, VideoFrame::Format format,
const gfx::Size& coded_size,
const gfx::Rect& visible_rect,
int frame_rate_numerator,
@@ -51,6 +69,12 @@ void VideoDecoderConfig::Initialize(VideoCodec codec,
size_t extra_data_size) {
CHECK((extra_data_size != 0) == (extra_data != NULL));
+ UMA_HISTOGRAM_ENUMERATION("Media.VideoCodec", codec, kVideoCodecMax + 1);
+ UMA_HISTOGRAM_COUNTS_10000("Media.VideoCodedWidth", coded_size.width());
+ UmaHistogramAspectRatio("Media.VideoCodedAspectRatio", coded_size);
+ UMA_HISTOGRAM_COUNTS_10000("Media.VideoVisibleWidth", visible_rect.width());
+ UmaHistogramAspectRatio("Media.VideoVisibleAspectRatio", visible_rect);
+
codec_ = codec;
format_ = format;
coded_size_ = coded_size;
diff --git a/media/base/video_decoder_config.h b/media/base/video_decoder_config.h
index 00a19eb..b02bee8 100644
--- a/media/base/video_decoder_config.h
+++ b/media/base/video_decoder_config.h
@@ -15,18 +15,22 @@
namespace media {
enum VideoCodec {
- kUnknownVideoCodec,
+ // These values are histogrammed over time; do not change their ordinal
+ // values. When deleting a codec replace it with a dummy value; when adding a
+ // codec, do so at the bottom (and update kVideoCodecMax).
+ kUnknownVideoCodec = 0,
kCodecH264,
kCodecVC1,
kCodecMPEG2,
kCodecMPEG4,
kCodecTheora,
kCodecVP8,
-
// DO NOT ADD RANDOM VIDEO CODECS!
//
// The only acceptable time to add a new codec is if there is production code
// that uses said codec in the same CL.
+
+ kVideoCodecMax = kCodecVP8 // Must equal the last "real" codec above.
};
class MEDIA_EXPORT VideoDecoderConfig {