Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
403560bb by Thomas Guillem at 2026-01-07T10:08:14+00:00
android: utils: remove android 2.3 surface handling
- - - - -
61ece71e by Thomas Guillem at 2026-01-07T10:08:14+00:00
android: utils: remove now unused API
- - - - -
8b3ad489 by Thomas Guillem at 2026-01-07T10:08:14+00:00
mediacodec: remove JNI mc_api
Keep mediacodec_jni.c for MediaCodec_GetName() (no NDK equivalent).
We always prefer the mc_api NDK implementation. All NDK MediaCodec symbols
are present since API 21, that is the minimum API for VLC 4.0.
The JNI implementation was never used by default.
- - - - -
75958a20 by Thomas Guillem at 2026-01-07T10:08:14+00:00
mediacodec: remove jsurface handling
It was only used from JNI.
- - - - -
bbcce66c by Thomas Guillem at 2026-01-07T10:08:14+00:00
android: utils: remove AWindowHandler_getSurface
It was only used by MediaCodec JNI.
- - - - -
6 changed files:
- modules/codec/omxil/mediacodec.c
- modules/codec/omxil/mediacodec.h
- modules/codec/omxil/mediacodec_jni.c
- modules/codec/omxil/mediacodec_ndk.c
- modules/video_output/android/utils.c
- modules/video_output/android/utils.h
Changes:
=====================================
modules/codec/omxil/mediacodec.c
=====================================
@@ -129,7 +129,7 @@ typedef struct decoder_sys_t
{
vlc_video_context *ctx;
struct android_picture_ctx apic_ctxs[MAX_PIC];
- void *p_surface, *p_jsurface;
+ void *p_surface;
unsigned i_angle;
unsigned i_input_offset_x, i_input_offset_y;
unsigned i_input_width, i_input_height;
@@ -155,7 +155,6 @@ typedef struct decoder_sys_t
/*****************************************************************************
* Local prototypes
*****************************************************************************/
-static int OpenDecoderJni(vlc_object_t *);
static int OpenDecoderNdk(vlc_object_t *);
static void CleanDecoder(decoder_sys_t *);
static void CloseDecoder(vlc_object_t *);
@@ -215,15 +214,6 @@ vlc_module_begin ()
set_capability("audio decoder", 0)
set_callbacks(OpenDecoderNdk, CloseDecoder)
add_shortcut("mediacodec_ndk")
- add_submodule ()
- set_description("Video decoder using Android MediaCodec via JNI")
- set_capability("video decoder", 0)
- set_callbacks(OpenDecoderJni, CloseDecoder)
- add_shortcut("mediacodec_jni")
- add_submodule ()
- set_capability("audio decoder", 0)
- set_callbacks(OpenDecoderJni, CloseDecoder)
- add_shortcut("mediacodec_jni")
vlc_module_end ()
static void CSDFree(decoder_sys_t *p_sys)
@@ -466,7 +456,6 @@ static int StartMediaCodec(decoder_t *p_dec)
args.video.i_angle = p_sys->video.i_angle;
args.video.p_surface = p_sys->video.p_surface;
- args.video.p_jsurface = p_sys->video.p_jsurface;
switch (p_dec->fmt_out.video.color_range)
{
@@ -732,7 +721,6 @@ CreateVideoContext(decoder_t *p_dec)
if (!use_surfacetexture)
{
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)
{
@@ -748,9 +736,7 @@ CreateVideoContext(decoder_t *p_dec)
if (p_sys->video.surfacetexture == NULL)
goto error;
p_sys->video.p_surface = p_sys->video.surfacetexture->window;
- p_sys->video.p_jsurface = p_sys->video.surfacetexture->jsurface;
assert(p_sys->video.p_surface);
- assert(p_sys->video.p_jsurface);
}
static const struct vlc_video_context_operations ops =
@@ -1093,11 +1079,6 @@ static int OpenDecoderNdk(vlc_object_t *p_this)
return OpenDecoder(p_this, MediaCodecNdk_Init);
}
-static int OpenDecoderJni(vlc_object_t *p_this)
-{
- return OpenDecoder(p_this, MediaCodecJni_Init);
-}
-
static void AbortDecoderLocked(decoder_sys_t *p_sys)
{
if (!p_sys->b_aborted)
=====================================
modules/codec/omxil/mediacodec.h
=====================================
@@ -30,7 +30,6 @@ typedef struct mc_api_out mc_api_out;
typedef int (*pf_MediaCodecApi_init)(mc_api*);
-int MediaCodecJni_Init(mc_api*);
int MediaCodecNdk_Init(mc_api*);
#define MC_API_ERROR (-1)
@@ -120,7 +119,6 @@ union mc_api_args
struct
{
void *p_surface;
- void *p_jsurface;
int i_width;
int i_height;
int i_angle;
@@ -190,7 +188,7 @@ struct mc_api
/* Dynamically sets the output surface
* Returns 0 on success, or MC_API_ERROR */
- int (*set_output_surface)(mc_api*, void *p_surface, void *p_jsurface);
+ int (*set_output_surface)(mc_api*, void *p_surface);
};
#endif
=====================================
modules/codec/omxil/mediacodec_jni.c
=====================================
@@ -42,13 +42,7 @@
char* MediaCodec_GetName(vlc_object_t *p_obj, vlc_fourcc_t codec,
const char *psz_mime, int profile, int *p_quirks);
-#define THREAD_NAME "mediacodec_jni"
-
-#define BUFFER_FLAG_CODEC_CONFIG 2
-#define BUFFER_FLAG_END_OF_STREAM 4
-#define INFO_OUTPUT_BUFFERS_CHANGED -3
-#define INFO_OUTPUT_FORMAT_CHANGED -2
-#define INFO_TRY_AGAIN_LATER -1
+#define THREAD_NAME "mediacodec"
/*****************************************************************************
* JNI Initialisation
@@ -56,23 +50,11 @@ char* MediaCodec_GetName(vlc_object_t *p_obj, vlc_fourcc_t
codec,
struct jfields
{
- jclass media_codec_list_class, media_codec_class, media_format_class;
- jclass buffer_info_class, byte_buffer_class;
- jmethodID tostring;
+ jclass media_codec_list_class;
jmethodID get_codec_count, get_codec_info_at, is_encoder,
get_capabilities_for_type;
jmethodID is_feature_supported;
jfieldID profile_levels_field, profile_field, level_field;
jmethodID get_supported_types, get_name;
- jmethodID create_by_codec_name, configure, start, stop, flush, release;
- jmethodID get_output_format;
- jmethodID get_input_buffers, get_input_buffer;
- jmethodID get_output_buffers, get_output_buffer;
- jmethodID dequeue_input_buffer, dequeue_output_buffer, queue_input_buffer;
- jmethodID release_output_buffer;
- jmethodID create_video_format, create_audio_format;
- jmethodID set_integer, set_bytebuffer, get_integer;
- jmethodID buffer_info_ctor;
- jfieldID size_field, offset_field, pts_field, flags_field;
};
static struct jfields jfields;
@@ -89,11 +71,6 @@ struct classname
};
static const struct classname classes[] = {
{ "android/media/MediaCodecList", OFF(media_codec_list_class) },
- { "android/media/MediaCodec", OFF(media_codec_class) },
- { "android/media/MediaFormat", OFF(media_format_class) },
- { "android/media/MediaFormat", OFF(media_format_class) },
- { "android/media/MediaCodec$BufferInfo", OFF(buffer_info_class) },
- { "java/nio/ByteBuffer", OFF(byte_buffer_class) },
{ NULL, 0 },
};
@@ -107,8 +84,6 @@ struct member
bool critical;
};
static const struct member members[] = {
- { "toString", "()Ljava/lang/String;", "java/lang/Object", OFF(tostring),
METHOD, true },
-
{ "getCodecCount", "()I", "android/media/MediaCodecList",
OFF(get_codec_count), STATIC_METHOD, true },
{ "getCodecInfoAt", "(I)Landroid/media/MediaCodecInfo;",
"android/media/MediaCodecList", OFF(get_codec_info_at), STATIC_METHOD, true },
@@ -121,33 +96,7 @@ static const struct member members[] = {
{ "profile", "I", "android/media/MediaCodecInfo$CodecProfileLevel",
OFF(profile_field), FIELD, true },
{ "level", "I", "android/media/MediaCodecInfo$CodecProfileLevel",
OFF(level_field), FIELD, true },
- { "createByCodecName", "(Ljava/lang/String;)Landroid/media/MediaCodec;",
"android/media/MediaCodec", OFF(create_by_codec_name), STATIC_METHOD, true },
- { "configure",
"(Landroid/media/MediaFormat;Landroid/view/Surface;Landroid/media/MediaCrypto;I)V",
"android/media/MediaCodec", OFF(configure), METHOD, true },
- { "start", "()V", "android/media/MediaCodec", OFF(start), METHOD, true },
- { "stop", "()V", "android/media/MediaCodec", OFF(stop), METHOD, true },
- { "flush", "()V", "android/media/MediaCodec", OFF(flush), METHOD, true },
- { "release", "()V", "android/media/MediaCodec", OFF(release), METHOD, true
},
- { "getOutputFormat", "()Landroid/media/MediaFormat;",
"android/media/MediaCodec", OFF(get_output_format), METHOD, true },
- { "getInputBuffers", "()[Ljava/nio/ByteBuffer;",
"android/media/MediaCodec", OFF(get_input_buffers), METHOD, false },
- { "getInputBuffer", "(I)Ljava/nio/ByteBuffer;",
"android/media/MediaCodec", OFF(get_input_buffer), METHOD, false },
- { "getOutputBuffers", "()[Ljava/nio/ByteBuffer;",
"android/media/MediaCodec", OFF(get_output_buffers), METHOD, false },
- { "getOutputBuffer", "(I)Ljava/nio/ByteBuffer;",
"android/media/MediaCodec", OFF(get_output_buffer), METHOD, false },
- { "dequeueInputBuffer", "(J)I", "android/media/MediaCodec",
OFF(dequeue_input_buffer), METHOD, true },
- { "dequeueOutputBuffer", "(Landroid/media/MediaCodec$BufferInfo;J)I",
"android/media/MediaCodec", OFF(dequeue_output_buffer), METHOD, true },
- { "queueInputBuffer", "(IIIJI)V", "android/media/MediaCodec",
OFF(queue_input_buffer), METHOD, true },
- { "releaseOutputBuffer", "(IZ)V", "android/media/MediaCodec",
OFF(release_output_buffer), METHOD, true },
- { "createVideoFormat",
"(Ljava/lang/String;II)Landroid/media/MediaFormat;",
"android/media/MediaFormat", OFF(create_video_format), STATIC_METHOD, true },
- { "createAudioFormat",
"(Ljava/lang/String;II)Landroid/media/MediaFormat;",
"android/media/MediaFormat", OFF(create_audio_format), STATIC_METHOD, true },
- { "setInteger", "(Ljava/lang/String;I)V", "android/media/MediaFormat",
OFF(set_integer), METHOD, true },
- { "getInteger", "(Ljava/lang/String;)I", "android/media/MediaFormat",
OFF(get_integer), METHOD, true },
- { "setByteBuffer", "(Ljava/lang/String;Ljava/nio/ByteBuffer;)V",
"android/media/MediaFormat", OFF(set_bytebuffer), METHOD, true },
-
- { "<init>", "()V", "android/media/MediaCodec$BufferInfo",
OFF(buffer_info_ctor), METHOD, true },
- { "size", "I", "android/media/MediaCodec$BufferInfo", OFF(size_field),
FIELD, true },
- { "offset", "I", "android/media/MediaCodec$BufferInfo", OFF(offset_field),
FIELD, true },
- { "presentationTimeUs", "J", "android/media/MediaCodec$BufferInfo",
OFF(pts_field), FIELD, true },
- { "flags", "I", "android/media/MediaCodec$BufferInfo", OFF(flags_field),
FIELD, true },
{ NULL, NULL, NULL, 0, 0, false },
};
@@ -173,7 +122,6 @@ static inline bool check_exception(JNIEnv *env)
return false;
}
#define CHECK_EXCEPTION() check_exception(env)
-#define GET_ENV() if (!(env = android_getEnv(api->p_obj, THREAD_NAME))) return
MC_API_ERROR;
static inline jstring jni_new_string(JNIEnv *env, const char *psz_string)
{
@@ -182,35 +130,6 @@ static inline jstring jni_new_string(JNIEnv *env, const
char *psz_string)
}
#define JNI_NEW_STRING(psz_string) jni_new_string(env, psz_string)
-static inline int get_integer(JNIEnv *env, jobject obj, const char *psz_name)
-{
- jstring jname = JNI_NEW_STRING(psz_name);
- if (jname)
- {
- int i_ret = (*env)->CallIntMethod(env, obj, jfields.get_integer,
jname);
- (*env)->DeleteLocalRef(env, jname);
- /* getInteger can throw NullPointerException (when fetching the
- * "channel-mask" property for example) */
- if (CHECK_EXCEPTION())
- return 0;
- return i_ret;
- }
- else
- return 0;
-}
-#define GET_INTEGER(obj, name) get_integer(env, obj, name)
-
-static inline void set_integer(JNIEnv *env, jobject jobj, const char *psz_name,
- int i_value)
-{
- jstring jname = JNI_NEW_STRING(psz_name);
- if (jname)
- {
- (*env)->CallVoidMethod(env, jobj, jfields.set_integer, jname, i_value);
- (*env)->DeleteLocalRef(env, jname);
- }
-}
-#define SET_INTEGER(obj, name, value) set_integer(env, obj, name, value)
/* Initialize all jni fields.
* Done only one time during the first initialisation */
@@ -281,18 +200,6 @@ InitJNIFields (vlc_object_t *p_obj, JNIEnv *env)
}
if (last_class != NULL)
(*env)->DeleteLocalRef(env, last_class);
- /* getInputBuffers and getOutputBuffers are deprecated if API >= 21
- * use getInputBuffer and getOutputBuffer instead. */
- if (jfields.get_input_buffer && jfields.get_output_buffer)
- {
- jfields.get_output_buffers =
- jfields.get_input_buffers = NULL;
- }
- else if (!jfields.get_output_buffers && !jfields.get_input_buffers)
- {
- msg_Err(p_obj, "Unable to find get Output/Input Buffer/Buffers");
- goto end;
- }
i_init_state = 1;
end:
@@ -304,17 +211,6 @@ end:
return ret;
}
-/****************************************************************************
- * Local prototypes
- ****************************************************************************/
-
-struct mc_api_sys
-{
- jobject codec;
- jobject buffer_info;
- jobject input_buffers, output_buffers;
-};
-
static char *GetManufacturer(JNIEnv *env)
{
char *manufacturer = NULL;
@@ -521,591 +417,4 @@ loopclean:
(*env)->DeleteLocalRef(env, jmime);
return psz_name;
-}
-
-/*****************************************************************************
- * ConfigureDecoder
- *****************************************************************************/
-static int ConfigureDecoder(mc_api *api, union mc_api_args* p_args)
-{
- mc_api_sys *p_sys = api->p_sys;
- JNIEnv* env = NULL;
- int i_ret = MC_API_ERROR;
- bool b_direct_rendering = false;
- jstring jmime = NULL;
- jstring jcodec_name = NULL;
- jobject jcodec = NULL;
- jobject jformat = NULL;
- jobject jsurface = NULL;
-
- assert(api->psz_mime && api->psz_name);
-
- GET_ENV();
-
- jmime = JNI_NEW_STRING(api->psz_mime);
- jcodec_name = JNI_NEW_STRING(api->psz_name);
- if (!jmime || !jcodec_name)
- goto error;
-
- /* This method doesn't handle errors nicely, it crashes if the codec isn't
- * found. (The same goes for createDecoderByType.) This is fixed in latest
- * AOSP and in 4.2, but not in 4.1 devices. */
- jcodec = (*env)->CallStaticObjectMethod(env, jfields.media_codec_class,
- jfields.create_by_codec_name,
- jcodec_name);
- if (CHECK_EXCEPTION())
- {
- msg_Warn(api->p_obj, "Exception occurred in
MediaCodec.createByCodecName");
- goto error;
- }
- p_sys->codec = (*env)->NewGlobalRef(env, jcodec);
-
- if (api->i_cat == VIDEO_ES)
- {
- assert(p_args->video.i_angle == 0 || api->b_support_rotation);
- jformat = (*env)->CallStaticObjectMethod(env,
- jfields.media_format_class,
- jfields.create_video_format,
- jmime,
- p_args->video.i_width,
- p_args->video.i_height);
- jsurface = p_args->video.p_jsurface;
- b_direct_rendering = !!jsurface;
-
- if (p_args->video.i_angle != 0)
- SET_INTEGER(jformat, "rotation-degrees", p_args->video.i_angle);
-
- if (p_args->video.b_low_latency)
- SET_INTEGER(jformat, "low-latency", 1);
-
- SET_INTEGER(jformat, "color-range", p_args->video.color_range);
- SET_INTEGER(jformat, "color-standard", p_args->video.color_standard);
- SET_INTEGER(jformat, "color-transfer", p_args->video.color_transfer);
-
- if (b_direct_rendering)
- {
- /* feature-tunneled-playback available since API 21 */
- if (jfields.get_input_buffer && p_args->video.b_tunneled_playback)
- SET_INTEGER(jformat, "feature-tunneled-playback", 1);
-
- if (p_args->video.b_adaptive_playback)
- SET_INTEGER(jformat, "feature-adaptive-playback", 1);
- }
- }
- else
- {
- jformat = (*env)->CallStaticObjectMethod(env,
- jfields.media_format_class,
- jfields.create_audio_format,
- jmime,
- p_args->audio.i_sample_rate,
-
p_args->audio.i_channel_count);
- }
-
- /* No limits for input size */
- SET_INTEGER(jformat, "max-input-size", 0);
-
- if (b_direct_rendering)
- {
- // Configure MediaCodec with the Android surface.
- (*env)->CallVoidMethod(env, p_sys->codec, jfields.configure,
- jformat, jsurface, NULL, 0);
- if (CHECK_EXCEPTION())
- {
- msg_Warn(api->p_obj, "Exception occurred in MediaCodec.configure "
- "with an output surface.");
- goto error;
- }
-
- api->b_direct_rendering = b_direct_rendering;
- }
- else
- {
- (*env)->CallVoidMethod(env, p_sys->codec, jfields.configure,
- jformat, NULL, NULL, 0);
- if (CHECK_EXCEPTION())
- {
- msg_Warn(api->p_obj, "Exception occurred in MediaCodec.configure");
- goto error;
- }
- api->b_direct_rendering = false;
- }
-
- i_ret = 0;
-
-error:
- if (jmime)
- (*env)->DeleteLocalRef(env, jmime);
- if (jcodec_name)
- (*env)->DeleteLocalRef(env, jcodec_name);
- if (jcodec)
- (*env)->DeleteLocalRef(env, jcodec);
- if (jformat)
- (*env)->DeleteLocalRef(env, jformat);
-
- return i_ret;
-}
-
-/*****************************************************************************
- * Stop
- *****************************************************************************/
-static int Stop(mc_api *api)
-{
- mc_api_sys *p_sys = api->p_sys;
- JNIEnv *env;
-
- api->b_direct_rendering = false;
-
- GET_ENV();
-
- if (p_sys->input_buffers)
- {
- (*env)->DeleteGlobalRef(env, p_sys->input_buffers);
- p_sys->input_buffers = NULL;
- }
- if (p_sys->output_buffers)
- {
- (*env)->DeleteGlobalRef(env, p_sys->output_buffers);
- p_sys->output_buffers = NULL;
- }
- if (p_sys->codec)
- {
- if (api->b_started)
- {
- (*env)->CallVoidMethod(env, p_sys->codec, jfields.stop);
- if (CHECK_EXCEPTION())
- msg_Err(api->p_obj, "Exception in MediaCodec.stop");
- api->b_started = false;
- }
-
- (*env)->CallVoidMethod(env, p_sys->codec, jfields.release);
- if (CHECK_EXCEPTION())
- msg_Err(api->p_obj, "Exception in MediaCodec.release");
- (*env)->DeleteGlobalRef(env, p_sys->codec);
- p_sys->codec = NULL;
- }
- if (p_sys->buffer_info)
- {
- (*env)->DeleteGlobalRef(env, p_sys->buffer_info);
- p_sys->buffer_info = NULL;
- }
- msg_Dbg(api->p_obj, "MediaCodec via JNI closed");
- return 0;
-}
-
-/*****************************************************************************
- * Start
- *****************************************************************************/
-static int Start(mc_api *api)
-{
- mc_api_sys *p_sys = api->p_sys;
- JNIEnv* env = NULL;
- jobject jinput_buffers = NULL;
- jobject joutput_buffers = NULL;
- jobject jbuffer_info = NULL;
-
- GET_ENV();
-
- int i_ret = MC_API_ERROR;
-
- (*env)->CallVoidMethod(env, p_sys->codec, jfields.start);
- if (CHECK_EXCEPTION())
- {
- msg_Warn(api->p_obj, "Exception occurred in MediaCodec.start");
- goto error;
- }
- api->b_started = true;
-
- if (jfields.get_input_buffers && jfields.get_output_buffers)
- {
- jinput_buffers = (*env)->CallObjectMethod(env, p_sys->codec,
- jfields.get_input_buffers);
- if (CHECK_EXCEPTION())
- {
- msg_Err(api->p_obj, "Exception in MediaCodec.getInputBuffers");
- goto error;
- }
- p_sys->input_buffers = (*env)->NewGlobalRef(env, jinput_buffers);
-
- joutput_buffers = (*env)->CallObjectMethod(env, p_sys->codec,
- jfields.get_output_buffers);
- if (CHECK_EXCEPTION())
- {
- msg_Err(api->p_obj, "Exception in MediaCodec.getOutputBuffers");
- goto error;
- }
- p_sys->output_buffers = (*env)->NewGlobalRef(env, joutput_buffers);
- }
- jbuffer_info = (*env)->NewObject(env, jfields.buffer_info_class,
- jfields.buffer_info_ctor);
- p_sys->buffer_info = (*env)->NewGlobalRef(env, jbuffer_info);
-
- i_ret = 0;
- msg_Dbg(api->p_obj, "MediaCodec via JNI opened");
-
-error:
- if (jinput_buffers)
- (*env)->DeleteLocalRef(env, jinput_buffers);
- if (joutput_buffers)
- (*env)->DeleteLocalRef(env, joutput_buffers);
- if (jbuffer_info)
- (*env)->DeleteLocalRef(env, jbuffer_info);
-
- if (i_ret != 0)
- Stop(api);
- return i_ret;
-}
-
-/*****************************************************************************
- * Flush
- *****************************************************************************/
-static int Flush(mc_api *api)
-{
- mc_api_sys *p_sys = api->p_sys;
- JNIEnv *env = NULL;
-
- GET_ENV();
-
- (*env)->CallVoidMethod(env, p_sys->codec, jfields.flush);
- if (CHECK_EXCEPTION())
- {
- msg_Warn(api->p_obj, "Exception occurred in MediaCodec.flush");
- return MC_API_ERROR;
- }
- return 0;
-}
-
-/*****************************************************************************
- * DequeueInput
- *****************************************************************************/
-static int DequeueInput(mc_api *api, vlc_tick_t i_timeout)
-{
- mc_api_sys *p_sys = api->p_sys;
- JNIEnv *env;
- int i_index;
-
- GET_ENV();
-
- i_index = (*env)->CallIntMethod(env, p_sys->codec,
- jfields.dequeue_input_buffer, i_timeout);
- if (CHECK_EXCEPTION())
- {
- msg_Err(api->p_obj, "Exception occurred in
MediaCodec.dequeueInputBuffer");
- return MC_API_ERROR;
- }
- if (i_index >= 0)
- return i_index;
- else
- return MC_API_INFO_TRYAGAIN;
-
-}
-
-/*****************************************************************************
- * QueueInput
- *****************************************************************************/
-static int QueueInput(mc_api *api, int i_index, const void *p_buf,
- size_t i_size, vlc_tick_t i_ts, bool b_config)
-{
- mc_api_sys *p_sys = api->p_sys;
- JNIEnv *env;
- uint8_t *p_mc_buf;
- jobject j_mc_buf;
- jsize j_mc_size;
- jint jflags = (b_config ? BUFFER_FLAG_CODEC_CONFIG : 0)
- | (p_buf == NULL ? BUFFER_FLAG_END_OF_STREAM : 0);
-
- assert(i_index >= 0);
-
- GET_ENV();
-
- if (jfields.get_input_buffers)
- j_mc_buf = (*env)->GetObjectArrayElement(env, p_sys->input_buffers,
- i_index);
- else
- {
- j_mc_buf = (*env)->CallObjectMethod(env, p_sys->codec,
- jfields.get_input_buffer, i_index);
- if (CHECK_EXCEPTION())
- {
- msg_Err(api->p_obj, "Exception in MediaCodec.getInputBuffer");
- return MC_API_ERROR;
- }
- }
- j_mc_size = (*env)->GetDirectBufferCapacity(env, j_mc_buf);
- p_mc_buf = (*env)->GetDirectBufferAddress(env, j_mc_buf);
- if (j_mc_size < 0)
- {
- msg_Err(api->p_obj, "Java buffer has invalid size");
- (*env)->DeleteLocalRef(env, j_mc_buf);
- return MC_API_ERROR;
- }
- if ((size_t) j_mc_size > i_size)
- j_mc_size = i_size;
- memcpy(p_mc_buf, p_buf, j_mc_size);
-
- (*env)->CallVoidMethod(env, p_sys->codec, jfields.queue_input_buffer,
- i_index, 0, j_mc_size, i_ts, jflags);
- (*env)->DeleteLocalRef(env, j_mc_buf);
- if (CHECK_EXCEPTION())
- {
- msg_Err(api->p_obj, "Exception in MediaCodec.queueInputBuffer");
- return MC_API_ERROR;
- }
-
- return 0;
-}
-
-/*****************************************************************************
- * DequeueOutput
- *****************************************************************************/
-static int DequeueOutput(mc_api *api, vlc_tick_t i_timeout)
-{
- mc_api_sys *p_sys = api->p_sys;
- JNIEnv *env;
- int i_index;
-
- GET_ENV();
- i_index = (*env)->CallIntMethod(env, p_sys->codec,
- jfields.dequeue_output_buffer,
- p_sys->buffer_info, i_timeout);
- if (CHECK_EXCEPTION())
- return MC_API_ERROR;
-
- if (i_index >= 0)
- return i_index;
- else if (i_index == INFO_OUTPUT_FORMAT_CHANGED)
- return MC_API_INFO_OUTPUT_FORMAT_CHANGED;
- else if (i_index == INFO_OUTPUT_BUFFERS_CHANGED)
- return MC_API_INFO_OUTPUT_BUFFERS_CHANGED;
- else
- return MC_API_INFO_TRYAGAIN;
-}
-
-/*****************************************************************************
- * GetOutput
- *****************************************************************************/
-static int GetOutput(mc_api *api, int i_index, mc_api_out *p_out)
-{
- mc_api_sys *p_sys = api->p_sys;
- JNIEnv *env;
-
- GET_ENV();
-
- if (i_index >= 0)
- {
- p_out->type = MC_OUT_TYPE_BUF;
- p_out->buf.i_index = i_index;
- p_out->buf.i_ts = (*env)->GetLongField(env, p_sys->buffer_info,
- jfields.pts_field);
-
- int flags = (*env)->GetIntField(env, p_sys->buffer_info,
- jfields.flags_field);
- p_out->b_eos = flags & BUFFER_FLAG_END_OF_STREAM;
-
- if (api->b_direct_rendering)
- {
- p_out->buf.p_ptr = NULL;
- p_out->buf.i_size = 0;
- }
- else
- {
- jobject buf;
- uint8_t *ptr = NULL;
- int offset = 0;
-
- if (jfields.get_output_buffers)
- buf = (*env)->GetObjectArrayElement(env, p_sys->output_buffers,
- i_index);
- else
- {
- buf = (*env)->CallObjectMethod(env, p_sys->codec,
- jfields.get_output_buffer,
- i_index);
- if (CHECK_EXCEPTION())
- {
- msg_Err(api->p_obj, "Exception in
MediaCodec.getOutputBuffer");
- return MC_API_ERROR;
- }
- }
- //jsize buf_size = (*env)->GetDirectBufferCapacity(env, buf);
- /* buf can be NULL in case of EOS */
- if (buf)
- {
- ptr = (*env)->GetDirectBufferAddress(env, buf);
-
- offset = (*env)->GetIntField(env, p_sys->buffer_info,
- jfields.offset_field);
- }
- p_out->buf.p_ptr = ptr + offset;
- p_out->buf.i_size = (*env)->GetIntField(env, p_sys->buffer_info,
- jfields.size_field);
- (*env)->DeleteLocalRef(env, buf);
- }
- return 1;
- } else if (i_index == MC_API_INFO_OUTPUT_FORMAT_CHANGED)
- {
- jobject format = NULL;
- jobject format_string = NULL;
- jsize format_len;
- const char *format_ptr;
-
- format = (*env)->CallObjectMethod(env, p_sys->codec,
- jfields.get_output_format);
- if (CHECK_EXCEPTION())
- {
- msg_Err(api->p_obj, "Exception in MediaCodec.getOutputFormat");
- return MC_API_ERROR;
- }
-
- format_string = (*env)->CallObjectMethod(env, format,
jfields.tostring);
-
- format_len = (*env)->GetStringUTFLength(env, format_string);
- format_ptr = (*env)->GetStringUTFChars(env, format_string, NULL);
- msg_Dbg(api->p_obj, "output format changed: %.*s", format_len,
- format_ptr);
- (*env)->ReleaseStringUTFChars(env, format_string, format_ptr);
-
- p_out->type = MC_OUT_TYPE_CONF;
- p_out->b_eos = false;
- if (api->i_cat == VIDEO_ES)
- {
- p_out->conf.video.width = GET_INTEGER(format, "width");
- p_out->conf.video.height = GET_INTEGER(format, "height");
- p_out->conf.video.stride = GET_INTEGER(format, "stride");
- p_out->conf.video.slice_height = GET_INTEGER(format,
"slice-height");
- p_out->conf.video.pixel_format = GET_INTEGER(format,
"color-format");
- p_out->conf.video.crop_left = GET_INTEGER(format, "crop-left");
- p_out->conf.video.crop_top = GET_INTEGER(format, "crop-top");
- p_out->conf.video.crop_right = GET_INTEGER(format,
"crop-right");
- p_out->conf.video.crop_bottom = GET_INTEGER(format,
"crop-bottom");
- }
- else
- {
- p_out->conf.audio.channel_count = GET_INTEGER(format,
"channel-count");
- p_out->conf.audio.channel_mask = GET_INTEGER(format,
"channel-mask");
- p_out->conf.audio.sample_rate = GET_INTEGER(format, "sample-rate");
- }
-
- (*env)->DeleteLocalRef(env, format);
- return 1;
- }
- else if (i_index == MC_API_INFO_OUTPUT_BUFFERS_CHANGED)
- {
- jobject joutput_buffers;
-
- msg_Dbg(api->p_obj, "output buffers changed");
- if (!jfields.get_output_buffers)
- return 0;
- (*env)->DeleteGlobalRef(env, p_sys->output_buffers);
-
- joutput_buffers = (*env)->CallObjectMethod(env, p_sys->codec,
- jfields.get_output_buffers);
- if (CHECK_EXCEPTION())
- {
- msg_Err(api->p_obj, "Exception in MediaCodec.getOutputBuffer");
- p_sys->output_buffers = NULL;
- return MC_API_ERROR;
- }
- p_sys->output_buffers = (*env)->NewGlobalRef(env, joutput_buffers);
- (*env)->DeleteLocalRef(env, joutput_buffers);
- }
- return 0;
-}
-
-/*****************************************************************************
- * ReleaseOutput
- *****************************************************************************/
-static int ReleaseOutput(mc_api *api, int i_index, bool b_render)
-{
- mc_api_sys *p_sys = api->p_sys;
- JNIEnv *env;
-
- assert(i_index >= 0);
-
- GET_ENV();
-
- (*env)->CallVoidMethod(env, p_sys->codec, jfields.release_output_buffer,
- i_index, b_render);
- if (CHECK_EXCEPTION())
- {
- msg_Err(api->p_obj, "Exception in MediaCodec.releaseOutputBuffer");
- return MC_API_ERROR;
- }
- return 0;
-}
-
-/*****************************************************************************
- * SetOutputSurface
- *****************************************************************************/
-static int SetOutputSurface(mc_api *api, void *p_surface, void *p_jsurface)
-{
- (void) api; (void) p_surface; (void) p_jsurface;
-
- return MC_API_ERROR;
-}
-
-/*****************************************************************************
- * Clean
- *****************************************************************************/
-static void Clean(mc_api *api)
-{
- free(api->psz_name);
- free(api->p_sys);
-}
-
-/*****************************************************************************
- * Prepare
- *****************************************************************************/
-static int Prepare(mc_api *api, int i_profile)
-{
- free(api->psz_name);
-
- api->i_quirks = 0;
- api->psz_name = MediaCodec_GetName(api->p_obj, api->i_codec, api->psz_mime,
- i_profile, &api->i_quirks);
- if (!api->psz_name)
- return MC_API_ERROR;
- api->i_quirks |= OMXCodec_GetQuirks(api->i_cat, api->i_codec,
api->psz_name,
- strlen(api->psz_name));
-
- /* Allow interlaced picture after API 21 */
- if (jfields.get_input_buffer && jfields.get_output_buffer)
- api->i_quirks |= MC_API_VIDEO_QUIRKS_SUPPORT_INTERLACED;
- return 0;
-}
-
-/*****************************************************************************
- * MediaCodecJni_New
- *****************************************************************************/
-int MediaCodecJni_Init(mc_api *api)
-{
- JNIEnv *env;
-
- GET_ENV();
-
- if (!InitJNIFields(api->p_obj, env))
- return MC_API_ERROR;
-
- api->p_sys = calloc(1, sizeof(mc_api_sys));
- if (!api->p_sys)
- return MC_API_ERROR;
-
- api->clean = Clean;
- api->prepare = Prepare;
- api->configure_decoder = ConfigureDecoder;
- api->start = Start;
- api->stop = Stop;
- api->flush = Flush;
- api->dequeue_in = DequeueInput;
- api->queue_in = QueueInput;
- api->dequeue_out = DequeueOutput;
- api->get_out = GetOutput;
- api->release_out = ReleaseOutput;
- api->release_out_ts = NULL;
- api->set_output_surface = SetOutputSurface;
-
- /* Allow rotation only after API 21 */
- if (jfields.get_input_buffer && jfields.get_output_buffer)
- api->b_support_rotation = true;
- return 0;
-}
+}
\ No newline at end of file
=====================================
modules/codec/omxil/mediacodec_ndk.c
=====================================
@@ -562,9 +562,8 @@ static int ReleaseOutputAtTime(mc_api *api, int i_index,
int64_t i_ts_ns)
/*****************************************************************************
* SetOutputSurface
*****************************************************************************/
-static int SetOutputSurface(mc_api *api, void *p_surface, void *p_jsurface)
+static int SetOutputSurface(mc_api *api, void *p_surface)
{
- (void) p_jsurface;
assert(p_surface != NULL);
mc_api_sys *p_sys = api->p_sys;
=====================================
modules/video_output/android/utils.c
=====================================
@@ -156,180 +156,6 @@ struct AWindowHandler
#define JNI_STEXCALL(what, method, ...) \
(*p_env)->what(p_env, p_awh->jobj, p_awh->jfields.AWindow.method,
##__VA_ARGS__)
-/*
- * Android Surface (pre android 2.3)
- */
-
-extern void *jni_AndroidJavaSurfaceToNativeSurface(jobject surf);
-#ifndef ANDROID_SYM_S_LOCK
-# define ANDROID_SYM_S_LOCK "_ZN7android7Surface4lockEPNS0_11SurfaceInfoEb"
-#endif
-#ifndef ANDROID_SYM_S_LOCK2
-# define ANDROID_SYM_S_LOCK2
"_ZN7android7Surface4lockEPNS0_11SurfaceInfoEPNS_6RegionE"
-#endif
-#ifndef ANDROID_SYM_S_UNLOCK
-# define ANDROID_SYM_S_UNLOCK "_ZN7android7Surface13unlockAndPostEv"
-#endif
-typedef void (*AndroidSurface_lock)(void *, void *, int);
-typedef void (*AndroidSurface_lock2)(void *, void *, void *);
-typedef void (*AndroidSurface_unlockAndPost)(void *);
-
-typedef struct {
- void *p_dl_handle;
- void *p_surface_handle;
- AndroidSurface_lock pf_lock;
- AndroidSurface_lock2 pf_lock2;
- AndroidSurface_unlockAndPost pf_unlockAndPost;
-} NativeSurface;
-
-static inline void *
-NativeSurface_Load(const char *psz_lib, NativeSurface *p_ns)
-{
- void *p_lib = dlopen(psz_lib, RTLD_NOW);
- if (!p_lib)
- return NULL;
-
- p_ns->pf_lock = (AndroidSurface_lock)(dlsym(p_lib, ANDROID_SYM_S_LOCK));
- p_ns->pf_lock2 = (AndroidSurface_lock2)(dlsym(p_lib, ANDROID_SYM_S_LOCK2));
- p_ns->pf_unlockAndPost =
- (AndroidSurface_unlockAndPost)(dlsym(p_lib, ANDROID_SYM_S_UNLOCK));
-
- if ((p_ns->pf_lock || p_ns->pf_lock2) && p_ns->pf_unlockAndPost)
- return p_lib;
-
- dlclose(p_lib);
- return NULL;
-}
-
-static void *
-NativeSurface_getHandle(JNIEnv *p_env, jobject jsurf)
-{
- jclass clz;
- jfieldID fid;
- intptr_t p_surface_handle = 0;
-
- clz = (*p_env)->GetObjectClass(p_env, jsurf);
- if ((*p_env)->ExceptionCheck(p_env))
- {
- (*p_env)->ExceptionClear(p_env);
- return NULL;
- }
- fid = (*p_env)->GetFieldID(p_env, clz, "mSurface", "I");
- if (fid == NULL)
- {
- if ((*p_env)->ExceptionCheck(p_env))
- (*p_env)->ExceptionClear(p_env);
- fid = (*p_env)->GetFieldID(p_env, clz, "mNativeSurface", "I");
- if (fid == NULL)
- {
- if ((*p_env)->ExceptionCheck(p_env))
- (*p_env)->ExceptionClear(p_env);
- }
- }
- if (fid != NULL)
- p_surface_handle = (intptr_t)(*p_env)->GetIntField(p_env, jsurf, fid);
- (*p_env)->DeleteLocalRef(p_env, clz);
-
- return (void *)p_surface_handle;
-}
-
-
-static ANativeWindow*
-NativeSurface_fromSurface(JNIEnv *p_env, jobject jsurf)
-{
- void *p_surface_handle;
- NativeSurface *p_ns;
-
- static const char *libs[] = {
- "libsurfaceflinger_client.so",
- "libgui.so",
- "libui.so"
- };
- p_surface_handle = NativeSurface_getHandle(p_env, jsurf);
- if (!p_surface_handle)
- return NULL;
- p_ns = malloc(sizeof(NativeSurface));
- if (!p_ns)
- return NULL;
- p_ns->p_surface_handle = p_surface_handle;
-
- for (size_t i = 0; i < ARRAY_SIZE(libs); i++)
- {
- void *p_dl_handle = NativeSurface_Load(libs[i], p_ns);
- if (p_dl_handle)
- {
- p_ns->p_dl_handle = p_dl_handle;
- return (ANativeWindow*)p_ns;
- }
- }
- free(p_ns);
- return NULL;
-}
-
-static void
-NativeSurface_release(ANativeWindow* p_anw)
-{
- NativeSurface *p_ns = (NativeSurface *)p_anw;
-
- dlclose(p_ns->p_dl_handle);
- free(p_ns);
-}
-
-static int32_t
-NativeSurface_lock(ANativeWindow *p_anw, ANativeWindow_Buffer *p_anb,
- ARect *p_rect)
-{
- (void) p_rect;
- NativeSurface *p_ns = (NativeSurface *)p_anw;
- struct {
- uint32_t w;
- uint32_t h;
- uint32_t s;
- uint32_t usage;
- uint32_t format;
- uint32_t* bits;
- uint32_t reserved[2];
- } info = { 0 };
-
- if (p_ns->pf_lock)
- p_ns->pf_lock(p_ns->p_surface_handle, &info, 1);
- else
- p_ns->pf_lock2(p_ns->p_surface_handle, &info, NULL);
-
- if (!info.w || !info.h) {
- p_ns->pf_unlockAndPost(p_ns->p_surface_handle);
- return -1;
- }
-
- if (p_anb) {
- p_anb->bits = info.bits;
- p_anb->width = info.w;
- p_anb->height = info.h;
- p_anb->stride = info.s;
- p_anb->format = info.format;
- }
- return 0;
-}
-
-static void
-NativeSurface_unlockAndPost(ANativeWindow *p_anw)
-{
- NativeSurface *p_ns = (NativeSurface *)p_anw;
-
- p_ns->pf_unlockAndPost(p_ns->p_surface_handle);
-}
-
-static void
-LoadNativeSurfaceAPI(AWindowHandler *p_awh)
-{
- p_awh->pf_winFromSurface = NativeSurface_fromSurface;
- p_awh->pf_winAcquire = NULL;
- p_awh->pf_winRelease = NativeSurface_release;
- p_awh->anw_api.winLock = NativeSurface_lock;
- p_awh->anw_api.unlockAndPost = NativeSurface_unlockAndPost;
- p_awh->anw_api.setBuffersGeometry = NULL;
-}
-
static int
NDKSurfaceTexture_attachToGLContext(
struct vlc_asurfacetexture *surface,
@@ -571,20 +397,14 @@ LoadNativeWindowAPI(AWindowHandler *p_awh)
{
void *p_library = dlopen("libandroid.so", RTLD_NOW);
if (!p_library)
- {
- LoadNativeSurfaceAPI(p_awh);
return;
- }
p_awh->pf_winFromSurface = dlsym(p_library, "ANativeWindow_fromSurface");
p_awh->pf_winAcquire = dlsym(p_library, "ANativeWindow_acquire");
p_awh->pf_winRelease = dlsym(p_library, "ANativeWindow_release");
- p_awh->anw_api.winLock = dlsym(p_library, "ANativeWindow_lock");
- p_awh->anw_api.unlockAndPost = dlsym(p_library,
"ANativeWindow_unlockAndPost");
p_awh->anw_api.setBuffersGeometry = dlsym(p_library,
"ANativeWindow_setBuffersGeometry");
if (p_awh->pf_winFromSurface && p_awh->pf_winAcquire &&
p_awh->pf_winRelease
- && p_awh->anw_api.winLock && p_awh->anw_api.unlockAndPost
&& p_awh->anw_api.setBuffersGeometry)
{
p_awh->b_has_ndk_ast_api = !LoadNDKSurfaceTextureAPI(p_awh, p_library);
@@ -593,7 +413,6 @@ LoadNativeWindowAPI(AWindowHandler *p_awh)
else
{
dlclose(p_library);
- LoadNativeSurfaceAPI(p_awh);
}
}
@@ -1216,19 +1035,6 @@ AWindowHandler_getANativeWindow(AWindowHandler *p_awh,
enum AWindow_ID id)
return p_awh->views[id].p_anw;
}
-jobject
-AWindowHandler_getSurface(AWindowHandler *p_awh, enum AWindow_ID id)
-{
- assert(id < AWindow_Max);
-
- if (p_awh->views[id].jsurface)
- return p_awh->views[id].jsurface;
-
- AWindowHandler_getANativeWindow(p_awh, id);
- return p_awh->views[id].jsurface;
-}
-
-
void AWindowHandler_releaseANativeWindow(AWindowHandler *p_awh,
enum AWindow_ID id)
{
=====================================
modules/video_output/android/utils.h
=====================================
@@ -52,8 +52,6 @@ enum AWindow_ID {
*/
typedef struct
{
- int32_t (*winLock)(ANativeWindow*, ANativeWindow_Buffer*, ARect*);
- void (*unlockAndPost)(ANativeWindow*);
int32_t (*setBuffersGeometry)(ANativeWindow*, int32_t, int32_t, int32_t);
/* can be NULL */
} native_window_api_t;
@@ -142,14 +140,6 @@ AWindowHandler_newFromANWs(vlc_object_t *obj,
ANativeWindow *video,
*/
native_window_api_t *AWindowHandler_getANativeWindowAPI(AWindowHandler *p_awh);
-/**
- * Get the Video or the Subtitles Android Surface
- *
- * \return the surface in a jobject, or NULL. It should be released with
- * AWindowHandler_releaseANativeWindow() or AWindowHandler_destroy().
- */
-jobject AWindowHandler_getSurface(AWindowHandler *p_awh, enum AWindow_ID id);
-
/**
* Get the Video or the Subtitles ANativeWindow
*
View it on GitLab:
https://code.videolan.org/videolan/vlc/-/compare/8a18772682564dc9ae038ba6adb522ee4752c888...bbcce66cf55e12e12f022499a41aa6fd1a154665
--
View it on GitLab:
https://code.videolan.org/videolan/vlc/-/compare/8a18772682564dc9ae038ba6adb522ee4752c888...bbcce66cf55e12e12f022499a41aa6fd1a154665
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits