| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_PEPPER_PLATFORM_VIDEO_DECODER_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PLATFORM_VIDEO_DECODER_IMPL_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_PLATFORM_VIDEO_DECODER_IMPL_H_ | 6 #define CONTENT_RENDERER_PEPPER_PLATFORM_VIDEO_DECODER_IMPL_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "media/video/video_decode_accelerator.h" | 13 #include "media/video/video_decode_accelerator.h" |
| 14 #include "webkit/plugins/ppapi/plugin_delegate.h" | 14 #include "webkit/plugins/ppapi/plugin_delegate.h" |
| 15 | 15 |
| 16 class GpuChannelHost; | 16 class GpuChannelHost; |
| 17 namespace gpu { |
| 18 class CommandBufferHelper; |
| 19 } |
| 17 | 20 |
| 18 class PlatformVideoDecoderImpl | 21 class PlatformVideoDecoderImpl |
| 19 : public webkit::ppapi::PluginDelegate::PlatformVideoDecoder, | 22 : public webkit::ppapi::PluginDelegate::PlatformVideoDecoder, |
| 20 public media::VideoDecodeAccelerator::Client, | 23 public media::VideoDecodeAccelerator::Client, |
| 21 public base::RefCountedThreadSafe<PlatformVideoDecoderImpl> { | 24 public base::RefCountedThreadSafe<PlatformVideoDecoderImpl> { |
| 22 public: | 25 public: |
| 23 explicit PlatformVideoDecoderImpl( | 26 PlatformVideoDecoderImpl( |
| 24 media::VideoDecodeAccelerator::Client* client, | 27 media::VideoDecodeAccelerator::Client* client, |
| 25 uint32 command_buffer_route_id); | 28 int32 command_buffer_route_id, |
| 29 gpu::CommandBufferHelper* cmd_buffer_helper); |
| 26 virtual ~PlatformVideoDecoderImpl(); | 30 virtual ~PlatformVideoDecoderImpl(); |
| 27 | 31 |
| 28 // PlatformVideoDecoder implementation. | 32 // PlatformVideoDecoder implementation. |
| 29 virtual bool GetConfigs( | 33 virtual bool GetConfigs( |
| 30 const std::vector<uint32>& requested_configs, | 34 const std::vector<uint32>& requested_configs, |
| 31 std::vector<uint32>* matched_configs) OVERRIDE; | 35 std::vector<uint32>* matched_configs) OVERRIDE; |
| 32 virtual bool Initialize(const std::vector<uint32>& config) OVERRIDE; | 36 virtual bool Initialize(const std::vector<uint32>& config) OVERRIDE; |
| 33 virtual bool Decode( | 37 virtual void Decode( |
| 34 const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; | 38 const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; |
| 35 virtual void AssignGLESBuffers( | 39 virtual void AssignGLESBuffers( |
| 36 const std::vector<media::GLESBuffer>& buffers) OVERRIDE; | 40 const std::vector<media::GLESBuffer>& buffers) OVERRIDE; |
| 37 virtual void AssignSysmemBuffers( | 41 virtual void AssignSysmemBuffers( |
| 38 const std::vector<media::SysmemBuffer>& buffers) OVERRIDE; | 42 const std::vector<media::SysmemBuffer>& buffers) OVERRIDE; |
| 39 virtual void ReusePictureBuffer(int32 picture_buffer_id); | 43 virtual void ReusePictureBuffer(int32 picture_buffer_id); |
| 40 virtual bool Flush() OVERRIDE; | 44 virtual void Flush() OVERRIDE; |
| 41 virtual bool Abort() OVERRIDE; | 45 virtual void Abort() OVERRIDE; |
| 42 | 46 |
| 43 // VideoDecodeAccelerator::Client implementation. | 47 // VideoDecodeAccelerator::Client implementation. |
| 44 virtual void ProvidePictureBuffers( | 48 virtual void ProvidePictureBuffers( |
| 45 uint32 requested_num_of_buffers, | 49 uint32 requested_num_of_buffers, |
| 46 const gfx::Size& dimensions, | 50 const gfx::Size& dimensions, |
| 47 media::VideoDecodeAccelerator::MemoryType type) OVERRIDE; | 51 media::VideoDecodeAccelerator::MemoryType type) OVERRIDE; |
| 48 virtual void PictureReady(const media::Picture& picture) OVERRIDE; | 52 virtual void PictureReady(const media::Picture& picture) OVERRIDE; |
| 49 virtual void DismissPictureBuffer(int32 picture_buffer_id) OVERRIDE; | 53 virtual void DismissPictureBuffer(int32 picture_buffer_id) OVERRIDE; |
| 50 virtual void NotifyInitializeDone() OVERRIDE; | 54 virtual void NotifyInitializeDone() OVERRIDE; |
| 51 virtual void NotifyEndOfStream() OVERRIDE; | 55 virtual void NotifyEndOfStream() OVERRIDE; |
| 52 virtual void NotifyError( | 56 virtual void NotifyError( |
| 53 media::VideoDecodeAccelerator::Error error) OVERRIDE; | 57 media::VideoDecodeAccelerator::Error error) OVERRIDE; |
| 54 virtual void NotifyEndOfBitstreamBuffer(int32 bitstream_buffer_id) OVERRIDE; | 58 virtual void NotifyEndOfBitstreamBuffer(int32 bitstream_buffer_id) OVERRIDE; |
| 55 virtual void NotifyFlushDone() OVERRIDE; | 59 virtual void NotifyFlushDone() OVERRIDE; |
| 56 virtual void NotifyAbortDone() OVERRIDE; | 60 virtual void NotifyAbortDone() OVERRIDE; |
| 57 | 61 |
| 58 private: | 62 private: |
| 59 void InitializeDecoder(const std::vector<uint32>& configs); | 63 void InitializeDecoder(const std::vector<uint32>& configs); |
| 60 | 64 |
| 61 // Client lifetime must exceed lifetime of this class. | 65 // Client lifetime must exceed lifetime of this class. |
| 62 // TODO(vrk/fischman): We should take another look at the overall | 66 // TODO(vrk/fischman): We should take another look at the overall |
| 63 // arcitecture of PPAPI Video Decode to make sure lifetime/ownership makes | 67 // arcitecture of PPAPI Video Decode to make sure lifetime/ownership makes |
| 64 // sense, including lifetime of this client. | 68 // sense, including lifetime of this client. |
| 65 media::VideoDecodeAccelerator::Client* client_; | 69 media::VideoDecodeAccelerator::Client* client_; |
| 66 | 70 |
| 67 // Route ID for the command buffer associated with video decoder's context. | 71 // Route ID for the command buffer associated with video decoder's context. |
| 68 uint32 command_buffer_route_id_; | 72 int32 command_buffer_route_id_; |
| 73 |
| 74 // Helper for the command buffer associated with video decoder's context. |
| 75 gpu::CommandBufferHelper* cmd_buffer_helper_; |
| 69 | 76 |
| 70 // Host for GpuVideoDecodeAccelerator. | 77 // Host for GpuVideoDecodeAccelerator. |
| 71 scoped_ptr<media::VideoDecodeAccelerator> decoder_; | 78 scoped_ptr<media::VideoDecodeAccelerator> decoder_; |
| 72 | 79 |
| 73 // Host for Gpu Channel. | 80 // Host for Gpu Channel. |
| 74 scoped_refptr<GpuChannelHost> channel_; | 81 scoped_refptr<GpuChannelHost> channel_; |
| 75 | 82 |
| 76 // Message loop on which plugin is initialized. | |
| 77 MessageLoop* message_loop_; | |
| 78 | |
| 79 DISALLOW_COPY_AND_ASSIGN(PlatformVideoDecoderImpl); | 83 DISALLOW_COPY_AND_ASSIGN(PlatformVideoDecoderImpl); |
| 80 }; | 84 }; |
| 81 | 85 |
| 82 // PlatformVideoDecoderImpl must extend RefCountedThreadSafe in order to post | 86 // PlatformVideoDecoderImpl must extend RefCountedThreadSafe in order to post |
| 83 // tasks on the IO loop. However, it is not actually ref counted: | 87 // tasks on the IO loop. However, it is not actually ref counted: |
| 84 // PPB_VideoDecode_Impl is the only thing that holds reference to | 88 // PPB_VideoDecode_Impl is the only thing that holds reference to |
| 85 // PlatformVideoDecoderImpl, so ref counting is unnecessary. | 89 // PlatformVideoDecoderImpl, so ref counting is unnecessary. |
| 86 // | 90 // |
| 87 // TODO(vrk): Not sure if this is the right thing to do. Talk with fischman. | 91 // TODO(vrk): Not sure if this is the right thing to do. Talk with fischman. |
| 88 DISABLE_RUNNABLE_METHOD_REFCOUNT(PlatformVideoDecoderImpl); | 92 DISABLE_RUNNABLE_METHOD_REFCOUNT(PlatformVideoDecoderImpl); |
| 89 | 93 |
| 90 #endif // CONTENT_RENDERER_PEPPER_PLATFORM_VIDEO_DECODER_IMPL_H_ | 94 #endif // CONTENT_RENDERER_PEPPER_PLATFORM_VIDEO_DECODER_IMPL_H_ |
| OLD | NEW |