"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,
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;
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);
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;
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;
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)
{
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;
}