Chromium Code Reviews| 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 WEBKIT_PLUGINS_PPAPI_PPB_VIDEO_DECODER_IMPL_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_VIDEO_DECODER_IMPL_H_ |
| 6 #define WEBKIT_PLUGINS_PPAPI_PPB_VIDEO_DECODER_IMPL_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_PPB_VIDEO_DECODER_IMPL_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 | 31 |
| 32 namespace webkit { | 32 namespace webkit { |
| 33 namespace ppapi { | 33 namespace ppapi { |
| 34 | 34 |
| 35 class PluginInstance; | 35 class PluginInstance; |
| 36 | 36 |
| 37 class PPB_VideoDecoder_Impl : public Resource, | 37 class PPB_VideoDecoder_Impl : public Resource, |
| 38 public ::ppapi::thunk::PPB_VideoDecoder_API, | 38 public ::ppapi::thunk::PPB_VideoDecoder_API, |
| 39 public media::VideoDecodeAccelerator::Client { | 39 public media::VideoDecodeAccelerator::Client { |
| 40 public: | 40 public: |
| 41 explicit PPB_VideoDecoder_Impl(PluginInstance* instance); | |
| 42 virtual ~PPB_VideoDecoder_Impl(); | 41 virtual ~PPB_VideoDecoder_Impl(); |
| 42 static PP_Resource Create(PluginInstance* instance, | |
|
vrk (LEFT CHROMIUM)
2011/07/29 18:11:02
comment? Perhaps mention that it returns 0 if it f
Ami GONE FROM CHROMIUM
2011/07/29 18:20:41
Done.
| |
| 43 PP_Resource context3d_id, | |
| 44 const PP_VideoConfigElement* config); | |
| 43 | 45 |
| 44 // ResourceObjectBase overrides. | 46 // ResourceObjectBase overrides. |
| 45 virtual PPB_VideoDecoder_API* AsPPB_VideoDecoder_API() OVERRIDE; | 47 virtual PPB_VideoDecoder_API* AsPPB_VideoDecoder_API() OVERRIDE; |
| 46 | 48 |
| 47 // PPB_VideoDecoder_API implementation. | 49 // PPB_VideoDecoder_API implementation. |
| 48 virtual int32_t Initialize(PP_Resource context_id, | |
| 49 const PP_VideoConfigElement* dec_config, | |
| 50 PP_CompletionCallback callback) OVERRIDE; | |
| 51 virtual int32_t Decode(const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, | 50 virtual int32_t Decode(const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, |
| 52 PP_CompletionCallback callback) OVERRIDE; | 51 PP_CompletionCallback callback) OVERRIDE; |
| 53 virtual void AssignPictureBuffers( | 52 virtual void AssignPictureBuffers( |
| 54 uint32_t no_of_buffers, const PP_PictureBuffer_Dev* buffers) OVERRIDE; | 53 uint32_t no_of_buffers, const PP_PictureBuffer_Dev* buffers) OVERRIDE; |
| 55 virtual void ReusePictureBuffer(int32_t picture_buffer_id) OVERRIDE; | 54 virtual void ReusePictureBuffer(int32_t picture_buffer_id) OVERRIDE; |
| 56 virtual int32_t Flush(PP_CompletionCallback callback) OVERRIDE; | 55 virtual int32_t Flush(PP_CompletionCallback callback) OVERRIDE; |
| 57 virtual int32_t Reset(PP_CompletionCallback callback) OVERRIDE; | 56 virtual int32_t Reset(PP_CompletionCallback callback) OVERRIDE; |
| 58 virtual void Destroy() OVERRIDE; | 57 virtual void Destroy() OVERRIDE; |
| 59 | 58 |
| 60 // media::VideoDecodeAccelerator::Client implementation. | 59 // media::VideoDecodeAccelerator::Client implementation. |
| 61 virtual void ProvidePictureBuffers( | 60 virtual void ProvidePictureBuffers( |
| 62 uint32 requested_num_of_buffers, const gfx::Size& dimensions) OVERRIDE; | 61 uint32 requested_num_of_buffers, const gfx::Size& dimensions) OVERRIDE; |
| 63 virtual void DismissPictureBuffer(int32 picture_buffer_id) OVERRIDE; | 62 virtual void DismissPictureBuffer(int32 picture_buffer_id) OVERRIDE; |
| 64 virtual void PictureReady(const media::Picture& picture) OVERRIDE; | 63 virtual void PictureReady(const media::Picture& picture) OVERRIDE; |
| 65 virtual void NotifyInitializeDone() OVERRIDE; | 64 virtual void NotifyInitializeDone() OVERRIDE; |
| 66 virtual void NotifyEndOfStream() OVERRIDE; | 65 virtual void NotifyEndOfStream() OVERRIDE; |
| 67 virtual void NotifyError( | 66 virtual void NotifyError( |
| 68 media::VideoDecodeAccelerator::Error error) OVERRIDE; | 67 media::VideoDecodeAccelerator::Error error) OVERRIDE; |
| 69 virtual void NotifyFlushDone() OVERRIDE; | 68 virtual void NotifyFlushDone() OVERRIDE; |
| 70 virtual void NotifyEndOfBitstreamBuffer(int32 buffer_id) OVERRIDE; | 69 virtual void NotifyEndOfBitstreamBuffer(int32 buffer_id) OVERRIDE; |
| 71 virtual void NotifyResetDone() OVERRIDE; | 70 virtual void NotifyResetDone() OVERRIDE; |
| 72 | 71 |
| 73 private: | 72 private: |
| 74 // Key: bitstream_buffer_id, value: callback to run when bitstream decode is | 73 // Key: bitstream_buffer_id, value: callback to run when bitstream decode is |
| 75 // done. | 74 // done. |
| 76 typedef std::map<int32, PP_CompletionCallback> CallbackById; | 75 typedef std::map<int32, PP_CompletionCallback> CallbackById; |
| 77 | 76 |
| 77 explicit PPB_VideoDecoder_Impl(PluginInstance* instance); | |
| 78 | |
| 79 // Initialize the underlying decoder and return success status. | |
| 80 bool Init(PP_Resource context_id, const PP_VideoConfigElement* dec_config); | |
| 81 | |
| 78 // Tell command buffer to process all commands it has received so far. | 82 // Tell command buffer to process all commands it has received so far. |
| 79 void FlushCommandBuffer(); | 83 void FlushCommandBuffer(); |
| 80 | 84 |
| 81 // This is NULL before initialization, and if this PPB_VideoDecoder_Impl is | 85 // This is NULL before initialization, and if this PPB_VideoDecoder_Impl is |
| 82 // swapped with another. | 86 // swapped with another. |
| 83 scoped_refptr<PluginDelegate::PlatformVideoDecoder> platform_video_decoder_; | 87 scoped_refptr<PluginDelegate::PlatformVideoDecoder> platform_video_decoder_; |
| 84 | 88 |
| 85 // Factory to produce our callbacks. | 89 // Factory to produce our callbacks. |
| 86 base::ScopedCallbackFactory<PPB_VideoDecoder_Impl> callback_factory_; | 90 base::ScopedCallbackFactory<PPB_VideoDecoder_Impl> callback_factory_; |
| 87 | 91 |
| 88 // The resource ID of the underlying Context3d object being used. Used only | 92 // The resource ID of the underlying Context3d object being used. Used only |
| 89 // for reference counting to keep it alive for the lifetime of |*this|. | 93 // for reference counting to keep it alive for the lifetime of |*this|. |
| 90 PP_Resource context3d_id_; | 94 PP_Resource context3d_id_; |
| 91 | 95 |
| 92 PP_CompletionCallback initialization_callback_; | |
| 93 PP_CompletionCallback flush_callback_; | 96 PP_CompletionCallback flush_callback_; |
| 94 PP_CompletionCallback reset_callback_; | 97 PP_CompletionCallback reset_callback_; |
| 95 CallbackById bitstream_buffer_callbacks_; | 98 CallbackById bitstream_buffer_callbacks_; |
| 96 | 99 |
| 97 // Reference to the plugin requesting this interface. | 100 // Reference to the plugin requesting this interface. |
| 98 const PPP_VideoDecoder_Dev* ppp_videodecoder_; | 101 const PPP_VideoDecoder_Dev* ppp_videodecoder_; |
| 99 | 102 |
| 100 // Reference to the GLES2Implementation owned by PPB_Context3D_Impl. | 103 // Reference to the GLES2Implementation owned by PPB_Context3D_Impl. |
| 101 // PPB_Context3D_Impl is guaranteed to be alive for the lifetime of this | 104 // PPB_Context3D_Impl is guaranteed to be alive for the lifetime of this |
| 102 // class. | 105 // class. |
| 103 // In the out-of-process case, Context3D's gles2_impl() exists in the plugin | 106 // In the out-of-process case, Context3D's gles2_impl() exists in the plugin |
| 104 // process only, so gles2_impl_ is NULL in that case. | 107 // process only, so gles2_impl_ is NULL in that case. |
| 105 gpu::gles2::GLES2Implementation* gles2_impl_; | 108 gpu::gles2::GLES2Implementation* gles2_impl_; |
| 106 | 109 |
| 107 DISALLOW_COPY_AND_ASSIGN(PPB_VideoDecoder_Impl); | 110 DISALLOW_COPY_AND_ASSIGN(PPB_VideoDecoder_Impl); |
| 108 }; | 111 }; |
| 109 | 112 |
| 110 } // namespace ppapi | 113 } // namespace ppapi |
| 111 } // namespace webkit | 114 } // namespace webkit |
| 112 | 115 |
| 113 #endif // WEBKIT_PLUGINS_PPAPI_PPB_VIDEO_DECODER_IMPL_H_ | 116 #endif // WEBKIT_PLUGINS_PPAPI_PPB_VIDEO_DECODER_IMPL_H_ |
| OLD | NEW |