diff --git a/ChangeLog b/ChangeLog index 9181698987..cc45c81e06 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2005-11-23 Martin Soto + + * gst/mpegstream/gstmpegparse.c (gst_mpeg_parse_class_init) + (gst_mpeg_parse_handle_discont, gst_mpeg_parse_send_newsegment) + (gst_mpeg_parse_chain): + * gst/mpegstream/gstmpegdemux.c (gst_mpeg_demux_class_init) + (gst_mpeg_demux_send_newsegment): + * gst/mpegstream/gstdvddemux.c (gst_dvd_demux_send_subbuffer): + * gst/mpegstream/gstmpegparse.h: + Rename send_discont method to send_newsegment and add parameters + to handle actual segments. Adapt code all around to run with the + new name and signature. + * gst/mpegstream/gstmpegdemux.c: + * gst/mpegstream/gstmpegparse.c: + * gst/mpegstream/gstdvddemux.c: + Convert to GST_BOILERPLATE. + 2005-11-23 Thomas Vander Stichele * configure.ac: back to HEAD @@ -79,6 +96,7 @@ * ext/mad/Makefile.am: libgsttagedit => libgsttag +>>>>>>> 1.1895 2005-11-22 Edward Hervey * ext/lame/gstlame.c: (gst_lame_sink_event): diff --git a/gst/mpegstream/gstdvddemux.c b/gst/mpegstream/gstdvddemux.c index 241d9fc0d6..1ce91d5d7a 100644 --- a/gst/mpegstream/gstdvddemux.c +++ b/gst/mpegstream/gstdvddemux.c @@ -1,5 +1,5 @@ /* GStreamer - * Copyright (C) 2004 Martin Soto + * Copyright (C) 2005 Martin Soto * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -47,7 +47,7 @@ static GstElementDetails dvd_demux_details = { "DVD Demuxer", "Codec/Demuxer", "Demultiplexes DVD (VOB) MPEG2 streams", - "Martin Soto " + "Martin Soto " }; /* DVDDemux signals and args */ @@ -127,9 +127,17 @@ GST_STATIC_PAD_TEMPLATE ("current_subpicture", GST_PAD_ALWAYS, SUBPICTURE_CAPS); +#define _do_init(bla) \ + GST_DEBUG_CATEGORY_INIT (gstdvddemux_debug, "dvddemux", 0, \ + "DVD (VOB) demultiplexer element"); + +GST_BOILERPLATE_FULL (GstDVDDemux, gst_dvd_demux, GstMPEGDemux, + GST_TYPE_MPEG_DEMUX, _do_init); + static void gst_dvd_demux_class_init (GstDVDDemuxClass * klass); -static void gst_dvd_demux_base_init (GstDVDDemuxClass * klass); -static void gst_dvd_demux_init (GstDVDDemux * dvd_demux); +static void gst_dvd_demux_base_init (gpointer klass); +static void gst_dvd_demux_init (GstDVDDemux * dvd_demux, + GstDVDDemuxClass * klass); static GstFlowReturn gst_dvd_demux_send_buffer (GstMPEGParse * mpeg_parse, GstBuffer * buffer, GstClockTime time); @@ -181,46 +189,16 @@ static void gst_dvd_demux_sync_stream_to_time (GstMPEGDemux * mpeg_demux, static GstStateChangeReturn gst_dvd_demux_change_state (GstElement * element, GstStateChange transition); -static GstMPEGDemuxClass *parent_class = NULL; - /*static guint gst_dvd_demux_signals[LAST_SIGNAL] = { 0 };*/ -GType -gst_dvd_demux_get_type (void) -{ - static GType dvd_demux_type = 0; - - if (!dvd_demux_type) { - static const GTypeInfo dvd_demux_info = { - sizeof (GstDVDDemuxClass), - (GBaseInitFunc) gst_dvd_demux_base_init, - NULL, - (GClassInitFunc) gst_dvd_demux_class_init, - NULL, - NULL, - sizeof (GstDVDDemux), - 0, - (GInstanceInitFunc) gst_dvd_demux_init, - }; - - dvd_demux_type = g_type_register_static (GST_TYPE_MPEG_DEMUX, - "GstDVDDemux", &dvd_demux_info, 0); - - GST_DEBUG_CATEGORY_INIT (gstdvddemux_debug, "dvddemux", 0, - "DVD (VOB) demultiplexer element"); - } - - return dvd_demux_type; -} - - static void -gst_dvd_demux_base_init (GstDVDDemuxClass * klass) +gst_dvd_demux_base_init (gpointer klass) { GstElementClass *element_class = GST_ELEMENT_CLASS (klass); + GstMPEGParseClass *mpeg_parse_class = GST_MPEG_PARSE_CLASS (klass); GstMPEGDemuxClass *demux_class = GST_MPEG_DEMUX_CLASS (klass); - GstMPEGParseClass *mpeg_parse_class = (GstMPEGParseClass *) klass; + GstDVDDemuxClass *dvd_demux_class = GST_DVD_DEMUX_CLASS (klass); mpeg_parse_class->send_buffer = gst_dvd_demux_send_buffer; mpeg_parse_class->process_event = gst_dvd_demux_process_event; @@ -231,23 +209,27 @@ gst_dvd_demux_base_init (GstDVDDemuxClass * klass) demux_class->audio_template = gst_static_pad_template_get (&audio_template); - klass->cur_video_template = gst_static_pad_template_get (&cur_video_template); - klass->cur_audio_template = gst_static_pad_template_get (&cur_audio_template); - klass->subpicture_template = + dvd_demux_class->cur_video_template = + gst_static_pad_template_get (&cur_video_template); + dvd_demux_class->cur_audio_template = + gst_static_pad_template_get (&cur_audio_template); + dvd_demux_class->subpicture_template = gst_static_pad_template_get (&subpicture_template); - klass->cur_subpicture_template = + dvd_demux_class->cur_subpicture_template = gst_static_pad_template_get (&cur_subpicture_template); gst_element_class_add_pad_template (element_class, demux_class->audio_template); - gst_element_class_add_pad_template (element_class, klass->cur_video_template); - gst_element_class_add_pad_template (element_class, klass->cur_audio_template); + gst_element_class_add_pad_template (element_class, + dvd_demux_class->cur_video_template); + gst_element_class_add_pad_template (element_class, + dvd_demux_class->cur_audio_template); gst_element_class_add_pad_template (element_class, - klass->subpicture_template); + dvd_demux_class->subpicture_template); gst_element_class_add_pad_template (element_class, - klass->cur_subpicture_template); + dvd_demux_class->cur_subpicture_template); gst_element_class_set_details (element_class, &dvd_demux_details); } @@ -283,7 +265,7 @@ gst_dvd_demux_class_init (GstDVDDemuxClass * klass) static void -gst_dvd_demux_init (GstDVDDemux * dvd_demux) +gst_dvd_demux_init (GstDVDDemux * dvd_demux, GstDVDDemuxClass * klass) { GstMPEGDemux *mpeg_demux = GST_MPEG_DEMUX (dvd_demux); gint i; @@ -1084,8 +1066,8 @@ gst_dvd_demux_send_subbuffer (GstMPEGDemux * mpeg_demux, GST_ERROR ("DVD Discont < 0! % " G_GINT64_FORMAT, (gint64) dvd_demux->discont_time); } - PARSE_CLASS (mpeg_demux)->send_discont (mpeg_parse, - dvd_demux->discont_time); + PARSE_CLASS (mpeg_demux)->send_newsegment (mpeg_parse, 1.0, + dvd_demux->discont_time, GST_CLOCK_TIME_NONE); dvd_demux->discont_time = GST_CLOCK_TIME_NONE; } diff --git a/gst/mpegstream/gstmpegdemux.c b/gst/mpegstream/gstmpegdemux.c index 812e9ca341..ea80ad8dc0 100644 --- a/gst/mpegstream/gstmpegdemux.c +++ b/gst/mpegstream/gstmpegdemux.c @@ -83,16 +83,21 @@ GST_STATIC_PAD_TEMPLATE ("private_%d", GST_PAD_SOMETIMES, GST_STATIC_CAPS_ANY); -static void gst_mpeg_demux_base_init (GstMPEGDemuxClass * klass); +#define _do_init(bla) \ + GST_DEBUG_CATEGORY_INIT (gstmpegdemux_debug, "mpegdemux", 0, \ + "MPEG demuxer element"); + +GST_BOILERPLATE_FULL (GstMPEGDemux, gst_mpeg_demux, GstMPEGParse, + GST_TYPE_MPEG_PARSE, _do_init); + static void gst_mpeg_demux_class_init (GstMPEGDemuxClass * klass); -static void gst_mpeg_demux_init (GstMPEGDemux * mpeg_demux); static GstFlowReturn gst_mpeg_demux_send_buffer (GstMPEGParse * mpeg_parse, GstBuffer * buffer, GstClockTime time); static gboolean gst_mpeg_demux_process_event (GstMPEGParse * mpeg_parse, GstEvent * event, GstClockTime time); -static gboolean gst_mpeg_demux_send_discont (GstMPEGParse * mpeg_parse, - GstClockTime time); +static gboolean gst_mpeg_demux_send_newsegment (GstMPEGParse * parse, + gdouble rate, GstClockTime start_time, GstClockTime stop_time); static gboolean gst_mpeg_demux_handle_discont (GstMPEGParse * mpeg_parse, GstEvent * event); static gboolean gst_mpeg_demux_send_event (GstMPEGParse * mpeg_parse, @@ -154,43 +159,13 @@ static void gst_mpeg_demux_set_index (GstElement * element, GstIndex * index); static GstIndex *gst_mpeg_demux_get_index (GstElement * element); -static GstMPEGParseClass *parent_class = NULL; - /*static guint gst_mpeg_demux_signals[LAST_SIGNAL] = { 0 };*/ -GType -gst_mpeg_demux_get_type (void) -{ - static GType mpeg_demux_type = 0; - - if (!mpeg_demux_type) { - static const GTypeInfo mpeg_demux_info = { - sizeof (GstMPEGDemuxClass), - (GBaseInitFunc) gst_mpeg_demux_base_init, - NULL, - (GClassInitFunc) gst_mpeg_demux_class_init, - NULL, - NULL, - sizeof (GstMPEGDemux), - 0, - (GInstanceInitFunc) gst_mpeg_demux_init, - }; - - mpeg_demux_type = - g_type_register_static (GST_TYPE_MPEG_PARSE, "GstMPEGDemux", - &mpeg_demux_info, 0); - - GST_DEBUG_CATEGORY_INIT (gstmpegdemux_debug, "mpegdemux", 0, - "MPEG demultiplexer element"); - } - - return mpeg_demux_type; -} - static void -gst_mpeg_demux_base_init (GstMPEGDemuxClass * klass) +gst_mpeg_demux_base_init (gpointer klass_ptr) { - GstElementClass *element_class = GST_ELEMENT_CLASS (klass); + GstMPEGDemuxClass *klass = GST_MPEG_DEMUX_CLASS (klass_ptr); + GstElementClass *element_class = GST_ELEMENT_CLASS (klass_ptr); klass->video_template = gst_static_pad_template_get (&video_template); klass->audio_template = gst_static_pad_template_get (&audio_template); @@ -225,7 +200,7 @@ gst_mpeg_demux_class_init (GstMPEGDemuxClass * klass) mpeg_parse_class->parse_pes = gst_mpeg_demux_parse_pes; mpeg_parse_class->send_buffer = gst_mpeg_demux_send_buffer; mpeg_parse_class->process_event = gst_mpeg_demux_process_event; - mpeg_parse_class->send_discont = gst_mpeg_demux_send_discont; + mpeg_parse_class->send_newsegment = gst_mpeg_demux_send_newsegment; mpeg_parse_class->handle_discont = gst_mpeg_demux_handle_discont; mpeg_parse_class->send_event = gst_mpeg_demux_send_event; @@ -245,7 +220,7 @@ gst_mpeg_demux_class_init (GstMPEGDemuxClass * klass) } static void -gst_mpeg_demux_init (GstMPEGDemux * mpeg_demux) +gst_mpeg_demux_init (GstMPEGDemux * mpeg_demux, GstMPEGDemuxClass * klass) { gint i; @@ -298,25 +273,31 @@ gst_mpeg_demux_process_event (GstMPEGParse * mpeg_parse, GstEvent * event, } static gboolean -gst_mpeg_demux_send_discont (GstMPEGParse * mpeg_parse, GstClockTime time) +gst_mpeg_demux_send_newsegment (GstMPEGParse * mpeg_parse, gdouble rate, + GstClockTime start_time, GstClockTime stop_time) { GstMPEGDemux *mpeg_demux = GST_MPEG_DEMUX (mpeg_parse); - if (GST_CLOCK_TIME_IS_VALID (time)) - time += mpeg_demux->adjust; + g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (start_time), FALSE); + + start_time += mpeg_demux->adjust; + stop_time += mpeg_demux->adjust; if (!mpeg_demux->just_flushed) { - GST_DEBUG_OBJECT (mpeg_parse, "Discont without flush, ts = %llu", time); + GST_DEBUG_OBJECT (mpeg_parse, "NEWSEGMENT without flush, st = %llu", + start_time); /* Add padding to the end to make sure all streams end at the same timestamp */ CLASS (mpeg_demux)->synchronise_pads (mpeg_demux, mpeg_parse->current_ts + mpeg_demux->adjust + (GST_SECOND / 20), mpeg_parse->current_ts + mpeg_demux->adjust + (GST_SECOND / 20)); } else { - GST_DEBUG_OBJECT (mpeg_parse, "Discont after flush, ts = %llu", time); + GST_DEBUG_OBJECT (mpeg_parse, "NEWSEGMENT after flush, st = %llu", + start_time); } mpeg_demux->just_flushed = FALSE; - return parent_class->send_discont (mpeg_parse, time); + return parent_class->send_newsegment (mpeg_parse, rate, start_time, + stop_time); } static gboolean @@ -1054,7 +1035,6 @@ gst_mpeg_demux_send_subbuffer (GstMPEGDemux * mpeg_demux, GST_BUFFER_TIMESTAMP (outbuf) = timestamp; GST_BUFFER_OFFSET (outbuf) = GST_BUFFER_OFFSET (buffer) + offset; - g_print ("pushing buffer %p\n", GST_BUFFER (outbuf)); ret = gst_pad_push (outstream->pad, outbuf); if (GST_CLOCK_TIME_IS_VALID (mpeg_demux->max_gap) && diff --git a/gst/mpegstream/gstmpegparse.c b/gst/mpegstream/gstmpegparse.c index 157bd686b7..87f6972a1d 100644 --- a/gst/mpegstream/gstmpegparse.c +++ b/gst/mpegstream/gstmpegparse.c @@ -86,9 +86,14 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src", "mpegversion = (int) [ 1, 2 ], " "systemstream = (boolean) TRUE") ); +#define _do_init(bla) \ + GST_DEBUG_CATEGORY_INIT (gstmpegparse_debug, "mpegparse", 0, \ + "MPEG parser element"); + +GST_BOILERPLATE_FULL (GstMPEGParse, gst_mpeg_parse, GstElement, + GST_TYPE_ELEMENT, _do_init); + 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 GstStateChangeReturn gst_mpeg_parse_change_state (GstElement * element, GstStateChange transition); @@ -106,8 +111,8 @@ static GstFlowReturn gst_mpeg_parse_send_buffer (GstMPEGParse * mpeg_parse, GstBuffer * buffer, GstClockTime time); static GstFlowReturn gst_mpeg_parse_process_event (GstMPEGParse * mpeg_parse, GstEvent * event, GstClockTime time); -static GstFlowReturn gst_mpeg_parse_send_discont (GstMPEGParse * mpeg_parse, - GstClockTime time); +static GstFlowReturn gst_mpeg_parse_send_newsegment (GstMPEGParse * parse, + gdouble rate, GstClockTime start_time, GstClockTime stop_time); static gboolean gst_mpeg_parse_send_event (GstMPEGParse * mpeg_parse, GstEvent * event, GstClockTime time); @@ -123,40 +128,10 @@ static void gst_mpeg_parse_set_property (GObject * object, guint prop_id, static void gst_mpeg_parse_set_index (GstElement * element, GstIndex * index); static GstIndex *gst_mpeg_parse_get_index (GstElement * element); -static GstElementClass *parent_class = NULL; - static guint gst_mpeg_parse_signals[LAST_SIGNAL] = { 0 }; -GType -gst_mpeg_parse_get_type (void) -{ - static GType mpeg_parse_type = 0; - - if (!mpeg_parse_type) { - static const GTypeInfo mpeg_parse_info = { - sizeof (GstMPEGParseClass), - (GBaseInitFunc) gst_mpeg_parse_base_init, - NULL, - (GClassInitFunc) gst_mpeg_parse_class_init, - NULL, - NULL, - sizeof (GstMPEGParse), - 0, - (GInstanceInitFunc) gst_mpeg_parse_init, - }; - - mpeg_parse_type = - g_type_register_static (GST_TYPE_ELEMENT, "GstMPEGParse", - &mpeg_parse_info, 0); - - GST_DEBUG_CATEGORY_INIT (gstmpegparse_debug, "mpegparse", 0, - "MPEG parser element"); - } - return mpeg_parse_type; -} - static void -gst_mpeg_parse_base_init (GstMPEGParseClass * klass) +gst_mpeg_parse_base_init (gpointer klass) { GstElementClass *element_class = GST_ELEMENT_CLASS (klass); @@ -195,7 +170,7 @@ gst_mpeg_parse_class_init (GstMPEGParseClass * klass) klass->handle_discont = gst_mpeg_parse_handle_discont; klass->send_buffer = gst_mpeg_parse_send_buffer; klass->process_event = gst_mpeg_parse_process_event; - klass->send_discont = gst_mpeg_parse_send_discont; + klass->send_newsegment = gst_mpeg_parse_send_newsegment; klass->send_event = gst_mpeg_parse_send_event; /* FIXME: this is a hack. We add the pad templates here instead @@ -229,16 +204,18 @@ gst_mpeg_parse_class_init (GstMPEGParseClass * klass) } static void -gst_mpeg_parse_init (GstMPEGParse * mpeg_parse) +gst_mpeg_parse_init (GstMPEGParse * mpeg_parse, GstMPEGParseClass * klass) { - GstElementClass *klass = GST_ELEMENT_GET_CLASS (mpeg_parse); + GstElementClass *gstelement_class; GstPadTemplate *templ; - templ = gst_element_class_get_pad_template (klass, "sink"); + gstelement_class = GST_ELEMENT_GET_CLASS (mpeg_parse); + + templ = gst_element_class_get_pad_template (gstelement_class, "sink"); mpeg_parse->sinkpad = gst_pad_new_from_template (templ, "sink"); gst_element_add_pad (GST_ELEMENT (mpeg_parse), mpeg_parse->sinkpad); - if ((templ = gst_element_class_get_pad_template (klass, "src"))) { + if ((templ = gst_element_class_get_pad_template (gstelement_class, "src"))) { mpeg_parse->srcpad = gst_pad_new_from_template (templ, "src"); gst_element_add_pad (GST_ELEMENT (mpeg_parse), mpeg_parse->srcpad); gst_pad_set_event_function (mpeg_parse->srcpad, @@ -348,8 +325,9 @@ gst_mpeg_parse_handle_discont (GstMPEGParse * mpeg_parse, GstEvent * event) GST_DEBUG_OBJECT (mpeg_parse, "forwarding discontinuity, time: %0.3fs", (double) time / GST_SECOND); - if (CLASS (mpeg_parse)->send_discont) - ret = CLASS (mpeg_parse)->send_discont (mpeg_parse, time); + if (CLASS (mpeg_parse)->send_newsegment) + ret = CLASS (mpeg_parse)->send_newsegment (mpeg_parse, 1.0, time, + GST_CLOCK_TIME_NONE); } else { /* Use the next SCR to send a discontinuous event. */ GST_DEBUG_OBJECT (mpeg_parse, "Using next SCR to send discont"); @@ -402,15 +380,17 @@ gst_mpeg_parse_process_event (GstMPEGParse * mpeg_parse, GstEvent * event, } static gboolean -gst_mpeg_parse_send_discont (GstMPEGParse * mpeg_parse, GstClockTime time) +gst_mpeg_parse_send_newsegment (GstMPEGParse * mpeg_parse, gdouble rate, + GstClockTime start_time, GstClockTime stop_time) { GstEvent *event; - event = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, time, - GST_CLOCK_TIME_NONE, (gint64) 0); + event = gst_event_new_new_segment (FALSE, rate, GST_FORMAT_TIME, start_time, + stop_time, (gint64) 0); - if (CLASS (mpeg_parse)->send_event) - return CLASS (mpeg_parse)->send_event (mpeg_parse, event, time); + if (CLASS (mpeg_parse)->send_event) { + return CLASS (mpeg_parse)->send_event (mpeg_parse, event, start_time); + } return FALSE; } @@ -709,10 +689,10 @@ gst_mpeg_parse_chain (GstPad * pad, GstBuffer * buffer) MPEGTIME_TO_GSTTIME (mpeg_parse->current_scr)); } #endif - if (CLASS (mpeg_parse)->send_discont) { - CLASS (mpeg_parse)->send_discont (mpeg_parse, + if (CLASS (mpeg_parse)->send_newsegment) { + CLASS (mpeg_parse)->send_newsegment (mpeg_parse, 1.0, MPEGTIME_TO_GSTTIME (mpeg_parse->current_scr + - mpeg_parse->adjust)); + mpeg_parse->adjust), GST_CLOCK_TIME_NONE); } mpeg_parse->discont_pending = FALSE; } else { diff --git a/gst/mpegstream/gstmpegparse.h b/gst/mpegstream/gstmpegparse.h index 4e2dae537c..22fb9002e1 100644 --- a/gst/mpegstream/gstmpegparse.h +++ b/gst/mpegstream/gstmpegparse.h @@ -117,13 +117,19 @@ G_BEGIN_DECLS GstFlowReturn (*handle_discont) (GstMPEGParse * parse, GstEvent * event); /* optional method to send out the data */ - GstFlowReturn (*send_buffer) (GstMPEGParse * parse, GstBuffer * buffer, GstClockTime time); - gboolean (*process_event) (GstMPEGParse * parse, GstEvent * event, GstClockTime time); - gboolean (*send_discont) (GstMPEGParse * parse, GstClockTime time); - gboolean (*send_event) (GstMPEGParse * parse, GstEvent *event, GstClockTime time); + GstFlowReturn (*send_buffer) (GstMPEGParse * parse, + GstBuffer * buffer, GstClockTime time); + gboolean (*process_event) (GstMPEGParse * parse, + GstEvent * event, GstClockTime time); + gboolean (*send_newsegment)(GstMPEGParse * parse, gdouble rate, + GstClockTime start_time, + GstClockTime stop_time); + gboolean (*send_event) (GstMPEGParse * parse, GstEvent *event, + GstClockTime time); /* signals */ - void (*reached_offset) (GstMPEGParse *parse, GstClockTime timeval); + void (*reached_offset) (GstMPEGParse *parse, + GstClockTime timeval); }; GType gst_mpeg_parse_get_type (void);