[vlc-commits] android: utils: expose vlc_surfacetexture API
Alexandre Janniaux
git at videolan.org
Wed Jul 8 17:52:53 CEST 2020
vlc | branch: master | Alexandre Janniaux <ajanni at videolabs.io> | Wed Jun 24 15:14:34 2020 +0200| [6624563cc603d51fb2b0876c5c953ded10168ffa] | committer: Alexandre Janniaux
android: utils: expose vlc_surfacetexture API
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.
Signed-off-by: Alexandre Janniaux <ajanni at videolabs.io>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6624563cc603d51fb2b0876c5c953ded10168ffa
---
modules/video_output/android/utils.c | 18 ++++++++++++++++++
modules/video_output/android/utils.h | 19 +++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/modules/video_output/android/utils.c b/modules/video_output/android/utils.c
index e6c5da61ea..a5471b8d5d 100644
--- a/modules/video_output/android/utils.c
+++ b/modules/video_output/android/utils.c
@@ -462,6 +462,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);
}
@@ -562,6 +563,7 @@ static void JNISurfaceTexture_destroy(
if (handle->surface.jsurface)
(*p_env)->DeleteGlobalRef(p_env, handle->surface.jsurface);
+ handle->awh->st = NULL;
free(handle);
}
@@ -1149,6 +1151,22 @@ 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");
+ struct vlc_asurfacetexture_priv *surfacetexture =
+ CreateSurfaceTexture(p_awh, p_env);
+ if (surfacetexture == NULL)
+ return NULL;
+ return &surfacetexture->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 0f11de77ee..b042df695d 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
*
More information about the vlc-commits
mailing list