1 /* GStreamer
2 *
3 * Copyright (C) 2016 Pexip AS
4 * @author Stian Selnes <stian@pexip.com>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 */
21
22 #include <gst/check/check.h>
23 #include <gst/check/gstharness.h>
24
25 #define RTP_VP9_CAPS_STR \
26 "application/x-rtp,media=video,encoding-name=VP9,clock-rate=90000,payload=96"
27
28
GST_START_TEST(test_depay_flexible_mode)29 GST_START_TEST (test_depay_flexible_mode)
30 {
31 /* b-bit, e-bit, f-bit and marker bit set */
32 /* First packet of first frame, handcrafted to also set the e-bit and marker
33 * bit in addition to changing the seqnum */
34 guint8 intra[] = {
35 0x80, 0xf4, 0x00, 0x00, 0x49, 0xb5, 0xbe, 0x32, 0xb1, 0x01, 0x64, 0xd1,
36 0xbc, 0x98, 0xbf, 0x00, 0x83, 0x49, 0x83, 0x42, 0x00, 0x77, 0xf0, 0x43,
37 0x71, 0xd8, 0xe0, 0x90, 0x70, 0x66, 0x80, 0x60, 0x0e, 0xf0, 0x5f, 0xfd,
38 };
39 /* b-bit, e-bit, p-bit, f-bit and marker bit set */
40 /* First packet of second frame, handcrafted to also set the e-bit and
41 * marker bit in addition to changing the seqnum */
42 guint8 inter[] = {
43 0x80, 0xf4, 0x00, 0x01, 0x49, 0xb6, 0x02, 0xc0, 0xb1, 0x01, 0x64, 0xd1,
44 0xfc, 0x98, 0xc0, 0x00, 0x02, 0x87, 0x01, 0x00, 0x09, 0x3f, 0x1c, 0x12,
45 0x0e, 0x0c, 0xd0, 0x1b, 0xa7, 0x80, 0x80, 0xb0, 0x18, 0x0f, 0xda, 0x11,
46 };
47
48 GstHarness *h = gst_harness_new ("rtpvp9depay");
49 gst_harness_set_src_caps_str (h, RTP_VP9_CAPS_STR);
50
51 gst_harness_push (h, gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY,
52 intra, sizeof (intra), 0, sizeof (intra), NULL, NULL));
53 fail_unless_equals_int (1, gst_harness_buffers_received (h));
54
55 gst_harness_push (h, gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY,
56 inter, sizeof (inter), 0, sizeof (inter), NULL, NULL));
57 fail_unless_equals_int (2, gst_harness_buffers_received (h));
58
59 gst_harness_teardown (h);
60 }
61
62 GST_END_TEST;
63
GST_START_TEST(test_depay_non_flexible_mode)64 GST_START_TEST (test_depay_non_flexible_mode)
65 {
66 /* b-bit, e-bit and marker bit set. f-bit NOT set */
67 /* First packet of first frame, handcrafted to also set the e-bit and marker
68 * bit in addition to changing the seqnum */
69 guint8 intra[] = {
70 0x80, 0xf4, 0x00, 0x00, 0x49, 0x88, 0xd9, 0xf8, 0xa0, 0x6c, 0x65, 0x6c,
71 0x8c, 0x98, 0xc0, 0x87, 0x01, 0x02, 0x49, 0x3f, 0x1c, 0x12, 0x0e, 0x0c,
72 0xd0, 0x1b, 0xb9, 0x80, 0x80, 0xb0, 0x18, 0x0f, 0xa6, 0x4d, 0x01, 0xa5
73 };
74 /* b-bit, e-bit, p-bit and marker bit set. f-bit NOT set */
75 /* First packet of second frame, handcrafted to also set the e-bit and
76 * marker bit in addition to changing the seqnum */
77 guint8 inter[] = {
78 0x80, 0xf4, 0x00, 0x01, 0x49, 0x88, 0xe5, 0x38, 0xa0, 0x6c, 0x65, 0x6c,
79 0xcc, 0x98, 0xc1, 0x87, 0x01, 0x02, 0x49, 0x3f, 0x1c, 0x12, 0x0e, 0x0c,
80 0xd0, 0x1b, 0x97, 0x80, 0x80, 0xb0, 0x18, 0x0f, 0x8a, 0x9f, 0x01, 0xbc
81 };
82
83 GstHarness *h = gst_harness_new ("rtpvp9depay");
84 gst_harness_set_src_caps_str (h, RTP_VP9_CAPS_STR);
85
86 gst_harness_push (h, gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY,
87 intra, sizeof (intra), 0, sizeof (intra), NULL, NULL));
88 fail_unless_equals_int (1, gst_harness_buffers_received (h));
89
90 gst_harness_push (h, gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY,
91 inter, sizeof (inter), 0, sizeof (inter), NULL, NULL));
92 fail_unless_equals_int (2, gst_harness_buffers_received (h));
93
94 gst_harness_teardown (h);
95 }
96
97 GST_END_TEST;
98
99
100
101 static Suite *
rtpvp9_suite(void)102 rtpvp9_suite (void)
103 {
104 Suite *s = suite_create ("rtpvp9");
105 TCase *tc_chain;
106
107 suite_add_tcase (s, (tc_chain = tcase_create ("vp9depay")));
108 tcase_add_test (tc_chain, test_depay_flexible_mode);
109 tcase_add_test (tc_chain, test_depay_non_flexible_mode);
110
111 return s;
112 }
113
114 GST_CHECK_MAIN (rtpvp9);
115