1 | /* |
---|
2 | * Copyright (C) 2004 Benjamin Otte <in7y118@public.uni-hamburg.de> |
---|
3 | * |
---|
4 | * This library is free software; you can redistribute it and/or |
---|
5 | * modify it under the terms of the GNU General Public |
---|
6 | * License as published by the Free Software Foundation; either |
---|
7 | * version 2 of the License, or (at your option) any later version. |
---|
8 | * |
---|
9 | * This library is distributed in the hope that it will be useful, |
---|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
12 | * General Public License for more details. |
---|
13 | * |
---|
14 | * You should have received a copy of the GNU General Public |
---|
15 | * License along with this library; if not, write to the Free |
---|
16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
17 | */ |
---|
18 | |
---|
19 | #include <gst/gst.h> |
---|
20 | #include <string.h> |
---|
21 | #include "caps.h" |
---|
22 | |
---|
23 | static void |
---|
24 | check_caps (const gchar * eins, const gchar * zwei) |
---|
25 | { |
---|
26 | GstCaps *one, *two, *test, *test2, *test3, *test4; |
---|
27 | |
---|
28 | one = gst_caps_from_string (eins); |
---|
29 | two = gst_caps_from_string (zwei); |
---|
30 | g_print (" A = %u\n", strlen (eins)); |
---|
31 | g_print (" B = %u\n", strlen (zwei)); |
---|
32 | |
---|
33 | test = gst_caps_intersect (one, two); |
---|
34 | if (gst_caps_is_equal (one, two)) { |
---|
35 | g_print (" EQUAL\n\n"); |
---|
36 | g_assert (gst_caps_is_equal (one, test)); |
---|
37 | g_assert (gst_caps_is_equal (two, test)); |
---|
38 | } else if (!gst_caps_is_any (one) || gst_caps_is_empty (two)) { |
---|
39 | test2 = gst_caps_subtract (one, test); |
---|
40 | g_print (" A - B = %u\n", strlen (gst_caps_to_string (test2))); |
---|
41 | /* test2 = one - (one A two) = one - two */ |
---|
42 | test3 = gst_caps_intersect (test2, two); |
---|
43 | g_print (" empty = %s\n", gst_caps_to_string (test3)); |
---|
44 | g_assert (gst_caps_is_empty (test3)); |
---|
45 | gst_caps_free (test3); |
---|
46 | test3 = gst_caps_union (test2, two); |
---|
47 | g_print (" A + B = %u\n", strlen (gst_caps_to_string (test3))); |
---|
48 | /* test3 = one - two + two = one + two */ |
---|
49 | g_print (" A + B = %s\n", gst_caps_to_string (gst_caps_subtract (one, |
---|
50 | test3))); |
---|
51 | g_assert (gst_caps_is_subset (one, test3)); |
---|
52 | test4 = gst_caps_union (one, two); |
---|
53 | g_assert (gst_caps_is_equal (test3, test4)); |
---|
54 | g_print (" NOT EQUAL\n\n"); |
---|
55 | gst_caps_free (test2); |
---|
56 | gst_caps_free (test3); |
---|
57 | gst_caps_free (test4); |
---|
58 | } else { |
---|
59 | g_print (" ANY CAPS\n\n"); |
---|
60 | } |
---|
61 | gst_caps_free (test); |
---|
62 | gst_caps_free (two); |
---|
63 | gst_caps_free (one); |
---|
64 | } |
---|
65 | |
---|
66 | gint |
---|
67 | main (gint argc, gchar ** argv) |
---|
68 | { |
---|
69 | guint i, j; |
---|
70 | |
---|
71 | gst_init (&argc, &argv); |
---|
72 | |
---|
73 | for (i = 0; i < G_N_ELEMENTS (caps_list); i++) { |
---|
74 | for (j = 0; j < G_N_ELEMENTS (caps_list); j++) { |
---|
75 | g_print ("%u - %u\n", i, j); |
---|
76 | check_caps (caps_list[i], caps_list[j]); |
---|
77 | } |
---|
78 | } |
---|
79 | |
---|
80 | return 0; |
---|
81 | } |
---|