[vlc-devel] [PATCH 09/14] android: utils: expose vlc_surfacetexture API
Alexandre Janniaux
ajanni at videolabs.io
Fri Jun 12 11:40:52 CEST 2020
Expose public functions to create and destroy the vlc_asurfacetexture
objects from an AWindowHandler object. It will be used in particular by
Mediacodec to output to OpenGL textures.
---
modules/video_output/android/utils.c | 14 ++++++++++++++
modules/video_output/android/utils.h | 19 +++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/modules/video_output/android/utils.c b/modules/video_output/android/utils.c
index f0b0f3fd64d..9c143af4669 100644
--- a/modules/video_output/android/utils.c
+++ b/modules/video_output/android/utils.c
@@ -459,6 +459,7 @@ static void NDKSurfaceTexture_destroy(
handle->awh->ndk_ast_api.pf_releaseAst(handle->texture);
(*p_env)->DeleteGlobalRef(p_env, handle->jtexture);
+ handle->awh->st = NULL;
free(handle);
}
@@ -557,6 +558,7 @@ static void JNISurfaceTexture_destroy(
handle->awh->pf_winRelease(handle->surface.window);
(*p_env)->DeleteGlobalRef(p_env, handle->surface.jsurface);
+ handle->awh->st = NULL;
free(handle);
}
@@ -1136,6 +1138,18 @@ error:
return NULL;
}
+struct vlc_asurfacetexture *
+vlc_asurfacetexture_New(AWindowHandler *p_awh)
+{
+ if (p_awh->st == NULL)
+ {
+ JNIEnv *p_env = android_getEnvCommon(NULL, p_awh->p_jvm, "SurfaceTexture");
+ p_awh->st = &SurfaceTextureHandle_Create(p_awh, p_env)->surface;
+ }
+
+ return p_awh->st;
+}
+
static int
WindowHandler_NewSurfaceEnv(AWindowHandler *p_awh, JNIEnv *p_env,
enum AWindow_ID id)
diff --git a/modules/video_output/android/utils.h b/modules/video_output/android/utils.h
index e54da93a9ff..15b22c43c52 100644
--- a/modules/video_output/android/utils.h
+++ b/modules/video_output/android/utils.h
@@ -192,6 +192,25 @@ SurfaceTexture_attachToGLContext(AWindowHandler *p_awh, uint32_t tex_name);
void
SurfaceTexture_detachFromGLContext(AWindowHandler *p_awh);
+/**
+ * Create a new SurfaceTexture object.
+ *
+ * See Android SurfaceTexture
+ */
+struct vlc_asurfacetexture *
+vlc_asurfacetexture_New(AWindowHandler *p_awh);
+
+/**
+ * Delete a SurfaceTexture object created with SurfaceTexture_New.
+ */
+static inline void
+vlc_asurfacetexture_Delete(struct vlc_asurfacetexture *st)
+{
+ if (st->ops->destroy)
+ st->ops->destroy(st);
+}
+
+
/**
* Get a Java Surface from the attached SurfaceTexture
*
--
2.27.0
More information about the vlc-devel
mailing list