mpegtsmux: propagate flow returns

And add a unit test.

https://bugzilla.gnome.org/show_bug.cgi?id=688870
This commit is contained in:
Krzysztof Konopko 2012-11-22 10:57:25 +00:00 committed by Tim-Philipp Müller
parent 97a365c439
commit 76b8e8be51
2 changed files with 58 additions and 3 deletions

View file

@ -1172,9 +1172,7 @@ mpegtsmux_collected_buffer (GstCollectPads * pads, GstCollectData * data,
}
}
/* flush packet cache */
mpegtsmux_push_packets (mux, FALSE);
return ret;
return mpegtsmux_push_packets (mux, FALSE);
/* ERRORS */
write_fail:

View file

@ -620,6 +620,62 @@ GST_START_TEST (test_force_key_unit_event_upstream)
GST_END_TEST;
static GstFlowReturn
flow_test_stat_chain_func (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
/* the requested status is conveyed in the timestamp */
GstFlowReturn ret = (GstFlowReturn) GST_BUFFER_TIMESTAMP (buffer);
gst_buffer_unref (buffer);
return ret;
}
GST_START_TEST (test_propagate_flow_status)
{
GstElement *mux;
gchar *padname;
GstSegment segment;
GstBuffer *inbuffer;
GstCaps *caps;
guint i;
GstFlowReturn expected[] = { GST_FLOW_OK, GST_FLOW_FLUSHING, GST_FLOW_EOS,
GST_FLOW_NOT_NEGOTIATED, GST_FLOW_ERROR, GST_FLOW_NOT_SUPPORTED
};
mux = setup_tsmux (&video_src_template, "sink_%d", &padname);
gst_pad_set_chain_function (mysinkpad, flow_test_stat_chain_func);
fail_unless (gst_element_set_state (mux,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
gst_segment_init (&segment, GST_FORMAT_TIME);
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_segment (&segment)));
caps = gst_caps_from_string (VIDEO_CAPS_STRING);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
for (i = 0; i < G_N_ELEMENTS (expected); ++i) {
GstFlowReturn res;
inbuffer = gst_buffer_new_and_alloc (1);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* convey the requested status in the timestamp */
GST_BUFFER_TIMESTAMP (inbuffer) = expected[i];
res = gst_pad_push (mysrcpad, inbuffer);
fail_unless (res == expected[i],
"result: %d, expected: %d", res, expected[i]);
}
cleanup_tsmux (mux, padname);
g_free (padname);
}
GST_END_TEST;
static Suite *
mpegtsmux_suite (void)
{
@ -632,6 +688,7 @@ mpegtsmux_suite (void)
tcase_add_test (tc_chain, test_video);
tcase_add_test (tc_chain, test_force_key_unit_event_downstream);
tcase_add_test (tc_chain, test_force_key_unit_event_upstream);
tcase_add_test (tc_chain, test_propagate_flow_status);
return s;
}