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

Side by Side Diff: chrome/renderer/pepper_plugin_delegate_impl.cc

Issue 3087009: add pepper video decoder glue and delegate (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: reload Created 10 years, 4 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/renderer/pepper_plugin_delegate_impl.h" 5 #include "chrome/renderer/pepper_plugin_delegate_impl.h"
6 6
7 #include "app/surface/transport_dib.h" 7 #include "app/surface/transport_dib.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "chrome/common/render_messages.h" 10 #include "chrome/common/render_messages.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // Make sure we don't call shutdown more than once. 150 // Make sure we don't call shutdown more than once.
151 if (!stream_id_) { 151 if (!stream_id_) {
152 return; 152 return;
153 } 153 }
154 filter_->Send(new ViewHostMsg_CloseAudioStream(0, stream_id_)); 154 filter_->Send(new ViewHostMsg_CloseAudioStream(0, stream_id_));
155 filter_->RemoveDelegate(stream_id_); 155 filter_->RemoveDelegate(stream_id_);
156 stream_id_ = 0; 156 stream_id_ = 0;
157 client_ = NULL; 157 client_ = NULL;
158 } 158 }
159 159
160 // Implements the VideoDecoder.
161 class PlatformVideoDecoderImpl
162 : public pepper::PluginDelegate::PlatformVideoDecoder {
163 public:
164 PlatformVideoDecoderImpl()
165 : input_buffer_size_(0),
166 next_dib_id_(0),
167 dib_(NULL) {
168 memset(&flush_callback_, 0, sizeof(flush_callback_));
169 }
170
171 virtual bool Init(const PP_VideoDecoderConfig& decoder_config) {
172 decoder_config_ = decoder_config;
173 input_buffer_size_ = 1024 << 4;
174
175 // Allocate the transport DIB.
176 TransportDIB* dib = TransportDIB::Create(input_buffer_size_,
177 next_dib_id_++);
178 if (!dib)
179 return false;
180
181 // TODO(wjia): Create video decoder in GPU process.
182
183 return true;
184 }
185
186 virtual bool Decode(PP_VideoCompressedDataBuffer& input_buffer) {
187 // TODO(wjia): Implement me!
188 NOTIMPLEMENTED();
189
190 input_buffers_.push(&input_buffer);
191
192 // Copy input data to dib_ and send it to GPU video decoder.
193
194 return false;
195 }
196
197 virtual int32_t Flush(PP_CompletionCallback& callback) {
198 // TODO(wjia): Implement me!
199 NOTIMPLEMENTED();
200
201 // Do nothing if there is a flush pending.
202 if (flush_callback_.func)
203 return PP_ERROR_BADARGUMENT;
204
205 flush_callback_ = callback;
206
207 // Call GPU video decoder to flush.
208
209 return PP_ERROR_WOULDBLOCK;
210 }
211
212 virtual bool ReturnUncompressedDataBuffer(
213 PP_VideoUncompressedDataBuffer& buffer) {
214 // TODO(wjia): Implement me!
215 NOTIMPLEMENTED();
216
217 // Deliver the buffer to GPU video decoder.
218
219 return false;
220 }
221
222 void OnFlushDone() {
223 if (!flush_callback_.func)
224 return;
225
226 flush_callback_.func(flush_callback_.user_data, PP_OK);
227 flush_callback_.func = NULL;
228 }
229
230 virtual intptr_t GetSharedMemoryHandle() const {
231 return reinterpret_cast<intptr_t>(dib_.get());
232 }
233
234 private:
235 size_t input_buffer_size_;
236 int next_dib_id_;
237 scoped_ptr<TransportDIB> dib_;
238 PP_VideoDecoderConfig decoder_config_;
239 std::queue<PP_VideoCompressedDataBuffer*> input_buffers_;
240 PP_CompletionCallback flush_callback_;
241
242 DISALLOW_COPY_AND_ASSIGN(PlatformVideoDecoderImpl);
243 };
244
160 } // namespace 245 } // namespace
161 246
162 PepperPluginDelegateImpl::PepperPluginDelegateImpl(RenderView* render_view) 247 PepperPluginDelegateImpl::PepperPluginDelegateImpl(RenderView* render_view)
163 : render_view_(render_view) { 248 : render_view_(render_view) {
164 } 249 }
165 250
166 void PepperPluginDelegateImpl::ViewInitiatedPaint() { 251 void PepperPluginDelegateImpl::ViewInitiatedPaint() {
167 // Notify all of our instances that we started painting. This is used for 252 // Notify all of our instances that we started painting. This is used for
168 // internal bookkeeping only, so we know that the set can not change under 253 // internal bookkeeping only, so we know that the set can not change under
169 // us. 254 // us.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 #else 326 #else
242 static int next_dib_id = 0; 327 static int next_dib_id = 0;
243 TransportDIB* dib = TransportDIB::Create(buffer_size, next_dib_id++); 328 TransportDIB* dib = TransportDIB::Create(buffer_size, next_dib_id++);
244 if (!dib) 329 if (!dib)
245 return NULL; 330 return NULL;
246 #endif 331 #endif
247 332
248 return new PlatformImage2DImpl(width, height, dib); 333 return new PlatformImage2DImpl(width, height, dib);
249 } 334 }
250 335
336 pepper::PluginDelegate::PlatformVideoDecoder*
337 PepperPluginDelegateImpl::CreateVideoDecoder(
338 const PP_VideoDecoderConfig& decoder_config) {
339 scoped_ptr<PlatformVideoDecoderImpl> decoder(new PlatformVideoDecoderImpl());
340
341 if (!decoder->Init(decoder_config))
342 return NULL;
343
344 return decoder.release();
345 }
346
251 void PepperPluginDelegateImpl::DidChangeNumberOfFindResults(int identifier, 347 void PepperPluginDelegateImpl::DidChangeNumberOfFindResults(int identifier,
252 int total, 348 int total,
253 bool final_result) { 349 bool final_result) {
254 if (total == 0) { 350 if (total == 0) {
255 render_view_->ReportNoFindInPageResults(identifier); 351 render_view_->ReportNoFindInPageResults(identifier);
256 } else { 352 } else {
257 render_view_->reportFindInPageMatchCount(identifier, total, final_result); 353 render_view_->reportFindInPageMatchCount(identifier, total, final_result);
258 } 354 }
259 } 355 }
260 356
(...skipping 13 matching lines...) Expand all
274 } else { 370 } else {
275 return NULL; 371 return NULL;
276 } 372 }
277 } 373 }
278 374
279 bool PepperPluginDelegateImpl::RunFileChooser( 375 bool PepperPluginDelegateImpl::RunFileChooser(
280 const WebKit::WebFileChooserParams& params, 376 const WebKit::WebFileChooserParams& params,
281 WebKit::WebFileChooserCompletion* chooser_completion) { 377 WebKit::WebFileChooserCompletion* chooser_completion) {
282 return render_view_->runFileChooser(params, chooser_completion); 378 return render_view_->runFileChooser(params, chooser_completion);
283 } 379 }
OLDNEW
« no previous file with comments | « chrome/renderer/pepper_plugin_delegate_impl.h ('k') | webkit/glue/plugins/pepper_plugin_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698