void CDVDVideoCodecHybris::InitSurfaceTexture(void) { REPORT_FUNCTION(); // We MUST create the GLES texture on the main thread // to match where the valid GLES context is located. // It would be nice to move this out of here, we would need // to create/fetch/create from g_RenderMananger. But g_RenderMananger // does not know we are using MediaCodec until Configure and we // we need m_surfaceTexture valid before then. Chicken, meet Egg. if (g_application.IsCurrentThread()) { // localize GLuint so we do not spew gles includes in our header GLuint texture_id; glGenTextures(1, &texture_id); glBindTexture( GL_TEXTURE_EXTERNAL_OES, texture_id); glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glBindTexture( GL_TEXTURE_EXTERNAL_OES, 0); m_textureId = texture_id; CLog::Log(LOGNOTICE, "%s::%s::%d - m_textureId = %x", CLASSNAME, __func__, __LINE__,(unsigned int)m_textureId); //m_surfaceTexture = std::shared_ptr<CJNISurfaceTexture>(new CJNISurfaceTexture(m_textureId)); decoding_service_init(); decoding_service_set_client_death_cb(&on_client_died_cb, 123, static_cast<void*>(this)); DSSessionWrapperHybris decoding_session = decoding_service_create_session(123); CLog::Log(LOGNOTICE, "%s::%s::%d - decoding_session = %x", CLASSNAME, __func__, __LINE__,(unsigned int)decoding_session); IGBCWrapperHybris igbc_wrapper = decoding_service_get_igraphicbufferconsumer(); CLog::Log(LOGNOTICE, "%s::%s::%d - igbc_wrapper = %x", CLASSNAME, __func__, __LINE__,(unsigned int)igbc_wrapper); m_surfaceTexture = gl_consumer_create_by_id_with_igbc(m_textureId, igbc_wrapper ); CLog::Log(LOGNOTICE, "%s::%s::%d - m_surfaceTexture = %x", CLASSNAME, __func__, __LINE__,(unsigned int)m_surfaceTexture); // hook the surfaceTexture OnFrameAvailable callback m_frameAvailable = std::shared_ptr<CDVDMediaCodecOnFrameAvailable>(new CDVDMediaCodecOnFrameAvailable(m_surfaceTexture)); CLog::Log(LOGNOTICE, "%s::%s::%d - m_frameAvailable = %x", CLASSNAME, __func__, __LINE__,(unsigned int)&(*m_frameAvailable)); IGBPWrapperHybris igbp = decoding_service_get_igraphicbufferproducer(); CLog::Log(LOGNOTICE, "%s::%s::%d - igbp = %x", CLASSNAME, __func__, __LINE__,(unsigned int)igbp); m_surface = surface_texture_client_create_by_igbp(igbp); CLog::Log(LOGNOTICE, "%s::%s::%d - m_surface = %x", CLASSNAME, __func__, __LINE__,(unsigned int)m_surface); surface_texture_client_set_hardware_rendering (m_surface, true); } else { ThreadMessageCallback callbackData; callbackData.callback = &CallbackInitSurfaceTexture; callbackData.userptr = (void*)this; ThreadMessage msg; msg.dwMessage = TMSG_CALLBACK; msg.lpVoid = (void*)&callbackData; // wait for it. CApplicationMessenger::Get().SendMessage(msg, true); } return; }
static void gst_mir_sink_create_surface_texture (GObject * object) { GstMirSink *sink = GST_MIR_SINK (object); /* Create a new SurfaceTextureClientHybris instance from a texture ID */ sink->surface_texture_client = surface_texture_client_create_by_id (sink->texture_id); GST_DEBUG_OBJECT (sink, "Created new SurfaceTextureClientHybris instance: %p", sink->surface_texture_client); /* Because mirsink is being loaded, we are definitely doing * hardware rendering. */ surface_texture_client_set_hardware_rendering (sink->surface_texture_client, TRUE); /* Signal the client API that a surface_texture_client instance has been set */ g_signal_emit (G_OBJECT (sink), surface_texture_client_set_signal, 0, (gpointer) sink->surface_texture_client); }