Debian Codegraph @

tests/check/ges/track.c

raw
1 /* GStreamer Editing Services
2 * Copyright (C) 2014 Mathieu Duponchelle <[email protected]>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library 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 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #include "test-utils.h"
21 #include <ges/ges.h>
22 #include <gst/check/gstcheck.h>
23
24 static gboolean
25 compare_caps_from_string (GstCaps * caps, const gchar * desc)
26 {
27 GstCaps *new_caps = gst_caps_from_string (desc);
28 gboolean ret = TRUE;
29
30 if (!gst_caps_is_strictly_equal (caps, new_caps))
31 ret = FALSE;
32
33 gst_caps_unref (new_caps);
34 return ret;
35 }
36
37 GST_START_TEST (test_update_restriction_caps)
38 {
39 GESTrack *track;
40 GstCaps *original;
41 GstCaps *new;
42 GstCaps *current;
43
44 ges_init ();
45
46 track = GES_TRACK (ges_audio_track_new ());
47
48 original = gst_caps_from_string ("audio/x-raw, format=S32LE");
49 ges_track_set_restriction_caps (track, original);
50
51 new = gst_caps_from_string ("audio/x-raw, format=S16LE, width=720");
52 ges_track_update_restriction_caps (track, new);
53 g_object_get (track, "restriction-caps", &current, NULL);
54
55 /* Assuming the format for to_string doesn't change */
56 fail_unless (compare_caps_from_string (current,
57 "audio/x-raw, format=(string)S16LE, width=(int)720"));
58
59 gst_caps_unref (new);
60 new = gst_caps_from_string ("audio/x-raw, width=360");
61 ges_track_update_restriction_caps (track, new);
62 gst_caps_unref (current);
63 g_object_get (track, "restriction-caps", &current, NULL);
64 fail_unless (compare_caps_from_string (current,
65 "audio/x-raw, format=(string)S16LE, width=(int)360"));
66
67 gst_caps_append_structure (new,
68 gst_structure_new_from_string ("audio/x-raw, format=S16LE"));
69 ges_track_update_restriction_caps (track, new);
70 gst_caps_unref (current);
71 g_object_get (track, "restriction-caps", &current, NULL);
72 fail_unless (compare_caps_from_string (current,
73 "audio/x-raw, format=(string)S16LE, width=(int)360; audio/x-raw, format=S16LE"));
74
75 gst_caps_unref (new);
76 new =
77 gst_caps_from_string
78 ("audio/x-raw, width=240; audio/x-raw, format=S32LE");
79 ges_track_update_restriction_caps (track, new);
80 gst_caps_unref (current);
81 g_object_get (track, "restriction-caps", &current, NULL);
82 fail_unless (compare_caps_from_string (current,
83 "audio/x-raw, format=(string)S16LE, width=(int)240; audio/x-raw, format=S32LE"));
84
85 gst_caps_unref (new);
86 gst_caps_unref (original);
87 gst_caps_unref (current);
88
89 ges_deinit ();
90 }
91
92 GST_END_TEST;
93
94 static Suite *
95 ges_suite (void)
96 {
97 Suite *s = suite_create ("ges-track");
98 TCase *tc_chain = tcase_create ("track");
99
100 suite_add_tcase (s, tc_chain);
101
102 tcase_add_test (tc_chain, test_update_restriction_caps);
103
104 return s;
105 }
106
107 GST_CHECK_MAIN (ges);