Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(363)

Side by Side Diff: webkit/plugins/ppapi/ppb_video_decoder_impl.cc

Issue 10749019: VideoDecodeAccelerator now SupportsWeakPtr instead of being RefCountedThreadSafe. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/plugins/ppapi/ppb_video_decoder_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "webkit/plugins/ppapi/ppb_video_decoder_impl.h" 5 #include "webkit/plugins/ppapi/ppb_video_decoder_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 InitCommon(graphics_context, gles2_impl); 109 InitCommon(graphics_context, gles2_impl);
110 110
111 int command_buffer_route_id = context->GetCommandBufferRouteId(); 111 int command_buffer_route_id = context->GetCommandBufferRouteId();
112 if (command_buffer_route_id == 0) 112 if (command_buffer_route_id == 0)
113 return false; 113 return false;
114 114
115 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); 115 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this);
116 if (!plugin_delegate) 116 if (!plugin_delegate)
117 return false; 117 return false;
118 118
119 platform_video_decoder_ = plugin_delegate->CreateVideoDecoder( 119 platform_video_decoder_.reset(plugin_delegate->CreateVideoDecoder(
120 this, command_buffer_route_id); 120 this, command_buffer_route_id));
121 if (!platform_video_decoder_) 121 if (!platform_video_decoder_.get())
122 return false; 122 return false;
123 123
124 FlushCommandBuffer(); 124 FlushCommandBuffer();
125 return platform_video_decoder_->Initialize(PPToMediaProfile(profile)); 125 return platform_video_decoder_->Initialize(PPToMediaProfile(profile));
126 } 126 }
127 127
128 int32_t PPB_VideoDecoder_Impl::Decode( 128 int32_t PPB_VideoDecoder_Impl::Decode(
129 const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, 129 const PP_VideoBitstreamBuffer_Dev* bitstream_buffer,
130 scoped_refptr<TrackedCallback> callback) { 130 scoped_refptr<TrackedCallback> callback) {
131 if (!platform_video_decoder_) 131 if (!platform_video_decoder_.get())
132 return PP_ERROR_BADRESOURCE; 132 return PP_ERROR_BADRESOURCE;
133 133
134 EnterResourceNoLock<PPB_Buffer_API> enter(bitstream_buffer->data, true); 134 EnterResourceNoLock<PPB_Buffer_API> enter(bitstream_buffer->data, true);
135 if (enter.failed()) 135 if (enter.failed())
136 return PP_ERROR_FAILED; 136 return PP_ERROR_FAILED;
137 137
138 PPB_Buffer_Impl* buffer = static_cast<PPB_Buffer_Impl*>(enter.object()); 138 PPB_Buffer_Impl* buffer = static_cast<PPB_Buffer_Impl*>(enter.object());
139 media::BitstreamBuffer decode_buffer( 139 media::BitstreamBuffer decode_buffer(
140 bitstream_buffer->id, 140 bitstream_buffer->id,
141 buffer->shared_memory()->handle(), 141 buffer->shared_memory()->handle(),
142 static_cast<size_t>(bitstream_buffer->size)); 142 static_cast<size_t>(bitstream_buffer->size));
143 if (!SetBitstreamBufferCallback(bitstream_buffer->id, callback)) 143 if (!SetBitstreamBufferCallback(bitstream_buffer->id, callback))
144 return PP_ERROR_BADARGUMENT; 144 return PP_ERROR_BADARGUMENT;
145 145
146 FlushCommandBuffer(); 146 FlushCommandBuffer();
147 platform_video_decoder_->Decode(decode_buffer); 147 platform_video_decoder_->Decode(decode_buffer);
148 return PP_OK_COMPLETIONPENDING; 148 return PP_OK_COMPLETIONPENDING;
149 } 149 }
150 150
151 void PPB_VideoDecoder_Impl::AssignPictureBuffers( 151 void PPB_VideoDecoder_Impl::AssignPictureBuffers(
152 uint32_t no_of_buffers, 152 uint32_t no_of_buffers,
153 const PP_PictureBuffer_Dev* buffers) { 153 const PP_PictureBuffer_Dev* buffers) {
154 if (!platform_video_decoder_) 154 if (!platform_video_decoder_.get())
155 return; 155 return;
156 156
157 std::vector<media::PictureBuffer> wrapped_buffers; 157 std::vector<media::PictureBuffer> wrapped_buffers;
158 for (uint32 i = 0; i < no_of_buffers; i++) { 158 for (uint32 i = 0; i < no_of_buffers; i++) {
159 PP_PictureBuffer_Dev in_buf = buffers[i]; 159 PP_PictureBuffer_Dev in_buf = buffers[i];
160 media::PictureBuffer buffer( 160 media::PictureBuffer buffer(
161 in_buf.id, 161 in_buf.id,
162 gfx::Size(in_buf.size.width, in_buf.size.height), 162 gfx::Size(in_buf.size.width, in_buf.size.height),
163 in_buf.texture_id); 163 in_buf.texture_id);
164 wrapped_buffers.push_back(buffer); 164 wrapped_buffers.push_back(buffer);
165 } 165 }
166 166
167 FlushCommandBuffer(); 167 FlushCommandBuffer();
168 platform_video_decoder_->AssignPictureBuffers(wrapped_buffers); 168 platform_video_decoder_->AssignPictureBuffers(wrapped_buffers);
169 } 169 }
170 170
171 void PPB_VideoDecoder_Impl::ReusePictureBuffer(int32_t picture_buffer_id) { 171 void PPB_VideoDecoder_Impl::ReusePictureBuffer(int32_t picture_buffer_id) {
172 if (!platform_video_decoder_) 172 if (!platform_video_decoder_.get())
173 return; 173 return;
174 174
175 FlushCommandBuffer(); 175 FlushCommandBuffer();
176 platform_video_decoder_->ReusePictureBuffer(picture_buffer_id); 176 platform_video_decoder_->ReusePictureBuffer(picture_buffer_id);
177 } 177 }
178 178
179 int32_t PPB_VideoDecoder_Impl::Flush(scoped_refptr<TrackedCallback> callback) { 179 int32_t PPB_VideoDecoder_Impl::Flush(scoped_refptr<TrackedCallback> callback) {
180 if (!platform_video_decoder_) 180 if (!platform_video_decoder_.get())
181 return PP_ERROR_BADRESOURCE; 181 return PP_ERROR_BADRESOURCE;
182 182
183 if (!SetFlushCallback(callback)) 183 if (!SetFlushCallback(callback))
184 return PP_ERROR_INPROGRESS; 184 return PP_ERROR_INPROGRESS;
185 185
186 FlushCommandBuffer(); 186 FlushCommandBuffer();
187 platform_video_decoder_->Flush(); 187 platform_video_decoder_->Flush();
188 return PP_OK_COMPLETIONPENDING; 188 return PP_OK_COMPLETIONPENDING;
189 } 189 }
190 190
191 int32_t PPB_VideoDecoder_Impl::Reset(scoped_refptr<TrackedCallback> callback) { 191 int32_t PPB_VideoDecoder_Impl::Reset(scoped_refptr<TrackedCallback> callback) {
192 if (!platform_video_decoder_) 192 if (!platform_video_decoder_.get())
193 return PP_ERROR_BADRESOURCE; 193 return PP_ERROR_BADRESOURCE;
194 194
195 if (!SetResetCallback(callback)) 195 if (!SetResetCallback(callback))
196 return PP_ERROR_INPROGRESS; 196 return PP_ERROR_INPROGRESS;
197 197
198 FlushCommandBuffer(); 198 FlushCommandBuffer();
199 platform_video_decoder_->Reset(); 199 platform_video_decoder_->Reset();
200 return PP_OK_COMPLETIONPENDING; 200 return PP_OK_COMPLETIONPENDING;
201 } 201 }
202 202
203 void PPB_VideoDecoder_Impl::Destroy() { 203 void PPB_VideoDecoder_Impl::Destroy() {
204 if (!platform_video_decoder_) 204 if (!platform_video_decoder_.get())
205 return; 205 return;
206 206
207 FlushCommandBuffer(); 207 FlushCommandBuffer();
208 platform_video_decoder_->Destroy(); 208 platform_video_decoder_.release()->Destroy();
209 ::ppapi::PPB_VideoDecoder_Shared::Destroy(); 209 ::ppapi::PPB_VideoDecoder_Shared::Destroy();
210 platform_video_decoder_ = NULL;
211 ppp_videodecoder_ = NULL; 210 ppp_videodecoder_ = NULL;
212 } 211 }
213 212
214 void PPB_VideoDecoder_Impl::ProvidePictureBuffers( 213 void PPB_VideoDecoder_Impl::ProvidePictureBuffers(
215 uint32 requested_num_of_buffers, 214 uint32 requested_num_of_buffers,
216 const gfx::Size& dimensions, 215 const gfx::Size& dimensions,
217 uint32 texture_target) { 216 uint32 texture_target) {
218 if (!ppp_videodecoder_) 217 if (!ppp_videodecoder_)
219 return; 218 return;
220 219
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 void PPB_VideoDecoder_Impl::NotifyFlushDone() { 264 void PPB_VideoDecoder_Impl::NotifyFlushDone() {
266 RunFlushCallback(PP_OK); 265 RunFlushCallback(PP_OK);
267 } 266 }
268 267
269 void PPB_VideoDecoder_Impl::NotifyInitializeDone() { 268 void PPB_VideoDecoder_Impl::NotifyInitializeDone() {
270 NOTREACHED() << "PlatformVideoDecoder::Initialize() is synchronous!"; 269 NOTREACHED() << "PlatformVideoDecoder::Initialize() is synchronous!";
271 } 270 }
272 271
273 } // namespace ppapi 272 } // namespace ppapi
274 } // namespace webkit 273 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppb_video_decoder_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698