androidmedia: call all static_init() functions from single entry point

This allows the implementations to do custom logic behind the hood. For
example, when NDK implementation is added, the entrypoint can chooses to
statically initialize the NDK implementations or the JNI one.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4115>
This commit is contained in:
Ratchanan Srirattanamet 2023-11-12 02:27:22 +07:00 committed by GStreamer Marge Bot
parent 814f21557f
commit d0ffcb46df
18 changed files with 108 additions and 46 deletions

View file

@ -44,8 +44,6 @@ struct _GstAmcBufferInfo {
gint size;
};
gboolean gst_amc_codec_static_init (void);
void gst_amc_buffer_free (GstAmcBuffer * buffer);
gboolean gst_amc_buffer_set_position_and_limit (GstAmcBuffer * buffer, GError ** err,
gint position, gint limit);

View file

@ -35,8 +35,6 @@ struct _GstAmcCodecProfileLevel
gint level;
};
gboolean gst_amc_codeclist_static_init (void);
gboolean gst_amc_codeclist_get_count (gint * count, GError **err);
GstAmcCodecInfoHandle * gst_amc_codeclist_get_codec_info_at (gint index,
GError **err);

View file

@ -28,8 +28,6 @@ G_BEGIN_DECLS
typedef struct _GstAmcFormat GstAmcFormat;
typedef struct _GstAmcColorFormatInfo GstAmcColorFormatInfo;
gboolean gst_amc_format_static_init (void);
GstAmcFormat * gst_amc_format_new_audio (const gchar *mime, gint sample_rate, gint channels, GError **err);
GstAmcFormat * gst_amc_format_new_video (const gchar *mime, gint width, gint height, GError **err);
void gst_amc_format_free (GstAmcFormat * format);

View file

@ -1840,16 +1840,7 @@ amc_init (GstPlugin * plugin)
gst_amc_codec_info_quark = g_quark_from_static_string ("gst-amc-codec-info");
if (!gst_amc_codeclist_static_init ())
return FALSE;
if (!gst_amc_codec_static_init ())
return FALSE;
if (!gst_amc_format_static_init ())
return FALSE;
if (!gst_amc_surface_texture_static_init ())
if (!gst_amc_static_init ())
return FALSE;
/* Set this to TRUE to allow registering decoders that have

View file

@ -53,6 +53,8 @@ struct _GstAmcCodecInfo {
extern GQuark gst_amc_codec_info_quark;
gboolean gst_amc_static_init (void);
GstVideoFormat gst_amc_color_format_to_video_format (const GstAmcCodecInfo * codec_info, const gchar * mime, gint color_format);
gint gst_amc_video_format_to_color_format (const GstAmcCodecInfo * codec_info, const gchar * mime, GstVideoFormat video_format);

View file

@ -65,8 +65,6 @@ struct _GstAmcSurfaceTextureClass
GError ** err);
};
gboolean gst_amc_surface_texture_static_init (void);
gboolean gst_amc_surface_texture_update_tex_image (GstAmcSurfaceTexture *texture,
GError ** err);

View file

@ -26,6 +26,7 @@
#include "../gstjniutils.h"
#include "../gstamc-codec.h"
#include "../gstamc-constants.h"
#include "gstamc-jni.h"
#include "gstamc-internal-jni.h"
#include "gstamcsurfacetexture-jni.h"
#include "gstamcsurface.h"
@ -90,7 +91,7 @@ static struct
} java_nio_buffer;
gboolean
gst_amc_codec_static_init (void)
gst_amc_codec_jni_static_init (void)
{
gboolean ret = TRUE;
JNIEnv *env;

View file

@ -26,6 +26,8 @@
#include "../gstjniutils.h"
#include "../gstamc-codeclist.h"
#include "gstamc-jni.h"
struct _GstAmcCodecInfoHandle
{
jobject object;
@ -67,7 +69,7 @@ static struct
} media_codecprofilelevel;
gboolean
gst_amc_codeclist_static_init (void)
gst_amc_codeclist_jni_static_init (void)
{
JNIEnv *env;
GError *err = NULL;

View file

@ -25,6 +25,7 @@
#include "../gstjniutils.h"
#include "../gstamc-format.h"
#include "gstamc-jni.h"
#include "gstamc-internal-jni.h"
static struct
@ -44,7 +45,7 @@ static struct
} media_format;
gboolean
gst_amc_format_static_init (void)
gst_amc_format_jni_static_init (void)
{
gboolean ret = TRUE;
JNIEnv *env;

View file

@ -0,0 +1,39 @@
/*
* Copyright (C) 2023, Ratchanan Srirattanamet <peathot@hotmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "../gstamc.h"
#include "gstamc-jni.h"
gboolean
gst_amc_static_init (void)
{
if (!gst_amc_codeclist_jni_static_init ())
return FALSE;
if (!gst_amc_codec_jni_static_init ())
return FALSE;
if (!gst_amc_format_jni_static_init ())
return FALSE;
if (!gst_amc_surface_texture_jni_static_init ())
return FALSE;
return TRUE;
}

View file

@ -0,0 +1,25 @@
/*
* Copyright (C) 2023, Ratchanan Srirattanamet <peathot@hotmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include <glib.h>
gboolean gst_amc_codeclist_jni_static_init (void);
gboolean gst_amc_format_jni_static_init (void);
gboolean gst_amc_codec_jni_static_init (void);
gboolean gst_amc_surface_texture_jni_static_init (void);

View file

@ -27,6 +27,7 @@
#include "gstjniutils.h"
#include "gstamcsurfacetexture-jni.h"
#include "gstamc-jni.h"
struct _GstAmcSurfaceTextureJNI
{
@ -58,7 +59,7 @@ G_DEFINE_TYPE (GstAmcSurfaceTextureJNI, gst_amc_surface_texture_jni,
GST_TYPE_AMC_SURFACE_TEXTURE);
gboolean
gst_amc_surface_texture_static_init (void)
gst_amc_surface_texture_jni_static_init (void)
{
JNIEnv *env;
GError *err = NULL;

View file

@ -35,12 +35,6 @@ struct _GstAmcCodec
GstAmcSurfaceTexture *surface_texture;
};
gboolean
gst_amc_codec_static_init (void)
{
return TRUE;
}
void
gst_amc_buffer_free (GstAmcBuffer * buffer)
{

View file

@ -37,12 +37,6 @@ struct _GstAmcCodecCapabilitiesHandle
gchar *type;
};
gboolean
gst_amc_codeclist_static_init (void)
{
return TRUE;
}
gboolean
gst_amc_codeclist_get_count (gint * count, GError ** err)
{

View file

@ -32,12 +32,6 @@ struct _GstAmcFormat
MLHandle handle;
};
gboolean
gst_amc_format_static_init (void)
{
return TRUE;
}
GstAmcFormat *
gst_amc_format_new_audio (const gchar * mime, gint sample_rate, gint channels,
GError ** err)

View file

@ -0,0 +1,30 @@
/*
* Copyright (C) 2023, Ratchanan Srirattanamet <peathot@hotmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "../gstamc.h"
gboolean
gst_amc_static_init (void)
{
/*
* MagicLeap doesn't require any static initialization. All required
* functions are in C and are linked into the plugin directly.
*/
return TRUE;
}

View file

@ -39,12 +39,6 @@ struct _GstAmcSurfaceTextureML
G_DEFINE_TYPE (GstAmcSurfaceTextureML, gst_amc_surface_texture_ml,
GST_TYPE_AMC_SURFACE_TEXTURE);
gboolean
gst_amc_surface_texture_static_init (void)
{
return TRUE;
}
static gboolean
gst_amc_surface_texture_ml_update_tex_image (GstAmcSurfaceTexture * base,
GError ** err)

View file

@ -39,6 +39,7 @@ extra_deps = []
extra_cargs = []
if have_mlsdk
androidmedia_sources += [
'magicleap/gstamc-ml.c',
'magicleap/gstamc-codec-ml.c',
'magicleap/gstamc-codeclist-ml.c',
'magicleap/gstamc-format-ml.c',
@ -65,6 +66,7 @@ else
'gst-android-hardware-camera.c',
'gst-android-hardware-sensor.c',
'gstjniutils.c',
'jni/gstamc-jni.c',
'jni/gstamc-codec-jni.c',
'jni/gstamc-codeclist-jni.c',
'jni/gstamc-format-jni.c',