mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
tests: mpegtsmux: add unit test for "alignment" property
https://bugzilla.gnome.org/show_bug.cgi?id=722129
This commit is contained in:
parent
09c05df889
commit
ab52bfbfa6
1 changed files with 56 additions and 7 deletions
|
@ -54,6 +54,8 @@ static GstPad *mysrcpad, *mysinkpad;
|
|||
"alignment = (string) nal, " \
|
||||
"parsed = (boolean) true "
|
||||
|
||||
typedef void (CheckOutputBuffersFunc) (GList * buffers);
|
||||
|
||||
/* setup and teardown needs some special handling for muxer */
|
||||
static GstPad *
|
||||
setup_src_pad (GstElement * element,
|
||||
|
@ -146,8 +148,10 @@ cleanup_tsmux (GstElement * mux, const gchar * sinkname)
|
|||
static void
|
||||
check_tsmux_pad (GstStaticPadTemplate * srctemplate,
|
||||
const gchar * src_caps_string, gint pes_id, gint pmt_id,
|
||||
const gchar * sinkname)
|
||||
const gchar * sinkname, CheckOutputBuffersFunc check_func, guint n_bufs,
|
||||
gssize input_buf_size, guint alignment)
|
||||
{
|
||||
GstClockTime ts;
|
||||
GstElement *mux;
|
||||
GstBuffer *inbuffer, *outbuffer;
|
||||
GstCaps *caps;
|
||||
|
@ -157,17 +161,38 @@ check_tsmux_pad (GstStaticPadTemplate * srctemplate,
|
|||
gchar *padname;
|
||||
|
||||
mux = setup_tsmux (srctemplate, sinkname, &padname);
|
||||
|
||||
if (alignment != 0)
|
||||
g_object_set (mux, "alignment", alignment, NULL);
|
||||
|
||||
fail_unless (gst_element_set_state (mux,
|
||||
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
||||
"could not set to playing");
|
||||
|
||||
inbuffer = gst_buffer_new_and_alloc (1);
|
||||
caps = gst_caps_from_string (src_caps_string);
|
||||
gst_check_setup_events (mysrcpad, mux, caps, GST_FORMAT_TIME);
|
||||
gst_caps_unref (caps);
|
||||
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
||||
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
||||
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
||||
|
||||
ts = 0;
|
||||
for (i = 0; i < n_bufs; ++i) {
|
||||
GstFlowReturn flow;
|
||||
|
||||
if (input_buf_size >= 0)
|
||||
inbuffer = gst_buffer_new_and_alloc (input_buf_size);
|
||||
else
|
||||
inbuffer = gst_buffer_new_and_alloc (g_random_int_range (0, 49141));
|
||||
|
||||
GST_BUFFER_TIMESTAMP (inbuffer) = ts;
|
||||
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
||||
flow = gst_pad_push (mysrcpad, inbuffer);
|
||||
if (flow != GST_FLOW_OK)
|
||||
fail ("Got %s flow instead of OK", gst_flow_get_name (flow));
|
||||
ts += 40 * GST_MSECOND;
|
||||
}
|
||||
|
||||
if (check_func)
|
||||
check_func (buffers);
|
||||
|
||||
num_buffers = g_list_length (buffers);
|
||||
/* all output might get aggregated */
|
||||
fail_unless (num_buffers >= 1);
|
||||
|
@ -317,7 +342,7 @@ check_tsmux_pad (GstStaticPadTemplate * srctemplate,
|
|||
GST_START_TEST (test_video)
|
||||
{
|
||||
check_tsmux_pad (&video_src_template, VIDEO_CAPS_STRING, 0xE0, 0x1b,
|
||||
"sink_%d");
|
||||
"sink_%d", NULL, 1, 1, 0);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
@ -326,7 +351,7 @@ GST_END_TEST;
|
|||
GST_START_TEST (test_audio)
|
||||
{
|
||||
check_tsmux_pad (&audio_src_template, AUDIO_CAPS_STRING, 0xC0, 0x03,
|
||||
"sink_%d");
|
||||
"sink_%d", NULL, 1, 1, 0);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
@ -716,6 +741,29 @@ GST_START_TEST (test_multiple_state_change)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
static void
|
||||
test_align_check_output (GList * bufs)
|
||||
{
|
||||
GST_LOG ("%u buffers", g_list_length (bufs));
|
||||
while (bufs != NULL) {
|
||||
GstBuffer *buf = bufs->data;
|
||||
gsize size;
|
||||
|
||||
size = gst_buffer_get_size (buf);
|
||||
GST_LOG ("buffer, size = %5u", (guint) size);
|
||||
fail_unless_equals_int (size, 7 * 188);
|
||||
bufs = bufs->next;
|
||||
}
|
||||
}
|
||||
|
||||
GST_START_TEST (test_align)
|
||||
{
|
||||
check_tsmux_pad (&video_src_template, VIDEO_CAPS_STRING, 0xE0, 0x1b,
|
||||
"sink_%d", test_align_check_output, 817, -1, 7);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
static Suite *
|
||||
mpegtsmux_suite (void)
|
||||
{
|
||||
|
@ -730,6 +778,7 @@ mpegtsmux_suite (void)
|
|||
tcase_add_test (tc_chain, test_force_key_unit_event_upstream);
|
||||
tcase_add_test (tc_chain, test_propagate_flow_status);
|
||||
tcase_add_test (tc_chain, test_multiple_state_change);
|
||||
tcase_add_test (tc_chain, test_align);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue