[vlc-devel] [PATCHv2 12/14] android: utils: switch from AWH to surfacetexture
Alexandre Janniaux
ajanni at videolabs.io
Wed Jun 24 15:14:36 CEST 2020
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.
---
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 a5471b8d5d0..0ce143d9986 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 dfec53f5891..94f19d74490 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 aee9766884e..425ca0570f5 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);
}
--
2.27.0
More information about the vlc-devel
mailing list