[vlc-devel] [PATCH] android: use AWindowHandler from video context

Alexandre Janniaux ajanni at videolabs.io
Thu May 7 11:31:51 CEST 2020


Using an global AWindowHandler instance for interops and decoder
entangle the pipeline between the decoder and the display, preventing
adding intermediate SurfaceTexture to use through filters.
---
 modules/codec/omxil/mediacodec.c              |  1 +
 modules/video_output/android/utils.h          |  1 +
 modules/video_output/opengl/interop_android.c | 10 ++++++----
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/modules/codec/omxil/mediacodec.c b/modules/codec/omxil/mediacodec.c
index 145752eb3b1..52b15cd075a 100644
--- a/modules/codec/omxil/mediacodec.c
+++ b/modules/codec/omxil/mediacodec.c
@@ -673,6 +673,7 @@ CreateVideoContext(decoder_t *p_dec)
     android_video_context_t *avctx =
         vlc_video_context_GetPrivate(p_sys->video.ctx, VLC_VIDEO_CONTEXT_AWINDOW);
     avctx->id = id;
+    avctx->anativewindow = awh;
     avctx->dec_opaque = p_dec->p_sys;
     avctx->render = PictureContextRenderPic;
     avctx->render_ts = p_sys->api.release_out_ts ? PictureContextRenderPicTs : NULL;
diff --git a/modules/video_output/android/utils.h b/modules/video_output/android/utils.h
index 086819dc1ae..aa4b41f9df0 100644
--- a/modules/video_output/android/utils.h
+++ b/modules/video_output/android/utils.h
@@ -74,6 +74,7 @@ typedef struct android_video_context_t android_video_context_t;
 struct android_video_context_t
 {
     enum AWindow_ID id;
+    AWindowHandler *anativewindow;
     void *dec_opaque;
     bool (*render)(struct picture_context_t *ctx);
     bool (*render_ts)(struct picture_context_t *ctx, vlc_tick_t ts);
diff --git a/modules/video_output/opengl/interop_android.c b/modules/video_output/opengl/interop_android.c
index 29fef17fce9..56bdfff5f6d 100644
--- a/modules/video_output/opengl/interop_android.c
+++ b/modules/video_output/opengl/interop_android.c
@@ -108,16 +108,18 @@ Open(vlc_object_t *obj)
 {
     struct vlc_gl_interop *interop = (void *) obj;
 
-    if (interop->fmt.i_chroma != VLC_CODEC_ANDROID_OPAQUE
-     || !interop->gl->surface->handle.anativewindow
-     || !interop->vctx)
+    if (interop->fmt.i_chroma != VLC_CODEC_ANDROID_OPAQUE || !interop->vctx)
         return VLC_EGENERIC;
 
     android_video_context_t *avctx =
         vlc_video_context_GetPrivate(interop->vctx, VLC_VIDEO_CONTEXT_AWINDOW);
 
-    if (avctx->id != AWindow_SurfaceTexture)
+    if (avctx == NULL
+     || avctx->anativewindow == NULL
+     || avctx->id != AWindow_SurfaceTexture)
+    {
         return VLC_EGENERIC;
+    }
 
     interop->priv = malloc(sizeof(struct priv));
     if (unlikely(interop->priv == NULL))
-- 
2.26.2



More information about the vlc-devel mailing list