Commit 099989ff authored by Tim-Philipp Müller's avatar Tim-Philipp Müller
Browse files

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.
parent 0c1fa2e8
......@@ -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)
/* 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;
......@@ -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_caps_unref (muxcaps);
stop_pipeline (bin, pad);
/* clean up */
......@@ -301,6 +317,30 @@ GST_START_TEST (test_vorbis)
("audiotestsrc num-buffers=5 ! audioconvert ! vorbisenc ! oggmux");
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'");
/* no sink, no async state change */
fail_unless_equals_int (gst_element_set_state (pipe, GST_STATE_PAUSED),
/* we expect an error (without any criticals/warnings) */
msg = gst_bus_timed_pop_filtered (GST_ELEMENT_BUS (pipe), -1,
gst_message_unref (msg);
fail_unless_equals_int (gst_element_set_state (pipe, GST_STATE_NULL),
gst_object_unref (pipe);
......@@ -370,6 +410,7 @@ oggmux_suite (void)
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_vorbis);
tcase_add_test (tc_chain, test_vorbis_oggmux_unlinked);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment