rtph264pay: add stream-format and alignment to h264 sink caps
[platform/upstream/gstreamer.git] / tests / check / elements / rtp-payloading.c
1 /* GStreamer RTP payloader unit tests
2  * Copyright (C) 2008 Nokia Corporation and its subsidary(-ies)
3  *               contact: <stefan.kost@nokia.com>
4  *
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.
9  *
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.
14  *
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., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20 #include <gst/check/gstcheck.h>
21 #include <stdlib.h>
22 #include <unistd.h>
23
24 #define RELEASE_ELEMENT(x) if(x) {gst_object_unref(x); x = NULL;}
25
26 #define LOOP_COUNT 1
27
28 /*
29  * RTP pipeline structure to store the required elements.
30  */
31 typedef struct
32 {
33   GstElement *pipeline;
34   GstElement *appsrc;
35   GstElement *rtppay;
36   GstElement *rtpdepay;
37   GstElement *fakesink;
38   const guint8 *frame_data;
39   int frame_data_size;
40   int frame_count;
41 } rtp_pipeline;
42
43 /*
44  * Number of bytes received in the chain list function when using buffer lists
45  */
46 static guint chain_list_bytes_received;
47
48 /*
49  * Chain list function for testing buffer lists
50  */
51 static GstFlowReturn
52 rtp_pipeline_chain_list (GstPad * pad, GstBufferList * list)
53 {
54   GstBufferListIterator *it;
55
56   fail_if (!list);
57   it = gst_buffer_list_iterate (list);
58
59   /*
60    * Count the size of the payload in the buffer list.
61    */
62
63   /* Loop through all groups */
64   while (gst_buffer_list_iterator_next_group (it)) {
65     GstBuffer *paybuf;
66
67     /* Skip the first buffer in the group, its the RTP header */
68     fail_if (!gst_buffer_list_iterator_next (it));
69
70     /* Loop through all payload buffers in the current group */
71     while ((paybuf = gst_buffer_list_iterator_next (it))) {
72       chain_list_bytes_received += GST_BUFFER_SIZE (paybuf);
73     }
74   }
75
76   gst_buffer_list_iterator_free (it);
77   gst_buffer_list_unref (list);
78
79   return GST_FLOW_OK;
80 }
81
82 /*
83  * RTP bus callback.
84  */
85 static gboolean
86 rtp_bus_callback (GstBus * bus, GstMessage * message, gpointer data)
87 {
88   GMainLoop *mainloop = (GMainLoop *) data;
89
90   switch (GST_MESSAGE_TYPE (message)) {
91     case GST_MESSAGE_ERROR:
92     {
93       GError *err;
94
95       gchar *debug;
96
97       gchar *element_name;
98
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 : "");
104       g_error_free (err);
105       g_free (debug);
106       g_free (element_name);
107
108       g_main_loop_quit (mainloop);
109     }
110       break;
111
112     case GST_MESSAGE_EOS:
113     {
114       g_main_loop_quit (mainloop);
115     }
116       break;
117       break;
118
119     default:
120     {
121     }
122       break;
123   }
124
125   return TRUE;
126 }
127
128 /*
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.
136  * @return
137  * Returns pointer to the RTP pipeline.
138  * The user must free the RTP pipeline when it's not used anymore.
139  */
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)
143 {
144   gchar *pipeline_name;
145   rtp_pipeline *p;
146   GstCaps *caps;
147
148   /* Check parameters. */
149   if (!frame_data || !pay || !depay) {
150     return NULL;
151   }
152
153   /* Allocate memory for the RTP pipeline. */
154   p = (rtp_pipeline *) malloc (sizeof (rtp_pipeline));
155
156   p->frame_data = frame_data;
157   p->frame_data_size = frame_data_size;
158   p->frame_count = frame_count;
159
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);
168
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);
177
178     /* Release allocated memory. */
179     free (p);
180
181     return NULL;
182   }
183
184   /* Set src properties. */
185   caps = gst_caps_from_string (filtercaps);
186   g_object_set (p->appsrc, "do-timestamp", TRUE, "caps", caps, NULL);
187   gst_caps_unref (caps);
188
189   /* Add elements to the pipeline. */
190   gst_bin_add (GST_BIN (p->pipeline), p->appsrc);
191   gst_bin_add (GST_BIN (p->pipeline), p->rtppay);
192   gst_bin_add (GST_BIN (p->pipeline), p->rtpdepay);
193   gst_bin_add (GST_BIN (p->pipeline), p->fakesink);
194
195   /* Link elements. */
196   gst_element_link (p->appsrc, p->rtppay);
197   gst_element_link (p->rtppay, p->rtpdepay);
198   gst_element_link (p->rtpdepay, p->fakesink);
199
200   return p;
201 }
202
203 /*
204  * Destroys the RTP pipeline.
205  * @param p Pointer to the RTP pipeline.
206  */
207 static void
208 rtp_pipeline_destroy (rtp_pipeline * p)
209 {
210   /* Check parameters. */
211   if (p == NULL) {
212     return;
213   }
214
215   /* Release pipeline. */
216   RELEASE_ELEMENT (p->pipeline);
217
218   /* Release allocated memory. */
219   free (p);
220 }
221
222 /*
223  * Runs the RTP pipeline.
224  * @param p Pointer to the RTP pipeline.
225  */
226 static void
227 rtp_pipeline_run (rtp_pipeline * p)
228 {
229   GstFlowReturn flow_ret;
230   GMainLoop *mainloop = NULL;
231   GstBus *bus;
232   gint i, j;
233
234   /* Check parameters. */
235   if (p == NULL) {
236     return;
237   }
238
239   /* Create mainloop. */
240   mainloop = g_main_loop_new (NULL, FALSE);
241   if (!mainloop) {
242     return;
243   }
244
245   /* Add bus callback. */
246   bus = gst_pipeline_get_bus (GST_PIPELINE (p->pipeline));
247
248   gst_bus_add_watch (bus, rtp_bus_callback, (gpointer) mainloop);
249   gst_object_unref (bus);
250
251   /* Set pipeline to PLAYING. */
252   gst_element_set_state (p->pipeline, GST_STATE_PLAYING);
253
254   /* Push data into the pipeline */
255   for (i = 0; i < LOOP_COUNT; i++) {
256     const guint8 *data = p->frame_data;
257
258     for (j = 0; j < p->frame_count; j++) {
259       GstBuffer *buf;
260
261       buf = gst_buffer_new ();
262       GST_BUFFER_DATA (buf) = (guint8 *) data;
263       GST_BUFFER_SIZE (buf) = p->frame_data_size;
264       GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_READONLY);
265
266       g_signal_emit_by_name (p->appsrc, "push-buffer", buf, &flow_ret);
267       fail_unless_equals_int (flow_ret, GST_FLOW_OK);
268       data += p->frame_data_size;
269
270       gst_buffer_unref (buf);
271     }
272   }
273
274   g_signal_emit_by_name (p->appsrc, "end-of-stream", &flow_ret);
275
276   /* Run mainloop. */
277   g_main_loop_run (mainloop);
278
279   /* Set pipeline to NULL. */
280   gst_element_set_state (p->pipeline, GST_STATE_NULL);
281
282   /* Release mainloop. */
283   g_main_loop_unref (mainloop);
284 }
285
286 /*
287  * Enables buffer lists. Sets the buffer-list property of the payloader
288  * and adds a chain_list_function to the depayloader.
289  * @param p Pointer to the RTP pipeline.
290  */
291 static void
292 rtp_pipeline_enable_lists (rtp_pipeline * p, guint mtu_size)
293 {
294   GstPad *pad;
295
296   /* use buffer lists */
297   g_object_set (p->rtppay, "buffer-list", TRUE, NULL);
298
299   /* set mtu size if needed */
300   if (mtu_size) {
301     g_object_set (p->rtppay, "mtu", mtu_size, NULL);
302   }
303
304   /* Add chain list function for the buffer list tests */
305   pad = gst_element_get_static_pad (p->rtpdepay, "sink");
306   gst_pad_set_chain_list_function (pad,
307       GST_DEBUG_FUNCPTR (rtp_pipeline_chain_list));
308   gst_object_unref (pad);
309 }
310
311 /*
312  * Creates the RTP pipeline and runs the test using the pipeline.
313  * @param frame_data Pointer to the frame data which is used to pass thru pay/depayloaders.
314  * @param frame_data_size Frame data size in bytes.
315  * @param frame_count Frame count.
316  * @param filtercaps Caps filters.
317  * @param pay Payloader name.
318  * @param depay Depayloader name.
319  * @bytes_sent bytes that will be sent, used when testing buffer lists
320  * @mtu_size set mtu size when testing lists
321  * @use_lists enable buffer lists
322  */
323 static void
324 rtp_pipeline_test (const guint8 * frame_data, int frame_data_size,
325     int frame_count, const char *filtercaps, const char *pay, const char *depay,
326     guint bytes_sent, guint mtu_size, gboolean use_lists)
327 {
328   /* Create RTP pipeline. */
329   rtp_pipeline *p =
330       rtp_pipeline_create (frame_data, frame_data_size, frame_count, filtercaps,
331       pay, depay);
332
333   if (p == NULL) {
334     return;
335   }
336
337   if (use_lists) {
338     rtp_pipeline_enable_lists (p, mtu_size);
339     chain_list_bytes_received = 0;
340   }
341
342   /* Run RTP pipeline. */
343   rtp_pipeline_run (p);
344
345   /* Destroy RTP pipeline. */
346   rtp_pipeline_destroy (p);
347
348   if (use_lists) {
349     /* 'next NAL' indicator is 4 bytes */
350     fail_if (chain_list_bytes_received != bytes_sent * LOOP_COUNT);
351   }
352 }
353
354 static const guint8 rtp_ilbc_frame_data[] =
355     { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
356   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
357 };
358
359 static int rtp_ilbc_frame_data_size = 20;
360
361 static int rtp_ilbc_frame_count = 1;
362
363 GST_START_TEST (rtp_ilbc)
364 {
365   rtp_pipeline_test (rtp_ilbc_frame_data, rtp_ilbc_frame_data_size,
366       rtp_ilbc_frame_count, "audio/x-iLBC,mode=20", "rtpilbcpay",
367       "rtpilbcdepay", 0, 0, FALSE);
368 }
369
370 GST_END_TEST;
371 static const guint8 rtp_gsm_frame_data[] =
372     { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
373   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
374 };
375
376 static int rtp_gsm_frame_data_size = 20;
377
378 static int rtp_gsm_frame_count = 1;
379
380 GST_START_TEST (rtp_gsm)
381 {
382   rtp_pipeline_test (rtp_gsm_frame_data, rtp_gsm_frame_data_size,
383       rtp_gsm_frame_count, "audio/x-gsm,rate=8000,channels=1", "rtpgsmpay",
384       "rtpgsmdepay", 0, 0, FALSE);
385 }
386
387 GST_END_TEST;
388 static const guint8 rtp_amr_frame_data[] =
389     { 0x3c, 0x24, 0x03, 0xb3, 0x48, 0x10, 0x68, 0x46, 0x6c, 0xec, 0x03,
390   0x7a, 0x37, 0x16, 0x41, 0x41, 0xc0, 0x00, 0x0d, 0xcd, 0x12, 0xed,
391   0xad, 0x80, 0x00, 0x00, 0x11, 0x31, 0x00, 0x00, 0x0d, 0xa0
392 };
393
394 static int rtp_amr_frame_data_size = 32;
395
396 static int rtp_amr_frame_count = 1;
397
398 GST_START_TEST (rtp_amr)
399 {
400   rtp_pipeline_test (rtp_amr_frame_data, rtp_amr_frame_data_size,
401       rtp_amr_frame_count, "audio/AMR,channels=1,rate=8000", "rtpamrpay",
402       "rtpamrdepay", 0, 0, FALSE);
403 }
404
405 GST_END_TEST;
406 static const guint8 rtp_pcma_frame_data[] =
407     { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
408   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
409 };
410
411 static int rtp_pcma_frame_data_size = 20;
412
413 static int rtp_pcma_frame_count = 1;
414
415 GST_START_TEST (rtp_pcma)
416 {
417   rtp_pipeline_test (rtp_pcma_frame_data, rtp_pcma_frame_data_size,
418       rtp_pcma_frame_count, "audio/x-alaw,channels=1,rate=8000", "rtppcmapay",
419       "rtppcmadepay", 0, 0, FALSE);
420 }
421
422 GST_END_TEST;
423 static const guint8 rtp_pcmu_frame_data[] =
424     { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
425   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
426 };
427
428 static int rtp_pcmu_frame_data_size = 20;
429
430 static int rtp_pcmu_frame_count = 1;
431
432 GST_START_TEST (rtp_pcmu)
433 {
434   rtp_pipeline_test (rtp_pcmu_frame_data, rtp_pcmu_frame_data_size,
435       rtp_pcmu_frame_count, "audio/x-mulaw,channels=1,rate=8000", "rtppcmupay",
436       "rtppcmudepay", 0, 0, FALSE);
437 }
438
439 GST_END_TEST;
440 static const guint8 rtp_mpa_frame_data[] =
441     { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
442   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
443 };
444
445 static int rtp_mpa_frame_data_size = 20;
446
447 static int rtp_mpa_frame_count = 1;
448
449 GST_START_TEST (rtp_mpa)
450 {
451   rtp_pipeline_test (rtp_mpa_frame_data, rtp_mpa_frame_data_size,
452       rtp_mpa_frame_count, "audio/mpeg", "rtpmpapay", "rtpmpadepay", 0, 0,
453       FALSE);
454 }
455
456 GST_END_TEST;
457 static const guint8 rtp_h263_frame_data[] =
458     { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
459   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
460 };
461
462 static int rtp_h263_frame_data_size = 20;
463
464 static int rtp_h263_frame_count = 1;
465
466 GST_START_TEST (rtp_h263)
467 {
468   rtp_pipeline_test (rtp_h263_frame_data, rtp_h263_frame_data_size,
469       rtp_h263_frame_count, "video/x-h263,variant=(string)itu,h263version=h263",
470       "rtph263pay", "rtph263depay", 0, 0, FALSE);
471 }
472
473 GST_END_TEST;
474 static const guint8 rtp_h263p_frame_data[] =
475     { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
476   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
477 };
478
479 static int rtp_h263p_frame_data_size = 20;
480
481 static int rtp_h263p_frame_count = 1;
482
483 GST_START_TEST (rtp_h263p)
484 {
485   rtp_pipeline_test (rtp_h263p_frame_data, rtp_h263p_frame_data_size,
486       rtp_h263p_frame_count, "video/x-h263,variant=(string)itu", "rtph263ppay",
487       "rtph263pdepay", 0, 0, FALSE);
488 }
489
490 GST_END_TEST;
491 static const guint8 rtp_h264_frame_data[] =
492     { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
493   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
494 };
495
496 static int rtp_h264_frame_data_size = 20;
497
498 static int rtp_h264_frame_count = 1;
499
500 GST_START_TEST (rtp_h264)
501 {
502   /* FIXME 0.11: fully specify h264 caps (and make payloader check) */
503   rtp_pipeline_test (rtp_h264_frame_data, rtp_h264_frame_data_size,
504       rtp_h264_frame_count, "video/x-h264", "rtph264pay", "rtph264depay",
505       0, 0, FALSE);
506 }
507
508 GST_END_TEST;
509 static const guint8 rtp_h264_list_lt_mtu_frame_data[] =
510     /* not packetized, next NAL starts with 0001 */
511 { 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
512   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
513   0xad, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x00
514 };
515
516 static int rtp_h264_list_lt_mtu_frame_data_size = 16;
517
518 static int rtp_h264_list_lt_mtu_frame_count = 2;
519
520 /* NAL = 4 bytes */
521 static int rtp_h264_list_lt_mtu_bytes_sent = 2 * (16 - 4);
522
523 static int rtp_h264_list_lt_mtu_mtu_size = 1024;
524
525 GST_START_TEST (rtp_h264_list_lt_mtu)
526 {
527   /* FIXME 0.11: fully specify h264 caps (and make payloader check) */
528   rtp_pipeline_test (rtp_h264_list_lt_mtu_frame_data,
529       rtp_h264_list_lt_mtu_frame_data_size, rtp_h264_list_lt_mtu_frame_count,
530       "video/x-h264", "rtph264pay", "rtph264depay",
531       rtp_h264_list_lt_mtu_bytes_sent, rtp_h264_list_lt_mtu_mtu_size, TRUE);
532 }
533
534 GST_END_TEST;
535 static const guint8 rtp_h264_list_gt_mtu_frame_data[] =
536     /* not packetized, next NAL starts with 0001 */
537 { 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
538   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
539   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
540   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
541   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
542   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
543 };
544
545 static int rtp_h264_list_gt_mtu_frame_data_size = 64;
546
547 static int rtp_h264_list_gt_mtu_frame_count = 1;
548
549 /* NAL = 4 bytes. When data does not fit into 1 mtu, 1 byte will be skipped */
550 static int rtp_h264_list_gt_mtu_bytes_sent = 1 * (64 - 4) - 1;
551
552 static int rtp_h264_list_gt_mtu_mty_size = 28;
553
554 GST_START_TEST (rtp_h264_list_gt_mtu)
555 {
556   /* FIXME 0.11: fully specify h264 caps (and make payloader check) */
557   rtp_pipeline_test (rtp_h264_list_gt_mtu_frame_data,
558       rtp_h264_list_gt_mtu_frame_data_size, rtp_h264_list_gt_mtu_frame_count,
559       "video/x-h264", "rtph264pay", "rtph264depay",
560       rtp_h264_list_gt_mtu_bytes_sent, rtp_h264_list_gt_mtu_mty_size, TRUE);
561 }
562
563 GST_END_TEST;
564 static const guint8 rtp_L16_frame_data[] =
565     { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
566   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
567 };
568
569 static int rtp_L16_frame_data_size = 20;
570
571 static int rtp_L16_frame_count = 1;
572
573 GST_START_TEST (rtp_L16)
574 {
575   rtp_pipeline_test (rtp_L16_frame_data, rtp_L16_frame_data_size,
576       rtp_L16_frame_count,
577       "audio/x-raw-int,endianess=4321,signed=true,width=16,depth=16,rate=1,channels=1",
578       "rtpL16pay", "rtpL16depay", 0, 0, FALSE);
579 }
580
581 GST_END_TEST;
582 static const guint8 rtp_mp2t_frame_data[] =
583     { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
584   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
585 };
586
587 static int rtp_mp2t_frame_data_size = 20;
588
589 static int rtp_mp2t_frame_count = 1;
590
591 GST_START_TEST (rtp_mp2t)
592 {
593   rtp_pipeline_test (rtp_mp2t_frame_data, rtp_mp2t_frame_data_size,
594       rtp_mp2t_frame_count, "video/mpegts,packetsize=188,systemstream=true",
595       "rtpmp2tpay", "rtpmp2tdepay", 0, 0, FALSE);
596 }
597
598 GST_END_TEST;
599 static const guint8 rtp_mp4v_frame_data[] =
600     { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
601   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
602 };
603
604 static int rtp_mp4v_frame_data_size = 20;
605
606 static int rtp_mp4v_frame_count = 1;
607
608 GST_START_TEST (rtp_mp4v)
609 {
610   rtp_pipeline_test (rtp_mp4v_frame_data, rtp_mp4v_frame_data_size,
611       rtp_mp4v_frame_count, "video/mpeg,mpegversion=4,systemstream=false",
612       "rtpmp4vpay", "rtpmp4vdepay", 0, 0, FALSE);
613 }
614
615 GST_END_TEST;
616 static const guint8 rtp_mp4v_list_frame_data[] =
617     { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
618   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
619 };
620
621 static int rtp_mp4v_list_frame_data_size = 20;
622
623 static int rtp_mp4v_list_frame_count = 1;
624
625 static int rtp_mp4v_list_bytes_sent = 1 * 20;
626
627 GST_START_TEST (rtp_mp4v_list)
628 {
629   rtp_pipeline_test (rtp_mp4v_list_frame_data, rtp_mp4v_list_frame_data_size,
630       rtp_mp4v_list_frame_count,
631       "video/mpeg,mpegversion=4,codec_data=(buffer)000001b001",
632       "rtpmp4vpay", "rtpmp4vdepay", rtp_mp4v_list_bytes_sent, 0, TRUE);
633 }
634
635 GST_END_TEST;
636 static const guint8 rtp_mp4g_frame_data[] =
637     { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
638   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
639 };
640
641 static int rtp_mp4g_frame_data_size = 20;
642
643 static int rtp_mp4g_frame_count = 1;
644
645 GST_START_TEST (rtp_mp4g)
646 {
647   rtp_pipeline_test (rtp_mp4g_frame_data, rtp_mp4g_frame_data_size,
648       rtp_mp4g_frame_count,
649       "video/mpeg,mpegversion=4,codec_data=(buffer)000001b001", "rtpmp4gpay",
650       "rtpmp4gdepay", 0, 0, FALSE);
651 }
652
653 GST_END_TEST;
654 static const guint8 rtp_theora_frame_data[] =
655     { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
656   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
657 };
658
659 static int rtp_theora_frame_data_size = 20;
660
661 static int rtp_theora_frame_count = 1;
662
663 GST_START_TEST (rtp_theora)
664 {
665   rtp_pipeline_test (rtp_theora_frame_data, rtp_theora_frame_data_size,
666       rtp_theora_frame_count, "video/x-theora", "rtptheorapay",
667       "rtptheoradepay", 0, 0, FALSE);
668 }
669
670 GST_END_TEST;
671 static const guint8 rtp_vorbis_frame_data[] =
672     { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
673   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
674 };
675
676 static int rtp_vorbis_frame_data_size = 20;
677
678 static int rtp_vorbis_frame_count = 1;
679
680 GST_START_TEST (rtp_vorbis)
681 {
682   rtp_pipeline_test (rtp_vorbis_frame_data, rtp_vorbis_frame_data_size,
683       rtp_vorbis_frame_count, "audio/x-vorbis", "rtpvorbispay",
684       "rtpvorbisdepay", 0, 0, FALSE);
685 }
686
687 GST_END_TEST;
688 static const guint8 rtp_jpeg_frame_data[] =
689     { /* SOF */ 0xFF, 0xC0, 0x00, 0x11, 0x08, 0x00, 0x08, 0x00, 0x08,
690   0x03, 0x00, 0x21, 0x08, 0x01, 0x11, 0x08, 0x02, 0x11, 0x08,
691   /* DQT */ 0xFF, 0xDB, 0x00, 0x43, 0x08,
692   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
693   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
694   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
695   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
696   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
697   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
698   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
699   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
700   /* DATA */ 0x00, 0x00, 0x00, 0x00, 0x00
701 };
702
703 static int rtp_jpeg_frame_data_size = sizeof (rtp_jpeg_frame_data);
704
705 static int rtp_jpeg_frame_count = 1;
706
707 GST_START_TEST (rtp_jpeg)
708 {
709   rtp_pipeline_test (rtp_jpeg_frame_data, rtp_jpeg_frame_data_size,
710       rtp_jpeg_frame_count, "video/x-jpeg,height=640,width=480", "rtpjpegpay",
711       "rtpjpegdepay", 0, 0, FALSE);
712 }
713
714 GST_END_TEST;
715 static const guint8 rtp_jpeg_list_frame_data[] =
716     { /* SOF */ 0xFF, 0xC0, 0x00, 0x11, 0x08, 0x00, 0x08, 0x00, 0x08,
717   0x03, 0x00, 0x21, 0x08, 0x01, 0x11, 0x08, 0x02, 0x11, 0x08,
718   /* DQT */ 0xFF, 0xDB, 0x00, 0x43, 0x08,
719   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
720   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
721   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
722   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
723   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
724   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
725   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
726   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
727   /* DATA */ 0x00, 0x00, 0x00, 0x00, 0x00
728 };
729
730 static int rtp_jpeg_list_frame_data_size = sizeof (rtp_jpeg_list_frame_data);
731
732 static int rtp_jpeg_list_frame_count = 1;
733
734 static int rtp_jpeg_list_bytes_sent = 1 * sizeof (rtp_jpeg_list_frame_data);
735
736 GST_START_TEST (rtp_jpeg_list)
737 {
738   rtp_pipeline_test (rtp_jpeg_list_frame_data, rtp_jpeg_list_frame_data_size,
739       rtp_jpeg_list_frame_count, "video/x-jpeg,height=640,width=480",
740       "rtpjpegpay", "rtpjpegdepay", rtp_jpeg_list_bytes_sent, 0, TRUE);
741 }
742
743 GST_END_TEST;
744 static const guint8 rtp_g729_frame_data[] =
745     { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
746   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
747 };
748
749 static int rtp_g729_frame_data_size = 22;
750
751 static int rtp_g729_frame_count = 1;
752
753 GST_START_TEST (rtp_g729)
754 {
755   rtp_pipeline_test (rtp_g729_frame_data, rtp_g729_frame_data_size,
756       rtp_g729_frame_count, "audio/G729", "rtpg729pay",
757       "rtpg729depay", 0, 0, FALSE);
758 }
759
760 GST_END_TEST;
761
762 /*
763  * Creates the test suite.
764  *
765  * Returns: pointer to the test suite.
766  */
767 static Suite *
768 rtp_payloading_suite (void)
769 {
770   Suite *s = suite_create ("rtp_data_test");
771
772   TCase *tc_chain = tcase_create ("linear");
773
774   /* Set timeout to 60 seconds. */
775   tcase_set_timeout (tc_chain, 60);
776
777   suite_add_tcase (s, tc_chain);
778   tcase_add_test (tc_chain, rtp_ilbc);
779   tcase_add_test (tc_chain, rtp_gsm);
780   tcase_add_test (tc_chain, rtp_amr);
781   tcase_add_test (tc_chain, rtp_pcma);
782   tcase_add_test (tc_chain, rtp_pcmu);
783   tcase_add_test (tc_chain, rtp_mpa);
784   tcase_add_test (tc_chain, rtp_h263);
785   tcase_add_test (tc_chain, rtp_h263p);
786   tcase_add_test (tc_chain, rtp_h264);
787   tcase_add_test (tc_chain, rtp_h264_list_lt_mtu);
788   tcase_add_test (tc_chain, rtp_h264_list_gt_mtu);
789   tcase_add_test (tc_chain, rtp_L16);
790   tcase_add_test (tc_chain, rtp_mp2t);
791   tcase_add_test (tc_chain, rtp_mp4v);
792   tcase_add_test (tc_chain, rtp_mp4v_list);
793   tcase_add_test (tc_chain, rtp_mp4g);
794   tcase_add_test (tc_chain, rtp_theora);
795   tcase_add_test (tc_chain, rtp_vorbis);
796   tcase_add_test (tc_chain, rtp_jpeg);
797   tcase_add_test (tc_chain, rtp_jpeg_list);
798   tcase_add_test (tc_chain, rtp_g729);
799   return s;
800 }
801
802 GST_CHECK_MAIN (rtp_payloading)