1 /* GStreamer unit test for gstprofile
3 * Copyright (C) <2009> Edward Hervey <edward.hervey@collabora.co.uk>
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.
26 #include <glib/gstdio.h>
27 #include <gst/check/gstcheck.h>
29 #include <gst/pbutils/encoding-profile.h>
30 #include <gst/pbutils/encoding-target.h>
33 #include <unistd.h> /* For R_OK etc. */
36 static inline gboolean
37 gst_caps_is_equal_unref (GstCaps * caps1, GstCaps * caps2)
41 ret = gst_caps_is_equal (caps1, caps2);
42 gst_caps_unref (caps1);
47 #define CHECK_PROFILE(profile, name, description, format, preset, presence, restriction) \
49 fail_if(profile == NULL); \
50 fail_unless_equals_string (gst_encoding_profile_get_name (profile), name); \
51 fail_unless_equals_string (gst_encoding_profile_get_description (profile), description); \
52 fail_unless (gst_caps_is_equal_unref (gst_encoding_profile_get_format (profile), format)); \
53 fail_unless_equals_string (gst_encoding_profile_get_preset (profile), preset); \
54 fail_unless_equals_int (gst_encoding_profile_get_presence (profile), presence); \
56 fail_unless (gst_caps_is_equal_unref (gst_encoding_profile_get_restriction (profile), restriction)); \
59 GST_START_TEST (test_profile_creation)
61 GstEncodingProfile *encprof;
62 GstEncodingAudioProfile *audioprof;
63 GstEncodingVideoProfile *videoprof;
64 GstCaps *ogg, *vorbis, *theora;
65 GstCaps *test1, *test2;
67 ogg = gst_caps_new_empty_simple ("application/ogg");
68 vorbis = gst_caps_new_empty_simple ("audio/x-vorbis");
69 theora = gst_caps_new_empty_simple ("video/x-theora");
71 encprof = (GstEncodingProfile *) gst_encoding_container_profile_new ((gchar *)
72 "ogg-theora-vorbis", "dumb-profile", ogg, (gchar *) "dumb-preset");
73 CHECK_PROFILE (encprof, "ogg-theora-vorbis", "dumb-profile", ogg,
74 "dumb-preset", 0, NULL);
76 audioprof = gst_encoding_audio_profile_new (vorbis, (gchar *) "HQ", NULL, 0);
77 CHECK_PROFILE ((GstEncodingProfile *) audioprof, NULL, NULL, vorbis, "HQ", 0,
80 videoprof = gst_encoding_video_profile_new (theora, (gchar *) "HQ", NULL, 0);
81 CHECK_PROFILE ((GstEncodingProfile *) videoprof, NULL, NULL, theora, "HQ",
84 fail_unless (gst_encoding_container_profile_add_profile (
85 (GstEncodingContainerProfile *) encprof,
86 (GstEncodingProfile *) audioprof));
87 fail_unless (gst_encoding_container_profile_add_profile (
88 (GstEncodingContainerProfile *) encprof,
89 (GstEncodingProfile *) videoprof));
92 test1 = gst_caps_from_string ("video/x-theora; audio/x-vorbis");
93 test2 = gst_encoding_profile_get_input_caps (encprof);
94 fail_unless (gst_caps_is_equal (test1, test2));
95 gst_caps_unref (test1);
96 gst_caps_unref (test2);
98 gst_encoding_profile_unref (encprof);
100 gst_caps_unref (theora);
101 gst_caps_unref (vorbis);
107 GST_START_TEST (test_profile_input_caps)
109 GstEncodingProfile *sprof;
111 GstCaps *out, *restriction, *test1;
113 vorbis = gst_caps_new_empty_simple ("audio/x-vorbis");
115 /* Simple case, no restriction */
116 sprof = (GstEncodingProfile *)
117 gst_encoding_audio_profile_new (vorbis, NULL, NULL, 0);
118 fail_if (sprof == NULL);
120 out = gst_encoding_profile_get_input_caps (sprof);
121 fail_if (out == NULL);
122 fail_unless (gst_caps_is_equal (out, vorbis));
123 gst_caps_unref (out);
124 gst_encoding_profile_unref (sprof);
126 /* One simple restriction */
127 restriction = gst_caps_from_string ("audio/x-raw,channels=2,rate=44100");
128 test1 = gst_caps_from_string ("audio/x-vorbis,channels=2,rate=44100");
129 fail_if (restriction == NULL);
131 sprof = (GstEncodingProfile *)
132 gst_encoding_audio_profile_new (vorbis, NULL, restriction, 0);
133 fail_if (sprof == NULL);
135 out = gst_encoding_profile_get_input_caps (sprof);
136 fail_if (out == NULL);
137 GST_DEBUG ("got caps %" GST_PTR_FORMAT, out);
138 fail_unless (gst_caps_is_equal (out, test1));
139 gst_caps_unref (out);
140 gst_caps_unref (restriction);
141 gst_caps_unref (test1);
142 gst_encoding_profile_unref (sprof);
144 gst_caps_unref (vorbis);
150 GST_START_TEST (test_target_naming)
152 GstEncodingTarget *target;
154 gst_debug_set_threshold_for_name ("default", GST_LEVEL_NONE);
157 ASSERT_CRITICAL (target = gst_encoding_target_new (NULL, NULL, NULL, NULL));
158 fail_if (target != NULL);
159 ASSERT_CRITICAL (target =
160 gst_encoding_target_new ("donkey", NULL, NULL, NULL));
161 fail_if (target != NULL);
162 ASSERT_CRITICAL (target =
163 gst_encoding_target_new (NULL, "donkey", NULL, NULL));
164 fail_if (target != NULL);
165 ASSERT_CRITICAL (target =
166 gst_encoding_target_new (NULL, NULL, "donkey", NULL));
167 fail_if (target != NULL);
169 /* Name and Category validation */
171 /* empty non-NULL strings */
172 fail_if (gst_encoding_target_new ("", "valid", "description", NULL) != NULL);
173 fail_if (gst_encoding_target_new ("valid", "", "description", NULL) != NULL);
175 /* don't start with a lower case ASCII character */
176 fail_if (gst_encoding_target_new ("A", "valid", "description", NULL) != NULL);
177 fail_if (gst_encoding_target_new ("3", "valid", "description", NULL) != NULL);
178 fail_if (gst_encoding_target_new ("-", "valid", "description", NULL) != NULL);
179 fail_if (gst_encoding_target_new ("!", "valid", "description", NULL) != NULL);
180 fail_if (gst_encoding_target_new (" ", "valid", "description", NULL) != NULL);
181 fail_if (gst_encoding_target_new ("valid", "A", "description", NULL) != NULL);
182 fail_if (gst_encoding_target_new ("valid", "3", "description", NULL) != NULL);
183 fail_if (gst_encoding_target_new ("valid", "-", "description", NULL) != NULL);
184 fail_if (gst_encoding_target_new ("valid", "!", "description", NULL) != NULL);
185 fail_if (gst_encoding_target_new ("valid", " ", "description", NULL) != NULL);
187 /* Starting with anything else is valid */
188 target = gst_encoding_target_new ("a", "valid", "description", NULL);
189 fail_if (target == NULL);
190 gst_encoding_target_unref (target);
191 target = gst_encoding_target_new ("z", "valid", "description", NULL);
192 fail_if (target == NULL);
193 gst_encoding_target_unref (target);
194 target = gst_encoding_target_new ("valid", "a", "description", NULL);
195 fail_if (target == NULL);
196 gst_encoding_target_unref (target);
197 target = gst_encoding_target_new ("valid", "z", "description", NULL);
198 fail_if (target == NULL);
199 gst_encoding_target_unref (target);
201 /* only inner valid characters are lower-case ASCII letters *OR* digits *OR* hyphens */
202 fail_if (gst_encoding_target_new ("aA", "valid", "description",
204 fail_if (gst_encoding_target_new ("a!", "valid", "description",
206 fail_if (gst_encoding_target_new ("space donkeys", "valid", "description",
208 fail_if (gst_encoding_target_new ("howaboutùnicode", "valid", "description",
210 fail_if (gst_encoding_target_new ("valid", "aA", "description",
212 fail_if (gst_encoding_target_new ("valid", "a!", "description",
216 gst_encoding_target_new ("donkey-4-ever", "valid", "description", NULL);
217 fail_if (target == NULL);
218 gst_encoding_target_unref (target);
220 gst_encoding_target_new ("valid", "donkey-4-ever", "description", NULL);
221 fail_if (target == NULL);
222 gst_encoding_target_unref (target);
228 static GstEncodingTarget *
229 create_saveload_target (const gchar * targetname)
231 GstEncodingTarget *target;
232 GstEncodingProfile *profile, *sprof;
233 GstCaps *caps, *caps2;
235 GST_DEBUG ("Creating target");
237 target = gst_encoding_target_new (targetname, "herding",
238 "Plenty of pony glitter profiles", NULL);
239 caps = gst_caps_from_string ("animal/x-pony");
241 (GstEncodingProfile *) gst_encoding_container_profile_new ("pony",
242 "I don't want a description !", caps, NULL);
243 gst_caps_unref (caps);
244 gst_encoding_target_add_profile (target, profile);
246 caps = gst_caps_from_string ("audio/x-pony-song,pretty=True");
247 caps2 = gst_caps_from_string ("audio/x-raw,channels=1,rate=44100");
249 (GstEncodingProfile *) gst_encoding_audio_profile_new (caps, NULL, caps2,
251 gst_encoding_container_profile_add_profile ((GstEncodingContainerProfile *)
253 gst_caps_unref (caps);
254 gst_caps_unref (caps2);
256 caps = gst_caps_from_string ("video/x-glitter,sparkling=True");
258 gst_caps_from_string ("video/x-raw,width=640,height=480,framerate=15/1");
259 sprof = (GstEncodingProfile *)
260 gst_encoding_video_profile_new (caps, "seriously glittery", caps2, 0);
261 gst_encoding_video_profile_set_variableframerate ((GstEncodingVideoProfile *)
263 gst_encoding_container_profile_add_profile ((GstEncodingContainerProfile *)
265 gst_caps_unref (caps);
266 gst_caps_unref (caps2);
271 GST_START_TEST (test_target_profile)
273 GstEncodingTarget *target;
274 GstEncodingProfile *prof;
276 target = create_saveload_target ("myponytarget");
278 /* NULL isn't a valid profile name */
279 ASSERT_CRITICAL (gst_encoding_target_get_profile (target, NULL));
281 /* try finding a profile that doesn't exist */
282 fail_if (gst_encoding_target_get_profile (target,
283 "no-really-does-not-exist"));
285 /* try finding a profile that exists */
286 prof = gst_encoding_target_get_profile (target, "pony");
287 fail_if (prof == NULL);
289 gst_encoding_profile_unref (prof);
290 gst_encoding_target_unref (target);
295 GST_START_TEST (test_saving_profile)
297 GstEncodingTarget *orig, *loaded = NULL;
298 GstEncodingProfile *proforig, *profloaded;
299 gchar *profile_file_name;
301 /* Create and store a target */
302 orig = create_saveload_target ("myponytarget2");
303 GST_DEBUG ("Saving target 'myponytarget2'");
304 fail_unless (gst_encoding_target_save (orig, NULL));
306 /* Check we can load it */
308 g_build_filename (g_get_user_data_dir (), "gstreamer-1.0",
309 "encoding-profiles", "herding", "myponytarget2.gep", NULL);
310 GST_DEBUG ("Loading target from '%s'", profile_file_name);
311 loaded = gst_encoding_target_load_from_file (profile_file_name, NULL);
312 fail_unless (loaded != NULL);
313 g_free (profile_file_name);
315 GST_DEBUG ("Checking targets are equal");
316 /* Check targets are identical */
317 /* 1. at the target level */
318 fail_unless_equals_string (gst_encoding_target_get_name (orig),
319 gst_encoding_target_get_name (loaded));
320 fail_unless_equals_string (gst_encoding_target_get_category (orig),
321 gst_encoding_target_get_category (loaded));
322 fail_unless_equals_string (gst_encoding_target_get_description (orig),
323 gst_encoding_target_get_description (loaded));
324 fail_unless_equals_int (g_list_length ((GList *)
325 gst_encoding_target_get_profiles (loaded)), 1);
327 /* 2. at the profile level */
329 (GstEncodingProfile *) gst_encoding_target_get_profiles (loaded)->data;
331 (GstEncodingProfile *) gst_encoding_target_get_profiles (orig)->data;
333 fail_unless_equals_int (G_TYPE_FROM_INSTANCE (profloaded),
334 G_TYPE_FROM_INSTANCE (proforig));
335 GST_DEBUG ("Comparing loaded:%p to original:%p", profloaded, proforig);
336 fail_unless (gst_encoding_profile_is_equal (profloaded, proforig));
338 gst_encoding_target_unref (orig);
339 gst_encoding_target_unref (loaded);
345 test_individual_target (GstEncodingTarget * target)
347 GstEncodingProfile *prof;
348 GstCaps *tmpcaps, *tmpcaps2;
349 GstEncodingProfile *sprof1, *sprof2;
351 GST_DEBUG ("Checking the target properties");
352 /* Check the target */
353 fail_unless_equals_string (gst_encoding_target_get_name (target),
355 fail_unless_equals_string (gst_encoding_target_get_category (target),
357 fail_unless_equals_string (gst_encoding_target_get_description (target),
358 "Plenty of pony glitter profiles");
360 GST_DEBUG ("Checking the number of profiles the target contains");
361 fail_unless_equals_int (g_list_length ((GList *)
362 gst_encoding_target_get_profiles (target)), 1);
365 GST_DEBUG ("Checking the container profile");
366 /* Check the profile */
367 prof = (GstEncodingProfile *) gst_encoding_target_get_profiles (target)->data;
368 tmpcaps = gst_caps_from_string ("animal/x-pony");
369 CHECK_PROFILE (prof, "pony", "I don't want a description !", tmpcaps, NULL, 0,
371 gst_caps_unref (tmpcaps);
373 GST_DEBUG ("Checking the container profile has 2 stream profiles");
374 /* Check the stream profiles */
375 fail_unless_equals_int (g_list_length ((GList *)
376 gst_encoding_container_profile_get_profiles (
377 (GstEncodingContainerProfile *) prof)), 2);
379 GST_DEBUG ("Checking the container profile has the audio/x-pony-song stream");
380 tmpcaps = gst_caps_from_string ("audio/x-pony-song,pretty=True");
381 tmpcaps2 = gst_caps_from_string ("audio/x-raw,channels=1,rate=44100");
383 (GstEncodingProfile *) gst_encoding_audio_profile_new (tmpcaps, NULL,
385 fail_unless (gst_encoding_container_profile_contains_profile (
386 (GstEncodingContainerProfile *) prof, sprof1));
387 gst_encoding_profile_unref (sprof1);
388 gst_caps_unref (tmpcaps);
389 gst_caps_unref (tmpcaps2);
391 GST_DEBUG ("Checking the container profile has the video//x-glitter stream");
392 tmpcaps = gst_caps_from_string ("video/x-glitter,sparkling=True");
394 gst_caps_from_string ("video/x-raw,width=640,height=480,framerate=15/1");
395 sprof2 = (GstEncodingProfile *)
396 gst_encoding_video_profile_new (tmpcaps, "seriously glittery", tmpcaps2,
398 gst_encoding_video_profile_set_variableframerate ((GstEncodingVideoProfile *)
400 fail_unless (gst_encoding_container_profile_contains_profile (
401 (GstEncodingContainerProfile *) prof, sprof2));
402 gst_encoding_profile_unref (sprof2);
403 gst_caps_unref (tmpcaps);
404 gst_caps_unref (tmpcaps2);
407 GST_START_TEST (test_loading_profile)
409 GstEncodingTarget *target;
410 gchar *profile_file_name;
411 GstEncodingProfile *profile;
413 GValue strvalue = { 0, };
414 GValue objectvalue = { 0, };
416 gst_debug_set_threshold_for_name ("default", GST_LEVEL_NONE);
418 /* Test loading using short method and all arguments */
419 target = gst_encoding_target_load ("myponytarget", "herding", NULL);
420 fail_unless (target != NULL);
421 test_individual_target (target);
422 gst_encoding_target_unref (target);
424 /* Test loading using short method and no category */
425 target = gst_encoding_target_load ("myponytarget", NULL, NULL);
426 fail_unless (target != NULL);
427 test_individual_target (target);
428 gst_encoding_target_unref (target);
430 /* Test loading using fully specified path */
432 g_build_filename (g_get_user_data_dir (), "gstreamer-1.0",
433 "encoding-profiles", "herding", "myponytarget.gep", NULL);
435 GST_DEBUG ("Loading target from '%s'", profile_file_name);
436 target = gst_encoding_target_load_from_file (profile_file_name, NULL);
437 g_free (profile_file_name);
438 fail_unless (target != NULL);
439 test_individual_target (target);
440 gst_encoding_target_unref (target);
442 /* Test getting the profiles directly
443 * First without category */
444 profile = gst_encoding_profile_find ("myponytarget", "pony", NULL);
445 fail_unless (profile != NULL);
446 tmpcaps = gst_caps_from_string ("animal/x-pony");
447 CHECK_PROFILE (profile, "pony", "I don't want a description !", tmpcaps, NULL,
449 gst_caps_unref (tmpcaps);
450 gst_encoding_profile_unref (profile);
452 /* Then with a specific category */
453 profile = gst_encoding_profile_find ("myponytarget", "pony", "herding");
454 fail_unless (profile != NULL);
455 tmpcaps = gst_caps_from_string ("animal/x-pony");
456 CHECK_PROFILE (profile, "pony", "I don't want a description !", tmpcaps, NULL,
458 gst_caps_unref (tmpcaps);
459 gst_encoding_profile_unref (profile);
461 /* For my next trick, I will need the assistance of a GValue */
462 g_value_init (&strvalue, G_TYPE_STRING);
463 g_value_init (&objectvalue, GST_TYPE_ENCODING_PROFILE);
464 g_value_set_static_string (&strvalue, "myponytarget/pony");
465 fail_unless (g_value_transform (&strvalue, &objectvalue));
466 profile = (GstEncodingProfile *) g_value_dup_object (&objectvalue);
467 fail_if (profile == NULL);
468 g_value_unset (&strvalue);
469 g_value_unset (&objectvalue);
470 tmpcaps = gst_caps_from_string ("animal/x-pony");
471 CHECK_PROFILE (profile, "pony", "I don't want a description !", tmpcaps, NULL,
473 gst_caps_unref (tmpcaps);
474 gst_encoding_profile_unref (profile);
476 /* Let's go crazy for error detection */
477 fail_if (gst_encoding_profile_find ("myponytarget", "whales", NULL));
478 fail_if (gst_encoding_profile_find ("myponytarget", "whales", "herding"));
479 fail_if (gst_encoding_profile_find ("myponytarget", "", NULL));
480 fail_if (gst_encoding_profile_find ("", "pony", NULL));
485 GST_START_TEST (test_target_list)
491 /* Make sure we get our test category in the available categories */
492 categories = gst_encoding_list_available_categories ();
493 fail_if (categories == NULL);
494 fail_if (g_list_find_custom (categories, "herding",
495 (GCompareFunc) g_strcmp0) == NULL);
496 g_list_foreach (categories, (GFunc) g_free, NULL);
497 g_list_free (categories);
499 /* Try getting all available targets with a specified category */
500 targets = gst_encoding_list_all_targets ("herding");
501 fail_if (targets == NULL);
502 for (tmp = targets; tmp; tmp = tmp->next) {
503 GstEncodingTarget *target = (GstEncodingTarget *) tmp->data;
504 if (!g_strcmp0 (gst_encoding_target_get_name (target), "myponytarget"))
507 /* If tmp is NULL, it means we iterated the whole list without finding
509 fail_if (tmp == NULL);
510 g_list_foreach (targets, (GFunc) g_object_unref, NULL);
511 g_list_free (targets);
513 /* Try getting all available targets without a specified category */
514 targets = gst_encoding_list_all_targets (NULL);
515 fail_if (targets == NULL);
516 for (tmp = targets; tmp; tmp = tmp->next) {
517 GstEncodingTarget *target = (GstEncodingTarget *) tmp->data;
518 if (!g_strcmp0 (gst_encoding_target_get_name (target), "myponytarget"))
521 /* If tmp is NULL, it means we iterated the whole list without finding
523 fail_if (tmp == NULL);
524 g_list_foreach (targets, (GFunc) g_object_unref, NULL);
525 g_list_free (targets);
531 static const gchar *profile_string = "\
532 [GStreamer Encoding Target]\n\
535 description=Plenty of pony glitter profiles\n\
540 description=I don't want a description !\n\
541 format=animal/x-pony\n\
543 [streamprofile-pony11]\n\
546 format=audio/x-pony-song,pretty=True\n\
547 restriction=audio/x-raw,channels=1,rate=44100\n\
550 [streamprofile-pony12]\n\
553 preset=seriously glittery\n\
554 format=video/x-glitter,sparkling=True\n\
555 restriction=video/x-raw,width=640,height=480,framerate=15/1\n\
557 variableframerate=true\n\
561 remove_profile_file (void)
563 gchar *profile_file_name;
566 g_build_filename (g_get_user_data_dir (), "gstreamer-1.0",
567 "encoding-profiles", "herding", "myponytarget.gep", NULL);
568 g_unlink (profile_file_name);
569 g_free (profile_file_name);
571 g_build_filename (g_get_user_data_dir (), "gstreamer-1.0",
572 "encoding-profiles", "herding", "myponytarget2.gep", NULL);
573 g_unlink (profile_file_name);
574 g_free (profile_file_name);
578 create_profile_file (void)
580 gchar *profile_file_name;
582 GError *error = NULL;
585 g_build_filename (g_get_user_data_dir (), "gstreamer-1.0",
586 "encoding-profiles", "herding", NULL);
588 g_build_filename (g_get_user_data_dir (), "gstreamer-1.0",
589 "encoding-profiles", "herding", "myponytarget.gep", NULL);
591 /* on Windows it will ignore the mode anyway */
593 g_mkdir_with_parents (profile_dir, 0700);
595 g_mkdir_with_parents (profile_dir, S_IRUSR | S_IWUSR | S_IXUSR);
598 if (!g_file_set_contents (profile_file_name, profile_string,
599 strlen (profile_string), &error))
600 GST_WARNING ("Couldn't write contents to file : %s", error->message);
601 g_free (profile_dir);
602 g_free (profile_file_name);
608 create_profile_file ();
614 remove_profile_file ();
617 GST_START_TEST (test_file_extension)
619 GstEncodingContainerProfile *cprof;
620 GstCaps *ogg, *speex, *vorbis, *theora, *id3, *mp3;
622 /* 1 - ogg variants */
623 ogg = gst_caps_new_empty_simple ("application/ogg");
624 cprof = gst_encoding_container_profile_new ("myprofile", NULL, ogg, NULL);
625 gst_caps_unref (ogg);
627 fail_unless_equals_string (gst_encoding_profile_get_file_extension
628 (GST_ENCODING_PROFILE (cprof)), "ogg");
630 speex = gst_caps_new_empty_simple ("audio/x-speex");
631 gst_encoding_container_profile_add_profile (cprof,
632 (GstEncodingProfile *) gst_encoding_audio_profile_new (speex, NULL,
634 gst_caps_unref (speex);
636 fail_unless_equals_string (gst_encoding_profile_get_file_extension
637 (GST_ENCODING_PROFILE (cprof)), "spx");
639 vorbis = gst_caps_new_empty_simple ("audio/x-vorbis");
640 gst_encoding_container_profile_add_profile (cprof,
641 (GstEncodingProfile *) gst_encoding_audio_profile_new (vorbis, NULL,
643 gst_caps_unref (vorbis);
645 fail_unless_equals_string (gst_encoding_profile_get_file_extension
646 (GST_ENCODING_PROFILE (cprof)), "ogg");
648 theora = gst_caps_new_empty_simple ("video/x-theora");
649 gst_encoding_container_profile_add_profile (cprof,
650 (GstEncodingProfile *) gst_encoding_video_profile_new (theora, NULL,
652 gst_caps_unref (theora);
654 fail_unless_equals_string (gst_encoding_profile_get_file_extension
655 (GST_ENCODING_PROFILE (cprof)), "ogv");
657 gst_encoding_profile_unref (cprof);
659 /* 2 - tag container */
660 id3 = gst_caps_new_empty_simple ("application/x-id3");
661 cprof = gst_encoding_container_profile_new ("myprofile", NULL, id3, NULL);
662 gst_caps_unref (id3);
664 fail_unless (gst_encoding_profile_get_file_extension (GST_ENCODING_PROFILE
667 mp3 = gst_caps_new_simple ("audio/mpeg", "mpegversion", G_TYPE_INT, 1,
668 "layer", G_TYPE_INT, 3, NULL);
669 gst_encoding_container_profile_add_profile (cprof,
670 (GstEncodingProfile *) gst_encoding_audio_profile_new (mp3, NULL,
672 gst_caps_unref (mp3);
674 fail_unless_equals_string (gst_encoding_profile_get_file_extension
675 (GST_ENCODING_PROFILE (cprof)), "mp3");
677 gst_encoding_profile_unref (cprof);
685 Suite *s = suite_create ("profile support library");
686 TCase *tc_chain = tcase_create ("general");
690 /* cehck if we can create profiles */
692 gst_dir = g_build_filename (g_get_user_data_dir (), "gstreamer-1.0", NULL);
693 can_write = (g_access (gst_dir, R_OK | W_OK | X_OK) == 0);
696 can_write = FALSE; /* FIXME: fix can_write test on Windows */
699 suite_add_tcase (s, tc_chain);
701 tcase_add_test (tc_chain, test_profile_creation);
702 tcase_add_test (tc_chain, test_profile_input_caps);
703 tcase_add_test (tc_chain, test_target_naming);
704 tcase_add_test (tc_chain, test_target_profile);
705 tcase_add_test (tc_chain, test_file_extension);
707 tcase_add_test (tc_chain, test_loading_profile);
708 tcase_add_test (tc_chain, test_saving_profile);
709 tcase_add_test (tc_chain, test_target_list);
712 tcase_add_unchecked_fixture (tc_chain, test_setup, test_teardown);
717 GST_CHECK_MAIN (profile);