1 /*
2 mediastreamer2 library - modular sound and video processing and streaming
3 Copyright (C) 2006-2013 Belledonne Communications, Grenoble
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9
10 This program 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
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20
21 #include "mediastreamer2/mediastream.h"
22 #include "mediastreamer2/dtmfgen.h"
23 #include "mediastreamer2/msfileplayer.h"
24 #include "mediastreamer2/msfilerec.h"
25 #include "mediastreamer2/msrtp.h"
26 #include "mediastreamer2/mstonedetector.h"
27 #include "mediastreamer2_tester.h"
28 #include "mediastreamer2_tester_private.h"
29
30 #ifdef VIDEO_ENABLED
31 typedef enum {
32 YUV420Planar,
33 YUV420SemiPlanar
34 } VideoFormat;
35
36 typedef enum {
37 PixTypeInvalid,
38 PixTypeY,
39 PixTypeU,
40 PixTypeV
41 } PixType;
42 #endif
43
tester_before_all(void)44 static int tester_before_all(void) {
45 /* ms_init();
46 ms_filter_enable_statistics(TRUE);
47 ortp_init();*/
48 return 0;
49 }
50
tester_after_all(void)51 static int tester_after_all(void) {
52 /* ms_exit();*/
53 return 0;
54 }
55
filter_register_tester(void)56 static void filter_register_tester(void) {
57 MSFilter* filter;
58 MSFactory* factory = NULL;
59
60 factory = ms_factory_new_with_voip();
61
62 BC_ASSERT_PTR_NOT_NULL(ms_factory_lookup_filter_by_name(factory, "MSVoidSource"));
63
64 BC_ASSERT_PTR_NOT_NULL(ms_factory_lookup_filter_by_name(factory, "MSVoidSource"));
65 filter= ms_factory_create_decoder(factory, "pcma");
66 BC_ASSERT_PTR_NOT_NULL(filter);
67 ms_filter_destroy(filter);
68
69 BC_ASSERT_PTR_NOT_NULL(ms_factory_lookup_filter_by_name(factory,"MSVoidSource"));
70 filter= ms_factory_create_decoder(factory, "pcma");
71 BC_ASSERT_PTR_NOT_NULL(filter);
72 ms_filter_destroy(filter);
73
74 ms_factory_destroy(factory);
75
76 }
77 #ifdef VIDEO_ENABLED
pix_value(PixType type,size_t idx)78 static uint8_t pix_value(PixType type, size_t idx) {
79 uint8_t idx_code = idx % 32;
80 uint8_t type_code;
81 switch(type) {
82 case PixTypeY:
83 type_code = 0x01 << 6;
84 break;
85 case PixTypeU:
86 type_code = 0x02 << 6;
87 break;
88 case PixTypeV:
89 type_code = 0x03 << 6;
90 break;
91 default:
92 return 0;
93 }
94 return type_code | idx_code;
95 }
96
pix_is_valid(PixType type,size_t idx,uint8_t value)97 static bool_t pix_is_valid(PixType type, size_t idx, uint8_t value) {
98 uint8_t idx_code = idx % 32;
99 uint8_t type_code = 0;
100 switch(type) {
101 case PixTypeY:
102 type_code = 0x01 << 6;
103 break;
104 case PixTypeU:
105 type_code = 0x02 << 6;
106 break;
107 case PixTypeV:
108 type_code = 0x03 << 6;
109 break;
110 default:
111 break;
112 }
113 return (idx_code == (value & 0x3f)) && (type_code == (value & 0xc0));
114 }
115
make_plane(PixType type,const MSVideoSize * buffer_size,const MSRect * roi)116 static uint8_t *make_plane(PixType type, const MSVideoSize *buffer_size, const MSRect *roi) {
117 size_t buflen = buffer_size->width * buffer_size->height;
118 uint8_t *buffer = ms_new0(uint8_t, buflen);
119 uint8_t *wptr = buffer + (roi->y * buffer_size->width + roi->x);
120 int i = 0, l, c;
121
122 for(l=0; l<roi->h; l++) {
123 for(c=0; c<roi->w; c++) {
124 *wptr = pix_value(type, i);
125 wptr++;
126 i++;
127 }
128 wptr += (buffer_size->width - roi->w);
129 }
130 return buffer;
131 }
132
check_plane(PixType type,const MSVideoSize * buffer_size,const MSRect * roi,const uint8_t * buffer)133 static bool_t check_plane(PixType type, const MSVideoSize *buffer_size, const MSRect *roi, const uint8_t *buffer) {
134 const uint8_t *rptr = buffer + (roi->y * buffer_size->width + roi->x);
135 int i = 0, l, c;
136
137 for(l=0; l<roi->h; l++) {
138 for(c=0; c<roi->w; c++) {
139 if(!pix_is_valid(type, i, *rptr))
140 return FALSE;
141 rptr++;
142 i++;
143 }
144 rptr += (buffer_size->width - roi->w);
145 }
146 return TRUE;
147 }
148
make_interleave_plane(PixType type1,PixType type2,const MSVideoSize * buffer_size,const MSRect * roi)149 static uint8_t *make_interleave_plane(PixType type1, PixType type2, const MSVideoSize *buffer_size, const MSRect *roi) {
150 size_t buflen = buffer_size->width * buffer_size->height * 2;
151 uint8_t *buffer = ms_new0(uint8_t, buflen);
152 uint8_t *wptr = buffer + ((roi->y * buffer_size->width + roi->x)*2);
153 int i = 0, l, c;
154
155 for(l=0; l<roi->h; l++) {
156 for(c=0; c<roi->w; c++) {
157 *wptr = pix_value(type1, i);
158 *(wptr+1) = pix_value(type2, i);
159 wptr+=2;
160 i++;
161 }
162 wptr += ((buffer_size->width-roi->w)*2);
163 }
164 return buffer;
165 }
166
check_interleave_plane(PixType type1,PixType type2,const MSVideoSize * buffer_size,const MSRect * roi,const uint8_t * buffer)167 static bool_t check_interleave_plane(PixType type1, PixType type2, const MSVideoSize *buffer_size, const MSRect *roi, const uint8_t *buffer) {
168 const uint8_t *rptr = buffer + ((roi->y * buffer_size->width + roi->x)*2);
169 int i = 0, l, c;
170
171 for(l=0; l<roi->h; l++) {
172 for(c=0; c<roi->w; c++) {
173 if(!pix_is_valid(type1, i, *rptr)) return FALSE;
174 if(!pix_is_valid(type2, i, *(rptr+1))) return FALSE;
175 rptr+=2;
176 i++;
177 }
178 rptr += ((buffer_size->width-roi->w)*2);
179 }
180 return TRUE;
181 }
182
generate_picture(const MSVideoSize * buffer_size,const MSRect * roi,bool_t semi_planar)183 static uint8_t *generate_picture(const MSVideoSize *buffer_size, const MSRect *roi, bool_t semi_planar) {
184 MSVideoSize u_buf_size = { buffer_size->width/2, buffer_size->height/2 };
185 MSRect u_roi = { roi->x/2, roi->y/2, roi->w/2, roi->h/2 };
186 size_t planelen = buffer_size->width * buffer_size->height;
187 size_t buflen = (planelen*3)/2;
188 uint8_t *buffer = ms_new0(uint8_t, buflen);
189 uint8_t *y_plane = make_plane(PixTypeY, buffer_size, roi);
190 uint8_t *wptr;
191
192 wptr = buffer;
193 memcpy(wptr, y_plane, planelen), wptr+=planelen;
194 ms_free(y_plane);
195
196 if(!semi_planar) {
197 uint8_t *u_plane = make_plane(PixTypeU, &u_buf_size, &u_roi);
198 uint8_t *v_plane = make_plane(PixTypeV, &u_buf_size, &u_roi);
199 memcpy(wptr, u_plane, planelen/4), wptr+=planelen/4;
200 memcpy(wptr, v_plane, planelen/4);
201 ms_free(u_plane);
202 ms_free(v_plane);
203 } else {
204 uint8_t *interleave_plane = make_interleave_plane(PixTypeU, PixTypeV, &u_buf_size, &u_roi);
205 memcpy(wptr, interleave_plane, planelen/2);
206 ms_free(interleave_plane);
207 }
208 return buffer;
209 }
210
check_picture(const MSVideoSize * buffer_size,const MSRect * roi,bool_t semi_planar,const uint8_t * buffer)211 static bool_t check_picture(const MSVideoSize *buffer_size, const MSRect *roi, bool_t semi_planar, const uint8_t *buffer) {
212 MSVideoSize u_buf_size = { buffer_size->width/2, buffer_size->height/2 };
213 MSRect u_roi = { roi->x/2, roi->y/2, roi->w/2, roi->h/2 };
214
215 if(!check_plane(PixTypeY, buffer_size, roi, buffer)) return FALSE;
216 buffer += (buffer_size->width * buffer_size->height);
217 if(!semi_planar) {
218 if(!check_plane(PixTypeU, &u_buf_size, &u_roi, buffer)) return FALSE;
219 buffer += ((buffer_size->width * buffer_size->height)/4);
220 if(!check_plane(PixTypeV, &u_buf_size, &u_roi, buffer)) return FALSE;
221 } else {
222 if(!check_interleave_plane(PixTypeU, PixTypeV, &u_buf_size, &u_roi, buffer)) return FALSE;
223 }
224 return TRUE;
225 }
226
test_video_processing_base(bool_t downscaling,bool_t rotate_clock_wise,bool_t flip)227 static void test_video_processing_base (bool_t downscaling,bool_t rotate_clock_wise,bool_t flip) {
228 MSVideoSize src_size = { MS_VIDEO_SIZE_VGA_W, MS_VIDEO_SIZE_VGA_H };
229 MSVideoSize dest_size = src_size;
230
231 mblk_t * yuv_block2;
232 YuvBuf yuv;
233 int y_bytes_per_row = src_size.width + src_size.width%32 ;
234 uint8_t* y = (uint8_t*)ms_malloc(y_bytes_per_row*src_size.height); /*to allow bloc to work with multiple of 32*/
235 int crcb_bytes_per_row = src_size.width/2 + (src_size.width/2)%32 ;
236 uint8_t* cbcr = (uint8_t*)ms_malloc(crcb_bytes_per_row*src_size.height);
237 int i,j;
238 MSYuvBufAllocator *yba = ms_yuv_buf_allocator_new();
239 int factor=downscaling?2:1;
240 int rotation = 0;
241 if (rotate_clock_wise && flip) {
242 ms_fatal("fix you test");
243 }
244 if (rotate_clock_wise) {
245 rotation = 90;
246 dest_size.height=src_size.width;
247 dest_size.width=src_size.height;
248 } else if (flip) {
249 rotation = 180;
250 }
251 dest_size.height = dest_size.height/factor;
252 dest_size.width=dest_size.width/factor;
253
254 for (i=0;i<src_size.height*src_size.width;i++) {
255 y[i]=i%256;
256 }
257 for (i=0;i<src_size.height*src_size.width/2;i++) {
258 cbcr[i]=i%256;
259 }
260
261 yuv_block2 = copy_ycbcrbiplanar_to_true_yuv_with_rotation_and_down_scale_by_2(yba, y
262 ,cbcr
263 ,rotation
264 , dest_size.width
265 , dest_size.height
266 , y_bytes_per_row
267 , crcb_bytes_per_row
268 , 1
269 , downscaling);
270
271 BC_ASSERT_FALSE(ms_yuv_buf_init_from_mblk(&yuv, yuv_block2));
272 BC_ASSERT_EQUAL(dest_size.width,yuv.w, int, "%d");
273 BC_ASSERT_EQUAL(dest_size.height,yuv.h, int, "%d");
274
275 if (rotate_clock_wise) {
276 /*check y*/
277 for (i=0;i<yuv.h;i++) {
278 for (j=0;j<yuv.w;j++)
279 if (yuv.planes[0][i*yuv.strides[0]+j] != y[(yuv.w-1-j)*factor*y_bytes_per_row+i*factor]) {
280 ms_error("Wrong value [%i] at ofset [%i], should be [%i]",yuv.planes[0][i*yuv.strides[0]+j],i*yuv.strides[0]+j,y[(yuv.w-1-j)*factor*y_bytes_per_row+i*factor]);
281 BC_FAIL("bad y value");
282 break;
283 }
284
285 }
286 /*check cb*/
287 for (i=0;i<yuv.h/2;i++) {
288 for (j=0;j<yuv.w/2;j++) {
289 if (yuv.planes[1][i*yuv.strides[1]+j] != cbcr[(yuv.w/2-1-j)*factor*crcb_bytes_per_row+2*i*factor]) {
290 ms_error("Wrong value [%i] at ofset [%i], should be [%i]",yuv.planes[1][i*yuv.strides[1]+j],i*yuv.strides[1]+j,cbcr[(yuv.w/2-1-j)*factor*crcb_bytes_per_row+2*i*factor]);
291 BC_FAIL("bad cb value");
292 break;
293 }
294 if (yuv.planes[2][i*yuv.strides[2]+j] != cbcr[(yuv.w/2-1-j)*factor*crcb_bytes_per_row+2*i*factor+1]) {
295 ms_error("Wrong value [%i] at ofset [%i], should be [%i]",yuv.planes[2][i*yuv.strides[2]+j],i*yuv.strides[2]+j,cbcr[(yuv.w/2-1-j)*factor*crcb_bytes_per_row+2*i*factor+1]);
296 BC_FAIL("bad cr value");
297 break;
298 }
299 }
300 }
301 } else if (flip) {
302
303 /*check y*/
304 for (i=0;i<yuv.h;i++) {
305 for (j=0;j<yuv.w;j++)
306 if (yuv.planes[0][i*yuv.strides[0]+j] != y[(yuv.h-1-i)*factor*y_bytes_per_row+(yuv.w-1-j)*factor]) {
307 ms_error("Wrong value [%i] at ofset [%i], should be [%i]",yuv.planes[0][i*yuv.strides[0]+j],i*yuv.strides[0]+j,y[(yuv.h-1-i)*factor*y_bytes_per_row+(yuv.w-1-j)*factor]);
308 BC_FAIL("bad y value");
309 break;
310 }
311 }
312
313 for (i=0;i<yuv.h/2;i++) {
314 for (j=0;j<yuv.w/2;j++) {
315 /*check cb*/
316 if (yuv.planes[1][i*yuv.strides[1]+j] != cbcr[(yuv.h/2-1-i)*factor*crcb_bytes_per_row+2*(yuv.w/2-1-j)*factor]) {
317 ms_error("Wrong value [%i] at ofset [%i], should be [%i]",yuv.planes[1][i*yuv.strides[1]+j],i*yuv.strides[1]+j,cbcr[(yuv.h/2-1-i)*factor*crcb_bytes_per_row+2*(yuv.w/2-1-j)*factor]);
318 BC_FAIL("bad cb value");
319 break;
320 }
321 /*check cr*/
322 if (yuv.planes[2][i*yuv.strides[2]+j] != cbcr[(yuv.h/2-1-i)*factor*crcb_bytes_per_row+2*(yuv.w/2-1-j)*factor+1]) {
323 ms_error("Wrong value [%i] at ofset [%i], should be [%i]",yuv.planes[2][i*yuv.strides[2]+j],i*yuv.strides[2]+j,cbcr[(yuv.h/2-1-i)*factor*crcb_bytes_per_row+2*(yuv.w/2-1-j)*factor+1]);
324 BC_FAIL("bad cr value");
325 break;
326 }
327
328 }
329 }
330 }
331 else {
332 /*check y*/
333 for (i=0;i<yuv.h;i++) {
334 for (j=0;j<yuv.w;j++)
335 if (yuv.planes[0][i*yuv.strides[0]+j] != y[i*factor*y_bytes_per_row+j*factor]) {
336 ms_error("Wrong value [%i] at ofset [%i], should be [%i]",yuv.planes[0][i*yuv.strides[0]+j],i*yuv.strides[0]+j,y[i*factor*y_bytes_per_row+j*factor]);
337 BC_FAIL("bad y value");
338 break;
339 }
340 }
341
342 for (i=0;i<yuv.h/2;i++) {
343 for (j=0;j<yuv.w/2;j++) {
344 /*check cb*/
345 if (yuv.planes[1][i*yuv.strides[1]+j] != cbcr[i*factor*crcb_bytes_per_row+2*j*factor]) {
346 ms_error("Wrong value [%i] at ofset [%i], should be [%i]",yuv.planes[1][i*yuv.strides[1]+j],i*yuv.strides[1]+j,cbcr[i*factor*crcb_bytes_per_row+2*j*factor]);
347 BC_FAIL("bad cb value");
348 break;
349 }
350 /*check cr*/
351 if (yuv.planes[2][i*yuv.strides[2]+j] != cbcr[i*factor*crcb_bytes_per_row+2*j*factor+1]) {
352 ms_error("Wrong value [%i] at ofset [%i], should be [%i]",yuv.planes[2][i*yuv.strides[2]+j],i*yuv.strides[2]+j,cbcr[i*factor*crcb_bytes_per_row+2*j*factor+1]);
353 BC_FAIL("bad cr value");
354 break;
355 }
356
357 }
358 }
359 }
360 freemsg(yuv_block2);
361 ms_free(y);
362 ms_free(cbcr);
363 ms_yuv_buf_allocator_free(yba);
364
365 }
test_video_processing(void)366 static void test_video_processing (void) {
367 test_video_processing_base(FALSE,FALSE,FALSE);
368 }
369
test_copy_ycbcrbiplanar_to_true_yuv_with_downscaling(void)370 static void test_copy_ycbcrbiplanar_to_true_yuv_with_downscaling (void) {
371 test_video_processing_base(TRUE,FALSE,FALSE);
372 }
373
test_copy_ycbcrbiplanar_to_true_yuv_with_rotation_clock_wise(void)374 static void test_copy_ycbcrbiplanar_to_true_yuv_with_rotation_clock_wise(void) {
375 test_video_processing_base(FALSE,TRUE,FALSE);
376 }
377
test_copy_ycbcrbiplanar_to_true_yuv_with_rotation_clock_wise_with_downscaling(void)378 static void test_copy_ycbcrbiplanar_to_true_yuv_with_rotation_clock_wise_with_downscaling(void) {
379 test_video_processing_base(TRUE,TRUE,FALSE);
380 }
381
test_copy_ycbcrbiplanar_to_true_yuv_with_rotation_180(void)382 static void test_copy_ycbcrbiplanar_to_true_yuv_with_rotation_180(void) {
383 test_video_processing_base(FALSE,FALSE,TRUE);
384 }
385
test_copy_ycbcrbiplanar_to_true_yuv_with_rotation_180_with_downscaling(void)386 static void test_copy_ycbcrbiplanar_to_true_yuv_with_rotation_180_with_downscaling(void) {
387 test_video_processing_base(TRUE,FALSE,TRUE);
388 }
389
test_yuv_buf_copy_with_pix_strides_base(const MSVideoSize * size,bool_t src_is_semiplanar,bool_t dst_is_semiplanar,bool_t test_sliding)390 static void test_yuv_buf_copy_with_pix_strides_base(const MSVideoSize *size, bool_t src_is_semiplanar, bool_t dst_is_semiplanar, bool_t test_sliding) {
391 const int rpadding = 16, bpadding = 16;
392 MSVideoSize buffer_size = { size->width+rpadding, size->height+bpadding };
393 MSRect roi1 = { 0, 0, size->width, size->height };
394 MSRect roi2 = roi1;
395 uint8_t *buf1 = generate_picture(&buffer_size, &roi1, src_is_semiplanar);
396 uint8_t *buf2 = ms_new0(uint8_t, buffer_size.width * buffer_size.height * 3 / 2);
397 uint8_t *src_planes[3], *dst_planes[3];
398 int src_row_strides[3], dst_row_strides[3];
399 int src_pix_strides[3], dst_pix_strides[3];
400
401 if(test_sliding) {
402 roi2.x = rpadding;
403 roi2.y = bpadding;
404 }
405
406 if(!src_is_semiplanar) {
407 src_planes[0] = buf1;
408 src_planes[1] = src_planes[0] + (buffer_size.width*buffer_size.height);
409 src_planes[2] = src_planes[1] + (buffer_size.width*buffer_size.height)/4;
410 src_row_strides[0] = buffer_size.width;
411 src_row_strides[1] = buffer_size.width/2;
412 src_row_strides[2] = buffer_size.width/2;
413 src_pix_strides[0] = 1;
414 src_pix_strides[1] = 1;
415 src_pix_strides[2] = 1;
416 } else {
417 src_planes[0] = buf1;
418 src_planes[1] = src_planes[0] + (buffer_size.width*buffer_size.height);
419 src_planes[2] = src_planes[1] + 1;
420 src_row_strides[0] = buffer_size.width;
421 src_row_strides[1] = buffer_size.width;
422 src_row_strides[2] = buffer_size.width;
423 src_pix_strides[0] = 1;
424 src_pix_strides[1] = 2;
425 src_pix_strides[2] = 2;
426 }
427
428 if(!dst_is_semiplanar) {
429 dst_planes[0] = buf2;
430 dst_planes[1] = dst_planes[0] + (buffer_size.width*buffer_size.height);
431 dst_planes[2] = dst_planes[1] + (buffer_size.width*buffer_size.height)/4;
432 dst_row_strides[0] = buffer_size.width;
433 dst_row_strides[1] = buffer_size.width/2;
434 dst_row_strides[2] = buffer_size.width/2;
435 dst_pix_strides[0] = 1;
436 dst_pix_strides[1] = 1;
437 dst_pix_strides[2] = 1;
438 } else {
439 dst_planes[0] = buf2;
440 dst_planes[1] = dst_planes[0] + (buffer_size.width*buffer_size.height);
441 dst_planes[2] = dst_planes[1] + 1;
442 dst_row_strides[0] = buffer_size.width;
443 dst_row_strides[1] = buffer_size.width;
444 dst_row_strides[2] = buffer_size.width;
445 dst_pix_strides[0] = 1;
446 dst_pix_strides[1] = 2;
447 dst_pix_strides[2] = 2;
448 }
449
450 BC_ASSERT(check_picture(&buffer_size, &roi1, src_is_semiplanar, buf1));
451 ms_yuv_buf_copy_with_pix_strides(src_planes, src_row_strides, src_pix_strides, roi1, dst_planes, dst_row_strides, dst_pix_strides, roi2);
452 BC_ASSERT(check_picture(&buffer_size, &roi2, dst_is_semiplanar, buf2));
453
454 ms_free(buf1);
455 ms_free(buf2);
456 }
457
test_yuv_copy_with_pix_strides_planar_to_planar(void)458 void test_yuv_copy_with_pix_strides_planar_to_planar(void) {
459 MSVideoSize size = MS_VIDEO_SIZE_VGA;
460 test_yuv_buf_copy_with_pix_strides_base(&size, FALSE, FALSE, FALSE);
461 }
462
test_yuv_copy_with_pix_strides_planar_to_semi_planar(void)463 void test_yuv_copy_with_pix_strides_planar_to_semi_planar(void) {
464 MSVideoSize size = MS_VIDEO_SIZE_VGA;
465 test_yuv_buf_copy_with_pix_strides_base(&size, FALSE, TRUE, FALSE);
466 }
467
test_yuv_copy_with_pix_strides_semi_planar_to_planar(void)468 void test_yuv_copy_with_pix_strides_semi_planar_to_planar(void) {
469 MSVideoSize size = MS_VIDEO_SIZE_VGA;
470 test_yuv_buf_copy_with_pix_strides_base(&size, TRUE, FALSE, FALSE);
471 }
472
test_yuv_copy_with_pix_strides_semi_planar_to_semi_planar(void)473 void test_yuv_copy_with_pix_strides_semi_planar_to_semi_planar(void) {
474 MSVideoSize size = MS_VIDEO_SIZE_VGA;
475 test_yuv_buf_copy_with_pix_strides_base(&size, TRUE, TRUE, FALSE);
476 }
477
test_yuv_copy_with_pix_strides_planar_to_planar_with_sliding(void)478 void test_yuv_copy_with_pix_strides_planar_to_planar_with_sliding(void) {
479 MSVideoSize size = MS_VIDEO_SIZE_VGA;
480 test_yuv_buf_copy_with_pix_strides_base(&size, FALSE, FALSE, TRUE);
481 }
482
test_yuv_copy_with_pix_strides_planar_to_semi_planar_with_sliding(void)483 void test_yuv_copy_with_pix_strides_planar_to_semi_planar_with_sliding(void) {
484 MSVideoSize size = MS_VIDEO_SIZE_VGA;
485 test_yuv_buf_copy_with_pix_strides_base(&size, FALSE, TRUE, TRUE);
486 }
487
test_yuv_copy_with_pix_strides_semi_planar_to_planar_with_sliding(void)488 void test_yuv_copy_with_pix_strides_semi_planar_to_planar_with_sliding(void) {
489 MSVideoSize size = MS_VIDEO_SIZE_VGA;
490 test_yuv_buf_copy_with_pix_strides_base(&size, TRUE, FALSE, TRUE);
491 }
492
test_yuv_copy_with_pix_strides_semi_planar_to_semi_planar_with_sliding(void)493 void test_yuv_copy_with_pix_strides_semi_planar_to_semi_planar_with_sliding(void) {
494 MSVideoSize size = MS_VIDEO_SIZE_VGA;
495 test_yuv_buf_copy_with_pix_strides_base(&size, TRUE, TRUE, TRUE);
496 }
497
498 #endif
499
test_is_multicast(void)500 static void test_is_multicast(void) {
501
502 BC_ASSERT_TRUE(ms_is_multicast("224.1.2.3"));
503 BC_ASSERT_TRUE(ms_is_multicast("239.0.0.0"));
504 BC_ASSERT_TRUE(ms_is_multicast("ff02::3:2"));
505 BC_ASSERT_FALSE(ms_is_multicast("192.68.0.1"));
506 BC_ASSERT_FALSE(ms_is_multicast("::1"));
507
508 }
509
test_filterdesc_enable_disable_base(const char * mime,const char * filtername,bool_t is_enc)510 static void test_filterdesc_enable_disable_base(const char* mime, const char* filtername,bool_t is_enc) {
511 MSFilter *filter;
512
513 MSFactory *factory = NULL;
514 factory = ms_factory_new_with_voip();
515
516 if (is_enc)
517 filter = ms_factory_create_encoder(factory,mime);
518 else
519 filter = ms_factory_create_decoder(factory,mime);
520
521 BC_ASSERT_PTR_NOT_NULL(filter);
522 ms_filter_destroy(filter);
523
524 BC_ASSERT_FALSE(ms_factory_enable_filter_from_name(factory,filtername,FALSE));
525 BC_ASSERT_FALSE(ms_factory_filter_from_name_enabled(factory,filtername));
526 if (is_enc)
527 filter = ms_factory_create_encoder(factory,mime);
528 else
529 filter = ms_factory_create_decoder(factory,mime);
530 BC_ASSERT_PTR_NULL(filter);
531
532 BC_ASSERT_FALSE(ms_factory_enable_filter_from_name(factory,filtername,TRUE));
533 BC_ASSERT_TRUE(ms_factory_filter_from_name_enabled(factory,filtername));
534 if (is_enc)
535 filter = ms_factory_create_encoder(factory,mime);
536 else
537 filter = ms_factory_create_decoder(factory,mime);
538 BC_ASSERT_PTR_NOT_NULL(filter);
539
540 ms_filter_destroy(filter);
541
542 ms_factory_destroy(factory);
543 }
test_filterdesc_enable_disable(void)544 static void test_filterdesc_enable_disable(void) {
545 test_filterdesc_enable_disable_base("pcmu", "MSUlawDec", FALSE);
546 test_filterdesc_enable_disable_base("pcma", "MSAlawEnc", TRUE);
547 }
548 static test_t tests[] = {
549 TEST_NO_TAG("Multiple ms_voip_init", filter_register_tester),
550 TEST_NO_TAG("Is multicast", test_is_multicast),
551 TEST_NO_TAG("FilterDesc enabling/disabling", test_filterdesc_enable_disable),
552 #ifdef VIDEO_ENABLED
553 TEST_NO_TAG("Video processing function", test_video_processing),
554 TEST_NO_TAG("Copy ycbcrbiplanar to true yuv with downscaling", test_copy_ycbcrbiplanar_to_true_yuv_with_downscaling),
555 TEST_NO_TAG("Copy ycbcrbiplanar to true yuv with rotation clock wise",test_copy_ycbcrbiplanar_to_true_yuv_with_rotation_clock_wise),
556 TEST_NO_TAG("Copy ycbcrbiplanar to true yuv with rotation clock wise with downscaling",test_copy_ycbcrbiplanar_to_true_yuv_with_rotation_clock_wise_with_downscaling),
557 TEST_NO_TAG("Copy ycbcrbiplanar to true yuv with rotation 180", test_copy_ycbcrbiplanar_to_true_yuv_with_rotation_180),
558 TEST_NO_TAG("Copy ycbcrbiplanar to true yuv with rotation 180 with downscaling", test_copy_ycbcrbiplanar_to_true_yuv_with_rotation_180_with_downscaling),
559 TEST_NO_TAG("Copy yuv buffer with pixel strides: planar to planar",test_yuv_copy_with_pix_strides_planar_to_planar),
560 TEST_NO_TAG("Copy yuv buffer with pixel strides: planar to semi-planar",test_yuv_copy_with_pix_strides_planar_to_semi_planar),
561 TEST_NO_TAG("Copy yuv buffer with pixel strides: semi-planar to planar",test_yuv_copy_with_pix_strides_semi_planar_to_planar),
562 TEST_NO_TAG("Copy yuv buffer with pixel strides: semi-planar to semi-planar",test_yuv_copy_with_pix_strides_semi_planar_to_semi_planar),
563 TEST_NO_TAG("Copy yuv buffer with pixel strides: planar to planar with sliding",test_yuv_copy_with_pix_strides_planar_to_planar_with_sliding),
564 TEST_NO_TAG("Copy yuv buffer with pixel strides: planar to semi-planar with sliding",test_yuv_copy_with_pix_strides_planar_to_semi_planar_with_sliding),
565 TEST_NO_TAG("Copy yuv buffer with pixel strides: semi-planar to planar with sliding",test_yuv_copy_with_pix_strides_semi_planar_to_planar_with_sliding),
566 TEST_NO_TAG("Copy yuv buffer with pixel strides: semi-planar to semi-planar with sliding",test_yuv_copy_with_pix_strides_semi_planar_to_semi_planar_with_sliding)
567 #endif
568 };
569
570 test_suite_t framework_test_suite = {
571 "Framework",
572 tester_before_all,
573 tester_after_all,
574 NULL,
575 NULL,
576 sizeof(tests) / sizeof(tests[0]),
577 tests
578 };
579