OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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" |
11 #include "media/video/picture.h" | 11 #include "media/video/picture.h" |
12 #include "ppapi/c/dev/pp_video_dev.h" | 12 #include "ppapi/c/dev/pp_video_dev.h" |
13 #include "ppapi/c/dev/ppb_video_decoder_dev.h" | 13 #include "ppapi/c/dev/ppb_video_decoder_dev.h" |
14 #include "ppapi/c/dev/ppp_video_decoder_dev.h" | 14 #include "ppapi/c/dev/ppp_video_decoder_dev.h" |
15 #include "ppapi/c/pp_completion_callback.h" | 15 #include "ppapi/c/pp_completion_callback.h" |
16 #include "ppapi/c/pp_errors.h" | 16 #include "ppapi/c/pp_errors.h" |
17 #include "ppapi/thunk/enter.h" | 17 #include "ppapi/thunk/enter.h" |
18 #include "webkit/plugins/ppapi/common.h" | 18 #include "webkit/plugins/ppapi/common.h" |
19 #include "webkit/plugins/ppapi/plugin_module.h" | 19 #include "webkit/plugins/ppapi/plugin_module.h" |
20 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 20 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
21 #include "webkit/plugins/ppapi/ppb_buffer_impl.h" | 21 #include "webkit/plugins/ppapi/ppb_buffer_impl.h" |
22 #include "webkit/plugins/ppapi/ppb_context_3d_impl.h" | 22 #include "webkit/plugins/ppapi/ppb_context_3d_impl.h" |
23 #include "webkit/plugins/ppapi/resource_tracker.h" | 23 #include "webkit/plugins/ppapi/resource_tracker.h" |
24 #include "webkit/plugins/ppapi/var.h" | 24 #include "webkit/plugins/ppapi/var.h" |
25 | 25 |
| 26 using ppapi::thunk::EnterResourceNoLock; |
| 27 using ppapi::thunk::PPB_Buffer_API; |
| 28 using ppapi::thunk::PPB_Context3D_API; |
26 using ppapi::thunk::PPB_VideoDecoder_API; | 29 using ppapi::thunk::PPB_VideoDecoder_API; |
27 | 30 |
28 namespace webkit { | 31 namespace webkit { |
29 namespace ppapi { | 32 namespace ppapi { |
30 | 33 |
31 namespace { | 34 namespace { |
32 | 35 |
33 // Utility methods to convert data to and from the ppapi C-types and their | 36 // Utility methods to convert data to and from the ppapi C-types and their |
34 // C++ media-namespace equivalents. | 37 // C++ media-namespace equivalents. |
35 void CopyToPictureDev(const media::Picture& input, PP_Picture_Dev* output) { | 38 void CopyToPictureDev(const media::Picture& input, PP_Picture_Dev* output) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 int32_t PPB_VideoDecoder_Impl::Initialize( | 118 int32_t PPB_VideoDecoder_Impl::Initialize( |
116 PP_Resource context_id, | 119 PP_Resource context_id, |
117 const PP_VideoConfigElement* decoder_config, | 120 const PP_VideoConfigElement* decoder_config, |
118 PP_CompletionCallback callback) { | 121 PP_CompletionCallback callback) { |
119 if (!callback.func) | 122 if (!callback.func) |
120 return PP_ERROR_BADARGUMENT; | 123 return PP_ERROR_BADARGUMENT; |
121 | 124 |
122 if (!instance()) | 125 if (!instance()) |
123 return PP_ERROR_FAILED; | 126 return PP_ERROR_FAILED; |
124 | 127 |
125 scoped_refptr<webkit::ppapi::PPB_Context3D_Impl> context3d = | 128 EnterResourceNoLock<PPB_Context3D_API> enter(context_id, true); |
126 webkit::ppapi::Resource::GetAs<webkit::ppapi::PPB_Context3D_Impl>( | 129 if (enter.failed()) |
127 context_id); | |
128 if (!context3d) | |
129 return PP_ERROR_BADRESOURCE; | 130 return PP_ERROR_BADRESOURCE; |
| 131 PPB_Context3D_Impl* context3d = |
| 132 static_cast<PPB_Context3D_Impl*>(enter.object()); |
130 | 133 |
131 int command_buffer_route_id = | 134 int command_buffer_route_id = |
132 context3d->platform_context()->GetCommandBufferRouteId(); | 135 context3d->platform_context()->GetCommandBufferRouteId(); |
133 if (command_buffer_route_id == 0) | 136 if (command_buffer_route_id == 0) |
134 return PP_ERROR_FAILED; | 137 return PP_ERROR_FAILED; |
135 | 138 |
136 platform_video_decoder_.reset( | 139 platform_video_decoder_.reset( |
137 instance()->delegate()->CreateVideoDecoder( | 140 instance()->delegate()->CreateVideoDecoder( |
138 this, command_buffer_route_id)); | 141 this, command_buffer_route_id)); |
139 | 142 |
(...skipping 10 matching lines...) Expand all Loading... |
150 return PP_ERROR_FAILED; | 153 return PP_ERROR_FAILED; |
151 } | 154 } |
152 } | 155 } |
153 | 156 |
154 int32_t PPB_VideoDecoder_Impl::Decode( | 157 int32_t PPB_VideoDecoder_Impl::Decode( |
155 const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, | 158 const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, |
156 PP_CompletionCallback callback) { | 159 PP_CompletionCallback callback) { |
157 if (!platform_video_decoder_.get()) | 160 if (!platform_video_decoder_.get()) |
158 return PP_ERROR_BADRESOURCE; | 161 return PP_ERROR_BADRESOURCE; |
159 | 162 |
160 ::ppapi::thunk::EnterResourceNoLock< ::ppapi::thunk::PPB_Buffer_API> | 163 EnterResourceNoLock<PPB_Buffer_API> enter(bitstream_buffer->data, true); |
161 enter(bitstream_buffer->data, true); | |
162 if (enter.failed()) | 164 if (enter.failed()) |
163 return PP_ERROR_FAILED; | 165 return PP_ERROR_FAILED; |
164 | 166 |
165 PPB_Buffer_Impl* buffer = static_cast<PPB_Buffer_Impl*>(enter.object()); | 167 PPB_Buffer_Impl* buffer = static_cast<PPB_Buffer_Impl*>(enter.object()); |
166 media::BitstreamBuffer decode_buffer(bitstream_buffer->id, | 168 media::BitstreamBuffer decode_buffer(bitstream_buffer->id, |
167 buffer->shared_memory()->handle(), | 169 buffer->shared_memory()->handle(), |
168 static_cast<size_t>(buffer->size())); | 170 static_cast<size_t>(buffer->size())); |
169 | 171 |
170 // Store the callback to inform when bitstream buffer has been processed. | 172 // Store the callback to inform when bitstream buffer has been processed. |
171 // TODO(vmr): handle simultaneous decodes + callbacks. | 173 // TODO(vmr): handle simultaneous decodes + callbacks. |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 size_(info.size.width, info.size.height) { | 349 size_(info.size.width, info.size.height) { |
348 } | 350 } |
349 | 351 |
350 GLESBuffer::GLESBuffer(const PP_GLESBuffer_Dev& buffer) | 352 GLESBuffer::GLESBuffer(const PP_GLESBuffer_Dev& buffer) |
351 : BaseBuffer(buffer.info), | 353 : BaseBuffer(buffer.info), |
352 texture_id_(buffer.texture_id) { | 354 texture_id_(buffer.texture_id) { |
353 } | 355 } |
354 | 356 |
355 SysmemBuffer::SysmemBuffer(const PP_SysmemBuffer_Dev& buffer) | 357 SysmemBuffer::SysmemBuffer(const PP_SysmemBuffer_Dev& buffer) |
356 : BaseBuffer(buffer.info) { | 358 : BaseBuffer(buffer.info) { |
357 scoped_refptr<webkit::ppapi::PPB_Buffer_Impl> pepper_buffer = | 359 // TODO(brettw) we should properly handle the errors here if the buffer |
358 webkit::ppapi::Resource::GetAs<webkit::ppapi::PPB_Buffer_Impl>( | 360 // isn't a valid image rather than CHECKing. |
359 buffer.data); | 361 EnterResourceNoLock<PPB_Buffer_API> enter(buffer.data, true); |
| 362 CHECK(enter.succeeded()); |
| 363 webkit::ppapi::PPB_Buffer_Impl* pepper_buffer = |
| 364 static_cast<webkit::ppapi::PPB_Buffer_Impl*>(enter.object()); |
360 CHECK(pepper_buffer->IsMapped()); | 365 CHECK(pepper_buffer->IsMapped()); |
361 data_ = pepper_buffer->Map(); | 366 data_ = pepper_buffer->Map(); |
362 } | 367 } |
363 | 368 |
364 Picture::Picture(const PP_Picture_Dev& picture) | 369 Picture::Picture(const PP_Picture_Dev& picture) |
365 : picture_buffer_id_(picture.picture_buffer_id), | 370 : picture_buffer_id_(picture.picture_buffer_id), |
366 bitstream_buffer_id_(picture.bitstream_buffer_id), | 371 bitstream_buffer_id_(picture.bitstream_buffer_id), |
367 visible_size_(picture.visible_size.width, picture.visible_size.height), | 372 visible_size_(picture.visible_size.width, picture.visible_size.height), |
368 decoded_size_(picture.decoded_size.width, picture.decoded_size.height) { | 373 decoded_size_(picture.decoded_size.width, picture.decoded_size.height) { |
369 } | 374 } |
370 | 375 |
371 } // namespace media | 376 } // namespace media |
OLD | NEW |