Commit dabaf655 authored by scottfr@chromium.org's avatar scottfr@chromium.org

Plumb media data from renderers up to MediaInternals in the browser process.

BUG=none
TEST=manually


Review URL: http://codereview.chromium.org/7480032

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95542 0039d316-1c4b-4281-b951-d872f2087c98
parent c3d78e06
include_rules = [
"+media/base",
]
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "chrome/browser/media/media_internals_observer.h" #include "chrome/browser/media/media_internals_observer.h"
#include "content/browser/browser_thread.h" #include "content/browser/browser_thread.h"
#include "content/browser/webui/web_ui.h" #include "content/browser/webui/web_ui.h"
#include "media/base/media_log_event.h"
// The names of the javascript functions to call with updates. // The names of the javascript functions to call with updates.
static const char kDeleteItemFunction[] = "media.onItemDeleted"; static const char kDeleteItemFunction[] = "media.onItemDeleted";
...@@ -46,6 +47,13 @@ void MediaInternals::OnSetAudioStreamVolume( ...@@ -46,6 +47,13 @@ void MediaInternals::OnSetAudioStreamVolume(
"volume", Value::CreateDoubleValue(volume)); "volume", Value::CreateDoubleValue(volume));
} }
void MediaInternals::OnMediaEvent(
int render_process_id, const media::MediaLogEvent& event) {
DCHECK(CalledOnValidThread());
// TODO(scottfr): Handle |event|. Record status information in data_ and pass
// |event| along to observers.
}
void MediaInternals::AddObserver(MediaInternalsObserver* observer) { void MediaInternals::AddObserver(MediaInternalsObserver* observer) {
DCHECK(CalledOnValidThread()); DCHECK(CalledOnValidThread());
observers_.AddObserver(observer); observers_.AddObserver(observer);
......
...@@ -14,6 +14,10 @@ ...@@ -14,6 +14,10 @@
class MediaInternalsObserver; class MediaInternalsObserver;
namespace media {
struct MediaLogEvent;
}
// This class stores information about currently active media. // This class stores information about currently active media.
// All of its methods are called on the IO thread. // All of its methods are called on the IO thread.
class MediaInternals : public MediaObserver, public base::NonThreadSafe { class MediaInternals : public MediaObserver, public base::NonThreadSafe {
...@@ -26,6 +30,8 @@ class MediaInternals : public MediaObserver, public base::NonThreadSafe { ...@@ -26,6 +30,8 @@ class MediaInternals : public MediaObserver, public base::NonThreadSafe {
virtual void OnSetAudioStreamStatus(void* host, int stream_id, virtual void OnSetAudioStreamStatus(void* host, int stream_id,
const std::string& status); const std::string& status);
virtual void OnSetAudioStreamVolume(void* host, int stream_id, double volume); virtual void OnSetAudioStreamVolume(void* host, int stream_id, double volume);
virtual void OnMediaEvent(int render_process_id,
const media::MediaLogEvent& event);
// Methods for observers. // Methods for observers.
// Observers should add themselves on construction and remove themselves // Observers should add themselves on construction and remove themselves
......
...@@ -6,6 +6,10 @@ ...@@ -6,6 +6,10 @@
#define CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_OBSERVER_H_ #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_OBSERVER_H_
#pragma once #pragma once
namespace media {
struct MediaLogEvent;
}
// A class may implement MediaObserver and register itself with ResourceContext // A class may implement MediaObserver and register itself with ResourceContext
// to receive callbacks as media events occur. // to receive callbacks as media events occur.
class MediaObserver { class MediaObserver {
...@@ -27,6 +31,10 @@ class MediaObserver { ...@@ -27,6 +31,10 @@ class MediaObserver {
// Called when the volume of an audio stream is set. // Called when the volume of an audio stream is set.
virtual void OnSetAudioStreamVolume(void* host, int stream_id, virtual void OnSetAudioStreamVolume(void* host, int stream_id,
double volume) = 0; double volume) = 0;
// Called when a MediaEvent occurs.
virtual void OnMediaEvent(int render_process_id,
const media::MediaLogEvent& event) = 0;
}; };
#endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_OBSERVER_H_ #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_OBSERVER_H_
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "content/browser/renderer_host/media/media_observer.h" #include "content/browser/renderer_host/media/media_observer.h"
#include "media/base/media_log_event.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
class MockMediaObserver : public MediaObserver { class MockMediaObserver : public MediaObserver {
...@@ -25,6 +26,8 @@ class MockMediaObserver : public MediaObserver { ...@@ -25,6 +26,8 @@ class MockMediaObserver : public MediaObserver {
void(void* host, int stream_id, const std::string& status)); void(void* host, int stream_id, const std::string& status));
MOCK_METHOD3(OnSetAudioStreamVolume, MOCK_METHOD3(OnSetAudioStreamVolume,
void(void* host, int stream_id, double volume)); void(void* host, int stream_id, double volume));
MOCK_METHOD2(OnMediaEvent,
void(int source, const media::MediaLogEvent& event));
}; };
#endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MOCK_MEDIA_OBSERVER_H_ #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MOCK_MEDIA_OBSERVER_H_
...@@ -24,8 +24,10 @@ ...@@ -24,8 +24,10 @@
#include "content/browser/ppapi_plugin_process_host.h" #include "content/browser/ppapi_plugin_process_host.h"
#include "content/browser/ppapi_broker_process_host.h" #include "content/browser/ppapi_broker_process_host.h"
#include "content/browser/renderer_host/browser_render_process_host.h" #include "content/browser/renderer_host/browser_render_process_host.h"
#include "content/browser/renderer_host/media/media_observer.h"
#include "content/browser/renderer_host/render_view_host_delegate.h" #include "content/browser/renderer_host/render_view_host_delegate.h"
#include "content/browser/renderer_host/render_widget_helper.h" #include "content/browser/renderer_host/render_widget_helper.h"
#include "content/browser/resource_context.h"
#include "content/browser/user_metrics.h" #include "content/browser/user_metrics.h"
#include "content/common/content_switches.h" #include "content/common/content_switches.h"
#include "content/common/desktop_notification_messages.h" #include "content/common/desktop_notification_messages.h"
...@@ -35,6 +37,7 @@ ...@@ -35,6 +37,7 @@
#include "ipc/ipc_channel_handle.h" #include "ipc/ipc_channel_handle.h"
#include "ipc/ipc_platform_file.h" #include "ipc/ipc_platform_file.h"
#include "media/audio/audio_util.h" #include "media/audio/audio_util.h"
#include "media/base/media_log_event.h"
#include "net/base/cookie_monster.h" #include "net/base/cookie_monster.h"
#include "net/base/host_resolver_impl.h" #include "net/base/host_resolver_impl.h"
#include "net/base/io_buffer.h" #include "net/base/io_buffer.h"
...@@ -369,6 +372,7 @@ bool RenderMessageFilter::OnMessageReceived(const IPC::Message& message, ...@@ -369,6 +372,7 @@ bool RenderMessageFilter::OnMessageReceived(const IPC::Message& message,
IPC_MESSAGE_HANDLER(ViewHostMsg_AsyncOpenFile, OnAsyncOpenFile) IPC_MESSAGE_HANDLER(ViewHostMsg_AsyncOpenFile, OnAsyncOpenFile)
IPC_MESSAGE_HANDLER(ViewHostMsg_GetHardwareSampleRate, IPC_MESSAGE_HANDLER(ViewHostMsg_GetHardwareSampleRate,
OnGetHardwareSampleRate) OnGetHardwareSampleRate)
IPC_MESSAGE_HANDLER(ViewHostMsg_MediaLogEvent, OnMediaLogEvent)
IPC_MESSAGE_UNHANDLED(handled = false) IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP_EX() IPC_END_MESSAGE_MAP_EX()
...@@ -867,6 +871,10 @@ void RenderMessageFilter::AsyncOpenFileOnFileThread(const FilePath& path, ...@@ -867,6 +871,10 @@ void RenderMessageFilter::AsyncOpenFileOnFileThread(const FilePath& path,
this, &RenderMessageFilter::Send, reply)); this, &RenderMessageFilter::Send, reply));
} }
void RenderMessageFilter::OnMediaLogEvent(const media::MediaLogEvent& event) {
resource_context_.media_observer()->OnMediaEvent(render_process_id_, event);
}
void RenderMessageFilter::CheckPolicyForCookies( void RenderMessageFilter::CheckPolicyForCookies(
const GURL& url, const GURL& url,
const GURL& first_party_for_cookies, const GURL& first_party_for_cookies,
......
...@@ -49,6 +49,10 @@ namespace gfx { ...@@ -49,6 +49,10 @@ namespace gfx {
class Rect; class Rect;
} }
namespace media {
struct MediaLogEvent;
}
namespace net { namespace net {
class CookieList; class CookieList;
class URLRequestContextGetter; class URLRequestContextGetter;
...@@ -212,6 +216,7 @@ class RenderMessageFilter : public BrowserMessageFilter { ...@@ -212,6 +216,7 @@ class RenderMessageFilter : public BrowserMessageFilter {
int flags, int flags,
int message_id, int message_id,
int routing_id); int routing_id);
void OnMediaLogEvent(const media::MediaLogEvent&);
// Check the policy for getting cookies. Gets the cookies if allowed. // Check the policy for getting cookies. Gets the cookies if allowed.
void CheckPolicyForCookies(const GURL& url, void CheckPolicyForCookies(const GURL& url,
......
include_rules = [
"+media/base", # For media_log_event.h.
]
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "content/common/window_container_type.h" #include "content/common/window_container_type.h"
#include "ipc/ipc_message_macros.h" #include "ipc/ipc_message_macros.h"
#include "ipc/ipc_platform_file.h" #include "ipc/ipc_platform_file.h"
#include "media/base/media_log_event.h"
#include "net/base/host_port_pair.h" #include "net/base/host_port_pair.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderline.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderline.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h"
...@@ -172,6 +173,7 @@ IPC_ENUM_TRAITS(webkit_glue::WebAccessibility::IntAttribute) ...@@ -172,6 +173,7 @@ IPC_ENUM_TRAITS(webkit_glue::WebAccessibility::IntAttribute)
IPC_ENUM_TRAITS(webkit_glue::WebAccessibility::Role) IPC_ENUM_TRAITS(webkit_glue::WebAccessibility::Role)
IPC_ENUM_TRAITS(webkit_glue::WebAccessibility::State) IPC_ENUM_TRAITS(webkit_glue::WebAccessibility::State)
IPC_ENUM_TRAITS(webkit_glue::WebAccessibility::StringAttribute) IPC_ENUM_TRAITS(webkit_glue::WebAccessibility::StringAttribute)
IPC_ENUM_TRAITS(media::MediaLogEvent::Type)
IPC_STRUCT_TRAITS_BEGIN(ContextMenuParams) IPC_STRUCT_TRAITS_BEGIN(ContextMenuParams)
IPC_STRUCT_TRAITS_MEMBER(media_type) IPC_STRUCT_TRAITS_MEMBER(media_type)
...@@ -408,6 +410,13 @@ IPC_STRUCT_TRAITS_BEGIN(webkit::npapi::WebPluginInfo) ...@@ -408,6 +410,13 @@ IPC_STRUCT_TRAITS_BEGIN(webkit::npapi::WebPluginInfo)
IPC_STRUCT_TRAITS_MEMBER(enabled) IPC_STRUCT_TRAITS_MEMBER(enabled)
IPC_STRUCT_TRAITS_END() IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(media::MediaLogEvent)
IPC_STRUCT_TRAITS_MEMBER(id)
IPC_STRUCT_TRAITS_MEMBER(type)
IPC_STRUCT_TRAITS_MEMBER(params)
IPC_STRUCT_TRAITS_MEMBER(time)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_BEGIN(ViewHostMsg_CreateWindow_Params) IPC_STRUCT_BEGIN(ViewHostMsg_CreateWindow_Params)
// Routing ID of the view initiating the open. // Routing ID of the view initiating the open.
IPC_STRUCT_MEMBER(int, opener_id) IPC_STRUCT_MEMBER(int, opener_id)
...@@ -2028,3 +2037,6 @@ IPC_MESSAGE_ROUTED3(ViewHostMsg_SendSerializedHtmlData, ...@@ -2028,3 +2037,6 @@ IPC_MESSAGE_ROUTED3(ViewHostMsg_SendSerializedHtmlData,
// being sent back. // being sent back.
IPC_MESSAGE_ROUTED0(ViewHostMsg_RequestRemoteAccessClientFirewallTraversal) IPC_MESSAGE_ROUTED0(ViewHostMsg_RequestRemoteAccessClientFirewallTraversal)
// Notifies the browser of an event occurring in the media pipeline.
IPC_MESSAGE_CONTROL1(ViewHostMsg_MediaLogEvent,
media::MediaLogEvent /* event */)
...@@ -81,6 +81,8 @@ ...@@ -81,6 +81,8 @@
'renderer/media/media_stream_dispatcher_eventhandler.h', 'renderer/media/media_stream_dispatcher_eventhandler.h',
'renderer/media/media_stream_impl.cc', 'renderer/media/media_stream_impl.cc',
'renderer/media/media_stream_impl.h', 'renderer/media/media_stream_impl.h',
'renderer/media/render_media_log.cc',
'renderer/media/render_media_log.h',
'renderer/media/rtc_video_decoder.cc', 'renderer/media/rtc_video_decoder.cc',
'renderer/media/rtc_video_decoder.h', 'renderer/media/rtc_video_decoder.h',
'renderer/media/video_capture_impl.cc', 'renderer/media/video_capture_impl.cc',
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/renderer/media/render_media_log.h"
#include "base/message_loop_proxy.h"
#include "content/common/view_messages.h"
#include "content/renderer/render_thread.h"
RenderMediaLog::RenderMediaLog()
: render_loop_(base::MessageLoopProxy::CreateForCurrentThread()) {
DCHECK(RenderThread::current()) <<
"RenderMediaLog must be constructed on the render thread";
}
void RenderMediaLog::AddEvent(media::MediaLogEvent* event) {
scoped_ptr<media::MediaLogEvent> e(event);
if (RenderThread::current()) {
RenderThread::current()->Send(new ViewHostMsg_MediaLogEvent(*e));
} else {
render_loop_->PostTask(FROM_HERE,
NewRunnableMethod(this, &RenderMediaLog::AddEvent, e.release()));
}
}
RenderMediaLog::~RenderMediaLog() {}
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_RENDERER_MEDIA_RENDER_MEDIA_LOG_H_
#define CONTENT_RENDERER_MEDIA_RENDER_MEDIA_LOG_H_
#pragma once
#include "media/base/media_log.h"
namespace base {
class MessageLoopProxy;
}
// RenderMediaLog is an implementation of MediaLog that passes all events to the
// browser process.
class RenderMediaLog : public media::MediaLog {
public:
RenderMediaLog();
// MediaLog implementation.
virtual void AddEvent(media::MediaLogEvent* event);
private:
virtual ~RenderMediaLog();
scoped_refptr<base::MessageLoopProxy> render_loop_;
DISALLOW_COPY_AND_ASSIGN(RenderMediaLog);
};
#endif // CONTENT_RENDERER_MEDIA_RENDER_MEDIA_LOG_H_
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#include "content/renderer/media/audio_message_filter.h" #include "content/renderer/media/audio_message_filter.h"
#include "content/renderer/media/audio_renderer_impl.h" #include "content/renderer/media/audio_renderer_impl.h"
#include "content/renderer/media/media_stream_impl.h" #include "content/renderer/media/media_stream_impl.h"
#include "content/renderer/media/render_media_log.h"
#include "content/renderer/navigation_state.h" #include "content/renderer/navigation_state.h"
#include "content/renderer/notification_provider.h" #include "content/renderer/notification_provider.h"
#include "content/renderer/p2p/socket_dispatcher.h" #include "content/renderer/p2p/socket_dispatcher.h"
...@@ -1968,7 +1969,8 @@ WebMediaPlayer* RenderView::createMediaPlayer( ...@@ -1968,7 +1969,8 @@ WebMediaPlayer* RenderView::createMediaPlayer(
new webkit_glue::WebMediaPlayerImpl(client, new webkit_glue::WebMediaPlayerImpl(client,
collection.release(), collection.release(),
message_loop_factory.release(), message_loop_factory.release(),
media_stream_impl_.get())); media_stream_impl_.get(),
new RenderMediaLog()));
if (!result->Initialize(frame, if (!result->Initialize(frame,
cmd_line->HasSwitch(switches::kSimpleDataSource), cmd_line->HasSwitch(switches::kSimpleDataSource),
video_renderer)) { video_renderer)) {
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/base/media_log.h"
#include "base/atomic_sequence_num.h"
#include "base/logging.h"
namespace media {
// A count of all MediaLogs created on this render process.
// Used to generate unique ids.
static base::AtomicSequenceNumber media_log_count(base::LINKER_INITIALIZED);
const char* MediaLog::EventTypeToString(MediaLogEvent::Type type) {
switch (type) {
case MediaLogEvent::CREATING:
return "CREATING";
case MediaLogEvent::DESTROYING:
return "DESTROYING";
case MediaLogEvent::LOAD:
return "LOAD";
case MediaLogEvent::PLAY:
return "PLAY";
case MediaLogEvent::PAUSE:
return "PAUSE";
}
NOTREACHED();
return NULL;
}
MediaLog::MediaLog() {
id_ = media_log_count.GetNext();
}
MediaLog::~MediaLog() {}
void MediaLog::Load(const std::string& url) {
MediaLogEvent* event = CreateEvent(MediaLogEvent::LOAD);
event->params.SetString("url", url);
AddEvent(event);
}
void MediaLog::AddEventOfType(MediaLogEvent::Type type) {
MediaLogEvent* event = CreateEvent(type);
AddEvent(event);
}
MediaLogEvent* MediaLog::CreateEvent(MediaLogEvent::Type type) {
MediaLogEvent* event = new MediaLogEvent;
event->id = id_;
event->type = type;
event->time = base::Time::Now();
return event;
}
void MediaLog::AddEvent(MediaLogEvent* event) {}
} //namespace media
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_BASE_MEDIA_LOG_H_
#define MEDIA_BASE_MEDIA_LOG_H_
#pragma once
#include "base/memory/ref_counted.h"
#include "media/base/media_log_event.h"
namespace media {
class MediaLog : public base::RefCountedThreadSafe<MediaLog> {
public:
// Return a string to represent an EventType.
static const char* EventTypeToString(MediaLogEvent::Type type);
MediaLog();
// Methods called by loggers when events occur. These generate appropriate
// event parameters so the caller need not worry about them.
void Load(const std::string& url);
// Add an event to this log. Overriden by inheritors to actually do something
// with it.
// Takes ownership of |event|.
virtual void AddEvent(MediaLogEvent* event);
// Convenience method for adding an event with no parameters.
void AddEventOfType(MediaLogEvent::Type type);
// Convenience method for filling in common fields of a new event.
MediaLogEvent* CreateEvent(MediaLogEvent::Type type);
protected:
friend class base::RefCountedThreadSafe<MediaLog>;
virtual ~MediaLog();
private:
// A unique (to this process) id for this MediaLog.
int32 id_;
DISALLOW_COPY_AND_ASSIGN(MediaLog);
};
} // namespace media
#endif // MEDIA_BASE_MEDIA_LOG_H_
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_BASE_MEDIA_LOG_EVENT_H_
#define MEDIA_BASE_MEDIA_LOG_EVENT_H_
#pragma once
#include "base/time.h"
#include "base/values.h"
namespace media {
struct MediaLogEvent {
enum Type {
// A media player is being created or destroyed.
// params: none.
CREATING,
DESTROYING,
// A media player is loading a resource.
// params: "url": <URL of the resource>.
LOAD,
// A media player has been told to play or pause.
// params: none.
PLAY,
PAUSE,
};
int32 id;
Type type;
base::DictionaryValue params;
base::Time time;
};
} // namespace media
#endif // MEDIA_BASE_MEDIA_LOG_EVENT_H_
...@@ -109,6 +109,9 @@ ...@@ -109,6 +109,9 @@
'base/h264_bitstream_converter.h', 'base/h264_bitstream_converter.h',
'base/media.h', 'base/media.h',
'base/media_export.h', 'base/media_export.h',
'base/media_log.cc',
'base/media_log.h',
'base/media_log_event.h',
'base/media_posix.cc', 'base/media_posix.cc',
'base/media_switches.cc', 'base/media_switches.cc',
'base/media_switches.h', 'base/media_switches.h',
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "media/base/composite_data_source_factory.h" #include "media/base/composite_data_source_factory.h"
#include "media/base/filter_collection.h" #include "media/base/filter_collection.h"
#include "media/base/limits.h" #include "media/base/limits.h"
#include "media/base/media_log.h"
#include "media/base/media_switches.h" #include "media/base/media_switches.h"
#include "media/base/pipeline_impl.h" #include "media/base/pipeline_impl.h"
#include "media/base/video_frame.h" #include "media/base/video_frame.h"
...@@ -319,7 +320,8 @@ WebMediaPlayerImpl::WebMediaPlayerImpl( ...@@ -319,7 +320,8 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(
WebKit::WebMediaPlayerClient* client, WebKit::WebMediaPlayerClient* client,
media::FilterCollection* collection, media::FilterCollection* collection,
media::MessageLoopFactory* message_loop_factory, media::MessageLoopFactory* message_loop_factory,
MediaStreamClient* media_stream_client) MediaStreamClient* media_stream_client,
media::MediaLog* media_log)
: network_state_(WebKit::WebMediaPlayer::Empty), : network_state_(WebKit::WebMediaPlayer::Empty),
ready_state_(WebKit::WebMediaPlayer::HaveNothing), ready_state_(WebKit::WebMediaPlayer::HaveNothing),
main_loop_(NULL), main_loop_(NULL),
...@@ -331,10 +333,12 @@ WebMediaPlayerImpl::WebMediaPlayerImpl( ...@@ -331,10 +333,12 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(
playback_rate_(0.0f), playback_rate_(0.0f),
client_(client), client_(client),
proxy_(NULL), proxy_(NULL),
media_stream_client_(media_stream_client) { media_stream_client_(media_stream_client),
media_log_(media_log) {
// Saves the current message loop. // Saves the current message loop.
DCHECK(!main_loop_); DCHECK(!main_loop_);
main_loop_ = MessageLoop::current(); main_loop_ = MessageLoop::current();
media_log_->AddEventOfType(media::MediaLogEvent::CREATING);
} }
bool WebMediaPlayerImpl::Initialize( bool WebMediaPlayerImpl::Initialize(
...@@ -421,6 +425,7 @@ bool WebMediaPlayerImpl::Initialize( ...@@ -421,6 +425,7 @@ bool WebMediaPlayerImpl::Initialize(
} }
WebMediaPlayerImpl::~WebMediaPlayerImpl() { WebMediaPlayerImpl::~WebMediaPlayerImpl() {
media_log_->AddEventOfType(media::MediaLogEvent::DESTROYING);
Destroy(); Destroy();
// Finally tell the |main_loop_| we don't want to be notified of destruction // Finally tell the |main_loop_| we don't want to be notified of destruction
...@@ -458,6 +463,8 @@ void WebMediaPlayerImpl::load(const WebKit::WebURL& url) { ...@@ -458,6 +463,8 @@ void WebMediaPlayerImpl::load(const WebKit::WebURL& url) {
url.spec(), url.spec(),
NewCallback(proxy_.get(), NewCallback(proxy_.get(),
&WebMediaPlayerImpl::Proxy::PipelineInitializationCallback)); &WebMediaPlayerImpl::Proxy::PipelineInitializationCallback));
media_log_->Load(url.spec());
} }
void WebMediaPlayerImpl::cancelLoad() { void WebMediaPlayerImpl::cancelLoad() {
...@@ -469,6 +476,8 @@ void WebMediaPlayerImpl::play() { ...@@ -469,6 +476,8 @@ void WebMediaPlayerImpl::play() {
paused_ = false; paused_ = false;
pipeline_->SetPlaybackRate(playback_rate_); pipeline_->SetPlaybackRate(playback_rate_);
media_log_->AddEventOfType(media::MediaLogEvent::PLAY);
} }
void WebMediaPlayerImpl::pause() { void WebMediaPlayerImpl::pause() {
...@@ -477,6 +486,8 @@ void WebMediaPlayerImpl::pause() { ...@@ -477,6 +486,8 @@ void WebMediaPlayerImpl::pause() {
paused_ = true; paused_ = true;
pipeline_->SetPlaybackRate(0.0f); pipeline_->SetPlaybackRate(0.0f);
paused_time_ = pipeline_->GetCurrentTime(); paused_time_ = pipeline_->GetCurrentTime();
media_log_->AddEventOfType(media::MediaLogEvent::PAUSE);
} }
bool WebMediaPlayerImpl::supportsFullscreen() const { bool WebMediaPlayerImpl::supportsFullscreen() const {
......
...@@ -77,6 +77,10 @@ namespace WebKit { ...@@ -77,6 +77,10 @@ namespace WebKit {
class WebFrame; class WebFrame;
} }
namespace media {
class MediaLog;
}
namespace webkit_glue { namespace webkit_glue {
class MediaResourceLoaderBridgeFactory; class MediaResourceLoaderBridgeFactory;
...@@ -208,7 +212,8 @@ class WebMediaPlayerImpl ...@@ -208,7 +212,8 @@ class WebMediaPlayerImpl
WebMediaPlayerImpl(WebKit::WebMediaPlayerClient* client, WebMediaPlayerImpl(WebKit::WebMediaPlayerClient* client,
media::FilterCollection* collection, media::FilterCollection* collection,
media::MessageLoopFactory* message_loop_factory, media::MessageLoopFactory* message_loop_factory,
MediaStreamClient* media_stream_client); MediaStreamClient* media_stream_client,
media::MediaLog* media_log);
virtual ~WebMediaPlayerImpl(); virtual ~WebMediaPlayerImpl();
// Finalizes initialization of the object. // Finalizes initialization of the object.
...@@ -361,6 +366,8 @@ class WebMediaPlayerImpl ...@@ -361,6 +366,8 @@ class WebMediaPlayerImpl
scoped_ptr<skia::PlatformCanvas> skia_canvas_; scoped_ptr<skia::PlatformCanvas> skia_canvas_;
#endif #endif
scoped_refptr<media::MediaLog> media_log_;
DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl);
}; };
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "googleurl/src/url_util.h" #include "googleurl/src/url_util.h"
#include "grit/webkit_chromium_resources.h" #include "grit/webkit_chromium_resources.h"
#include "media/base/filter_collection.h" #include "media/base/filter_collection.h"
#include "media/base/media_log.h"
#include "media/base/message_loop_factory_impl.h" #include "media/base/message_loop_factory_impl.h"
#include "net/base/escape.h" #include "net/base/escape.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
...@@ -309,7 +310,8 @@ WebKit::WebMediaPlayer* CreateMediaPlayer(WebFrame* frame, ...@@ -309,7 +310,8 @@ WebKit::WebMediaPlayer* CreateMediaPlayer(WebFrame* frame,
new webkit_glue::WebMediaPlayerImpl(client, new webkit_glue::WebMediaPlayerImpl(client,
collection.release(), collection.release(),
message_loop_factory.release(), message_loop_factory.release(),
NULL)); NULL,
new media::MediaLog()));
if (!result->Initialize(frame, false, video_renderer)) { if (!result->Initialize(frame, false, video_renderer)) {
return NULL; return NULL;
} }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "base/string_number_conversions.h" #include "base/string_number_conversions.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "media/base/filter_collection.h" #include "media/base/filter_collection.h"
#include "media/base/media_log.h"
#include "media/base/message_loop_factory_impl.h" #include "media/base/message_loop_factory_impl.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObject.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObject.h"
...@@ -625,7 +626,8 @@ WebMediaPlayer* TestWebViewDelegate::createMediaPlayer( ...@@ -625,7 +626,8 @@ WebMediaPlayer* TestWebViewDelegate::createMediaPlayer(
new webkit_glue::WebMediaPlayerImpl(client, new webkit_glue::WebMediaPlayerImpl(client,
collection.release(), collection.release(),
message_loop_factory.release(), message_loop_factory.release(),
NULL)); NULL,
new media::MediaLog()));
if (!result->Initialize(frame, false, video_renderer)) { if (!result->Initialize(frame, false, video_renderer)) {
return NULL; return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment