oggmux: do not skip a pageno at start
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Fri, 21 Jan 2011 10:56:00 +0000 (10:56 +0000)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Tue, 1 Feb 2011 17:25:43 +0000 (17:25 +0000)
Discontinuities are automatically signalled by oggdemux at the start
of a new stream. When oggmux is yet to output actual data pages,
do not signal these discontinuities in the ogg stream.

This patch may miss some actual discontinuities at the very start of
a stream, but avoids the spurious missing pages when encoding happens
normally.

A better fix might involve finding a way to distinguish between actual
data discontinuities and discontinuities merely marking the start of
a new stream.

Fixes an issue with ogg page numbering (would skip a number for no
reason, which then looks like a packet was lost somewhere) when
re-muxing an ogg stream, e.g. when re-tagging in rhythmbox.

https://bugzilla.gnome.org/show_bug.cgi?id=629196

ext/ogg/gstoggmux.c
ext/ogg/gstoggmux.h

index 11a6792..c36b4fb 100644 (file)
@@ -394,6 +394,7 @@ gst_ogg_mux_request_new_pad (GstElement * element,
       oggpad->new_page = TRUE;
       oggpad->first_delta = FALSE;
       oggpad->prev_delta = FALSE;
+      oggpad->data_pushed = FALSE;
       oggpad->pagebuffers = g_queue_new ();
 
       oggpad->collect_event = (GstPadEventFunction) GST_PAD_EVENTFUNC (newpad);
@@ -1306,11 +1307,15 @@ gst_ogg_mux_process_best_pad (GstOggMux * ogg_mux, GstOggPadData * best)
     }
 
     if (GST_BUFFER_IS_DISCONT (buf)) {
-      GST_LOG_OBJECT (pad->collect.pad, "got discont");
-      packet.packetno++;
-      /* No public API for this; hack things in */
-      pad->stream.pageno++;
-      force_flush = TRUE;
+      if (pad->data_pushed) {
+        GST_LOG_OBJECT (pad->collect.pad, "got discont");
+        packet.packetno++;
+        /* No public API for this; hack things in */
+        pad->stream.pageno++;
+        force_flush = TRUE;
+      } else {
+        GST_LOG_OBJECT (pad->collect.pad, "discont at stream start");
+      }
     }
 
     /* flush the currently built page if necessary */
@@ -1364,6 +1369,7 @@ gst_ogg_mux_process_best_pad (GstOggMux * ogg_mux, GstOggPadData * best)
       GST_DEBUG_OBJECT (pad->collect.pad, "swapping in BOS packet");
 
     ogg_stream_packetin (&pad->stream, &packet);
+    pad->data_pushed = TRUE;
 
     gp_time = GST_BUFFER_OFFSET (pad->buffer);
     granulepos = GST_BUFFER_OFFSET_END (pad->buffer);
@@ -1607,6 +1613,7 @@ gst_ogg_mux_init_collectpads (GstCollectPads * collect)
     oggpad->new_page = TRUE;
     oggpad->first_delta = FALSE;
     oggpad->prev_delta = FALSE;
+    oggpad->data_pushed = FALSE;
     oggpad->pagebuffers = g_queue_new ();
 
     walk = g_slist_next (walk);
index 6134d5e..37b1fae 100644 (file)
@@ -78,6 +78,7 @@ typedef struct
   gboolean new_page;            /* starting a new page */
   gboolean first_delta;         /* was the first packet in the page a delta */
   gboolean prev_delta;          /* was the previous buffer a delta frame */
+  gboolean data_pushed;         /* whether we pushed data already */
 
   GstPadEventFunction collect_event;