diff options
-rw-r--r-- | chrome/common/gpu_messages_internal.h | 4 | ||||
-rw-r--r-- | chrome/common/gpu_video_common.cc | 24 | ||||
-rw-r--r-- | chrome/common/gpu_video_common.h | 19 | ||||
-rw-r--r-- | chrome/gpu/gpu_channel.cc | 18 | ||||
-rw-r--r-- | chrome/gpu/gpu_channel.h | 1 | ||||
-rw-r--r-- | chrome/renderer/ggl/ggl.cc | 2 | ||||
-rw-r--r-- | chrome/renderer/gpu_channel_host.cc | 7 | ||||
-rw-r--r-- | chrome/renderer/gpu_channel_host.h | 9 | ||||
-rw-r--r-- | chrome/renderer/gpu_video_decoder_host.h | 4 | ||||
-rw-r--r-- | chrome/renderer/gpu_video_service_host.cc | 58 | ||||
-rw-r--r-- | chrome/renderer/gpu_video_service_host.h | 33 | ||||
-rw-r--r-- | chrome/renderer/media/ipc_video_decoder.cc | 20 | ||||
-rw-r--r-- | chrome/renderer/media/ipc_video_decoder.h | 4 | ||||
-rw-r--r-- | chrome/renderer/render_thread.cc | 2 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 3 | ||||
-rw-r--r-- | media/base/video_frame.cc | 2 |
16 files changed, 70 insertions, 140 deletions
diff --git a/chrome/common/gpu_messages_internal.h b/chrome/common/gpu_messages_internal.h index 86c5481..f61be25b1 100644 --- a/chrome/common/gpu_messages_internal.h +++ b/chrome/common/gpu_messages_internal.h @@ -181,10 +181,6 @@ IPC_BEGIN_MESSAGES(GpuChannel) IPC_SYNC_MESSAGE_CONTROL1_0(GpuChannelMsg_DestroyCommandBuffer, int32 /* instance_id */) - // Get hardware video service routing id. - IPC_SYNC_MESSAGE_CONTROL0_1(GpuChannelMsg_GetVideoService, - GpuVideoServiceInfoParam) - // Create hardware video decoder && associate it with the output |decoder_id|; // We need this to be control message because we had to map the GpuChannel and // |decoder_id|. diff --git a/chrome/common/gpu_video_common.cc b/chrome/common/gpu_video_common.cc index f6339e3..e0279de 100644 --- a/chrome/common/gpu_video_common.cc +++ b/chrome/common/gpu_video_common.cc @@ -6,30 +6,6 @@ namespace IPC { -void ParamTraits<GpuVideoServiceInfoParam>::Write( - Message* m, const GpuVideoServiceInfoParam& p) { - WriteParam(m, p.video_service_route_id); - WriteParam(m, p.video_service_host_route_id); - WriteParam(m, p.service_available); -} - -bool ParamTraits<GpuVideoServiceInfoParam>::Read( - const Message* m, void** iter, GpuVideoServiceInfoParam* r) { - if (!ReadParam(m, iter, &r->video_service_route_id) || - !ReadParam(m, iter, &r->video_service_host_route_id) || - !ReadParam(m, iter, &r->service_available)) - return false; - return true; -} - -void ParamTraits<GpuVideoServiceInfoParam>::Log( - const GpuVideoServiceInfoParam& p, std::string* l) { - l->append(StringPrintf("(%d, %d, %d)", - p.video_service_route_id, - p.video_service_host_route_id, - p.service_available)); -} - /////////////////////////////////////////////////////////////////////////////// void ParamTraits<GpuVideoDecoderInitParam>::Write( diff --git a/chrome/common/gpu_video_common.h b/chrome/common/gpu_video_common.h index 55a44bc..17d5498 100644 --- a/chrome/common/gpu_video_common.h +++ b/chrome/common/gpu_video_common.h @@ -16,17 +16,6 @@ enum GpuVideoBufferFlag { kGpuVideoDiscontinuous = 1 << 1, }; -struct GpuVideoServiceInfoParam { - // route id for GpuVideoService on GPU process side for this channel. - int32 video_service_route_id; - - // route id for GpuVideoServiceHost on Render process side for this channel. - int32 video_service_host_route_id; - - // TODO(jiesun): define capabilities of video service. - int32 service_available; -}; - struct GpuVideoDecoderInitParam { int32 codec_id; int32 width; @@ -65,14 +54,6 @@ struct GpuVideoDecoderFormatChangeParam { namespace IPC { template <> -struct ParamTraits<GpuVideoServiceInfoParam> { - typedef GpuVideoServiceInfoParam param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); - static void Log(const param_type& p, std::string* l); -}; - -template <> struct ParamTraits<GpuVideoDecoderInitParam> { typedef GpuVideoDecoderInitParam param_type; static void Write(Message* m, const param_type& p); diff --git a/chrome/gpu/gpu_channel.cc b/chrome/gpu/gpu_channel.cc index 9b8095f..fc2c09c 100644 --- a/chrome/gpu/gpu_channel.cc +++ b/chrome/gpu/gpu_channel.cc @@ -89,8 +89,6 @@ void GpuChannel::OnControlMessageReceived(const IPC::Message& msg) { OnCreateOffscreenCommandBuffer) IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyCommandBuffer, OnDestroyCommandBuffer) - IPC_MESSAGE_HANDLER(GpuChannelMsg_GetVideoService, - OnGetVideoService) IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateVideoDecoder, OnCreateVideoDecoder) IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyVideoDecoder, @@ -190,22 +188,6 @@ void GpuChannel::OnDestroyCommandBuffer(int32 route_id) { #endif } -void GpuChannel::OnGetVideoService(GpuVideoServiceInfoParam* info) { - info->service_available = 0; -#if defined(ENABLE_GPU) - LOG(INFO) << "GpuChannel::OnGetVideoService"; - GpuVideoService* service = GpuVideoService::get(); - if (service == NULL) - return; - - info->video_service_host_route_id = GenerateRouteID(); - info->video_service_route_id = GenerateRouteID(); - // TODO(jiesun): we could had multiple entries in this routing table. - router_.AddRoute(info->video_service_route_id, service); - info->service_available = 1; -#endif -} - void GpuChannel::OnCreateVideoDecoder(int32 context_route_id, int32 decoder_host_id) { #if defined(ENABLE_GPU) diff --git a/chrome/gpu/gpu_channel.h b/chrome/gpu/gpu_channel.h index 73fce43..e7cb1db 100644 --- a/chrome/gpu/gpu_channel.h +++ b/chrome/gpu/gpu_channel.h @@ -75,7 +75,6 @@ class GpuChannel : public IPC::Channel::Listener, int32* route_id); void OnDestroyCommandBuffer(int32 route_id); - void OnGetVideoService(GpuVideoServiceInfoParam* info); void OnCreateVideoDecoder(int32 context_route_id, int32 decoder_host_id); void OnDestroyVideoDecoder(int32 decoder_id); diff --git a/chrome/renderer/ggl/ggl.cc b/chrome/renderer/ggl/ggl.cc index 1a0e6e9..f69e3c3 100644 --- a/chrome/renderer/ggl/ggl.cc +++ b/chrome/renderer/ggl/ggl.cc @@ -367,7 +367,7 @@ bool Context::SwapBuffers() { } media::VideoDecodeEngine* Context::CreateVideoDecodeEngine() { - return GpuVideoServiceHost::get()->CreateVideoDecoder( + return channel_->gpu_video_service_host()->CreateVideoDecoder( command_buffer_->route_id()); } diff --git a/chrome/renderer/gpu_channel_host.cc b/chrome/renderer/gpu_channel_host.cc index 0b576b8..de89774 100644 --- a/chrome/renderer/gpu_channel_host.cc +++ b/chrome/renderer/gpu_channel_host.cc @@ -47,9 +47,10 @@ void GpuChannelHost::OnMessageReceived(const IPC::Message& message) { } void GpuChannelHost::OnChannelConnected(int32 peer_pid) { - GpuVideoServiceHost::get()->OnGpuChannelConnected(this, - &router_, - channel_.get()); + // When the channel is connected we create a GpuVideoServiceHost and add it + // as a message filter. + gpu_video_service_host_.reset(new GpuVideoServiceHost()); + channel_->AddFilter(gpu_video_service_host_.get()); } void GpuChannelHost::OnChannelError() { diff --git a/chrome/renderer/gpu_channel_host.h b/chrome/renderer/gpu_channel_host.h index c139219..e6eecea 100644 --- a/chrome/renderer/gpu_channel_host.h +++ b/chrome/renderer/gpu_channel_host.h @@ -20,6 +20,7 @@ #include "ipc/ipc_sync_channel.h" class CommandBufferProxy; +class GpuVideoServiceHost; // Encapsulates an IPC channel between the renderer and one plugin process. // On the plugin side there's a corresponding GpuChannel. @@ -72,6 +73,10 @@ class GpuChannelHost : public IPC::Channel::Listener, // Destroy a command buffer created by this channel. void DestroyCommandBuffer(CommandBufferProxy* command_buffer); + GpuVideoServiceHost* gpu_video_service_host() { + return gpu_video_service_host_.get(); + } + private: State state_; @@ -88,6 +93,10 @@ class GpuChannelHost : public IPC::Channel::Listener, typedef base::hash_map<int, IPC::Channel::Listener*> ProxyMap; ProxyMap proxies_; + // This is a MessageFilter to intercept IPC messages and distribute them + // to the corresponding GpuVideoDecoderHost. + scoped_ptr<GpuVideoServiceHost> gpu_video_service_host_; + DISALLOW_COPY_AND_ASSIGN(GpuChannelHost); }; diff --git a/chrome/renderer/gpu_video_decoder_host.h b/chrome/renderer/gpu_video_decoder_host.h index 5ca520e..baf0ffe 100644 --- a/chrome/renderer/gpu_video_decoder_host.h +++ b/chrome/renderer/gpu_video_decoder_host.h @@ -37,6 +37,10 @@ class MessageRouter; class GpuVideoDecoderHost : public media::VideoDecodeEngine, public IPC::Channel::Listener { public: + // |router| is used to dispatch IPC messages to this object. + // |ipc_sender| is used to send IPC messages to GPU process. + // It is important that the above two objects are accessed on the + // |message_loop_|. GpuVideoDecoderHost(MessageRouter* router, IPC::Message::Sender* ipc_sender, int context_route_id, diff --git a/chrome/renderer/gpu_video_service_host.cc b/chrome/renderer/gpu_video_service_host.cc index 9c4f433..2971ff2 100644 --- a/chrome/renderer/gpu_video_service_host.cc +++ b/chrome/renderer/gpu_video_service_host.cc @@ -9,52 +9,46 @@ #include "chrome/renderer/render_thread.h" GpuVideoServiceHost::GpuVideoServiceHost() - : channel_host_(NULL), - router_(NULL), - message_loop_(NULL), + : channel_(NULL), next_decoder_host_id_(0) { - memset(&service_info_, 0, sizeof(service_info_)); } -void GpuVideoServiceHost::OnChannelError() { - LOG(ERROR) << "GpuVideoServiceHost::OnChannelError"; - channel_host_ = NULL; - router_ = NULL; +void GpuVideoServiceHost::OnFilterAdded(IPC::Channel* channel) { + channel_ = channel; } -void GpuVideoServiceHost::OnMessageReceived(const IPC::Message& msg) { -#if 0 - IPC_BEGIN_MESSAGE_MAP(GpuVideoServiceHost, msg) - IPC_MESSAGE_UNHANDLED_ERROR() - IPC_END_MESSAGE_MAP() -#endif +void GpuVideoServiceHost::OnFilterRemoved() { + // TODO(hclam): Implement. } -void GpuVideoServiceHost::OnRendererThreadInit(MessageLoop* message_loop) { - message_loop_ = message_loop; +void GpuVideoServiceHost::OnChannelClosing() { + // TODO(hclam): Implement. } -void GpuVideoServiceHost::OnGpuChannelConnected( - GpuChannelHost* channel_host, - MessageRouter* router, - IPC::SyncChannel* channel) { - - channel_host_ = channel_host; - router_ = router; - - // Get the routing_id of video service in GPU process. - service_info_.service_available = 0; - if (!channel_host_->Send(new GpuChannelMsg_GetVideoService(&service_info_))) { - LOG(ERROR) << "GpuChannelMsg_GetVideoService failed"; +bool GpuVideoServiceHost::OnMessageReceived(const IPC::Message& msg) { + switch (msg.type()) { + case GpuVideoDecoderHostMsg_CreateVideoDecoderDone::ID: + case GpuVideoDecoderHostMsg_InitializeACK::ID: + case GpuVideoDecoderHostMsg_DestroyACK::ID: + case GpuVideoDecoderHostMsg_FlushACK::ID: + case GpuVideoDecoderHostMsg_PrerollDone::ID: + case GpuVideoDecoderHostMsg_EmptyThisBufferACK::ID: + case GpuVideoDecoderHostMsg_EmptyThisBufferDone::ID: + case GpuVideoDecoderHostMsg_ConsumeVideoFrame::ID: + case GpuVideoDecoderHostMsg_AllocateVideoFrames::ID: + case GpuVideoDecoderHostMsg_ReleaseAllVideoFrames::ID: + if (!router_.RouteMessage(msg)) { + LOG(ERROR) << "GpuVideoDecoderHostMsg cannot be dispatched."; + } + return true; + default: + return false; } - - if (service_info_.service_available) - router->AddRoute(service_info_.video_service_host_route_id, this); } GpuVideoDecoderHost* GpuVideoServiceHost::CreateVideoDecoder( int context_route_id) { - GpuVideoDecoderHost* host = new GpuVideoDecoderHost(router_, channel_host_, + GpuVideoDecoderHost* host = new GpuVideoDecoderHost(&router_, channel_, context_route_id, next_decoder_host_id_); // TODO(hclam): Handle thread safety of incrementing the ID. diff --git a/chrome/renderer/gpu_video_service_host.h b/chrome/renderer/gpu_video_service_host.h index ff54cd2..e4f3be0 100644 --- a/chrome/renderer/gpu_video_service_host.h +++ b/chrome/renderer/gpu_video_service_host.h @@ -13,23 +13,17 @@ #include "media/base/buffers.h" #include "media/base/video_frame.h" -// A GpuVideoServiceHost is a singleton in the renderer process that provides -// access to hardware accelerated video decoding device in the GPU process -// though a GpuVideoDecoderHost. -class GpuVideoServiceHost : public IPC::Channel::Listener, - public Singleton<GpuVideoServiceHost> { +// GpuVideoServiceHost lives on IO thread and is used to dispatch IPC messages +// to GpuVideoDecoderHost objects. +class GpuVideoServiceHost : public IPC::ChannelProxy::MessageFilter { public: - // IPC::Channel::Listener. - virtual void OnChannelConnected(int32 peer_pid) {} - virtual void OnChannelError(); - virtual void OnMessageReceived(const IPC::Message& message); - - void OnRendererThreadInit(MessageLoop* message_loop); + GpuVideoServiceHost(); - // Called by GpuChannelHost when a GPU channel is established. - void OnGpuChannelConnected(GpuChannelHost* channel_host, - MessageRouter* router, - IPC::SyncChannel* channel); + // IPC::ChannelProxy::MessageFilter implementations. + virtual bool OnMessageReceived(const IPC::Message& message); + virtual void OnFilterAdded(IPC::Channel* channel); + virtual void OnFilterRemoved(); + virtual void OnChannelClosing(); // Called on RenderThread to create a hardware accelerated video decoder // in the GPU process. @@ -46,17 +40,14 @@ class GpuVideoServiceHost : public IPC::Channel::Listener, GpuVideoDecoderHost* CreateVideoDecoder(int context_route_id); private: - GpuVideoServiceHost(); + IPC::Channel* channel_; - GpuChannelHost* channel_host_; - MessageRouter* router_; - GpuVideoServiceInfoParam service_info_; - MessageLoop* message_loop_; // Message loop of render thread. + // Router to send messages to a GpuVideoDecoderHost. + MessageRouter router_; // ID for the next GpuVideoDecoderHost. int32 next_decoder_host_id_; - friend struct DefaultSingletonTraits<GpuVideoServiceHost>; DISALLOW_COPY_AND_ASSIGN(GpuVideoServiceHost); }; diff --git a/chrome/renderer/media/ipc_video_decoder.cc b/chrome/renderer/media/ipc_video_decoder.cc index c8f8096..d06130e 100644 --- a/chrome/renderer/media/ipc_video_decoder.cc +++ b/chrome/renderer/media/ipc_video_decoder.cc @@ -5,6 +5,7 @@ #include "chrome/renderer/media/ipc_video_decoder.h" #include "base/task.h" +#include "chrome/common/child_process.h" #include "chrome/renderer/ggl/ggl.h" #include "media/base/callback.h" #include "media/base/filters.h" @@ -21,7 +22,7 @@ IpcVideoDecoder::IpcVideoDecoder(MessageLoop* message_loop, ggl::Context* ggl_context) : width_(0), height_(0), - decode_engine_message_loop_(message_loop), + decode_context_message_loop_(message_loop), ggl_context_(ggl_context) { } @@ -56,10 +57,9 @@ void IpcVideoDecoder::Initialize(media::DemuxerStream* demuxer_stream, // Create a video decode context that assocates with the graphics // context. - // TODO(hclam): Need to define a message loop that hosts decode context. decode_context_.reset( ggl::CreateVideoDecodeContext( - ggl_context_, decode_engine_message_loop_, true)); + ggl_context_, decode_context_message_loop_, true)); // Create a hardware video decoder handle. decode_engine_.reset(ggl::CreateVideoDecodeEngine(ggl_context_)); @@ -70,11 +70,9 @@ void IpcVideoDecoder::Initialize(media::DemuxerStream* demuxer_stream, param.width = width_; param.height = height_; - // TODO(hclam): Move VideoDecodeEngine to IO Thread, this will avoid - // dead lock during teardown. // VideoDecodeEngine will perform initialization on the message loop // given to it so it doesn't matter on which thread we are calling this. - decode_engine_->Initialize(decode_engine_message_loop_, this, + decode_engine_->Initialize(ChildProcess::current()->io_message_loop(), this, decode_context_.get(), param); } @@ -102,7 +100,7 @@ void IpcVideoDecoder::Seek(base::TimeDelta time, } void IpcVideoDecoder::OnInitializeComplete(const media::VideoCodecInfo& info) { - DCHECK_EQ(decode_engine_message_loop_, MessageLoop::current()); + DCHECK_EQ(ChildProcess::current()->io_message_loop(), MessageLoop::current()); if (info.success) { media_format_.SetAsString(media::MediaFormat::kMimeType, @@ -128,7 +126,7 @@ void IpcVideoDecoder::OnInitializeComplete(const media::VideoCodecInfo& info) { } void IpcVideoDecoder::OnUninitializeComplete() { - DCHECK_EQ(decode_engine_message_loop_, MessageLoop::current()); + DCHECK_EQ(ChildProcess::current()->io_message_loop(), MessageLoop::current()); // After the decode engine is uninitialized we are safe to destroy the decode // context. The task will add a refcount to this object so don't need to worry @@ -144,19 +142,19 @@ void IpcVideoDecoder::OnUninitializeComplete() { } void IpcVideoDecoder::OnFlushComplete() { - DCHECK_EQ(decode_engine_message_loop_, MessageLoop::current()); + DCHECK_EQ(ChildProcess::current()->io_message_loop(), MessageLoop::current()); flush_callback_->Run(); flush_callback_.reset(); } void IpcVideoDecoder::OnSeekComplete() { - DCHECK_EQ(decode_engine_message_loop_, MessageLoop::current()); + DCHECK_EQ(ChildProcess::current()->io_message_loop(), MessageLoop::current()); seek_callback_->Run(); seek_callback_.reset(); } void IpcVideoDecoder::OnError() { - DCHECK_EQ(decode_engine_message_loop_, MessageLoop::current()); + DCHECK_EQ(ChildProcess::current()->io_message_loop(), MessageLoop::current()); host()->SetError(media::PIPELINE_ERROR_DECODE); } diff --git a/chrome/renderer/media/ipc_video_decoder.h b/chrome/renderer/media/ipc_video_decoder.h index d0aba70..c9d800d 100644 --- a/chrome/renderer/media/ipc_video_decoder.h +++ b/chrome/renderer/media/ipc_video_decoder.h @@ -72,8 +72,8 @@ class IpcVideoDecoder : public media::VideoDecoder, // Pointer to the demuxer stream that will feed us compressed buffers. scoped_refptr<media::DemuxerStream> demuxer_stream_; - // This is the message loop that we should assign to VideoDecodeEngine. - MessageLoop* decode_engine_message_loop_; + // This is the message loop that we should assign to VideoDecodeContext. + MessageLoop* decode_context_message_loop_; // A context for allocating textures and issuing GLES2 commands. // TODO(hclam): A ggl::Context lives on the Render Thread while this object diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc index bef96f9..a0cdd5f 100644 --- a/chrome/renderer/render_thread.cc +++ b/chrome/renderer/render_thread.cc @@ -296,8 +296,6 @@ void RenderThread::Init() { kPrelauchGpuProcessDelayMS); } - GpuVideoServiceHost::get()->OnRendererThreadInit(MessageLoop::current()); - TRACE_EVENT_END("RenderThread::Init", 0, ""); } diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index b164a39..1e8a533 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -2476,8 +2476,7 @@ WebMediaPlayer* RenderView::createMediaPlayer( CHECK(ret) << "Failed to switch context"; factory->AddFactory(IpcVideoDecoder::CreateFactory( - MessageLoop::current(), - ggl::GetCurrentContext())); + MessageLoop::current(), ggl::GetCurrentContext())); } WebApplicationCacheHostImpl* appcache_host = diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc index 9a53090..57a4d0d 100644 --- a/media/base/video_frame.cc +++ b/media/base/video_frame.cc @@ -115,6 +115,8 @@ void VideoFrame::CreateFrameGlTexture(Format format, frame->planes_ = GetNumberOfPlanes(format); for (size_t i = 0; i < kMaxPlanes; ++i) { frame->gl_textures_[i] = textures[i]; + // TODO(hclam): Fix me for color format other than RGBA. + frame->strides_[i] = width; } } *frame_out = frame; |