diff options
author | scottfr@chromium.org <scottfr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-20 06:25:06 +0000 |
---|---|---|
committer | scottfr@chromium.org <scottfr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-20 06:25:06 +0000 |
commit | 48d215486c5facfa878c037cf1e886b02936d607 (patch) | |
tree | 15be8325d1784eb256f35611b9b9fcf8b23a2b81 /media | |
parent | b781ff288ee35415b6fa72499aaf8a70f3863283 (diff) | |
download | chromium_src-48d215486c5facfa878c037cf1e886b02936d607.zip chromium_src-48d215486c5facfa878c037cf1e886b02936d607.tar.gz chromium_src-48d215486c5facfa878c037cf1e886b02936d607.tar.bz2 |
Log media pipeline statistics to MediaLog.
BUG=
TEST=
Review URL: http://codereview.chromium.org/7695008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97568 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/base/media_log.cc | 31 | ||||
-rw-r--r-- | media/base/media_log.h | 14 | ||||
-rw-r--r-- | media/base/media_log_event.h | 5 | ||||
-rw-r--r-- | media/base/pipeline_impl.cc | 1 |
4 files changed, 51 insertions, 0 deletions
diff --git a/media/base/media_log.cc b/media/base/media_log.cc index e829d1f..9ead460 100644 --- a/media/base/media_log.cc +++ b/media/base/media_log.cc @@ -57,6 +57,8 @@ const char* MediaLog::EventTypeToString(MediaLogEvent::Type type) { return "AUDIO_RENDERER_DISABLED"; case MediaLogEvent::BUFFERED_EXTENTS_CHANGED: return "BUFFERED_EXTENTS_CHANGED"; + case MediaLogEvent::STATISTICS_UPDATED: + return "STATISTICS_UPDATED"; } NOTREACHED(); return NULL; @@ -144,6 +146,7 @@ const char* MediaLog::PipelineStatusToString(PipelineStatus status) { MediaLog::MediaLog() { id_ = media_log_count.GetNext(); + stats_update_pending_ = false; } MediaLog::~MediaLog() {} @@ -225,4 +228,32 @@ MediaLogEvent* MediaLog::CreateBufferedExtentsChangedEvent( return event.release(); } +void MediaLog::QueueStatisticsUpdatedEvent(PipelineStatistics stats) { + base::AutoLock auto_lock(stats_lock_); + last_statistics_ = stats; + + if (!stats_update_pending_) { + stats_update_pending_ = true; + MessageLoop::current()->PostDelayedTask(FROM_HERE, + NewRunnableMethod(this, &media::MediaLog::AddStatisticsUpdatedEvent), + 500); + } +} + +void MediaLog::AddStatisticsUpdatedEvent() { + base::AutoLock auto_lock(stats_lock_); + scoped_ptr<MediaLogEvent> event( + CreateEvent(MediaLogEvent::STATISTICS_UPDATED)); + event->params.SetInteger("audio_bytes_decoded", + last_statistics_.audio_bytes_decoded); + event->params.SetInteger("video_bytes_decoded", + last_statistics_.video_bytes_decoded); + event->params.SetInteger("video_frames_decoded", + last_statistics_.video_frames_decoded); + event->params.SetInteger("video_frames_dropped", + last_statistics_.video_frames_dropped); + AddEvent(event.release()); + stats_update_pending_ = false; +} + } //namespace media diff --git a/media/base/media_log.h b/media/base/media_log.h index 3a300e2d..bdd8700 100644 --- a/media/base/media_log.h +++ b/media/base/media_log.h @@ -7,6 +7,7 @@ #pragma once #include "base/memory/ref_counted.h" +#include "base/synchronization/lock.h" #include "media/base/media_log_event.h" #include "media/base/pipeline_impl.h" #include "media/base/pipeline_status.h" @@ -43,14 +44,27 @@ class MediaLog : public base::RefCountedThreadSafe<MediaLog> { MediaLogEvent* CreateBufferedExtentsChangedEvent(size_t start, size_t current, size_t end); + // Called when the pipeline statistics have been updated. + // This gets called every frame, so we send the most recent stats after 500ms. + // This function is NOT thread safe. + void QueueStatisticsUpdatedEvent(PipelineStatistics stats); + protected: friend class base::RefCountedThreadSafe<MediaLog>; virtual ~MediaLog(); private: + // Actually add a STATISTICS_UPDATED event. + void AddStatisticsUpdatedEvent(); + // A unique (to this process) id for this MediaLog. int32 id_; + // The most recent set of pipeline stats. + PipelineStatistics last_statistics_; + bool stats_update_pending_; + base::Lock stats_lock_; + DISALLOW_COPY_AND_ASSIGN(MediaLog); }; diff --git a/media/base/media_log_event.h b/media/base/media_log_event.h index 1ebbaa8..8dae432 100644 --- a/media/base/media_log_event.h +++ b/media/base/media_log_event.h @@ -71,6 +71,11 @@ struct MediaLogEvent { // "buffer_current": <current offset>. // "buffer_end": <last buffered byte>. BUFFERED_EXTENTS_CHANGED, + + // The recorded statistics of the media pipeline have been updated. + // params: "audio_bytes_decoded", "video_bytes_decoded", + // "video_frames_decoded", "video_frames_dropped": <integers>. + STATISTICS_UPDATED, }; int32 id; diff --git a/media/base/pipeline_impl.cc b/media/base/pipeline_impl.cc index 50cba5f..97facab 100644 --- a/media/base/pipeline_impl.cc +++ b/media/base/pipeline_impl.cc @@ -634,6 +634,7 @@ void PipelineImpl::OnUpdateStatistics(const PipelineStatistics& stats) { statistics_.video_bytes_decoded += stats.video_bytes_decoded; statistics_.video_frames_decoded += stats.video_frames_decoded; statistics_.video_frames_dropped += stats.video_frames_dropped; + media_log_->QueueStatisticsUpdatedEvent(statistics_); } void PipelineImpl::StartTask(FilterCollection* filter_collection, |