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