1 /* GStreamer RTP payloader unit tests
2 * Copyright (C) 2008 Nokia Corporation and its subsidary(-ies)
3 * contact: <stefan.kost@nokia.com>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
20 #include <gst/check/gstcheck.h>
24 #define RELEASE_ELEMENT(x) if(x) {gst_object_unref(x); x = NULL;}
29 * RTP pipeline structure to store the required elements.
38 const guint8 *frame_data;
44 * Number of bytes received in the chain list function when using buffer lists
46 static guint chain_list_bytes_received;
49 * Chain list function for testing buffer lists
52 rtp_pipeline_chain_list (GstPad * pad, GstObject * parent, GstBufferList * list)
58 * Count the size of the payload in the buffer list.
60 len = gst_buffer_list_length (list);
62 /* Loop through all groups */
63 for (i = 0; i < len; i++) {
68 paybuf = gst_buffer_list_get (list, i);
69 /* only count real data which is expected in last memory block */
70 fail_unless (gst_buffer_n_memory (paybuf) > 1);
71 mem = gst_buffer_get_memory_range (paybuf, gst_buffer_n_memory (paybuf) - 1,
73 size = gst_memory_get_sizes (mem, NULL, NULL);
74 gst_memory_unref (mem);
75 chain_list_bytes_received += size;
77 gst_buffer_list_unref (list);
86 rtp_bus_callback (GstBus * bus, GstMessage * message, gpointer data)
88 GMainLoop *mainloop = (GMainLoop *) data;
90 switch (GST_MESSAGE_TYPE (message)) {
91 case GST_MESSAGE_ERROR:
99 element_name = (message->src) ? gst_object_get_name (message->src) : NULL;
100 gst_message_parse_error (message, &err, &debug);
101 /* FIXME: should we fail the test here? */
102 g_print ("\nError from element %s: %s\n%s\n\n",
103 GST_STR_NULL (element_name), err->message, (debug) ? debug : "");
106 g_free (element_name);
108 g_main_loop_quit (mainloop);
112 case GST_MESSAGE_EOS:
114 g_main_loop_quit (mainloop);
129 * Creates a RTP pipeline for one test.
130 * @param frame_data Pointer to the frame data which is used to pass thru pay/depayloaders.
131 * @param frame_data_size Frame data size in bytes.
132 * @param frame_count Frame count.
133 * @param filtercaps Caps filters.
134 * @param pay Payloader name.
135 * @param depay Depayloader name.
137 * Returns pointer to the RTP pipeline.
138 * The user must free the RTP pipeline when it's not used anymore.
140 static rtp_pipeline *
141 rtp_pipeline_create (const guint8 * frame_data, int frame_data_size,
142 int frame_count, const char *filtercaps, const char *pay, const char *depay)
144 gchar *pipeline_name;
148 /* Check parameters. */
149 if (!frame_data || !pay || !depay) {
153 /* Allocate memory for the RTP pipeline. */
154 p = (rtp_pipeline *) malloc (sizeof (rtp_pipeline));
156 p->frame_data = frame_data;
157 p->frame_data_size = frame_data_size;
158 p->frame_count = frame_count;
160 /* Create elements. */
161 pipeline_name = g_strdup_printf ("%s-%s-pipeline", pay, depay);
162 p->pipeline = gst_pipeline_new (pipeline_name);
163 g_free (pipeline_name);
164 p->appsrc = gst_element_factory_make ("appsrc", NULL);
165 p->rtppay = gst_element_factory_make (pay, NULL);
166 p->rtpdepay = gst_element_factory_make (depay, NULL);
167 p->fakesink = gst_element_factory_make ("fakesink", NULL);
169 /* One or more elements are not created successfully or failed to create p? */
170 if (!p->pipeline || !p->appsrc || !p->rtppay || !p->rtpdepay || !p->fakesink) {
171 /* Release created elements. */
172 RELEASE_ELEMENT (p->pipeline);
173 RELEASE_ELEMENT (p->appsrc);
174 RELEASE_ELEMENT (p->rtppay);
175 RELEASE_ELEMENT (p->rtpdepay);
176 RELEASE_ELEMENT (p->fakesink);
178 /* Release allocated memory. */
184 /* Set src properties. */
185 caps = gst_caps_from_string (filtercaps);
186 g_object_set (p->appsrc, "do-timestamp", TRUE, "caps", caps,
187 "format", GST_FORMAT_TIME, NULL);
188 gst_caps_unref (caps);
190 /* Add elements to the pipeline. */
191 gst_bin_add (GST_BIN (p->pipeline), p->appsrc);
192 gst_bin_add (GST_BIN (p->pipeline), p->rtppay);
193 gst_bin_add (GST_BIN (p->pipeline), p->rtpdepay);
194 gst_bin_add (GST_BIN (p->pipeline), p->fakesink);
197 gst_element_link (p->appsrc, p->rtppay);
198 gst_element_link (p->rtppay, p->rtpdepay);
199 gst_element_link (p->rtpdepay, p->fakesink);
205 * Destroys the RTP pipeline.
206 * @param p Pointer to the RTP pipeline.
209 rtp_pipeline_destroy (rtp_pipeline * p)
211 /* Check parameters. */
216 /* Release pipeline. */
217 RELEASE_ELEMENT (p->pipeline);
219 /* Release allocated memory. */
224 * Runs the RTP pipeline.
225 * @param p Pointer to the RTP pipeline.
228 rtp_pipeline_run (rtp_pipeline * p)
230 GstFlowReturn flow_ret;
231 GMainLoop *mainloop = NULL;
235 /* Check parameters. */
240 /* Create mainloop. */
241 mainloop = g_main_loop_new (NULL, FALSE);
246 /* Add bus callback. */
247 bus = gst_pipeline_get_bus (GST_PIPELINE (p->pipeline));
249 gst_bus_add_watch (bus, rtp_bus_callback, (gpointer) mainloop);
250 gst_object_unref (bus);
252 /* Set pipeline to PLAYING. */
253 gst_element_set_state (p->pipeline, GST_STATE_PLAYING);
255 /* Push data into the pipeline */
256 for (i = 0; i < LOOP_COUNT; i++) {
257 const guint8 *data = p->frame_data;
259 for (j = 0; j < p->frame_count; j++) {
263 gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY,
264 (guint8 *) data, p->frame_data_size, 0, p->frame_data_size, NULL,
267 g_signal_emit_by_name (p->appsrc, "push-buffer", buf, &flow_ret);
268 fail_unless_equals_int (flow_ret, GST_FLOW_OK);
269 data += p->frame_data_size;
271 gst_buffer_unref (buf);
275 g_signal_emit_by_name (p->appsrc, "end-of-stream", &flow_ret);
278 g_main_loop_run (mainloop);
280 /* Set pipeline to NULL. */
281 gst_element_set_state (p->pipeline, GST_STATE_NULL);
283 /* Release mainloop. */
284 g_main_loop_unref (mainloop);
288 * Enables buffer lists and adds a chain_list_function to the depayloader.
289 * @param p Pointer to the RTP pipeline.
292 rtp_pipeline_enable_lists (rtp_pipeline * p, guint mtu_size)
296 /* set mtu size if needed */
298 g_object_set (p->rtppay, "mtu", mtu_size, NULL);
301 /* Add chain list function for the buffer list tests */
302 pad = gst_element_get_static_pad (p->rtpdepay, "sink");
303 gst_pad_set_chain_list_function (pad,
304 GST_DEBUG_FUNCPTR (rtp_pipeline_chain_list));
305 gst_object_unref (pad);
309 * Creates the RTP pipeline and runs the test using the pipeline.
310 * @param frame_data Pointer to the frame data which is used to pass thru pay/depayloaders.
311 * @param frame_data_size Frame data size in bytes.
312 * @param frame_count Frame count.
313 * @param filtercaps Caps filters.
314 * @param pay Payloader name.
315 * @param depay Depayloader name.
316 * @bytes_sent bytes that will be sent, used when testing buffer lists
317 * @mtu_size set mtu size when testing lists
318 * @use_lists enable buffer lists
321 rtp_pipeline_test (const guint8 * frame_data, int frame_data_size,
322 int frame_count, const char *filtercaps, const char *pay, const char *depay,
323 guint bytes_sent, guint mtu_size, gboolean use_lists)
325 /* Create RTP pipeline. */
327 rtp_pipeline_create (frame_data, frame_data_size, frame_count, filtercaps,
335 rtp_pipeline_enable_lists (p, mtu_size);
336 chain_list_bytes_received = 0;
339 /* Run RTP pipeline. */
340 rtp_pipeline_run (p);
342 /* Destroy RTP pipeline. */
343 rtp_pipeline_destroy (p);
346 /* 'next NAL' indicator is 4 bytes */
347 fail_if (chain_list_bytes_received != bytes_sent * LOOP_COUNT);
351 static const guint8 rtp_ilbc_frame_data[] =
352 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
353 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
356 static int rtp_ilbc_frame_data_size = 20;
358 static int rtp_ilbc_frame_count = 1;
360 GST_START_TEST (rtp_ilbc)
362 rtp_pipeline_test (rtp_ilbc_frame_data, rtp_ilbc_frame_data_size,
363 rtp_ilbc_frame_count, "audio/x-iLBC,mode=20", "rtpilbcpay",
364 "rtpilbcdepay", 0, 0, FALSE);
368 static const guint8 rtp_gsm_frame_data[] =
369 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
370 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
373 static int rtp_gsm_frame_data_size = 20;
375 static int rtp_gsm_frame_count = 1;
377 GST_START_TEST (rtp_gsm)
379 rtp_pipeline_test (rtp_gsm_frame_data, rtp_gsm_frame_data_size,
380 rtp_gsm_frame_count, "audio/x-gsm,rate=8000,channels=1", "rtpgsmpay",
381 "rtpgsmdepay", 0, 0, FALSE);
385 static const guint8 rtp_amr_frame_data[] =
386 { 0x3c, 0x24, 0x03, 0xb3, 0x48, 0x10, 0x68, 0x46, 0x6c, 0xec, 0x03,
387 0x7a, 0x37, 0x16, 0x41, 0x41, 0xc0, 0x00, 0x0d, 0xcd, 0x12, 0xed,
388 0xad, 0x80, 0x00, 0x00, 0x11, 0x31, 0x00, 0x00, 0x0d, 0xa0
391 static int rtp_amr_frame_data_size = 32;
393 static int rtp_amr_frame_count = 1;
395 GST_START_TEST (rtp_amr)
397 rtp_pipeline_test (rtp_amr_frame_data, rtp_amr_frame_data_size,
398 rtp_amr_frame_count, "audio/AMR,channels=1,rate=8000", "rtpamrpay",
399 "rtpamrdepay", 0, 0, FALSE);
403 static const guint8 rtp_pcma_frame_data[] =
404 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
405 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
408 static int rtp_pcma_frame_data_size = 20;
410 static int rtp_pcma_frame_count = 1;
412 GST_START_TEST (rtp_pcma)
414 rtp_pipeline_test (rtp_pcma_frame_data, rtp_pcma_frame_data_size,
415 rtp_pcma_frame_count, "audio/x-alaw,channels=1,rate=8000", "rtppcmapay",
416 "rtppcmadepay", 0, 0, FALSE);
420 static const guint8 rtp_pcmu_frame_data[] =
421 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
422 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
425 static int rtp_pcmu_frame_data_size = 20;
427 static int rtp_pcmu_frame_count = 1;
429 GST_START_TEST (rtp_pcmu)
431 rtp_pipeline_test (rtp_pcmu_frame_data, rtp_pcmu_frame_data_size,
432 rtp_pcmu_frame_count, "audio/x-mulaw,channels=1,rate=8000", "rtppcmupay",
433 "rtppcmudepay", 0, 0, FALSE);
437 static const guint8 rtp_mpa_frame_data[] =
438 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
439 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
442 static int rtp_mpa_frame_data_size = 20;
444 static int rtp_mpa_frame_count = 1;
446 GST_START_TEST (rtp_mpa)
448 rtp_pipeline_test (rtp_mpa_frame_data, rtp_mpa_frame_data_size,
449 rtp_mpa_frame_count, "audio/mpeg,mpegversion=1", "rtpmpapay",
450 "rtpmpadepay", 0, 0, FALSE);
454 static const guint8 rtp_h263_frame_data[] =
455 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
456 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
459 static int rtp_h263_frame_data_size = 20;
461 static int rtp_h263_frame_count = 1;
463 GST_START_TEST (rtp_h263)
465 rtp_pipeline_test (rtp_h263_frame_data, rtp_h263_frame_data_size,
466 rtp_h263_frame_count, "video/x-h263,variant=(string)itu,h263version=h263",
467 "rtph263pay", "rtph263depay", 0, 0, FALSE);
471 static const guint8 rtp_h263p_frame_data[] =
472 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
473 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
476 static int rtp_h263p_frame_data_size = 20;
478 static int rtp_h263p_frame_count = 1;
480 GST_START_TEST (rtp_h263p)
482 rtp_pipeline_test (rtp_h263p_frame_data, rtp_h263p_frame_data_size,
483 rtp_h263p_frame_count, "video/x-h263,variant=(string)itu,"
484 "h263version=(string)h263", "rtph263ppay", "rtph263pdepay", 0, 0, FALSE);
486 /* payloader should accept any input that matches the template caps
487 * if there's just a udpsink or fakesink downstream */
488 rtp_pipeline_test (rtp_h263p_frame_data, rtp_h263p_frame_data_size,
489 rtp_h263p_frame_count, "video/x-h263,variant=(string)itu,"
490 "h263version=(string)h263", "rtph263ppay", "identity", 0, 0, FALSE);
492 /* default output of avenc_h263p */
493 rtp_pipeline_test (rtp_h263p_frame_data, rtp_h263p_frame_data_size,
494 rtp_h263p_frame_count, "video/x-h263,variant=(string)itu,"
495 "h263version=(string)h263p, annex-f=(boolean)true, "
496 "annex-j=(boolean)true, annex-i=(boolean)true, annex-t=(boolean)true",
497 "rtph263ppay", "identity", 0, 0, FALSE);
499 /* pay ! depay should also work with any input */
500 rtp_pipeline_test (rtp_h263p_frame_data, rtp_h263p_frame_data_size,
501 rtp_h263p_frame_count, "video/x-h263,variant=(string)itu,"
502 "h263version=(string)h263p, annex-f=(boolean)true, "
503 "annex-j=(boolean)true, annex-i=(boolean)true, annex-t=(boolean)true",
504 "rtph263ppay", "rtph263pdepay", 0, 0, FALSE);
508 static const guint8 rtp_h264_frame_data[] =
509 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
510 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
513 static int rtp_h264_frame_data_size = 20;
515 static int rtp_h264_frame_count = 1;
517 GST_START_TEST (rtp_h264)
519 /* FIXME 0.11: fully specify h264 caps (and make payloader check) */
520 rtp_pipeline_test (rtp_h264_frame_data, rtp_h264_frame_data_size,
521 rtp_h264_frame_count,
522 "video/x-h264,stream-format=(string)byte-stream,alignment=(string)nal,"
523 "width=(int)320,height=(int)240", "rtph264pay", "rtph264depay", 0, 0,
528 static const guint8 rtp_h264_list_lt_mtu_frame_data[] =
529 /* not packetized, next NAL starts with 0001 */
530 { 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
531 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
532 0xad, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x00
535 static int rtp_h264_list_lt_mtu_frame_data_size = 16;
537 static int rtp_h264_list_lt_mtu_frame_count = 2;
540 /* also 2 bytes FU-A header each time */
541 static int rtp_h264_list_lt_mtu_bytes_sent = 2 * (16 - 4);
543 static int rtp_h264_list_lt_mtu_mtu_size = 1024;
545 GST_START_TEST (rtp_h264_list_lt_mtu)
547 /* FIXME 0.11: fully specify h264 caps (and make payloader check) */
548 rtp_pipeline_test (rtp_h264_list_lt_mtu_frame_data,
549 rtp_h264_list_lt_mtu_frame_data_size, rtp_h264_list_lt_mtu_frame_count,
550 "video/x-h264,stream-format=(string)byte-stream,alignment=(string)nal,"
551 "width=(int)320,height=(int)240", "rtph264pay", "rtph264depay",
552 rtp_h264_list_lt_mtu_bytes_sent, rtp_h264_list_lt_mtu_mtu_size, TRUE);
556 static const guint8 rtp_h264_list_lt_mtu_frame_data_avc[] =
557 /* packetized data */
558 { 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00,
559 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00,
560 0xad, 0x80, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x0d, 0x00
564 static int rtp_h264_list_lt_mtu_bytes_sent_avc = 2 * (16 - 2 * 4);
566 //static int rtp_h264_list_lt_mtu_mtu_size = 1024;
568 GST_START_TEST (rtp_h264_list_lt_mtu_avc)
570 /* FIXME 0.11: fully specify h264 caps (and make payloader check) */
571 rtp_pipeline_test (rtp_h264_list_lt_mtu_frame_data_avc,
572 rtp_h264_list_lt_mtu_frame_data_size, rtp_h264_list_lt_mtu_frame_count,
573 "video/x-h264,stream-format=(string)avc,alignment=(string)au,"
574 "codec_data=(buffer)01640014ffe1001867640014acd94141fb0110000003001773594000f142996001000568ebecb22c,"
575 "width=(int)320,height=(int)240,framerate=(fraction)30/1", "rtph264pay",
576 "rtph264depay", rtp_h264_list_lt_mtu_bytes_sent_avc,
577 rtp_h264_list_lt_mtu_mtu_size, TRUE);
581 static const guint8 rtp_h264_list_gt_mtu_frame_data[] =
582 /* not packetized, next NAL starts with 0001 */
583 { 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
584 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
585 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
586 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
587 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
588 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
591 static int rtp_h264_list_gt_mtu_frame_data_size = 64;
593 static int rtp_h264_list_gt_mtu_frame_count = 1;
595 /* NAL = 4 bytes. When data does not fit into 1 mtu, 1 byte will be skipped */
596 static int rtp_h264_list_gt_mtu_bytes_sent = 1 * (64 - 4) - 1;
598 static int rtp_h264_list_gt_mtu_mty_size = 28;
600 GST_START_TEST (rtp_h264_list_gt_mtu)
602 /* FIXME 0.11: fully specify h264 caps (and make payloader check) */
603 rtp_pipeline_test (rtp_h264_list_gt_mtu_frame_data,
604 rtp_h264_list_gt_mtu_frame_data_size, rtp_h264_list_gt_mtu_frame_count,
605 "video/x-h264,stream-format=(string)byte-stream,alignment=(string)nal,"
606 "width=(int)320,height=(int)240", "rtph264pay", "rtph264depay",
607 rtp_h264_list_gt_mtu_bytes_sent, rtp_h264_list_gt_mtu_mty_size, TRUE);
611 static const guint8 rtp_h264_list_gt_mtu_frame_data_avc[] =
612 /* packetized data */
613 { 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
614 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
615 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
616 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00,
617 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
618 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
621 /* NAL = 4 bytes. When data does not fit into 1 mtu, 1 byte will be skipped */
622 static int rtp_h264_list_gt_mtu_bytes_sent_avc = 1 * (64 - 2 * 4 - 2 * 1);
624 GST_START_TEST (rtp_h264_list_gt_mtu_avc)
626 /* FIXME 0.11: fully specify h264 caps (and make payloader check) */
627 rtp_pipeline_test (rtp_h264_list_gt_mtu_frame_data_avc,
628 rtp_h264_list_gt_mtu_frame_data_size, rtp_h264_list_gt_mtu_frame_count,
629 "video/x-h264,stream-format=(string)avc,alignment=(string)au,"
630 "codec_data=(buffer)01640014ffe1001867640014acd94141fb0110000003001773594000f142996001000568ebecb22c,"
631 "width=(int)320,height=(int)240,framerate=(fraction)30/1" , "rtph264pay",
632 "rtph264depay", rtp_h264_list_gt_mtu_bytes_sent_avc,
633 rtp_h264_list_gt_mtu_mty_size, TRUE);
638 static const guint8 rtp_L16_frame_data[] =
639 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
640 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
643 static int rtp_L16_frame_data_size = 20;
645 static int rtp_L16_frame_count = 1;
647 GST_START_TEST (rtp_L16)
649 rtp_pipeline_test (rtp_L16_frame_data, rtp_L16_frame_data_size,
651 "audio/x-raw,format=S16BE,rate=1,channels=1,layout=(string)interleaved",
652 "rtpL16pay", "rtpL16depay", 0, 0, FALSE);
656 static const guint8 rtp_mp2t_frame_data[] =
657 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
658 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
661 static int rtp_mp2t_frame_data_size = 20;
663 static int rtp_mp2t_frame_count = 1;
665 GST_START_TEST (rtp_mp2t)
667 rtp_pipeline_test (rtp_mp2t_frame_data, rtp_mp2t_frame_data_size,
668 rtp_mp2t_frame_count, "video/mpegts,packetsize=188,systemstream=true",
669 "rtpmp2tpay", "rtpmp2tdepay", 0, 0, FALSE);
673 static const guint8 rtp_mp4v_frame_data[] =
674 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
675 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
678 static int rtp_mp4v_frame_data_size = 20;
680 static int rtp_mp4v_frame_count = 1;
682 GST_START_TEST (rtp_mp4v)
684 rtp_pipeline_test (rtp_mp4v_frame_data, rtp_mp4v_frame_data_size,
685 rtp_mp4v_frame_count, "video/mpeg,mpegversion=4,systemstream=false",
686 "rtpmp4vpay", "rtpmp4vdepay", 0, 0, FALSE);
690 static const guint8 rtp_mp4v_list_frame_data[] =
691 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
692 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
695 static int rtp_mp4v_list_frame_data_size = 20;
697 static int rtp_mp4v_list_frame_count = 1;
699 static int rtp_mp4v_list_bytes_sent = 1 * 20;
701 GST_START_TEST (rtp_mp4v_list)
703 rtp_pipeline_test (rtp_mp4v_list_frame_data, rtp_mp4v_list_frame_data_size,
704 rtp_mp4v_list_frame_count,
705 "video/mpeg,mpegversion=4,systemstream=false,codec_data=(buffer)000001b001",
706 "rtpmp4vpay", "rtpmp4vdepay", rtp_mp4v_list_bytes_sent, 0, TRUE);
710 static const guint8 rtp_mp4g_frame_data[] =
711 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
712 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
715 static int rtp_mp4g_frame_data_size = 20;
717 static int rtp_mp4g_frame_count = 1;
719 GST_START_TEST (rtp_mp4g)
721 rtp_pipeline_test (rtp_mp4g_frame_data, rtp_mp4g_frame_data_size,
722 rtp_mp4g_frame_count,
723 "video/mpeg,mpegversion=4,systemstream=false,codec_data=(buffer)000001b001",
724 "rtpmp4gpay", "rtpmp4gdepay", 0, 0, FALSE);
728 static const guint8 rtp_theora_frame_data[] =
729 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
730 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
733 static int rtp_theora_frame_data_size = 20;
735 static int rtp_theora_frame_count = 1;
737 GST_START_TEST (rtp_theora)
739 rtp_pipeline_test (rtp_theora_frame_data, rtp_theora_frame_data_size,
740 rtp_theora_frame_count, "video/x-theora", "rtptheorapay",
741 "rtptheoradepay", 0, 0, FALSE);
745 static const guint8 rtp_vorbis_frame_data[] =
746 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
747 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
750 static int rtp_vorbis_frame_data_size = 20;
752 static int rtp_vorbis_frame_count = 1;
754 GST_START_TEST (rtp_vorbis)
756 rtp_pipeline_test (rtp_vorbis_frame_data, rtp_vorbis_frame_data_size,
757 rtp_vorbis_frame_count, "audio/x-vorbis", "rtpvorbispay",
758 "rtpvorbisdepay", 0, 0, FALSE);
762 static const guint8 rtp_jpeg_frame_data[] =
763 { /* SOF */ 0xFF, 0xC0, 0x00, 0x11, 0x08, 0x00, 0x08, 0x00, 0x08,
764 0x03, 0x00, 0x21, 0x08, 0x01, 0x11, 0x08, 0x02, 0x11, 0x08,
765 /* DQT */ 0xFF, 0xDB, 0x00, 0x43, 0x08,
766 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
767 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
768 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
769 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
770 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
771 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
772 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
773 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
774 /* DATA */ 0x00, 0x00, 0x00, 0x00, 0x00
777 static int rtp_jpeg_frame_data_size = sizeof (rtp_jpeg_frame_data);
779 static int rtp_jpeg_frame_count = 1;
781 GST_START_TEST (rtp_jpeg)
783 rtp_pipeline_test (rtp_jpeg_frame_data, rtp_jpeg_frame_data_size,
784 rtp_jpeg_frame_count, "video/x-jpeg,height=640,width=480", "rtpjpegpay",
785 "rtpjpegdepay", 0, 0, FALSE);
790 GST_START_TEST (rtp_jpeg_width_greater_than_2040)
792 rtp_pipeline_test (rtp_jpeg_frame_data, rtp_jpeg_frame_data_size,
793 rtp_jpeg_frame_count, "video/x-jpeg,height=2048,width=480", "rtpjpegpay",
794 "rtpjpegdepay", 0, 0, FALSE);
799 GST_START_TEST (rtp_jpeg_height_greater_than_2040)
801 rtp_pipeline_test (rtp_jpeg_frame_data, rtp_jpeg_frame_data_size,
802 rtp_jpeg_frame_count, "video/x-jpeg,height=640,width=2048", "rtpjpegpay",
803 "rtpjpegdepay", 0, 0, FALSE);
808 GST_START_TEST (rtp_jpeg_width_and_height_greater_than_2040)
810 rtp_pipeline_test (rtp_jpeg_frame_data, rtp_jpeg_frame_data_size,
811 rtp_jpeg_frame_count, "video/x-jpeg,height=2048,width=2048", "rtpjpegpay",
812 "rtpjpegdepay", 0, 0, FALSE);
817 static const guint8 rtp_jpeg_list_frame_data[] =
818 { /* SOF */ 0xFF, 0xC0, 0x00, 0x11, 0x08, 0x00, 0x08, 0x00, 0x08,
819 0x03, 0x00, 0x21, 0x08, 0x01, 0x11, 0x08, 0x02, 0x11, 0x08,
820 /* DQT */ 0xFF, 0xDB, 0x00, 0x43, 0x08,
821 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
822 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
823 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
824 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
825 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
826 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
827 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
828 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
829 /* DATA */ 0x00, 0x00, 0x00, 0x00, 0x00
832 static int rtp_jpeg_list_frame_data_size = sizeof (rtp_jpeg_list_frame_data);
834 static int rtp_jpeg_list_frame_count = 1;
836 static int rtp_jpeg_list_bytes_sent = 1 * sizeof (rtp_jpeg_list_frame_data);
838 GST_START_TEST (rtp_jpeg_list)
840 rtp_pipeline_test (rtp_jpeg_list_frame_data, rtp_jpeg_list_frame_data_size,
841 rtp_jpeg_list_frame_count, "video/x-jpeg,height=640,width=480",
842 "rtpjpegpay", "rtpjpegdepay", rtp_jpeg_list_bytes_sent, 0, TRUE);
847 GST_START_TEST (rtp_jpeg_list_width_greater_than_2040)
849 rtp_pipeline_test (rtp_jpeg_list_frame_data, rtp_jpeg_list_frame_data_size,
850 rtp_jpeg_list_frame_count, "video/x-jpeg,height=2048,width=480",
851 "rtpjpegpay", "rtpjpegdepay", rtp_jpeg_list_bytes_sent, 0, TRUE);
856 GST_START_TEST (rtp_jpeg_list_height_greater_than_2040)
858 rtp_pipeline_test (rtp_jpeg_list_frame_data, rtp_jpeg_list_frame_data_size,
859 rtp_jpeg_list_frame_count, "video/x-jpeg,height=640,width=2048",
860 "rtpjpegpay", "rtpjpegdepay", rtp_jpeg_list_bytes_sent, 0, TRUE);
865 GST_START_TEST (rtp_jpeg_list_width_and_height_greater_than_2040)
867 rtp_pipeline_test (rtp_jpeg_list_frame_data, rtp_jpeg_list_frame_data_size,
868 rtp_jpeg_list_frame_count, "video/x-jpeg,height=2048,width=2048",
869 "rtpjpegpay", "rtpjpegdepay", rtp_jpeg_list_bytes_sent, 0, TRUE);
874 static const guint8 rtp_g729_frame_data[] =
875 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
876 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
879 static int rtp_g729_frame_data_size = 22;
881 static int rtp_g729_frame_count = 1;
883 GST_START_TEST (rtp_g729)
885 rtp_pipeline_test (rtp_g729_frame_data, rtp_g729_frame_data_size,
886 rtp_g729_frame_count, "audio/G729,rate=8000,channels=1", "rtpg729pay",
887 "rtpg729depay", 0, 0, FALSE);
893 * Creates the test suite.
895 * Returns: pointer to the test suite.
898 rtp_payloading_suite (void)
900 Suite *s = suite_create ("rtp_data_test");
902 TCase *tc_chain = tcase_create ("linear");
904 /* Set timeout to 60 seconds. */
905 tcase_set_timeout (tc_chain, 60);
907 suite_add_tcase (s, tc_chain);
908 tcase_add_test (tc_chain, rtp_ilbc);
909 tcase_add_test (tc_chain, rtp_gsm);
910 tcase_add_test (tc_chain, rtp_amr);
911 tcase_add_test (tc_chain, rtp_pcma);
912 tcase_add_test (tc_chain, rtp_pcmu);
913 tcase_add_test (tc_chain, rtp_mpa);
914 tcase_add_test (tc_chain, rtp_h263);
915 tcase_add_test (tc_chain, rtp_h263p);
916 tcase_add_test (tc_chain, rtp_h264);
917 tcase_add_test (tc_chain, rtp_h264_list_lt_mtu);
918 tcase_add_test (tc_chain, rtp_h264_list_lt_mtu_avc);
919 tcase_add_test (tc_chain, rtp_h264_list_gt_mtu);
920 tcase_add_test (tc_chain, rtp_h264_list_gt_mtu_avc);
921 tcase_add_test (tc_chain, rtp_L16);
922 tcase_add_test (tc_chain, rtp_mp2t);
923 tcase_add_test (tc_chain, rtp_mp4v);
924 tcase_add_test (tc_chain, rtp_mp4v_list);
925 tcase_add_test (tc_chain, rtp_mp4g);
926 tcase_add_test (tc_chain, rtp_theora);
927 tcase_add_test (tc_chain, rtp_vorbis);
928 tcase_add_test (tc_chain, rtp_jpeg);
929 tcase_add_test (tc_chain, rtp_jpeg_width_greater_than_2040);
930 tcase_add_test (tc_chain, rtp_jpeg_height_greater_than_2040);
931 tcase_add_test (tc_chain, rtp_jpeg_width_and_height_greater_than_2040);
932 tcase_add_test (tc_chain, rtp_jpeg_list);
933 tcase_add_test (tc_chain, rtp_jpeg_list_width_greater_than_2040);
934 tcase_add_test (tc_chain, rtp_jpeg_list_height_greater_than_2040);
935 tcase_add_test (tc_chain, rtp_jpeg_list_width_and_height_greater_than_2040);
936 tcase_add_test (tc_chain, rtp_g729);
940 GST_CHECK_MAIN (rtp_payloading)