[gst-cvs] gst-plugins-base: oggmux: don' t drop the streamheader field from the output caps

Tim Mueller tpm at kemper.freedesktop.org
Thu Aug 20 05:20:10 PDT 2009


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

Author: Tim-Philipp Müller <tim.muller at collabora.co.uk>
Date:   Thu Aug 20 13:11:07 2009 +0100

oggmux: don't drop the streamheader field from the output caps

Revert previous 'fix' for bug #588717 and fix it properly, whilst
maintaining the streamheader field on the output caps. Also make
sure we don't leak header buffers we couldn't push when downstream
is unlinked. Add unit test for the presence of the streamheader
field on the output caps and for the issue from bug #588717.

---

 ext/ogg/gstoggmux.c            |   14 +++++++-----
 tests/check/pipelines/oggmux.c |   41 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+), 6 deletions(-)

diff --git a/ext/ogg/gstoggmux.c b/ext/ogg/gstoggmux.c
index bed43b0..f943150 100644
--- a/ext/ogg/gstoggmux.c
+++ b/ext/ogg/gstoggmux.c
@@ -499,9 +499,10 @@ gst_ogg_mux_push_buffer (GstOggMux * mux, GstBuffer * buffer)
       mux->last_ts = GST_BUFFER_TIMESTAMP (buffer);
   }
 
-  caps = gst_static_pad_template_get_caps (&src_factory);
+  caps = gst_pad_get_negotiated_caps (mux->srcpad);
   gst_buffer_set_caps (buffer, caps);
-  gst_caps_unref (caps);
+  if (caps)
+    gst_caps_unref (caps);
 
   return gst_pad_push (mux->srcpad, buffer);
 }
@@ -1130,15 +1131,16 @@ gst_ogg_mux_send_headers (GstOggMux * mux)
     gst_caps_unref (caps);
   }
   /* and send the buffers */
-  hwalk = hbufs;
-  while (hwalk) {
-    GstBuffer *buf = GST_BUFFER (hwalk->data);
+  while (hbufs != NULL) {
+    GstBuffer *buf = GST_BUFFER (hbufs->data);
 
-    hwalk = hwalk->next;
+    hbufs = g_list_delete_link (hbufs, hbufs);
 
     if ((ret = gst_ogg_mux_push_buffer (mux, buf)) != GST_FLOW_OK)
       break;
   }
+  /* free any remaining nodes/buffers in case we couldn't push them */
+  g_list_foreach (hbufs, (GFunc) gst_mini_object_unref, NULL);
   g_list_free (hbufs);
 
   return ret;
diff --git a/tests/check/pipelines/oggmux.c b/tests/check/pipelines/oggmux.c
index ef01eed..16bb3f2 100644
--- a/tests/check/pipelines/oggmux.c
+++ b/tests/check/pipelines/oggmux.c
@@ -286,6 +286,22 @@ test_pipeline (const char *pipeline)
 
   start_pipeline (bin, pad);
   g_main_loop_run (loop);
+
+  /* we're EOS now; make sure oggmux out caps have stream headers on them */
+  {
+    GstStructure *s;
+    GstCaps *muxcaps;
+
+    muxcaps = gst_pad_get_negotiated_caps (sinkpad);
+    fail_unless (muxcaps != NULL);
+    s = gst_caps_get_structure (muxcaps, 0);
+    fail_unless (gst_structure_has_name (s, "application/ogg"));
+    fail_unless (gst_structure_has_field (s, "streamheader"));
+    fail_unless (gst_structure_has_field_typed (s, "streamheader",
+            GST_TYPE_ARRAY));
+    gst_caps_unref (muxcaps);
+  }
+
   stop_pipeline (bin, pad);
 
   /* clean up */
@@ -302,6 +318,30 @@ GST_START_TEST (test_vorbis)
 }
 
 GST_END_TEST;
+
+GST_START_TEST (test_vorbis_oggmux_unlinked)
+{
+  GstElement *pipe;
+  GstMessage *msg;
+
+  pipe = gst_parse_launch ("audiotestsrc ! vorbisenc ! oggmux", NULL);
+  if (pipe == NULL) {
+    g_printerr ("Skipping test 'test_vorbis_oggmux_unlinked'");
+    return;
+  }
+  /* no sink, no async state change */
+  fail_unless_equals_int (gst_element_set_state (pipe, GST_STATE_PAUSED),
+      GST_STATE_CHANGE_SUCCESS);
+  /* we expect an error (without any criticals/warnings) */
+  msg = gst_bus_timed_pop_filtered (GST_ELEMENT_BUS (pipe), -1,
+      GST_MESSAGE_ERROR);
+  gst_message_unref (msg);
+  fail_unless_equals_int (gst_element_set_state (pipe, GST_STATE_NULL),
+      GST_STATE_CHANGE_SUCCESS);
+  gst_object_unref (pipe);
+}
+
+GST_END_TEST;
 #endif
 
 #ifdef HAVE_THEORA
@@ -370,6 +410,7 @@ oggmux_suite (void)
   suite_add_tcase (s, tc_chain);
 #ifdef HAVE_VORBIS
   tcase_add_test (tc_chain, test_vorbis);
+  tcase_add_test (tc_chain, test_vorbis_oggmux_unlinked);
 #endif
 
 #ifdef HAVE_THEORA





More information about the Gstreamer-commits mailing list