qtmux: Test gaps at start of stream

https://bugzilla.gnome.org/show_bug.cgi?id=751242
This commit is contained in:
Nicolas Dufresne 2015-06-19 18:37:59 -04:00 committed by Nicolas Dufresne
parent 7b8615d4fc
commit 89104e35bf

View file

@ -930,6 +930,10 @@ struct TestInputData
* is used to vefity it */ * is used to vefity it */
gint64 expected_segment_start; gint64 expected_segment_start;
GstClockTime expected_gap_ts;
GstClockTime expected_gap_duration;
gboolean gap_received;
GstPad *sinkpad; GstPad *sinkpad;
GList *output_iter; GList *output_iter;
@ -940,6 +944,9 @@ test_input_data_init (struct TestInputData *data)
{ {
data->ts_offset = 0; data->ts_offset = 0;
data->expected_segment_start = 0; data->expected_segment_start = 0;
data->expected_gap_ts = 0;
data->expected_gap_duration = 0;
data->gap_received = FALSE;
data->srcpad = NULL; data->srcpad = NULL;
data->sinkpad = NULL; data->sinkpad = NULL;
data->input = NULL; data->input = NULL;
@ -1071,6 +1078,15 @@ _test_sink_pad_event (GstPad * pad, GstObject * parent, GstEvent * event)
test_data->output_iter = g_list_next (test_data->output_iter); test_data->output_iter = g_list_next (test_data->output_iter);
break; break;
} }
case GST_EVENT_GAP:{
GstClockTime timestamp;
GstClockTime duration;
gst_event_parse_gap (event, &timestamp, &duration);
fail_unless (timestamp == test_data->expected_gap_ts);
fail_unless (duration == test_data->expected_gap_duration);
test_data->gap_received = TRUE;
break;
}
case GST_EVENT_TAG: case GST_EVENT_TAG:
/* ignore this event */ /* ignore this event */
break; break;
@ -1426,8 +1442,9 @@ GST_START_TEST (test_muxing_dts_outside_segment)
g_list_append (input1.input, create_buffer (3 * GST_SECOND, g_list_append (input1.input, create_buffer (3 * GST_SECOND,
2 * GST_SECOND, GST_SECOND, 4096)); 2 * GST_SECOND, GST_SECOND, 4096));
input1.input = g_list_append (input1.input, gst_event_new_eos ()); input1.input = g_list_append (input1.input, gst_event_new_eos ());
/* First DTS is 0, first PTS is 1s, so the output segment should /* First DTS is 0, first PTS is 1s. The segment start being 1, this means
* start from 1s to have the first running time == 0 */ * running time -1s and 0. So the output segment should start from 1s to keep
* the same running time */
input1.expected_segment_start = GST_SECOND; input1.expected_segment_start = GST_SECOND;
input2.input = NULL; input2.input = NULL;
@ -1457,6 +1474,74 @@ GST_START_TEST (test_muxing_dts_outside_segment)
GST_END_TEST; GST_END_TEST;
GST_START_TEST (test_muxing_initial_gap)
{
struct TestInputData input1, input2;
GstCaps *caps;
test_input_data_init (&input1);
test_input_data_init (&input2);
/* Create the inputs, after calling the run below, all this data is
* transfered to it and we have no need to clean up */
input1.input = NULL;
input1.input =
g_list_append (input1.input, gst_event_new_stream_start ("test-1"));
caps = gst_caps_from_string
("video/x-h264, width=(int)800, height=(int)600, "
"framerate=(fraction)1/1, stream-format=(string)avc, codec_data=(buffer)0000,"
" alignment=(string)au, level=(int)2, profile=(string)high");
input1.input = g_list_append (input1.input, gst_event_new_caps (caps));
gst_caps_unref (caps);
gst_segment_init (&input1.segment, GST_FORMAT_TIME);
input1.input =
g_list_append (input1.input, gst_event_new_segment (&input1.segment));
/* Duplicate the segment to please the harness */
input1.input =
g_list_append (input1.input, gst_event_new_segment (&input1.segment));
input1.input =
g_list_append (input1.input, create_buffer (1 * GST_SECOND,
0, GST_SECOND, 4096));
input1.input =
g_list_append (input1.input, create_buffer (2 * GST_SECOND,
1 * GST_SECOND, GST_SECOND, 4096));
input1.input =
g_list_append (input1.input, create_buffer (3 * GST_SECOND,
2 * GST_SECOND, GST_SECOND, 4096));
input1.input = g_list_append (input1.input, gst_event_new_eos ());
/* We expect a 1s gap at the start */
input1.expected_gap_duration = GST_SECOND;
input2.input = NULL;
input2.input =
g_list_append (input2.input, gst_event_new_stream_start ("test-2"));
caps = gst_caps_from_string
("audio/mpeg, rate=(int)44100, channels=(int)1, mpegversion=(int)4, "
"stream-format=(string)raw, framed=(boolean)true");
input2.input = g_list_append (input2.input, gst_event_new_caps (caps));
gst_caps_unref (caps);
gst_segment_init (&input2.segment, GST_FORMAT_TIME);
input2.input =
g_list_append (input2.input, gst_event_new_segment (&input2.segment));
input2.input =
g_list_append (input2.input, create_buffer (0, 0, GST_SECOND,
44100 * 4 * 2));
input2.input =
g_list_append (input2.input, create_buffer (GST_SECOND, GST_SECOND,
GST_SECOND, 44100 * 4 * 2));
input2.input =
g_list_append (input2.input, create_buffer (2 * GST_SECOND,
2 * GST_SECOND, GST_SECOND, 44100 * 4 * 2));
input2.input = g_list_append (input2.input, gst_event_new_eos ());
run_muxing_test (&input1, &input2);
fail_unless (input1.gap_received);
}
GST_END_TEST;
static Suite * static Suite *
qtmux_suite (void) qtmux_suite (void)
{ {
@ -1498,6 +1583,7 @@ qtmux_suite (void)
tcase_add_test (tc_chain, test_muxing_non_zero_segment); tcase_add_test (tc_chain, test_muxing_non_zero_segment);
tcase_add_test (tc_chain, test_muxing_non_zero_segment_different); tcase_add_test (tc_chain, test_muxing_non_zero_segment_different);
tcase_add_test (tc_chain, test_muxing_dts_outside_segment); tcase_add_test (tc_chain, test_muxing_dts_outside_segment);
tcase_add_test (tc_chain, test_muxing_initial_gap);
return s; return s;
} }