law: allow per feature registration

Split plugin into features including
dynamic types which can be indiviually
registered during a static build.

More details here:

https://gitlab.freedesktop.org/gstreamer/gst-build/-/merge_requests/199
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/661

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/876>
This commit is contained in:
Stéphane Cerveau 2021-02-16 10:57:58 +01:00
parent 2cce1247da
commit 217162e35c
10 changed files with 101 additions and 76 deletions

View file

@ -41,6 +41,8 @@ static GstFlowReturn gst_alaw_dec_handle_frame (GstAudioDecoder * dec,
#define gst_alaw_dec_parent_class parent_class #define gst_alaw_dec_parent_class parent_class
G_DEFINE_TYPE (GstALawDec, gst_alaw_dec, GST_TYPE_AUDIO_DECODER); G_DEFINE_TYPE (GstALawDec, gst_alaw_dec, GST_TYPE_AUDIO_DECODER);
GST_ELEMENT_REGISTER_DEFINE (alawdec, "alawdec", GST_RANK_PRIMARY,
GST_TYPE_ALAW_DEC);
/* some day we might have defines in gstconfig.h that tell us about the /* some day we might have defines in gstconfig.h that tell us about the
* desired cpu/memory/binary size trade-offs */ * desired cpu/memory/binary size trade-offs */
@ -111,6 +113,22 @@ alaw_to_s16 (guint8 a_val)
#endif /* GST_ALAW_DEC_USE_TABLE */ #endif /* GST_ALAW_DEC_USE_TABLE */
GstStaticPadTemplate alaw_dec_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) " GST_AUDIO_NE (S16) ", "
"layout = (string) interleaved, "
"rate = (int) [ 8000, 192000 ], " "channels = (int) [ 1, 2 ]")
);
GstStaticPadTemplate alaw_dec_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-alaw, "
"rate = [ 8000 , 192000 ], " "channels = [ 1 , 2 ]")
);
static gboolean static gboolean
gst_alaw_dec_set_format (GstAudioDecoder * dec, GstCaps * caps) gst_alaw_dec_set_format (GstAudioDecoder * dec, GstCaps * caps)
{ {

View file

@ -49,6 +49,8 @@ struct _GstALawDecClass {
GType gst_alaw_dec_get_type(void); GType gst_alaw_dec_get_type(void);
GST_ELEMENT_REGISTER_DECLARE (alawdec);
G_END_DECLS G_END_DECLS
#endif /* __GST_ALAW_DECODE_H__ */ #endif /* __GST_ALAW_DECODE_H__ */

View file

@ -28,6 +28,7 @@
#endif #endif
#include <gst/audio/audio.h> #include <gst/audio/audio.h>
#include "alaw-encode.h" #include "alaw-encode.h"
GST_DEBUG_CATEGORY_STATIC (alaw_enc_debug); GST_DEBUG_CATEGORY_STATIC (alaw_enc_debug);
@ -37,6 +38,8 @@ extern GstStaticPadTemplate alaw_enc_src_factory;
extern GstStaticPadTemplate alaw_enc_sink_factory; extern GstStaticPadTemplate alaw_enc_sink_factory;
G_DEFINE_TYPE (GstALawEnc, gst_alaw_enc, GST_TYPE_AUDIO_ENCODER); G_DEFINE_TYPE (GstALawEnc, gst_alaw_enc, GST_TYPE_AUDIO_ENCODER);
GST_ELEMENT_REGISTER_DEFINE (alawenc, "alawenc", GST_RANK_PRIMARY,
GST_TYPE_ALAW_ENC);
static gboolean gst_alaw_enc_start (GstAudioEncoder * audioenc); static gboolean gst_alaw_enc_start (GstAudioEncoder * audioenc);
static gboolean gst_alaw_enc_set_format (GstAudioEncoder * enc, static gboolean gst_alaw_enc_set_format (GstAudioEncoder * enc,
@ -302,6 +305,22 @@ s16_to_alaw (gint pcm_val)
#endif /* GST_ALAW_ENC_USE_TABLE */ #endif /* GST_ALAW_ENC_USE_TABLE */
GstStaticPadTemplate alaw_enc_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) " GST_AUDIO_NE (S16) ", "
"layout = (string) interleaved, "
"rate = (int) [ 8000, 192000 ], " "channels = (int) [ 1, 2 ]")
);
GstStaticPadTemplate alaw_enc_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-alaw, "
"rate = [ 8000 , 192000 ], " "channels = [ 1 , 2 ]")
);
static gboolean static gboolean
gst_alaw_enc_start (GstAudioEncoder * audioenc) gst_alaw_enc_start (GstAudioEncoder * audioenc)
{ {

View file

@ -52,6 +52,8 @@ struct _GstALawEncClass {
GType gst_alaw_enc_get_type(void); GType gst_alaw_enc_get_type(void);
GST_ELEMENT_REGISTER_DECLARE (alawenc);
G_END_DECLS G_END_DECLS
#endif /* __GST_ALAW_ENCODE_H__ */ #endif /* __GST_ALAW_ENCODE_H__ */

View file

@ -25,48 +25,15 @@
#include "alaw-encode.h" #include "alaw-encode.h"
#include "alaw-decode.h" #include "alaw-decode.h"
GstStaticPadTemplate alaw_dec_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) " GST_AUDIO_NE (S16) ", "
"layout = (string) interleaved, "
"rate = (int) [ 8000, 192000 ], " "channels = (int) [ 1, 2 ]")
);
GstStaticPadTemplate alaw_dec_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-alaw, "
"rate = [ 8000 , 192000 ], " "channels = [ 1 , 2 ]")
);
GstStaticPadTemplate alaw_enc_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) " GST_AUDIO_NE (S16) ", "
"layout = (string) interleaved, "
"rate = (int) [ 8000, 192000 ], " "channels = (int) [ 1, 2 ]")
);
GstStaticPadTemplate alaw_enc_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-alaw, "
"rate = [ 8000 , 192000 ], " "channels = [ 1 , 2 ]")
);
static gboolean static gboolean
plugin_init (GstPlugin * plugin) plugin_init (GstPlugin * plugin)
{ {
if (!gst_element_register (plugin, "alawenc", gboolean ret = FALSE;
GST_RANK_PRIMARY, GST_TYPE_ALAW_ENC) ||
!gst_element_register (plugin, "alawdec",
GST_RANK_PRIMARY, GST_TYPE_ALAW_DEC))
return FALSE;
return TRUE; ret |= GST_ELEMENT_REGISTER (alawenc, plugin);
ret |= GST_ELEMENT_REGISTER (alawdec, plugin);
return ret;
} }
/* FIXME 0.11: merge alaw and mulaw into one plugin? */ /* FIXME 0.11: merge alaw and mulaw into one plugin? */

View file

@ -51,8 +51,32 @@ enum
PROP_0 PROP_0
}; };
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define INT_FORMAT "S16LE"
#else
#define INT_FORMAT "S16BE"
#endif
GstStaticPadTemplate mulaw_dec_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) " INT_FORMAT ", "
"layout = (string) interleaved, "
"rate = (int) [ 8000, 192000 ], " "channels = (int) [ 1, 2 ]")
);
GstStaticPadTemplate mulaw_dec_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-mulaw, "
"rate = [ 8000 , 192000 ], " "channels = [ 1 , 2 ]")
);
#define gst_mulawdec_parent_class parent_class #define gst_mulawdec_parent_class parent_class
G_DEFINE_TYPE (GstMuLawDec, gst_mulawdec, GST_TYPE_AUDIO_DECODER); G_DEFINE_TYPE (GstMuLawDec, gst_mulawdec, GST_TYPE_AUDIO_DECODER);
GST_ELEMENT_REGISTER_DEFINE (mulawdec, "mulawdec", GST_RANK_PRIMARY,
GST_TYPE_MULAWDEC);
static gboolean static gboolean
gst_mulawdec_set_format (GstAudioDecoder * dec, GstCaps * caps) gst_mulawdec_set_format (GstAudioDecoder * dec, GstCaps * caps)

View file

@ -49,6 +49,7 @@ struct _GstMuLawDecClass
}; };
GType gst_mulawdec_get_type (void); GType gst_mulawdec_get_type (void);
GST_ELEMENT_REGISTER_DECLARE (mulawdec);
G_END_DECLS G_END_DECLS
#endif /* __GST_STEREO_H__ */ #endif /* __GST_STEREO_H__ */

View file

@ -35,6 +35,27 @@
extern GstStaticPadTemplate mulaw_enc_src_factory; extern GstStaticPadTemplate mulaw_enc_src_factory;
extern GstStaticPadTemplate mulaw_enc_sink_factory; extern GstStaticPadTemplate mulaw_enc_sink_factory;
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define INT_FORMAT "S16LE"
#else
#define INT_FORMAT "S16BE"
#endif
GstStaticPadTemplate mulaw_enc_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) " INT_FORMAT ", "
"layout = (string) interleaved, "
"rate = (int) [ 8000, 192000 ], " "channels = (int) [ 1, 2 ]")
);
GstStaticPadTemplate mulaw_enc_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-mulaw, "
"rate = [ 8000 , 192000 ], " "channels = [ 1 , 2 ]")
);
/* Stereo signals and args */ /* Stereo signals and args */
enum enum
{ {
@ -57,6 +78,8 @@ static void gst_mulawenc_set_tags (GstMuLawEnc * mulawenc);
#define gst_mulawenc_parent_class parent_class #define gst_mulawenc_parent_class parent_class
G_DEFINE_TYPE (GstMuLawEnc, gst_mulawenc, GST_TYPE_AUDIO_ENCODER); G_DEFINE_TYPE (GstMuLawEnc, gst_mulawenc, GST_TYPE_AUDIO_ENCODER);
GST_ELEMENT_REGISTER_DEFINE (mulawenc, "mulawenc", GST_RANK_PRIMARY,
GST_TYPE_MULAWENC);
/*static guint gst_stereo_signals[LAST_SIGNAL] = { 0 }; */ /*static guint gst_stereo_signals[LAST_SIGNAL] = { 0 }; */

View file

@ -53,5 +53,7 @@ struct _GstMuLawEncClass
GType gst_mulawenc_get_type (void); GType gst_mulawenc_get_type (void);
GST_ELEMENT_REGISTER_DECLARE (mulawenc);
G_END_DECLS G_END_DECLS
#endif /* __GST_STEREO_H__ */ #endif /* __GST_STEREO_H__ */

View file

@ -28,48 +28,15 @@
#define INT_FORMAT "S16BE" #define INT_FORMAT "S16BE"
#endif #endif
GstStaticPadTemplate mulaw_dec_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) " INT_FORMAT ", "
"layout = (string) interleaved, "
"rate = (int) [ 8000, 192000 ], " "channels = (int) [ 1, 2 ]")
);
GstStaticPadTemplate mulaw_dec_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-mulaw, "
"rate = [ 8000 , 192000 ], " "channels = [ 1 , 2 ]")
);
GstStaticPadTemplate mulaw_enc_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) " INT_FORMAT ", "
"layout = (string) interleaved, "
"rate = (int) [ 8000, 192000 ], " "channels = (int) [ 1, 2 ]")
);
GstStaticPadTemplate mulaw_enc_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-mulaw, "
"rate = [ 8000 , 192000 ], " "channels = [ 1 , 2 ]")
);
static gboolean static gboolean
plugin_init (GstPlugin * plugin) plugin_init (GstPlugin * plugin)
{ {
if (!gst_element_register (plugin, "mulawenc", gboolean ret = FALSE;
GST_RANK_PRIMARY, GST_TYPE_MULAWENC) ||
!gst_element_register (plugin, "mulawdec",
GST_RANK_PRIMARY, GST_TYPE_MULAWDEC))
return FALSE;
return TRUE; ret |= GST_ELEMENT_REGISTER (mulawenc, plugin);
ret |= GST_ELEMENT_REGISTER (mulawdec, plugin);
return ret;
} }
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,