| 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.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 | |
| 25 // Implements the logic to set and run callbacks for various video decoder | |
| 26 // events. Both the proxy and the renderer implementation share this code. | |
| 27 class PPAPI_SHARED_EXPORT VideoDecoderImpl | |
| 28 : NON_EXPORTED_BASE(public thunk::PPB_VideoDecoder_API) { | |
| 29 public: | |
| 30 VideoDecoderImpl(); | |
| 31 virtual ~VideoDecoderImpl(); | |
| 32 | |
| 33 // PPB_VideoDecoder_API implementation. | |
| 34 virtual void Destroy() OVERRIDE; | |
| 35 | |
| 36 protected: | |
| 37 bool SetFlushCallback(PP_CompletionCallback callback); | |
| 38 bool SetResetCallback(PP_CompletionCallback callback); | |
| 39 bool SetBitstreamBufferCallback( | |
| 40 int32 bitstream_buffer_id, PP_CompletionCallback callback); | |
| 41 | |
| 42 void RunFlushCallback(int32 result); | |
| 43 void RunResetCallback(int32 result); | |
| 44 void RunBitstreamBufferCallback(int32 bitstream_buffer_id, int32 result); | |
| 45 | |
| 46 // Tell command buffer to process all commands it has received so far. | |
| 47 void FlushCommandBuffer(); | |
| 48 | |
| 49 // Initialize the underlying decoder. | |
| 50 void InitCommon(PP_Resource graphics_context, | |
| 51 gpu::gles2::GLES2Implementation* gles2_impl); | |
| 52 | |
| 53 private: | |
| 54 // Key: bitstream_buffer_id, value: callback to run when bitstream decode is | |
| 55 // done. | |
| 56 typedef std::map<int32, PP_CompletionCallback> CallbackById; | |
| 57 | |
| 58 PP_CompletionCallback flush_callback_; | |
| 59 PP_CompletionCallback reset_callback_; | |
| 60 CallbackById bitstream_buffer_callbacks_; | |
| 61 | |
| 62 // The resource ID of the underlying Graphics3D object being used. Used only | |
| 63 // for reference counting to keep it alive for the lifetime of |*this|. | |
| 64 PP_Resource graphics_context_; | |
| 65 | |
| 66 // Reference to the GLES2Implementation owned by |graphics_context_|. | |
| 67 // Graphics3D is guaranteed to be alive for the lifetime of this class. | |
| 68 // In the out-of-process case, Graphics3D's gles2_impl() exists in the plugin | |
| 69 // process only, so gles2_impl_ is NULL in that case. | |
| 70 gpu::gles2::GLES2Implementation* gles2_impl_; | |
| 71 | |
| 72 DISALLOW_COPY_AND_ASSIGN(VideoDecoderImpl); | |
| 73 }; | |
| 74 | |
| 75 } // namespace ppapi | |
| 76 | |
| 77 #endif // PPAPI_SHARED_IMPL_VIDEO_DECODER_IMPL_H_ | |
| OLD | NEW |