Chromium Code Reviews| 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 "media/video/picture.h" | 10 #include "media/video/picture.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 PPB_VideoDecoder_Impl* decoder = new PPB_VideoDecoder_Impl(instance); | 52 PPB_VideoDecoder_Impl* decoder = new PPB_VideoDecoder_Impl(instance); |
| 53 return decoder->GetReference(); | 53 return decoder->GetReference(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 int32_t Initialize(PP_Resource video_decoder, | 56 int32_t Initialize(PP_Resource video_decoder, |
| 57 const PP_VideoConfigElement* decoder_config, | 57 const PP_VideoConfigElement* decoder_config, |
| 58 struct PP_CompletionCallback callback) { | 58 struct PP_CompletionCallback callback) { |
| 59 scoped_refptr<PPB_VideoDecoder_Impl> decoder( | 59 scoped_refptr<PPB_VideoDecoder_Impl> decoder( |
| 60 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder)); | 60 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder)); |
| 61 if (!decoder) | 61 if (!decoder) |
| 62 return PP_ERROR_BADRESOURCE; | 62 return MayForceCallback(callback, PP_ERROR_BADRESOURCE); |
| 63 | 63 |
| 64 return decoder->Initialize(decoder_config, callback); | 64 int32_t result =decoder->Initialize(decoder_config, callback); |
|
piman
2011/06/07 17:32:14
nit: space after =
polina
2011/06/09 23:53:51
Done.
| |
| 65 return MayForceCallback(callback, result); | |
| 65 } | 66 } |
| 66 | 67 |
| 67 PP_Bool IsVideoDecoder(PP_Resource resource) { | 68 PP_Bool IsVideoDecoder(PP_Resource resource) { |
| 68 return BoolToPPBool(!!Resource::GetAs<PPB_VideoDecoder_Impl>(resource)); | 69 return BoolToPPBool(!!Resource::GetAs<PPB_VideoDecoder_Impl>(resource)); |
| 69 } | 70 } |
| 70 | 71 |
| 71 int32_t Decode(PP_Resource decoder_id, | 72 int32_t Decode(PP_Resource decoder_id, |
| 72 const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, | 73 const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, |
| 73 PP_CompletionCallback callback) { | 74 PP_CompletionCallback callback) { |
| 74 scoped_refptr<PPB_VideoDecoder_Impl> decoder( | 75 scoped_refptr<PPB_VideoDecoder_Impl> decoder( |
| 75 Resource::GetAs<PPB_VideoDecoder_Impl>(decoder_id)); | 76 Resource::GetAs<PPB_VideoDecoder_Impl>(decoder_id)); |
| 76 if (!decoder) | 77 if (!decoder) |
| 77 return PP_ERROR_BADRESOURCE; | 78 return MayForceCallback(callback, PP_ERROR_BADRESOURCE); |
| 78 | 79 |
| 79 return decoder->Decode(bitstream_buffer, callback); | 80 int32_t result = decoder->Decode(bitstream_buffer, callback); |
| 81 return MayForceCallback(callback, result); | |
| 80 } | 82 } |
| 81 | 83 |
| 82 void AssignGLESBuffers(PP_Resource video_decoder, | 84 void AssignGLESBuffers(PP_Resource video_decoder, |
| 83 uint32_t no_of_buffers, | 85 uint32_t no_of_buffers, |
| 84 const PP_GLESBuffer_Dev* buffers) { | 86 const PP_GLESBuffer_Dev* buffers) { |
| 85 scoped_refptr<PPB_VideoDecoder_Impl> decoder( | 87 scoped_refptr<PPB_VideoDecoder_Impl> decoder( |
| 86 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder)); | 88 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder)); |
| 87 if (!decoder) | 89 if (!decoder) |
| 88 return; | 90 return; |
| 89 | 91 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 107 if (!decoder) | 109 if (!decoder) |
| 108 return; | 110 return; |
| 109 | 111 |
| 110 decoder->ReusePictureBuffer(picture_buffer_id); | 112 decoder->ReusePictureBuffer(picture_buffer_id); |
| 111 } | 113 } |
| 112 | 114 |
| 113 int32_t Flush(PP_Resource video_decoder, PP_CompletionCallback callback) { | 115 int32_t Flush(PP_Resource video_decoder, PP_CompletionCallback callback) { |
| 114 scoped_refptr<PPB_VideoDecoder_Impl> decoder( | 116 scoped_refptr<PPB_VideoDecoder_Impl> decoder( |
| 115 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder)); | 117 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder)); |
| 116 if (!decoder) | 118 if (!decoder) |
| 117 return PP_ERROR_BADRESOURCE; | 119 return MayForceCallback(callback, PP_ERROR_BADRESOURCE); |
| 118 | 120 |
| 119 return decoder->Flush(callback); | 121 return MayForceCallback(callback, decoder->Flush(callback)); |
| 120 } | 122 } |
| 121 | 123 |
| 122 int32_t Abort(PP_Resource video_decoder, | 124 int32_t Abort(PP_Resource video_decoder, |
| 123 PP_CompletionCallback callback) { | 125 PP_CompletionCallback callback) { |
| 124 scoped_refptr<PPB_VideoDecoder_Impl> decoder( | 126 scoped_refptr<PPB_VideoDecoder_Impl> decoder( |
| 125 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder)); | 127 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder)); |
| 126 if (!decoder) | 128 if (!decoder) |
| 127 return PP_ERROR_BADRESOURCE; | 129 return MayForceCallback(callback, PP_ERROR_BADRESOURCE); |
| 128 | 130 |
| 129 return decoder->Abort(callback); | 131 return MayForceCallback(callback, decoder->Abort(callback)); |
| 130 } | 132 } |
| 131 | 133 |
| 132 const PPB_VideoDecoder_Dev ppb_videodecoder = { | 134 const PPB_VideoDecoder_Dev ppb_videodecoder = { |
| 133 &GetConfigs, | 135 &GetConfigs, |
| 134 &Create, | 136 &Create, |
| 135 &Initialize, | 137 &Initialize, |
| 136 &IsVideoDecoder, | 138 &IsVideoDecoder, |
| 137 &Decode, | 139 &Decode, |
| 138 &AssignGLESBuffers, | 140 &AssignGLESBuffers, |
| 139 &AssignSysmemBuffers, | 141 &AssignSysmemBuffers, |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 453 } | 455 } |
| 454 | 456 |
| 455 Picture::Picture(const PP_Picture_Dev& picture) | 457 Picture::Picture(const PP_Picture_Dev& picture) |
| 456 : picture_buffer_id_(picture.picture_buffer_id), | 458 : picture_buffer_id_(picture.picture_buffer_id), |
| 457 bitstream_buffer_id_(picture.bitstream_buffer_id), | 459 bitstream_buffer_id_(picture.bitstream_buffer_id), |
| 458 visible_size_(picture.visible_size.width, picture.visible_size.height), | 460 visible_size_(picture.visible_size.width, picture.visible_size.height), |
| 459 decoded_size_(picture.decoded_size.width, picture.decoded_size.height) { | 461 decoded_size_(picture.decoded_size.width, picture.decoded_size.height) { |
| 460 } | 462 } |
| 461 | 463 |
| 462 } // namespace media | 464 } // namespace media |
| OLD | NEW |