OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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 PPAPI_PROXY_VIDEO_DECODER_RESOURCE_H_ | 5 #ifndef PPAPI_PROXY_VIDEO_DECODER_RESOURCE_H_ |
6 #define PPAPI_PROXY_VIDEO_DECODER_RESOURCE_H_ | 6 #define PPAPI_PROXY_VIDEO_DECODER_RESOURCE_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 | 9 |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
14 #include "ppapi/proxy/connection.h" | 14 #include "ppapi/proxy/connection.h" |
15 #include "ppapi/proxy/plugin_resource.h" | 15 #include "ppapi/proxy/plugin_resource.h" |
16 #include "ppapi/proxy/ppapi_proxy_export.h" | 16 #include "ppapi/proxy/ppapi_proxy_export.h" |
17 #include "ppapi/shared_impl/resource.h" | 17 #include "ppapi/shared_impl/resource.h" |
18 #include "ppapi/shared_impl/scoped_pp_resource.h" | 18 #include "ppapi/shared_impl/scoped_pp_resource.h" |
19 #include "ppapi/thunk/ppb_video_decoder_api.h" | 19 #include "ppapi/thunk/ppb_video_decoder_api.h" |
20 | 20 |
| 21 struct PP_Rect; |
| 22 |
21 namespace gpu { | 23 namespace gpu { |
22 struct Mailbox; | 24 struct Mailbox; |
23 namespace gles2 { | 25 namespace gles2 { |
24 class GLES2Implementation; | 26 class GLES2Implementation; |
25 } | 27 } |
26 } | 28 } |
27 | 29 |
28 namespace ppapi { | 30 namespace ppapi { |
29 | 31 |
30 class PPB_Graphics3D_Shared; | 32 class PPB_Graphics3D_Shared; |
(...skipping 18 matching lines...) Expand all Loading... |
49 PP_Bool allow_software_fallback, | 51 PP_Bool allow_software_fallback, |
50 scoped_refptr<TrackedCallback> callback) override; | 52 scoped_refptr<TrackedCallback> callback) override; |
51 virtual int32_t Initialize(PP_Resource graphics_context, | 53 virtual int32_t Initialize(PP_Resource graphics_context, |
52 PP_VideoProfile profile, | 54 PP_VideoProfile profile, |
53 PP_HardwareAcceleration acceleration, | 55 PP_HardwareAcceleration acceleration, |
54 scoped_refptr<TrackedCallback> callback) override; | 56 scoped_refptr<TrackedCallback> callback) override; |
55 virtual int32_t Decode(uint32_t decode_id, | 57 virtual int32_t Decode(uint32_t decode_id, |
56 uint32_t size, | 58 uint32_t size, |
57 const void* buffer, | 59 const void* buffer, |
58 scoped_refptr<TrackedCallback> callback) override; | 60 scoped_refptr<TrackedCallback> callback) override; |
| 61 virtual int32_t GetPicture0_1( |
| 62 PP_VideoPicture* picture, |
| 63 scoped_refptr<TrackedCallback> callback) override; |
59 virtual int32_t GetPicture(PP_VideoPicture* picture, | 64 virtual int32_t GetPicture(PP_VideoPicture* picture, |
| 65 PP_Rect* visible_rect, |
60 scoped_refptr<TrackedCallback> callback) override; | 66 scoped_refptr<TrackedCallback> callback) override; |
61 virtual void RecyclePicture(const PP_VideoPicture* picture) override; | 67 virtual void RecyclePicture(const PP_VideoPicture* picture) override; |
62 virtual int32_t Flush(scoped_refptr<TrackedCallback> callback) override; | 68 virtual int32_t Flush(scoped_refptr<TrackedCallback> callback) override; |
63 virtual int32_t Reset(scoped_refptr<TrackedCallback> callback) override; | 69 virtual int32_t Reset(scoped_refptr<TrackedCallback> callback) override; |
64 | 70 |
65 // PluginResource implementation. | 71 // PluginResource implementation. |
66 virtual void OnReplyReceived(const ResourceMessageReplyParams& params, | 72 virtual void OnReplyReceived(const ResourceMessageReplyParams& params, |
67 const IPC::Message& msg) override; | 73 const IPC::Message& msg) override; |
68 | 74 |
69 // Called only by unit tests. This bypasses Graphics3D setup, which doesn't | 75 // Called only by unit tests. This bypasses Graphics3D setup, which doesn't |
(...skipping 19 matching lines...) Expand all Loading... |
89 struct Texture { | 95 struct Texture { |
90 Texture(uint32_t texture_target, const PP_Size& size); | 96 Texture(uint32_t texture_target, const PP_Size& size); |
91 ~Texture(); | 97 ~Texture(); |
92 | 98 |
93 const uint32_t texture_target; | 99 const uint32_t texture_target; |
94 const PP_Size size; | 100 const PP_Size size; |
95 }; | 101 }; |
96 | 102 |
97 // Struct to hold a picture received from the decoder. | 103 // Struct to hold a picture received from the decoder. |
98 struct Picture { | 104 struct Picture { |
99 Picture(int32_t decode_id, uint32_t texture_id); | 105 Picture(int32_t decode_id, |
| 106 uint32_t texture_id, |
| 107 const PP_Rect& visible_rect); |
100 ~Picture(); | 108 ~Picture(); |
101 | 109 |
102 int32_t decode_id; | 110 int32_t decode_id; |
103 uint32_t texture_id; | 111 uint32_t texture_id; |
| 112 PP_Rect visible_rect; |
104 }; | 113 }; |
105 | 114 |
106 int32_t InitializeInternal(PP_Resource graphics_context, | |
107 PP_VideoProfile profile, | |
108 PP_Bool allow_software_fallback, | |
109 scoped_refptr<TrackedCallback> callback, | |
110 bool testing); | |
111 | |
112 // Unsolicited reply message handlers. | 115 // Unsolicited reply message handlers. |
113 void OnPluginMsgRequestTextures(const ResourceMessageReplyParams& params, | 116 void OnPluginMsgRequestTextures(const ResourceMessageReplyParams& params, |
114 uint32_t num_textures, | 117 uint32_t num_textures, |
115 const PP_Size& size, | 118 const PP_Size& size, |
116 uint32_t texture_target, | 119 uint32_t texture_target, |
117 const std::vector<gpu::Mailbox>& mailboxes); | 120 const std::vector<gpu::Mailbox>& mailboxes); |
118 void OnPluginMsgPictureReady(const ResourceMessageReplyParams& params, | 121 void OnPluginMsgPictureReady(const ResourceMessageReplyParams& params, |
119 int32_t decode_id, | 122 int32_t decode_id, |
120 uint32_t texture_id); | 123 uint32_t texture_id, |
| 124 const PP_Rect& visible_rect); |
121 void OnPluginMsgDismissPicture(const ResourceMessageReplyParams& params, | 125 void OnPluginMsgDismissPicture(const ResourceMessageReplyParams& params, |
122 uint32_t texture_id); | 126 uint32_t texture_id); |
123 void OnPluginMsgNotifyError(const ResourceMessageReplyParams& params, | 127 void OnPluginMsgNotifyError(const ResourceMessageReplyParams& params, |
124 int32_t error); | 128 int32_t error); |
125 | 129 |
126 // Reply message handlers for operations that are done in the host. | 130 // Reply message handlers for operations that are done in the host. |
127 void OnPluginMsgInitializeComplete(const ResourceMessageReplyParams& params); | 131 void OnPluginMsgInitializeComplete(const ResourceMessageReplyParams& params); |
128 void OnPluginMsgDecodeComplete(const ResourceMessageReplyParams& params, | 132 void OnPluginMsgDecodeComplete(const ResourceMessageReplyParams& params, |
129 uint32_t shm_id); | 133 uint32_t shm_id); |
130 void OnPluginMsgFlushComplete(const ResourceMessageReplyParams& params); | 134 void OnPluginMsgFlushComplete(const ResourceMessageReplyParams& params); |
131 void OnPluginMsgResetComplete(const ResourceMessageReplyParams& params); | 135 void OnPluginMsgResetComplete(const ResourceMessageReplyParams& params); |
132 | 136 |
133 void RunCallbackWithError(scoped_refptr<TrackedCallback>* callback); | 137 void RunCallbackWithError(scoped_refptr<TrackedCallback>* callback); |
134 void DeleteGLTexture(uint32_t texture_id); | 138 void DeleteGLTexture(uint32_t texture_id); |
135 void WriteNextPicture(PP_VideoPicture* picture); | 139 void WriteNextPicture(); |
136 | 140 |
137 // ScopedVector to own the shared memory buffers. | 141 // ScopedVector to own the shared memory buffers. |
138 ScopedVector<ShmBuffer> shm_buffers_; | 142 ScopedVector<ShmBuffer> shm_buffers_; |
139 | 143 |
140 // List of available shared memory buffers. | 144 // List of available shared memory buffers. |
141 typedef std::vector<ShmBuffer*> ShmBufferList; | 145 typedef std::vector<ShmBuffer*> ShmBufferList; |
142 ShmBufferList available_shm_buffers_; | 146 ShmBufferList available_shm_buffers_; |
143 | 147 |
144 // Map of GL texture id to texture info. | 148 // Map of GL texture id to texture info. |
145 typedef base::hash_map<uint32_t, Texture> TextureMap; | 149 typedef base::hash_map<uint32_t, Texture> TextureMap; |
(...skipping 16 matching lines...) Expand all Loading... |
162 // haven't received a picture from a Decode call after this many successive | 166 // haven't received a picture from a Decode call after this many successive |
163 // calls to Decode, then we will never receive a picture from the call. | 167 // calls to Decode, then we will never receive a picture from the call. |
164 // Note that this isn't guaranteed by H264 or other codecs. In practice, this | 168 // Note that this isn't guaranteed by H264 or other codecs. In practice, this |
165 // number is less than 16. Make it much larger just to be safe. | 169 // number is less than 16. Make it much larger just to be safe. |
166 // NOTE: because we count decodes mod 2^31, this value must be a power of 2. | 170 // NOTE: because we count decodes mod 2^31, this value must be a power of 2. |
167 static const int kMaximumPictureDelay = 128; | 171 static const int kMaximumPictureDelay = 128; |
168 uint32_t decode_ids_[kMaximumPictureDelay]; | 172 uint32_t decode_ids_[kMaximumPictureDelay]; |
169 | 173 |
170 // State for pending get_picture_callback_. | 174 // State for pending get_picture_callback_. |
171 PP_VideoPicture* get_picture_; | 175 PP_VideoPicture* get_picture_; |
| 176 PP_Rect* get_visible_rect_; |
172 | 177 |
173 ScopedPPResource graphics3d_; | 178 ScopedPPResource graphics3d_; |
174 gpu::gles2::GLES2Implementation* gles2_impl_; | 179 gpu::gles2::GLES2Implementation* gles2_impl_; |
175 | 180 |
176 bool initialized_; | 181 bool initialized_; |
177 bool testing_; | 182 bool testing_; |
178 int32_t decoder_last_error_; | 183 int32_t decoder_last_error_; |
179 | 184 |
180 DISALLOW_COPY_AND_ASSIGN(VideoDecoderResource); | 185 DISALLOW_COPY_AND_ASSIGN(VideoDecoderResource); |
181 }; | 186 }; |
182 | 187 |
183 } // namespace proxy | 188 } // namespace proxy |
184 } // namespace ppapi | 189 } // namespace ppapi |
185 | 190 |
186 #endif // PPAPI_PROXY_VIDEO_DECODER_RESOURCE_H_ | 191 #endif // PPAPI_PROXY_VIDEO_DECODER_RESOURCE_H_ |
OLD | NEW |