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" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 PP_Bool allow_software_fallback, | 49 PP_Bool allow_software_fallback, |
50 scoped_refptr<TrackedCallback> callback) override; | 50 scoped_refptr<TrackedCallback> callback) override; |
51 virtual int32_t Initialize(PP_Resource graphics_context, | 51 virtual int32_t Initialize(PP_Resource graphics_context, |
52 PP_VideoProfile profile, | 52 PP_VideoProfile profile, |
53 PP_HardwareAcceleration acceleration, | 53 PP_HardwareAcceleration acceleration, |
54 scoped_refptr<TrackedCallback> callback) override; | 54 scoped_refptr<TrackedCallback> callback) override; |
55 virtual int32_t Decode(uint32_t decode_id, | 55 virtual int32_t Decode(uint32_t decode_id, |
56 uint32_t size, | 56 uint32_t size, |
57 const void* buffer, | 57 const void* buffer, |
58 scoped_refptr<TrackedCallback> callback) override; | 58 scoped_refptr<TrackedCallback> callback) override; |
| 59 virtual int32_t GetPicture0_1( |
| 60 PP_VideoPicture_0_1* picture, |
| 61 scoped_refptr<TrackedCallback> callback) override; |
59 virtual int32_t GetPicture(PP_VideoPicture* picture, | 62 virtual int32_t GetPicture(PP_VideoPicture* picture, |
60 scoped_refptr<TrackedCallback> callback) override; | 63 scoped_refptr<TrackedCallback> callback) override; |
61 virtual void RecyclePicture(const PP_VideoPicture* picture) override; | 64 virtual void RecyclePicture(const PP_VideoPicture* picture) override; |
62 virtual int32_t Flush(scoped_refptr<TrackedCallback> callback) override; | 65 virtual int32_t Flush(scoped_refptr<TrackedCallback> callback) override; |
63 virtual int32_t Reset(scoped_refptr<TrackedCallback> callback) override; | 66 virtual int32_t Reset(scoped_refptr<TrackedCallback> callback) override; |
64 | 67 |
65 // PluginResource implementation. | 68 // PluginResource implementation. |
66 virtual void OnReplyReceived(const ResourceMessageReplyParams& params, | 69 virtual void OnReplyReceived(const ResourceMessageReplyParams& params, |
67 const IPC::Message& msg) override; | 70 const IPC::Message& msg) override; |
68 | 71 |
(...skipping 20 matching lines...) Expand all Loading... |
89 struct Texture { | 92 struct Texture { |
90 Texture(uint32_t texture_target, const PP_Size& size); | 93 Texture(uint32_t texture_target, const PP_Size& size); |
91 ~Texture(); | 94 ~Texture(); |
92 | 95 |
93 const uint32_t texture_target; | 96 const uint32_t texture_target; |
94 const PP_Size size; | 97 const PP_Size size; |
95 }; | 98 }; |
96 | 99 |
97 // Struct to hold a picture received from the decoder. | 100 // Struct to hold a picture received from the decoder. |
98 struct Picture { | 101 struct Picture { |
99 Picture(int32_t decode_id, uint32_t texture_id); | 102 Picture(int32_t decode_id, |
| 103 uint32_t texture_id, |
| 104 const PP_Rect& visible_rect); |
100 ~Picture(); | 105 ~Picture(); |
101 | 106 |
102 int32_t decode_id; | 107 int32_t decode_id; |
103 uint32_t texture_id; | 108 uint32_t texture_id; |
| 109 PP_Rect visible_rect; |
104 }; | 110 }; |
105 | 111 |
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. | 112 // Unsolicited reply message handlers. |
113 void OnPluginMsgRequestTextures(const ResourceMessageReplyParams& params, | 113 void OnPluginMsgRequestTextures(const ResourceMessageReplyParams& params, |
114 uint32_t num_textures, | 114 uint32_t num_textures, |
115 const PP_Size& size, | 115 const PP_Size& size, |
116 uint32_t texture_target, | 116 uint32_t texture_target, |
117 const std::vector<gpu::Mailbox>& mailboxes); | 117 const std::vector<gpu::Mailbox>& mailboxes); |
118 void OnPluginMsgPictureReady(const ResourceMessageReplyParams& params, | 118 void OnPluginMsgPictureReady(const ResourceMessageReplyParams& params, |
119 int32_t decode_id, | 119 int32_t decode_id, |
120 uint32_t texture_id); | 120 uint32_t texture_id, |
| 121 const PP_Rect& visible_rect); |
121 void OnPluginMsgDismissPicture(const ResourceMessageReplyParams& params, | 122 void OnPluginMsgDismissPicture(const ResourceMessageReplyParams& params, |
122 uint32_t texture_id); | 123 uint32_t texture_id); |
123 void OnPluginMsgNotifyError(const ResourceMessageReplyParams& params, | 124 void OnPluginMsgNotifyError(const ResourceMessageReplyParams& params, |
124 int32_t error); | 125 int32_t error); |
125 | 126 |
126 // Reply message handlers for operations that are done in the host. | 127 // Reply message handlers for operations that are done in the host. |
127 void OnPluginMsgInitializeComplete(const ResourceMessageReplyParams& params); | 128 void OnPluginMsgInitializeComplete(const ResourceMessageReplyParams& params); |
128 void OnPluginMsgDecodeComplete(const ResourceMessageReplyParams& params, | 129 void OnPluginMsgDecodeComplete(const ResourceMessageReplyParams& params, |
129 uint32_t shm_id); | 130 uint32_t shm_id); |
130 void OnPluginMsgFlushComplete(const ResourceMessageReplyParams& params); | 131 void OnPluginMsgFlushComplete(const ResourceMessageReplyParams& params); |
131 void OnPluginMsgResetComplete(const ResourceMessageReplyParams& params); | 132 void OnPluginMsgResetComplete(const ResourceMessageReplyParams& params); |
132 | 133 |
133 void RunCallbackWithError(scoped_refptr<TrackedCallback>* callback); | 134 void RunCallbackWithError(scoped_refptr<TrackedCallback>* callback); |
134 void DeleteGLTexture(uint32_t texture_id); | 135 void DeleteGLTexture(uint32_t texture_id); |
135 void WriteNextPicture(PP_VideoPicture* picture); | 136 void WriteNextPicture(); |
136 | 137 |
137 // ScopedVector to own the shared memory buffers. | 138 // ScopedVector to own the shared memory buffers. |
138 ScopedVector<ShmBuffer> shm_buffers_; | 139 ScopedVector<ShmBuffer> shm_buffers_; |
139 | 140 |
140 // List of available shared memory buffers. | 141 // List of available shared memory buffers. |
141 typedef std::vector<ShmBuffer*> ShmBufferList; | 142 typedef std::vector<ShmBuffer*> ShmBufferList; |
142 ShmBufferList available_shm_buffers_; | 143 ShmBufferList available_shm_buffers_; |
143 | 144 |
144 // Map of GL texture id to texture info. | 145 // Map of GL texture id to texture info. |
145 typedef base::hash_map<uint32_t, Texture> TextureMap; | 146 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 | 163 // 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. | 164 // 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 | 165 // 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. | 166 // 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. | 167 // NOTE: because we count decodes mod 2^31, this value must be a power of 2. |
167 static const int kMaximumPictureDelay = 128; | 168 static const int kMaximumPictureDelay = 128; |
168 uint32_t decode_ids_[kMaximumPictureDelay]; | 169 uint32_t decode_ids_[kMaximumPictureDelay]; |
169 | 170 |
170 // State for pending get_picture_callback_. | 171 // State for pending get_picture_callback_. |
171 PP_VideoPicture* get_picture_; | 172 PP_VideoPicture* get_picture_; |
| 173 PP_VideoPicture_0_1* get_picture_0_1_; |
172 | 174 |
173 ScopedPPResource graphics3d_; | 175 ScopedPPResource graphics3d_; |
174 gpu::gles2::GLES2Implementation* gles2_impl_; | 176 gpu::gles2::GLES2Implementation* gles2_impl_; |
175 | 177 |
176 bool initialized_; | 178 bool initialized_; |
177 bool testing_; | 179 bool testing_; |
178 int32_t decoder_last_error_; | 180 int32_t decoder_last_error_; |
179 | 181 |
180 DISALLOW_COPY_AND_ASSIGN(VideoDecoderResource); | 182 DISALLOW_COPY_AND_ASSIGN(VideoDecoderResource); |
181 }; | 183 }; |
182 | 184 |
183 } // namespace proxy | 185 } // namespace proxy |
184 } // namespace ppapi | 186 } // namespace ppapi |
185 | 187 |
186 #endif // PPAPI_PROXY_VIDEO_DECODER_RESOURCE_H_ | 188 #endif // PPAPI_PROXY_VIDEO_DECODER_RESOURCE_H_ |
OLD | NEW |