From 87d8e8b1813b0f8de0bef7a8b273999414146e89 Mon Sep 17 00:00:00 2001 From: Iain Holmes Date: Sun, 2 Nov 2003 02:20:36 +0000 Subject: [PATCH] Vorbis compiles once more Original commit message from CVS: Vorbis compiles once more --- ext/vorbis/vorbis.c | 113 ++++++------------------------------------------ ext/vorbis/vorbisenc.c | 55 ++++++++++++++++++++--- ext/vorbis/vorbisfile.c | 75 +++++++++++++++++++++++++++++--- 3 files changed, 133 insertions(+), 110 deletions(-) diff --git a/ext/vorbis/vorbis.c b/ext/vorbis/vorbis.c index 8a0cff9..238c2a2 100644 --- a/ext/vorbis/vorbis.c +++ b/ext/vorbis/vorbis.c @@ -22,117 +22,30 @@ extern GType vorbisfile_get_type(void); -extern GstElementDetails vorbisfile_details; -extern GstElementDetails vorbisenc_details; - -GstPadTemplate *gst_vorbisdec_src_template, *gst_vorbisdec_sink_template; -GstPadTemplate *gst_vorbisenc_src_template, *gst_vorbisenc_sink_template; - -static GstCaps* -vorbis_caps_factory (void) -{ - return - gst_caps_new ( - "vorbis_vorbis", - "application/ogg", - NULL); -} - -static GstCaps* -raw_caps_factory (void) -{ - return - gst_caps_new ( - "vorbis_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 GstCaps* -raw_caps2_factory (void) -{ - return - gst_caps_new ( - "vorbis_raw_float", - "audio/x-raw-float", - gst_props_new ( - "width", GST_PROPS_INT (32), - "endianness", GST_PROPS_INT (G_BYTE_ORDER), - "rate", GST_PROPS_INT_RANGE (11025, 48000), - "channels", GST_PROPS_INT_RANGE (1, 2), - "buffer-frames", GST_PROPS_INT_RANGE (1, G_MAXINT), - NULL)); -} - static gboolean -plugin_init (GModule *module, GstPlugin *plugin) +plugin_init (GstPlugin *plugin) { - GstElementFactory *enc, *file; - GstCaps *raw_caps, *vorbis_caps, *raw_caps2; if (!gst_library_load ("gstbytestream")) return FALSE; - gst_plugin_set_longname (plugin, "The OGG Vorbis Codec"); - - /* create an elementfactory for the vorbisenc element */ - enc = gst_element_factory_new ("vorbisenc", GST_TYPE_VORBISENC, - &vorbisenc_details); - g_return_val_if_fail (enc != NULL, FALSE); - - raw_caps = raw_caps_factory (); - raw_caps2 = raw_caps2_factory (); - vorbis_caps = vorbis_caps_factory (); - - /* register sink pads */ - gst_vorbisenc_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK, - GST_PAD_ALWAYS, - raw_caps, NULL); - gst_element_factory_add_pad_template (enc, gst_vorbisenc_sink_template); - - /* register src pads */ - gst_vorbisenc_src_template = gst_pad_template_new ("src", GST_PAD_SRC, - GST_PAD_ALWAYS, - vorbis_caps, NULL); - gst_element_factory_add_pad_template (enc, gst_vorbisenc_src_template); - - gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (enc)); + if (!gst_element_register (plugin, "vorbisenc", GST_RANK_NONE, GST_TYPE_VORBISENC)) + return FALSE; - /* register sink pads */ - gst_vorbisdec_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK, - GST_PAD_ALWAYS, - vorbis_caps, NULL); - raw_caps = gst_caps_prepend (raw_caps, raw_caps2); - /* register src pads */ - gst_vorbisdec_src_template = gst_pad_template_new ("src", GST_PAD_SRC, - GST_PAD_ALWAYS, - raw_caps, NULL); - /* create an elementfactory for the vorbisfile element */ - file = gst_element_factory_new ("vorbisfile", vorbisfile_get_type(), - &vorbisfile_details); - g_return_val_if_fail(file != NULL, FALSE); - gst_element_factory_set_rank (file, GST_ELEMENT_RANK_PRIMARY); - - /* register sink pads */ - gst_element_factory_add_pad_template (file, gst_vorbisdec_sink_template); - /* register src pads */ - gst_element_factory_add_pad_template (file, gst_vorbisdec_src_template); - - gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (file)); + if (!gst_element_register (plugin, "vorbisfile", GST_RANK_PRIMARY, vorbisfile_get_type ())) + return FALSE; return TRUE; } -GstPluginDesc plugin_desc = { +GST_PLUGIN_DEFINE ( GST_VERSION_MAJOR, GST_VERSION_MINOR, "vorbis", - plugin_init -}; + "Vorbis plugin library", + plugin_init, + VERSION, + "LGPL", + GST_COPYRIGHT, + GST_PACKAGE, + GST_ORIGIN) diff --git a/ext/vorbis/vorbisenc.c b/ext/vorbis/vorbisenc.c index 74e073b..ad913f1 100644 --- a/ext/vorbis/vorbisenc.c +++ b/ext/vorbis/vorbisenc.c @@ -28,18 +28,15 @@ #include "vorbisenc.h" -extern GstPadTemplate *gst_vorbisenc_src_template, *gst_vorbisenc_sink_template; +static GstPadTemplate *gst_vorbisenc_src_template, *gst_vorbisenc_sink_template; /* elementfactory information */ GstElementDetails vorbisenc_details = { "Ogg Vorbis encoder", "Codec/Audio/Encoder", - "LGPL", "Encodes audio in OGG Vorbis format", - VERSION, "Monty , " "Wim Taymans ", - "(C) 2000", }; /* VorbisEnc signals and args */ @@ -85,6 +82,7 @@ gst_vorbisenc_get_formats (GstPad *pad) #define MIN_BITRATE_DEFAULT -1 #define QUALITY_DEFAULT 0.3 +static void gst_vorbisenc_base_init (gpointer g_class); static void gst_vorbisenc_class_init (VorbisEncClass *klass); static void gst_vorbisenc_init (VorbisEnc *vorbisenc); @@ -109,7 +107,7 @@ vorbisenc_get_type (void) if (!vorbisenc_type) { static const GTypeInfo vorbisenc_info = { sizeof (VorbisEncClass), - NULL, + gst_vorbisenc_base_init, NULL, (GClassInitFunc) gst_vorbisenc_class_init, NULL, @@ -124,6 +122,53 @@ vorbisenc_get_type (void) return vorbisenc_type; } +static GstCaps* +vorbis_caps_factory (void) +{ + return + gst_caps_new ( + "vorbis_vorbis", + "application/ogg", + NULL); +} + +static GstCaps* +raw_caps_factory (void) +{ + return + gst_caps_new ( + "vorbis_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_vorbisenc_base_init (gpointer g_class) +{ + GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); + GstCaps *raw_caps, *vorbis_caps; + + raw_caps = raw_caps_factory (); + vorbis_caps = vorbis_caps_factory (); + + gst_vorbisenc_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK, + GST_PAD_ALWAYS, + raw_caps, NULL); + gst_vorbisenc_src_template = gst_pad_template_new ("src", GST_PAD_SRC, + GST_PAD_ALWAYS, + vorbis_caps, NULL); + gst_element_class_add_pad_template (element_class, gst_vorbisenc_sink_template); + gst_element_class_add_pad_template (element_class, gst_vorbisenc_src_template); + gst_element_class_set_details (element_class, &vorbisenc_details); +} + static void gst_vorbisenc_class_init (VorbisEncClass * klass) { diff --git a/ext/vorbis/vorbisfile.c b/ext/vorbis/vorbisfile.c index 0bd2e53..12b7000 100644 --- a/ext/vorbis/vorbisfile.c +++ b/ext/vorbis/vorbisfile.c @@ -77,19 +77,16 @@ struct _VorbisFileClass { GType vorbisfile_get_type (void); -extern GstPadTemplate *gst_vorbisdec_src_template, *gst_vorbisdec_sink_template; +GstPadTemplate *gst_vorbisdec_src_template, *gst_vorbisdec_sink_template; /* elementfactory information */ GstElementDetails vorbisfile_details = { "Ogg Vorbis decoder", "Codec/Audio/Decoder", - "LGPL", "Decodes OGG Vorbis audio using the vorbisfile API", - VERSION, "Monty , " "Wim Taymans ", - "(C) 2000", }; /* VorbisFile signals and args */ @@ -108,6 +105,7 @@ enum ARG_STREAMINFO }; +static void gst_vorbisfile_base_init (gpointer g_class); static void gst_vorbisfile_class_init (VorbisFileClass *klass); static void gst_vorbisfile_init (VorbisFile *vorbisfile); @@ -161,7 +159,9 @@ vorbisfile_get_type (void) if (!vorbisfile_type) { static const GTypeInfo vorbisfile_info = { - sizeof (VorbisFileClass), NULL, NULL, + sizeof (VorbisFileClass), + gst_vorbisfile_base_init, + NULL, (GClassInitFunc) gst_vorbisfile_class_init, NULL, NULL, sizeof (VorbisFile), 0, (GInstanceInitFunc) gst_vorbisfile_init, @@ -177,6 +177,71 @@ vorbisfile_get_type (void) return vorbisfile_type; } +static GstCaps* +vorbis_caps_factory (void) +{ + return + gst_caps_new ( + "vorbis_vorbis", + "application/ogg", + NULL); +} + +static GstCaps* +raw_caps_factory (void) +{ + return + gst_caps_new ( + "vorbis_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 GstCaps* +raw_caps2_factory (void) +{ + return + gst_caps_new ( + "vorbis_raw_float", + "audio/x-raw-float", + gst_props_new ( + "width", GST_PROPS_INT (32), + "endianness", GST_PROPS_INT (G_BYTE_ORDER), + "rate", GST_PROPS_INT_RANGE (11025, 48000), + "channels", GST_PROPS_INT_RANGE (1, 2), + "buffer-frames", GST_PROPS_INT_RANGE (1, G_MAXINT), + NULL)); +} + +static void +gst_vorbisfile_base_init (gpointer g_class) +{ + GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); + GstCaps *raw_caps, *vorbis_caps, *raw_caps2; + + raw_caps = raw_caps_factory (); + raw_caps2 = raw_caps2_factory (); + vorbis_caps = vorbis_caps_factory (); + + gst_vorbisdec_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK, + GST_PAD_ALWAYS, + vorbis_caps, NULL); + raw_caps = gst_caps_prepend (raw_caps, raw_caps2); + gst_vorbisdec_src_template = gst_pad_template_new ("src", GST_PAD_SRC, + GST_PAD_ALWAYS, + raw_caps, NULL); + gst_element_class_add_pad_template (element_class, gst_vorbisdec_sink_template); + gst_element_class_add_pad_template (element_class, gst_vorbisdec_src_template); + gst_element_class_set_details (element_class, &vorbisfile_details); +} + static void gst_vorbisfile_class_init (VorbisFileClass * klass) { -- 2.7.4