[gst-cvs] gst-plugins-good: matroskamux: store caps and set on buffers rather than using pad caps

Zaheer Abbas Merali zaheer at kemper.freedesktop.org
Tue Jun 1 09:00:24 PDT 2010


Module: gst-plugins-good
Branch: master
Commit: d3daa12473c9b850fa30b0c7274d946586366d8e
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=d3daa12473c9b850fa30b0c7274d946586366d8e

Author: Zaheer Abbas Merali <zaheerabbas at merali.org>
Date:   Fri May 21 13:38:11 2010 +0100

matroskamux: store caps and set on buffers rather than using pad caps

---

 gst/matroska/ebml-write.c   |   16 ++++++++++++++--
 gst/matroska/ebml-write.h   |    2 ++
 gst/matroska/matroska-mux.c |   18 ++++++------------
 3 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/gst/matroska/ebml-write.c b/gst/matroska/ebml-write.c
index b31472d..6bcc3e4 100644
--- a/gst/matroska/ebml-write.c
+++ b/gst/matroska/ebml-write.c
@@ -65,6 +65,8 @@ gst_ebml_write_init (GstEbmlWrite * ebml, GstEbmlWriteClass * klass)
   ebml->streamheader = NULL;
   ebml->streamheader_pos = 0;
   ebml->writing_streamheader = FALSE;
+
+  ebml->caps = NULL;
 }
 
 static void
@@ -84,6 +86,10 @@ gst_ebml_write_finalize (GObject * object)
     ebml->streamheader = NULL;
   }
 
+  if (ebml->caps) {
+    gst_caps_unref (ebml->caps);
+    ebml->caps = NULL;
+  }
   GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
 }
 
@@ -216,7 +222,7 @@ gst_ebml_write_flush_cache (GstEbmlWrite * ebml)
   buffer = gst_byte_writer_free_and_get_buffer (ebml->cache);
   ebml->cache = NULL;
   GST_DEBUG ("Flushing cache of size %d", GST_BUFFER_SIZE (buffer));
-
+  gst_buffer_set_caps (buffer, ebml->caps);
   if (ebml->last_write_result == GST_FLOW_OK) {
     if (ebml->need_newsegment) {
       GstEvent *ev;
@@ -225,6 +231,9 @@ gst_ebml_write_flush_cache (GstEbmlWrite * ebml)
       if (gst_pad_push_event (ebml->srcpad, ev))
         ebml->need_newsegment = FALSE;
     }
+    if (ebml->writing_streamheader) {
+      GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_IN_CAPS);
+    }
     ebml->last_write_result = gst_pad_push (ebml->srcpad, buffer);
   } else {
     gst_buffer_unref (buffer);
@@ -390,7 +399,10 @@ gst_ebml_write_element_push (GstEbmlWrite * ebml, GstBuffer * buf)
         ebml->need_newsegment = FALSE;
     }
     buf = gst_buffer_make_metadata_writable (buf);
-    gst_buffer_set_caps (buf, GST_PAD_CAPS (ebml->srcpad));
+    gst_buffer_set_caps (buf, ebml->caps);
+    if (ebml->writing_streamheader) {
+      GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_IN_CAPS);
+    }
     ebml->last_write_result = gst_pad_push (ebml->srcpad, buf);
   } else {
     gst_buffer_unref (buf);
diff --git a/gst/matroska/ebml-write.h b/gst/matroska/ebml-write.h
index 72ac2e1..38f0766 100644
--- a/gst/matroska/ebml-write.h
+++ b/gst/matroska/ebml-write.h
@@ -59,6 +59,8 @@ typedef struct _GstEbmlWrite {
   gboolean writing_streamheader;
   GstByteWriter *streamheader;
   guint64 streamheader_pos;
+
+  GstCaps *caps;
 } GstEbmlWrite;
 
 typedef struct _GstEbmlWriteClass {
diff --git a/gst/matroska/matroska-mux.c b/gst/matroska/matroska-mux.c
index 2fc52d9..f0244c4 100644
--- a/gst/matroska/matroska-mux.c
+++ b/gst/matroska/matroska-mux.c
@@ -2007,16 +2007,10 @@ gst_matroska_mux_start (GstMatroskaMux * mux)
   GTimeVal time = { 0, 0 };
   GstBuffer *streamheader_buffer;
 
-  /* set initial pad caps */
-  {
-    GstCaps *caps;
-    if (!strcmp (mux->doctype, GST_MATROSKA_DOCTYPE_WEBM)) {
-      caps = gst_caps_from_string ("video/webm");
-    } else {
-      caps = gst_caps_from_string ("video/x-matroska");
-    }
-    gst_pad_set_caps (mux->srcpad, caps);
-    gst_caps_unref (caps);
+  if (!strcmp (mux->doctype, GST_MATROSKA_DOCTYPE_WEBM)) {
+    ebml->caps = gst_caps_from_string ("video/webm");
+  } else {
+    ebml->caps = gst_caps_from_string ("video/x-matroska");
   }
   /* we start with a EBML header */
   doctype = mux->doctype;
@@ -2135,8 +2129,8 @@ gst_matroska_mux_start (GstMatroskaMux * mux)
     g_value_unset (&bufval);
     gst_structure_set_value (s, "streamheader", &streamheader);
     g_value_unset (&streamheader);
-    gst_pad_set_caps (mux->srcpad, caps);
-    gst_caps_unref (caps);
+    gst_caps_unref (ebml->caps);
+    ebml->caps = caps;
   }
 }
 





More information about the Gstreamer-commits mailing list