------------------------------------------------------------------------------ | OpenMAXILTextureLoader::loadTexture +-----------------------------------------------------------------------------*/
| 117 | | OpenMAXILTextureLoader::loadTexture |
| 118 | +-----------------------------------------------------------------------------*/ |
| 119 | inline |
| 120 | void OpenMAXILTextureLoader::doLoadTextureFromImage( |
| 121 | QString fileAbsPath, |
| 122 | EGLDisplay eglDisplay, |
| 123 | EGLContext eglContext, |
| 124 | GLuint& texture |
| 125 | ) |
| 126 | { |
| 127 | QFile file(fileAbsPath); |
| 128 | if (!file.exists()) |
| 129 | throw runtime_error("File does not exist."); |
| 130 | if (!file.open(QIODevice::ReadOnly)) |
| 131 | throw runtime_error("Failed to open file."); |
| 132 | |
| 133 | core = OMX_Core::instance(); |
| 134 | Q_UNUSED(core); |
| 135 | |
| 136 | // Get components. |
| 137 | compImageDecoder = OMXComponentFactory<OMXComponent>::getInstance("OMX.broadcom.image_decode"); |
| 138 | compEGLRender = OMXComponentFactory<OMXComponent>::getInstance("OMX.broadcom.egl_render"); |
| 139 | |
| 140 | // Check the number of ports is correct. |
| 141 | OMX_PORT_PARAM_TYPE port; |
| 142 | port.nSize = sizeof(OMX_PORT_PARAM_TYPE); |
| 143 | port.nVersion.nVersion = OMX_VERSION; |
| 144 | compImageDecoder->GetParameter(OMX_IndexParamImageInit, &port); |
| 145 | if (port.nPorts != 2) |
| 146 | throw runtime_error("Unexpected number of ports returned from decoder."); |
| 147 | m_iInPortDecode = port.nStartPortNumber; |
| 148 | m_iOutPortDecode = port.nStartPortNumber + 1; |
| 149 | |
| 150 | compEGLRender->GetParameter(OMX_IndexParamVideoInit, &port); |
| 151 | if (port.nPorts != 2) |
| 152 | throw runtime_error("Unexpected number of ports returned from renderer."); |
| 153 | m_iInPortRender = port.nStartPortNumber; |
| 154 | m_iOutPortRender = port.nStartPortNumber + 1; |
| 155 | |
| 156 | // Disable all ports. |
| 157 | LOG_VERBOSE(LOG_TAG, "Disabling all the ports..."); |
| 158 | compImageDecoder->sendCommand(OMX_CommandPortDisable, m_iInPortDecode, NULL); |
| 159 | compImageDecoder->waitForEvent(OMX_EventCmdComplete, OMX_CommandPortDisable, m_iInPortDecode, TIMEOUT_MS); |
| 160 | compImageDecoder->sendCommand(OMX_CommandPortDisable, m_iOutPortDecode, NULL); |
| 161 | compImageDecoder->waitForEvent(OMX_EventCmdComplete, OMX_CommandPortDisable, m_iOutPortDecode, TIMEOUT_MS); |
| 162 | compEGLRender->sendCommand(OMX_CommandPortDisable, m_iInPortRender, NULL); |
| 163 | compEGLRender->waitForEvent(OMX_EventCmdComplete, OMX_CommandPortDisable, m_iInPortRender, TIMEOUT_MS); |
| 164 | compEGLRender->sendCommand(OMX_CommandPortDisable, m_iOutPortRender, NULL); |
| 165 | compEGLRender->waitForEvent(OMX_EventCmdComplete, OMX_CommandPortDisable, m_iOutPortRender, TIMEOUT_MS); |
| 166 | LOG_VERBOSE(LOG_TAG, "All the ports were disabled."); |
| 167 | |
| 168 | // move decoder component into idle state |
| 169 | LOG_VERBOSE(LOG_TAG, "Changing decoder state to IDLE..."); |
| 170 | compImageDecoder->sendCommand(OMX_CommandStateSet, OMX_StateIdle, NULL); |
| 171 | compImageDecoder->waitForEvent(OMX_EventCmdComplete, OMX_CommandStateSet, OMX_StateIdle, TIMEOUT_MS); |
| 172 | LOG_VERBOSE(LOG_TAG, "Decoder state changed to IDLE."); |
| 173 | |
| 174 | // Set input format. |
| 175 | OMX_IMAGE_PARAM_PORTFORMATTYPE portFormat; |
| 176 | OMX_INIT_STRUCTURE(portFormat); |
nothing calls this directly
no test coverage detected