| 1 |
/* GStreamer Editing Services |
| 2 |
* Copyright (C) 2010 Brandon Lewis <[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 |
GST_START_TEST (test_overlay_basic) |
| 25 |
{ |
| 26 |
GESTextOverlayClip *source; |
| 27 |
|
| 28 |
ges_init (); |
| 29 |
|
| 30 |
source = ges_text_overlay_clip_new (); |
| 31 |
fail_unless (source != NULL); |
| 32 |
|
| 33 |
gst_object_unref (source); |
| 34 |
|
| 35 |
ges_deinit (); |
| 36 |
} |
| 37 |
|
| 38 |
GST_END_TEST; |
| 39 |
|
| 40 |
GST_START_TEST (test_overlay_properties) |
| 41 |
{ |
| 42 |
GESClip *clip; |
| 43 |
GESTrack *track; |
| 44 |
GESTimeline *timeline; |
| 45 |
GESLayer *layer; |
| 46 |
GESTrackElement *trackelement; |
| 47 |
|
| 48 |
ges_init (); |
| 49 |
|
| 50 |
track = ges_track_new (GES_TRACK_TYPE_VIDEO, gst_caps_ref (GST_CAPS_ANY)); |
| 51 |
fail_unless (track != NULL); |
| 52 |
layer = ges_layer_new (); |
| 53 |
fail_unless (layer != NULL); |
| 54 |
timeline = ges_timeline_new (); |
| 55 |
fail_unless (timeline != NULL); |
| 56 |
fail_unless (ges_timeline_add_layer (timeline, layer)); |
| 57 |
fail_unless (ges_timeline_add_track (timeline, track)); |
| 58 |
ASSERT_OBJECT_REFCOUNT (timeline, "timeline", 1); |
| 59 |
|
| 60 |
clip = (GESClip *) ges_text_overlay_clip_new (); |
| 61 |
fail_unless (clip != NULL); |
| 62 |
|
| 63 |
/* Set some properties */ |
| 64 |
g_object_set (clip, "start", (guint64) 42, "duration", (guint64) 51, |
| 65 |
"in-point", (guint64) 12, NULL); |
| 66 |
assert_equals_uint64 (_START (clip), 42); |
| 67 |
assert_equals_uint64 (_DURATION (clip), 51); |
| 68 |
assert_equals_uint64 (_INPOINT (clip), 12); |
| 69 |
|
| 70 |
ges_layer_add_clip (layer, GES_CLIP (clip)); |
| 71 |
ges_timeline_commit (timeline); |
| 72 |
assert_equals_int (g_list_length (GES_CONTAINER_CHILDREN (clip)), 1); |
| 73 |
trackelement = GES_CONTAINER_CHILDREN (clip)->data; |
| 74 |
fail_unless (trackelement != NULL); |
| 75 |
fail_unless (GES_TIMELINE_ELEMENT_PARENT (trackelement) == |
| 76 |
GES_TIMELINE_ELEMENT (clip)); |
| 77 |
fail_unless (ges_track_element_get_track (trackelement) == track); |
| 78 |
|
| 79 |
/* Check that trackelement has the same properties */ |
| 80 |
assert_equals_uint64 (_START (trackelement), 42); |
| 81 |
assert_equals_uint64 (_DURATION (trackelement), 51); |
| 82 |
/* in-point is 0 since it does not have has-internal-source */ |
| 83 |
assert_equals_uint64 (_INPOINT (trackelement), 0); |
| 84 |
|
| 85 |
/* And let's also check that it propagated correctly to GNonLin */ |
| 86 |
nle_object_check (ges_track_element_get_nleobject (trackelement), 42, 51, 0, |
| 87 |
51, MIN_NLE_PRIO + TRANSITIONS_HEIGHT, TRUE); |
| 88 |
|
| 89 |
/* Change more properties, see if they propagate */ |
| 90 |
g_object_set (clip, "start", (guint64) 420, "duration", (guint64) 510, |
| 91 |
"in-point", (guint64) 120, NULL); |
| 92 |
ges_timeline_commit (timeline); |
| 93 |
assert_equals_uint64 (_START (clip), 420); |
| 94 |
assert_equals_uint64 (_DURATION (clip), 510); |
| 95 |
assert_equals_uint64 (_INPOINT (clip), 120); |
| 96 |
assert_equals_uint64 (_START (trackelement), 420); |
| 97 |
assert_equals_uint64 (_DURATION (trackelement), 510); |
| 98 |
assert_equals_uint64 (_INPOINT (trackelement), 0); |
| 99 |
|
| 100 |
/* And let's also check that it propagated correctly to GNonLin */ |
| 101 |
nle_object_check (ges_track_element_get_nleobject (trackelement), 420, 510, |
| 102 |
0, 510, MIN_NLE_PRIO + TRANSITIONS_HEIGHT + 0, TRUE); |
| 103 |
|
| 104 |
ges_container_remove (GES_CONTAINER (clip), |
| 105 |
GES_TIMELINE_ELEMENT (trackelement)); |
| 106 |
gst_object_unref (timeline); |
| 107 |
|
| 108 |
ges_deinit (); |
| 109 |
} |
| 110 |
|
| 111 |
GST_END_TEST; |
| 112 |
|
| 113 |
GST_START_TEST (test_overlay_in_layer) |
| 114 |
{ |
| 115 |
GESTimeline *timeline; |
| 116 |
GESLayer *layer; |
| 117 |
GESTrack *a, *v; |
| 118 |
GESTrackElement *track_element; |
| 119 |
GESTextOverlayClip *source; |
| 120 |
gchar *text; |
| 121 |
gint halign, valign; |
| 122 |
guint32 color; |
| 123 |
gdouble xpos; |
| 124 |
gdouble ypos; |
| 125 |
|
| 126 |
ges_init (); |
| 127 |
|
| 128 |
timeline = ges_timeline_new (); |
| 129 |
layer = (GESLayer *) ges_layer_new (); |
| 130 |
a = GES_TRACK (ges_audio_track_new ()); |
| 131 |
v = GES_TRACK (ges_video_track_new ()); |
| 132 |
|
| 133 |
ges_timeline_add_track (timeline, a); |
| 134 |
ges_timeline_add_track (timeline, v); |
| 135 |
ges_timeline_add_layer (timeline, layer); |
| 136 |
|
| 137 |
source = ges_text_overlay_clip_new (); |
| 138 |
|
| 139 |
g_object_set (source, "duration", (guint64) GST_SECOND, NULL); |
| 140 |
|
| 141 |
ges_layer_add_clip (layer, (GESClip *) source); |
| 142 |
|
| 143 |
/* specifically test the text property */ |
| 144 |
g_object_set (source, "text", (gchar *) "some text", NULL); |
| 145 |
g_object_get (source, "text", &text, NULL); |
| 146 |
assert_equals_string ("some text", text); |
| 147 |
g_free (text); |
| 148 |
|
| 149 |
track_element = |
| 150 |
ges_clip_find_track_element (GES_CLIP (source), v, G_TYPE_NONE); |
| 151 |
|
| 152 |
/* test the font-desc property */ |
| 153 |
g_object_set (source, "font-desc", (gchar *) "sans 72", NULL); |
| 154 |
g_object_get (source, "font-desc", &text, NULL); |
| 155 |
assert_equals_string ("sans 72", text); |
| 156 |
g_free (text); |
| 157 |
|
| 158 |
assert_equals_string ("sans 72", |
| 159 |
ges_text_overlay_get_font_desc (GES_TEXT_OVERLAY (track_element))); |
| 160 |
|
| 161 |
/* test halign and valign */ |
| 162 |
g_object_set (source, "halignment", (gint) |
| 163 |
GES_TEXT_HALIGN_LEFT, "valignment", (gint) GES_TEXT_VALIGN_TOP, NULL); |
| 164 |
g_object_get (source, "halignment", &halign, "valignment", &valign, NULL); |
| 165 |
assert_equals_int (halign, GES_TEXT_HALIGN_LEFT); |
| 166 |
assert_equals_int (valign, GES_TEXT_VALIGN_TOP); |
| 167 |
|
| 168 |
halign = ges_text_overlay_get_halignment (GES_TEXT_OVERLAY (track_element)); |
| 169 |
valign = ges_text_overlay_get_valignment (GES_TEXT_OVERLAY (track_element)); |
| 170 |
assert_equals_int (halign, GES_TEXT_HALIGN_LEFT); |
| 171 |
assert_equals_int (valign, GES_TEXT_VALIGN_TOP); |
| 172 |
|
| 173 |
/* test color */ |
| 174 |
g_object_set (source, "color", (gint) 2147483647, NULL); |
| 175 |
g_object_get (source, "color", &color, NULL); |
| 176 |
assert_equals_int (color, 2147483647); |
| 177 |
|
| 178 |
color = ges_text_overlay_get_color (GES_TEXT_OVERLAY (track_element)); |
| 179 |
assert_equals_int (color, 2147483647); |
| 180 |
|
| 181 |
/* test xpos */ |
| 182 |
g_object_set (source, "xpos", (gdouble) 0.5, NULL); |
| 183 |
g_object_get (source, "xpos", &xpos, NULL); |
| 184 |
assert_equals_float (xpos, 0.5); |
| 185 |
|
| 186 |
xpos = ges_text_overlay_get_xpos (GES_TEXT_OVERLAY (track_element)); |
| 187 |
assert_equals_float (xpos, 0.5); |
| 188 |
|
| 189 |
/* test ypos */ |
| 190 |
g_object_set (source, "ypos", (gdouble) 0.33, NULL); |
| 191 |
g_object_get (source, "ypos", &ypos, NULL); |
| 192 |
assert_equals_float (ypos, 0.33); |
| 193 |
|
| 194 |
ypos = ges_text_overlay_get_ypos (GES_TEXT_OVERLAY (track_element)); |
| 195 |
assert_equals_float (ypos, 0.33); |
| 196 |
|
| 197 |
GST_DEBUG ("removing the source"); |
| 198 |
|
| 199 |
ges_layer_remove_clip (layer, (GESClip *) source); |
| 200 |
|
| 201 |
GST_DEBUG ("removing the layer"); |
| 202 |
|
| 203 |
gst_object_unref (track_element); |
| 204 |
gst_object_unref (timeline); |
| 205 |
|
| 206 |
ges_deinit (); |
| 207 |
} |
| 208 |
|
| 209 |
GST_END_TEST; |
| 210 |
|
| 211 |
static Suite * |
| 212 |
ges_suite (void) |
| 213 |
{ |
| 214 |
Suite *s = suite_create ("ges-overlays"); |
| 215 |
TCase *tc_chain = tcase_create ("overlays"); |
| 216 |
|
| 217 |
suite_add_tcase (s, tc_chain); |
| 218 |
|
| 219 |
tcase_add_test (tc_chain, test_overlay_basic); |
| 220 |
tcase_add_test (tc_chain, test_overlay_properties); |
| 221 |
tcase_add_test (tc_chain, test_overlay_in_layer); |
| 222 |
|
| 223 |
return s; |
| 224 |
} |
| 225 |
|
| 226 |
GST_CHECK_MAIN (ges); |