[vlc-devel] [PATCH 09/14] android: utils: expose vlc_surfacetexture API
Thomas Guillem
thomas at gllm.fr
Mon Jun 15 13:25:02 CEST 2020
On Fri, Jun 12, 2020, at 11:40, Alexandre Janniaux wrote:
> 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;
Missing error check. Possible NULL-deref.
> + }
> +
> + 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
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list