? mpegstream.diff
Index: gstdvddemux.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins/gst/mpegstream/gstdvddemux.c,v
retrieving revision 1.13
diff -u -r1.13 gstdvddemux.c
--- gstdvddemux.c	16 Dec 2004 12:54:04 -0000	1.13
+++ gstdvddemux.c	21 Dec 2004 23:06:13 -0000
@@ -131,6 +131,8 @@
 
 static void gst_dvd_demux_send_discont
     (GstMPEGParse * mpeg_parse, GstClockTime time);
+static void gst_dvd_demux_handle_discont
+    (GstMPEGParse * mpeg_parse, GstEvent * event);
 static gboolean gst_dvd_demux_handle_dvd_event
     (GstDVDDemux * dvd_demux, GstEvent * event);
 
@@ -159,6 +161,10 @@
 static void gst_dvd_demux_set_cur_subpicture
     (GstDVDDemux * dvd_demux, gint stream_nr);
 
+static void gst_dvd_demux_reset
+    (GstDVDDemux * dvd_demux);
+
+
 static GstElementStateReturn gst_dvd_demux_change_state (GstElement * element);
 
 static GstMPEGDemuxClass *parent_class = NULL;
@@ -247,6 +253,7 @@
   gstelement_class->change_state = gst_dvd_demux_change_state;
 
   mpeg_parse_class->send_discont = gst_dvd_demux_send_discont;
+  mpeg_parse_class->handle_discont = gst_dvd_demux_handle_discont;
 
   mpeg_demux_class->get_audio_stream = gst_dvd_demux_get_audio_stream;
   mpeg_demux_class->get_video_stream = gst_dvd_demux_get_video_stream;
@@ -478,6 +485,20 @@
   }
 }
 
+static void
+gst_dvd_demux_handle_discont (GstMPEGParse * mpeg_parse, GstEvent * event)
+{
+  GstDVDDemux *dvd_demux = GST_DVD_DEMUX (mpeg_parse);
+
+  if (GST_EVENT_DISCONT_NEW_MEDIA(event)) {
+    gst_dvd_demux_reset(dvd_demux);
+  }
+
+  /* before we reset let parent handle and forward discont */
+  if (GST_MPEG_PARSE_CLASS(parent_class)->handle_discont != NULL)
+    GST_MPEG_PARSE_CLASS(parent_class)->handle_discont(mpeg_parse, event);
+}
+
 static GstMPEGStream *
 gst_dvd_demux_get_video_stream (GstMPEGDemux * mpeg_demux,
     guint8 stream_nr, gint type, const gpointer info)
Index: gstmpegdemux.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins/gst/mpegstream/gstmpegdemux.c,v
retrieving revision 1.69
diff -u -r1.69 gstmpegdemux.c
--- gstmpegdemux.c	16 Dec 2004 12:54:04 -0000	1.69
+++ gstmpegdemux.c	21 Dec 2004 23:06:16 -0000
@@ -93,6 +93,9 @@
     GstData * data, GstClockTime time);
 static void gst_mpeg_demux_send_discont (GstMPEGParse * mpeg_parse,
     GstClockTime time);
+static void gst_mpeg_demux_handle_discont (GstMPEGParse * mpeg_parse,
+    GstEvent * event);
+
 
 static GstPad *gst_mpeg_demux_new_output_pad (GstMPEGDemux * mpeg_demux,
     const gchar * name, GstPadTemplate * temp);
@@ -130,6 +133,8 @@
 
 static gboolean gst_mpeg_demux_handle_src_event (GstPad * pad,
     GstEvent * event);
+static void gst_mpeg_demux_reset (GstMPEGDemux * mpeg_demux);
+
 
 static GstElementStateReturn gst_mpeg_demux_change_state (GstElement * element);
 
@@ -207,6 +212,7 @@
   mpeg_parse_class->parse_pes = gst_mpeg_demux_parse_pes;
   mpeg_parse_class->send_data = gst_mpeg_demux_send_data;
   mpeg_parse_class->send_discont = gst_mpeg_demux_send_discont;
+  mpeg_parse_class->handle_discont = gst_mpeg_demux_handle_discont;
 
   klass->new_output_pad = gst_mpeg_demux_new_output_pad;
   klass->init_stream = gst_mpeg_demux_init_stream;
@@ -301,6 +307,19 @@
   }
 }
 
+static void
+gst_mpeg_demux_handle_discont (GstMPEGParse * mpeg_parse, GstEvent * event)
+{
+  GstMPEGDemux *mpeg_demux = GST_MPEG_DEMUX (mpeg_parse);
+
+  if (GST_EVENT_DISCONT_NEW_MEDIA(event)) {
+    gst_mpeg_demux_reset(mpeg_demux);
+  }
+
+  if (parent_class->handle_discont != NULL)
+    parent_class->handle_discont(mpeg_parse, event);
+}
+
 static gint
 _demux_get_writer_id (GstIndex * index, GstPad * pad)
 {
