From 09284d7f7b8edb7a651520a48a9375cfd823cd5c Mon Sep 17 00:00:00 2001 From: Iain Holmes Date: Sat, 1 Nov 2003 15:46:35 +0000 Subject: [PATCH] Whheeee, FLAC ported to new system too Original commit message from CVS: Whheeee, FLAC ported to new system too --- ext/flac/gstflac.c | 98 ++++++------------------------------------- ext/flac/gstflacdec.c | 64 ++++++++++++++++++++++++---- ext/flac/gstflacenc.c | 62 +++++++++++++++++++++++---- 3 files changed, 124 insertions(+), 100 deletions(-) diff --git a/ext/flac/gstflac.c b/ext/flac/gstflac.c index b4e9ccec4..eeed9c080 100644 --- a/ext/flac/gstflac.c +++ b/ext/flac/gstflac.c @@ -23,101 +23,29 @@ #include "flac_compat.h" -extern GstElementDetails flacenc_details; -extern GstElementDetails flacdec_details; - -GstPadTemplate *gst_flacdec_src_template, *gst_flacdec_sink_template; -GstPadTemplate *gst_flacenc_src_template, *gst_flacenc_sink_template; - -static GstCaps* -flac_caps_factory (void) -{ - return - gst_caps_new ( - "flac_flac", - "application/x-flac", - /*gst_props_new ( - "rate", GST_PROPS_INT_RANGE (11025, 48000), - "channels", GST_PROPS_INT_RANGE (1, 2), - NULL)*/ NULL); -} - -static GstCaps* -raw_caps_factory (void) -{ - return - gst_caps_new ( - "flac_raw", - "audio/x-raw-int", - gst_props_new ( - "endianness", GST_PROPS_INT (G_BYTE_ORDER), - "signed", GST_PROPS_BOOLEAN (TRUE), - "width", GST_PROPS_INT (16), - "depth", GST_PROPS_INT (16), - "rate", GST_PROPS_INT_RANGE (11025, 48000), - "channels", GST_PROPS_INT_RANGE (1, 2), - NULL)); -} - static gboolean -plugin_init (GModule *module, GstPlugin *plugin) +plugin_init (GstPlugin *plugin) { - GstElementFactory *enc, *dec; - GstCaps *raw_caps, *flac_caps; - if (!gst_library_load ("gstbytestream")) return FALSE; - gst_plugin_set_longname (plugin, "The FLAC Lossless compressor Codec"); - - /* create an elementfactory for the flacenc element */ - enc = gst_element_factory_new ("flacenc", GST_TYPE_FLACENC, - &flacenc_details); - g_return_val_if_fail (enc != NULL, FALSE); - - raw_caps = raw_caps_factory (); - flac_caps = flac_caps_factory (); - - /* register sink pads */ - gst_flacenc_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK, - GST_PAD_ALWAYS, - raw_caps, NULL); - gst_element_factory_add_pad_template (enc, gst_flacenc_sink_template); - - /* register src pads */ - gst_flacenc_src_template = gst_pad_template_new ("src", GST_PAD_SRC, - GST_PAD_ALWAYS, - flac_caps, NULL); - gst_element_factory_add_pad_template (enc, gst_flacenc_src_template); - - gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (enc)); - - /* create an elementfactory for the flacdec element */ - dec = gst_element_factory_new("flacdec",GST_TYPE_FLACDEC, - &flacdec_details); - g_return_val_if_fail(dec != NULL, FALSE); - gst_element_factory_set_rank (dec, GST_ELEMENT_RANK_PRIMARY); - - /* register sink pads */ - gst_flacdec_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK, - GST_PAD_ALWAYS, - flac_caps, NULL); - gst_element_factory_add_pad_template (dec, gst_flacdec_sink_template); + if (!gst_element_register (plugin, "flacenc", GST_RANK_NONE, GST_TYPE_FLACENC)) + return FALSE; - /* register src pads */ - gst_flacdec_src_template = gst_pad_template_new ("src", GST_PAD_SRC, - GST_PAD_ALWAYS, - raw_caps, NULL); - gst_element_factory_add_pad_template (dec, gst_flacdec_src_template); + if (!gst_element_register (plugin, "flacdec", GST_RANK_PRIMARY, GST_TYPE_FLACDEC)) + return FALSE; - gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (dec)); - return TRUE; } -GstPluginDesc plugin_desc = { +GST_PLUGIN_DEFINE ( GST_VERSION_MAJOR, GST_VERSION_MINOR, "flac", - plugin_init -}; + "The FLAC Lossless compressor Codec", + plugin_init, + VERSION, + "LGPL", + GST_COPYRIGHT, + GST_PACKAGE, + GST_ORIGIN) diff --git a/ext/flac/gstflacdec.c b/ext/flac/gstflacdec.c index ea7b05762..d794b5d38 100644 --- a/ext/flac/gstflacdec.c +++ b/ext/flac/gstflacdec.c @@ -28,17 +28,14 @@ #include "flac_compat.h" -extern GstPadTemplate *gst_flacdec_src_template, *gst_flacdec_sink_template; +static GstPadTemplate *src_template, *sink_template; /* elementfactory information */ GstElementDetails flacdec_details = { "FLAC decoder", "Codec/Audio/Decoder", - "LGPL", "Decodes FLAC lossless audio streams", - VERSION, "Wim Taymans ", - "(C) 2001", }; /* FlacDec signals and args */ @@ -49,9 +46,10 @@ enum { enum { ARG_0, - ARG_METADATA + ARG_METADATA }; +static void gst_flacdec_base_init (gpointer g_class); static void gst_flacdec_class_init (FlacDecClass *klass); static void gst_flacdec_init (FlacDec *flacdec); @@ -114,7 +112,7 @@ flacdec_get_type(void) { if (!flacdec_type) { static const GTypeInfo flacdec_info = { sizeof(FlacDecClass), - NULL, + gst_flacdec_base_init, NULL, (GClassInitFunc)gst_flacdec_class_init, NULL, @@ -128,6 +126,56 @@ flacdec_get_type(void) { return flacdec_type; } +static GstCaps* +flac_caps_factory (void) +{ + return + gst_caps_new ( + "flac_flac", + "application/x-flac", + /*gst_props_new ( + "rate", GST_PROPS_INT_RANGE (11025, 48000), + "channels", GST_PROPS_INT_RANGE (1, 2), + NULL)*/ NULL); +} + +static GstCaps* +raw_caps_factory (void) +{ + return + gst_caps_new ( + "flac_raw", + "audio/x-raw-int", + gst_props_new ( + "endianness", GST_PROPS_INT (G_BYTE_ORDER), + "signed", GST_PROPS_BOOLEAN (TRUE), + "width", GST_PROPS_INT (16), + "depth", GST_PROPS_INT (16), + "rate", GST_PROPS_INT_RANGE (11025, 48000), + "channels", GST_PROPS_INT_RANGE (1, 2), + NULL)); +} + +static void +gst_flacdec_base_init (gpointer g_class) +{ + GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); + GstCaps *raw_caps, *flac_caps; + + raw_caps = raw_caps_factory (); + flac_caps = flac_caps_factory (); + + sink_template = gst_pad_template_new ("sink", GST_PAD_SINK, + GST_PAD_ALWAYS, + flac_caps, NULL); + src_template = gst_pad_template_new ("src", GST_PAD_SRC, + GST_PAD_ALWAYS, + raw_caps, NULL); + gst_element_class_add_pad_template (element_class, sink_template); + gst_element_class_add_pad_template (element_class, src_template); + gst_element_class_set_details (element_class, &flacdec_details); +} + static void gst_flacdec_class_init (FlacDecClass *klass) { @@ -152,12 +200,12 @@ gst_flacdec_class_init (FlacDecClass *klass) static void gst_flacdec_init (FlacDec *flacdec) { - flacdec->sinkpad = gst_pad_new_from_template (gst_flacdec_sink_template, "sink"); + flacdec->sinkpad = gst_pad_new_from_template (sink_template, "sink"); gst_element_add_pad (GST_ELEMENT (flacdec), flacdec->sinkpad); gst_pad_set_convert_function (flacdec->sinkpad, NULL); gst_element_set_loop_function (GST_ELEMENT (flacdec), gst_flacdec_loop); - flacdec->srcpad = gst_pad_new_from_template (gst_flacdec_src_template, "src"); + flacdec->srcpad = gst_pad_new_from_template (src_template, "src"); gst_element_add_pad (GST_ELEMENT (flacdec), flacdec->srcpad); gst_pad_set_formats_function (flacdec->srcpad, gst_flacdec_get_src_formats); gst_pad_set_convert_function (flacdec->srcpad, gst_flacdec_convert_src); diff --git a/ext/flac/gstflacenc.c b/ext/flac/gstflacenc.c index 816c85588..90cb5dc0d 100644 --- a/ext/flac/gstflacenc.c +++ b/ext/flac/gstflacenc.c @@ -28,17 +28,14 @@ #include "flac_compat.h" -extern GstPadTemplate *gst_flacenc_src_template, *gst_flacenc_sink_template; +static GstPadTemplate *src_template, *sink_template; /* elementfactory information */ GstElementDetails flacenc_details = { "FLAC encoder", "Codec/Audio/Encoder", - "LGPL", "Encodes audio with the FLAC lossless audio encoder", - VERSION, "Wim Taymans ", - "(C) 2001", }; /* FlacEnc signals and args */ @@ -64,6 +61,7 @@ enum { ARG_RICE_PARAMETER_SEARCH_DIST, }; +static void gst_flacenc_base_init (gpointer g_class); static void gst_flacenc_init (FlacEnc *flacenc); static void gst_flacenc_class_init (FlacEncClass *klass); static void gst_flacenc_dispose (GObject *object); @@ -101,7 +99,7 @@ flacenc_get_type (void) if (!flacenc_type) { static const GTypeInfo flacenc_info = { sizeof(FlacEncClass), - NULL, + gst_flacenc_base_init, NULL, (GClassInitFunc)gst_flacenc_class_init, NULL, @@ -169,6 +167,56 @@ gst_flacenc_quality_get_type (void) return qtype; } +static GstCaps* +flac_caps_factory (void) +{ + return + gst_caps_new ( + "flac_flac", + "application/x-flac", + /*gst_props_new ( + "rate", GST_PROPS_INT_RANGE (11025, 48000), + "channels", GST_PROPS_INT_RANGE (1, 2), + NULL)*/ NULL); +} + +static GstCaps* +raw_caps_factory (void) +{ + return + gst_caps_new ( + "flac_raw", + "audio/x-raw-int", + gst_props_new ( + "endianness", GST_PROPS_INT (G_BYTE_ORDER), + "signed", GST_PROPS_BOOLEAN (TRUE), + "width", GST_PROPS_INT (16), + "depth", GST_PROPS_INT (16), + "rate", GST_PROPS_INT_RANGE (11025, 48000), + "channels", GST_PROPS_INT_RANGE (1, 2), + NULL)); +} + +static void +gst_flacenc_base_init (gpointer g_class) +{ + GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); + GstCaps *raw_caps, *flac_caps; + + raw_caps = raw_caps_factory (); + flac_caps = flac_caps_factory (); + + sink_template = gst_pad_template_new ("sink", GST_PAD_SINK, + GST_PAD_ALWAYS, + raw_caps, NULL); + src_template = gst_pad_template_new ("src", GST_PAD_SRC, + GST_PAD_ALWAYS, + flac_caps, NULL); + gst_element_class_add_pad_template (element_class, sink_template); + gst_element_class_add_pad_template (element_class, src_template); + gst_element_class_set_details (element_class, &flacenc_details); +} + static void gst_flacenc_class_init (FlacEncClass *klass) { @@ -266,12 +314,12 @@ gst_flacenc_class_init (FlacEncClass *klass) static void gst_flacenc_init (FlacEnc *flacenc) { - flacenc->sinkpad = gst_pad_new_from_template (gst_flacenc_sink_template, "sink"); + flacenc->sinkpad = gst_pad_new_from_template (sink_template, "sink"); gst_element_add_pad(GST_ELEMENT(flacenc),flacenc->sinkpad); gst_pad_set_chain_function(flacenc->sinkpad,gst_flacenc_chain); gst_pad_set_link_function (flacenc->sinkpad, gst_flacenc_sinkconnect); - flacenc->srcpad = gst_pad_new_from_template (gst_flacenc_src_template, "src"); + flacenc->srcpad = gst_pad_new_from_template (src_template, "src"); gst_element_add_pad(GST_ELEMENT(flacenc),flacenc->srcpad); GST_FLAG_SET (flacenc, GST_ELEMENT_EVENT_AWARE); -- 2.34.1