| 1 |
/* GStreamer Editing Services |
| 2 |
* Copyright (C) 2016 Sjors Gielen <[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 |
#include <plugins/nle/nleobject.h> |
| 24 |
|
| 25 |
GST_START_TEST (test_tempochange) |
| 26 |
{ |
| 27 |
GESTimeline *timeline; |
| 28 |
GESLayer *layer; |
| 29 |
GESTrack *track_audio; |
| 30 |
GESEffect *effect; |
| 31 |
GESTestClip *clip; |
| 32 |
GESClip *clip2, *clip3; |
| 33 |
|
| 34 |
ges_init (); |
| 35 |
|
| 36 |
timeline = ges_timeline_new (); |
| 37 |
layer = ges_layer_new (); |
| 38 |
track_audio = GES_TRACK (ges_audio_track_new ()); |
| 39 |
|
| 40 |
ges_timeline_add_track (timeline, track_audio); |
| 41 |
ges_timeline_add_layer (timeline, layer); |
| 42 |
|
| 43 |
/* Add a 9-second clip */ |
| 44 |
clip = ges_test_clip_new (); |
| 45 |
g_object_set (clip, "duration", 9 * GST_SECOND, NULL); |
| 46 |
ges_layer_add_clip (layer, (GESClip *) clip); |
| 47 |
|
| 48 |
/* Split it after 3 seconds */ |
| 49 |
clip2 = ges_clip_split ((GESClip *) clip, 3 * GST_SECOND); |
| 50 |
|
| 51 |
/* Add pitch effect to play 1.5 times faster */ |
| 52 |
effect = ges_effect_new ("pitch tempo=1.5"); |
| 53 |
|
| 54 |
fail_unless (GES_IS_EFFECT (effect)); |
| 55 |
fail_unless (ges_container_add (GES_CONTAINER (clip2), |
| 56 |
GES_TIMELINE_ELEMENT (effect))); |
| 57 |
fail_unless (ges_track_element_get_track (GES_TRACK_ELEMENT (effect)) != |
| 58 |
NULL); |
| 59 |
|
| 60 |
assert_equals_int (GES_TRACK_ELEMENT (effect)->active, TRUE); |
| 61 |
|
| 62 |
/* Split clip again after 6 seconds (note: this is timeline time) */ |
| 63 |
clip3 = ges_clip_split (clip2, 6 * GST_SECOND); |
| 64 |
|
| 65 |
// note: start and duration are counted in timeline time, while |
| 66 |
// inpoint is counted in media time. |
| 67 |
fail_unless_equals_int64 (_START (clip), 0 * GST_SECOND); |
| 68 |
fail_unless_equals_int64 (_INPOINT (clip), 0 * GST_SECOND); |
| 69 |
fail_unless_equals_int64 (_DURATION (clip), 3 * GST_SECOND); |
| 70 |
|
| 71 |
fail_unless_equals_int64 (_START (clip2), 3 * GST_SECOND); |
| 72 |
fail_unless_equals_int64 (_INPOINT (clip2), 3 * GST_SECOND); |
| 73 |
fail_unless_equals_int64 (_DURATION (clip2), 3 * GST_SECOND); |
| 74 |
|
| 75 |
fail_unless_equals_int64 (_START (clip3), 6 * GST_SECOND); |
| 76 |
fail_unless_equals_int64 (_INPOINT (clip3), 7.5 * GST_SECOND); |
| 77 |
fail_unless_equals_int64 (_DURATION (clip3), 3 * GST_SECOND); |
| 78 |
|
| 79 |
gst_object_unref (timeline); |
| 80 |
|
| 81 |
ges_deinit (); |
| 82 |
} |
| 83 |
|
| 84 |
GST_END_TEST; |
| 85 |
|
| 86 |
static Suite * |
| 87 |
ges_suite (void) |
| 88 |
{ |
| 89 |
Suite *s = suite_create ("ges"); |
| 90 |
GstPluginFeature *pitch = gst_registry_find_feature (gst_registry_get (), |
| 91 |
"pitch", GST_TYPE_ELEMENT_FACTORY); |
| 92 |
|
| 93 |
if (pitch) { |
| 94 |
TCase *tc_chain = tcase_create ("tempochange"); |
| 95 |
gst_object_unref (pitch); |
| 96 |
|
| 97 |
suite_add_tcase (s, tc_chain); |
| 98 |
tcase_add_test (tc_chain, test_tempochange); |
| 99 |
} |
| 100 |
|
| 101 |
return s; |
| 102 |
} |
| 103 |
|
| 104 |
GST_CHECK_MAIN (ges); |