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