mpegpsmux: remember whether an incoming buffer is a keyunit or not
authorTim-Philipp Müller <tim.muller@collabora.co.uk>
Wed, 31 Aug 2011 18:40:05 +0000 (19:40 +0100)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Sun, 11 Dec 2011 00:10:12 +0000 (00:10 +0000)
gst/mpegpsmux/mpegpsmux.c
gst/mpegpsmux/psmuxstream.c
gst/mpegpsmux/psmuxstream.h

index be8e3da..d0e31bb 100644 (file)
@@ -454,6 +454,7 @@ mpegpsmux_collected (GstCollectPads * pads, MpegPsMux * mux)
 
   GstFlowReturn ret = GST_FLOW_OK;
   MpegPsPadData *best = NULL;
+  gboolean keyunit;
 
   GST_DEBUG_OBJECT (mux, "Pads collected");
 
@@ -496,9 +497,12 @@ mpegpsmux_collected (GstCollectPads * pads, MpegPsMux * mux)
           G_GINT64_FORMAT, GST_TIME_ARGS (best->cur_ts), pts);
     }
 
+    keyunit = !GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT);
+
     /* give the buffer to libpsmux for processing */
     psmux_stream_add_data (best->stream, GST_BUFFER_DATA (buf),
-        GST_BUFFER_SIZE (buf), buf, pts, -1);
+        GST_BUFFER_SIZE (buf), buf, pts, -1, keyunit);
+
     best->queued_buf = NULL;
 
     /* write the data from libpsmux to stream */
index e91cc00..a0bd38e 100644 (file)
@@ -513,7 +513,7 @@ psmux_stream_write_pes_header (PsMuxStream * stream, guint8 * data)
  */
 void
 psmux_stream_add_data (PsMuxStream * stream, guint8 * data, guint len,
-    void *user_data, gint64 pts, gint64 dts)
+    void *user_data, gint64 pts, gint64 dts, gboolean keyunit)
 {
   PsMuxStreamBuffer *packet;
 
@@ -524,6 +524,7 @@ psmux_stream_add_data (PsMuxStream * stream, guint8 * data, guint len,
   packet->size = len;
   packet->user_data = user_data;
 
+  packet->keyunit = keyunit;
   packet->pts = pts;
   packet->dts = dts;
 
index 9860e62..ff4c289 100644 (file)
@@ -86,6 +86,8 @@ struct PsMuxStreamBuffer
   guint8 *data;
   guint32 size;
 
+  gboolean keyunit;
+
   /* PTS & DTS associated with the contents of this buffer */
   GstClockTime pts;
   GstClockTime dts;
@@ -146,7 +148,8 @@ void                psmux_stream_set_buffer_release_func    (PsMuxStream *stream,
 /* Add a new buffer to the pool of available bytes. If pts or dts are not -1, they
  * indicate the PTS or DTS of the first access unit within this packet */
 void           psmux_stream_add_data           (PsMuxStream *stream, guint8 *data, guint len,
-                                                        void *user_data, gint64 pts, gint64 dts);
+                                                void *user_data, gint64 pts, gint64 dts,
+                                                gboolean keyunit);
 
 /* total bytes in buffer */
 gint           psmux_stream_bytes_in_buffer    (PsMuxStream *stream);