Commit 11b7016f authored by Ognyan Tonchev's avatar Ognyan Tonchev Committed by Wim Taymans
Browse files

tests: add unit tests for buffer-list payloaders

See #585559
parent 83a0e7d2
......@@ -42,6 +42,45 @@ typedef struct
int frame_count;
} rtp_pipeline;
/*
* Number of bytes received in the chain list function when using buffer lists
*/
static guint chain_list_bytes_received;
/*
* Chain list function for testing buffer lists
*/
static GstFlowReturn
rtp_pipeline_chain_list (GstPad * pad, GstBufferList * list)
{
GstBufferListIterator *it;
fail_if (!list);
it = gst_buffer_list_iterate (list);
/*
* Count the size of the payload in the buffer list.
*/
/* Loop through all groups */
while (gst_buffer_list_iterator_next_group (it)) {
GstBuffer *paybuf;
/* Skip the first buffer in the group, its the RTP header */
fail_if (!gst_buffer_list_iterator_next (it));
/* Loop through all payload buffers in the current group */
while ((paybuf = gst_buffer_list_iterator_next (it))) {
chain_list_bytes_received += GST_BUFFER_SIZE (paybuf);
}
}
gst_buffer_list_iterator_free (it);
gst_buffer_list_unref (list);
return GST_FLOW_OK;
}
/*
* RTP bus callback.
*/
......@@ -274,6 +313,27 @@ rtp_pipeline_run (rtp_pipeline * p)
g_main_loop_unref (mainloop);
}
/*
* Enables buffer lists. Sets the buffer-list property of the payloader
* and adds a chain_list_function to the depayloader.
* @param p Pointer to the RTP pipeline.
*/
static void
rtp_pipeline_enable_lists (rtp_pipeline * p, guint mtu_size)
{
/* use buffer lists */
g_object_set (p->rtppay, "buffer-list", TRUE, NULL);
/* set mtu size if needed */
if (mtu_size) {
g_object_set (p->rtppay, "mtu", mtu_size, NULL);
}
/* Add chain list function for the buffer list tests */
gst_pad_set_chain_list_function (gst_element_get_static_pad (p->rtpdepay,
"sink"), GST_DEBUG_FUNCPTR (rtp_pipeline_chain_list));
}
/*
* Creates the RTP pipeline and runs the test using the pipeline.
* @param frame_data Pointer to the frame data which is used to pass thru pay/depayloaders.
......@@ -282,10 +342,14 @@ rtp_pipeline_run (rtp_pipeline * p)
* @param filtercaps Caps filters.
* @param pay Payloader name.
* @param depay Depayloader name.
* @bytes_sent bytes that will be sent, used when testing buffer lists
* @mtu_size set mtu size when testing lists
* @use_lists enable buffer lists
*/
static void
rtp_pipeline_test (const char *frame_data, int frame_data_size, int frame_count,
const char *filtercaps, const char *pay, const char *depay)
const char *filtercaps, const char *pay, const char *depay,
guint bytes_sent, guint mtu_size, gboolean use_lists)
{
/* Create RTP pipeline. */
rtp_pipeline *p =
......@@ -296,11 +360,21 @@ rtp_pipeline_test (const char *frame_data, int frame_data_size, int frame_count,
return;
}
if (use_lists) {
rtp_pipeline_enable_lists (p, mtu_size);
chain_list_bytes_received = 0;
}
/* Run RTP pipeline. */
rtp_pipeline_run (p);
/* Destroy RTP pipeline. */
rtp_pipeline_destroy (p);
if (use_lists) {
/* 'next NAL' indicator is 4 bytes */
fail_if (chain_list_bytes_received != bytes_sent * LOOP_COUNT);
}
}
static char rtp_ilbc_frame_data[] =
......@@ -316,7 +390,7 @@ GST_START_TEST (rtp_ilbc)
{
rtp_pipeline_test (rtp_ilbc_frame_data, rtp_ilbc_frame_data_size,
rtp_ilbc_frame_count, "audio/x-iLBC,mode=20", "rtpilbcpay",
"rtpilbcdepay");
"rtpilbcdepay", 0, 0, FALSE);
}
GST_END_TEST;
......@@ -333,7 +407,7 @@ GST_START_TEST (rtp_gsm)
{
rtp_pipeline_test (rtp_gsm_frame_data, rtp_gsm_frame_data_size,
rtp_gsm_frame_count, "audio/x-gsm,rate=8000,channels=1", "rtpgsmpay",
"rtpgsmdepay");
"rtpgsmdepay", 0, 0, FALSE);
}
GST_END_TEST;
......@@ -351,7 +425,7 @@ GST_START_TEST (rtp_amr)
{
rtp_pipeline_test (rtp_amr_frame_data, rtp_amr_frame_data_size,
rtp_amr_frame_count, "audio/AMR,channels=1,rate=8000", "rtpamrpay",
"rtpamrdepay");
"rtpamrdepay", 0, 0, FALSE);
}
GST_END_TEST;
......@@ -368,7 +442,7 @@ GST_START_TEST (rtp_pcma)
{
rtp_pipeline_test (rtp_pcma_frame_data, rtp_pcma_frame_data_size,
rtp_pcma_frame_count, "audio/x-alaw,channels=1,rate=8000", "rtppcmapay",
"rtppcmadepay");
"rtppcmadepay", 0, 0, FALSE);
}
GST_END_TEST;
......@@ -385,7 +459,7 @@ GST_START_TEST (rtp_pcmu)
{
rtp_pipeline_test (rtp_pcmu_frame_data, rtp_pcmu_frame_data_size,
rtp_pcmu_frame_count, "audio/x-mulaw,channels=1,rate=8000", "rtppcmupay",
"rtppcmudepay");
"rtppcmudepay", 0, 0, FALSE);
}
GST_END_TEST;
......@@ -401,7 +475,8 @@ static int rtp_mpa_frame_count = 1;
GST_START_TEST (rtp_mpa)
{
rtp_pipeline_test (rtp_mpa_frame_data, rtp_mpa_frame_data_size,
rtp_mpa_frame_count, "audio/mpeg", "rtpmpapay", "rtpmpadepay");
rtp_mpa_frame_count, "audio/mpeg", "rtpmpapay", "rtpmpadepay", 0, 0,
FALSE);
}
GST_END_TEST;
......@@ -418,7 +493,7 @@ GST_START_TEST (rtp_h263)
{
rtp_pipeline_test (rtp_h263_frame_data, rtp_h263_frame_data_size,
rtp_h263_frame_count, "video/x-h263,variant=itu,h263version=h263",
"rtph263pay", "rtph263depay");
"rtph263pay", "rtph263depay", 0, 0, FALSE);
}
GST_END_TEST;
......@@ -435,7 +510,7 @@ GST_START_TEST (rtp_h263p)
{
rtp_pipeline_test (rtp_h263p_frame_data, rtp_h263p_frame_data_size,
rtp_h263p_frame_count, "video/x-h263,variant=itu", "rtph263ppay",
"rtph263pdepay");
"rtph263pdepay", 0, 0, FALSE);
}
GST_END_TEST;
......@@ -451,7 +526,61 @@ static int rtp_h264_frame_count = 1;
GST_START_TEST (rtp_h264)
{
rtp_pipeline_test (rtp_h264_frame_data, rtp_h264_frame_data_size,
rtp_h264_frame_count, "video/x-h264", "rtph264pay", "rtph264depay");
rtp_h264_frame_count, "video/x-h264", "rtph264pay", "rtph264depay",
0, 0, FALSE);
}
GST_END_TEST;
static char rtp_h264_list_lt_mtu_frame_data[] =
/* not packetized, next NAL starts with 0001 */
{ 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
0xad, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x00
};
static int rtp_h264_list_lt_mtu_frame_data_size = 16;
static int rtp_h264_list_lt_mtu_frame_count = 2;
/* NAL = 4 bytes */
static int rtp_h264_list_lt_mtu_bytes_sent = 2 * (16 - 4);
static int rtp_h264_list_lt_mtu_mtu_size = 1024;
GST_START_TEST (rtp_h264_list_lt_mtu)
{
rtp_pipeline_test (rtp_h264_list_lt_mtu_frame_data,
rtp_h264_list_lt_mtu_frame_data_size, rtp_h264_list_lt_mtu_frame_count,
"video/x-h264", "rtph264pay", "rtph264depay",
rtp_h264_list_lt_mtu_bytes_sent, rtp_h264_list_lt_mtu_mtu_size, TRUE);
}
GST_END_TEST;
static char rtp_h264_list_gt_mtu_frame_data[] =
/* not packetized, next NAL starts with 0001 */
{ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
static int rtp_h264_list_gt_mtu_frame_data_size = 64;
static int rtp_h264_list_gt_mtu_frame_count = 1;
/* NAL = 4 bytes. When data does not fit into 1 mtu, 1 byte will be skipped */
static int rtp_h264_list_gt_mtu_bytes_sent = 1 * (64 - 4) - 1;
static int rtp_h264_list_gt_mtu_mty_size = 28;
GST_START_TEST (rtp_h264_list_gt_mtu)
{
rtp_pipeline_test (rtp_h264_list_gt_mtu_frame_data,
rtp_h264_list_gt_mtu_frame_data_size, rtp_h264_list_gt_mtu_frame_count,
"video/x-h264", "rtph264pay", "rtph264depay",
rtp_h264_list_gt_mtu_bytes_sent, rtp_h264_list_gt_mtu_mty_size, TRUE);
}
GST_END_TEST;
......@@ -469,7 +598,7 @@ GST_START_TEST (rtp_L16)
rtp_pipeline_test (rtp_L16_frame_data, rtp_L16_frame_data_size,
rtp_L16_frame_count,
"audio/x-raw-int,endianess=4321,signed=true,width=16,depth=16,rate=1,channels=1",
"rtpL16pay", "rtpL16depay");
"rtpL16pay", "rtpL16depay", 0, 0, FALSE);
}
GST_END_TEST;
......@@ -486,7 +615,7 @@ GST_START_TEST (rtp_mp2t)
{
rtp_pipeline_test (rtp_mp2t_frame_data, rtp_mp2t_frame_data_size,
rtp_mp2t_frame_count, "video/mpegts,packetsize=188,systemstream=true",
"rtpmp2tpay", "rtpmp2tdepay");
"rtpmp2tpay", "rtpmp2tdepay", 0, 0, FALSE);
}
GST_END_TEST;
......@@ -503,7 +632,27 @@ GST_START_TEST (rtp_mp4v)
{
rtp_pipeline_test (rtp_mp4v_frame_data, rtp_mp4v_frame_data_size,
rtp_mp4v_frame_count, "video/mpeg,mpegversion=4,systemstream=false",
"rtpmp4vpay", "rtpmp4vdepay");
"rtpmp4vpay", "rtpmp4vdepay", 0, 0, FALSE);
}
GST_END_TEST;
static char rtp_mp4v_list_frame_data[] =
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
static int rtp_mp4v_list_frame_data_size = 20;
static int rtp_mp4v_list_frame_count = 1;
static int rtp_mp4v_list_bytes_sent = 1 * 20;
GST_START_TEST (rtp_mp4v_list)
{
rtp_pipeline_test (rtp_mp4v_list_frame_data, rtp_mp4v_list_frame_data_size,
rtp_mp4v_list_frame_count,
"video/mpeg,mpegversion=4,codec_data=(buffer)000001b001",
"rtpmp4vpay", "rtpmp4vdepay", rtp_mp4v_list_bytes_sent, 0, TRUE);
}
GST_END_TEST;
......@@ -521,7 +670,7 @@ GST_START_TEST (rtp_mp4g)
rtp_pipeline_test (rtp_mp4g_frame_data, rtp_mp4g_frame_data_size,
rtp_mp4g_frame_count,
"video/mpeg,mpegversion=4,codec_data=(buffer)000001b001", "rtpmp4gpay",
"rtpmp4gdepay");
"rtpmp4gdepay", 0, 0, FALSE);
}
GST_END_TEST;
......@@ -538,7 +687,7 @@ GST_START_TEST (rtp_theora)
{
rtp_pipeline_test (rtp_theora_frame_data, rtp_theora_frame_data_size,
rtp_theora_frame_count, "video/x-theora", "rtptheorapay",
"rtptheoradepay");
"rtptheoradepay", 0, 0, FALSE);
}
GST_END_TEST;
......@@ -555,7 +704,49 @@ GST_START_TEST (rtp_vorbis)
{
rtp_pipeline_test (rtp_vorbis_frame_data, rtp_vorbis_frame_data_size,
rtp_vorbis_frame_count, "audio/x-vorbis", "rtpvorbispay",
"rtpvorbisdepay");
"rtpvorbisdepay", 0, 0, FALSE);
}
GST_END_TEST;
static char rtp_jpeg_frame_data[] =
{ /* SOF */ 0xFF, 0xC0, 0x00, 0x11, 0x08, 0x00, 0x08, 0x00, 0x08,
0x03, 0x00, 0x21, 0x08, 0x00, 0x11, 0x08, 0x00, 0x11, 0x08,
/* DQT */ 0xFF, 0xDB, 0x00, 0x11, 0x08, 0x00, 0x08, 0x00, 0x08,
0x03, 0x00, 0x21, 0x08, 0x00, 0x11, 0x08, 0x00, 0x11, 0x08,
/* DATA */ 0x00, 0x00, 0x00, 0x00, 0x00
};
static int rtp_jpeg_frame_data_size = 42;
static int rtp_jpeg_frame_count = 1;
GST_START_TEST (rtp_jpeg)
{
rtp_pipeline_test (rtp_jpeg_frame_data, rtp_jpeg_frame_data_size,
rtp_jpeg_frame_count, "video/x-jpeg,height=640,width=480", "rtpjpegpay",
"rtpjpegdepay", 0, 0, FALSE);
}
GST_END_TEST;
static char rtp_jpeg_list_frame_data[] =
{ /* SOF */ 0xFF, 0xC0, 0x00, 0x11, 0x08, 0x00, 0x08, 0x00, 0x08,
0x03, 0x00, 0x21, 0x08, 0x00, 0x11, 0x08, 0x00, 0x11, 0x08,
/* DQT */ 0xFF, 0xDB, 0x00, 0x11, 0x08, 0x00, 0x08, 0x00, 0x08,
0x03, 0x00, 0x21, 0x08, 0x00, 0x11, 0x08, 0x00, 0x11, 0x08,
/* DATA */ 0x00, 0x00, 0x00, 0x00, 0x00
};
static int rtp_jpeg_list_frame_data_size = 42;
static int rtp_jpeg_list_frame_count = 1;
static int rtp_jpeg_list_bytes_sent = 1 * 42;
GST_START_TEST (rtp_jpeg_list)
{
rtp_pipeline_test (rtp_jpeg_list_frame_data, rtp_jpeg_list_frame_data_size,
rtp_jpeg_list_frame_count, "video/x-jpeg,height=640,width=480",
"rtpjpegpay", "rtpjpegdepay", rtp_jpeg_list_bytes_sent, 0, TRUE);
}
GST_END_TEST;
......@@ -584,12 +775,17 @@ rtp_payloading_suite ()
tcase_add_test (tc_chain, rtp_h263);
tcase_add_test (tc_chain, rtp_h263p);
tcase_add_test (tc_chain, rtp_h264);
tcase_add_test (tc_chain, rtp_h264_list_lt_mtu);
tcase_add_test (tc_chain, rtp_h264_list_gt_mtu);
tcase_add_test (tc_chain, rtp_L16);
tcase_add_test (tc_chain, rtp_mp2t);
tcase_add_test (tc_chain, rtp_mp4v);
tcase_add_test (tc_chain, rtp_mp4v_list);
tcase_add_test (tc_chain, rtp_mp4g);
tcase_add_test (tc_chain, rtp_theora);
tcase_add_test (tc_chain, rtp_vorbis);
tcase_add_test (tc_chain, rtp_jpeg);
tcase_add_test (tc_chain, rtp_jpeg_list);
return s;
}
......
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