[gst-devel] [patch] adding newmedia support to oggmux and rawvorbisenc

Zaheer Abbas Merali zaheerabbas at merali.org
Thu Aug 26 06:06:06 CEST 2004


Hi

I am in Toronto on holiday, so cannot be on irc much.

I have made changes to oggmux and vorbisenc that I would like in the
next release.  These should not affect normal use of both of them, just
when new media events occur.  Please review and apply.

Take Care


-- 
Zaheer Abbas Merali <zaheerabbas at merali.org>
-------------- next part --------------
? ogg.diff
Index: gstoggmux.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins/ext/ogg/gstoggmux.c,v
retrieving revision 1.15
diff -u -r1.15 gstoggmux.c
--- gstoggmux.c	22 Aug 2004 09:31:06 -0000	1.15
+++ gstoggmux.c	26 Aug 2004 12:13:21 -0000
@@ -100,6 +100,7 @@
   GstOggPad *delta_pad;         /* when a delta frame is detected on a stream, we mark
                                    pages as delta frames up to the page that has the
                                    keyframe */
+  guint16 newmediacount;				   
 };
 
 typedef enum
@@ -238,6 +239,7 @@
 {
   static const GstEventMask gst_ogg_mux_sink_event_masks[] = {
     {GST_EVENT_EOS, 0},
+    {GST_EVENT_DISCONTINUOUS, 0},
     {0,}
   };
 
@@ -268,7 +270,7 @@
   ogg_mux->max_page_delay = DEFAULT_MAX_PAGE_DELAY;
 
   ogg_mux->delta_pad = NULL;
-
+  ogg_mux->newmediacount = 0;
   gst_element_set_loop_function (GST_ELEMENT (ogg_mux), gst_ogg_mux_loop);
 }
 
@@ -429,6 +431,18 @@
         {
           gint64 value = 0;
 
+          if (GST_EVENT_DISCONT_NEW_MEDIA (event)) {
+            /* only handle if its not first new media event */
+	    if (ogg_mux->newmediacount++ > 0) {
+	      ogg_mux->next_ts = 0;
+              ogg_mux->offset = 0;
+              ogg_mux->pulling = NULL;
+	      pad->offset = 0;
+              GST_DEBUG_OBJECT (ogg_mux, "received new media event");
+	      gst_pad_event_default (pad->pad, event);
+	      break;
+	    }
+          }
           if (gst_event_discont_get_value (event, GST_FORMAT_TIME, &value)) {
             GST_DEBUG_OBJECT (ogg_mux,
                 "got discont of %" G_GUINT64_FORMAT " on pad %s:%s",
-------------- next part --------------
? .vorbisenc.c.swp
? vorbis.diff
Index: vorbisenc.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins/ext/vorbis/vorbisenc.c,v
retrieving revision 1.60
diff -u -r1.60 vorbisenc.c
--- vorbisenc.c	3 Aug 2004 14:28:11 -0000	1.60
+++ vorbisenc.c	26 Aug 2004 12:13:42 -0000
@@ -473,6 +473,7 @@
   vorbisenc->eos = FALSE;
   vorbisenc->header_sent = FALSE;
 
+  vorbisenc->newmediacount = 0;
   vorbisenc->tags = gst_tag_list_new ();
 
   /* we're chained and we can deal with events */
@@ -808,6 +809,20 @@
         }
         gst_pad_event_default (pad, event);
         return;
+      case GST_EVENT_DISCONTINUOUS:
+        if (GST_EVENT_DISCONT_NEW_MEDIA (event)) {
+	  /* only do for new media events after the first one */
+	  if (vorbisenc->newmediacount++ > 0) {
+	    vorbisenc->setup = FALSE;
+            vorbisenc->header_sent = FALSE;
+            gst_tag_list_free (vorbisenc->tags);
+            vorbisenc->tags = gst_tag_list_new ();
+	    vorbisenc->eos = FALSE;
+	    gst_vorbisenc_setup (vorbisenc);
+          }
+          gst_pad_event_default (pad, event);
+	  break;
+	}
       default:
         gst_pad_event_default (pad, event);
         return;
Index: vorbisenc.h
===================================================================
RCS file: /cvs/gstreamer/gst-plugins/ext/vorbis/vorbisenc.h,v
retrieving revision 1.12
diff -u -r1.12 vorbisenc.h
--- vorbisenc.h	10 May 2004 17:44:07 -0000	1.12
+++ vorbisenc.h	26 Aug 2004 12:13:42 -0000
@@ -77,6 +77,7 @@
   gboolean         setup;
   gboolean         header_sent;
   gchar		  *last_message;
+  guint16 newmediacount;
 };
 
 struct _VorbisEncClass {


More information about the gstreamer-devel mailing list