21QOhosSurfaceImage::QOhosSurfaceImage(uint32_t glTextureId, QObject *parent)
22 : QObject(parent), m_textureId(glTextureId)
24 m_index = s_nextIndex.fetch_add(1);
26 m_image = OH_NativeImage_Create(glTextureId, kGlTextureExternalOes);
28 qCWarning(qLcOhosMediaPlugin) <<
"OH_NativeImage_Create failed for texture" << glTextureId;
32 m_nativeWindow = OH_NativeImage_AcquireNativeWindow(m_image);
33 if (!m_nativeWindow) {
34 qCWarning(qLcOhosMediaPlugin) <<
"OH_NativeImage_AcquireNativeWindow returned null";
35 OH_NativeImage_Destroy(&m_image);
39 uint64_t surfaceIdRaw = 0;
40 if (OH_NativeImage_GetSurfaceId(m_image, &surfaceIdRaw) == 0)
41 m_surfaceId = QByteArray::number(qulonglong(surfaceIdRaw));
43 OH_OnFrameAvailableListener listener{};
44 listener.context =
this;
45 listener.onFrameAvailable = &QOhosSurfaceImage::onFrameAvailableTrampoline;
46 OH_NativeImage_SetOnFrameAvailableListener(m_image, listener);