1 /* GStreamer RTP jpeg unit test
2 *
3 * Copyright (C) 2020 Kristofer Bjorkstrom <at axis dot 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., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21 #include <gst/check/check.h>
22 #include <gst/app/app.h>
23 #include <gst/rtp/gstrtpbuffer.h>
24
25
26 /* one complete blank jpeg 1x1 */
27 static const guint8 rtp_jpeg_frame_data[] =
28 { /* SOI */ 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46,
29 0x00, 0x01, 0x01, 0x01, 0x00, 0x60,
30 0x00, 0x60, 0x00, 0x00, /* DQT */ 0xff, 0xdb, 0x00, 0x43, 0x00, 0x08, 0x06,
31 0x06, 0x07, 0x06, 0x05, 0x08,
32 0x07, 0x07, 0x07, 0x09, 0x09, 0x08, 0x0a, 0x0c, 0x14, 0x0d, 0x0c, 0x0b, 0x0b,
33 0x0c, 0x19, 0x12,
34 0x13, 0x0f, 0x14, 0x1d, 0x1a, 0x1f, 0x1e, 0x1d, 0x1a, 0x1c, 0x1c, 0x20, 0x24,
35 0x2e, 0x27, 0x20,
36 0x22, 0x2c, 0x23, 0x1c, 0x1c, 0x28, 0x37, 0x29, 0x2c, 0x30, 0x31, 0x34, 0x34,
37 0x34, 0x1f, 0x27,
38 0x39, 0x3d, 0x38, 0x32, 0x3c, 0x2e, 0x33, 0x34, 0x32, 0xff, 0xdb, 0x00, 0x43,
39 0x01, 0x09, 0x09,
40 0x09, 0x0c, 0x0b, 0x0c, 0x18, 0x0d, 0x0d, 0x18, 0x32, 0x21, 0x1c, 0x21, 0x32,
41 0x32, 0x32, 0x32,
42 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
43 0x32, 0x32, 0x32,
44 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
45 0x32, 0x32, 0x32,
46 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
47 0x32, /* SOF */ 0xff, 0xc0,
48 0x00, 0x11, 0x08, 0x00, 0x01, 0x00, 0x01, 0x03, 0x01, 0x22, 0x00, 0x02, 0x11,
49 0x01, 0x03, 0x11,
50 0x01, 0xff, 0xc4, 0x00, 0x1f, 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01,
51 0x01, 0x01, 0x00,
52 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
53 0x07, 0x08, 0x09,
54 0x0a, 0x0b, 0xff, 0xc4, 0x00, 0xb5, 0x10, 0x00, 0x02, 0x01, 0x03, 0x03, 0x02,
55 0x04, 0x03, 0x05,
56 0x05, 0x04, 0x04, 0x00, 0x00, 0x01, 0x7d, 0x01, 0x02, 0x03, 0x00, 0x04, 0x11,
57 0x05, 0x12, 0x21,
58 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91,
59 0xa1, 0x08, 0x23,
60 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, 0x24, 0x33, 0x62, 0x72, 0x82, 0x09,
61 0x0a, 0x16, 0x17,
62 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37,
63 0x38, 0x39, 0x3a,
64 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57,
65 0x58, 0x59, 0x5a,
66 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77,
67 0x78, 0x79, 0x7a,
68 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96,
69 0x97, 0x98, 0x99,
70 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4,
71 0xb5, 0xb6, 0xb7,
72 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2,
73 0xd3, 0xd4, 0xd5,
74 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8,
75 0xe9, 0xea, 0xf1,
76 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xff, 0xc4, 0x00, 0x1f,
77 0x01, 0x00, 0x03,
78 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
79 0x00, 0x00, 0x01,
80 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0xff, 0xc4, 0x00,
81 0xb5, 0x11, 0x00,
82 0x02, 0x01, 0x02, 0x04, 0x04, 0x03, 0x04, 0x07, 0x05, 0x04, 0x04, 0x00, 0x01,
83 0x02, 0x77, 0x00,
84 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, 0x07,
85 0x61, 0x71, 0x13,
86 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33,
87 0x52, 0xf0, 0x15,
88 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19,
89 0x1a, 0x26, 0x27,
90 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46,
91 0x47, 0x48, 0x49,
92 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66,
93 0x67, 0x68, 0x69,
94 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85,
95 0x86, 0x87, 0x88,
96 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3,
97 0xa4, 0xa5, 0xa6,
98 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba,
99 0xc2, 0xc3, 0xc4,
100 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8,
101 0xd9, 0xda, 0xe2,
102 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6,
103 0xf7, 0xf8, 0xf9,
104 0xfa, 0xff, 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, 0x11, 0x00,
105 0x3f, 0x00, 0xf7,
106 0xfa, 0x28, 0xa2, 0x80, 0x3f, 0xff, 0xd9
107 };
108
109 /* first slice of one complete blank jpeg 1x1 */
110 static const guint8 rtp_jpeg_frame_data_s1[] = {
111 /* SOI */ 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00,
112 0x01, 0x01, 0x01, 0x00, 0x60,
113 0x00, 0x60, 0x00
114 };
115
116 /* second slice of one complete blank jpeg 1x1 */
117 static const guint8 rtp_jpeg_frame_data_s2[] = {
118 0x00, /* DQT */ 0xff, 0xdb, 0x00, 0x43, 0x00, 0x08, 0x06, 0x06, 0x07, 0x06,
119 0x05, 0x08,
120 0x07, 0x07, 0x07, 0x09, 0x09, 0x08, 0x0a, 0x0c, 0x14, 0x0d, 0x0c, 0x0b, 0x0b,
121 0x0c, 0x19, 0x12,
122 0x13, 0x0f, 0x14, 0x1d, 0x1a, 0x1f, 0x1e, 0x1d, 0x1a, 0x1c, 0x1c, 0x20, 0x24,
123 0x2e, 0x27, 0x20,
124 0x22, 0x2c, 0x23, 0x1c, 0x1c, 0x28, 0x37, 0x29, 0x2c, 0x30, 0x31, 0x34, 0x34,
125 0x34, 0x1f, 0x27,
126 0x39, 0x3d, 0x38, 0x32, 0x3c, 0x2e, 0x33, 0x34, 0x32, 0xff, 0xdb, 0x00, 0x43,
127 0x01, 0x09, 0x09,
128 0x09, 0x0c, 0x0b, 0x0c, 0x18, 0x0d, 0x0d, 0x18, 0x32, 0x21, 0x1c, 0x21, 0x32,
129 0x32, 0x32, 0x32,
130 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
131 0x32, 0x32, 0x32
132 };
133
134 /* third slice of one complete blank jpeg 1x1 */
135 static const guint8 rtp_jpeg_frame_data_s3[] = {
136 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
137 0x32, 0x32, 0x32,
138 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
139 0x32, /* SOF */ 0xff, 0xc0,
140 0x00, 0x11, 0x08, 0x00, 0x01, 0x00, 0x01, 0x03, 0x01, 0x22, 0x00, 0x02, 0x11,
141 0x01, 0x03, 0x11,
142 0x01, 0xff, 0xc4, 0x00, 0x1f, 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01,
143 0x01, 0x01, 0x00,
144 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
145 0x07, 0x08, 0x09,
146 0x0a, 0x0b
147 };
148
149 /* fourth slice of one complete blank jpeg 1x1 */
150 static const guint8 rtp_jpeg_frame_data_s4[] = {
151 0xff, 0xc4, 0x00, 0xb5, 0x10, 0x00, 0x02, 0x01, 0x03, 0x03, 0x02, 0x04, 0x03,
152 0x05,
153 0x05, 0x04, 0x04, 0x00, 0x00, 0x01, 0x7d, 0x01, 0x02, 0x03, 0x00, 0x04, 0x11,
154 0x05, 0x12, 0x21,
155 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91,
156 0xa1, 0x08, 0x23,
157 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, 0x24, 0x33, 0x62, 0x72, 0x82, 0x09,
158 0x0a, 0x16, 0x17,
159 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37,
160 0x38, 0x39, 0x3a,
161 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57,
162 0x58, 0x59, 0x5a,
163 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77,
164 0x78, 0x79, 0x7a,
165 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96,
166 0x97, 0x98, 0x99,
167 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4,
168 0xb5, 0xb6, 0xb7,
169 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2,
170 0xd3, 0xd4, 0xd5,
171 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8,
172 0xe9, 0xea, 0xf1,
173 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xff
174 };
175
176 /* fifth and last slice of one complete blank jpeg 1x1 */
177 static const guint8 rtp_jpeg_frame_data_s5[] = {
178 0xc4, 0x00, 0x1f, 0x01, 0x00, 0x03,
179 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
180 0x00, 0x00, 0x01,
181 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0xff, 0xc4, 0x00,
182 0xb5, 0x11, 0x00,
183 0x02, 0x01, 0x02, 0x04, 0x04, 0x03, 0x04, 0x07, 0x05, 0x04, 0x04, 0x00, 0x01,
184 0x02, 0x77, 0x00,
185 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, 0x07,
186 0x61, 0x71, 0x13,
187 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33,
188 0x52, 0xf0, 0x15,
189 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19,
190 0x1a, 0x26, 0x27,
191 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46,
192 0x47, 0x48, 0x49,
193 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66,
194 0x67, 0x68, 0x69,
195 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85,
196 0x86, 0x87, 0x88,
197 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3,
198 0xa4, 0xa5, 0xa6,
199 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba,
200 0xc2, 0xc3, 0xc4,
201 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8,
202 0xd9, 0xda, 0xe2,
203 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6,
204 0xf7, 0xf8, 0xf9,
205 0xfa, 0xff, 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, 0x11, 0x00,
206 0x3f, 0x00, 0xf7,
207 0xfa, 0x28, 0xa2, 0x80, 0x3f, 0xff, 0xd9
208 };
209
210
211 /*
212 * rfc2435 3.1. JPEG header
213 *
214 * Each packet contains a special JPEG header which immediately follows
215 * the RTP header. The first 8 bytes of this header, called the "main
216 * JPEG header", are as follows:
217 *
218 * 0 1 2 3
219 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
220 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
221 * | Type-specific | Fragment Offset |
222 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
223 * | Type | Q | Width | Height |
224 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
225 *
226 */
227
GST_START_TEST(test_rtpjpegpay_1_slice)228 GST_START_TEST (test_rtpjpegpay_1_slice)
229 {
230 GstFlowReturn ret;
231 GstBuffer *buffer;
232 GstRTPBuffer rtp = GST_RTP_BUFFER_INIT;
233 GstCaps *caps = gst_caps_from_string ("video/x-jpeg,height=1,width=1");
234 gchar *s = g_strdup_printf ("rtpjpegpay");
235 GstHarness *h = gst_harness_new_parse (s);
236 guint8 *payload;
237
238 gst_harness_set_src_caps (h, caps);
239 g_free (s);
240
241 buffer = gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY,
242 (guint8 *) rtp_jpeg_frame_data, sizeof (rtp_jpeg_frame_data), 0,
243 sizeof (rtp_jpeg_frame_data), NULL, NULL);
244
245 ret = gst_harness_push (h, buffer);
246 fail_unless_equals_int (ret, GST_FLOW_OK);
247
248 fail_unless_equals_int (gst_harness_buffers_in_queue (h), 1);
249
250 buffer = gst_harness_pull (h);
251 fail_unless (gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtp));
252 fail_unless (payload = gst_rtp_buffer_get_payload (&rtp));
253
254 /* verify JPEG header */
255 fail_unless (GST_READ_UINT24_BE (&payload[1]) == 0); /* offset */
256 fail_unless (payload[4] == 1); /* type */
257 fail_unless (payload[6] == 1); /* Width */
258 fail_unless (payload[7] == 1); /* Height */
259
260 fail_unless (gst_rtp_buffer_get_marker (&rtp));
261 gst_rtp_buffer_unmap (&rtp);
262 gst_buffer_unref (buffer);
263
264 gst_harness_teardown (h);
265 }
266
267 GST_END_TEST;
268
GST_START_TEST(test_rtpjpegpay_5_slices)269 GST_START_TEST (test_rtpjpegpay_5_slices)
270 {
271 GstFlowReturn ret;
272 GstBuffer *buffer;
273 GstBuffer *buffer_s1;
274 GstBuffer *buffer_s2;
275 GstBuffer *buffer_s3;
276 GstBuffer *buffer_s4;
277 GstBuffer *buffer_s5;
278 GstRTPBuffer rtp = GST_RTP_BUFFER_INIT;
279 GstCaps *caps = gst_caps_from_string ("video/x-jpeg,height=1,width=1");
280 gchar *s = g_strdup_printf ("rtpjpegpay");
281 GstHarness *h = gst_harness_new_parse (s);
282 guint8 *payload;
283
284 gst_harness_set_src_caps (h, caps);
285 g_free (s);
286
287 buffer_s1 = gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY,
288 (guint8 *) rtp_jpeg_frame_data_s1, sizeof (rtp_jpeg_frame_data_s1), 0,
289 sizeof (rtp_jpeg_frame_data_s1), NULL, NULL);
290 buffer_s2 =
291 gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY,
292 (guint8 *) rtp_jpeg_frame_data_s2, sizeof (rtp_jpeg_frame_data_s2), 0,
293 sizeof (rtp_jpeg_frame_data_s2), NULL, NULL);
294 buffer_s3 =
295 gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY,
296 (guint8 *) rtp_jpeg_frame_data_s3, sizeof (rtp_jpeg_frame_data_s3), 0,
297 sizeof (rtp_jpeg_frame_data_s3), NULL, NULL);
298 buffer_s4 =
299 gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY,
300 (guint8 *) rtp_jpeg_frame_data_s4, sizeof (rtp_jpeg_frame_data_s4), 0,
301 sizeof (rtp_jpeg_frame_data_s4), NULL, NULL);
302 buffer_s5 =
303 gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY,
304 (guint8 *) rtp_jpeg_frame_data_s5, sizeof (rtp_jpeg_frame_data_s5), 0,
305 sizeof (rtp_jpeg_frame_data_s5), NULL, NULL);
306
307
308 buffer = gst_buffer_append (buffer_s1, buffer_s2);
309 buffer = gst_buffer_append (buffer, buffer_s3);
310 buffer = gst_buffer_append (buffer, buffer_s4);
311 buffer = gst_buffer_append (buffer, buffer_s5);
312
313 ret = gst_harness_push (h, buffer);
314 fail_unless_equals_int (ret, GST_FLOW_OK);
315
316 fail_unless_equals_int (gst_harness_buffers_in_queue (h), 1);
317
318 buffer = gst_harness_pull (h);
319 fail_unless (gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtp));
320 fail_unless (payload = gst_rtp_buffer_get_payload (&rtp));
321
322 /* verify JPEG header */
323 fail_unless (GST_READ_UINT24_BE (&payload[1]) == 0); /* offset */
324 fail_unless (payload[4] == 1); /* type */
325 fail_unless (payload[6] == 1); /* Width */
326 fail_unless (payload[7] == 1); /* Height */
327
328 fail_unless (gst_rtp_buffer_get_marker (&rtp));
329 gst_rtp_buffer_unmap (&rtp);
330 gst_buffer_unref (buffer);
331
332 gst_harness_teardown (h);
333 }
334
335 GST_END_TEST;
336
337
338 static Suite *
rtpjpeg_suite(void)339 rtpjpeg_suite (void)
340 {
341 Suite *s = suite_create ("rtpjpeg");
342 TCase *tc_chain;
343
344 tc_chain = tcase_create ("rtpjpegpay_memory_slices");
345 suite_add_tcase (s, tc_chain);
346
347 tcase_add_test (tc_chain, test_rtpjpegpay_1_slice);
348 tcase_add_test (tc_chain, test_rtpjpegpay_5_slices);
349
350 return s;
351 }
352
353 GST_CHECK_MAIN (rtpjpeg);
354