------------------------------------------------------------------------------ | OpenMAXILTextureLoader::onDecoderOutputChanged +-----------------------------------------------------------------------------*/
| 378 | | OpenMAXILTextureLoader::onDecoderOutputChanged |
| 379 | +-----------------------------------------------------------------------------*/ |
| 380 | void OpenMAXILTextureLoader::onDecoderOutputChangedImage( |
| 381 | EGLDisplay eglDisplay, |
| 382 | EGLContext eglContext, |
| 383 | GLuint& texture |
| 384 | ) |
| 385 | { |
| 386 | // Setup the input for the render with the output of the decoder. |
| 387 | OMX_PARAM_PORTDEFINITIONTYPE portdef; |
| 388 | portdef.nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE); |
| 389 | OMX_INIT_STRUCTURE(portdef); |
| 390 | portdef.nPortIndex = m_iOutPortDecode; |
| 391 | compImageDecoder->GetParameter(OMX_IndexParamPortDefinition, &portdef); |
| 392 | portdef.nPortIndex = m_iInPortRender; |
| 393 | compEGLRender->SetParameter(OMX_IndexParamPortDefinition, &portdef); |
| 394 | |
| 395 | // Tunnel output of the decoder with the input of the renderer. |
| 396 | compImageDecoder->SetupTunnel(m_iOutPortDecode, compEGLRender.get(), m_iInPortRender); |
| 397 | |
| 398 | // Enable the ports involved in the tunnel. |
| 399 | compImageDecoder->sendCommand(OMX_CommandPortEnable, m_iOutPortDecode, NULL); |
| 400 | compEGLRender->sendCommand(OMX_CommandPortEnable, m_iInPortRender, NULL); |
| 401 | |
| 402 | // Put renderer in idle state (this allows the outport of the decoder to become enabled). |
| 403 | compEGLRender->sendCommand(OMX_CommandStateSet, OMX_StateIdle, NULL); |
| 404 | compEGLRender->waitForEvent(OMX_EventCmdComplete, OMX_CommandStateSet, OMX_StateIdle, TIMEOUT_MS); |
| 405 | |
| 406 | // Once the state changes, both ports should become enabled and the renderer output |
| 407 | // should generate a settings changed event. |
| 408 | compImageDecoder->waitForEvent(OMX_EventCmdComplete, OMX_CommandPortEnable, m_iOutPortDecode, TIMEOUT_MS); |
| 409 | compEGLRender->waitForEvent(OMX_EventCmdComplete, OMX_CommandPortEnable, m_iInPortRender, TIMEOUT_MS); |
| 410 | compEGLRender->waitForEvent(OMX_EventPortSettingsChanged, m_iOutPortRender, 0, TIMEOUT_MS); |
| 411 | |
| 412 | // NOTE : OpenMAX official spec says that upon receving OMX_EventPortSettingsChanged event, the |
| 413 | // port shall be disabled and then re-enabled (see 3.1.1.4.4 of IL v1.2.0 specification), |
| 414 | // but since we have not enabled the port, I don't think we need to do anything. |
| 415 | |
| 416 | // Query output buffer requirements for renderer and provide the native display |
| 417 | // the renderer will use. |
| 418 | portdef.nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE); |
| 419 | portdef.nVersion.nVersion = OMX_VERSION; |
| 420 | portdef.nPortIndex = m_iOutPortRender; |
| 421 | compEGLRender->GetParameter(OMX_IndexParamPortDefinition, &portdef); |
| 422 | portdef.format.video.pNativeWindow = eglDisplay; |
| 423 | compEGLRender->SetParameter(OMX_IndexParamPortDefinition, &portdef); |
| 424 | |
| 425 | // Assume this, if it's not true, more code will need to be written to handle it. |
| 426 | assert(portdef.nBufferCountActual == 1); |
| 427 | |
| 428 | // Put renderer in EXECUTING and wait for port settings changed event. |
| 429 | compEGLRender->sendCommand(OMX_CommandStateSet, OMX_StateExecuting, NULL); |
| 430 | compEGLRender->waitForEvent(OMX_EventCmdComplete, OMX_CommandStateSet, OMX_StateExecuting, TIMEOUT_MS); |
| 431 | |
| 432 | // show some logging so user knows it's working |
| 433 | char sLog[300]; |
| 434 | snprintf(sLog, sizeof(sLog), "Width: %u Height: %u Output Color Format: 0x%x Buffer Size: %u", |
| 435 | (unsigned int) portdef.format.video.nFrameWidth, |
| 436 | (unsigned int) portdef.format.video.nFrameHeight, |
| 437 | (unsigned int) portdef.format.video.eColorFormat, |
nothing calls this directly
no test coverage detected