| 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" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/scoped_callback_factory.h" | 12 #include "base/memory/scoped_callback_factory.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "ppapi/c/dev/pp_video_dev.h" | 14 #include "ppapi/c/dev/pp_video_dev.h" |
| 15 #include "ppapi/c/pp_var.h" | 15 #include "ppapi/c/pp_var.h" |
| 16 #include "ppapi/shared_impl/video_decoder_impl.h" |
| 16 #include "ppapi/thunk/ppb_video_decoder_api.h" | 17 #include "ppapi/thunk/ppb_video_decoder_api.h" |
| 17 #include "webkit/plugins/ppapi/plugin_delegate.h" | 18 #include "webkit/plugins/ppapi/plugin_delegate.h" |
| 18 #include "webkit/plugins/ppapi/resource.h" | 19 #include "webkit/plugins/ppapi/resource.h" |
| 19 | 20 |
| 20 struct PP_PictureBuffer_Dev; | 21 struct PP_PictureBuffer_Dev; |
| 21 struct PP_VideoDecoderConfig_Dev; | 22 struct PP_VideoDecoderConfig_Dev; |
| 22 struct PP_VideoBitstreamBuffer_Dev; | 23 struct PP_VideoBitstreamBuffer_Dev; |
| 23 struct PPB_VideoDecoder_Dev; | 24 struct PPB_VideoDecoder_Dev; |
| 24 struct PPP_VideoDecoder_Dev; | 25 struct PPP_VideoDecoder_Dev; |
| 25 | 26 |
| 26 namespace gpu { | 27 namespace gpu { |
| 27 namespace gles2 { | 28 namespace gles2 { |
| 28 class GLES2Implementation; | 29 class GLES2Implementation; |
| 29 } | 30 } |
| 30 } | 31 } |
| 31 | 32 |
| 32 namespace webkit { | 33 namespace webkit { |
| 33 namespace ppapi { | 34 namespace ppapi { |
| 34 | 35 |
| 35 class PluginInstance; | 36 class PluginInstance; |
| 36 | 37 |
| 37 class PPB_VideoDecoder_Impl : public Resource, | 38 class PPB_VideoDecoder_Impl : public Resource, |
| 38 public ::ppapi::thunk::PPB_VideoDecoder_API, | 39 public ::ppapi::VideoDecoderImpl, |
| 39 public media::VideoDecodeAccelerator::Client { | 40 public media::VideoDecodeAccelerator::Client { |
| 40 public: | 41 public: |
| 41 virtual ~PPB_VideoDecoder_Impl(); | 42 virtual ~PPB_VideoDecoder_Impl(); |
| 42 // See PPB_VideoDecoder_Dev::Create. Returns 0 on failure to create & | 43 // See PPB_VideoDecoder_Dev::Create. Returns 0 on failure to create & |
| 43 // initialize. | 44 // initialize. |
| 44 static PP_Resource Create(PluginInstance* instance, | 45 static PP_Resource Create(PluginInstance* instance, |
| 45 PP_Resource context3d_id, | 46 PP_Resource context3d_id, |
| 46 const PP_VideoConfigElement* config); | 47 const PP_VideoConfigElement* config); |
| 47 | 48 |
| 48 // ResourceObjectBase overrides. | 49 // ResourceObjectBase overrides. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 64 virtual void DismissPictureBuffer(int32 picture_buffer_id) OVERRIDE; | 65 virtual void DismissPictureBuffer(int32 picture_buffer_id) OVERRIDE; |
| 65 virtual void PictureReady(const media::Picture& picture) OVERRIDE; | 66 virtual void PictureReady(const media::Picture& picture) OVERRIDE; |
| 66 virtual void NotifyInitializeDone() OVERRIDE; | 67 virtual void NotifyInitializeDone() OVERRIDE; |
| 67 virtual void NotifyEndOfStream() OVERRIDE; | 68 virtual void NotifyEndOfStream() OVERRIDE; |
| 68 virtual void NotifyError( | 69 virtual void NotifyError( |
| 69 media::VideoDecodeAccelerator::Error error) OVERRIDE; | 70 media::VideoDecodeAccelerator::Error error) OVERRIDE; |
| 70 virtual void NotifyFlushDone() OVERRIDE; | 71 virtual void NotifyFlushDone() OVERRIDE; |
| 71 virtual void NotifyEndOfBitstreamBuffer(int32 buffer_id) OVERRIDE; | 72 virtual void NotifyEndOfBitstreamBuffer(int32 buffer_id) OVERRIDE; |
| 72 virtual void NotifyResetDone() OVERRIDE; | 73 virtual void NotifyResetDone() OVERRIDE; |
| 73 | 74 |
| 75 // Initialize the underlying decoder and return success status. |
| 76 virtual bool Init(PP_Resource context_id, |
| 77 const PP_VideoConfigElement* dec_config); |
| 78 |
| 74 private: | 79 private: |
| 75 // Key: bitstream_buffer_id, value: callback to run when bitstream decode is | |
| 76 // done. | |
| 77 typedef std::map<int32, PP_CompletionCallback> CallbackById; | |
| 78 | |
| 79 explicit PPB_VideoDecoder_Impl(PluginInstance* instance); | 80 explicit PPB_VideoDecoder_Impl(PluginInstance* instance); |
| 80 | 81 |
| 81 // Initialize the underlying decoder and return success status. | |
| 82 bool Init(PP_Resource context_id, const PP_VideoConfigElement* dec_config); | |
| 83 | |
| 84 // Tell command buffer to process all commands it has received so far. | |
| 85 void FlushCommandBuffer(); | |
| 86 | |
| 87 // This is NULL before initialization, and if this PPB_VideoDecoder_Impl is | 82 // This is NULL before initialization, and if this PPB_VideoDecoder_Impl is |
| 88 // swapped with another. | 83 // swapped with another. |
| 89 scoped_refptr<PluginDelegate::PlatformVideoDecoder> platform_video_decoder_; | 84 scoped_refptr<PluginDelegate::PlatformVideoDecoder> platform_video_decoder_; |
| 90 | 85 |
| 91 // Factory to produce our callbacks. | |
| 92 base::ScopedCallbackFactory<PPB_VideoDecoder_Impl> callback_factory_; | |
| 93 | |
| 94 // The resource ID of the underlying Context3d object being used. Used only | |
| 95 // for reference counting to keep it alive for the lifetime of |*this|. | |
| 96 PP_Resource context3d_id_; | |
| 97 | |
| 98 PP_CompletionCallback flush_callback_; | |
| 99 PP_CompletionCallback reset_callback_; | |
| 100 CallbackById bitstream_buffer_callbacks_; | |
| 101 | |
| 102 // Reference to the plugin requesting this interface. | 86 // Reference to the plugin requesting this interface. |
| 103 const PPP_VideoDecoder_Dev* ppp_videodecoder_; | 87 const PPP_VideoDecoder_Dev* ppp_videodecoder_; |
| 104 | 88 |
| 105 // Reference to the GLES2Implementation owned by PPB_Context3D_Impl. | |
| 106 // PPB_Context3D_Impl is guaranteed to be alive for the lifetime of this | |
| 107 // class. | |
| 108 // In the out-of-process case, Context3D's gles2_impl() exists in the plugin | |
| 109 // process only, so gles2_impl_ is NULL in that case. | |
| 110 gpu::gles2::GLES2Implementation* gles2_impl_; | |
| 111 | |
| 112 DISALLOW_COPY_AND_ASSIGN(PPB_VideoDecoder_Impl); | 89 DISALLOW_COPY_AND_ASSIGN(PPB_VideoDecoder_Impl); |
| 113 }; | 90 }; |
| 114 | 91 |
| 115 } // namespace ppapi | 92 } // namespace ppapi |
| 116 } // namespace webkit | 93 } // namespace webkit |
| 117 | 94 |
| 118 #endif // WEBKIT_PLUGINS_PPAPI_PPB_VIDEO_DECODER_IMPL_H_ | 95 #endif // WEBKIT_PLUGINS_PPAPI_PPB_VIDEO_DECODER_IMPL_H_ |
| OLD | NEW |