From d71c0d206566e6428671b71c5e9aa3caac76e603 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sun, 2 Nov 2003 21:22:09 +0000 Subject: [PATCH] MPEG system streams work too, now Original commit message from CVS: MPEG system streams work too, now --- gst/mpegstream/gstmpegdemux.c | 54 ++++++++++++++++++---------------- gst/mpegstream/gstmpegdemux.h | 2 +- gst/mpegstream/gstmpegparse.c | 38 ++++++++++++------------ gst/mpegstream/gstmpegparse.h | 2 +- gst/mpegstream/gstmpegstream.c | 21 ++++++++----- gst/mpegstream/gstrfc2250enc.c | 38 ++++++++++++------------ gst/mpegstream/gstrfc2250enc.h | 2 +- 7 files changed, 84 insertions(+), 73 deletions(-) diff --git a/gst/mpegstream/gstmpegdemux.c b/gst/mpegstream/gstmpegdemux.c index b651b1c823..8042c29edb 100644 --- a/gst/mpegstream/gstmpegdemux.c +++ b/gst/mpegstream/gstmpegdemux.c @@ -30,12 +30,9 @@ GST_DEBUG_CATEGORY_EXTERN (GST_CAT_SEEK); static GstElementDetails mpeg_demux_details = { "MPEG Demuxer", "Codec/Demuxer", - "LGPL", "Demultiplexes MPEG1 and MPEG2 System Streams", - VERSION, "Erik Walthinsen \n" - "Wim Taymans ", - "(C) 1999", + "Wim Taymans " }; /* MPEG2Demux signals and args */ @@ -154,6 +151,7 @@ GST_PAD_TEMPLATE_FACTORY (subtitle_factory, ); static void gst_mpeg_demux_class_init (GstMPEGDemuxClass *klass); +static void gst_mpeg_demux_base_init (GstMPEGDemuxClass *klass); static void gst_mpeg_demux_init (GstMPEGDemux *mpeg_demux); static gboolean gst_mpeg_demux_parse_packhead (GstMPEGParse *mpeg_parse, GstBuffer *buffer); @@ -187,7 +185,7 @@ mpeg_demux_get_type (void) if (!mpeg_demux_type) { static const GTypeInfo mpeg_demux_info = { sizeof(GstMPEGDemuxClass), - NULL, + (GBaseInitFunc)gst_mpeg_demux_base_init, NULL, (GClassInitFunc)gst_mpeg_demux_class_init, NULL, @@ -201,6 +199,29 @@ mpeg_demux_get_type (void) return mpeg_demux_type; } +static void +gst_mpeg_demux_base_init (GstMPEGDemuxClass *klass) +{ + GstElementClass *element_class = GST_ELEMENT_CLASS (klass); + + gst_element_class_add_pad_template (element_class, + GST_PAD_TEMPLATE_GET (sink_factory)); + gst_element_class_add_pad_template (element_class, + GST_PAD_TEMPLATE_GET (video_src_factory)); + gst_element_class_add_pad_template (element_class, + GST_PAD_TEMPLATE_GET (private1_factory)); + gst_element_class_add_pad_template (element_class, + GST_PAD_TEMPLATE_GET (private2_factory)); + gst_element_class_add_pad_template (element_class, + GST_PAD_TEMPLATE_GET (pcm_factory)); + gst_element_class_add_pad_template (element_class, + GST_PAD_TEMPLATE_GET (subtitle_factory)); + gst_element_class_add_pad_template (element_class, + GST_PAD_TEMPLATE_GET (audio_factory)); + gst_element_class_set_details (element_class, &mpeg_demux_details); + +} + static void gst_mpeg_demux_class_init (GstMPEGDemuxClass *klass) { @@ -1231,25 +1252,8 @@ gst_mpeg_demux_get_index (GstElement *element) gboolean -gst_mpeg_demux_plugin_init (GModule *module, GstPlugin *plugin) +gst_mpeg_demux_plugin_init (GstPlugin *plugin) { - GstElementFactory *factory; - - /* create an elementfactory for the mpeg_demux element */ - factory = gst_element_factory_new ("mpegdemux", GST_TYPE_MPEG_DEMUX, - &mpeg_demux_details); - g_return_val_if_fail (factory != NULL, FALSE); - gst_element_factory_set_rank (factory, GST_ELEMENT_RANK_PRIMARY); - - gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (sink_factory)); - gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (video_src_factory)); - gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (private1_factory)); - gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (private2_factory)); - gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (pcm_factory)); - gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (subtitle_factory)); - gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (audio_factory)); - - gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); - - return TRUE; + return gst_element_register (plugin, "mpegdemux", + GST_RANK_PRIMARY, GST_TYPE_MPEG_DEMUX); } diff --git a/gst/mpegstream/gstmpegdemux.h b/gst/mpegstream/gstmpegdemux.h index 329b1d5a83..74d1f3c3be 100644 --- a/gst/mpegstream/gstmpegdemux.h +++ b/gst/mpegstream/gstmpegdemux.h @@ -103,7 +103,7 @@ struct _GstMPEGDemuxClass { GType gst_mpeg_demux_get_type(void); -gboolean gst_mpeg_demux_plugin_init (GModule *module, GstPlugin *plugin); +gboolean gst_mpeg_demux_plugin_init (GstPlugin *plugin); #ifdef __cplusplus } diff --git a/gst/mpegstream/gstmpegparse.c b/gst/mpegstream/gstmpegparse.c index df7d0c4c38..20b4c24bc2 100644 --- a/gst/mpegstream/gstmpegparse.c +++ b/gst/mpegstream/gstmpegparse.c @@ -33,12 +33,9 @@ GST_DEBUG_CATEGORY_EXTERN (GST_CAT_SEEK); static GstElementDetails mpeg_parse_details = { "MPEG System Parser", "Codec/Parser", - "LGPL", "Parses MPEG1 and MPEG2 System Streams", - VERSION, "Erik Walthinsen \n" - "Wim Taymans ", - "(C) 1999", + "Wim Taymans " }; #define CLASS(o) GST_MPEG_PARSE_CLASS (G_OBJECT_GET_CLASS (o)) @@ -84,6 +81,7 @@ GST_PAD_TEMPLATE_FACTORY (src_factory, ); static void gst_mpeg_parse_class_init (GstMPEGParseClass *klass); +static void gst_mpeg_parse_base_init (GstMPEGParseClass *klass); static void gst_mpeg_parse_init (GstMPEGParse *mpeg_parse); static GstElementStateReturn gst_mpeg_parse_change_state (GstElement *element); @@ -117,7 +115,8 @@ gst_mpeg_parse_get_type (void) if (!mpeg_parse_type) { static const GTypeInfo mpeg_parse_info = { - sizeof(GstMPEGParseClass), NULL, + sizeof(GstMPEGParseClass), + (GBaseInitFunc)gst_mpeg_parse_base_init, NULL, (GClassInitFunc)gst_mpeg_parse_class_init, NULL, @@ -131,6 +130,18 @@ gst_mpeg_parse_get_type (void) return mpeg_parse_type; } +static void +gst_mpeg_parse_base_init (GstMPEGParseClass *klass) +{ + GstElementClass *element_class = GST_ELEMENT_CLASS (klass); + + gst_element_class_add_pad_template (element_class, + GST_PAD_TEMPLATE_GET (src_factory)); + gst_element_class_add_pad_template (element_class, + GST_PAD_TEMPLATE_GET (sink_factory)); + gst_element_class_set_details (element_class, &mpeg_parse_details); +} + static void gst_mpeg_parse_class_init (GstMPEGParseClass *klass) { @@ -911,21 +922,10 @@ gst_mpeg_parse_release_locks (GstElement *element) } gboolean -gst_mpeg_parse_plugin_init (GModule *module, GstPlugin *plugin) +gst_mpeg_parse_plugin_init (GstPlugin *plugin) { - GstElementFactory *factory; - - /* create an elementfactory for the mpeg_parse element */ - factory = gst_element_factory_new ("mpegparse", GST_TYPE_MPEG_PARSE, - &mpeg_parse_details); - g_return_val_if_fail(factory != NULL, FALSE); - scr_format = gst_format_register ("scr", "The MPEG system clock reference time"); - gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (src_factory)); - gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (sink_factory)); - - gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); - - return TRUE; + return gst_element_register (plugin, "mpegparse", + GST_RANK_NONE, GST_TYPE_MPEG_PARSE); } diff --git a/gst/mpegstream/gstmpegparse.h b/gst/mpegstream/gstmpegparse.h index 03757f3d1a..59340fa9f6 100644 --- a/gst/mpegstream/gstmpegparse.h +++ b/gst/mpegstream/gstmpegparse.h @@ -98,7 +98,7 @@ struct _GstMPEGParseClass { GType gst_mpeg_parse_get_type(void); -gboolean gst_mpeg_parse_plugin_init (GModule *module, GstPlugin *plugin); +gboolean gst_mpeg_parse_plugin_init (GstPlugin *plugin); const GstFormat* gst_mpeg_parse_get_src_formats (GstPad *pad); diff --git a/gst/mpegstream/gstmpegstream.c b/gst/mpegstream/gstmpegstream.c index 7bb43346f1..956bf2ef1b 100644 --- a/gst/mpegstream/gstmpegstream.c +++ b/gst/mpegstream/gstmpegstream.c @@ -23,7 +23,7 @@ #include "gstrfc2250enc.h" static gboolean -plugin_init (GModule *module, GstPlugin *plugin) +plugin_init (GstPlugin *plugin) { /* short-circuit here; this is potentially dangerous since if the second * or third init fails then the whole plug-in will be placed on the register @@ -33,16 +33,23 @@ plugin_init (GModule *module, GstPlugin *plugin) if (!gst_library_load ("gstbytestream")) return FALSE; - if (!gst_mpeg_parse_plugin_init (module, plugin)) return FALSE; - if (!gst_mpeg_demux_plugin_init (module, plugin)) return FALSE; - if (!gst_rfc2250_enc_plugin_init (module, plugin)) return FALSE; + if (!gst_mpeg_parse_plugin_init (plugin) || + !gst_mpeg_demux_plugin_init (plugin) || + !gst_rfc2250_enc_plugin_init (plugin)) + return FALSE; return TRUE; } -GstPluginDesc plugin_desc = { +GST_PLUGIN_DEFINE ( GST_VERSION_MAJOR, GST_VERSION_MINOR, "mpegstream", - plugin_init -}; + "MPEG system stream parser", + plugin_init, + VERSION, + "LGPL", + GST_COPYRIGHT, + GST_PACKAGE, + GST_ORIGIN +) diff --git a/gst/mpegstream/gstrfc2250enc.c b/gst/mpegstream/gstrfc2250enc.c index c64029072e..c95ff61305 100644 --- a/gst/mpegstream/gstrfc2250enc.c +++ b/gst/mpegstream/gstrfc2250enc.c @@ -28,11 +28,8 @@ static GstElementDetails rfc2250_enc_details = { "RFC 2250 packet encoder", "Codec/Parser", - "LGPL", "transforms MPEG1/2 video to an RFC 2250 compliant format", - VERSION, - "Wim Taymans ", - "(C) 2001", + "Wim Taymans " }; #define CLASS(o) GST_RFC2250_ENC_CLASS (G_OBJECT_GET_CLASS (o)) @@ -75,6 +72,7 @@ GST_PAD_TEMPLATE_FACTORY (src_factory, ); static void gst_rfc2250_enc_class_init (GstRFC2250EncClass *klass); +static void gst_rfc2250_enc_base_init (GstRFC2250EncClass *klass); static void gst_rfc2250_enc_init (GstRFC2250Enc *rfc2250_enc); static GstElementStateReturn gst_rfc2250_enc_change_state (GstElement *element); @@ -94,7 +92,8 @@ gst_rfc2250_enc_get_type (void) if (!rfc2250_enc_type) { static const GTypeInfo rfc2250_enc_info = { - sizeof(GstRFC2250EncClass), NULL, + sizeof(GstRFC2250EncClass), + (GBaseInitFunc)gst_rfc2250_enc_base_init, NULL, (GClassInitFunc)gst_rfc2250_enc_class_init, NULL, @@ -108,6 +107,18 @@ gst_rfc2250_enc_get_type (void) return rfc2250_enc_type; } +static void +gst_rfc2250_enc_base_init (GstRFC2250EncClass *klass) +{ + GstElementClass *element_class = GST_ELEMENT_CLASS (klass); + + gst_element_class_add_pad_template (element_class, + GST_PAD_TEMPLATE_GET (src_factory)); + gst_element_class_add_pad_template (element_class, + GST_PAD_TEMPLATE_GET (sink_factory)); + gst_element_class_set_details (element_class, &rfc2250_enc_details); +} + static void gst_rfc2250_enc_class_init (GstRFC2250EncClass *klass) { @@ -324,19 +335,8 @@ gst_rfc2250_enc_get_property (GObject *object, guint prop_id, GValue *value, GPa gboolean -gst_rfc2250_enc_plugin_init (GModule *module, GstPlugin *plugin) +gst_rfc2250_enc_plugin_init (GstPlugin *plugin) { - GstElementFactory *factory; - - /* create an elementfactory for the rfc2250_enc element */ - factory = gst_element_factory_new ("rfc2250enc", GST_TYPE_RFC2250_ENC, - &rfc2250_enc_details); - g_return_val_if_fail(factory != NULL, FALSE); - - gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (src_factory)); - gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (sink_factory)); - - gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); - - return TRUE; + return gst_element_register (plugin, "rfc2250enc", + GST_RANK_NONE, GST_TYPE_RFC2250_ENC); } diff --git a/gst/mpegstream/gstrfc2250enc.h b/gst/mpegstream/gstrfc2250enc.h index 2103c51d4b..52e350259d 100644 --- a/gst/mpegstream/gstrfc2250enc.h +++ b/gst/mpegstream/gstrfc2250enc.h @@ -78,7 +78,7 @@ struct _GstRFC2250EncClass { GType gst_rfc2250_enc_get_type(void); -gboolean gst_rfc2250_enc_plugin_init (GModule *module, GstPlugin *plugin); +gboolean gst_rfc2250_enc_plugin_init (GstPlugin *plugin); #ifdef __cplusplus