[vlc-commits] android: utils: remove AWindow_SurfaceTexture
Alexandre Janniaux
git at videolan.org
Wed Jul 8 17:52:58 CEST 2020
vlc | branch: master | Alexandre Janniaux <ajanni at videolabs.io> | Wed Jun 24 15:14:38 2020 +0200| [5c18c86849bad516aa8eb6aa7da0f38d33729b6f] | committer: Alexandre Janniaux
android: utils: remove AWindow_SurfaceTexture
The AWindow_ID is not used anymore since we moved the creation of
SurfaceTexture to the usage site. We also don't need to store the
SurfaceTexture in the AWindowHandler anymore.
This finally makes the SurfaceTexture independant of the AWindowHandler
and cleanup previous patches.
Signed-off-by: Alexandre Janniaux <ajanni at videolabs.io>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5c18c86849bad516aa8eb6aa7da0f38d33729b6f
---
modules/codec/omxil/mediacodec.c | 18 ++++------
modules/video_output/android/display.c | 2 +-
modules/video_output/android/utils.c | 49 ++++-----------------------
modules/video_output/android/utils.h | 25 --------------
modules/video_output/opengl/interop_android.c | 4 +--
5 files changed, 16 insertions(+), 82 deletions(-)
diff --git a/modules/codec/omxil/mediacodec.c b/modules/codec/omxil/mediacodec.c
index 16758fa17b..041faa9a46 100644
--- a/modules/codec/omxil/mediacodec.c
+++ b/modules/codec/omxil/mediacodec.c
@@ -634,7 +634,6 @@ CreateVideoContext(decoder_t *p_dec)
assert(dec_dev->opaque);
AWindowHandler *awh = dec_dev->opaque;
- enum AWindow_ID id;
const bool has_subtitle_surface =
AWindowHandler_getANativeWindow(awh, AWindow_Subtitles) != NULL;
@@ -643,15 +642,13 @@ CreateVideoContext(decoder_t *p_dec)
* projection or an orientation to handle, if the Surface owner is not able
* to modify its layout, or if there is no external subtitle surfaces. */
- if (p_dec->fmt_out.video.projection_mode != PROJECTION_MODE_RECTANGULAR
+ bool use_surfacetexture =
+ p_dec->fmt_out.video.projection_mode != PROJECTION_MODE_RECTANGULAR
|| (!p_sys->api.b_support_rotation && p_dec->fmt_out.video.orientation != ORIENT_NORMAL)
|| !AWindowHandler_canSetVideoLayout(awh)
- || !has_subtitle_surface)
- id = AWindow_SurfaceTexture;
- else
- id = AWindow_Video;
+ || !has_subtitle_surface;
- if (id == AWindow_SurfaceTexture)
+ if (use_surfacetexture)
{
p_sys->video.surfacetexture = vlc_asurfacetexture_New(awh);
if (p_sys->video.surfacetexture == NULL)
@@ -661,8 +658,8 @@ CreateVideoContext(decoder_t *p_dec)
}
else
{
- p_sys->video.p_surface = AWindowHandler_getANativeWindow(awh, id);
- p_sys->video.p_jsurface = AWindowHandler_getSurface(awh, id);
+ p_sys->video.p_surface = AWindowHandler_getANativeWindow(awh, AWindow_Video);
+ p_sys->video.p_jsurface = AWindowHandler_getSurface(awh, AWindow_Video);
assert (p_sys->video.p_surface);
if (!p_sys->video.p_surface)
{
@@ -685,7 +682,6 @@ 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->texture = p_sys->video.surfacetexture;
avctx->dec_opaque = p_dec->p_sys;
avctx->render = PictureContextRenderPic;
@@ -910,7 +906,7 @@ static int OpenDecoder(vlc_object_t *p_this, pf_MediaCodecApi_init pf_init)
vlc_video_context_GetPrivate(p_sys->video.ctx,
VLC_VIDEO_CONTEXT_AWINDOW);
- if (p_sys->api.b_support_rotation && avctx->id == AWindow_Video)
+ if (p_sys->api.b_support_rotation && avctx->texture == NULL)
{
switch (p_dec->fmt_in.video.orientation)
{
diff --git a/modules/video_output/android/display.c b/modules/video_output/android/display.c
index 3ad9aeb452..e412bd75bb 100644
--- a/modules/video_output/android/display.c
+++ b/modules/video_output/android/display.c
@@ -538,7 +538,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
goto error;
sys->avctx = vlc_video_context_GetPrivate(context, VLC_VIDEO_CONTEXT_AWINDOW);
assert(sys->avctx);
- if (sys->avctx->id != AWindow_Video)
+ if (sys->avctx->texture != NULL)
{
/* video context configured for opengl */
goto error;
diff --git a/modules/video_output/android/utils.c b/modules/video_output/android/utils.c
index 1180d5e21f..1cd7469cf2 100644
--- a/modules/video_output/android/utils.c
+++ b/modules/video_output/android/utils.c
@@ -100,9 +100,6 @@ struct AWindowHandler
ptr_ANativeWindow_release pf_winRelease;
native_window_api_t anw_api;
- /* Store the surfacetexture that AWindowHandler will use. */
- struct vlc_asurfacetexture *st;
-
struct ASurfaceTextureAPI ndk_ast_api;
bool b_has_ndk_ast_api;
@@ -458,7 +455,6 @@ 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);
}
@@ -559,7 +555,6 @@ static void JNISurfaceTexture_destroy(
if (handle->surface.jsurface)
(*p_env)->DeleteGlobalRef(p_env, handle->surface.jsurface);
- handle->awh->st = NULL;
free(handle);
}
@@ -859,8 +854,7 @@ AWindowHandler_new(vout_window_t *wnd, awh_events_t *p_events)
{
/* XXX: HACK: force mediacodec to setup an OpenGL surface when the vout
* is forced to gles2. Indeed, setting b_has_video_layout_listener to
- * false will result in mediacodec using the AWindow_SurfaceTexture
- * surface.
+ * false will result in mediacodec using a SurfaceTexture for output.
*/
char *vout_modules = var_InheritString(wnd, "vout");
if (vout_modules
@@ -899,9 +893,6 @@ AWindowHandler_destroy(AWindowHandler *p_awh)
if (p_env)
{
- if (p_awh->st)
- p_awh->st->ops->destroy(p_awh->st);
-
if (jfields.SurfaceTexture.clazz)
(*p_env)->DeleteGlobalRef(p_env, jfields.SurfaceTexture.clazz);
@@ -1140,17 +1131,12 @@ error:
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;
+ 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;
}
static int
@@ -1167,27 +1153,6 @@ WindowHandler_NewSurfaceEnv(AWindowHandler *p_awh, JNIEnv *p_env,
case AWindow_Subtitles:
jsurface = JNI_ANWCALL(CallObjectMethod, getSubtitlesSurface);
break;
- case AWindow_SurfaceTexture:
- {
- struct vlc_asurfacetexture_priv *surfacetexture =
- CreateSurfaceTexture(p_awh, p_env);
-
- if (surfacetexture == NULL)
- return VLC_EGENERIC;
-
- p_awh->views[id].p_anw = surfacetexture->surface.window;
- p_awh->views[id].jsurface = surfacetexture->surface.jsurface;
- p_awh->ndk_ast_api.p_ast = surfacetexture->texture;
- p_awh->ndk_ast_api.surfacetexture = surfacetexture->jtexture;
-
- assert(surfacetexture->surface.window);
- assert(surfacetexture->surface.jsurface);
-
- /* Store the vlc_asurfacetexture pointer for current AWH wrapper */
- p_awh->st = &surfacetexture->surface;
- return VLC_SUCCESS;
-
- }
default:
vlc_assert_unreachable();
}
diff --git a/modules/video_output/android/utils.h b/modules/video_output/android/utils.h
index 94f19d7449..69c5eaaceb 100644
--- a/modules/video_output/android/utils.h
+++ b/modules/video_output/android/utils.h
@@ -39,7 +39,6 @@ typedef struct ASurfaceTexture ASurfaceTexture;
enum AWindow_ID {
AWindow_Video,
AWindow_Subtitles,
- AWindow_SurfaceTexture,
AWindow_Max,
};
@@ -73,7 +72,6 @@ typedef struct android_video_context_t android_video_context_t;
struct android_video_context_t
{
- enum AWindow_ID id;
struct vlc_asurfacetexture *texture;
void *dec_opaque;
bool (*render)(struct picture_context_t *ctx);
@@ -211,29 +209,6 @@ vlc_asurfacetexture_Delete(struct vlc_asurfacetexture *st)
st->ops->destroy(st);
}
-
-/**
- * Get a Java Surface from the attached SurfaceTexture
- *
- * This object can be used with mediacodec_jni.
- */
-static inline jobject
-SurfaceTexture_getSurface(AWindowHandler *p_awh)
-{
- return AWindowHandler_getSurface(p_awh, AWindow_SurfaceTexture);
-}
-
-/**
- * Get a ANativeWindow from the attached SurfaceTexture
- *
- * This pointer can be used with mediacodec_ndk.
- */
-static inline ANativeWindow *
-SurfaceTexture_getANativeWindow(AWindowHandler *p_awh)
-{
- return AWindowHandler_getANativeWindow(p_awh, AWindow_SurfaceTexture);
-}
-
/**
* Update the SurfaceTexture to the most recent frame.
*
diff --git a/modules/video_output/opengl/interop_android.c b/modules/video_output/opengl/interop_android.c
index b5fa2177cc..c5f654b95b 100644
--- a/modules/video_output/opengl/interop_android.c
+++ b/modules/video_output/opengl/interop_android.c
@@ -34,7 +34,6 @@
struct priv
{
android_video_context_t *avctx;
- AWindowHandler *awh;
const float *transform_mtx;
bool stex_attached;
};
@@ -117,7 +116,7 @@ Open(vlc_object_t *obj)
android_video_context_t *avctx =
vlc_video_context_GetPrivate(interop->vctx, VLC_VIDEO_CONTEXT_AWINDOW);
- if (avctx->id != AWindow_SurfaceTexture)
+ if (avctx == NULL || avctx->texture == NULL)
return VLC_EGENERIC;
interop->priv = malloc(sizeof(struct priv));
@@ -126,7 +125,6 @@ Open(vlc_object_t *obj)
struct priv *priv = interop->priv;
priv->avctx = avctx;
- priv->awh = interop->gl->surface->handle.anativewindow;
priv->transform_mtx = NULL;
priv->stex_attached = false;
More information about the vlc-commits
mailing list