1 /* GStreamer unit tests for libgstpbutils
3 * Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
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.
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.
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.
25 #include <gst/check/gstcheck.h>
26 #include <gst/pbutils/pbutils.h>
27 #include <gst/base/gstbitwriter.h>
30 #include <glib/gstdio.h>
31 #include <glib/gprintf.h>
33 #ifdef HAVE_SYS_TYPES_H
34 #include <sys/types.h> /* for chmod() and getpid () */
37 #ifdef HAVE_SYS_STAT_H
38 #include <sys/stat.h> /* for chmod() */
42 #include <unistd.h> /* for getpid() */
46 missing_msg_check_getters (GstMessage * msg)
50 str = gst_missing_plugin_message_get_installer_detail (msg);
51 fail_unless (str != NULL);
52 fail_unless (*str != '\0');
53 fail_unless (g_str_has_prefix (str, "gstreamer|"));
56 str = gst_missing_plugin_message_get_description (msg);
57 fail_unless (str != NULL);
58 fail_unless (*str != '\0');
62 GST_START_TEST (test_pb_utils_post_missing_messages)
64 const GstStructure *s;
72 pipeline = gst_pipeline_new ("pipeline");
73 bus = gst_element_get_bus (pipeline);
75 /* first, test common assertion failure cases */
76 ASSERT_CRITICAL (msg = gst_missing_uri_source_message_new (NULL, "http"));
77 ASSERT_CRITICAL (gst_missing_uri_source_message_new (pipeline, NULL));
79 ASSERT_CRITICAL (gst_missing_uri_sink_message_new (NULL, "http"));
80 ASSERT_CRITICAL (gst_missing_uri_sink_message_new (pipeline, NULL));
82 ASSERT_CRITICAL (gst_missing_element_message_new (NULL, "rgbfyltr"));
83 ASSERT_CRITICAL (gst_missing_element_message_new (pipeline, NULL));
85 caps = gst_caps_new_empty_simple ("audio/x-dontexist");
87 ASSERT_CRITICAL (gst_missing_decoder_message_new (NULL, caps));
88 ASSERT_CRITICAL (gst_missing_decoder_message_new (pipeline, NULL));
90 ASSERT_CRITICAL (gst_missing_encoder_message_new (NULL, caps));
91 ASSERT_CRITICAL (gst_missing_encoder_message_new (pipeline, NULL));
93 gst_caps_unref (caps);
95 /* URI source (with existing protocol) */
96 msg = gst_missing_uri_source_message_new (pipeline, "http");
97 fail_unless (msg != NULL);
98 fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ELEMENT);
99 fail_unless (gst_message_get_structure (msg) != NULL);
100 s = gst_message_get_structure (msg);
101 fail_unless (gst_structure_has_name (s, "missing-plugin"));
102 fail_unless (gst_structure_has_field_typed (s, "type", G_TYPE_STRING));
103 fail_unless_equals_string (gst_structure_get_string (s, "type"), "urisource");
104 fail_unless (gst_structure_has_field_typed (s, "detail", G_TYPE_STRING));
105 fail_unless_equals_string (gst_structure_get_string (s, "detail"), "http");
106 missing_msg_check_getters (msg);
107 gst_message_unref (msg);
109 /* URI sink (with existing protocol) */
110 msg = gst_missing_uri_sink_message_new (pipeline, "smb");
111 fail_unless (msg != NULL);
112 fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ELEMENT);
113 fail_unless (gst_message_get_structure (msg) != NULL);
114 s = gst_message_get_structure (msg);
115 fail_unless (gst_structure_has_name (s, "missing-plugin"));
116 fail_unless (gst_structure_has_field_typed (s, "type", G_TYPE_STRING));
117 fail_unless_equals_string (gst_structure_get_string (s, "type"), "urisink");
118 fail_unless (gst_structure_has_field_typed (s, "detail", G_TYPE_STRING));
119 fail_unless_equals_string (gst_structure_get_string (s, "detail"), "smb");
120 missing_msg_check_getters (msg);
121 gst_message_unref (msg);
123 /* URI source (with bogus protocol) */
124 msg = gst_missing_uri_source_message_new (pipeline, "chchck");
125 fail_unless (msg != NULL);
126 fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ELEMENT);
127 fail_unless (gst_message_get_structure (msg) != NULL);
128 s = gst_message_get_structure (msg);
129 fail_unless (gst_structure_has_name (s, "missing-plugin"));
130 fail_unless (gst_structure_has_field_typed (s, "type", G_TYPE_STRING));
131 fail_unless_equals_string (gst_structure_get_string (s, "type"), "urisource");
132 fail_unless (gst_structure_has_field_typed (s, "detail", G_TYPE_STRING));
133 fail_unless_equals_string (gst_structure_get_string (s, "detail"), "chchck");
134 missing_msg_check_getters (msg);
135 gst_message_unref (msg);
137 /* URI sink (with bogus protocol) */
138 msg = gst_missing_uri_sink_message_new (pipeline, "chchck");
139 fail_unless (msg != NULL);
140 fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ELEMENT);
141 fail_unless (gst_message_get_structure (msg) != NULL);
142 s = gst_message_get_structure (msg);
143 fail_unless (gst_structure_has_name (s, "missing-plugin"));
144 fail_unless (gst_structure_has_field_typed (s, "type", G_TYPE_STRING));
145 fail_unless_equals_string (gst_structure_get_string (s, "type"), "urisink");
146 fail_unless (gst_structure_has_field_typed (s, "detail", G_TYPE_STRING));
147 fail_unless_equals_string (gst_structure_get_string (s, "detail"), "chchck");
148 missing_msg_check_getters (msg);
149 gst_message_unref (msg);
152 msg = gst_missing_element_message_new (pipeline, "foobar");
153 fail_unless (msg != NULL);
154 fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ELEMENT);
155 fail_unless (gst_message_get_structure (msg) != NULL);
156 s = gst_message_get_structure (msg);
157 fail_unless (gst_structure_has_name (s, "missing-plugin"));
158 fail_unless (gst_structure_has_field_typed (s, "type", G_TYPE_STRING));
159 fail_unless_equals_string (gst_structure_get_string (s, "type"), "element");
160 fail_unless (gst_structure_has_field_typed (s, "detail", G_TYPE_STRING));
161 fail_unless_equals_string (gst_structure_get_string (s, "detail"), "foobar");
162 missing_msg_check_getters (msg);
163 gst_message_unref (msg);
165 /* create bogus caps that don't exist */
166 caps = gst_caps_new_simple ("do/x-not", "exist", G_TYPE_BOOLEAN, FALSE, NULL);
168 /* decoder (with unknown caps) */
169 msg = gst_missing_decoder_message_new (pipeline, caps);
170 fail_unless (msg != NULL);
171 fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ELEMENT);
172 fail_unless (gst_message_get_structure (msg) != NULL);
173 s = gst_message_get_structure (msg);
174 fail_unless (gst_structure_has_name (s, "missing-plugin"));
175 fail_unless (gst_structure_has_field_typed (s, "type", G_TYPE_STRING));
176 fail_unless_equals_string (gst_structure_get_string (s, "type"), "decoder");
177 fail_unless (gst_structure_has_field_typed (s, "detail", GST_TYPE_CAPS));
178 missing_msg_check_getters (msg);
179 gst_message_unref (msg);
181 /* encoder (with unknown caps) */
182 msg = gst_missing_encoder_message_new (pipeline, caps);
183 fail_unless (msg != NULL);
184 fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ELEMENT);
185 fail_unless (gst_message_get_structure (msg) != NULL);
186 s = gst_message_get_structure (msg);
187 fail_unless (gst_structure_has_name (s, "missing-plugin"));
188 fail_unless (gst_structure_has_field_typed (s, "type", G_TYPE_STRING));
189 fail_unless_equals_string (gst_structure_get_string (s, "type"), "encoder");
190 fail_unless (gst_structure_has_field_typed (s, "detail", GST_TYPE_CAPS));
191 missing_msg_check_getters (msg);
192 gst_message_unref (msg);
194 gst_caps_unref (caps);
196 /* create caps that exist */
197 caps = gst_caps_new_empty_simple ("video/x-matroska");
198 /* decoder (with known caps) */
199 msg = gst_missing_decoder_message_new (pipeline, caps);
200 fail_unless (msg != NULL);
201 fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ELEMENT);
202 fail_unless (gst_message_get_structure (msg) != NULL);
203 s = gst_message_get_structure (msg);
204 fail_unless (gst_structure_has_name (s, "missing-plugin"));
205 fail_unless (gst_structure_has_field_typed (s, "type", G_TYPE_STRING));
206 fail_unless_equals_string (gst_structure_get_string (s, "type"), "decoder");
207 fail_unless (gst_structure_has_field_typed (s, "detail", GST_TYPE_CAPS));
208 fail_unless (gst_structure_has_field_typed (s, "name", G_TYPE_STRING));
209 fail_unless (gst_structure_get_string (s, "name") != NULL);
210 missing_msg_check_getters (msg);
211 gst_message_unref (msg);
213 /* encoder (with known caps) */
214 msg = gst_missing_encoder_message_new (pipeline, caps);
215 fail_unless (msg != NULL);
216 fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ELEMENT);
217 fail_unless (gst_message_get_structure (msg) != NULL);
218 s = gst_message_get_structure (msg);
219 fail_unless (gst_structure_has_name (s, "missing-plugin"));
220 fail_unless (gst_structure_has_field_typed (s, "type", G_TYPE_STRING));
221 fail_unless_equals_string (gst_structure_get_string (s, "type"), "encoder");
222 fail_unless (gst_structure_has_field_typed (s, "detail", GST_TYPE_CAPS));
223 fail_unless (gst_structure_has_field_typed (s, "name", G_TYPE_STRING));
224 fail_unless (gst_structure_get_string (s, "name") != NULL);
225 missing_msg_check_getters (msg);
226 gst_message_unref (msg);
228 gst_caps_unref (caps);
230 gst_element_set_state (pipeline, GST_STATE_NULL);
231 gst_object_unref (pipeline);
232 gst_object_unref (bus);
237 GST_START_TEST (test_pb_utils_init)
239 /* should be fine to call multiple times */
240 gst_pb_utils_init ();
241 gst_pb_utils_init ();
242 gst_pb_utils_init ();
243 gst_pb_utils_init ();
248 #define F_AUDIO GST_PBUTILS_CAPS_DESCRIPTION_FLAG_AUDIO
249 #define F_VIDEO GST_PBUTILS_CAPS_DESCRIPTION_FLAG_VIDEO
250 #define F_SUB GST_PBUTILS_CAPS_DESCRIPTION_FLAG_SUBTITLE
251 #define F_IMAGE GST_PBUTILS_CAPS_DESCRIPTION_FLAG_IMAGE
252 #define F_AV (F_AUDIO | F_VIDEO)
253 #define F_AVS (F_AUDIO | F_VIDEO | F_SUB)
254 #define F_AVSI (F_AUDIO | F_VIDEO | F_SUB | F_IMAGE)
255 #define F_CONTAINER GST_PBUTILS_CAPS_DESCRIPTION_FLAG_CONTAINER
256 #define F_AV_CONTAINER (F_CONTAINER | F_AV)
257 #define F_AVS_CONTAINER (F_CONTAINER | F_AVS)
258 #define F_AVSI_CONTAINER (F_CONTAINER | F_AVSI)
259 #define F_META GST_PBUTILS_CAPS_DESCRIPTION_FLAG_METADATA
260 #define F_TAG GST_PBUTILS_CAPS_DESCRIPTION_FLAG_TAG
263 static const struct FlagDescEntry
265 const gchar *caps_string;
266 GstPbUtilsCapsDescriptionFlags flags;
268 {"application/x-binary", 0},
269 {"audio/x-wav", F_AUDIO | F_CONTAINER},
270 {"video/quicktime", F_AVSI_CONTAINER},
271 {"video/x-flv", F_AV_CONTAINER},
272 {"video/x-h264", F_VIDEO},
273 {"audio/mpeg,mpegversion=4", F_AUDIO},
274 {"image/jpeg", F_IMAGE | F_VIDEO},
275 // FIXME: {"meta/x-klv", F_META},
276 {"application/x-onvif-metadata", F_META},
277 {"random/x-nonsense, sense=false", 0},
281 GST_START_TEST (test_pb_utils_get_caps_description_flags)
285 for (i = 0; i < G_N_ELEMENTS (flag_descs); ++i) {
286 GstPbUtilsCapsDescriptionFlags flags;
287 const struct FlagDescEntry *e;
291 caps = gst_caps_from_string (e->caps_string);
292 flags = gst_pb_utils_get_caps_description_flags (caps);
293 gst_caps_unref (caps);
294 GST_DEBUG ("%s: expecting 0x%x, got 0x%x", e->caps_string, e->flags, flags);
295 fail_unless_equals_int (flags, e->flags);
301 static const gchar *caps_strings[] = {
302 /* formats with static descriptions */
303 "application/ogg", "application/vnd.rn-realmedia", "video/x-fli",
304 "video/x-flv", "video/x-matroska", "video/x-ms-asf", "video/x-msvideo",
305 "video/x-quicktime", "video/quicktime", "audio/x-ac3", "audio/ac3",
306 "audio/x-private-ac3", "audio/x-private1-ac3", "audio/x-adpcm",
307 "audio/aiff", "audio/x-alaw", "audio/amr", "audio/AMR", "audio/AMR-WB",
308 "audio/iLBC-sh", "audio/ms-gsm", "audio/qcelp", "audio/x-adpcm",
309 "audio/x-aiff", "audio/x-alac", "audio/x-amr-nb-sh", "audio/x-amr-wb-sh",
310 "audio/x-au", "audio/x-cinepak", "audio/x-dpcm", "audio/x-dts",
311 "audio/x-dv", "audio/x-flac", "audio/x-gsm", "audio/x-iec958",
312 "audio/x-iLBC", "audio/x-ircam", "audio/x-lpcm", "audio/x-private1-lpcm",
313 "audio/x-m4a", "audio/x-mod", "audio/x-mulaw", "audio/x-musepack",
314 "audio/x-nist", "audio/x-nsf", "audio/x-paris", "audio/x-qdm2",
315 "audio/x-ralf-mpeg4-generic", "audio/x-sds", "audio/x-shorten",
316 "audio/x-sid", "audio/x-sipro", "audio/x-spc", "audio/x-speex",
317 "audio/x-svx", "audio/x-tta", "audio/x-ttafile",
318 "audio/x-vnd.sony.atrac3", "audio/x-vorbis", "audio/x-voc", "audio/x-w64",
319 "audio/x-wav", "audio/x-wavpack", "audio/x-wavpack-correction",
320 "audio/x-wms", "audio/x-voxware", "audio/x-xi", "video/sp5x", "video/vivo",
321 "video/x-4xm", "video/x-apple-video", "video/x-camtasia",
322 "video/x-cdxa", "video/x-cinepak", "video/x-cirrus-logic-accupak",
323 "video/x-compressed-yuv", "subpicture/x-dvd",
324 "video/x-ffv", "video/x-flash-screen", "video/x-flash-video",
325 "video/x-h261", "video/x-huffyuv", "video/x-intel-h263", "video/x-jpeg",
326 "video/x-mjpeg", "video/x-mjpeg-b", "video/mpegts", "video/x-mng",
327 "video/x-mszh", "video/x-msvideocodec", "video/x-mve", "video/x-nut",
328 "video/x-nuv", "video/x-qdrw", "video/x-raw", "video/x-smc",
329 "video/x-smoke", "video/x-tarkin", "video/x-theora", "video/x-rle",
330 "video/x-ultimotion", "video/x-vcd", "video/x-vmnc", "video/x-vp3",
331 "video/x-vp5", "video/x-vp6", "video/x-vp6-flash", "video/x-vp7",
332 "video/x-zlib", "image/bmp", "image/x-bmp",
333 "image/x-MS-bmp", "image/gif", "image/jpeg", "image/jng", "image/png",
334 "image/pbm", "image/ppm", "image/svg+xml", "image/tiff",
335 "image/x-cmu-raster", "image/x-icon", "image/x-xcf", "image/x-pixmap",
336 "image/x-xpixmap", "image/x-quicktime", "image/x-sun-raster",
337 "image/x-tga", "video/x-dv", "video/x-dv",
338 /* some RTP formats */
339 "application/x-rtp, media=(string)video, encoding-name=(string)TimVCodec",
340 "application/x-rtp, media=(string)audio, encoding-name=(string)TimACodec",
341 "application/x-rtp, media=(string)application, encoding-name=(string)TimMux",
342 "application/x-rtp, media=(string)woohoo, encoding-name=(string)TPM",
343 /* incomplete RTP formats */
344 "application/x-rtp, media=(string)woohoo",
345 "application/x-rtp, encoding-name=(string)TPM",
346 "application/x-rtp, media=(string)woohoo",
347 /* formats with dynamic descriptions */
349 "audio/x-adpcm, layout=(string)dvi",
350 "audio/x-adpcm, layout=(string)swf",
351 "audio/x-adpcm, layout=(string)microsoft",
352 "audio/x-adpcm, layout=(string)quicktime",
353 "audio/mpeg, mpegversion=(int)4",
354 "audio/mpeg, mpegversion=(int)1, layer=(int)1",
355 "audio/mpeg, mpegversion=(int)1, layer=(int)2",
356 "audio/mpeg, mpegversion=(int)1, layer=(int)3",
357 "audio/mpeg, mpegversion=(int)1, layer=(int)99",
358 "audio/mpeg, mpegversion=(int)99",
359 "video/mpeg, mpegversion=(int)2, systemstream=(boolean)TRUE",
360 "video/mpeg, systemstream=(boolean)FALSE",
361 "video/mpeg, mpegversion=(int)2",
362 "video/mpeg, mpegversion=(int)1, systemstream=(boolean)FALSE",
363 "video/mpeg, mpegversion=(int)2, systemstream=(boolean)FALSE",
364 "video/mpeg, mpegversion=(int)4, systemstream=(boolean)FALSE",
365 "video/mpeg, mpegversion=(int)99, systemstream=(boolean)TRUE",
366 "video/mpeg, mpegversion=(int)99, systemstream=(boolean)FALSE",
367 "video/mpeg, mpegversion=(int)4, systemstream=(boolean)FALSE, profile=main",
368 "video/mpeg, mpegversion=(int)4, systemstream=(boolean)FALSE, profile=adsfad",
370 "video/x-indeo, indeoversion=(int)3",
371 "video/x-indeo, indeoversion=(int)5",
373 "video/x-wmv, wmvversion=(int)1",
374 "video/x-wmv, wmvversion=(int)2",
375 "video/x-wmv, wmvversion=(int)3",
376 "video/x-wmv, wmvversion=(int)99",
378 "audio/x-wma, wmaversion=(int)1",
379 "audio/x-wma, wmaversion=(int)2",
380 "audio/x-wma, wmaversion=(int)3",
381 "audio/x-wma, wmaversion=(int)99",
384 "video/x-dirac, profile=(string)vc2-low-delay",
385 "video/x-dirac, profile=(string)vc2-simple",
386 "video/x-dirac, profile=(string)vc2-main",
387 "video/x-dirac, profile=(string)main",
388 "video/x-dirac, profile=(string)czvja",
389 "video/x-divx, divxversion=(int)3",
390 "video/x-divx, divxversion=(int)4",
391 "video/x-divx, divxversion=(int)5",
392 "video/x-divx, divxversion=(int)99",
394 "video/x-svq, svqversion=(int)1",
395 "video/x-svq, svqversion=(int)3",
396 "video/x-svq, svqversion=(int)99",
398 "video/x-h265, profile=(string)main",
399 "video/x-h265, profile=(string)xafasdf",
401 "video/x-h264, variant=(string)itu",
402 "video/x-h264, variant=(string)videosoft",
403 "video/x-h264, variant=(string)foobar",
405 "video/x-h264, profile=(string)foobar",
406 "video/x-h264, profile=(string)high-4:4:4-intra",
407 "video/x-h264, profile=(string)high",
408 "video/x-h263, variant=(string)itu",
409 "video/x-h263, variant=(string)lead",
410 "video/x-h263, variant=(string)microsoft",
411 "video/x-h263, variant=(string)vdolive",
412 "video/x-h263, variant=(string)vivo",
413 "video/x-h263, variant=(string)xirlink",
414 "video/x-h263, variant=(string)foobar",
416 "video/x-msmpeg, msmpegversion=(int)41",
417 "video/x-msmpeg, msmpegversion=(int)42",
418 "video/x-msmpeg, msmpegversion=(int)43",
419 "video/x-msmpeg, msmpegversion=(int)99",
421 "video/x-pn-realvideo, rmversion=(int)1",
422 "video/x-pn-realvideo, rmversion=(int)2",
423 "video/x-pn-realvideo, rmversion=(int)3",
424 "video/x-pn-realvideo, rmversion=(int)4",
425 "video/x-pn-realvideo, rmversion=(int)99",
426 "video/x-pn-realvideo",
427 "audio/x-pn-realaudio, raversion=(int)1",
428 "audio/x-pn-realaudio, raversion=(int)2",
429 "audio/x-pn-realaudio, raversion=(int)99",
430 "audio/x-pn-realaudio",
431 "audio/x-mace, maceversion=(int)3",
432 "audio/x-mace, maceversion=(int)6",
433 "audio/x-mace, maceversion=(int)99",
435 "video/x-truemotion, trueversion=(int)1",
436 "video/x-truemotion, trueversion=(int)2",
437 "video/x-truemotion, trueversion=(int)99",
438 "video/x-truemotion",
439 "video/x-asus, asusversion=(int)1",
440 "video/x-asus, asusversion=(int)2",
441 "video/x-asus, asusversion=(int)99",
443 "video/x-xan, wcversion=(int)1",
444 "video/x-xan, wcversion=(int)99",
446 "video/x-ati-vcr, vcrversion=(int)1",
447 "video/x-ati-vcr, vcrversion=(int)2",
448 "video/x-ati-vcr, vcrversion=(int)99",
451 "audio/x-raw, format=(string)S16LE, rate=(int)44100, channels=(int)2",
452 "audio/x-raw, format=(string)F32,rate=(int)22050, channels=(int)2",
454 "video/x-raw, format=(string)RGB16, width=(int)320, height=(int)240, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1",
455 "video/x-raw, format=(string)YUY2, width=(int)320, height=(int)240, framerate=(fraction)30/1",
456 /* and a made-up format */
460 GST_START_TEST (test_pb_utils_get_codec_description)
464 gst_pb_utils_init ();
466 for (i = 0; i < G_N_ELEMENTS (caps_strings); ++i) {
470 caps = gst_caps_from_string (caps_strings[i]);
471 fail_unless (caps != NULL, "could not create caps from string '%s'",
473 GST_LOG ("Caps %s:", caps_strings[i]);
474 desc = gst_pb_utils_get_codec_description (caps);
475 fail_unless (desc != NULL);
476 GST_LOG (" - codec : %s", desc);
477 fail_unless (g_utf8_validate (desc, -1, NULL));
479 desc = gst_pb_utils_get_decoder_description (caps);
480 fail_unless (desc != NULL);
481 GST_LOG (" - decoder : %s", desc);
482 fail_unless (g_utf8_validate (desc, -1, NULL));
484 desc = gst_pb_utils_get_encoder_description (caps);
485 fail_unless (desc != NULL);
486 GST_LOG (" - encoder : %s", desc);
487 fail_unless (g_utf8_validate (desc, -1, NULL));
489 gst_caps_unref (caps);
496 GST_START_TEST (test_pb_utils_taglist_add_codec_info)
499 GstCaps *caps, *bogus_caps;
502 gst_pb_utils_init ();
503 list = gst_tag_list_new_empty ();
504 caps = gst_caps_new_empty_simple ("video/x-theora");
505 ASSERT_CRITICAL (fail_if
506 (gst_pb_utils_add_codec_description_to_tag_list (NULL,
507 GST_TAG_VIDEO_CODEC, caps)));
508 ASSERT_CRITICAL (fail_if
509 (gst_pb_utils_add_codec_description_to_tag_list (list, "asdfa", caps)));
510 ASSERT_CRITICAL (fail_if
511 (gst_pb_utils_add_codec_description_to_tag_list (list,
512 GST_TAG_IMAGE, caps)));
513 ASSERT_CRITICAL (fail_if
514 (gst_pb_utils_add_codec_description_to_tag_list (list,
515 GST_TAG_VIDEO_CODEC, NULL)));
517 /* Try adding bogus caps (should fail) */
518 bogus_caps = gst_caps_new_empty_simple ("bogus/format");
519 fail_if (gst_pb_utils_add_codec_description_to_tag_list (list,
520 GST_TAG_VIDEO_CODEC, bogus_caps));
521 gst_caps_unref (bogus_caps);
523 /* Try adding valid caps with known tag */
524 fail_unless (gst_pb_utils_add_codec_description_to_tag_list (list,
525 GST_TAG_VIDEO_CODEC, caps));
526 fail_if (gst_tag_list_is_empty (list));
527 fail_unless (gst_tag_list_get_string (list, GST_TAG_VIDEO_CODEC, &res));
529 gst_tag_list_unref (list);
531 /* Try adding valid caps with auto-tag (for video, audio, subtitle, generic) */
532 list = gst_tag_list_new_empty ();
533 fail_unless (gst_pb_utils_add_codec_description_to_tag_list (list, NULL,
535 fail_if (gst_tag_list_is_empty (list));
536 fail_unless (gst_tag_list_get_string (list, GST_TAG_VIDEO_CODEC, &res));
538 gst_tag_list_unref (list);
539 gst_caps_unref (caps);
541 list = gst_tag_list_new_empty ();
542 caps = gst_caps_new_empty_simple ("audio/x-vorbis");
543 fail_unless (gst_pb_utils_add_codec_description_to_tag_list (list, NULL,
545 fail_if (gst_tag_list_is_empty (list));
546 fail_unless (gst_tag_list_get_string (list, GST_TAG_AUDIO_CODEC, &res));
548 gst_tag_list_unref (list);
549 gst_caps_unref (caps);
551 list = gst_tag_list_new_empty ();
552 caps = gst_caps_new_empty_simple ("subtitle/x-kate");
553 fail_unless (gst_pb_utils_add_codec_description_to_tag_list (list, NULL,
555 fail_if (gst_tag_list_is_empty (list));
556 fail_unless (gst_tag_list_get_string (list, GST_TAG_SUBTITLE_CODEC, &res));
558 gst_tag_list_unref (list);
559 gst_caps_unref (caps);
561 list = gst_tag_list_new_empty ();
562 caps = gst_caps_new_empty_simple ("application/ogg");
563 fail_unless (gst_pb_utils_add_codec_description_to_tag_list (list, NULL,
565 fail_if (gst_tag_list_is_empty (list));
566 fail_unless (gst_tag_list_get_string (list, GST_TAG_CONTAINER_FORMAT, &res));
568 gst_tag_list_unref (list);
569 gst_caps_unref (caps);
571 list = gst_tag_list_new_empty ();
572 caps = gst_caps_new_empty_simple ("image/bmp");
573 fail_unless (gst_pb_utils_add_codec_description_to_tag_list (list, NULL,
575 fail_if (gst_tag_list_is_empty (list));
576 fail_unless (gst_tag_list_get_string (list, GST_TAG_CODEC, &res));
578 gst_tag_list_unref (list);
579 gst_caps_unref (caps);
587 result_cb (GstInstallPluginsReturn result, gpointer user_data)
589 GST_LOG ("result = %u, user_data = %p", result, user_data);
591 fail_unless (user_data == (gpointer) & marker);
596 #define SCRIPT_NO_XID \
598 "if test x$1 != xdetail1; then exit 21; fi;\n" \
599 "if test x$2 != xdetail2; then exit 22; fi;\n" \
602 #define SCRIPT_WITH_XID \
604 "if test x$1 != 'x--transient-for=42'; then exit 21; fi;\n" \
605 "if test x$2 != xdetail1; then exit 22; fi;\n" \
606 "if test x$3 != xdetail2; then exit 23; fi;\n" \
609 /* make sure our script gets called with the right parameters */
611 test_pb_utils_install_plugins_do_callout (const gchar * const *details,
612 GstInstallPluginsContext * ctx, const gchar * script,
613 GstInstallPluginsReturn expected_result)
616 GstInstallPluginsReturn ret;
620 path = g_strdup_printf ("%s/gst-plugins-base-unit-test-helper.%s.%lu",
621 g_get_tmp_dir (), (g_get_user_name ())? g_get_user_name () : "nobody",
624 if (!g_file_set_contents (path, script, -1, &err)) {
625 GST_DEBUG ("Failed to write test script to %s: %s", path, err->message);
630 if (chmod (path, S_IRUSR | S_IWUSR | S_IXUSR) != 0) {
631 GST_DEBUG ("Could not set mode u+rwx on '%s'", path);
635 /* test gst_install_plugins_supported() I */
636 g_setenv ("GST_INSTALL_PLUGINS_HELPER", "/i/do/not/ex.ist!", 1);
637 fail_if (gst_install_plugins_supported ());
639 GST_LOG ("setting GST_INSTALL_PLUGINS_HELPER to '%s'", path);
640 g_setenv ("GST_INSTALL_PLUGINS_HELPER", path, 1);
642 /* test gst_install_plugins_supported() II */
643 fail_unless (gst_install_plugins_supported ());
645 /* test sync callout */
646 ret = gst_install_plugins_sync (details, ctx);
647 fail_unless (ret == GST_INSTALL_PLUGINS_HELPER_MISSING ||
648 ret == expected_result,
649 "gst_install_plugins_sync() failed with unexpected ret %d, which is "
650 "neither HELPER_MISSING nor %d", ret, expected_result);
652 /* test async callout */
654 ret = gst_install_plugins_async (details, ctx, result_cb,
655 (gpointer) & marker);
656 fail_unless (ret == GST_INSTALL_PLUGINS_HELPER_MISSING ||
657 ret == GST_INSTALL_PLUGINS_STARTED_OK,
658 "gst_install_plugins_async() failed with unexpected ret %d", ret);
659 if (ret == GST_INSTALL_PLUGINS_STARTED_OK) {
660 while (marker == -333) {
662 g_main_context_iteration (NULL, FALSE);
664 /* and check that the callback was called with the expected code */
665 fail_unless_equals_int (marker, expected_result);
672 #endif /* G_OS_UNIX */
675 GST_START_TEST (test_pb_utils_install_plugins)
677 GstInstallPluginsContext *ctx;
678 GstInstallPluginsReturn ret;
679 const gchar *details[] = { "detail1", "detail2", NULL };
680 const gchar *details_multi[] = { "detail1", "detail1", "detail2", NULL };
682 ctx = gst_install_plugins_context_new ();
684 ASSERT_CRITICAL (ret = gst_install_plugins_sync (NULL, ctx));
685 ASSERT_CRITICAL (ret =
686 gst_install_plugins_async (NULL, ctx, result_cb, (gpointer) & marker));
687 ASSERT_CRITICAL (ret =
688 gst_install_plugins_async (details, ctx, NULL, (gpointer) & marker));
690 /* make sure the functions return the right error code if the helper does
692 g_setenv ("GST_INSTALL_PLUGINS_HELPER", "/does/not/ex/is.t", 1);
693 ret = gst_install_plugins_sync (details, NULL);
694 fail_unless_equals_int (ret, GST_INSTALL_PLUGINS_HELPER_MISSING);
698 gst_install_plugins_async (details, NULL, result_cb, (gpointer) & marker);
699 fail_unless_equals_int (ret, GST_INSTALL_PLUGINS_HELPER_MISSING);
700 /* and check that the callback wasn't called */
701 fail_unless_equals_int (marker, -333);
703 /* now make sure our scripts are actually called as expected (if possible) */
704 test_pb_utils_install_plugins_do_callout (details, NULL, SCRIPT_NO_XID,
705 GST_INSTALL_PLUGINS_NOT_FOUND);
707 /* and again with context */
708 gst_install_plugins_context_set_xid (ctx, 42);
709 test_pb_utils_install_plugins_do_callout (details, ctx, SCRIPT_WITH_XID,
710 GST_INSTALL_PLUGINS_SUCCESS);
712 /* and make sure that duplicate detail strings get dropped */
713 test_pb_utils_install_plugins_do_callout (details_multi, NULL, SCRIPT_NO_XID,
714 GST_INSTALL_PLUGINS_NOT_FOUND);
716 /* and the same again with context */
717 gst_install_plugins_context_set_xid (ctx, 42);
718 test_pb_utils_install_plugins_do_callout (details_multi, ctx, SCRIPT_WITH_XID,
719 GST_INSTALL_PLUGINS_SUCCESS);
721 /* and free the context now that we don't need it any longer */
722 gst_install_plugins_context_free (ctx);
724 /* completely silly test to check gst_install_plugins_return_get_name()
725 * is somewhat well-behaved */
729 for (i = -99; i < 16738; ++i) {
732 s = gst_install_plugins_return_get_name ((GstInstallPluginsReturn) i);
733 fail_unless (s != NULL);
734 /* GST_LOG ("%5d = %s", i, s); */
741 GST_START_TEST (test_pb_utils_installer_details)
746 gchar *detail1, *detail2;
748 el = gst_pipeline_new ("dummy-element");
751 detail1 = gst_missing_uri_source_installer_detail_new ("http");
752 fail_unless (detail1 != NULL);
753 fail_unless (g_str_has_prefix (detail1, "gstreamer|1.0|"));
754 fail_unless (g_str_has_suffix (detail1, "|urisource-http"));
755 msg = gst_missing_uri_source_message_new (el, "http");
756 fail_unless (msg != NULL);
757 detail2 = gst_missing_plugin_message_get_installer_detail (msg);
758 fail_unless (detail2 != NULL);
759 gst_message_unref (msg);
760 fail_unless_equals_string (detail1, detail2);
765 detail1 = gst_missing_uri_sink_installer_detail_new ("http");
766 fail_unless (detail1 != NULL);
767 fail_unless (g_str_has_prefix (detail1, "gstreamer|1.0|"));
768 fail_unless (g_str_has_suffix (detail1, "|urisink-http"));
769 msg = gst_missing_uri_sink_message_new (el, "http");
770 fail_unless (msg != NULL);
771 detail2 = gst_missing_plugin_message_get_installer_detail (msg);
772 fail_unless (detail2 != NULL);
773 gst_message_unref (msg);
774 fail_unless_equals_string (detail1, detail2);
779 detail1 = gst_missing_element_installer_detail_new ("deinterlace");
780 fail_unless (detail1 != NULL);
781 fail_unless (g_str_has_prefix (detail1, "gstreamer|1.0|"));
782 fail_unless (g_str_has_suffix (detail1, "|element-deinterlace"));
783 msg = gst_missing_element_message_new (el, "deinterlace");
784 fail_unless (msg != NULL);
785 detail2 = gst_missing_plugin_message_get_installer_detail (msg);
786 fail_unless (detail2 != NULL);
787 gst_message_unref (msg);
788 fail_unless_equals_string (detail1, detail2);
793 caps = gst_caps_new_simple ("audio/x-spiffy", "spiffyversion", G_TYPE_INT,
794 2, "channels", G_TYPE_INT, 6, NULL);
795 detail1 = gst_missing_decoder_installer_detail_new (caps);
796 fail_unless (detail1 != NULL);
797 fail_unless (g_str_has_prefix (detail1, "gstreamer|1.0|"));
798 fail_unless (g_str_has_suffix (detail1,
799 "|decoder-audio/x-spiffy, spiffyversion=(int)2"));
800 msg = gst_missing_decoder_message_new (el, caps);
801 fail_unless (msg != NULL);
802 detail2 = gst_missing_plugin_message_get_installer_detail (msg);
803 fail_unless (detail2 != NULL);
804 gst_message_unref (msg);
805 gst_caps_unref (caps);
806 fail_unless_equals_string (detail1, detail2);
811 caps = gst_caps_new_simple ("audio/x-spiffy", "spiffyversion", G_TYPE_INT,
812 2, "channels", G_TYPE_INT, 6, NULL);
813 detail1 = gst_missing_encoder_installer_detail_new (caps);
814 fail_unless (g_str_has_prefix (detail1, "gstreamer|1.0|"));
815 fail_unless (g_str_has_suffix (detail1,
816 "|encoder-audio/x-spiffy, spiffyversion=(int)2"));
817 fail_unless (detail1 != NULL);
818 msg = gst_missing_encoder_message_new (el, caps);
819 fail_unless (msg != NULL);
820 detail2 = gst_missing_plugin_message_get_installer_detail (msg);
821 fail_unless (detail2 != NULL);
822 gst_message_unref (msg);
823 gst_caps_unref (caps);
824 fail_unless_equals_string (detail1, detail2);
828 gst_object_unref (el);
833 GST_START_TEST (test_pb_utils_versions)
836 guint maj, min, mic, nano;
838 gst_plugins_base_version (NULL, NULL, NULL, NULL);
839 gst_plugins_base_version (&maj, &min, &mic, &nano);
840 fail_unless_equals_int (maj, GST_PLUGINS_BASE_VERSION_MAJOR);
841 fail_unless_equals_int (min, GST_PLUGINS_BASE_VERSION_MINOR);
842 fail_unless_equals_int (mic, GST_PLUGINS_BASE_VERSION_MICRO);
843 fail_unless_equals_int (nano, GST_PLUGINS_BASE_VERSION_NANO);
845 s = gst_plugins_base_version_string ();
846 if (GST_PLUGINS_BASE_VERSION_NANO == 0) {
847 fail_if (strstr (s, "GIT") || strstr (s, "git") || strstr (s, "prerel"));
849 if (GST_PLUGINS_BASE_VERSION_NANO == 1) {
850 fail_unless (strstr (s, "GIT") || strstr (s, "git"));
852 if (GST_PLUGINS_BASE_VERSION_NANO >= 2) {
853 fail_unless (strstr (s, "Prerelease") || strstr (s, "prerelease"));
860 GST_START_TEST (test_pb_utils_aac_get_profile)
862 const guint8 aac_config[] = { 0x11, 0x90, 0x56, 0xE5, 0x00 };
863 const guint8 aac_config_sre[] = { 0x17, 0x80, 0x91, 0xA2, 0x82, 0x00 };
864 const guint8 heaac_config[] = { 0x2B, 0x11, 0x88, 0x00, 0x06, 0x01, 0x02 };
865 const gchar *profile, *level;
871 profile = gst_codec_utils_aac_get_profile (aac_config, sizeof (aac_config));
872 fail_unless (profile != NULL);
873 fail_unless_equals_string (profile, "lc");
875 level = gst_codec_utils_aac_get_level (aac_config, sizeof (aac_config));
876 fail_unless_equals_string (level, "2");
879 gst_codec_utils_aac_get_sample_rate (aac_config, sizeof (aac_config));
880 fail_unless_equals_int (sample_rate, 48000);
883 gst_codec_utils_aac_get_sample_rate (aac_config_sre,
884 sizeof (aac_config_sre));
885 fail_unless_equals_int (sample_rate, 0x12345);
888 gst_codec_utils_aac_get_profile (heaac_config, sizeof (heaac_config));
889 fail_unless (profile != NULL);
890 fail_unless_equals_string (profile, "lc");
892 level = gst_codec_utils_aac_get_level (heaac_config, sizeof (heaac_config));
893 fail_unless_equals_string (level, "2");
896 gst_codec_utils_aac_get_sample_rate (heaac_config, sizeof (heaac_config));
897 fail_unless_equals_int (sample_rate, 48000);
899 wr = gst_bit_writer_new ();
900 fail_if (wr == NULL);
901 gst_bit_writer_put_bits_uint8 (wr, 5, 5); /* object_type = 5 (SBR) */
902 gst_bit_writer_put_bits_uint8 (wr, 3, 4); /* freq_index = 3 (48KHz) */
903 gst_bit_writer_put_bits_uint8 (wr, 2, 4); /* channel_config = 2 (L&R) */
904 gst_bit_writer_put_bits_uint8 (wr, 0x0f, 4); /* freq_index extension */
905 gst_bit_writer_put_bits_uint32 (wr, 87654, 24); /* freq */
906 gst_bit_writer_put_bits_uint8 (wr, 2, 5); /* object_type = 2 (LC) */
908 buf = gst_bit_writer_get_data (wr);
909 buf_len = gst_bit_writer_get_size (wr);
910 profile = gst_codec_utils_aac_get_profile (buf, buf_len);
911 fail_unless (profile != NULL);
912 fail_unless_equals_string (profile, "lc");
913 level = gst_codec_utils_aac_get_level (buf, buf_len);
914 fail_unless (level != NULL);
915 fail_unless_equals_string (level, "5");
916 sample_rate = gst_codec_utils_aac_get_sample_rate (buf, buf_len);
917 fail_unless_equals_int (sample_rate, 87654);
918 gst_bit_writer_free (wr);
924 #define SPS_CONSTRAINT_SET_FLAG_0 1 << 7
925 #define SPS_CONSTRAINT_SET_FLAG_1 (1 << 6)
926 #define SPS_CONSTRAINT_SET_FLAG_2 (1 << 5)
927 #define SPS_CONSTRAINT_SET_FLAG_3 (1 << 4)
928 #define SPS_CONSTRAINT_SET_FLAG_4 (1 << 3)
929 #define SPS_CONSTRAINT_SET_FLAG_5 (1 << 2)
932 fill_h264_sps (guint8 * sps,
933 guint8 profile_idc, guint constraint_set_flags, guint8 level_idc)
935 memset (sps, 0x0, SPS_LEN);
937 * * Bit 0:7 - Profile indication
938 * * Bit 8 - constraint_set0_flag
939 * * Bit 9 - constraint_set1_flag
940 * * Bit 10 - constraint_set2_flag
941 * * Bit 11 - constraint_set3_flag
942 * * Bit 12 - constraint_set4_flag
943 * * Bit 13 - constraint_set5_flag
944 * * Bit 14:15 - Reserved
945 * * Bit 16:24 - Level indication
947 sps[0] = profile_idc;
948 sps[1] |= constraint_set_flags;
952 GST_START_TEST (test_pb_utils_h264_profiles)
954 guint8 sps[SPS_LEN] = { 0, };
955 const gchar *profile;
957 fill_h264_sps (sps, 66, 0, 0);
958 profile = gst_codec_utils_h264_get_profile (sps, SPS_LEN);
959 fail_unless_equals_string (profile, "baseline");
961 fill_h264_sps (sps, 66, SPS_CONSTRAINT_SET_FLAG_1, 0);
962 profile = gst_codec_utils_h264_get_profile (sps, SPS_LEN);
963 fail_unless_equals_string (profile, "constrained-baseline");
965 fill_h264_sps (sps, 77, 0, 0);
966 profile = gst_codec_utils_h264_get_profile (sps, SPS_LEN);
967 fail_unless_equals_string (profile, "main");
969 fill_h264_sps (sps, 88, 0, 0);
970 profile = gst_codec_utils_h264_get_profile (sps, SPS_LEN);
971 fail_unless_equals_string (profile, "extended");
973 fill_h264_sps (sps, 100, 0, 0);
974 profile = gst_codec_utils_h264_get_profile (sps, SPS_LEN);
975 fail_unless_equals_string (profile, "high");
977 fill_h264_sps (sps, 100,
978 SPS_CONSTRAINT_SET_FLAG_4 | SPS_CONSTRAINT_SET_FLAG_5, 0);
979 profile = gst_codec_utils_h264_get_profile (sps, SPS_LEN);
980 fail_unless_equals_string (profile, "constrained-high");
982 fill_h264_sps (sps, 100, SPS_CONSTRAINT_SET_FLAG_4, 0);
983 profile = gst_codec_utils_h264_get_profile (sps, SPS_LEN);
984 fail_unless_equals_string (profile, "progressive-high");
986 fill_h264_sps (sps, 110, 0, 0);
987 profile = gst_codec_utils_h264_get_profile (sps, SPS_LEN);
988 fail_unless_equals_string (profile, "high-10");
990 fill_h264_sps (sps, 110, SPS_CONSTRAINT_SET_FLAG_3, 0);
991 profile = gst_codec_utils_h264_get_profile (sps, SPS_LEN);
992 fail_unless_equals_string (profile, "high-10-intra");
994 fill_h264_sps (sps, 110, SPS_CONSTRAINT_SET_FLAG_4, 0);
995 profile = gst_codec_utils_h264_get_profile (sps, SPS_LEN);
996 fail_unless_equals_string (profile, "progressive-high-10");
998 fill_h264_sps (sps, 122, 0, 0);
999 profile = gst_codec_utils_h264_get_profile (sps, SPS_LEN);
1000 fail_unless_equals_string (profile, "high-4:2:2");
1002 fill_h264_sps (sps, 122, SPS_CONSTRAINT_SET_FLAG_3, 0);
1003 profile = gst_codec_utils_h264_get_profile (sps, SPS_LEN);
1004 fail_unless_equals_string (profile, "high-4:2:2-intra");
1006 fill_h264_sps (sps, 244, 0, 0);
1007 profile = gst_codec_utils_h264_get_profile (sps, SPS_LEN);
1008 fail_unless_equals_string (profile, "high-4:4:4");
1010 fill_h264_sps (sps, 244, SPS_CONSTRAINT_SET_FLAG_3, 0);
1011 profile = gst_codec_utils_h264_get_profile (sps, SPS_LEN);
1012 fail_unless_equals_string (profile, "high-4:4:4-intra");
1014 fill_h264_sps (sps, 44, 0, 0);
1015 profile = gst_codec_utils_h264_get_profile (sps, SPS_LEN);
1016 fail_unless_equals_string (profile, "cavlc-4:4:4-intra");
1018 fill_h264_sps (sps, 118, 0, 0);
1019 profile = gst_codec_utils_h264_get_profile (sps, SPS_LEN);
1020 fail_unless_equals_string (profile, "multiview-high");
1022 fill_h264_sps (sps, 128, 0, 0);
1023 profile = gst_codec_utils_h264_get_profile (sps, SPS_LEN);
1024 fail_unless_equals_string (profile, "stereo-high");
1026 fill_h264_sps (sps, 83, 0, 0);
1027 profile = gst_codec_utils_h264_get_profile (sps, SPS_LEN);
1028 fail_unless_equals_string (profile, "scalable-baseline");
1030 fill_h264_sps (sps, 83, SPS_CONSTRAINT_SET_FLAG_5, 0);
1031 profile = gst_codec_utils_h264_get_profile (sps, SPS_LEN);
1032 fail_unless_equals_string (profile, "scalable-constrained-baseline");
1034 fill_h264_sps (sps, 86, 0, 0);
1035 profile = gst_codec_utils_h264_get_profile (sps, SPS_LEN);
1036 fail_unless_equals_string (profile, "scalable-high");
1038 fill_h264_sps (sps, 86, SPS_CONSTRAINT_SET_FLAG_3, 0);
1039 profile = gst_codec_utils_h264_get_profile (sps, SPS_LEN);
1040 fail_unless_equals_string (profile, "scalable-high-intra");
1042 fill_h264_sps (sps, 86, SPS_CONSTRAINT_SET_FLAG_5, 0);
1043 profile = gst_codec_utils_h264_get_profile (sps, SPS_LEN);
1044 fail_unless_equals_string (profile, "scalable-constrained-high");
1050 GST_START_TEST (test_pb_utils_h264_get_profile_flags_level)
1052 gboolean ret = FALSE;
1053 guint codec_data_len = 7;
1054 guint8 codec_data[] = { 0x01, 0x64, 0x00, 0x32, 0x00, 0x00, 0x00 };
1055 guint8 codec_data_bad_version[] =
1056 { 0x00, 0x64, 0x00, 0x32, 0x00, 0x00, 0x00 };
1063 gst_codec_utils_h264_get_profile_flags_level (codec_data, codec_data_len,
1064 &profile, &flags, &level);
1065 fail_unless (ret == TRUE);
1066 fail_unless (profile == 0x64);
1067 fail_unless (flags == 0x00);
1068 fail_unless (level == 0x32);
1070 /* happy path, return locations null */
1072 gst_codec_utils_h264_get_profile_flags_level (codec_data, codec_data_len,
1074 fail_unless (ret == TRUE);
1076 /* data too short */
1078 gst_codec_utils_h264_get_profile_flags_level (codec_data, 6, &profile,
1080 fail_unless (ret == FALSE);
1082 /* wrong codec version */
1084 gst_codec_utils_h264_get_profile_flags_level (codec_data_bad_version,
1085 codec_data_len, &profile, &flags, &level);
1086 fail_unless (ret == FALSE);
1091 #define PROFILE_TIER_LEVEL_LEN 11
1094 fill_h265_profile (guint8 * profile_tier_level,
1095 guint8 profile_idc, guint8 max_14bit_flag, guint8 max_12bit_flag,
1096 guint8 max_10bit_flag, guint8 max_8bit_flag, guint8 max_422_flag,
1097 guint8 max_420_flag, guint8 max_mono_flag, guint8 intra_flag,
1098 guint8 one_pic_flag, guint8 lower_bit_rate_flag)
1100 /* Bit 0:1 - general_profile_space
1101 * Bit 2 - general_tier_flag
1102 * Bit 3:7 - general_profile_idc
1103 * Bit 8:39 - gernal_profile_compatibility_flags
1104 * Bit 40 - general_progressive_source_flag
1105 * Bit 41 - general_interlaced_source_flag
1106 * Bit 42 - general_non_packed_constraint_flag
1107 * Bit 43 - general_frame_only_constraint_flag
1110 memset (profile_tier_level, 0x0, PROFILE_TIER_LEVEL_LEN);
1112 profile_tier_level[0] = profile_idc;
1114 if (profile_idc < 4)
1117 profile_tier_level[5] |= (max_12bit_flag << 3);
1118 profile_tier_level[5] |= (max_10bit_flag << 2);
1119 profile_tier_level[5] |= (max_8bit_flag << 1);
1120 profile_tier_level[5] |= max_422_flag;
1121 profile_tier_level[6] |= (max_420_flag << 7);
1122 profile_tier_level[6] |= (max_mono_flag << 6);
1123 profile_tier_level[6] |= (intra_flag << 5);
1124 profile_tier_level[6] |= (one_pic_flag << 4);
1125 profile_tier_level[6] |= (lower_bit_rate_flag << 3);
1126 profile_tier_level[6] |= (max_14bit_flag << 2);
1129 GST_START_TEST (test_pb_utils_h265_profiles)
1131 guint8 profile_tier_level[PROFILE_TIER_LEVEL_LEN] = { 0, };
1132 const gchar *profile;
1134 fill_h265_profile (profile_tier_level, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
1135 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1136 sizeof (profile_tier_level));
1137 fail_unless_equals_string (profile, "main");
1139 fill_h265_profile (profile_tier_level, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
1140 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1141 sizeof (profile_tier_level));
1142 fail_unless_equals_string (profile, "main-10");
1144 fill_h265_profile (profile_tier_level, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
1145 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1146 sizeof (profile_tier_level));
1147 fail_unless_equals_string (profile, "main-still-picture");
1149 /* Format range extensions profiles */
1150 fill_h265_profile (profile_tier_level, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
1151 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1152 sizeof (profile_tier_level));
1153 fail_unless (profile == NULL);
1155 fill_h265_profile (profile_tier_level, 4, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1);
1156 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1157 sizeof (profile_tier_level));
1158 fail_unless_equals_string (profile, "monochrome");
1160 fill_h265_profile (profile_tier_level, 4, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1);
1161 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1162 sizeof (profile_tier_level));
1163 fail_unless_equals_string (profile, "monochrome-10");
1165 fill_h265_profile (profile_tier_level, 4, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1);
1166 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1167 sizeof (profile_tier_level));
1168 fail_unless_equals_string (profile, "monochrome-12");
1170 fill_h265_profile (profile_tier_level, 4, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1);
1171 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1172 sizeof (profile_tier_level));
1173 fail_unless_equals_string (profile, "monochrome-16");
1175 fill_h265_profile (profile_tier_level, 4, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1);
1176 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1177 sizeof (profile_tier_level));
1178 fail_unless_equals_string (profile, "main-12");
1180 fill_h265_profile (profile_tier_level, 4, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1);
1181 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1182 sizeof (profile_tier_level));
1183 fail_unless_equals_string (profile, "main-422-10");
1185 fill_h265_profile (profile_tier_level, 4, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1);
1186 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1187 sizeof (profile_tier_level));
1188 fail_unless_equals_string (profile, "main-422-12");
1190 fill_h265_profile (profile_tier_level, 4, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1);
1191 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1192 sizeof (profile_tier_level));
1193 fail_unless_equals_string (profile, "main-444");
1195 fill_h265_profile (profile_tier_level, 4, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1);
1196 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1197 sizeof (profile_tier_level));
1198 fail_unless_equals_string (profile, "main-444-10");
1200 fill_h265_profile (profile_tier_level, 4, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1);
1201 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1202 sizeof (profile_tier_level));
1203 fail_unless_equals_string (profile, "main-444-12");
1205 fill_h265_profile (profile_tier_level, 4, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0);
1206 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1207 sizeof (profile_tier_level));
1208 fail_unless_equals_string (profile, "main-intra");
1210 fill_h265_profile (profile_tier_level, 4, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0);
1211 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1212 sizeof (profile_tier_level));
1213 fail_unless_equals_string (profile, "main-10-intra");
1215 fill_h265_profile (profile_tier_level, 4, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0);
1216 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1217 sizeof (profile_tier_level));
1218 fail_unless_equals_string (profile, "main-12-intra");
1220 fill_h265_profile (profile_tier_level, 4, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0);
1221 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1222 sizeof (profile_tier_level));
1223 fail_unless_equals_string (profile, "main-422-10-intra");
1225 fill_h265_profile (profile_tier_level, 4, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0);
1226 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1227 sizeof (profile_tier_level));
1228 fail_unless_equals_string (profile, "main-422-12-intra");
1230 fill_h265_profile (profile_tier_level, 4, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0);
1231 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1232 sizeof (profile_tier_level));
1233 fail_unless_equals_string (profile, "main-444-intra");
1235 fill_h265_profile (profile_tier_level, 4, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0);
1236 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1237 sizeof (profile_tier_level));
1238 fail_unless_equals_string (profile, "main-444-10-intra");
1240 fill_h265_profile (profile_tier_level, 4, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0);
1241 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1242 sizeof (profile_tier_level));
1243 fail_unless_equals_string (profile, "main-444-12-intra");
1245 fill_h265_profile (profile_tier_level, 4, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0);
1246 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1247 sizeof (profile_tier_level));
1248 fail_unless_equals_string (profile, "main-444-16-intra");
1250 fill_h265_profile (profile_tier_level, 4, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0);
1251 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1252 sizeof (profile_tier_level));
1253 fail_unless_equals_string (profile, "main-444-still-picture");
1255 fill_h265_profile (profile_tier_level, 4, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0);
1256 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1257 sizeof (profile_tier_level));
1258 fail_unless_equals_string (profile, "main-444-16-still-picture");
1260 /* High Throughput profiles */
1261 fill_h265_profile (profile_tier_level, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
1262 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1263 sizeof (profile_tier_level));
1264 fail_unless (profile == NULL);
1266 fill_h265_profile (profile_tier_level, 5, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1);
1267 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1268 sizeof (profile_tier_level));
1269 fail_unless_equals_string (profile, "high-throughput-444");
1271 fill_h265_profile (profile_tier_level, 5, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1);
1272 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1273 sizeof (profile_tier_level));
1274 fail_unless_equals_string (profile, "high-throughput-444-10");
1276 fill_h265_profile (profile_tier_level, 5, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1);
1277 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1278 sizeof (profile_tier_level));
1279 fail_unless_equals_string (profile, "high-throughput-444-14");
1281 fill_h265_profile (profile_tier_level, 5, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0);
1282 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1283 sizeof (profile_tier_level));
1284 fail_unless_equals_string (profile, "high-throughput-444-16-intra");
1286 /* Multiview Main profile */
1287 fill_h265_profile (profile_tier_level, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
1288 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1289 sizeof (profile_tier_level));
1290 fail_unless (profile == NULL);
1292 fill_h265_profile (profile_tier_level, 6, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1);
1293 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1294 sizeof (profile_tier_level));
1295 fail_unless_equals_string (profile, "multiview-main");
1297 /* Scalable Main profiles */
1298 fill_h265_profile (profile_tier_level, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
1299 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1300 sizeof (profile_tier_level));
1301 fail_unless (profile == NULL);
1303 fill_h265_profile (profile_tier_level, 7, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1);
1304 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1305 sizeof (profile_tier_level));
1306 fail_unless_equals_string (profile, "scalable-main");
1308 fill_h265_profile (profile_tier_level, 7, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1);
1309 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1310 sizeof (profile_tier_level));
1311 fail_unless_equals_string (profile, "scalable-main-10");
1313 /* 3D Main profile */
1314 fill_h265_profile (profile_tier_level, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
1315 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1316 sizeof (profile_tier_level));
1317 fail_unless (profile == NULL);
1319 fill_h265_profile (profile_tier_level, 8, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1);
1320 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1321 sizeof (profile_tier_level));
1322 fail_unless_equals_string (profile, "3d-main");
1324 /* Screen content coding extensions profiles */
1325 fill_h265_profile (profile_tier_level, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
1326 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1327 sizeof (profile_tier_level));
1328 fail_unless (profile == NULL);
1330 fill_h265_profile (profile_tier_level, 9, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1);
1331 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1332 sizeof (profile_tier_level));
1333 fail_unless_equals_string (profile, "screen-extended-main");
1335 fill_h265_profile (profile_tier_level, 9, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1);
1336 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1337 sizeof (profile_tier_level));
1338 fail_unless_equals_string (profile, "screen-extended-main-10");
1340 fill_h265_profile (profile_tier_level, 9, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1);
1341 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1342 sizeof (profile_tier_level));
1343 fail_unless_equals_string (profile, "screen-extended-main-444");
1345 fill_h265_profile (profile_tier_level, 9, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1);
1346 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1347 sizeof (profile_tier_level));
1348 fail_unless_equals_string (profile, "screen-extended-main-444-10");
1350 fill_h265_profile (profile_tier_level, 9, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1);
1351 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1352 sizeof (profile_tier_level));
1353 fail_unless_equals_string (profile, "screen-extended-high-throughput-444-14");
1355 /* Scalable format range extensions profiles */
1356 fill_h265_profile (profile_tier_level, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
1357 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1358 sizeof (profile_tier_level));
1359 fail_unless (profile == NULL);
1361 fill_h265_profile (profile_tier_level, 10, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1);
1362 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1363 sizeof (profile_tier_level));
1364 fail_unless_equals_string (profile, "scalable-monochrome");
1366 fill_h265_profile (profile_tier_level, 10, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1);
1367 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1368 sizeof (profile_tier_level));
1369 fail_unless_equals_string (profile, "scalable-monochrome-12");
1371 fill_h265_profile (profile_tier_level, 10, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1);
1372 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1373 sizeof (profile_tier_level));
1374 fail_unless_equals_string (profile, "scalable-monochrome-16");
1376 fill_h265_profile (profile_tier_level, 10, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1);
1377 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1378 sizeof (profile_tier_level));
1379 fail_unless_equals_string (profile, "scalable-main-444");
1381 fill_h265_profile (profile_tier_level, 11, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1);
1382 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1383 sizeof (profile_tier_level));
1384 fail_unless_equals_string (profile, "screen-extended-main-444-10");
1386 fill_h265_profile (profile_tier_level, 11, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1);
1387 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1388 sizeof (profile_tier_level));
1389 fail_unless_equals_string (profile, "screen-extended-main-444");
1391 fill_h265_profile (profile_tier_level, 11, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1);
1392 profile = gst_codec_utils_h265_get_profile (profile_tier_level,
1393 sizeof (profile_tier_level));
1394 fail_unless_equals_string (profile, "screen-extended-high-throughput-444-14");
1399 static const guint8 h265_sample_codec_data[] = {
1400 0x01, 0x01, 0x60, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5d,
1402 0xfd, 0xf8, 0xf8, 0x00, 0x00, 0x0f, 0x03, 0x20, 0x00, 0x01, 0x00, 0x18, 0x40,
1404 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00,
1406 0x5d, 0x15, 0xc0, 0x90, 0x21, 0x00, 0x01, 0x00, 0x22, 0x42, 0x01, 0x01, 0x01,
1408 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5d, 0xa0, 0x0a,
1410 0x20, 0x57, 0xb9, 0x16, 0x55, 0x35, 0x01, 0x01, 0x01, 0x00, 0x80, 0x22, 0x00,
1412 0x44, 0x01, 0xc0, 0x2c, 0xbc, 0x14, 0xc9
1415 GST_START_TEST (test_pb_utils_caps_mime_codec)
1417 GstCaps *caps = NULL;
1418 GstCaps *caps2 = NULL;
1419 gchar *mime_codec = NULL;
1420 GstBuffer *buffer = NULL;
1421 guint8 *codec_data = NULL;
1422 gsize codec_data_len;
1424 /* h264 without codec data */
1425 caps = gst_caps_new_empty_simple ("video/x-h264");
1426 mime_codec = gst_codec_utils_caps_get_mime_codec (caps);
1427 fail_unless_equals_string (mime_codec, "avc1");
1428 caps2 = gst_codec_utils_caps_from_mime_codec (mime_codec);
1429 fail_unless (gst_caps_is_equal_fixed (caps, caps2));
1430 gst_caps_unref (caps2);
1431 g_free (mime_codec);
1432 gst_caps_unref (caps);
1434 /* h264 with codec data */
1435 codec_data_len = sizeof (guint8) * 7;
1436 codec_data = g_malloc0 (codec_data_len);
1437 codec_data[0] = 0x01;
1438 codec_data[1] = 0x64;
1439 codec_data[2] = 0x00;
1440 codec_data[3] = 0x32;
1441 /* seven bytes is the minumum for a valid h264 codec_data, but in
1442 * gst_codec_utils_h264_get_profile_flags_level we only parse the first four
1444 buffer = gst_buffer_new_wrapped (codec_data, codec_data_len);
1446 gst_caps_new_simple ("video/x-h264", "codec_data", GST_TYPE_BUFFER,
1448 mime_codec = gst_codec_utils_caps_get_mime_codec (caps);
1449 fail_unless_equals_string (mime_codec, "avc1.640032");
1450 g_free (mime_codec);
1451 gst_caps_unref (caps);
1452 gst_buffer_unref (buffer);
1456 gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY,
1457 (gpointer) h265_sample_codec_data, sizeof (h265_sample_codec_data), 0,
1458 sizeof (h265_sample_codec_data), NULL, NULL);
1460 gst_caps_new_simple ("video/x-h265", "stream-format", G_TYPE_STRING,
1461 "hvc1", "codec_data", GST_TYPE_BUFFER, buffer, NULL);
1462 mime_codec = gst_codec_utils_caps_get_mime_codec (caps);
1463 fail_unless_equals_string (mime_codec, "hvc1.1.6.L93.B0");
1464 g_free (mime_codec);
1465 gst_caps_unref (caps);
1466 gst_buffer_unref (buffer);
1469 caps = gst_caps_new_empty_simple ("video/x-av1");
1470 mime_codec = gst_codec_utils_caps_get_mime_codec (caps);
1471 fail_unless_equals_string (mime_codec, "av01");
1472 caps2 = gst_codec_utils_caps_from_mime_codec (mime_codec);
1473 fail_unless (gst_caps_is_equal_fixed (caps, caps2));
1474 gst_caps_unref (caps2);
1475 g_free (mime_codec);
1476 gst_caps_unref (caps);
1479 caps = gst_caps_new_empty_simple ("video/x-vp8");
1480 mime_codec = gst_codec_utils_caps_get_mime_codec (caps);
1481 fail_unless_equals_string (mime_codec, "vp08");
1482 caps2 = gst_codec_utils_caps_from_mime_codec (mime_codec);
1483 fail_unless (gst_caps_is_equal_fixed (caps, caps2));
1484 gst_caps_unref (caps2);
1485 g_free (mime_codec);
1486 gst_caps_unref (caps);
1489 caps = gst_caps_new_empty_simple ("video/x-vp9");
1490 mime_codec = gst_codec_utils_caps_get_mime_codec (caps);
1491 fail_unless_equals_string (mime_codec, "vp09");
1492 caps2 = gst_codec_utils_caps_from_mime_codec (mime_codec);
1493 fail_unless (gst_caps_is_equal_fixed (caps, caps2));
1494 gst_caps_unref (caps2);
1495 g_free (mime_codec);
1496 gst_caps_unref (caps);
1499 caps = gst_caps_new_empty_simple ("image/jpeg");
1500 mime_codec = gst_codec_utils_caps_get_mime_codec (caps);
1501 fail_unless_equals_string (mime_codec, "mjpg");
1502 g_free (mime_codec);
1503 gst_caps_unref (caps);
1505 /* aac without codec data */
1506 caps = gst_caps_new_empty_simple ("audio/mpeg");
1507 mime_codec = gst_codec_utils_caps_get_mime_codec (caps);
1508 fail_unless_equals_string (mime_codec, "mp4a.40");
1509 g_free (mime_codec);
1510 gst_caps_unref (caps);
1512 /* aac with codec data */
1513 codec_data_len = sizeof (guint8) * 2;
1514 codec_data = g_malloc0 (codec_data_len);
1515 codec_data[0] = 0x11;
1516 codec_data[1] = 0x88;
1517 buffer = gst_buffer_new_wrapped (codec_data, codec_data_len);
1519 gst_caps_new_simple ("audio/mpeg", "codec_data", GST_TYPE_BUFFER, buffer,
1521 mime_codec = gst_codec_utils_caps_get_mime_codec (caps);
1522 fail_unless_equals_string (mime_codec, "mp4a.40.2");
1523 g_free (mime_codec);
1524 gst_caps_unref (caps);
1525 gst_buffer_unref (buffer);
1528 caps = gst_caps_new_empty_simple ("audio/x-opus");
1529 mime_codec = gst_codec_utils_caps_get_mime_codec (caps);
1530 fail_unless_equals_string (mime_codec, "opus");
1531 caps2 = gst_codec_utils_caps_from_mime_codec (mime_codec);
1532 fail_unless (gst_caps_is_equal_fixed (caps, caps2));
1533 gst_caps_unref (caps2);
1534 g_free (mime_codec);
1535 gst_caps_unref (caps);
1538 caps = gst_caps_new_empty_simple ("audio/x-mulaw");
1539 mime_codec = gst_codec_utils_caps_get_mime_codec (caps);
1540 fail_unless_equals_string (mime_codec, "ulaw");
1541 caps2 = gst_codec_utils_caps_from_mime_codec (mime_codec);
1542 fail_unless (gst_caps_is_equal_fixed (caps, caps2));
1543 gst_caps_unref (caps2);
1544 g_free (mime_codec);
1545 gst_caps_unref (caps);
1549 gst_caps_new_simple ("audio/x-adpcm", "layout", G_TYPE_STRING, "g726",
1551 mime_codec = gst_codec_utils_caps_get_mime_codec (caps);
1552 fail_unless_equals_string (mime_codec, "g726");
1553 caps2 = gst_codec_utils_caps_from_mime_codec (mime_codec);
1554 fail_unless (gst_caps_is_equal_fixed (caps, caps2));
1555 gst_caps_unref (caps2);
1556 g_free (mime_codec);
1557 gst_caps_unref (caps);
1563 libgstpbutils_suite (void)
1565 Suite *s = suite_create ("pbutils library");
1566 TCase *tc_chain = tcase_create ("general");
1568 gst_pb_utils_init ();
1570 suite_add_tcase (s, tc_chain);
1571 tcase_add_test (tc_chain, test_pb_utils_init);
1572 tcase_add_test (tc_chain, test_pb_utils_post_missing_messages);
1573 tcase_add_test (tc_chain, test_pb_utils_taglist_add_codec_info);
1574 tcase_add_test (tc_chain, test_pb_utils_get_caps_description_flags);
1575 tcase_add_test (tc_chain, test_pb_utils_get_codec_description);
1576 tcase_add_test (tc_chain, test_pb_utils_install_plugins);
1577 tcase_add_test (tc_chain, test_pb_utils_installer_details);
1578 tcase_add_test (tc_chain, test_pb_utils_versions);
1579 tcase_add_test (tc_chain, test_pb_utils_aac_get_profile);
1580 tcase_add_test (tc_chain, test_pb_utils_h264_profiles);
1581 tcase_add_test (tc_chain, test_pb_utils_h264_get_profile_flags_level);
1582 tcase_add_test (tc_chain, test_pb_utils_h265_profiles);
1583 tcase_add_test (tc_chain, test_pb_utils_caps_mime_codec);
1587 GST_CHECK_MAIN (libgstpbutils);