[vlc-commits] android: utils: switch from AWH to surfacetexture

Alexandre Janniaux git at videolan.org
Wed Jul 8 17:52:55 CEST 2020


vlc | branch: master | Alexandre Janniaux <ajanni at videolabs.io> | Wed Jun 24 15:14:36 2020 +0200| [48f5e7b559e446200bd4909ae2266e9089db9551] | committer: Alexandre Janniaux

android: utils: switch from AWH to surfacetexture

Now that MediaCodec exposes a SurfaceTexture through the video context,
stop using AWindowHandler in interop and directly use the
vlc_asurfacetexture abstraction to bind the picture to the OpenGL
textures.

It means that, after dropping the hack in vlc_asurfacetexture_New,
multiple interop will finally work within the same AWindowHandler
instance and, for the future GPU Filter support, that filters can
provide their own SurfaceTexture.

Signed-off-by: Alexandre Janniaux <ajanni at videolabs.io>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=48f5e7b559e446200bd4909ae2266e9089db9551
---

 modules/video_output/android/utils.c          | 17 ++++++-----------
 modules/video_output/android/utils.h          |  6 +++---
 modules/video_output/opengl/interop_android.c |  7 ++++---
 3 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/modules/video_output/android/utils.c b/modules/video_output/android/utils.c
index a5471b8d5d..0ce143d998 100644
--- a/modules/video_output/android/utils.c
+++ b/modules/video_output/android/utils.c
@@ -1309,24 +1309,19 @@ AWindowHandler_setVideoLayout(AWindowHandler *p_awh,
 }
 
 int
-SurfaceTexture_attachToGLContext(AWindowHandler *p_awh, uint32_t tex_name)
+SurfaceTexture_attachToGLContext(struct vlc_asurfacetexture *st, uint32_t tex_name)
 {
-    return p_awh->st->ops->attach_to_gl_context(p_awh->st, tex_name);
+    return st->ops->attach_to_gl_context(st, tex_name);
 }
 
 void
-SurfaceTexture_detachFromGLContext(AWindowHandler *p_awh)
+SurfaceTexture_detachFromGLContext(struct vlc_asurfacetexture *st)
 {
-    JNIEnv *p_env = android_getEnvCommon(NULL, p_awh->p_jvm, "SurfaceTexture");
-
-    if (!p_env)
-        return;
-
-    p_awh->st->ops->detach_from_gl_context(p_awh->st);
+    st->ops->detach_from_gl_context(st);
 }
 
 int
-SurfaceTexture_updateTexImage(AWindowHandler *p_awh, const float **pp_transform_mtx)
+SurfaceTexture_updateTexImage(struct vlc_asurfacetexture *st, const float **pp_transform_mtx)
 {
-    return p_awh->st->ops->update_tex_image(p_awh->st, pp_transform_mtx);
+    return st->ops->update_tex_image(st, pp_transform_mtx);
 }
diff --git a/modules/video_output/android/utils.h b/modules/video_output/android/utils.h
index dfec53f589..94f19d7449 100644
--- a/modules/video_output/android/utils.h
+++ b/modules/video_output/android/utils.h
@@ -184,14 +184,14 @@ int AWindowHandler_setVideoLayout(AWindowHandler *p_awh,
  * \return 0 on success, -1 on error.
  */
 int
-SurfaceTexture_attachToGLContext(AWindowHandler *p_awh, uint32_t tex_name);
+SurfaceTexture_attachToGLContext(struct vlc_asurfacetexture *st, uint32_t tex_name);
 
 /**
  * Detach a SurfaceTexture from the OpenGL ES context that owns the OpenGL ES
  * texture object.
  */
 void
-SurfaceTexture_detachFromGLContext(AWindowHandler *p_awh);
+SurfaceTexture_detachFromGLContext(struct vlc_asurfacetexture *st);
 
 /**
  * Create a new SurfaceTexture object.
@@ -243,4 +243,4 @@ SurfaceTexture_getANativeWindow(AWindowHandler *p_awh)
  * \return VLC_SUCCESS or a VLC error
  */
 int
-SurfaceTexture_updateTexImage(AWindowHandler *p_awh, const float **pp_transform_mtx);
+SurfaceTexture_updateTexImage(struct vlc_asurfacetexture *st, const float **pp_transform_mtx);
diff --git a/modules/video_output/opengl/interop_android.c b/modules/video_output/opengl/interop_android.c
index 8e40753acb..b5fa2177cc 100644
--- a/modules/video_output/opengl/interop_android.c
+++ b/modules/video_output/opengl/interop_android.c
@@ -46,7 +46,8 @@ tc_anop_allocate_textures(const struct vlc_gl_interop *interop, GLuint *textures
     (void) tex_width; (void) tex_height;
     struct priv *priv = interop->priv;
     assert(textures[0] != 0);
-    if (SurfaceTexture_attachToGLContext(priv->awh, textures[0]) != 0)
+
+    if (SurfaceTexture_attachToGLContext(priv->avctx->texture, textures[0]) != 0)
     {
         msg_Err(interop->gl, "SurfaceTexture_attachToGLContext failed");
         return VLC_EGENERIC;
@@ -72,7 +73,7 @@ tc_anop_update(const struct vlc_gl_interop *interop, GLuint *textures,
     if (!priv->avctx->render(pic->context))
         return VLC_SUCCESS; /* already rendered */
 
-    if (SurfaceTexture_updateTexImage(priv->awh, &priv->transform_mtx)
+    if (SurfaceTexture_updateTexImage(priv->avctx->texture, &priv->transform_mtx)
         != VLC_SUCCESS)
     {
         priv->transform_mtx = NULL;
@@ -98,7 +99,7 @@ Close(struct vlc_gl_interop *interop)
     struct priv *priv = interop->priv;
 
     if (priv->stex_attached)
-        SurfaceTexture_detachFromGLContext(priv->awh);
+        SurfaceTexture_detachFromGLContext(priv->avctx->texture);
 
     free(priv);
 }



More information about the vlc-commits mailing list