summaryrefslogtreecommitdiffstats
path: root/media/base
diff options
context:
space:
mode:
authorscottfr@chromium.org <scottfr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-17 01:00:39 +0000
committerscottfr@chromium.org <scottfr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-17 01:00:39 +0000
commite71d5327c21ced22e6d61af99ff8e889087ccf7e (patch)
tree2c81bb62f310610f33b1a4ad77585e5dbadaf136 /media/base
parent0cbc91fc0a683ab7b1e7408624c9328bb0541047 (diff)
downloadchromium_src-e71d5327c21ced22e6d61af99ff8e889087ccf7e.zip
chromium_src-e71d5327c21ced22e6d61af99ff8e889087ccf7e.tar.gz
chromium_src-e71d5327c21ced22e6d61af99ff8e889087ccf7e.tar.bz2
Log FilterHost events in PipelineImpl to MediaLog.
BUG= TEST= Review URL: http://codereview.chromium.org/7587007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97073 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base')
-rw-r--r--media/base/media_log.cc96
-rw-r--r--media/base/media_log.h10
-rw-r--r--media/base/media_log_event.h26
-rw-r--r--media/base/pipeline_impl.cc27
4 files changed, 159 insertions, 0 deletions
diff --git a/media/base/media_log.cc b/media/base/media_log.cc
index 15bca41..95b9e8b 100644
--- a/media/base/media_log.cc
+++ b/media/base/media_log.cc
@@ -35,6 +35,24 @@ const char* MediaLog::EventTypeToString(MediaLogEvent::Type type) {
return "PAUSE";
case MediaLogEvent::PIPELINE_STATE_CHANGED:
return "PIPELINE_STATE_CHANGED";
+ case MediaLogEvent::PIPELINE_ERROR:
+ return "PIPELINE_ERROR";
+ case MediaLogEvent::VIDEO_SIZE_SET:
+ return "VIDEO_SIZE_SET";
+ case MediaLogEvent::DURATION_SET:
+ return "DURATION_SET";
+ case MediaLogEvent::TOTAL_BYTES_SET:
+ return "TOTAL_BYTES_SET";
+ case MediaLogEvent::STREAMING_SET:
+ return "STREAMING_SET";
+ case MediaLogEvent::LOADED_SET:
+ return "LOADED_SET";
+ case MediaLogEvent::NETWORK_ACTIVITY_SET:
+ return "NETWORK_ACTIVITY_SET";
+ case MediaLogEvent::ENDED:
+ return "ENDED";
+ case MediaLogEvent::AUDIO_RENDERER_DISABLED:
+ return "AUDIO_RENDERER_DISABLED";
case MediaLogEvent::BUFFERED_EXTENTS_CHANGED:
return "BUFFERED_EXTENTS_CHANGED";
}
@@ -79,6 +97,49 @@ const char* MediaLog::PipelineStateToString(PipelineImpl::State state) {
return NULL;
}
+const char* MediaLog::PipelineStatusToString(PipelineStatus status) {
+ switch (status) {
+ case PIPELINE_OK:
+ return "pipeline: ok";
+ case PIPELINE_ERROR_URL_NOT_FOUND:
+ return "pipeline: url not found";
+ case PIPELINE_ERROR_NETWORK:
+ return "pipeline: network error";
+ case PIPELINE_ERROR_DECODE:
+ return "pipeline: decode error";
+ case PIPELINE_ERROR_ABORT:
+ return "pipeline: abort";
+ case PIPELINE_ERROR_INITIALIZATION_FAILED:
+ return "pipeline: initialization failed";
+ case PIPELINE_ERROR_REQUIRED_FILTER_MISSING:
+ return "pipeline: required filter missing";
+ case PIPELINE_ERROR_OUT_OF_MEMORY:
+ return "pipeline: out of memory";
+ case PIPELINE_ERROR_COULD_NOT_RENDER:
+ return "pipeline: could not render";
+ case PIPELINE_ERROR_READ:
+ return "pipeline: read error";
+ case PIPELINE_ERROR_AUDIO_HARDWARE:
+ return "pipeline: audio hardware error";
+ case PIPELINE_ERROR_OPERATION_PENDING:
+ return "pipeline: operation pending";
+ case PIPELINE_ERROR_INVALID_STATE:
+ return "pipeline: invalid state";
+ case DEMUXER_ERROR_COULD_NOT_OPEN:
+ return "demuxer: could not open";
+ case DEMUXER_ERROR_COULD_NOT_PARSE:
+ return "dumuxer: could not parse";
+ case DEMUXER_ERROR_NO_SUPPORTED_STREAMS:
+ return "demuxer: no supported streams";
+ case DEMUXER_ERROR_COULD_NOT_CREATE_THREAD:
+ return "demuxer: could not create thread";
+ case DATASOURCE_ERROR_URL_NOT_SUPPORTED:
+ return "data source: url not supported";
+ }
+ NOTREACHED();
+ return NULL;
+}
+
MediaLog::MediaLog() {
id_ = media_log_count.GetNext();
}
@@ -97,6 +158,28 @@ MediaLogEvent* MediaLog::CreateEvent(MediaLogEvent::Type type) {
return event.release();
}
+MediaLogEvent* MediaLog::CreateBooleanEvent(MediaLogEvent::Type type,
+ const char* property, bool value) {
+ scoped_ptr<MediaLogEvent> event(CreateEvent(type));
+ event->params.SetBoolean(property, value);
+ return event.release();
+}
+
+MediaLogEvent* MediaLog::CreateIntegerEvent(MediaLogEvent::Type type,
+ const char* property, int64 value) {
+ scoped_ptr<MediaLogEvent> event(CreateEvent(type));
+ event->params.SetInteger(property, value);
+ return event.release();
+}
+
+MediaLogEvent* MediaLog::CreateTimeEvent(MediaLogEvent::Type type,
+ const char* property,
+ base::TimeDelta value) {
+ scoped_ptr<MediaLogEvent> event(CreateEvent(type));
+ event->params.SetDouble(property, value.InSecondsF());
+ return event.release();
+}
+
MediaLogEvent* MediaLog::CreateLoadEvent(const std::string& url) {
scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::LOAD));
event->params.SetString("url", url);
@@ -117,6 +200,19 @@ MediaLogEvent* MediaLog::CreatePipelineStateChangedEvent(
return event.release();
}
+MediaLogEvent* MediaLog::CreatePipelineErrorEvent(PipelineStatus error) {
+ scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::PIPELINE_ERROR));
+ event->params.SetString("pipeline_error", PipelineStatusToString(error));
+ return event.release();
+}
+
+MediaLogEvent* MediaLog::CreateVideoSizeSetEvent(size_t width, size_t height) {
+ scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::VIDEO_SIZE_SET));
+ event->params.SetInteger("width", width);
+ event->params.SetInteger("height", height);
+ return event.release();
+}
+
MediaLogEvent* MediaLog::CreateBufferedExtentsChangedEvent(
size_t start, size_t current, size_t end) {
scoped_ptr<MediaLogEvent> event(
diff --git a/media/base/media_log.h b/media/base/media_log.h
index c9905e5..3a300e2d 100644
--- a/media/base/media_log.h
+++ b/media/base/media_log.h
@@ -9,6 +9,7 @@
#include "base/memory/ref_counted.h"
#include "media/base/media_log_event.h"
#include "media/base/pipeline_impl.h"
+#include "media/base/pipeline_status.h"
namespace media {
@@ -17,6 +18,7 @@ class MediaLog : public base::RefCountedThreadSafe<MediaLog> {
// Convert various enums to strings.
static const char* EventTypeToString(MediaLogEvent::Type type);
static const char* PipelineStateToString(PipelineImpl::State);
+ static const char* PipelineStatusToString(PipelineStatus);
MediaLog();
@@ -27,9 +29,17 @@ class MediaLog : public base::RefCountedThreadSafe<MediaLog> {
// Helper methods to create events and their parameters.
MediaLogEvent* CreateEvent(MediaLogEvent::Type type);
+ MediaLogEvent* CreateBooleanEvent(MediaLogEvent::Type type,
+ const char* property, bool value);
+ MediaLogEvent* CreateIntegerEvent(MediaLogEvent::Type type,
+ const char* property, int64 value);
+ MediaLogEvent* CreateTimeEvent(MediaLogEvent::Type type,
+ const char* property, base::TimeDelta value);
MediaLogEvent* CreateLoadEvent(const std::string& url);
MediaLogEvent* CreateSeekEvent(float seconds);
MediaLogEvent* CreatePipelineStateChangedEvent(PipelineImpl::State state);
+ MediaLogEvent* CreatePipelineErrorEvent(PipelineStatus error);
+ MediaLogEvent* CreateVideoSizeSetEvent(size_t width, size_t height);
MediaLogEvent* CreateBufferedExtentsChangedEvent(size_t start, size_t current,
size_t end);
diff --git a/media/base/media_log_event.h b/media/base/media_log_event.h
index 9d4e15e..1ebbaa8 100644
--- a/media/base/media_log_event.h
+++ b/media/base/media_log_event.h
@@ -40,6 +40,32 @@ struct MediaLogEvent {
// params: "pipeline_state": <string name of the state>.
PIPELINE_STATE_CHANGED,
+ // An error has occurred in the pipeline.
+ // params: "pipeline_error": <string name of the error>.
+ PIPELINE_ERROR,
+
+ // The size of the video has been determined.
+ // params: "width": <integral width of the video>.
+ // "height": <integral height of the video>.
+ VIDEO_SIZE_SET,
+
+ // A property of the pipeline has been set by a filter.
+ // These take a single parameter based upon the name of the event and of
+ // the appropriate type. e.g. DURATION_SET: "duration" of type TimeDelta.
+ DURATION_SET,
+ TOTAL_BYTES_SET,
+ STREAMING_SET,
+ LOADED_SET,
+ NETWORK_ACTIVITY_SET,
+
+ // Playback has ended.
+ // params: none.
+ ENDED,
+
+ // The audio renderer has been disabled.
+ // params: none.
+ AUDIO_RENDERER_DISABLED,
+
// The extents of the sliding buffer have changed.
// params: "buffer_start": <first buffered byte>.
// "buffer_current": <current offset>.
diff --git a/media/base/pipeline_impl.cc b/media/base/pipeline_impl.cc
index cdb3311..50cba5f 100644
--- a/media/base/pipeline_impl.cc
+++ b/media/base/pipeline_impl.cc
@@ -469,6 +469,8 @@ void PipelineImpl::SetError(PipelineStatus error) {
message_loop_->PostTask(FROM_HERE,
NewRunnableMethod(this, &PipelineImpl::ErrorChangedTask, error));
+
+ media_log_->AddEvent(media_log_->CreatePipelineErrorEvent(error));
}
base::TimeDelta PipelineImpl::GetTime() const {
@@ -500,6 +502,10 @@ void PipelineImpl::SetTime(base::TimeDelta time) {
void PipelineImpl::SetDuration(base::TimeDelta duration) {
DCHECK(IsRunning());
+ media_log_->AddEvent(
+ media_log_->CreateTimeEvent(
+ MediaLogEvent::DURATION_SET, "duration", duration));
+
base::AutoLock auto_lock(lock_);
duration_ = duration;
}
@@ -512,6 +518,10 @@ void PipelineImpl::SetBufferedTime(base::TimeDelta buffered_time) {
void PipelineImpl::SetTotalBytes(int64 total_bytes) {
DCHECK(IsRunning());
+ media_log_->AddEvent(
+ media_log_->CreateIntegerEvent(
+ MediaLogEvent::TOTAL_BYTES_SET, "total_bytes", total_bytes));
+
base::AutoLock auto_lock(lock_);
total_bytes_ = total_bytes;
}
@@ -528,6 +538,8 @@ void PipelineImpl::SetBufferedBytes(int64 buffered_bytes) {
void PipelineImpl::SetVideoSize(size_t width, size_t height) {
DCHECK(IsRunning());
+ media_log_->AddEvent(media_log_->CreateVideoSizeSetEvent(width, height));
+
base::AutoLock auto_lock(lock_);
video_width_ = width;
video_height_ = height;
@@ -535,6 +547,10 @@ void PipelineImpl::SetVideoSize(size_t width, size_t height) {
void PipelineImpl::SetStreaming(bool streaming) {
DCHECK(IsRunning());
+ media_log_->AddEvent(
+ media_log_->CreateBooleanEvent(
+ MediaLogEvent::STREAMING_SET, "streaming", streaming));
+
base::AutoLock auto_lock(lock_);
streaming_ = streaming;
}
@@ -543,10 +559,15 @@ void PipelineImpl::NotifyEnded() {
DCHECK(IsRunning());
message_loop_->PostTask(FROM_HERE,
NewRunnableMethod(this, &PipelineImpl::NotifyEndedTask));
+ media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::ENDED));
}
void PipelineImpl::SetLoaded(bool loaded) {
DCHECK(IsRunning());
+ media_log_->AddEvent(
+ media_log_->CreateBooleanEvent(
+ MediaLogEvent::LOADED_SET, "loaded", loaded));
+
base::AutoLock auto_lock(lock_);
loaded_ = loaded;
}
@@ -559,6 +580,10 @@ void PipelineImpl::SetNetworkActivity(bool network_activity) {
}
message_loop_->PostTask(FROM_HERE,
NewRunnableMethod(this, &PipelineImpl::NotifyNetworkEventTask));
+ media_log_->AddEvent(
+ media_log_->CreateBooleanEvent(
+ MediaLogEvent::NETWORK_ACTIVITY_SET,
+ "network_activity", network_activity));
}
void PipelineImpl::DisableAudioRenderer() {
@@ -567,6 +592,8 @@ void PipelineImpl::DisableAudioRenderer() {
// Disable renderer on the message loop.
message_loop_->PostTask(FROM_HERE,
NewRunnableMethod(this, &PipelineImpl::DisableAudioRendererTask));
+ media_log_->AddEvent(
+ media_log_->CreateEvent(MediaLogEvent::AUDIO_RENDERER_DISABLED));
}
// Called from any thread.