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 | |
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 VideoDecoderImpl : public ResourceObjectBase, | |
28 public thunk::PPB_VideoDecoder_API { | |
29 public: | |
30 VideoDecoderImpl(bool in_renderer_process); | |
31 virtual ~VideoDecoderImpl(); | |
32 | |
33 // ResourceObjectBase implementation. | |
34 virtual PPB_VideoDecoder_API* AsPPB_VideoDecoder_API() OVERRIDE; | |
35 | |
36 // PPB_VideoDecoder_API implementation. | |
37 virtual void Destroy() OVERRIDE; | |
38 | |
39 void SetFlushCallback(PP_CompletionCallback callback); | |
Ami GONE FROM CHROMIUM
2011/08/02 00:49:08
Can these all be protected instead of public?
vrk (LEFT CHROMIUM)
2011/08/03 19:04:30
Yes, for everything but CopyConfigsToVector. Done.
| |
40 void SetResetCallback(PP_CompletionCallback callback); | |
41 void AddBitstreamBufferCallback( | |
Ami GONE FROM CHROMIUM
2011/08/02 00:49:08
Since the id is unique, I think Set is better than
vrk (LEFT CHROMIUM)
2011/08/03 19:04:30
Done.
| |
42 int32 bitstream_buffer_id, PP_CompletionCallback callback); | |
43 | |
44 void RunFlushCallback(); | |
45 void RunResetCallback(); | |
46 void RunBitstreamBufferCallback(int32 bitstream_buffer_id); | |
47 | |
48 // Tell command buffer to process all commands it has received so far. | |
49 void FlushCommandBuffer(); | |
50 | |
51 // Initialize the underlying decoder and return success status. | |
52 virtual bool Init(PP_Resource context_id, | |
53 const PP_VideoConfigElement* dec_config); | |
54 | |
55 // Copy C-style config list into |out_configs| vector. | |
56 static bool CopyConfigsToVector(const PP_VideoConfigElement* configs_to_copy, | |
57 std::vector<int32>* out_configs); | |
58 | |
59 private: | |
60 void SetGLES2Impl(gpu::gles2::GLES2Implementation* gles2_impl); | |
61 void AddRefResource(PP_Resource resource); | |
62 void UnrefResource(PP_Resource resource); | |
63 | |
64 // Key: bitstream_buffer_id, value: callback to run when bitstream decode is | |
65 // done. | |
66 typedef std::map<int32, PP_CompletionCallback> CallbackById; | |
67 | |
68 PP_CompletionCallback flush_callback_; | |
69 PP_CompletionCallback reset_callback_; | |
70 CallbackById bitstream_buffer_callbacks_; | |
71 | |
72 // The resource ID of the underlying Context3d object being used. Used only | |
73 // for reference counting to keep it alive for the lifetime of |*this|. | |
74 PP_Resource context3d_id_; | |
75 | |
76 // True if object is created in renderer process, false if it lives in the | |
77 // plugin process. | |
78 bool in_renderer_process_; | |
79 | |
80 // Reference to the GLES2Implementation owned by |context3d_id_|. | |
81 // Context3D is guaranteed to be alive for the lifetime of this class. | |
82 // In the out-of-process case, Context3D's gles2_impl() exists in the plugin | |
83 // process only, so gles2_impl_ is NULL in that case. | |
84 gpu::gles2::GLES2Implementation* gles2_impl_; | |
85 | |
86 DISALLOW_COPY_AND_ASSIGN(VideoDecoderImpl); | |
87 }; | |
88 | |
89 } // namespace ppapi | |
90 | |
91 #endif // PPAPI_SHARED_IMPL_VIDEO_DECODER_IMPL_H_ | |
OLD | NEW |