OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef PPAPI_SHARED_IMPL_VIDEO_DECODER_IMPL_H_ |
| 6 #define PPAPI_SHARED_IMPL_VIDEO_DECODER_IMPL_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" |
| 13 #include "ppapi/c/dev/ppb_video_decoder_dev.h" |
| 14 #include "ppapi/shared_impl/resource_object_base.h" |
| 15 #include "ppapi/thunk/ppb_video_decoder_api.h" |
| 16 |
| 17 namespace gpu { |
| 18 namespace gles2 { |
| 19 class GLES2Implementation; |
| 20 } // namespace gles2 |
| 21 } // namespace gpu |
| 22 |
| 23 namespace ppapi { |
| 24 namespace thunk { |
| 25 class PPB_Context3D_API; |
| 26 } // namespace thunk |
| 27 } // namespace ppapi |
| 28 |
| 29 namespace ppapi { |
| 30 |
| 31 // Implements the logic to set and run callbacks for various video decoder |
| 32 // events. Both the proxy and the renderer implementation share this code. |
| 33 class VideoDecoderImpl : public ResourceObjectBase, |
| 34 public thunk::PPB_VideoDecoder_API { |
| 35 public: |
| 36 VideoDecoderImpl(); |
| 37 virtual ~VideoDecoderImpl(); |
| 38 |
| 39 // ResourceObjectBase implementation. |
| 40 virtual PPB_VideoDecoder_API* AsPPB_VideoDecoder_API() OVERRIDE; |
| 41 |
| 42 // PPB_VideoDecoder_API implementation. |
| 43 virtual void Destroy() OVERRIDE; |
| 44 |
| 45 // Copy C-style config list into |out_configs| vector. |
| 46 static bool CopyConfigsToVector( |
| 47 const PP_VideoConfigElement* configs_to_copy, |
| 48 std::vector<PP_VideoConfigElement>* out_configs); |
| 49 |
| 50 protected: |
| 51 void SetFlushCallback(PP_CompletionCallback callback); |
| 52 void SetResetCallback(PP_CompletionCallback callback); |
| 53 void SetBitstreamBufferCallback( |
| 54 int32 bitstream_buffer_id, PP_CompletionCallback callback); |
| 55 |
| 56 void RunFlushCallback(int32 result); |
| 57 void RunResetCallback(int32 result); |
| 58 void RunBitstreamBufferCallback(int32 bitstream_buffer_id, int32 result); |
| 59 |
| 60 // Tell command buffer to process all commands it has received so far. |
| 61 void FlushCommandBuffer(); |
| 62 |
| 63 // Initialize the underlying decoder and return success status. |
| 64 virtual bool Init(PP_Resource context3d_id, |
| 65 thunk::PPB_Context3D_API* context, |
| 66 const PP_VideoConfigElement* dec_config); |
| 67 |
| 68 // TODO(fischman/vrk): Remove accordingly when brettw has merged resource |
| 69 // trackers. |
| 70 virtual void AddRefResource(PP_Resource resource) = 0; |
| 71 virtual void UnrefResource(PP_Resource resource) = 0; |
| 72 |
| 73 private: |
| 74 // Key: bitstream_buffer_id, value: callback to run when bitstream decode is |
| 75 // done. |
| 76 typedef std::map<int32, PP_CompletionCallback> CallbackById; |
| 77 |
| 78 PP_CompletionCallback flush_callback_; |
| 79 PP_CompletionCallback reset_callback_; |
| 80 CallbackById bitstream_buffer_callbacks_; |
| 81 |
| 82 // The resource ID of the underlying Context3d object being used. Used only |
| 83 // for reference counting to keep it alive for the lifetime of |*this|. |
| 84 PP_Resource context3d_id_; |
| 85 |
| 86 // Reference to the GLES2Implementation owned by |context3d_id_|. |
| 87 // Context3D is guaranteed to be alive for the lifetime of this class. |
| 88 // In the out-of-process case, Context3D's gles2_impl() exists in the plugin |
| 89 // process only, so gles2_impl_ is NULL in that case. |
| 90 gpu::gles2::GLES2Implementation* gles2_impl_; |
| 91 |
| 92 DISALLOW_COPY_AND_ASSIGN(VideoDecoderImpl); |
| 93 }; |
| 94 |
| 95 } // namespace ppapi |
| 96 |
| 97 #endif // PPAPI_SHARED_IMPL_VIDEO_DECODER_IMPL_H_ |
OLD | NEW |