From e0b3ea152c9450288319cd65329a8f664cac9107 Mon Sep 17 00:00:00 2001 From: "davemoore@chromium.org" Date: Fri, 10 Jun 2011 18:55:06 +0000 Subject: Revert 88698 - Implement AssignGLESBuffers for VideoDecode PPAPI Fills in implementation for AssignGLESBuffers where it was missing. Also updates OmxVideoDecodeAccelerator to reflect the changes. BUG=NONE TEST=NONE Review URL: http://codereview.chromium.org/6965010 TBR=vrk@google.com Review URL: http://codereview.chromium.org/7044115 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88702 0039d316-1c4b-4281-b951-d872f2087c98 --- content/common/gpu/gpu_channel.cc | 32 ++----- content/common/gpu/gpu_channel.h | 6 -- content/common/gpu/gpu_messages.h | 18 ++-- content/common/gpu/gpu_video_decode_accelerator.cc | 14 ++-- content/common/gpu/gpu_video_decode_accelerator.h | 6 +- content/common/gpu/gpu_video_service.cc | 47 +---------- content/common/gpu/gpu_video_service.h | 33 +------- .../gpu/omx_video_decode_accelerator_unittest.cc | 4 +- .../gpu/gpu_video_decode_accelerator_host.cc | 10 +-- .../gpu/gpu_video_decode_accelerator_host.h | 5 -- content/renderer/gpu/gpu_video_service_host.cc | 6 +- content/renderer/gpu/gpu_video_service_host.h | 3 +- .../renderer/pepper_platform_context_3d_impl.cc | 7 +- content/renderer/pepper_platform_context_3d_impl.h | 1 - .../renderer/pepper_platform_video_decoder_impl.cc | 18 +--- .../renderer/pepper_platform_video_decoder_impl.h | 10 +-- content/renderer/pepper_plugin_delegate_impl.cc | 5 +- content/renderer/pepper_plugin_delegate_impl.h | 3 +- media/video/picture.cc | 6 +- media/video/picture.h | 13 ++- ppapi/c/dev/pp_video_dev.h | 3 + ppapi/c/dev/ppb_video_decoder_dev.h | 7 +- ppapi/c/dev/ppp_video_decoder_dev.h | 32 +++---- ppapi/cpp/dev/video_decoder_client_dev.cc | 98 ---------------------- ppapi/cpp/dev/video_decoder_client_dev.h | 57 ------------- ppapi/cpp/dev/video_decoder_dev.cc | 45 +++++----- ppapi/cpp/dev/video_decoder_dev.h | 51 +++++++++-- ppapi/ppapi_cpp.gypi | 2 - ppapi/tests/test_video_decoder.cc | 2 +- webkit/plugins/ppapi/mock_plugin_delegate.cc | 3 +- webkit/plugins/ppapi/mock_plugin_delegate.h | 3 +- webkit/plugins/ppapi/plugin_delegate.h | 7 +- webkit/plugins/ppapi/ppb_video_decoder_impl.cc | 41 +++------ webkit/plugins/ppapi/ppb_video_decoder_impl.h | 3 +- 34 files changed, 161 insertions(+), 440 deletions(-) delete mode 100644 ppapi/cpp/dev/video_decoder_client_dev.cc delete mode 100644 ppapi/cpp/dev/video_decoder_client_dev.h diff --git a/content/common/gpu/gpu_channel.cc b/content/common/gpu/gpu_channel.cc index b7a8349..72d822b 100644 --- a/content/common/gpu/gpu_channel.cc +++ b/content/common/gpu/gpu_channel.cc @@ -18,7 +18,6 @@ #include "content/common/gpu/gpu_messages.h" #include "content/common/gpu/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" #if defined(OS_POSIX) @@ -206,8 +205,6 @@ bool GpuChannel::OnControlMessageReceived(const IPC::Message& msg) { OnDestroyVideoDecoder) IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateTransportTexture, OnCreateTransportTexture) - IPC_MESSAGE_HANDLER(GpuChannelMsg_AssignTexturesToVideoDecoder, - OnAssignTexturesToVideoDecoder) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() DCHECK(handled); @@ -298,26 +295,24 @@ void GpuChannel::OnDestroySurface(int route_id) { #endif } -void GpuChannel::OnCreateVideoDecoder(int32 decoder_host_id, - uint32 command_buffer_route_id, - const std::vector& configs) { +void GpuChannel::OnCreateVideoDecoder( + int32 decoder_host_id, const std::vector& configs) { +// TODO(cevans): do NOT re-enable this until GpuVideoService has been checked +// for integer overflows, including the classic "width * height" overflow. +#if 0 + VLOG(1) << "GpuChannel::OnCreateVideoDecoder"; 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(); bool ret = service->CreateVideoDecoder( - this, &router_, decoder_host_id, decoder_id, stub->scheduler()->decoder(), - configs); + this, &router_, decoder_host_id, decoder_id, configs); DCHECK(ret) << "Failed to create a GpuVideoDecodeAccelerator"; +#endif } void GpuChannel::OnDestroyVideoDecoder(int32 decoder_id) { @@ -346,16 +341,7 @@ void GpuChannel::OnCreateTransportTexture(int32 context_route_id, host_id, route_id); Send(msg); #endif -} - -void GpuChannel::OnAssignTexturesToVideoDecoder( - int32 decoder_id, - const std::vector& buffer_ids, - const std::vector& texture_ids, - const std::vector& sizes) { - GpuVideoService* service = GpuVideoService::GetInstance(); - service->AssignTexturesToDecoder(decoder_id, buffer_ids, texture_ids, sizes); -} + } bool GpuChannel::Init(base::MessageLoopProxy* io_message_loop, base::WaitableEvent* shutdown_event) { diff --git a/content/common/gpu/gpu_channel.h b/content/common/gpu/gpu_channel.h index a7bf112..d0632bd 100644 --- a/content/common/gpu/gpu_channel.h +++ b/content/common/gpu/gpu_channel.h @@ -127,16 +127,10 @@ class GpuChannel : public IPC::Channel::Listener, void OnDestroySurface(int route_id); void OnCreateVideoDecoder(int32 decoder_host_id, - uint32 command_buffer_route_id, const std::vector& configs); void OnDestroyVideoDecoder(int32 decoder_id); void OnCreateTransportTexture(int32 context_route_id, int32 host_id); - void OnAssignTexturesToVideoDecoder(int32 decoder_id, - const std::vector& buffer_ids, - const std::vector& texture_ids, - const std::vector& sizes); - // The lifetime of objects of this class is managed by a GpuChannelManager. // The GpuChannelManager destroy all the GpuChannels that they own when they // are destroyed. So a raw pointer is safe. diff --git a/content/common/gpu/gpu_messages.h b/content/common/gpu/gpu_messages.h index bd390c2..98f838e 100644 --- a/content/common/gpu/gpu_messages.h +++ b/content/common/gpu/gpu_messages.h @@ -261,9 +261,8 @@ IPC_MESSAGE_CONTROL1(GpuChannelMsg_DestroySurface, // 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|. -IPC_MESSAGE_CONTROL3(GpuChannelMsg_CreateVideoDecoder, +IPC_MESSAGE_CONTROL2(GpuChannelMsg_CreateVideoDecoder, int32, /* decoder_id */ - uint32, /* command buffer route id*/ std::vector) /* configs */ // Release all resource of the hardware video decoder which was assocaited @@ -277,13 +276,6 @@ IPC_MESSAGE_CONTROL2(GpuChannelMsg_CreateTransportTexture, int32, /* context_route_id */ int32 /* host_id */) -// Sent from Renderer process to the GPU process to give the texture IDs for -// the textures the decoder will use for output. -IPC_MESSAGE_CONTROL4(GpuChannelMsg_AssignTexturesToVideoDecoder, - int32, /* Decoder ID */ - std::vector, /* Picture buffer ID */ - std::vector, /* Texture ID */ - std::vector) /* Size */ //------------------------------------------------------------------------------ // GPU Command Buffer Messages // These are messages between a renderer process to the GPU process relating to @@ -424,6 +416,14 @@ IPC_MESSAGE_ROUTED3(AcceleratedVideoDecoderMsg_Decode, base::SharedMemoryHandle, /* input_buffer_handle */ int32) /* size */ +// Sent from Renderer process to the GPU process to give the texture IDs for +// the textures the decoder will use for output. +IPC_MESSAGE_ROUTED4(AcceleratedVideoDecoderMsg_AssignGLESBuffers, + std::vector, /* Picture buffer ID */ + std::vector, /* Texture ID */ + std::vector, /* Context ID */ + std::vector) /* Size */ + // Sent from Renderer process to the GPU process to give the system memory // buffers that the decoder will use for output. // diff --git a/content/common/gpu/gpu_video_decode_accelerator.cc b/content/common/gpu/gpu_video_decode_accelerator.cc index 5a19b8a..646fd57 100644 --- a/content/common/gpu/gpu_video_decode_accelerator.cc +++ b/content/common/gpu/gpu_video_decode_accelerator.cc @@ -32,6 +32,8 @@ bool GpuVideoDecodeAccelerator::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_Decode, OnDecode) IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_AssignSysmemBuffers, OnAssignSysmemBuffers) + IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_AssignGLESBuffers, + OnAssignGLESBuffers) IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_ReusePictureBuffer, OnReusePictureBuffer) IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_Flush, OnFlush) @@ -120,11 +122,13 @@ void GpuVideoDecodeAccelerator::OnDecode(int32 id, video_decode_accelerator_->Decode(media::BitstreamBuffer(id, handle, size)); } -void GpuVideoDecodeAccelerator::AssignGLESBuffers( - const std::vector& buffers) { - if (!video_decode_accelerator_.get()) - return; - video_decode_accelerator_->AssignGLESBuffers(buffers); +void GpuVideoDecodeAccelerator::OnAssignGLESBuffers( + const std::vector buffer_ids, + const std::vector texture_ids, + const std::vector context_ids, + const std::vector sizes) { + // TODO(vrk): Implement. + NOTIMPLEMENTED(); } void GpuVideoDecodeAccelerator::OnAssignSysmemBuffers( diff --git a/content/common/gpu/gpu_video_decode_accelerator.h b/content/common/gpu/gpu_video_decode_accelerator.h index ffa855a..383cbc9 100644 --- a/content/common/gpu/gpu_video_decode_accelerator.h +++ b/content/common/gpu/gpu_video_decode_accelerator.h @@ -50,14 +50,16 @@ class GpuVideoDecodeAccelerator video_decode_accelerator_.reset(accelerator); } - void AssignGLESBuffers(const std::vector& buffers); - private: // Handlers for IPC messages. void OnGetConfigs(const std::vector& config, std::vector* configs); void OnInitialize(const std::vector& configs); void OnDecode(int32 id, base::SharedMemoryHandle handle, int32 size); + void OnAssignGLESBuffers(const std::vector buffer_ids, + const std::vector texture_ids, + const std::vector context_ids, + const std::vector sizes); void OnAssignSysmemBuffers(const std::vector buffer_ids, const std::vector data, const std::vector sizes); diff --git a/content/common/gpu/gpu_video_service.cc b/content/common/gpu/gpu_video_service.cc index 9b5c0e6..26814f5 100644 --- a/content/common/gpu/gpu_video_service.cc +++ b/content/common/gpu/gpu_video_service.cc @@ -7,11 +7,9 @@ #include "content/common/gpu/gpu_channel.h" #include "content/common/gpu/gpu_messages.h" #include "content/common/gpu/gpu_video_decode_accelerator.h" -#include "gpu/command_buffer/service/gles2_cmd_decoder.h" #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) #include "content/common/gpu/omx_video_decode_accelerator.h" -#include "ui/gfx/gl/gl_surface_egl.h" #endif // defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) GpuVideoService::GpuVideoService() { @@ -59,23 +57,16 @@ bool GpuVideoService::CreateVideoDecoder( MessageRouter* router, int32 decoder_host_id, int32 decoder_id, - gpu::gles2::GLES2Decoder* command_decoder, const std::vector& configs) { // Create GpuVideoDecodeAccelerator and add to map. scoped_refptr decoder = new GpuVideoDecodeAccelerator(channel, decoder_host_id); - #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) - OmxVideoDecodeAccelerator* omx_decoder = - new OmxVideoDecodeAccelerator(decoder, MessageLoop::current()); - omx_decoder->SetEglState(gfx::GLSurfaceEGL::GetDisplay(), - command_decoder->GetGLContext()->GetHandle()); - decoder->set_video_decode_accelerator(omx_decoder); - + decoder->set_video_decode_accelerator( + new OmxVideoDecodeAccelerator(decoder, MessageLoop::current())); #endif // defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) - bool result = decoder_map_.insert(std::make_pair( - decoder_id, VideoDecoderInfo(decoder, command_decoder))).second; + bool result = decoder_map_.insert(std::make_pair(decoder_id, decoder)).second; // Decoder ID is a unique ID determined by GpuVideoServiceHost. // We should always be adding entries here. @@ -97,35 +88,3 @@ void GpuVideoService::DestroyVideoDecoder( router->RemoveRoute(decoder_id); decoder_map_.erase(decoder_id); } - -void GpuVideoService::AssignTexturesToDecoder( - int32 decoder_id, - const std::vector& buffer_ids, - const std::vector& texture_ids, - const std::vector& sizes) { - std::vector buffers; - for (uint32 i = 0; i < buffer_ids.size(); ++i) { - uint32 service_texture_id; - bool result = TranslateTextureForDecoder( - decoder_id, texture_ids[i], &service_texture_id); - // TODO(vrk): Send an error for invalid GLES buffers. - if (!result) - return; - buffers.push_back( - media::GLESBuffer(buffer_ids[i], sizes[i], service_texture_id)); - } - - DecoderMap::iterator it = decoder_map_.find(decoder_id); - DCHECK(it != decoder_map_.end()); - it->second.video_decoder->AssignGLESBuffers(buffers); -} - -bool GpuVideoService::TranslateTextureForDecoder( - int32 decoder_id, uint32 client_texture_id, uint32* service_texture_id) { - DecoderMap::iterator it = decoder_map_.find(decoder_id); - if (it == decoder_map_.end()) - return false; - it->second.command_decoder->MakeCurrent(); - return it->second.command_decoder->GetServiceTextureId( - client_texture_id, service_texture_id); -} diff --git a/content/common/gpu/gpu_video_service.h b/content/common/gpu/gpu_video_service.h index 43e5833..44090c4 100644 --- a/content/common/gpu/gpu_video_service.h +++ b/content/common/gpu/gpu_video_service.h @@ -12,12 +12,6 @@ #include "content/common/gpu/gpu_video_decode_accelerator.h" #include "ipc/ipc_channel.h" -namespace gpu { -namespace gles2 { -class GLES2Decoder; -} // namespace gles2 -} // namespace gpu - class GpuChannel; class MessageRouter; @@ -35,43 +29,20 @@ class GpuVideoService : public IPC::Channel::Listener { MessageRouter* router, int32 decoder_host_id, int32 decoder_id, - gpu::gles2::GLES2Decoder* command_decoder, const std::vector& configs); 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& buffer_ids, - const std::vector& texture_ids, - const std::vector& sizes); - private: - struct VideoDecoderInfo { - VideoDecoderInfo(scoped_refptr g_v_d_a, - gpu::gles2::GLES2Decoder* g_d) - : video_decoder(g_v_d_a), - command_decoder(g_d) {} - scoped_refptr video_decoder; - gpu::gles2::GLES2Decoder* command_decoder; - }; - // Map of video and command buffer decoders, indexed by video decoder id. - typedef std::map DecoderMap; - GpuVideoService(); virtual ~GpuVideoService(); + std::map > decoder_map_; + // Specialize video service on different platform will override. virtual bool IntializeGpuVideoService(); virtual bool UnintializeGpuVideoService(); - // Translates a given client texture id to the "real" texture id as recognized - // in the GPU process. - bool TranslateTextureForDecoder( - int32 decoder_id, uint32 client_texture_id, uint32* service_texture_id); - - DecoderMap decoder_map_; - friend struct DefaultSingletonTraits; DISALLOW_COPY_AND_ASSIGN(GpuVideoService); }; diff --git a/content/common/gpu/omx_video_decode_accelerator_unittest.cc b/content/common/gpu/omx_video_decode_accelerator_unittest.cc index fb358bc..691d6da 100644 --- a/content/common/gpu/omx_video_decode_accelerator_unittest.cc +++ b/content/common/gpu/omx_video_decode_accelerator_unittest.cc @@ -495,8 +495,10 @@ void EglRenderingVDAClient::ProvidePictureBuffers( base::WaitableEvent done(false, false); rendering_helper_->CreateTexture(rendering_window_id_, &texture_id, &done); done.Wait(); + // TODO(fischman): context_id is always 0. Can it be removed from the API? + // (since it's always inferrable from context). media::GLESBuffer* buffer = - new media::GLESBuffer(id, dimensions, texture_id); + new media::GLESBuffer(id, dimensions, texture_id, 0 /* context_id */); CHECK(picture_buffers_by_id_.insert(std::make_pair(id, buffer)).second); buffers.push_back(*buffer); } diff --git a/content/renderer/gpu/gpu_video_decode_accelerator_host.cc b/content/renderer/gpu/gpu_video_decode_accelerator_host.cc index 8a03cda..4ca5ca6 100644 --- a/content/renderer/gpu/gpu_video_decode_accelerator_host.cc +++ b/content/renderer/gpu/gpu_video_decode_accelerator_host.cc @@ -19,13 +19,11 @@ GpuVideoDecodeAcceleratorHost::GpuVideoDecodeAcceleratorHost( MessageRouter* router, IPC::Message::Sender* ipc_sender, int32 decoder_host_id, - uint32 command_buffer_route_id, VideoDecodeAccelerator::Client* client) : router_(router), ipc_sender_(ipc_sender), decoder_host_id_(decoder_host_id), decoder_id_(0), - command_buffer_route_id_(command_buffer_route_id), client_(client) { } @@ -81,7 +79,7 @@ bool GpuVideoDecodeAcceleratorHost::Initialize( configs_ = configs; if (!ipc_sender_->Send(new GpuChannelMsg_CreateVideoDecoder( - decoder_id_, command_buffer_route_id_, configs))) { + decoder_id_, configs))) { LOG(ERROR) << "Send(GpuChannelMsg_CreateVideoDecoder) failed"; return false; } @@ -105,15 +103,17 @@ void GpuVideoDecodeAcceleratorHost::AssignGLESBuffers( // Rearrange data for IPC command. std::vector buffer_ids; std::vector texture_ids; + std::vector context_ids; std::vector sizes; for (uint32 i = 0; i < buffers.size(); i++) { const media::GLESBuffer& buffer = buffers[i]; texture_ids.push_back(buffer.texture_id()); + context_ids.push_back(buffer.context_id()); buffer_ids.push_back(buffer.id()); sizes.push_back(buffer.size()); } - if (!ipc_sender_->Send(new GpuChannelMsg_AssignTexturesToVideoDecoder( - decoder_id_, buffer_ids, texture_ids, sizes))) { + if (!ipc_sender_->Send(new AcceleratedVideoDecoderMsg_AssignGLESBuffers( + decoder_id_, buffer_ids, texture_ids, context_ids, sizes))) { LOG(ERROR) << "Send(AcceleratedVideoDecoderMsg_AssignGLESBuffers) failed"; } } diff --git a/content/renderer/gpu/gpu_video_decode_accelerator_host.h b/content/renderer/gpu/gpu_video_decode_accelerator_host.h index 8b4a4c3..a7ac98f 100644 --- a/content/renderer/gpu/gpu_video_decode_accelerator_host.h +++ b/content/renderer/gpu/gpu_video_decode_accelerator_host.h @@ -25,7 +25,6 @@ class GpuVideoDecodeAcceleratorHost : public IPC::Channel::Listener, GpuVideoDecodeAcceleratorHost(MessageRouter* router, IPC::Message::Sender* ipc_sender, int32 decoder_host_id, - uint32 command_buffer_route_id, media::VideoDecodeAccelerator::Client* client); virtual ~GpuVideoDecodeAcceleratorHost(); @@ -76,10 +75,6 @@ class GpuVideoDecodeAcceleratorHost : public IPC::Channel::Listener, // ID of VideoDecodeAccelerator in the Gpu process. int32 decoder_id_; - // Route ID for the command buffer associated with the context the GPU Video - // Decoder uses. - uint32 command_buffer_route_id_; - // Temporarily store configs here in between Create and Initialize phase. std::vector configs_; diff --git a/content/renderer/gpu/gpu_video_service_host.cc b/content/renderer/gpu/gpu_video_service_host.cc index 9b3fe22..0c629f8 100644 --- a/content/renderer/gpu/gpu_video_service_host.cc +++ b/content/renderer/gpu/gpu_video_service_host.cc @@ -71,11 +71,9 @@ void GpuVideoServiceHost::SetOnInitialized( } GpuVideoDecodeAcceleratorHost* GpuVideoServiceHost::CreateVideoAccelerator( - media::VideoDecodeAccelerator::Client* client, - int command_buffer_route_id) { + media::VideoDecodeAccelerator::Client* client) { base::AutoLock auto_lock(lock_); DCHECK(channel_); return new GpuVideoDecodeAcceleratorHost( - &router_, channel_, next_decoder_host_id_++, - command_buffer_route_id, client); + &router_, channel_, next_decoder_host_id_++, client); } diff --git a/content/renderer/gpu/gpu_video_service_host.h b/content/renderer/gpu/gpu_video_service_host.h index 83028c11..be3e44b 100644 --- a/content/renderer/gpu/gpu_video_service_host.h +++ b/content/renderer/gpu/gpu_video_service_host.h @@ -37,8 +37,7 @@ class GpuVideoServiceHost : public IPC::ChannelProxy::MessageFilter { // Called on RenderThread to create a hardware accelerated video decoder // in the GPU process. GpuVideoDecodeAcceleratorHost* CreateVideoAccelerator( - media::VideoDecodeAccelerator::Client* client, - int command_buffer_route_id); + media::VideoDecodeAccelerator::Client* client); private: // Guards all members other than |router_|. diff --git a/content/renderer/pepper_platform_context_3d_impl.cc b/content/renderer/pepper_platform_context_3d_impl.cc index acd19f6..5b7a59a 100644 --- a/content/renderer/pepper_platform_context_3d_impl.cc +++ b/content/renderer/pepper_platform_context_3d_impl.cc @@ -103,13 +103,8 @@ gpu::CommandBuffer* PlatformContext3DImpl::GetCommandBuffer() { return command_buffer_; } -int PlatformContext3DImpl::GetCommandBufferRouteId() { - DCHECK(command_buffer_); - return command_buffer_->route_id(); -} - void PlatformContext3DImpl::SetContextLostCallback(Callback0::Type* callback) { - context_lost_callback_.reset(callback); + context_lost_callback_.reset(callback); } void PlatformContext3DImpl::OnContextLost() { diff --git a/content/renderer/pepper_platform_context_3d_impl.h b/content/renderer/pepper_platform_context_3d_impl.h index c1a34aa..9968217 100644 --- a/content/renderer/pepper_platform_context_3d_impl.h +++ b/content/renderer/pepper_platform_context_3d_impl.h @@ -32,7 +32,6 @@ class PlatformContext3DImpl virtual void SetSwapBuffersCallback(Callback0::Type* callback); virtual unsigned GetBackingTextureId(); virtual gpu::CommandBuffer* GetCommandBuffer(); - virtual int GetCommandBufferRouteId(); virtual void SetContextLostCallback(Callback0::Type* callback); private: diff --git a/content/renderer/pepper_platform_video_decoder_impl.cc b/content/renderer/pepper_platform_video_decoder_impl.cc index 27fd963..7873bcf 100644 --- a/content/renderer/pepper_platform_video_decoder_impl.cc +++ b/content/renderer/pepper_platform_video_decoder_impl.cc @@ -17,11 +17,9 @@ using media::BitstreamBuffer; PlatformVideoDecoderImpl::PlatformVideoDecoderImpl( - VideoDecodeAccelerator::Client* client, uint32 command_buffer_route_id) + VideoDecodeAccelerator::Client* client) : client_(client), - command_buffer_route_id_(command_buffer_route_id), - decoder_(NULL), - message_loop_(NULL) { + decoder_(NULL) { DCHECK(client); } @@ -41,8 +39,6 @@ bool PlatformVideoDecoderImpl::Initialize(const std::vector& config) { RenderThread* render_thread = RenderThread::current(); DCHECK(render_thread); - message_loop_ = MessageLoop::current(); - DCHECK(message_loop_); channel_ = render_thread->EstablishGpuChannelSync( content::CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); @@ -76,8 +72,7 @@ void PlatformVideoDecoderImpl::InitializeDecoder( return; } GpuVideoServiceHost* video_service = channel_->gpu_video_service_host(); - decoder_.reset(video_service->CreateVideoAccelerator( - this, command_buffer_route_id_)); + decoder_.reset(video_service->CreateVideoAccelerator(this)); // Send IPC message to initialize decoder in GPU process. decoder_->Initialize(configs); @@ -141,13 +136,6 @@ void PlatformVideoDecoderImpl::PictureReady(const media::Picture& picture) { } void PlatformVideoDecoderImpl::NotifyInitializeDone() { - if (message_loop_ != MessageLoop::current() ) { - message_loop_-> - PostTask(FROM_HERE, base::Bind( - &PlatformVideoDecoderImpl::NotifyInitializeDone, - base::Unretained(this))); - return; - } client_->NotifyInitializeDone(); } diff --git a/content/renderer/pepper_platform_video_decoder_impl.h b/content/renderer/pepper_platform_video_decoder_impl.h index eb8bf4e..4588ea7 100644 --- a/content/renderer/pepper_platform_video_decoder_impl.h +++ b/content/renderer/pepper_platform_video_decoder_impl.h @@ -9,7 +9,6 @@ #include "base/scoped_ptr.h" #include "base/memory/ref_counted.h" -#include "base/message_loop.h" #include "media/video/video_decode_accelerator.h" #include "webkit/plugins/ppapi/plugin_delegate.h" @@ -21,8 +20,7 @@ class PlatformVideoDecoderImpl public base::RefCountedThreadSafe { public: explicit PlatformVideoDecoderImpl( - media::VideoDecodeAccelerator::Client* client, - uint32 command_buffer_route_id); + media::VideoDecodeAccelerator::Client* client); virtual ~PlatformVideoDecoderImpl(); // PlatformVideoDecoder implementation. @@ -61,18 +59,12 @@ class PlatformVideoDecoderImpl // Client lifetime must exceed lifetime of this class. media::VideoDecodeAccelerator::Client* client_; - // Route ID for the command buffer associated with video decoder's context. - uint32 command_buffer_route_id_; - // Host for GpuVideoDecodeAccelerator. scoped_ptr decoder_; // Host for Gpu Channel. scoped_refptr channel_; - // Message loop on which plugin is initialized. - MessageLoop* message_loop_; - DISALLOW_COPY_AND_ASSIGN(PlatformVideoDecoderImpl); }; diff --git a/content/renderer/pepper_plugin_delegate_impl.cc b/content/renderer/pepper_plugin_delegate_impl.cc index 4367c4e..918ec5b 100644 --- a/content/renderer/pepper_plugin_delegate_impl.cc +++ b/content/renderer/pepper_plugin_delegate_impl.cc @@ -828,9 +828,8 @@ webkit::ppapi::PluginDelegate::PlatformContext3D* webkit::ppapi::PluginDelegate::PlatformVideoDecoder* PepperPluginDelegateImpl::CreateVideoDecoder( - media::VideoDecodeAccelerator::Client* client, - int command_buffer_route_id) { - return new PlatformVideoDecoderImpl(client, command_buffer_route_id); + media::VideoDecodeAccelerator::Client* client) { + return new PlatformVideoDecoderImpl(client); } void PepperPluginDelegateImpl::NumberOfFindResultsChanged(int identifier, diff --git a/content/renderer/pepper_plugin_delegate_impl.h b/content/renderer/pepper_plugin_delegate_impl.h index 2c7bf47..8f66680 100644 --- a/content/renderer/pepper_plugin_delegate_impl.h +++ b/content/renderer/pepper_plugin_delegate_impl.h @@ -179,8 +179,7 @@ class PepperPluginDelegateImpl virtual PlatformImage2D* CreateImage2D(int width, int height); virtual PlatformContext3D* CreateContext3D(); virtual PlatformVideoDecoder* CreateVideoDecoder( - media::VideoDecodeAccelerator::Client* client, - int command_buffer_route_id); + media::VideoDecodeAccelerator::Client* client); virtual PpapiBroker* ConnectToPpapiBroker( webkit::ppapi::PPB_Broker_Impl* client); virtual void NumberOfFindResultsChanged(int identifier, diff --git a/media/video/picture.cc b/media/video/picture.cc index 60fd3f5..f2d6632 100644 --- a/media/video/picture.cc +++ b/media/video/picture.cc @@ -15,9 +15,9 @@ BaseBuffer::~BaseBuffer() {} BaseBuffer::BaseBuffer(int32 id, gfx::Size size) : id_(id), size_(size) { } -GLESBuffer::GLESBuffer(int32 id, gfx::Size size, uint32 texture_id) - : BaseBuffer(id, size), - texture_id_(texture_id) { +GLESBuffer::GLESBuffer( + int32 id, gfx::Size size, uint32 texture_id, uint32 context_id) + : BaseBuffer(id, size), texture_id_(texture_id), context_id_(context_id) { } SysmemBuffer::SysmemBuffer(int32 id, gfx::Size size, void* data) diff --git a/media/video/picture.h b/media/video/picture.h index e28a5c4..e268c51 100644 --- a/media/video/picture.h +++ b/media/video/picture.h @@ -6,7 +6,6 @@ #define MEDIA_VIDEO_PICTURE_H_ #include "base/basictypes.h" -#include "ui/gfx/gl/gl_context.h" #include "ui/gfx/size.h" struct PP_BufferInfo_Dev; @@ -43,18 +42,24 @@ class BaseBuffer { // This is the media-namespace equivalent of PP_GLESBuffer_Dev. class GLESBuffer : public BaseBuffer { public: - GLESBuffer(int32 id, gfx::Size size, uint32 texture_id); + GLESBuffer(int32 id, gfx::Size size, uint32 texture_id, uint32 context_id); GLESBuffer(const PP_GLESBuffer_Dev& buffer); // Returns the id of the texture. - // NOTE: The texture id in the renderer process corresponds to a different - // texture id in the GPU process. uint32 texture_id() const { return texture_id_; } + // Returns the id of the context in which this texture lives. + // TODO(vrk): I'm not sure if "id" is what we want, or some reference to the + // PPB_Context3D_Dev. Not sure how this eventually gets used. + uint32 context_id() const { + return context_id_; + } + private: uint32 texture_id_; + uint32 context_id_; }; // A picture buffer that lives in system memory. diff --git a/ppapi/c/dev/pp_video_dev.h b/ppapi/c/dev/pp_video_dev.h index 8833818..4bf1cf3 100644 --- a/ppapi/c/dev/pp_video_dev.h +++ b/ppapi/c/dev/pp_video_dev.h @@ -201,6 +201,9 @@ struct PP_BufferInfo_Dev { // Struct for specifying texture-backed picture data. struct PP_GLESBuffer_Dev { + // Context allocated using PPB_Context3D_Dev. + PP_Resource context; + // Texture ID in the given context where picture is stored. GLuint texture_id; diff --git a/ppapi/c/dev/ppb_video_decoder_dev.h b/ppapi/c/dev/ppb_video_decoder_dev.h index 7f59df1..4ec65df 100644 --- a/ppapi/c/dev/ppb_video_decoder_dev.h +++ b/ppapi/c/dev/ppb_video_decoder_dev.h @@ -9,8 +9,8 @@ #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_var.h" -#define PPB_VIDEODECODER_DEV_INTERFACE_0_9 "PPB_VideoDecoder(Dev);0.9" -#define PPB_VIDEODECODER_DEV_INTERFACE PPB_VIDEODECODER_DEV_INTERFACE_0_9 +#define PPB_VIDEODECODER_DEV_INTERFACE_0_8 "PPB_VideoDecoder(Dev);0.8" +#define PPB_VIDEODECODER_DEV_INTERFACE PPB_VIDEODECODER_DEV_INTERFACE_0_8 // Video decoder interface. // @@ -139,14 +139,11 @@ struct PPB_VideoDecoder_Dev { // // Parameters: // |video_decoder| is the previously created handle to the decoder resource. - // |context| the GL context in which decoding will happen. This should be a - // resource of type PPB_Context3D_Dev. // |decoder_config| the configuration to use to initialize the decoder. // |callback| called after initialization is complete. // // Returns an error code from pp_errors.h. int32_t (*Initialize)(PP_Resource video_decoder, - PP_Resource context, const PP_VideoConfigElement* decoder_config, struct PP_CompletionCallback callback); diff --git a/ppapi/c/dev/ppp_video_decoder_dev.h b/ppapi/c/dev/ppp_video_decoder_dev.h index e18146d..af5eaaf 100644 --- a/ppapi/c/dev/ppp_video_decoder_dev.h +++ b/ppapi/c/dev/ppp_video_decoder_dev.h @@ -5,11 +5,9 @@ #ifndef PPAPI_C_DEV_PPP_VIDEO_DECODER_DEV_H_ #define PPAPI_C_DEV_PPP_VIDEO_DECODER_DEV_H_ -#include "ppapi/c/pp_instance.h" -#include "ppapi/c/pp_resource.h" #include "ppapi/c/dev/pp_video_dev.h" -#define PPP_VIDEODECODER_DEV_INTERFACE "PPP_VideoDecoder(Dev);0.4" +#define PPP_VIDEODECODER_DEV_INTERFACE "PPP_VideoDecoder(Dev);0.3" // PPP_VideoDecoder_Dev structure contains the function pointers that the // plugin MUST implement to provide services needed by the video decoder @@ -23,13 +21,11 @@ struct PPP_VideoDecoder_Dev { // Decoding will not proceed until buffers have been provided. // // Parameters: - // |instance| the plugin instance to which the callback is responding. - // |decoder| is pointer to the Pepper Video Decoder resource. + // |decoder| is pointer to the Pepper Video Decoder instance. // |req_num_of_bufs| tells how many buffers are needed by the decoder. // |dimensions| tells the dimensions of the buffer to allocate. // |type| specifies whether the buffer lives in system memory or GL texture. void (*ProvidePictureBuffers)( - PP_Instance instance, PP_Resource decoder, uint32_t req_num_of_bufs, struct PP_Size dimensions, @@ -39,11 +35,9 @@ struct PPP_VideoDecoder_Dev { // the plugin. // // Parameters: - // |instance| the plugin instance to which the callback is responding. - // |decoder| is pointer to the Pepper Video Decoder resource. + // |decoder| is pointer to the Pepper Video Decoder instance. // |picture_buffer| points to the picture buffer that is no longer needed. - void (*DismissPictureBuffer)(PP_Instance instance, - PP_Resource decoder, + void (*DismissPictureBuffer)(PP_Resource decoder, int32_t picture_buffer_id); // Callback function for decoder to deliver decoded pictures ready to be @@ -51,11 +45,9 @@ struct PPP_VideoDecoder_Dev { // decoder through ReusePictureBuffer function in PPB Video Decoder API. // // Parameters: - // |instance| the plugin instance to which the callback is responding. - // |decoder| is pointer to the Pepper Video Decoder resource. + // |decoder| is pointer to the Pepper Video Decoder instance. // |picture| is the picture that is ready. - void (*PictureReady)(PP_Instance instance, - PP_Resource decoder, + void (*PictureReady)(PP_Resource decoder, struct PP_Picture_Dev picture); // Callback function to tell the plugin that decoder has decoded end of stream @@ -63,9 +55,8 @@ struct PPP_VideoDecoder_Dev { // stream. // // Parameters: - // |instance| the plugin instance to which the callback is responding. - // |decoder| is pointer to the Pepper Video Decoder resource. - void (*EndOfStream)(PP_Instance instance, PP_Resource decoder); + // |decoder| is pointer to the Pepper Video Decoder instance. + void (*EndOfStream)(PP_Resource decoder); // Error handler callback for decoder to deliver information about detected // errors to the plugin. @@ -73,12 +64,9 @@ struct PPP_VideoDecoder_Dev { // TODO(vmr): Fill out error result codes and corresponding actions. // // Parameters: - // |instance| the plugin instance to which the callback is responding. - // |decoder| is pointer to the Pepper Video Decoder resource. + // |decoder| is pointer to the Pepper Video Decoder instance. // |error| error is the enumeration specifying the error. - void (*NotifyError)(PP_Instance instance, - PP_Resource decoder, - enum PP_VideoDecodeError_Dev error); + void (*NotifyError)(PP_Resource decoder, enum PP_VideoDecodeError_Dev error); }; #endif /* PPAPI_C_DEV_PPP_VIDEO_DECODER_DEV_H_ */ diff --git a/ppapi/cpp/dev/video_decoder_client_dev.cc b/ppapi/cpp/dev/video_decoder_client_dev.cc deleted file mode 100644 index aa00c6f..0000000 --- a/ppapi/cpp/dev/video_decoder_client_dev.cc +++ /dev/null @@ -1,98 +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 "ppapi/cpp/dev/video_decoder_client_dev.h" - -#include "ppapi/c/dev/ppp_video_decoder_dev.h" -#include "ppapi/cpp/dev/video_decoder_dev.h" -#include "ppapi/cpp/instance.h" -#include "ppapi/cpp/module.h" -#include "ppapi/cpp/module_impl.h" - -namespace pp { - -namespace { - -const char kPPPVideoDecoderInterface[] = PPP_VIDEODECODER_DEV_INTERFACE; - -// Callback to provide buffers for the decoded output pictures. -void ProvidePictureBuffers(PP_Instance instance, - PP_Resource decoder_id, - uint32_t req_num_of_bufs, - struct PP_Size dimensions, - enum PP_PictureBufferType_Dev type) { - void* object = pp::Instance::GetPerInstanceObject( - instance, kPPPVideoDecoderInterface); - if (!object) - return; - static_cast(object)->ProvidePictureBuffers( - VideoDecoder_Dev(decoder_id), req_num_of_bufs, dimensions, type); -} - -void DismissPictureBuffer(PP_Instance instance, - PP_Resource decoder_id, - int32_t picture_buffer_id) { - void* object = pp::Instance::GetPerInstanceObject( - instance, kPPPVideoDecoderInterface); - if (!object) - return; - static_cast(object)->DismissPictureBuffer( - VideoDecoder_Dev(decoder_id), picture_buffer_id); -} - -void PictureReady(PP_Instance instance, - PP_Resource decoder_id, - PP_Picture_Dev picture) { - void* object = pp::Instance::GetPerInstanceObject( - instance, kPPPVideoDecoderInterface); - if (!object) - return; - static_cast(object)->PictureReady( - VideoDecoder_Dev(decoder_id), picture); -} - -void EndOfStream(PP_Instance instance, PP_Resource decoder_id) { - void* object = pp::Instance::GetPerInstanceObject( - instance, kPPPVideoDecoderInterface); - if (!object) - return; - static_cast(object)->EndOfStream( - VideoDecoder_Dev(decoder_id)); -} - -void NotifyError(PP_Instance instance, - PP_Resource decoder_id, - PP_VideoDecodeError_Dev error) { - void* object = pp::Instance::GetPerInstanceObject( - instance, kPPPVideoDecoderInterface); - if (!object) - return; - static_cast(object)->NotifyError( - VideoDecoder_Dev(decoder_id), error); -} - -static PPP_VideoDecoder_Dev videodecoder_interface = { - &ProvidePictureBuffers, - &DismissPictureBuffer, - &PictureReady, - &EndOfStream, - &NotifyError, -}; - -} // namespace - -VideoDecoderClient_Dev::VideoDecoderClient_Dev(Instance* instance) - : associated_instance_(instance) { - pp::Module::Get()->AddPluginInterface(kPPPVideoDecoderInterface, - &videodecoder_interface); - associated_instance_->AddPerInstanceObject( - kPPPVideoDecoderInterface, this); -} - -VideoDecoderClient_Dev::~VideoDecoderClient_Dev() { - associated_instance_->RemovePerInstanceObject( - kPPPVideoDecoderInterface, this); -} - -} // namespace pp diff --git a/ppapi/cpp/dev/video_decoder_client_dev.h b/ppapi/cpp/dev/video_decoder_client_dev.h deleted file mode 100644 index 776d54b..0000000 --- a/ppapi/cpp/dev/video_decoder_client_dev.h +++ /dev/null @@ -1,57 +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 PPAPI_CPP_DEV_VIDEO_DECODER_CLIENT_DEV_H_ -#define PPAPI_CPP_DEV_VIDEO_DECODER_CLIENT_DEV_H_ - -#include "ppapi/c/pp_stdint.h" -#include "ppapi/c/dev/pp_video_dev.h" - -namespace pp { - -class Instance; -class VideoDecoder_Dev; - -// This class provides a C++ interface for callbacks related to video decoding. -// It is the C++ counterpart to PPP_VideoDecoder_Dev. -// You would normally use multiple inheritance to derive from this class in your -// instance. -class VideoDecoderClient_Dev { - public: - VideoDecoderClient_Dev(Instance* instance); - virtual ~VideoDecoderClient_Dev(); - - // Callback to provide buffers for the decoded output pictures. - virtual void ProvidePictureBuffers( - VideoDecoder_Dev decoder, - uint32_t req_num_of_bufs, - struct PP_Size dimensions, - enum PP_PictureBufferType_Dev type) = 0; - - // Callback for decoder to delivered unneeded picture buffers back to the - // plugin. - virtual void DismissPictureBuffer( - VideoDecoder_Dev decoder, - int32_t picture_buffer_id) = 0; - - // Callback to deliver decoded pictures ready to be displayed. - virtual void PictureReady( - VideoDecoder_Dev decoder, - const PP_Picture_Dev& picture) = 0; - - // Callback to notify that decoder has decoded end of stream marker and has - // outputted all displayable pictures. - virtual void EndOfStream(VideoDecoder_Dev decoder) = 0; - - // Callback to notify about decoding errors. - virtual void NotifyError( - VideoDecoder_Dev decoder, PP_VideoDecodeError_Dev error) = 0; - - private: - Instance* associated_instance_; -}; - -} // namespace pp - -#endif // PPAPI_CPP_DEV_VIDEO_DECODER_CLIENT_DEV_H_ diff --git a/ppapi/cpp/dev/video_decoder_dev.cc b/ppapi/cpp/dev/video_decoder_dev.cc index c8d6ff4..b1ebcfb 100644 --- a/ppapi/cpp/dev/video_decoder_dev.cc +++ b/ppapi/cpp/dev/video_decoder_dev.cc @@ -8,7 +8,6 @@ #include "ppapi/c/dev/ppp_video_decoder_dev.h" #include "ppapi/c/pp_errors.h" #include "ppapi/cpp/common.h" -#include "ppapi/cpp/dev/context_3d_dev.h" #include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/module_impl.h" @@ -23,41 +22,37 @@ template <> const char* interface_name() { } // namespace -VideoDecoder_Dev::VideoDecoder_Dev(const Instance& instance) { +VideoDecoder::VideoDecoder(const Instance* instance, Client* client) + : client_(client) { if (!has_interface()) return; PassRefFromConstructor(get_interface()->Create( - instance.pp_instance())); + instance->pp_instance())); } -VideoDecoder_Dev::VideoDecoder_Dev(PP_Resource resource) : Resource(resource) { -} - -VideoDecoder_Dev::~VideoDecoder_Dev() {} +VideoDecoder::~VideoDecoder() {} -int32_t VideoDecoder_Dev::Initialize(const PP_VideoConfigElement* config, - const Context3D_Dev& context, - CompletionCallback callback) { +int32_t VideoDecoder::Initialize(const PP_VideoConfigElement* config, + CompletionCallback callback) { if (!has_interface()) return PP_ERROR_NOINTERFACE; return get_interface()->Initialize( - pp_resource(), context.pp_resource(), config, - callback.pp_completion_callback()); + pp_resource(), config, callback.pp_completion_callback()); } -bool VideoDecoder_Dev::GetConfigs(Instance* instance, - const PP_VideoConfigElement* prototype_config, - PP_VideoConfigElement* matching_configs, - uint32_t matching_configs_size, - uint32_t* num_of_matching_configs) { +bool VideoDecoder::GetConfigs(Instance* instance, + const PP_VideoConfigElement* prototype_config, + PP_VideoConfigElement* matching_configs, + uint32_t matching_configs_size, + uint32_t* num_of_matching_configs) { if (!has_interface()) return false; return PPBoolToBool(get_interface()->GetConfigs( - instance->pp_instance(), prototype_config, matching_configs, - matching_configs_size, num_of_matching_configs)); + instance->pp_instance(), prototype_config, matching_configs, + matching_configs_size, num_of_matching_configs)); } -void VideoDecoder_Dev::AssignGLESBuffers( +void VideoDecoder::AssignGLESBuffers( const std::vector& buffers) { if (!has_interface() || !pp_resource()) return; @@ -65,7 +60,7 @@ void VideoDecoder_Dev::AssignGLESBuffers( pp_resource(), buffers.size(), &buffers[0]); } -void VideoDecoder_Dev::AssignSysmemBuffers( +void VideoDecoder::AssignSysmemBuffers( const std::vector& buffers) { if (!has_interface() || !pp_resource()) return; @@ -73,7 +68,7 @@ void VideoDecoder_Dev::AssignSysmemBuffers( pp_resource(), buffers.size(), &buffers[0]); } -int32_t VideoDecoder_Dev::Decode( +int32_t VideoDecoder::Decode( const PP_VideoBitstreamBuffer_Dev& bitstream_buffer, CompletionCallback callback) { if (!has_interface()) @@ -84,14 +79,14 @@ int32_t VideoDecoder_Dev::Decode( pp_resource(), &bitstream_buffer, callback.pp_completion_callback()); } -void VideoDecoder_Dev::ReusePictureBuffer(int32_t picture_buffer_id) { +void VideoDecoder::ReusePictureBuffer(int32_t picture_buffer_id) { if (!has_interface() || !pp_resource()) return; get_interface()->ReusePictureBuffer( pp_resource(), picture_buffer_id); } -int32_t VideoDecoder_Dev::Flush(CompletionCallback callback) { +int32_t VideoDecoder::Flush(CompletionCallback callback) { if (!has_interface()) return PP_ERROR_NOINTERFACE; if (!pp_resource()) @@ -100,7 +95,7 @@ int32_t VideoDecoder_Dev::Flush(CompletionCallback callback) { pp_resource(), callback.pp_completion_callback()); } -int32_t VideoDecoder_Dev::Abort(CompletionCallback callback) { +int32_t VideoDecoder::Abort(CompletionCallback callback) { if (!has_interface()) return PP_ERROR_NOINTERFACE; if (!pp_resource()) diff --git a/ppapi/cpp/dev/video_decoder_dev.h b/ppapi/cpp/dev/video_decoder_dev.h index 326604f..e6558b1 100644 --- a/ppapi/cpp/dev/video_decoder_dev.h +++ b/ppapi/cpp/dev/video_decoder_dev.h @@ -14,33 +14,59 @@ namespace pp { -class Context3D_Dev; class Instance; // C++ wrapper for the Pepper Video Decoder interface. For more detailed -// documentation refer to the C interfaces. +// documentation refer to PPB_VideoDecoder_Dev and PPP_VideoDecoder_Dev +// interfaces. // // C++ version of the PPB_VideoDecoder_Dev interface. -class VideoDecoder_Dev : public Resource { +class VideoDecoder : public Resource { public: + // C++ version of PPP_VideoDecoder_Dev interface. + class Client { + public: + virtual ~Client(); + + // Callback to provide buffers for the decoded output pictures. + virtual void ProvidePictureBuffers( + uint32_t req_num_of_bufs, + struct PP_Size dimensions, + enum PP_PictureBufferType_Dev type); + + // Callback for decoder to delivered unneeded picture buffers back to the + // plugin. + virtual void DismissPictureBuffer(int32_t picture_buffer_id) = 0; + + // Callback to deliver decoded pictures ready to be displayed. + virtual void PictureReady(const PP_Picture_Dev& picture) = 0; + + // Callback to notify that decoder has decoded end of stream marker and has + // outputted all displayable pictures. + virtual void EndOfStream() = 0; + + // Callback to notify about decoding errors. + virtual void NotifyError(PP_VideoDecodeError_Dev error) = 0; + }; + // Constructor for the video decoder. Calls the Create on the // PPB_VideoDecoder_Dev interface. // // Parameters: // |instance| is the pointer to the plug-in instance. - explicit VideoDecoder_Dev(const Instance& instance); - explicit VideoDecoder_Dev(PP_Resource resource); - virtual ~VideoDecoder_Dev(); + // |callback| will be called when decoder is initialized. + // |client| is the pointer to the client object. Ownership of the object is + // not transferred and it must outlive the lifetime of this class. + VideoDecoder(const Instance* instance, Client* client); + ~VideoDecoder(); // Initializates the video decoder with a requested configuration. // Calls Init() on PPB_VideoDecoder_Dev interface. // // Parameters: // |config| is the configuration on which the decoder should be initialized. - // |context| GL context in which video decoder decodes frames. // |callback| will be called when decoder is initialized. int32_t Initialize(const PP_VideoConfigElement* config, - const Context3D_Dev& context, CompletionCallback callback); // GetConfigs returns supported configurations that are subsets of given @@ -72,6 +98,15 @@ class VideoDecoder_Dev : public Resource { // Dispatches abortion request to the decoder to abort decoding as soon as // possible. |callback| will be called as soon as abortion has been finished. int32_t Abort(CompletionCallback callback); + + private: + // Pointer to the plugin's video decoder support interface for providing the + // buffers for video decoding. + Client* client_; + + // Suppress compiler-generated copy constructors. + VideoDecoder(const VideoDecoder&); + void operator=(const VideoDecoder&); }; } // namespace pp diff --git a/ppapi/ppapi_cpp.gypi b/ppapi/ppapi_cpp.gypi index 9933d7c..74dc1f6 100644 --- a/ppapi/ppapi_cpp.gypi +++ b/ppapi/ppapi_cpp.gypi @@ -201,8 +201,6 @@ 'cpp/dev/surface_3d_dev.h', 'cpp/dev/url_util_dev.cc', 'cpp/dev/url_util_dev.h', - 'cpp/dev/video_decoder_client_dev.cc', - 'cpp/dev/video_decoder_client_dev.h', 'cpp/dev/video_decoder_dev.cc', 'cpp/dev/video_decoder_dev.h', 'cpp/dev/widget_client_dev.cc', diff --git a/ppapi/tests/test_video_decoder.cc b/ppapi/tests/test_video_decoder.cc index f4f2678..82f99c7 100644 --- a/ppapi/tests/test_video_decoder.cc +++ b/ppapi/tests/test_video_decoder.cc @@ -35,7 +35,7 @@ std::string TestVideoDecoder::TestCreateAndInitialize() { return "Create: error creating the decoder"; int32_t pp_error = video_decoder_interface_->Initialize( - decoder, 0, NULL, PP_BlockUntilComplete()); + decoder, NULL, PP_BlockUntilComplete()); pp::Module::Get()->core()->ReleaseResource(decoder); if (pp_error != PP_ERROR_BADARGUMENT) return "Initialize: error detecting null callback"; diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.cc b/webkit/plugins/ppapi/mock_plugin_delegate.cc index 476d4c9..9905791 100644 --- a/webkit/plugins/ppapi/mock_plugin_delegate.cc +++ b/webkit/plugins/ppapi/mock_plugin_delegate.cc @@ -45,8 +45,7 @@ MockPluginDelegate::PlatformContext3D* MockPluginDelegate::CreateContext3D() { MockPluginDelegate::PlatformVideoDecoder* MockPluginDelegate::CreateVideoDecoder( - media::VideoDecodeAccelerator::Client* client, - int command_buffer_route_id) { + media::VideoDecodeAccelerator::Client* client) { return NULL; } diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.h b/webkit/plugins/ppapi/mock_plugin_delegate.h index 0b91348..940dece 100644 --- a/webkit/plugins/ppapi/mock_plugin_delegate.h +++ b/webkit/plugins/ppapi/mock_plugin_delegate.h @@ -23,8 +23,7 @@ class MockPluginDelegate : public PluginDelegate { virtual PlatformImage2D* CreateImage2D(int width, int height); virtual PlatformContext3D* CreateContext3D(); virtual PlatformVideoDecoder* CreateVideoDecoder( - media::VideoDecodeAccelerator::Client* client, - int command_buffer_route_id); + media::VideoDecodeAccelerator::Client* client); virtual PlatformAudio* CreateAudio(uint32_t sample_rate, uint32_t sample_count, PlatformAudio::Client* client); diff --git a/webkit/plugins/ppapi/plugin_delegate.h b/webkit/plugins/ppapi/plugin_delegate.h index c72eaaa..931a39d 100644 --- a/webkit/plugins/ppapi/plugin_delegate.h +++ b/webkit/plugins/ppapi/plugin_delegate.h @@ -174,10 +174,6 @@ class PluginDelegate { // destroyed. virtual ::gpu::CommandBuffer* GetCommandBuffer() = 0; - // If the command buffer is routed in the GPU channel, return the route id. - // Otherwise return 0. - virtual int GetCommandBufferRouteId() = 0; - // Set an optional callback that will be invoked when the context is lost // (e.g. gpu process crash). Takes ownership of the callback. virtual void SetContextLostCallback(Callback0::Type* callback) = 0; @@ -262,8 +258,7 @@ class PluginDelegate { // The caller will own the pointer returned from this. virtual PlatformVideoDecoder* CreateVideoDecoder( - media::VideoDecodeAccelerator::Client* client, - int command_buffer_route_id) = 0; + media::VideoDecodeAccelerator::Client* client) = 0; // The caller is responsible for calling Shutdown() on the returned pointer // to clean up the corresponding resources allocated during this call. diff --git a/webkit/plugins/ppapi/ppb_video_decoder_impl.cc b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc index 47777c4..5fd318a 100644 --- a/webkit/plugins/ppapi/ppb_video_decoder_impl.cc +++ b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc @@ -7,7 +7,6 @@ #include #include "base/logging.h" -#include "base/message_loop.h" #include "media/video/picture.h" #include "ppapi/c/dev/pp_video_dev.h" #include "ppapi/c/dev/ppb_video_decoder_dev.h" @@ -19,7 +18,6 @@ #include "webkit/plugins/ppapi/plugin_module.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" #include "webkit/plugins/ppapi/ppb_buffer_impl.h" -#include "webkit/plugins/ppapi/ppb_context_3d_impl.h" #include "webkit/plugins/ppapi/resource_tracker.h" #include "webkit/plugins/ppapi/var.h" @@ -56,7 +54,6 @@ PP_Resource Create(PP_Instance instance_id) { } int32_t Initialize(PP_Resource video_decoder, - PP_Resource context_id, const PP_VideoConfigElement* decoder_config, struct PP_CompletionCallback callback) { scoped_refptr decoder( @@ -64,7 +61,7 @@ int32_t Initialize(PP_Resource video_decoder, if (!decoder) return PP_ERROR_BADRESOURCE; - return decoder->Initialize(context_id, decoder_config, callback); + return decoder->Initialize(decoder_config, callback); } PP_Bool IsVideoDecoder(PP_Resource resource) { @@ -223,29 +220,15 @@ bool PPB_VideoDecoder_Impl::GetConfigs( } int32_t PPB_VideoDecoder_Impl::Initialize( - PP_Resource context_id, const PP_VideoConfigElement* decoder_config, PP_CompletionCallback callback) { if (!callback.func) return PP_ERROR_BADARGUMENT; - if (!instance()) return PP_ERROR_FAILED; - scoped_refptr context3d = - webkit::ppapi::Resource::GetAs( - context_id); - if (!context3d) - return PP_ERROR_BADRESOURCE; - - int command_buffer_route_id = - context3d->platform_context()->GetCommandBufferRouteId(); - if (command_buffer_route_id == 0) - return PP_ERROR_FAILED; - platform_video_decoder_.reset( - instance()->delegate()->CreateVideoDecoder( - this, command_buffer_route_id)); + instance()->delegate()->CreateVideoDecoder(this)); if (!platform_video_decoder_.get()) return PP_ERROR_FAILED; @@ -365,8 +348,7 @@ void PPB_VideoDecoder_Impl::ProvidePictureBuffers( PP_Size out_dim = PP_MakeSize(dimensions.width(), dimensions.height()); ScopedResourceId resource(this); ppp_videodecoder_->ProvidePictureBuffers( - instance()->pp_instance(), resource.id, requested_num_of_buffers, - out_dim, out_type); + resource.id, requested_num_of_buffers, out_dim, out_type); } void PPB_VideoDecoder_Impl::PictureReady(const media::Picture& picture) { @@ -376,8 +358,7 @@ void PPB_VideoDecoder_Impl::PictureReady(const media::Picture& picture) { ScopedResourceId resource(this); PP_Picture_Dev out_pic; CopyToPictureDev(picture, &out_pic); - ppp_videodecoder_->PictureReady( - instance()->pp_instance(), resource.id, out_pic); + ppp_videodecoder_->PictureReady(resource.id, out_pic); } void PPB_VideoDecoder_Impl::DismissPictureBuffer(int32 picture_buffer_id) { @@ -385,8 +366,7 @@ void PPB_VideoDecoder_Impl::DismissPictureBuffer(int32 picture_buffer_id) { return; ScopedResourceId resource(this); - ppp_videodecoder_->DismissPictureBuffer( - instance()->pp_instance(), resource.id, picture_buffer_id); + ppp_videodecoder_->DismissPictureBuffer(resource.id, picture_buffer_id); } void PPB_VideoDecoder_Impl::NotifyEndOfStream() { @@ -394,7 +374,7 @@ void PPB_VideoDecoder_Impl::NotifyEndOfStream() { return; ScopedResourceId resource(this); - ppp_videodecoder_->EndOfStream(instance()->pp_instance(), resource.id); + ppp_videodecoder_->EndOfStream(resource.id); } void PPB_VideoDecoder_Impl::NotifyError( @@ -407,7 +387,7 @@ void PPB_VideoDecoder_Impl::NotifyError( // PP_VideoDecodeError_Dev have identical enum values. There is no compiler // assert to guarantee this. We either need to add such asserts or // merge these two enums. - ppp_videodecoder_->NotifyError(instance()->pp_instance(), resource.id, + ppp_videodecoder_->NotifyError(resource.id, static_cast(error)); } @@ -449,17 +429,18 @@ void PPB_VideoDecoder_Impl::NotifyInitializeDone() { // These functions are declared in picture.h but are defined here because of // dependencies (we can't depend on ppapi types from media). -// TODO(fischman/vrk): Find a way to clean this up as it violates the spirit of -// checkdeps. namespace media { BaseBuffer::BaseBuffer(const PP_BufferInfo_Dev& info) : id_(info.id), size_(info.size.width, info.size.height) { } +// TODO(vrk): This assigns the PP_Resource context to be +// the context_id. Not sure what it's actually supposed to be. GLESBuffer::GLESBuffer(const PP_GLESBuffer_Dev& buffer) : BaseBuffer(buffer.info), - texture_id_(buffer.texture_id) { + texture_id_(buffer.texture_id), + context_id_(buffer.context) { } SysmemBuffer::SysmemBuffer(const PP_SysmemBuffer_Dev& buffer) diff --git a/webkit/plugins/ppapi/ppb_video_decoder_impl.h b/webkit/plugins/ppapi/ppb_video_decoder_impl.h index 7af31a0..f67aa83 100644 --- a/webkit/plugins/ppapi/ppb_video_decoder_impl.h +++ b/webkit/plugins/ppapi/ppb_video_decoder_impl.h @@ -46,8 +46,7 @@ class PPB_VideoDecoder_Impl : public Resource, PP_VideoConfigElement* matching_configs, uint32_t matching_configs_size, uint32_t* num_of_matching_configs); - int32_t Initialize(PP_Resource context_id, - const PP_VideoConfigElement* dec_config, + int32_t Initialize(const PP_VideoConfigElement* dec_config, PP_CompletionCallback callback); int32_t Decode(const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, PP_CompletionCallback callback); -- cgit v1.1