| 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 "content/gpu/omx_video_decode_accelerator.h" | 5 #include "content/common/gpu/omx_video_decode_accelerator.h" |
| 6 | 6 |
| 7 #include "base/stl_util-inl.h" |
| 8 #include "base/string_util.h" |
| 9 #include "content/common/gpu/gles2_texture_to_egl_image_translator.h" |
| 7 #include "content/common/gpu/gpu_channel.h" | 10 #include "content/common/gpu/gpu_channel.h" |
| 8 #include "content/common/gpu_messages.h" | |
| 9 #include "content/gpu/gles2_texture_to_egl_image_translator.h" | |
| 10 #include "media/base/bitstream_buffer.h" | 11 #include "media/base/bitstream_buffer.h" |
| 11 #include "media/base/data_buffer.h" | |
| 12 #include "media/video/picture.h" | 12 #include "media/video/picture.h" |
| 13 | 13 |
| 14 static Gles2TextureToEglImageTranslator* texture2eglImage_translator( | 14 static Gles2TextureToEglImageTranslator* texture2eglImage_translator( |
| 15 new Gles2TextureToEglImageTranslator(NULL, 0)); | 15 new Gles2TextureToEglImageTranslator(NULL, 0)); |
| 16 enum { kNumPictureBuffers = 4 }; | 16 enum { kNumPictureBuffers = 4 }; |
| 17 | 17 |
| 18 // Open the libnvomx here for now. | 18 // Open the libnvomx here for now. |
| 19 void* omx_handle = dlopen("libnvomx.so", RTLD_NOW); | 19 void* omx_handle = dlopen("libnvomx.so", RTLD_NOW); |
| 20 | 20 |
| 21 typedef OMX_ERRORTYPE (*OMXInit)(); | 21 typedef OMX_ERRORTYPE (*OMXInit)(); |
| 22 typedef OMX_ERRORTYPE (*OMXGetHandle)( | 22 typedef OMX_ERRORTYPE (*OMXGetHandle)( |
| 23 OMX_HANDLETYPE*, OMX_STRING, OMX_PTR, OMX_CALLBACKTYPE*); | 23 OMX_HANDLETYPE*, OMX_STRING, OMX_PTR, OMX_CALLBACKTYPE*); |
| 24 typedef OMX_ERRORTYPE (*OMXGetComponentsOfRole)(OMX_STRING, OMX_U32*, OMX_U8**); | 24 typedef OMX_ERRORTYPE (*OMXGetComponentsOfRole)(OMX_STRING, OMX_U32*, OMX_U8**); |
| 25 typedef OMX_ERRORTYPE (*OMXFreeHandle)(OMX_HANDLETYPE); | 25 typedef OMX_ERRORTYPE (*OMXFreeHandle)(OMX_HANDLETYPE); |
| 26 typedef OMX_ERRORTYPE (*OMXDeinit)(); | 26 typedef OMX_ERRORTYPE (*OMXDeinit)(); |
| 27 | 27 |
| 28 OMXInit omx_init = reinterpret_cast<OMXInit>(dlsym(omx_handle, "OMX_Init")); | 28 OMXInit omx_init = reinterpret_cast<OMXInit>(dlsym(omx_handle, "OMX_Init")); |
| 29 | |
| 30 OMXGetHandle omx_gethandle = | 29 OMXGetHandle omx_gethandle = |
| 31 reinterpret_cast<OMXGetHandle>(dlsym(omx_handle, "OMX_GetHandle")); | 30 reinterpret_cast<OMXGetHandle>(dlsym(omx_handle, "OMX_GetHandle")); |
| 32 OMXGetComponentsOfRole omx_get_components_of_role = | 31 OMXGetComponentsOfRole omx_get_components_of_role = |
| 33 reinterpret_cast<OMXGetComponentsOfRole>( | 32 reinterpret_cast<OMXGetComponentsOfRole>( |
| 34 dlsym(omx_handle, "OMX_GetComponentsOfRole")); | 33 dlsym(omx_handle, "OMX_GetComponentsOfRole")); |
| 35 OMXFreeHandle omx_free_handle = | 34 OMXFreeHandle omx_free_handle = |
| 36 reinterpret_cast<OMXFreeHandle>(dlsym(omx_handle, "OMX_FreeHandle")); | 35 reinterpret_cast<OMXFreeHandle>(dlsym(omx_handle, "OMX_FreeHandle")); |
| 37 OMXDeinit omx_deinit = | 36 OMXDeinit omx_deinit = |
| 38 reinterpret_cast<OMXDeinit>(dlsym(omx_handle, "OMX_Deinit")); | 37 reinterpret_cast<OMXDeinit>(dlsym(omx_handle, "OMX_Deinit")); |
| 39 | 38 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 51 height_(-1), | 50 height_(-1), |
| 52 input_buffer_count_(0), | 51 input_buffer_count_(0), |
| 53 input_buffer_size_(0), | 52 input_buffer_size_(0), |
| 54 input_port_(0), | 53 input_port_(0), |
| 55 input_buffers_at_component_(0), | 54 input_buffers_at_component_(0), |
| 56 output_buffer_count_(0), | 55 output_buffer_count_(0), |
| 57 output_buffer_size_(0), | 56 output_buffer_size_(0), |
| 58 output_port_(0), | 57 output_port_(0), |
| 59 output_buffers_at_component_(0), | 58 output_buffers_at_component_(0), |
| 60 uses_egl_image_(false), | 59 uses_egl_image_(false), |
| 61 client_(client), | 60 client_(client) { |
| 62 egl_image_(NULL) { | |
| 63 if (!AreOMXFunctionPointersInitialized()) { | 61 if (!AreOMXFunctionPointersInitialized()) { |
| 64 LOG(ERROR) << "Failed to load openmax library"; | 62 LOG(ERROR) << "Failed to load openmax library"; |
| 65 return; | 63 return; |
| 66 } | 64 } |
| 67 OMX_ERRORTYPE result = omx_init(); | 65 OMX_ERRORTYPE result = omx_init(); |
| 68 if (result != OMX_ErrorNone) | 66 if (result != OMX_ErrorNone) |
| 69 LOG(ERROR) << "Failed to init OpenMAX core"; | 67 LOG(ERROR) << "Failed to init OpenMAX core"; |
| 70 } | 68 } |
| 71 | 69 |
| 72 OmxVideoDecodeAccelerator::~OmxVideoDecodeAccelerator() { | 70 OmxVideoDecodeAccelerator::~OmxVideoDecodeAccelerator() { |
| 73 DCHECK(free_input_buffers_.empty()); | 71 DCHECK(free_input_buffers_.empty()); |
| 74 DCHECK_EQ(0, input_buffers_at_component_); | 72 DCHECK_EQ(0, input_buffers_at_component_); |
| 75 DCHECK_EQ(0, output_buffers_at_component_); | 73 DCHECK_EQ(0, output_buffers_at_component_); |
| 76 DCHECK(output_pictures_.empty()); | 74 DCHECK(output_pictures_.empty()); |
| 77 } | 75 } |
| 78 | 76 |
| 79 const std::vector<uint32>& OmxVideoDecodeAccelerator::GetConfig( | 77 void OmxVideoDecodeAccelerator::GetConfigs( |
| 80 const std::vector<uint32>& prototype_config) { | 78 const std::vector<uint32>& requested_configs, |
| 79 std::vector<uint32>* matched_configs) { |
| 81 // TODO(vhiremath@nvidia.com) use this properly | 80 // TODO(vhiremath@nvidia.com) use this properly |
| 82 NOTIMPLEMENTED(); | 81 NOTIMPLEMENTED(); |
| 83 return component_config_; | |
| 84 } | 82 } |
| 85 | 83 |
| 86 // This is to initialize the OMX data structures to default values. | 84 // This is to initialize the OMX data structures to default values. |
| 87 template <typename T> | 85 template <typename T> |
| 88 static void InitParam(const OmxVideoDecodeAccelerator& dec, T* param) { | 86 static void InitParam(const OmxVideoDecodeAccelerator& dec, T* param) { |
| 89 memset(param, 0, sizeof(T)); | 87 memset(param, 0, sizeof(T)); |
| 90 param->nVersion.nVersion = 0x00000101; | 88 param->nVersion.nVersion = 0x00000101; |
| 91 param->nSize = sizeof(T); | 89 param->nSize = sizeof(T); |
| 92 } | 90 } |
| 93 | 91 |
| 94 bool OmxVideoDecodeAccelerator::Initialize(const std::vector<uint32>& config) { | 92 bool OmxVideoDecodeAccelerator::Initialize(const std::vector<uint32>& config) { |
| 95 // TODO(vhiremath@nvidia.com) get these acutal values from config | 93 // TODO(vhiremath@nvidia.com) get these actual values from config |
| 96 // Assume qvga for now | 94 // Assume qvga for now |
| 97 width_ = 320; | 95 width_ = 320; |
| 98 height_ = 240; | 96 height_ = 240; |
| 99 | 97 |
| 100 client_state_ = OMX_StateLoaded; | 98 client_state_ = OMX_StateLoaded; |
| 101 if (!CreateComponent()) { | 99 if (!CreateComponent()) { |
| 102 StopOnError(); | 100 StopOnError(); |
| 103 return false; | 101 return false; |
| 104 } | 102 } |
| 105 // Transition component to Idle state | 103 // Transition component to Idle state |
| 106 on_state_event_func_ = | 104 on_state_event_func_ = |
| 107 &OmxVideoDecodeAccelerator::OnStateChangeLoadedToIdle; | 105 &OmxVideoDecodeAccelerator::OnStateChangeLoadedToIdle; |
| 108 if (!TransitionToState(OMX_StateIdle)) | 106 if (!TransitionToState(OMX_StateIdle)) |
| 109 return false; | 107 return false; |
| 110 | 108 |
| 111 if (!AllocateInputBuffers()) { | 109 if (!AllocateInputBuffers()) { |
| 112 LOG(ERROR) << "OMX_AllocateBuffer() Input buffer error"; | 110 LOG(ERROR) << "OMX_AllocateBuffer() Input buffer error"; |
| 113 StopOnError(); | 111 StopOnError(); |
| 114 return false; | 112 return false; |
| 115 } | 113 } |
| 116 | 114 |
| 117 // After AllocateInputBuffers ideally this should be AllocateOutputBuffers. | 115 // After AllocateInputBuffers ideally this should be AllocateOutputBuffers. |
| 118 // Since in this case app provides the output buffers, | 116 // Since in this case app provides the output buffers, |
| 119 // we query this through ProvidePictureBuffers. | 117 // we query this through ProvidePictureBuffers. |
| 120 // This is call to ppapi to provide the output buffers initially. | 118 // This is call to ppapi to provide the output buffers initially. |
| 121 // ProvidePictureBuffers will provide | 119 // ProvidePictureBuffers will provide |
| 122 // - SharedMemHandle in case of decoding to system memory. | 120 // - SharedMemHandle in case of decoding to system memory. |
| 123 // - Textures in case of decoding to egl-images. | 121 // - Textures in case of decoding to egl-images. |
| 124 | 122 |
| 125 // Output buffers will be eventually allocated in AssignPictureBuffer(). | 123 // Output buffers will be eventually handed to us via |
| 126 | 124 // Assign{GLES,Sysmem}Buffers(). |
| 127 // TODO(vhiremath@nvidia.com) fill buffer_properties | |
| 128 std::vector<uint32> buffer_properties; | |
| 129 output_buffer_count_ = kNumPictureBuffers; | 125 output_buffer_count_ = kNumPictureBuffers; |
| 130 client_->ProvidePictureBuffers(output_buffer_count_, buffer_properties); | 126 client_->ProvidePictureBuffers( |
| 127 output_buffer_count_, gfx::Size(width_, height_), |
| 128 PICTUREBUFFER_MEMORYTYPE_GL_TEXTURE); |
| 129 // TODO(fischman): we always ask for GLES buffers above. So why maintain the |
| 130 // !uses_egl_image_ path in this class at all? Theoretically it could be |
| 131 // useful for testing, but today there's no such testing. Consider ripping it |
| 132 // out of this class and replacing AssignSysmemBuffers() with |
| 133 // NOTIMPLEMENTED(). |
| 131 return true; | 134 return true; |
| 132 } | 135 } |
| 133 | 136 |
| 134 bool OmxVideoDecodeAccelerator::CreateComponent() { | 137 bool OmxVideoDecodeAccelerator::CreateComponent() { |
| 135 OMX_CALLBACKTYPE omx_accelerator_callbacks = { | 138 OMX_CALLBACKTYPE omx_accelerator_callbacks = { |
| 136 &OmxVideoDecodeAccelerator::EventHandler, | 139 &OmxVideoDecodeAccelerator::EventHandler, |
| 137 &OmxVideoDecodeAccelerator::EmptyBufferCallback, | 140 &OmxVideoDecodeAccelerator::EmptyBufferCallback, |
| 138 &OmxVideoDecodeAccelerator::FillBufferCallback | 141 &OmxVideoDecodeAccelerator::FillBufferCallback |
| 139 }; | 142 }; |
| 140 OMX_ERRORTYPE result = OMX_ErrorNone; | 143 OMX_ERRORTYPE result = OMX_ErrorNone; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 // OMX_IndexParamPortDefinition on output port to be done in | 244 // OMX_IndexParamPortDefinition on output port to be done in |
| 242 // AllocateOutputBuffers. | 245 // AllocateOutputBuffers. |
| 243 // Since at this point we dont know if we will be using system memory | 246 // Since at this point we dont know if we will be using system memory |
| 244 // or egl-image for decoding. | 247 // or egl-image for decoding. |
| 245 // We get this info in AssignPictureBuffers() from plugin. | 248 // We get this info in AssignPictureBuffers() from plugin. |
| 246 | 249 |
| 247 return true; | 250 return true; |
| 248 } | 251 } |
| 249 | 252 |
| 250 bool OmxVideoDecodeAccelerator::Decode( | 253 bool OmxVideoDecodeAccelerator::Decode( |
| 251 const media::BitstreamBuffer& bitstream_buffer, | 254 const media::BitstreamBuffer& bitstream_buffer) { |
| 252 const media::VideoDecodeAcceleratorCallback& callback) { | |
| 253 DCHECK(!free_input_buffers_.empty()); | 255 DCHECK(!free_input_buffers_.empty()); |
| 254 DCHECK(bitstream_buffer); | |
| 255 | 256 |
| 256 if (!CanAcceptInput()) { | 257 if (!CanAcceptInput()) { |
| 257 return false; | 258 return false; |
| 258 } | 259 } |
| 259 | 260 |
| 260 OMX_BUFFERHEADERTYPE* omx_buffer = free_input_buffers_.front(); | 261 OMX_BUFFERHEADERTYPE* omx_buffer = free_input_buffers_.front(); |
| 261 free_input_buffers_.pop(); | 262 free_input_buffers_.pop(); |
| 262 | 263 |
| 263 // Setup |omx_buffer|. | 264 // Setup |omx_buffer|. |
| 264 scoped_ptr<base::SharedMemory> shm( | 265 scoped_ptr<base::SharedMemory> shm( |
| 265 new base::SharedMemory(bitstream_buffer.handle(), true)); | 266 new base::SharedMemory(bitstream_buffer.handle(), true)); |
| 266 if (!shm->Map(bitstream_buffer.size())) { | 267 if (!shm->Map(bitstream_buffer.size())) { |
| 267 LOG(ERROR) << "Failed to SharedMemory::Map()."; | 268 LOG(ERROR) << "Failed to SharedMemory::Map()."; |
| 268 return false; | 269 return false; |
| 269 } | 270 } |
| 270 omx_buffer->pBuffer = static_cast<OMX_U8*>(shm->memory()); | 271 omx_buffer->pBuffer = static_cast<OMX_U8*>(shm->memory()); |
| 271 omx_buffer->nFilledLen = bitstream_buffer->size(); | 272 omx_buffer->nFilledLen = bitstream_buffer.size(); |
| 272 omx_buffer->nAllocLen = omx_buffer->nFilledLen; | 273 omx_buffer->nAllocLen = omx_buffer->nFilledLen; |
| 273 | 274 |
| 274 omx_buffer->nFlags &= ~OMX_BUFFERFLAG_EOS; | 275 omx_buffer->nFlags &= ~OMX_BUFFERFLAG_EOS; |
| 275 omx_buffer->nTimeStamp = 0; | 276 omx_buffer->nTimeStamp = 0; |
| 276 | 277 |
| 277 // Give this buffer to OMX. | 278 // Give this buffer to OMX. |
| 278 OMX_ERRORTYPE result = OMX_ErrorNone; | 279 OMX_ERRORTYPE result = OMX_ErrorNone; |
| 279 result = OMX_EmptyThisBuffer(component_handle_, omx_buffer); | 280 result = OMX_EmptyThisBuffer(component_handle_, omx_buffer); |
| 280 if (result != OMX_ErrorNone) { | 281 if (result != OMX_ErrorNone) { |
| 281 LOG(ERROR) << "OMX_EmptyThisBuffer() failed with result " << result; | 282 LOG(ERROR) << "OMX_EmptyThisBuffer() failed with result " << result; |
| 282 StopOnError(); | 283 StopOnError(); |
| 283 return false; | 284 return false; |
| 284 } | 285 } |
| 285 input_buffers_at_component_++; | 286 input_buffers_at_component_++; |
| 286 // OMX_EmptyThisBuffer is a non blocking call and should | 287 // OMX_EmptyThisBuffer is a non blocking call and should |
| 287 // not make any assumptions about its completion. | 288 // not make any assumptions about its completion. |
| 288 omx_buff_cb_.insert(std::make_pair( | 289 omx_buff_ids_.insert(std::make_pair( |
| 289 omx_buffer, make_pair(shm.release(), callback))); | 290 omx_buffer, std::make_pair(shm.release(), bitstream_buffer.id()))); |
| 290 return true; | 291 return true; |
| 291 } | 292 } |
| 292 | 293 |
| 293 void OmxVideoDecodeAccelerator::AssignPictureBuffer( | 294 // NOTE: this is only partially-implemented as never unsets uses_egl_image_ once |
| 294 std::vector<PictureBuffer*> picture_buffers) { | 295 // set. |
| 295 // NOTE: this is only partially-implemented as it only inspects the first | 296 void OmxVideoDecodeAccelerator::AssignGLESBuffers( |
| 296 // picture buffer passed in each AssignPictureBuffer call, and never unsets | 297 const std::vector<media::GLESBuffer>& buffers) { |
| 297 // uses_egl_image_ once set. | 298 uses_egl_image_ = true; |
| 298 if (PictureBuffer::PICTUREBUFFER_MEMORYTYPE_GL_TEXTURE == | 299 std::vector<media::BaseBuffer*> base_buffers(buffers.size()); |
| 299 picture_buffers[0]->GetMemoryType()) { | 300 for (size_t i = 0; i < buffers.size(); ++i) |
| 300 uses_egl_image_ = true; | 301 base_buffers[i] = new media::GLESBuffer(buffers[i]); |
| 301 } | 302 AssignBuffersHelper(base_buffers); |
| 303 } |
| 302 | 304 |
| 305 void OmxVideoDecodeAccelerator::AssignSysmemBuffers( |
| 306 const std::vector<media::SysmemBuffer>& buffers) { |
| 307 DCHECK(!uses_egl_image_); |
| 308 std::vector<media::BaseBuffer*> base_buffers(buffers.size()); |
| 309 for (size_t i = 0; i < buffers.size(); ++i) |
| 310 base_buffers[i] = new media::SysmemBuffer(buffers[i]); |
| 311 AssignBuffersHelper(base_buffers); |
| 312 } |
| 313 |
| 314 void OmxVideoDecodeAccelerator::AssignBuffersHelper( |
| 315 const std::vector<media::BaseBuffer*>& buffers) { |
| 303 assigned_picture_buffers_.insert( | 316 assigned_picture_buffers_.insert( |
| 304 assigned_picture_buffers_.end(), | 317 assigned_picture_buffers_.end(), buffers.begin(), buffers.end()); |
| 305 picture_buffers.begin(), | |
| 306 picture_buffers.end()); | |
| 307 | 318 |
| 308 if (assigned_picture_buffers_.size() < kNumPictureBuffers) | 319 if (assigned_picture_buffers_.size() < kNumPictureBuffers) |
| 309 return; // get all the buffers first. | 320 return; // get all the buffers first. |
| 310 | 321 |
| 311 // Obtain the information about the output port. | 322 // Obtain the information about the output port. |
| 312 OMX_PARAM_PORTDEFINITIONTYPE port_format; | 323 OMX_PARAM_PORTDEFINITIONTYPE port_format; |
| 313 InitParam(*this, &port_format); | 324 InitParam(*this, &port_format); |
| 314 port_format.nPortIndex = output_port_; | 325 port_format.nPortIndex = output_port_; |
| 315 OMX_ERRORTYPE result = OMX_GetParameter(component_handle_, | 326 OMX_ERRORTYPE result = OMX_GetParameter(component_handle_, |
| 316 OMX_IndexParamPortDefinition, | 327 OMX_IndexParamPortDefinition, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 StopOnError(); | 360 StopOnError(); |
| 350 } | 361 } |
| 351 } | 362 } |
| 352 | 363 |
| 353 void OmxVideoDecodeAccelerator::ReusePictureBuffer(int32 picture_buffer_id) { | 364 void OmxVideoDecodeAccelerator::ReusePictureBuffer(int32 picture_buffer_id) { |
| 354 // TODO(vhiremath@nvidia.com) Avoid leaking of the picture buffer. | 365 // TODO(vhiremath@nvidia.com) Avoid leaking of the picture buffer. |
| 355 if (!CanFillBuffer()) | 366 if (!CanFillBuffer()) |
| 356 return; | 367 return; |
| 357 | 368 |
| 358 for (int i = 0; i < output_buffer_count_; ++i) { | 369 for (int i = 0; i < output_buffer_count_; ++i) { |
| 359 if (picture_buffer_id != assigned_picture_buffers_[i]->GetId()) | 370 if (picture_buffer_id != assigned_picture_buffers_[i]->id()) |
| 360 continue; | 371 continue; |
| 361 output_buffers_at_component_++; | 372 output_buffers_at_component_++; |
| 362 OMX_ERRORTYPE result = | 373 OMX_ERRORTYPE result = |
| 363 OMX_FillThisBuffer(component_handle_, output_pictures_[i].second); | 374 OMX_FillThisBuffer(component_handle_, output_pictures_[i].second); |
| 364 if (result != OMX_ErrorNone) { | 375 if (result != OMX_ErrorNone) { |
| 365 LOG(ERROR) << "OMX_FillThisBuffer() failed with result " << result; | 376 LOG(ERROR) << "OMX_FillThisBuffer() failed with result " << result; |
| 366 StopOnError(); | 377 StopOnError(); |
| 367 } | 378 } |
| 368 // Sent one buffer to omx. | 379 // Sent one buffer to omx. |
| 369 return; | 380 return; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 383 output_buffers_at_component_++; | 394 output_buffers_at_component_++; |
| 384 OMX_ERRORTYPE result = OMX_FillThisBuffer(component_handle_, omx_buffer); | 395 OMX_ERRORTYPE result = OMX_FillThisBuffer(component_handle_, omx_buffer); |
| 385 if (result != OMX_ErrorNone) { | 396 if (result != OMX_ErrorNone) { |
| 386 LOG(ERROR) << "OMX_FillThisBuffer() failed with result " << result; | 397 LOG(ERROR) << "OMX_FillThisBuffer() failed with result " << result; |
| 387 StopOnError(); | 398 StopOnError(); |
| 388 return; | 399 return; |
| 389 } | 400 } |
| 390 } | 401 } |
| 391 } | 402 } |
| 392 | 403 |
| 393 bool OmxVideoDecodeAccelerator::Flush( | 404 bool OmxVideoDecodeAccelerator::Flush() { |
| 394 const media::VideoDecodeAcceleratorCallback& callback) { | |
| 395 OMX_STATETYPE il_state; | 405 OMX_STATETYPE il_state; |
| 396 OMX_GetState(component_handle_, &il_state); | 406 OMX_GetState(component_handle_, &il_state); |
| 397 DCHECK_EQ(il_state, OMX_StateExecuting); | 407 DCHECK_EQ(il_state, OMX_StateExecuting); |
| 398 if (il_state != OMX_StateExecuting) { | 408 if (il_state != OMX_StateExecuting) { |
| 399 callback.Run(); | 409 client_->NotifyFlushDone(); |
| 400 return false; | 410 return false; |
| 401 } | 411 } |
| 402 on_buffer_flag_event_func_ = &OmxVideoDecodeAccelerator::FlushBegin; | 412 on_buffer_flag_event_func_ = &OmxVideoDecodeAccelerator::FlushBegin; |
| 403 flush_done_callback_ = callback; | |
| 404 | 413 |
| 405 OMX_BUFFERHEADERTYPE* omx_buffer = free_input_buffers_.front(); | 414 OMX_BUFFERHEADERTYPE* omx_buffer = free_input_buffers_.front(); |
| 406 free_input_buffers_.pop(); | 415 free_input_buffers_.pop(); |
| 407 omx_buffer->nFilledLen = 0; | 416 omx_buffer->nFilledLen = 0; |
| 408 omx_buffer->nAllocLen = omx_buffer->nFilledLen; | 417 omx_buffer->nAllocLen = omx_buffer->nFilledLen; |
| 409 omx_buffer->nFlags |= OMX_BUFFERFLAG_EOS; | 418 omx_buffer->nFlags |= OMX_BUFFERFLAG_EOS; |
| 410 omx_buffer->nTimeStamp = 0; | 419 omx_buffer->nTimeStamp = 0; |
| 411 // Give this buffer to OMX. | 420 // Give this buffer to OMX. |
| 412 OMX_ERRORTYPE result = OMX_ErrorNone; | 421 OMX_ERRORTYPE result = OMX_ErrorNone; |
| 413 result = OMX_EmptyThisBuffer(component_handle_, omx_buffer); | 422 result = OMX_EmptyThisBuffer(component_handle_, omx_buffer); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 VLOG(1) << "Output Port had been flushed"; | 480 VLOG(1) << "Output Port had been flushed"; |
| 472 DCHECK_EQ(output_buffers_at_component_, 0); | 481 DCHECK_EQ(output_buffers_at_component_, 0); |
| 473 } | 482 } |
| 474 | 483 |
| 475 client_state_ = OMX_StatePause; | 484 client_state_ = OMX_StatePause; |
| 476 // So Finally call OnPortCommandFlush which should | 485 // So Finally call OnPortCommandFlush which should |
| 477 // internally call DismissPictureBuffer(); | 486 // internally call DismissPictureBuffer(); |
| 478 OnPortCommandFlush(OMX_StateExecuting); | 487 OnPortCommandFlush(OMX_StateExecuting); |
| 479 } | 488 } |
| 480 | 489 |
| 481 bool OmxVideoDecodeAccelerator::Abort( | 490 bool OmxVideoDecodeAccelerator::Abort() { |
| 482 const media::VideoDecodeAcceleratorCallback& callback) { | |
| 483 // TODO(vhiremath@nvidia.com) | 491 // TODO(vhiremath@nvidia.com) |
| 484 // Need more thinking on this to handle w.r.t OMX. | 492 // Need more thinking on this to handle w.r.t OMX. |
| 485 // There is no explicit UnInitialize call for this. | 493 // There is no explicit UnInitialize call for this. |
| 486 // Also review again for trick modes. | 494 // Also review again for trick modes. |
| 487 callback.Run(); | 495 client_->NotifyAbortDone(); |
| 488 return true; | 496 return true; |
| 489 } | 497 } |
| 490 | 498 |
| 491 // Event callback during initialization to handle DoneStateSet to idle | 499 // Event callback during initialization to handle DoneStateSet to idle |
| 492 void OmxVideoDecodeAccelerator::OnStateChangeLoadedToIdle(OMX_STATETYPE state) { | 500 void OmxVideoDecodeAccelerator::OnStateChangeLoadedToIdle(OMX_STATETYPE state) { |
| 493 DCHECK_EQ(client_state_, OMX_StateLoaded); | 501 DCHECK_EQ(client_state_, OMX_StateLoaded); |
| 494 DCHECK_EQ(OMX_StateIdle, state); | 502 DCHECK_EQ(OMX_StateIdle, state); |
| 495 VLOG(1) << "OMX video decode engine is in Idle"; | 503 VLOG(1) << "OMX video decode engine is in Idle"; |
| 496 | 504 |
| 497 on_state_event_func_ = | 505 on_state_event_func_ = |
| 498 &OmxVideoDecodeAccelerator::OnStateChangeIdleToExecuting; | 506 &OmxVideoDecodeAccelerator::OnStateChangeIdleToExecuting; |
| 499 if (!TransitionToState(OMX_StateExecuting)) | 507 if (!TransitionToState(OMX_StateExecuting)) |
| 500 return; | 508 return; |
| 501 } | 509 } |
| 502 | 510 |
| 503 // Event callback during initialization to handle DoneStateSet to executing | 511 // Event callback during initialization to handle DoneStateSet to executing |
| 504 void OmxVideoDecodeAccelerator::OnStateChangeIdleToExecuting( | 512 void OmxVideoDecodeAccelerator::OnStateChangeIdleToExecuting( |
| 505 OMX_STATETYPE state) { | 513 OMX_STATETYPE state) { |
| 506 DCHECK_EQ(OMX_StateExecuting, state); | 514 DCHECK_EQ(OMX_StateExecuting, state); |
| 507 VLOG(1) << "OMX video decode engine is in Executing"; | 515 VLOG(1) << "OMX video decode engine is in Executing"; |
| 508 | 516 |
| 509 client_state_ = OMX_StateExecuting; | 517 client_state_ = OMX_StateExecuting; |
| 510 on_state_event_func_ = NULL; | 518 on_state_event_func_ = NULL; |
| 511 // This will kickoff the actual decoding | 519 // This will kickoff the actual decoding |
| 512 client_->NotifyResourcesAcquired(); | |
| 513 InitialFillBuffer(); | 520 InitialFillBuffer(); |
| 514 } | 521 } |
| 515 | 522 |
| 516 // Send state transition command to component. | 523 // Send state transition command to component. |
| 517 bool OmxVideoDecodeAccelerator::TransitionToState(OMX_STATETYPE new_state) { | 524 bool OmxVideoDecodeAccelerator::TransitionToState(OMX_STATETYPE new_state) { |
| 518 OMX_ERRORTYPE result = OMX_SendCommand(component_handle_, | 525 OMX_ERRORTYPE result = OMX_SendCommand(component_handle_, |
| 519 OMX_CommandStateSet, | 526 OMX_CommandStateSet, |
| 520 new_state, 0); | 527 new_state, 0); |
| 521 if (result != OMX_ErrorNone) { | 528 if (result != OMX_ErrorNone) { |
| 522 LOG(ERROR) << "SendCommand(OMX_CommandStateSet) failed"; | 529 LOG(ERROR) << "SendCommand(OMX_CommandStateSet) failed"; |
| 523 StopOnError(); | 530 StopOnError(); |
| 524 return false; | 531 return false; |
| 525 } | 532 } |
| 526 return true; | 533 return true; |
| 527 } | 534 } |
| 528 | 535 |
| 529 void OmxVideoDecodeAccelerator::OnPortCommandFlush(OMX_STATETYPE state) { | 536 void OmxVideoDecodeAccelerator::OnPortCommandFlush(OMX_STATETYPE state) { |
| 530 DCHECK_EQ(state, OMX_StateExecuting); | 537 DCHECK_EQ(state, OMX_StateExecuting); |
| 531 | 538 |
| 532 VLOG(1) << "Deinit from Executing"; | 539 VLOG(1) << "Deinit from Executing"; |
| 533 on_state_event_func_ = | 540 on_state_event_func_ = |
| 534 &OmxVideoDecodeAccelerator::OnStateChangeExecutingToIdle; | 541 &OmxVideoDecodeAccelerator::OnStateChangeExecutingToIdle; |
| 535 TransitionToState(OMX_StateIdle); | 542 TransitionToState(OMX_StateIdle); |
| 536 for (int i = 0; i < output_buffer_count_; ++i) { | 543 for (int i = 0; i < output_buffer_count_; ++i) { |
| 537 OutputPicture output_picture = output_pictures_[i]; | 544 OutputPicture output_picture = output_pictures_[i]; |
| 538 client_->DismissPictureBuffer(output_picture.first); | 545 client_->DismissPictureBuffer(output_picture.first); |
| 539 } | 546 } |
| 547 STLDeleteElements(&assigned_picture_buffers_); |
| 540 } | 548 } |
| 541 | 549 |
| 542 void OmxVideoDecodeAccelerator::OnStateChangeExecutingToIdle( | 550 void OmxVideoDecodeAccelerator::OnStateChangeExecutingToIdle( |
| 543 OMX_STATETYPE state) { | 551 OMX_STATETYPE state) { |
| 544 DCHECK_EQ(state, OMX_StateIdle); | 552 DCHECK_EQ(state, OMX_StateIdle); |
| 545 | 553 |
| 546 VLOG(1) << "Deinit from Idle"; | 554 VLOG(1) << "Deinit from Idle"; |
| 547 on_state_event_func_ = | 555 on_state_event_func_ = |
| 548 &OmxVideoDecodeAccelerator::OnStateChangeIdleToLoaded; | 556 &OmxVideoDecodeAccelerator::OnStateChangeIdleToLoaded; |
| 549 TransitionToState(OMX_StateLoaded); | 557 TransitionToState(OMX_StateLoaded); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 562 | 570 |
| 563 if (component_handle_) { | 571 if (component_handle_) { |
| 564 OMX_ERRORTYPE result = (*omx_free_handle)(component_handle_); | 572 OMX_ERRORTYPE result = (*omx_free_handle)(component_handle_); |
| 565 if (result != OMX_ErrorNone) | 573 if (result != OMX_ErrorNone) |
| 566 LOG(ERROR) << "OMX_FreeHandle() error. Error code: " << result; | 574 LOG(ERROR) << "OMX_FreeHandle() error. Error code: " << result; |
| 567 component_handle_ = NULL; | 575 component_handle_ = NULL; |
| 568 } | 576 } |
| 569 client_state_ = OMX_StateLoaded; | 577 client_state_ = OMX_StateLoaded; |
| 570 (*omx_deinit)(); | 578 (*omx_deinit)(); |
| 571 VLOG(1) << "OMX Deinit Clean exit done"; | 579 VLOG(1) << "OMX Deinit Clean exit done"; |
| 572 flush_done_callback_.Run(); | 580 client_->NotifyFlushDone(); |
| 573 } | 581 } |
| 574 | 582 |
| 575 void OmxVideoDecodeAccelerator::StopOnError() { | 583 void OmxVideoDecodeAccelerator::StopOnError() { |
| 576 OMX_STATETYPE il_state; | 584 OMX_STATETYPE il_state; |
| 577 OMX_GetState(component_handle_, &il_state); | 585 OMX_GetState(component_handle_, &il_state); |
| 578 client_state_ = OMX_StateInvalid; | 586 client_state_ = OMX_StateInvalid; |
| 579 switch (il_state) { | 587 switch (il_state) { |
| 580 case OMX_StateExecuting: | 588 case OMX_StateExecuting: |
| 581 OnPortCommandFlush(OMX_StateExecuting); | 589 OnPortCommandFlush(OMX_StateExecuting); |
| 582 return; | 590 return; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 604 return false; | 612 return false; |
| 605 buffer->nInputPortIndex = input_port_; | 613 buffer->nInputPortIndex = input_port_; |
| 606 buffer->nOffset = 0; | 614 buffer->nOffset = 0; |
| 607 buffer->nFlags = 0; | 615 buffer->nFlags = 0; |
| 608 free_input_buffers_.push(buffer); | 616 free_input_buffers_.push(buffer); |
| 609 } | 617 } |
| 610 return true; | 618 return true; |
| 611 } | 619 } |
| 612 | 620 |
| 613 bool OmxVideoDecodeAccelerator::AllocateOutputBuffers() { | 621 bool OmxVideoDecodeAccelerator::AllocateOutputBuffers() { |
| 614 OMX_BUFFERHEADERTYPE* buffer; | |
| 615 Picture* picture; | |
| 616 OMX_ERRORTYPE result; | |
| 617 gfx::Size decoded_pixel_size(width_, height_); | 622 gfx::Size decoded_pixel_size(width_, height_); |
| 618 gfx::Size visible_pixel_size(width_, height_); | 623 gfx::Size visible_pixel_size(width_, height_); |
| 619 | 624 // TODO(fischman): remove garbage bitstream buffer id's below (42 and 24) when |
| 625 // the bitstream_buffer_id field is removed from Picture. |
| 620 if (uses_egl_image_) { | 626 if (uses_egl_image_) { |
| 621 media::VideoDecodeAccelerator::PictureBuffer::DataPlaneHandle egl_ids; | |
| 622 std::vector<PictureBuffer::DataPlaneHandle> planes; | |
| 623 uint32 texture; | |
| 624 | |
| 625 for (uint32 i = 0; i < assigned_picture_buffers_.size(); i++) { | 627 for (uint32 i = 0; i < assigned_picture_buffers_.size(); i++) { |
| 626 picture = new media::Picture( | 628 media::GLESBuffer* gles_buffer = |
| 627 reinterpret_cast<media::PictureBuffer*>(assigned_picture_buffers_[i]), | 629 reinterpret_cast<media::GLESBuffer*>(assigned_picture_buffers_[i]); |
| 628 decoded_pixel_size, visible_pixel_size, | 630 OMX_BUFFERHEADERTYPE* omx_buffer; |
| 629 static_cast<void*>(component_handle_)); | 631 void* egl = texture2eglImage_translator->TranslateToEglImage( |
| 630 | 632 gles_buffer->texture_id()); |
| 631 planes = assigned_picture_buffers_[i]->GetPlaneHandles(); | 633 OMX_ERRORTYPE result = OMX_UseEGLImage( |
| 632 egl_ids = planes[i]; | 634 component_handle_, &omx_buffer, output_port_, gles_buffer, egl); |
| 633 texture = egl_ids.texture_id; | |
| 634 egl_image_ = texture2eglImage_translator->TranslateToEglImage(texture); | |
| 635 result = OMX_UseEGLImage( | |
| 636 component_handle_, | |
| 637 &buffer, | |
| 638 output_port_, | |
| 639 reinterpret_cast<media::PictureBuffer*>(assigned_picture_buffers_[i]), | |
| 640 egl_image_); | |
| 641 | |
| 642 if (result != OMX_ErrorNone) { | 635 if (result != OMX_ErrorNone) { |
| 643 LOG(ERROR) << "OMX_UseEGLImage failed"; | 636 LOG(ERROR) << "OMX_UseEGLImage failed"; |
| 644 return false; | 637 return false; |
| 645 } | 638 } |
| 639 omx_buffer->pAppPrivate = |
| 640 new media::Picture(gles_buffer->id(), |
| 641 42 /* garbage bitstreambuffer id */, |
| 642 decoded_pixel_size, visible_pixel_size); |
| 646 output_pictures_.push_back( | 643 output_pictures_.push_back( |
| 647 std::make_pair( | 644 std::make_pair(assigned_picture_buffers_[i]->id(), omx_buffer)); |
| 648 reinterpret_cast<media::PictureBuffer*>( | |
| 649 assigned_picture_buffers_[i]), | |
| 650 buffer)); | |
| 651 buffer->pAppPrivate = picture; | |
| 652 } | 645 } |
| 653 } else { | 646 } else { |
| 654 for (uint32 i = 0; i < assigned_picture_buffers_.size(); i++) { | 647 for (uint32 i = 0; i < assigned_picture_buffers_.size(); i++) { |
| 655 picture = new media::Picture( | 648 media::SysmemBuffer* sysmem_buffer = |
| 656 reinterpret_cast<media::PictureBuffer*>(assigned_picture_buffers_[i]), | 649 reinterpret_cast<media::SysmemBuffer*>(assigned_picture_buffers_[i]); |
| 657 decoded_pixel_size, visible_pixel_size, | 650 OMX_BUFFERHEADERTYPE* omx_buffer; |
| 658 static_cast<void*>(component_handle_)); | 651 OMX_ERRORTYPE result = OMX_AllocateBuffer( |
| 659 | 652 component_handle_, &omx_buffer, output_port_, NULL, |
| 660 result = OMX_AllocateBuffer(component_handle_, &buffer, output_port_, | 653 output_buffer_size_); |
| 661 NULL, output_buffer_size_); | |
| 662 if (result != OMX_ErrorNone) | 654 if (result != OMX_ErrorNone) |
| 663 return false; | 655 return false; |
| 656 omx_buffer->pAppPrivate = new media::Picture( |
| 657 sysmem_buffer->id(), |
| 658 24 /* garbage bitstreambuffer id */, |
| 659 decoded_pixel_size, visible_pixel_size); |
| 664 output_pictures_.push_back( | 660 output_pictures_.push_back( |
| 665 std::make_pair( | 661 std::make_pair(sysmem_buffer->id(), omx_buffer)); |
| 666 reinterpret_cast<media::PictureBuffer*>( | |
| 667 assigned_picture_buffers_[i]), | |
| 668 buffer)); | |
| 669 buffer->pAppPrivate = picture; | |
| 670 } | 662 } |
| 671 } | 663 } |
| 672 return true; | 664 return true; |
| 673 } | 665 } |
| 674 | 666 |
| 675 void OmxVideoDecodeAccelerator::FreeInputBuffers() { | 667 void OmxVideoDecodeAccelerator::FreeInputBuffers() { |
| 676 // Calls to OMX to free buffers. | 668 // Calls to OMX to free buffers. |
| 677 OMX_ERRORTYPE result; | 669 OMX_ERRORTYPE result; |
| 678 OMX_BUFFERHEADERTYPE* omx_buffer; | 670 OMX_BUFFERHEADERTYPE* omx_buffer; |
| 679 while (!free_input_buffers_.empty()) { | 671 while (!free_input_buffers_.empty()) { |
| 680 omx_buffer = free_input_buffers_.front(); | 672 omx_buffer = free_input_buffers_.front(); |
| 681 free_input_buffers_.pop(); | 673 free_input_buffers_.pop(); |
| 682 result = OMX_FreeBuffer(component_handle_, input_port_, omx_buffer); | 674 result = OMX_FreeBuffer(component_handle_, input_port_, omx_buffer); |
| 683 if (result != OMX_ErrorNone) { | 675 if (result != OMX_ErrorNone) { |
| 684 LOG(ERROR) << "SendCommand(OMX_CommandPortDisable) failed"; | 676 LOG(ERROR) << "SendCommand(OMX_CommandPortDisable) failed"; |
| 685 StopOnError(); | 677 StopOnError(); |
| 686 return; | 678 return; |
| 687 } | 679 } |
| 688 } | 680 } |
| 689 } | 681 } |
| 690 | 682 |
| 691 void OmxVideoDecodeAccelerator::FreeOutputBuffers() { | 683 void OmxVideoDecodeAccelerator::FreeOutputBuffers() { |
| 692 // Calls to OMX to free buffers. | 684 // Calls to OMX to free buffers. |
| 693 OMX_ERRORTYPE result; | 685 OMX_ERRORTYPE result; |
| 694 for (size_t i = 0; i < output_pictures_.size(); ++i) { | 686 for (size_t i = 0; i < output_pictures_.size(); ++i) { |
| 695 OMX_BUFFERHEADERTYPE* omx_buffer = output_pictures_[i].second; | 687 OMX_BUFFERHEADERTYPE* omx_buffer = output_pictures_[i].second; |
| 696 CHECK(omx_buffer); | 688 CHECK(omx_buffer); |
| 689 delete reinterpret_cast<media::Picture*>(omx_buffer->pAppPrivate); |
| 697 result = OMX_FreeBuffer(component_handle_, output_port_, omx_buffer); | 690 result = OMX_FreeBuffer(component_handle_, output_port_, omx_buffer); |
| 698 if (result != OMX_ErrorNone) { | 691 if (result != OMX_ErrorNone) { |
| 699 LOG(ERROR) << "SendCommand(OMX_CommandPortDisable) failed"; | 692 LOG(ERROR) << "SendCommand(OMX_CommandPortDisable) failed"; |
| 700 StopOnError(); | 693 StopOnError(); |
| 701 return; | 694 return; |
| 702 } | 695 } |
| 703 } | 696 } |
| 704 output_pictures_.clear(); | 697 output_pictures_.clear(); |
| 705 } | 698 } |
| 706 | 699 |
| 707 void OmxVideoDecodeAccelerator::OnPortSettingsChangedRun( | 700 void OmxVideoDecodeAccelerator::OnPortSettingsChangedRun( |
| 708 int port, OMX_INDEXTYPE index) { | 701 int port, OMX_INDEXTYPE index) { |
| 709 // TODO(vhiremath@nvidia.com) visit again later | 702 // TODO(vhiremath@nvidia.com) visit again later |
| 710 // Port settings changes can be called during run time | 703 // Port settings changes can be called during run time |
| 711 // changes in the resolution of video playback. | 704 // changes in the resolution of video playback. |
| 712 // In this case, the component detects PortSettingsChanged | 705 // In this case, the component detects PortSettingsChanged |
| 713 // and sends the particular event to the IL-client. | 706 // and sends the particular event to the IL-client. |
| 714 // This needs to be handled in this method. | 707 // This needs to be handled in this method. |
| 715 return; | 708 return; |
| 716 } | 709 } |
| 717 | 710 |
| 718 void OmxVideoDecodeAccelerator::FillBufferDoneTask( | 711 void OmxVideoDecodeAccelerator::FillBufferDoneTask( |
| 719 OMX_BUFFERHEADERTYPE* buffer) { | 712 OMX_BUFFERHEADERTYPE* buffer) { |
| 720 DCHECK_GT(output_buffers_at_component_, 0); | 713 DCHECK_GT(output_buffers_at_component_, 0); |
| 721 output_buffers_at_component_--; | 714 output_buffers_at_component_--; |
| 722 client_->PictureReady(reinterpret_cast<Picture*>(buffer->pAppPrivate)); | 715 client_->PictureReady(*reinterpret_cast<media::Picture*>( |
| 716 buffer->pAppPrivate)); |
| 723 } | 717 } |
| 724 | 718 |
| 725 void OmxVideoDecodeAccelerator::EmptyBufferDoneTask( | 719 void OmxVideoDecodeAccelerator::EmptyBufferDoneTask( |
| 726 OMX_BUFFERHEADERTYPE* buffer) { | 720 OMX_BUFFERHEADERTYPE* buffer) { |
| 727 DCHECK_GT(input_buffers_at_component_, 0); | 721 DCHECK_GT(input_buffers_at_component_, 0); |
| 728 free_input_buffers_.push(buffer); | 722 free_input_buffers_.push(buffer); |
| 729 input_buffers_at_component_--; | 723 input_buffers_at_component_--; |
| 730 if (buffer->nFlags & OMX_BUFFERFLAG_EOS) | 724 if (buffer->nFlags & OMX_BUFFERFLAG_EOS) |
| 731 return; | 725 return; |
| 732 // Retrieve the corresponding callback and run it. | 726 // Retrieve the corresponding BitstreamBuffer's id and notify the client of |
| 733 OMXBufferCallbackMap::iterator it = omx_buff_cb_.find(buffer); | 727 // its completion. |
| 734 if (it == omx_buff_cb_.end()) { | 728 OMXBufferIdMap::iterator it = omx_buff_ids_.find(buffer); |
| 735 LOG(ERROR) << "Unexpectedly failed to find a buffer callback."; | 729 if (it == omx_buff_ids_.end()) { |
| 730 LOG(ERROR) << "Unexpectedly failed to find a buffer id."; |
| 736 StopOnError(); | 731 StopOnError(); |
| 737 return; | 732 return; |
| 738 } | 733 } |
| 739 delete it->second.first; | 734 delete it->second.first; |
| 740 it->second.second.Run(); | 735 client_->NotifyEndOfBitstreamBuffer(it->second.second); |
| 741 omx_buff_cb_.erase(it); | 736 omx_buff_ids_.erase(it); |
| 742 } | 737 } |
| 743 | 738 |
| 744 void OmxVideoDecodeAccelerator::EventHandlerCompleteTask(OMX_EVENTTYPE event, | 739 void OmxVideoDecodeAccelerator::EventHandlerCompleteTask(OMX_EVENTTYPE event, |
| 745 OMX_U32 data1, | 740 OMX_U32 data1, |
| 746 OMX_U32 data2) { | 741 OMX_U32 data2) { |
| 747 switch (event) { | 742 switch (event) { |
| 748 case OMX_EventCmdComplete: { | 743 case OMX_EventCmdComplete: { |
| 749 // If the last command was successful, we have completed | 744 // If the last command was successful, we have completed |
| 750 // a state transition. So notify that we have done it | 745 // a state transition. So notify that we have done it |
| 751 // accordingly. | 746 // accordingly. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 OMX_ERRORTYPE OmxVideoDecodeAccelerator::EventHandler(OMX_HANDLETYPE component, | 798 OMX_ERRORTYPE OmxVideoDecodeAccelerator::EventHandler(OMX_HANDLETYPE component, |
| 804 OMX_PTR priv_data, | 799 OMX_PTR priv_data, |
| 805 OMX_EVENTTYPE event, | 800 OMX_EVENTTYPE event, |
| 806 OMX_U32 data1, | 801 OMX_U32 data1, |
| 807 OMX_U32 data2, | 802 OMX_U32 data2, |
| 808 OMX_PTR event_data) { | 803 OMX_PTR event_data) { |
| 809 OmxVideoDecodeAccelerator* decoder = | 804 OmxVideoDecodeAccelerator* decoder = |
| 810 static_cast<OmxVideoDecodeAccelerator*>(priv_data); | 805 static_cast<OmxVideoDecodeAccelerator*>(priv_data); |
| 811 DCHECK_EQ(component, decoder->component_handle_); | 806 DCHECK_EQ(component, decoder->component_handle_); |
| 812 | 807 |
| 813 decoder->message_loop_->PostTask(FROM_HERE, | 808 decoder->message_loop_->PostTask( |
| 814 NewRunnableMethod(decoder, | 809 FROM_HERE, |
| 815 &OmxVideoDecodeAccelerator::EventHandlerCompleteTask, | 810 NewRunnableMethod(decoder, |
| 816 event, data1, data2)); | 811 &OmxVideoDecodeAccelerator::EventHandlerCompleteTask, |
| 812 event, data1, data2)); |
| 817 | 813 |
| 818 return OMX_ErrorNone; | 814 return OMX_ErrorNone; |
| 819 } | 815 } |
| 820 | 816 |
| 821 // static | 817 // static |
| 822 OMX_ERRORTYPE OmxVideoDecodeAccelerator::EmptyBufferCallback( | 818 OMX_ERRORTYPE OmxVideoDecodeAccelerator::EmptyBufferCallback( |
| 823 OMX_HANDLETYPE component, | 819 OMX_HANDLETYPE component, |
| 824 OMX_PTR priv_data, | 820 OMX_PTR priv_data, |
| 825 OMX_BUFFERHEADERTYPE* buffer) { | 821 OMX_BUFFERHEADERTYPE* buffer) { |
| 826 OmxVideoDecodeAccelerator* decoder = | 822 OmxVideoDecodeAccelerator* decoder = |
| (...skipping 10 matching lines...) Expand all Loading... |
| 837 | 833 |
| 838 // static | 834 // static |
| 839 OMX_ERRORTYPE OmxVideoDecodeAccelerator::FillBufferCallback( | 835 OMX_ERRORTYPE OmxVideoDecodeAccelerator::FillBufferCallback( |
| 840 OMX_HANDLETYPE component, | 836 OMX_HANDLETYPE component, |
| 841 OMX_PTR priv_data, | 837 OMX_PTR priv_data, |
| 842 OMX_BUFFERHEADERTYPE* buffer) { | 838 OMX_BUFFERHEADERTYPE* buffer) { |
| 843 OmxVideoDecodeAccelerator* decoder = | 839 OmxVideoDecodeAccelerator* decoder = |
| 844 static_cast<OmxVideoDecodeAccelerator*>(priv_data); | 840 static_cast<OmxVideoDecodeAccelerator*>(priv_data); |
| 845 DCHECK_EQ(component, decoder->component_handle_); | 841 DCHECK_EQ(component, decoder->component_handle_); |
| 846 | 842 |
| 847 decoder->message_loop_->PostTask(FROM_HERE, | 843 decoder->message_loop_->PostTask( |
| 844 FROM_HERE, |
| 848 NewRunnableMethod( | 845 NewRunnableMethod( |
| 849 decoder, | 846 decoder, |
| 850 &OmxVideoDecodeAccelerator::FillBufferDoneTask, buffer)); | 847 &OmxVideoDecodeAccelerator::FillBufferDoneTask, buffer)); |
| 851 return OMX_ErrorNone; | 848 return OMX_ErrorNone; |
| 852 } | 849 } |
| 853 | 850 |
| 854 bool OmxVideoDecodeAccelerator::CanAcceptInput() { | 851 bool OmxVideoDecodeAccelerator::CanAcceptInput() { |
| 855 // We can't take input buffer when in error state. | 852 // We can't take input buffer when in error state. |
| 856 return (client_state_ != OMX_StateInvalid && | 853 return (client_state_ != OMX_StateInvalid && |
| 857 client_state_ != OMX_StatePause && | 854 client_state_ != OMX_StatePause && |
| (...skipping 22 matching lines...) Expand all Loading... |
| 880 OMX_ERRORTYPE result = OMX_SendCommand(component_handle_, | 877 OMX_ERRORTYPE result = OMX_SendCommand(component_handle_, |
| 881 cmd, port_index, 0); | 878 cmd, port_index, 0); |
| 882 if (result != OMX_ErrorNone) { | 879 if (result != OMX_ErrorNone) { |
| 883 LOG(ERROR) << "SendCommand(OMX_CommandPortDisable) failed"; | 880 LOG(ERROR) << "SendCommand(OMX_CommandPortDisable) failed"; |
| 884 StopOnError(); | 881 StopOnError(); |
| 885 return; | 882 return; |
| 886 } | 883 } |
| 887 } | 884 } |
| 888 | 885 |
| 889 DISABLE_RUNNABLE_METHOD_REFCOUNT(OmxVideoDecodeAccelerator); | 886 DISABLE_RUNNABLE_METHOD_REFCOUNT(OmxVideoDecodeAccelerator); |
| OLD | NEW |