diff options
author | vrk@google.com <vrk@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-07 19:48:17 +0000 |
---|---|---|
committer | vrk@google.com <vrk@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-07 19:48:17 +0000 |
commit | a13da24116e78e759c17ca410e2a7fd39f66c280 (patch) | |
tree | e2ad91811cbe823a4ab18aa988c9a4f655842d94 | |
parent | 0385fc680515fe21df6fc1cbb091e7a041230368 (diff) | |
download | chromium_src-a13da24116e78e759c17ca410e2a7fd39f66c280.zip chromium_src-a13da24116e78e759c17ca410e2a7fd39f66c280.tar.gz chromium_src-a13da24116e78e759c17ca410e2a7fd39f66c280.tar.bz2 |
Delete GpuVideoService and move GpuVideoDecodeAccelerator ownership to stubs
This CL divvies up the GpuVideoService functionality among the relevant
classes.
BUG=NONE
TEST=NONE
Review URL: http://codereview.chromium.org/7292010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91742 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/common/gpu/gpu_channel.cc | 41 | ||||
-rw-r--r-- | content/common/gpu/gpu_channel.h | 4 | ||||
-rw-r--r-- | content/common/gpu/gpu_command_buffer_stub.cc | 22 | ||||
-rw-r--r-- | content/common/gpu/gpu_command_buffer_stub.h | 8 | ||||
-rw-r--r-- | content/common/gpu/gpu_messages.h | 35 | ||||
-rw-r--r-- | content/common/gpu/media/gpu_video_decode_accelerator.cc | 73 | ||||
-rw-r--r-- | content/common/gpu/media/gpu_video_decode_accelerator.h | 23 | ||||
-rw-r--r-- | content/common/gpu/media/gpu_video_service.cc | 135 | ||||
-rw-r--r-- | content/common/gpu/media/gpu_video_service.h | 76 | ||||
-rw-r--r-- | content/content_common.gypi | 2 | ||||
-rw-r--r-- | content/renderer/gpu/gpu_video_decode_accelerator_host.cc | 33 | ||||
-rw-r--r-- | content/renderer/gpu/gpu_video_decode_accelerator_host.h | 4 | ||||
-rw-r--r-- | content/renderer/gpu/gpu_video_service_host.cc | 1 |
13 files changed, 97 insertions, 360 deletions
diff --git a/content/common/gpu/gpu_channel.cc b/content/common/gpu/gpu_channel.cc index e28e14d..e69d197 100644 --- a/content/common/gpu/gpu_channel.cc +++ b/content/common/gpu/gpu_channel.cc @@ -17,7 +17,6 @@ #include "content/common/content_switches.h" #include "content/common/gpu/gpu_channel_manager.h" #include "content/common/gpu/gpu_messages.h" -#include "content/common/gpu/media/gpu_video_service.h" #include "content/common/gpu/transport_texture.h" #include "ui/gfx/gl/gl_context.h" #include "ui/gfx/gl/gl_surface.h" @@ -237,10 +236,6 @@ bool GpuChannel::OnControlMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateOffscreenSurface, OnCreateOffscreenSurface) IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroySurface, OnDestroySurface) - IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateVideoDecoder, - OnCreateVideoDecoder) - IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyVideoDecoder, - OnDestroyVideoDecoder) IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateTransportTexture, OnCreateTransportTexture) IPC_MESSAGE_UNHANDLED(handled = false) @@ -335,42 +330,6 @@ void GpuChannel::OnDestroySurface(int route_id) { #endif } -void GpuChannel::OnCreateVideoDecoder(int32 decoder_host_id, - uint32 command_buffer_route_id, - const std::vector<uint32>& configs) { - GpuVideoService* service = GpuVideoService::GetInstance(); - if (service == NULL) { - // TODO(hclam): Need to send a failure message. - return; - } - - GpuCommandBufferStub* stub = stubs_.Lookup(command_buffer_route_id); - // TODO(vrk): Need to notify renderer that given route is invalid. - if (!stub) - return; - - int32 decoder_id = GenerateRouteID(); - - // TODO(fischman): this is a BUG. We hand off stub to be baked into the - // resulting GpuVideoDecodeAccelerator, but we don't own that GVDA, and we - // make no attempt to tear it down if/when stub is destroyed. GpuVideoService - // should be subsumed into this class and GpuVideoDecodeAccelerator should be - // owned by GpuCommandBufferStub. - bool ret = service->CreateVideoDecoder( - this, &router_, decoder_host_id, decoder_id, stub, configs); - DCHECK(ret) << "Failed to create a GpuVideoDecodeAccelerator"; -} - -void GpuChannel::OnDestroyVideoDecoder(int32 decoder_id) { -#if defined(ENABLE_GPU) - LOG(ERROR) << "GpuChannel::OnDestroyVideoDecoder"; - GpuVideoService* service = GpuVideoService::GetInstance(); - if (service == NULL) - return; - service->DestroyVideoDecoder(&router_, decoder_id); -#endif -} - void GpuChannel::OnCreateTransportTexture(int32 context_route_id, int32 host_id) { #if defined(ENABLE_GPU) diff --git a/content/common/gpu/gpu_channel.h b/content/common/gpu/gpu_channel.h index 8477b92..7344496 100644 --- a/content/common/gpu/gpu_channel.h +++ b/content/common/gpu/gpu_channel.h @@ -145,10 +145,6 @@ class GpuChannel : public IPC::Channel::Listener, int* route_id); void OnDestroySurface(int route_id); - void OnCreateVideoDecoder(int32 decoder_host_id, - uint32 command_buffer_route_id, - const std::vector<uint32>& configs); - void OnDestroyVideoDecoder(int32 decoder_id); void OnCreateTransportTexture(int32 context_route_id, int32 host_id); // The lifetime of objects of this class is managed by a GpuChannelManager. diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc index 0060831..4fea458 100644 --- a/content/common/gpu/gpu_command_buffer_stub.cc +++ b/content/common/gpu/gpu_command_buffer_stub.cc @@ -93,6 +93,10 @@ bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) { OnDestroyTransferBuffer); IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetTransferBuffer, OnGetTransferBuffer); + IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateVideoDecoder, + OnCreateVideoDecoder) + IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyVideoDecoder, + OnDestroyVideoDecoder) IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_ResizeOffscreenFrameBuffer, OnResizeOffscreenFrameBuffer); #if defined(OS_MACOSX) @@ -100,6 +104,12 @@ bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) { #endif // defined(OS_MACOSX) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() + + // If this message isn't intended for the stub, try to route it to the video + // decoder. + if (!handled && video_decoder_.get()) + handled = video_decoder_->OnMessageReceived(message); + DCHECK(handled); return handled; } @@ -573,4 +583,16 @@ void GpuCommandBufferStub::ReportState() { } } +void GpuCommandBufferStub::OnCreateVideoDecoder( + int32 decoder_host_id, const std::vector<uint32>& configs) { + video_decoder_.reset( + new GpuVideoDecodeAccelerator(this, decoder_host_id, this)); + video_decoder_->Initialize(configs); +} + +void GpuCommandBufferStub::OnDestroyVideoDecoder() { + LOG(ERROR) << "GpuCommandBufferStub::OnDestroyVideoDecoder"; + video_decoder_.reset(); +} + #endif // defined(ENABLE_GPU) diff --git a/content/common/gpu/gpu_command_buffer_stub.h b/content/common/gpu/gpu_command_buffer_stub.h index 5fdb0e9..71587c2 100644 --- a/content/common/gpu/gpu_command_buffer_stub.h +++ b/content/common/gpu/gpu_command_buffer_stub.h @@ -15,6 +15,7 @@ #include "base/memory/weak_ptr.h" #include "base/process.h" #include "base/task.h" +#include "content/common/gpu/media/gpu_video_decode_accelerator.h" #include "gpu/command_buffer/service/command_buffer_service.h" #include "gpu/command_buffer/service/gpu_scheduler.h" #include "ipc/ipc_channel.h" @@ -120,6 +121,10 @@ class GpuCommandBufferStub void OnGetTransferBuffer(int32 id, IPC::Message* reply_message); void OnResizeOffscreenFrameBuffer(const gfx::Size& size); + void OnCreateVideoDecoder(int32 decoder_host_id, + const std::vector<uint32>& configs); + void OnDestroyVideoDecoder(); + void OnSwapBuffers(); void OnCommandProcessed(); void HandleDeferredMessages(); @@ -171,6 +176,9 @@ class GpuCommandBufferStub GpuWatchdog* watchdog_; ScopedRunnableMethodFactory<GpuCommandBufferStub> task_factory_; + // The video decoder associated with this stub, if any. + scoped_ptr<GpuVideoDecodeAccelerator> video_decoder_; + DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferStub); }; diff --git a/content/common/gpu/gpu_messages.h b/content/common/gpu/gpu_messages.h index b17344b..10a52ff 100644 --- a/content/common/gpu/gpu_messages.h +++ b/content/common/gpu/gpu_messages.h @@ -311,21 +311,6 @@ IPC_SYNC_MESSAGE_CONTROL1_1(GpuChannelMsg_CreateOffscreenSurface, IPC_MESSAGE_CONTROL1(GpuChannelMsg_DestroySurface, int /* route_id */) -// Create a hardware video decoder; the new route ID is returned through -// AcceleratedVideoDecoderHostMsg_CreateDone. -// We need this to be control message because we had to map the GpuChannel and -// |decoder_id|. -IPC_MESSAGE_CONTROL3(GpuChannelMsg_CreateVideoDecoder, - int32, /* decoder_host_id */ - uint32, /* command buffer route id*/ - std::vector<uint32>) /* configs */ - -// Release all resource of the hardware video decoder which was assocaited -// with the input |decoder_id|. -// TODO(hclam): This message needs to be asynchronous. -IPC_SYNC_MESSAGE_CONTROL1_0(GpuChannelMsg_DestroyVideoDecoder, - int32 /* decoder_id */) - // Create a TransportTexture corresponding to |host_id|. IPC_MESSAGE_CONTROL2(GpuChannelMsg_CreateTransportTexture, int32, /* context_route_id */ @@ -404,6 +389,15 @@ IPC_SYNC_MESSAGE_ROUTED1_2(GpuCommandBufferMsg_GetTransferBuffer, base::SharedMemoryHandle /* transfer_buffer */, uint32 /* size */) +// Create and initialize a hardware video decoder. +IPC_MESSAGE_ROUTED2(GpuCommandBufferMsg_CreateVideoDecoder, + int32, /* decoder_host_id */ + std::vector<uint32>) /* configs */ + +// Release all resources held by the hardware video decoder associated with this +// stub. +IPC_MESSAGE_ROUTED0(GpuCommandBufferMsg_DestroyVideoDecoder); + // Send from command buffer stub to proxy when window is invalid and must be // repainted. IPC_MESSAGE_ROUTED0(GpuCommandBufferMsg_NotifyRepaint) @@ -475,11 +469,6 @@ IPC_SYNC_MESSAGE_CONTROL2_1(AcceleratedVideoDecoderMsg_GetConfigs, std::vector<uint32>, /* Proto config */ std::vector<uint32>) /* Matching configs */ -// Message to initialize the accelerated video decoder. -IPC_MESSAGE_ROUTED2(AcceleratedVideoDecoderMsg_Initialize, - gpu::ReadWriteTokens, /* tokens */ - std::vector<uint32>) /* Config */ - // Send input buffer for decoding. IPC_MESSAGE_ROUTED4(AcceleratedVideoDecoderMsg_Decode, gpu::ReadWriteTokens, /* tokens */ @@ -490,7 +479,7 @@ IPC_MESSAGE_ROUTED4(AcceleratedVideoDecoderMsg_Decode, // Sent from Renderer process to the GPU process to give the texture IDs for // the textures the decoder will use for output. Delays evaluation until // |token.second| is seen. -IPC_MESSAGE_ROUTED4(AcceleratedVideoDecoderMsg_AssignTextures, +IPC_MESSAGE_ROUTED4(AcceleratedVideoDecoderMsg_AssignGLESBuffers, gpu::ReadWriteTokens, /* tokens */ std::vector<int32>, /* Picture buffer ID */ std::vector<uint32>, /* Texture ID */ @@ -542,10 +531,6 @@ IPC_MESSAGE_ROUTED3(AcceleratedVideoDecoderHostMsg_ProvidePictureBuffers, gfx::Size, /* Requested size of buffer */ int32) /* Type of buffer */ -// Decoder has been created and is ready for initialization. -IPC_MESSAGE_ROUTED1(AcceleratedVideoDecoderHostMsg_CreateDone, - int32) /* Decoder ID */ - // Notify client that decoder has been initialized. IPC_MESSAGE_ROUTED0(AcceleratedVideoDecoderHostMsg_InitializeDone) diff --git a/content/common/gpu/media/gpu_video_decode_accelerator.cc b/content/common/gpu/media/gpu_video_decode_accelerator.cc index 3ca7235..15fb8e1 100644 --- a/content/common/gpu/media/gpu_video_decode_accelerator.cc +++ b/content/common/gpu/media/gpu_video_decode_accelerator.cc @@ -15,25 +15,29 @@ #include "content/common/gpu/gpu_channel.h" #include "content/common/gpu/gpu_command_buffer_stub.h" #include "content/common/gpu/gpu_messages.h" -#include "content/common/gpu/media/gpu_video_service.h" +#if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) +#include "content/common/gpu/media/omx_video_decode_accelerator.h" +#include "ui/gfx/gl/gl_surface_egl.h" +#endif #include "ui/gfx/size.h" GpuVideoDecodeAccelerator::GpuVideoDecodeAccelerator( IPC::Message::Sender* sender, int32 host_route_id, - int32 decoder_route_id, GpuCommandBufferStub* stub) : sender_(sender), host_route_id_(host_route_id), - decoder_route_id_(decoder_route_id), stub_(stub), video_decode_accelerator_(NULL) { + // stub_ owns and will always outlive this object. stub_->AddSetTokenCallback(base::Bind( - &GpuVideoDecodeAccelerator::OnSetToken, this)); + &GpuVideoDecodeAccelerator::OnSetToken, base::Unretained(this))); } GpuVideoDecodeAccelerator::~GpuVideoDecodeAccelerator() { STLDeleteElements(&deferred_messages_); + // TODO(fischman/vrk): We need to synchronously wait for the OMX decoder + // to finish shutting down. } void GpuVideoDecodeAccelerator::OnSetToken(int32 token) { @@ -52,9 +56,8 @@ bool GpuVideoDecodeAccelerator::DeferMessageIfNeeded( // Only consider deferring for message types that need it. switch (msg.type()) { case AcceleratedVideoDecoderMsg_GetConfigs::ID: - case AcceleratedVideoDecoderMsg_Initialize::ID: case AcceleratedVideoDecoderMsg_Decode::ID: - case AcceleratedVideoDecoderMsg_AssignTextures::ID: + case AcceleratedVideoDecoderMsg_AssignGLESBuffers::ID: case AcceleratedVideoDecoderMsg_AssignSysmemBuffers::ID: case AcceleratedVideoDecoderMsg_ReusePictureBuffer::ID: case AcceleratedVideoDecoderMsg_Flush::ID: @@ -87,10 +90,9 @@ bool GpuVideoDecodeAccelerator::OnMessageReceived(const IPC::Message& msg) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(GpuVideoDecodeAccelerator, msg) IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_GetConfigs, OnGetConfigs) - IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_Initialize, OnInitialize) IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_Decode, OnDecode) - IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_AssignTextures, - OnAssignTextures) + IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_AssignGLESBuffers, + OnAssignGLESBuffers) IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_AssignSysmemBuffers, OnAssignSysmemBuffers) IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_ReusePictureBuffer, @@ -166,13 +168,19 @@ void GpuVideoDecodeAccelerator::OnGetConfigs( video_decode_accelerator_->GetConfigs(requested, matched); } -void GpuVideoDecodeAccelerator::OnInitialize( - const gpu::ReadWriteTokens& /* tokens */, - const std::vector<uint32>& configs) { +void GpuVideoDecodeAccelerator::Initialize(const std::vector<uint32>& configs) { DCHECK(!video_decode_accelerator_.get()); - GpuVideoService::GetInstance()->InitializeVideoDecoder(decoder_route_id_); - DCHECK(video_decode_accelerator_.get()); +#if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) + DCHECK(stub_ && stub_->scheduler()); + OmxVideoDecodeAccelerator* omx_decoder = new OmxVideoDecodeAccelerator(this); + omx_decoder->SetEglState( + gfx::GLSurfaceEGL::GetDisplay(), + stub_->scheduler()->decoder()->GetGLContext()->GetHandle()); + video_decode_accelerator_.reset(omx_decoder); video_decode_accelerator_->Initialize(configs); +#else + NOTIMPLEMENTED() << "HW video decode acceleration not available."; +#endif // defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) } void GpuVideoDecodeAccelerator::OnDecode( @@ -182,24 +190,27 @@ void GpuVideoDecodeAccelerator::OnDecode( video_decode_accelerator_->Decode(media::BitstreamBuffer(id, handle, size)); } -void GpuVideoDecodeAccelerator::AssignGLESBuffers( - const std::vector<media::GLESBuffer>& buffers) { - // TODO(fischman,vrk): it's wonky that we handle the AssignTextures message by - // handing its contents to GpuVideoService which then turns around and calls - // this (public) method. Instead we should make GpuVideoService vend the - // translation method we need and use it directly. - DCHECK(video_decode_accelerator_.get()); - video_decode_accelerator_->AssignGLESBuffers(buffers); -} +void GpuVideoDecodeAccelerator::OnAssignGLESBuffers( + const gpu::ReadWriteTokens& /* tokens */, + const std::vector<int32>& buffer_ids, + const std::vector<uint32>& texture_ids, + const std::vector<gfx::Size>& sizes) { + DCHECK(stub_ && stub_->scheduler()); // Ensure already Initialize()'d. + gpu::gles2::GLES2Decoder* command_decoder = stub_->scheduler()->decoder(); -void GpuVideoDecodeAccelerator::OnAssignTextures( - const gpu::ReadWriteTokens& /* tokens */, - const std::vector<int32>& buffer_ids, - const std::vector<uint32>& texture_ids, - const std::vector<gfx::Size>& sizes) { - GpuVideoService* service = GpuVideoService::GetInstance(); - service->AssignTexturesToDecoder( - decoder_route_id_, buffer_ids, texture_ids, sizes); + std::vector<media::GLESBuffer> buffers; + for (uint32 i = 0; i < buffer_ids.size(); ++i) { + uint32 service_texture_id; + if (!command_decoder->GetServiceTextureId( + texture_ids[i], &service_texture_id)) { + // TODO(vrk): Send an error for invalid GLES buffers. + LOG(DFATAL) << "Failed to translate texture!"; + return; + } + buffers.push_back(media::GLESBuffer( + buffer_ids[i], sizes[i], service_texture_id)); + } + video_decode_accelerator_->AssignGLESBuffers(buffers); } void GpuVideoDecodeAccelerator::OnAssignSysmemBuffers( diff --git a/content/common/gpu/media/gpu_video_decode_accelerator.h b/content/common/gpu/media/gpu_video_decode_accelerator.h index 96954ff..8fa944c 100644 --- a/content/common/gpu/media/gpu_video_decode_accelerator.h +++ b/content/common/gpu/media/gpu_video_decode_accelerator.h @@ -20,14 +20,12 @@ class ReadWriteTokens; class GpuCommandBufferStub; class GpuVideoDecodeAccelerator - : public base::RefCountedThreadSafe<GpuVideoDecodeAccelerator>, - public IPC::Channel::Listener, + : public IPC::Channel::Listener, public IPC::Message::Sender, public media::VideoDecodeAccelerator::Client { public: GpuVideoDecodeAccelerator(IPC::Message::Sender* sender, int32 host_route_id, - int32 decoder_route_id, GpuCommandBufferStub* stub); virtual ~GpuVideoDecodeAccelerator(); @@ -53,17 +51,12 @@ class GpuVideoDecodeAccelerator // Function to delegate sending to actual sender. virtual bool Send(IPC::Message* message); - void set_video_decode_accelerator( - media::VideoDecodeAccelerator* accelerator) { - DCHECK(!video_decode_accelerator_.get()); - video_decode_accelerator_.reset(accelerator); - } - - void AssignGLESBuffers(const std::vector<media::GLESBuffer>& buffers); - // Callback to be fired when the underlying stub receives a new token. void OnSetToken(int32 token); + // Initialize the accelerator with the given configuration. + void Initialize(const std::vector<uint32>& configs); + private: // Defers |msg| for later processing if it specifies a write token that hasn't // come to pass yet, and set |*deferred| to true. Return false if the message @@ -75,13 +68,10 @@ class GpuVideoDecodeAccelerator const gpu::ReadWriteTokens& /* tokens */, const std::vector<uint32>& config, std::vector<uint32>* configs); - void OnInitialize( - const gpu::ReadWriteTokens& /* tokens */, - const std::vector<uint32>& configs); void OnDecode( const gpu::ReadWriteTokens& /* tokens */, base::SharedMemoryHandle handle, int32 id, int32 size); - void OnAssignTextures( + void OnAssignGLESBuffers( const gpu::ReadWriteTokens& /* tokens */, const std::vector<int32>& buffer_ids, const std::vector<uint32>& texture_ids, @@ -103,9 +93,6 @@ class GpuVideoDecodeAccelerator // Route ID to communicate with the host. int32 host_route_id_; - // Route ID of the decoder. - int32 decoder_route_id_; - // Messages deferred for later processing when their tokens have come to pass. std::vector<IPC::Message*> deferred_messages_; diff --git a/content/common/gpu/media/gpu_video_service.cc b/content/common/gpu/media/gpu_video_service.cc deleted file mode 100644 index d101d9d..0000000 --- a/content/common/gpu/media/gpu_video_service.cc +++ /dev/null @@ -1,135 +0,0 @@ -// 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/common/gpu/media/gpu_video_service.h" - -#include "content/common/gpu/gpu_channel.h" -#include "content/common/gpu/gpu_messages.h" -#include "content/common/gpu/media/gpu_video_decode_accelerator.h" - -#if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) -#include "content/common/gpu/media/omx_video_decode_accelerator.h" -#include "ui/gfx/gl/gl_surface_egl.h" -#endif // defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) - -GpuVideoService::GpuVideoService() { - // TODO(jiesun): move this time consuming stuff out of here. - IntializeGpuVideoService(); -} - -GpuVideoService::~GpuVideoService() { - // TODO(jiesun): move this time consuming stuff out of here. - UnintializeGpuVideoService(); -} - -// static -GpuVideoService* GpuVideoService::GetInstance() { - return Singleton<GpuVideoService>::get(); -} - -void GpuVideoService::OnChannelConnected(int32 peer_pid) { - LOG(ERROR) << "GpuVideoService::OnChannelConnected"; -} - -void GpuVideoService::OnChannelError() { - LOG(ERROR) << "GpuVideoService::OnChannelError"; -} - -bool GpuVideoService::OnMessageReceived(const IPC::Message& msg) { -#if 0 - IPC_BEGIN_MESSAGE_MAP(GpuVideoService, msg) - IPC_MESSAGE_UNHANDLED_ERROR() - IPC_END_MESSAGE_MAP() -#endif - return false; -} - -bool GpuVideoService::IntializeGpuVideoService() { - return true; -} - -bool GpuVideoService::UnintializeGpuVideoService() { - return true; -} - -bool GpuVideoService::CreateVideoDecoder( - GpuChannel* channel, - MessageRouter* router, - int32 decoder_host_id, - int32 decoder_id, - GpuCommandBufferStub* stub, - const std::vector<uint32>& configs) { - // Create GpuVideoDecodeAccelerator and add to map. - scoped_refptr<GpuVideoDecodeAccelerator> decoder = - new GpuVideoDecodeAccelerator(channel, decoder_host_id, decoder_id, stub); - - bool result = decoder_map_.insert(std::make_pair( - decoder_id, VideoDecoderInfo(decoder, stub))).second; - - // Decoder ID is a unique ID determined by GpuVideoServiceHost. - // We should always be adding entries here. - DCHECK(result); - - router->AddRoute(decoder_id, decoder); - - // Tell client that initialization is complete. - channel->Send( - new AcceleratedVideoDecoderHostMsg_CreateDone( - decoder_host_id, decoder_id)); - - return true; -} - -void GpuVideoService::InitializeVideoDecoder(int32 decoder_id) { -#if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) - DecoderMap::iterator it = decoder_map_.find(decoder_id); - DCHECK(it != decoder_map_.end()); - GpuVideoDecodeAccelerator* decoder = it->second.video_decoder.get(); - GpuCommandBufferStub* stub = it->second.stub; - DCHECK(stub->scheduler()); - OmxVideoDecodeAccelerator* omx_decoder = - new OmxVideoDecodeAccelerator(decoder); - omx_decoder->SetEglState( - gfx::GLSurfaceEGL::GetDisplay(), - stub->scheduler()->decoder()->GetGLContext()->GetHandle()); - decoder->set_video_decode_accelerator(omx_decoder); -#else - NOTIMPLEMENTED() << "HW video decode acceleration not available."; -#endif // defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) -} - -void GpuVideoService::DestroyVideoDecoder( - MessageRouter* router, - int32 decoder_id) { - router->RemoveRoute(decoder_id); - decoder_map_.erase(decoder_id); -} - -void GpuVideoService::AssignTexturesToDecoder( - int32 decoder_id, - const std::vector<int32>& buffer_ids, - const std::vector<uint32>& texture_ids, - const std::vector<gfx::Size>& sizes) { - DecoderMap::iterator it = decoder_map_.find(decoder_id); - DCHECK(it != decoder_map_.end()); - DCHECK_EQ(it->first, decoder_id); - GpuVideoDecodeAccelerator* video_decoder = it->second.video_decoder; - DCHECK(it->second.stub->scheduler()); // Ensure already Initialize()'d. - gpu::gles2::GLES2Decoder* command_decoder = - it->second.stub->scheduler()->decoder(); - - std::vector<media::GLESBuffer> buffers; - for (uint32 i = 0; i < buffer_ids.size(); ++i) { - uint32 service_texture_id; - if (!command_decoder->GetServiceTextureId( - texture_ids[i], &service_texture_id)) { - // TODO(vrk): Send an error for invalid GLES buffers. - LOG(DFATAL) << "Failed to translate texture!"; - return; - } - buffers.push_back(media::GLESBuffer( - buffer_ids[i], sizes[i], service_texture_id)); - } - video_decoder->AssignGLESBuffers(buffers); -} diff --git a/content/common/gpu/media/gpu_video_service.h b/content/common/gpu/media/gpu_video_service.h deleted file mode 100644 index 2700de8..0000000 --- a/content/common/gpu/media/gpu_video_service.h +++ /dev/null @@ -1,76 +0,0 @@ -// 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_COMMON_GPU_MEDIA_GPU_VIDEO_SERVICE_H_ -#define CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_SERVICE_H_ - -#include <map> - -#include "base/memory/ref_counted.h" -#include "base/memory/singleton.h" -#include "content/common/gpu/media/gpu_video_decode_accelerator.h" -#include "ipc/ipc_channel.h" - -namespace gpu { -namespace gles2 { -class GLES2Decoder; -} // namespace gles2 -} // namespace gpu - -class GpuChannel; -class MessageRouter; - -class GpuVideoService : public IPC::Channel::Listener { - public: - static GpuVideoService* GetInstance(); - - // IPC::Channel::Listener. - virtual void OnChannelConnected(int32 peer_pid); - virtual void OnChannelError(); - virtual bool OnMessageReceived(const IPC::Message& message); - - // TODO(hclam): Remove return value. - bool CreateVideoDecoder(GpuChannel* channel, - MessageRouter* router, - int32 decoder_host_id, - int32 decoder_id, - GpuCommandBufferStub* stub, - const std::vector<uint32>& configs); - void InitializeVideoDecoder(int32 decoder_id); - void DestroyVideoDecoder(MessageRouter* router, - int32 decoder_id); - - // Passes given GLES textures to the decoder indicated by id. - void AssignTexturesToDecoder(int32 decoder_id, - const std::vector<int32>& buffer_ids, - const std::vector<uint32>& texture_ids, - const std::vector<gfx::Size>& sizes); - - private: - struct VideoDecoderInfo { - VideoDecoderInfo(scoped_refptr<GpuVideoDecodeAccelerator> g_v_d_a, - GpuCommandBufferStub* s) - : video_decoder(g_v_d_a), - stub(s) {} - ~VideoDecoderInfo() {} - scoped_refptr<GpuVideoDecodeAccelerator> video_decoder; - GpuCommandBufferStub* stub; - }; - // Map of video and command buffer decoders, indexed by video decoder id. - typedef std::map<int32, VideoDecoderInfo> DecoderMap; - - GpuVideoService(); - virtual ~GpuVideoService(); - - // Specialize video service on different platform will override. - virtual bool IntializeGpuVideoService(); - virtual bool UnintializeGpuVideoService(); - - DecoderMap decoder_map_; - - friend struct DefaultSingletonTraits<GpuVideoService>; - DISALLOW_COPY_AND_ASSIGN(GpuVideoService); -}; - -#endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_SERVICE_H_ diff --git a/content/content_common.gypi b/content/content_common.gypi index 8fcc25a..5a85be8 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi @@ -127,8 +127,6 @@ 'common/gpu/gpu_watchdog.h', 'common/gpu/media/gpu_video_decode_accelerator.cc', 'common/gpu/media/gpu_video_decode_accelerator.h', - 'common/gpu/media/gpu_video_service.cc', - 'common/gpu/media/gpu_video_service.h', 'common/gpu/transport_texture.cc', 'common/gpu/transport_texture.h', 'common/hi_res_timer_manager_posix.cc', diff --git a/content/renderer/gpu/gpu_video_decode_accelerator_host.cc b/content/renderer/gpu/gpu_video_decode_accelerator_host.cc index 6aed720..1184fad 100644 --- a/content/renderer/gpu/gpu_video_decode_accelerator_host.cc +++ b/content/renderer/gpu/gpu_video_decode_accelerator_host.cc @@ -30,7 +30,6 @@ GpuVideoDecodeAcceleratorHost::GpuVideoDecodeAcceleratorHost( : router_(router), ipc_sender_(ipc_sender), decoder_host_id_(decoder_host_id), - decoder_id_(-1), command_buffer_route_id_(command_buffer_route_id), cmd_buffer_helper_(cmd_buffer_helper), client_(client) { @@ -55,8 +54,6 @@ bool GpuVideoDecodeAcceleratorHost::OnMessageReceived(const IPC::Message& msg) { OnBitstreamBufferProcessed) IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ProvidePictureBuffers, OnProvidePictureBuffer) - IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_CreateDone, - OnCreateDone) IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_InitializeDone, OnInitializeDone) IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_PictureReady, @@ -98,11 +95,9 @@ bool GpuVideoDecodeAcceleratorHost::Initialize( DCHECK(CalledOnValidThread()); router_->AddRoute(decoder_host_id_, this); - // Temporarily save configs for after create is done and we're - // ready to initialize. - configs_ = configs; - if (!ipc_sender_->Send(new GpuChannelMsg_CreateVideoDecoder( - decoder_host_id_, command_buffer_route_id_, configs))) { + // Tell GPU Channel to create and initialize a video decoder. + if (!ipc_sender_->Send(new GpuCommandBufferMsg_CreateVideoDecoder( + command_buffer_route_id_, decoder_host_id_, configs))) { LOG(ERROR) << "Send(GpuChannelMsg_CreateVideoDecoder) failed"; return false; } @@ -113,7 +108,7 @@ void GpuVideoDecodeAcceleratorHost::Decode( const media::BitstreamBuffer& bitstream_buffer) { DCHECK(CalledOnValidThread()); if (!ipc_sender_->Send(new AcceleratedVideoDecoderMsg_Decode( - decoder_id_, SyncTokens(), bitstream_buffer.handle(), + command_buffer_route_id_, SyncTokens(), bitstream_buffer.handle(), bitstream_buffer.id(), bitstream_buffer.size()))) { DLOG(ERROR) << "Send(AcceleratedVideoDecoderMsg_Decode) failed"; // TODO(fischman/vrk): signal error to client. @@ -134,8 +129,9 @@ void GpuVideoDecodeAcceleratorHost::AssignGLESBuffers( buffer_ids.push_back(buffer.id()); sizes.push_back(buffer.size()); } - if (!ipc_sender_->Send(new AcceleratedVideoDecoderMsg_AssignTextures( - decoder_id_, SyncTokens(), buffer_ids, texture_ids, sizes))) { + if (!ipc_sender_->Send(new AcceleratedVideoDecoderMsg_AssignGLESBuffers( + command_buffer_route_id_, SyncTokens(), buffer_ids, texture_ids, + sizes))) { LOG(ERROR) << "Send(AcceleratedVideoDecoderMsg_AssignGLESBuffers) failed"; } } @@ -151,7 +147,7 @@ void GpuVideoDecodeAcceleratorHost::ReusePictureBuffer( int32 picture_buffer_id) { DCHECK(CalledOnValidThread()); if (!ipc_sender_->Send(new AcceleratedVideoDecoderMsg_ReusePictureBuffer( - decoder_id_, SyncTokens(), picture_buffer_id))) { + command_buffer_route_id_, SyncTokens(), picture_buffer_id))) { LOG(ERROR) << "Send(AcceleratedVideoDecoderMsg_ReusePictureBuffer) failed"; } } @@ -159,7 +155,7 @@ void GpuVideoDecodeAcceleratorHost::ReusePictureBuffer( void GpuVideoDecodeAcceleratorHost::Flush() { DCHECK(CalledOnValidThread()); if (!ipc_sender_->Send(new AcceleratedVideoDecoderMsg_Flush( - decoder_id_, SyncTokens()))) { + command_buffer_route_id_, SyncTokens()))) { LOG(ERROR) << "Send(AcceleratedVideoDecoderMsg_Flush) failed"; // TODO(fischman/vrk): signal error to client. return; @@ -169,7 +165,7 @@ void GpuVideoDecodeAcceleratorHost::Flush() { void GpuVideoDecodeAcceleratorHost::Abort() { DCHECK(CalledOnValidThread()); if (!ipc_sender_->Send(new AcceleratedVideoDecoderMsg_Abort( - decoder_id_, SyncTokens()))) { + command_buffer_route_id_, SyncTokens()))) { LOG(ERROR) << "Send(AcceleratedVideoDecoderMsg_Abort) failed"; // TODO(fischman/vrk): signal error to client. return; @@ -199,15 +195,6 @@ void GpuVideoDecodeAcceleratorHost::OnDismissPictureBuffer( client_->DismissPictureBuffer(picture_buffer_id); } -void GpuVideoDecodeAcceleratorHost::OnCreateDone(int32 decoder_id) { - DCHECK(CalledOnValidThread()); - decoder_id_ = decoder_id; - if (!ipc_sender_->Send(new AcceleratedVideoDecoderMsg_Initialize( - decoder_id_, SyncTokens(), configs_))) { - LOG(ERROR) << "Send(AcceleratedVideoDecoderMsg_Initialize) failed"; - } -} - void GpuVideoDecodeAcceleratorHost::OnInitializeDone() { DCHECK(CalledOnValidThread()); client_->NotifyInitializeDone(); diff --git a/content/renderer/gpu/gpu_video_decode_accelerator_host.h b/content/renderer/gpu/gpu_video_decode_accelerator_host.h index 9012168..9c2d93b 100644 --- a/content/renderer/gpu/gpu_video_decode_accelerator_host.h +++ b/content/renderer/gpu/gpu_video_decode_accelerator_host.h @@ -65,7 +65,6 @@ class GpuVideoDecodeAcceleratorHost void OnProvidePictureBuffer( uint32 num_requested_buffers, const gfx::Size& buffer_size, int32 mem_type); void OnDismissPictureBuffer(int32 picture_buffer_id); - void OnCreateDone(int32 decoder_id); void OnInitializeDone(); void OnPictureReady(int32 picture_buffer_id, int32 bitstream_buffer_id, @@ -103,9 +102,6 @@ class GpuVideoDecodeAcceleratorHost // message processing behind it. gpu::CommandBufferHelper* cmd_buffer_helper_; - // Temporarily store configs here in between Create and Initialize phase. - std::vector<uint32> configs_; - // Reference to the client that will receive callbacks from the decoder. media::VideoDecodeAccelerator::Client* client_; diff --git a/content/renderer/gpu/gpu_video_service_host.cc b/content/renderer/gpu/gpu_video_service_host.cc index 2a39476..12309be 100644 --- a/content/renderer/gpu/gpu_video_service_host.cc +++ b/content/renderer/gpu/gpu_video_service_host.cc @@ -34,7 +34,6 @@ bool GpuVideoServiceHost::OnMessageReceived(const IPC::Message& msg) { switch (msg.type()) { case AcceleratedVideoDecoderHostMsg_BitstreamBufferProcessed::ID: case AcceleratedVideoDecoderHostMsg_ProvidePictureBuffers::ID: - case AcceleratedVideoDecoderHostMsg_CreateDone::ID: case AcceleratedVideoDecoderHostMsg_InitializeDone::ID: case AcceleratedVideoDecoderHostMsg_DismissPictureBuffer::ID: case AcceleratedVideoDecoderHostMsg_PictureReady::ID: |