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" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 EnterResourceNoLock<PPB_Buffer_API> enter(bitstream_buffer->data, true); | 98 EnterResourceNoLock<PPB_Buffer_API> enter(bitstream_buffer->data, true); |
99 if (enter.failed()) | 99 if (enter.failed()) |
100 return PP_ERROR_FAILED; | 100 return PP_ERROR_FAILED; |
101 | 101 |
102 PPB_Buffer_Impl* buffer = static_cast<PPB_Buffer_Impl*>(enter.object()); | 102 PPB_Buffer_Impl* buffer = static_cast<PPB_Buffer_Impl*>(enter.object()); |
103 media::BitstreamBuffer decode_buffer( | 103 media::BitstreamBuffer decode_buffer( |
104 bitstream_buffer->id, | 104 bitstream_buffer->id, |
105 buffer->shared_memory()->handle(), | 105 buffer->shared_memory()->handle(), |
106 static_cast<size_t>(bitstream_buffer->size)); | 106 static_cast<size_t>(bitstream_buffer->size)); |
107 SetBitstreamBufferCallback(bitstream_buffer->id, callback); | 107 if (!SetBitstreamBufferCallback(bitstream_buffer->id, callback)) |
| 108 return PP_ERROR_BADARGUMENT; |
108 | 109 |
109 FlushCommandBuffer(); | 110 FlushCommandBuffer(); |
110 platform_video_decoder_->Decode(decode_buffer); | 111 platform_video_decoder_->Decode(decode_buffer); |
111 return PP_OK_COMPLETIONPENDING; | 112 return PP_OK_COMPLETIONPENDING; |
112 } | 113 } |
113 | 114 |
114 void PPB_VideoDecoder_Impl::AssignPictureBuffers( | 115 void PPB_VideoDecoder_Impl::AssignPictureBuffers( |
115 uint32_t no_of_buffers, | 116 uint32_t no_of_buffers, |
116 const PP_PictureBuffer_Dev* buffers) { | 117 const PP_PictureBuffer_Dev* buffers) { |
117 if (!platform_video_decoder_) | 118 if (!platform_video_decoder_) |
(...skipping 18 matching lines...) Expand all Loading... |
136 return; | 137 return; |
137 | 138 |
138 FlushCommandBuffer(); | 139 FlushCommandBuffer(); |
139 platform_video_decoder_->ReusePictureBuffer(picture_buffer_id); | 140 platform_video_decoder_->ReusePictureBuffer(picture_buffer_id); |
140 } | 141 } |
141 | 142 |
142 int32_t PPB_VideoDecoder_Impl::Flush(PP_CompletionCallback callback) { | 143 int32_t PPB_VideoDecoder_Impl::Flush(PP_CompletionCallback callback) { |
143 if (!platform_video_decoder_) | 144 if (!platform_video_decoder_) |
144 return PP_ERROR_BADRESOURCE; | 145 return PP_ERROR_BADRESOURCE; |
145 | 146 |
146 SetFlushCallback(callback); | 147 if (!SetFlushCallback(callback)) |
| 148 return PP_ERROR_INPROGRESS; |
147 | 149 |
148 FlushCommandBuffer(); | 150 FlushCommandBuffer(); |
149 platform_video_decoder_->Flush(); | 151 platform_video_decoder_->Flush(); |
150 return PP_OK_COMPLETIONPENDING; | 152 return PP_OK_COMPLETIONPENDING; |
151 } | 153 } |
152 | 154 |
153 int32_t PPB_VideoDecoder_Impl::Reset(PP_CompletionCallback callback) { | 155 int32_t PPB_VideoDecoder_Impl::Reset(PP_CompletionCallback callback) { |
154 if (!platform_video_decoder_) | 156 if (!platform_video_decoder_) |
155 return PP_ERROR_BADRESOURCE; | 157 return PP_ERROR_BADRESOURCE; |
156 | 158 |
157 SetResetCallback(callback); | 159 if (!SetResetCallback(callback)) |
| 160 return PP_ERROR_INPROGRESS; |
158 | 161 |
159 FlushCommandBuffer(); | 162 FlushCommandBuffer(); |
160 platform_video_decoder_->Reset(); | 163 platform_video_decoder_->Reset(); |
161 return PP_OK_COMPLETIONPENDING; | 164 return PP_OK_COMPLETIONPENDING; |
162 } | 165 } |
163 | 166 |
164 void PPB_VideoDecoder_Impl::Destroy() { | 167 void PPB_VideoDecoder_Impl::Destroy() { |
165 if (!platform_video_decoder_) | 168 if (!platform_video_decoder_) |
166 return; | 169 return; |
167 | 170 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 void PPB_VideoDecoder_Impl::AddRefResource(PP_Resource resource) { | 249 void PPB_VideoDecoder_Impl::AddRefResource(PP_Resource resource) { |
247 ResourceTracker::Get()->AddRefResource(resource); | 250 ResourceTracker::Get()->AddRefResource(resource); |
248 } | 251 } |
249 | 252 |
250 void PPB_VideoDecoder_Impl::UnrefResource(PP_Resource resource) { | 253 void PPB_VideoDecoder_Impl::UnrefResource(PP_Resource resource) { |
251 ResourceTracker::Get()->UnrefResource(resource); | 254 ResourceTracker::Get()->UnrefResource(resource); |
252 } | 255 } |
253 | 256 |
254 } // namespace ppapi | 257 } // namespace ppapi |
255 } // namespace webkit | 258 } // namespace webkit |
OLD | NEW |