2012-09-10 00:25:54 +00:00
|
|
|
/* GStreamer Editing Services
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Volodymyr Rudyi <vladimir.rudoy@gmail.com>
|
2015-11-20 22:33:12 +00:00
|
|
|
* Copyright (C) 2015 Thibault Saunier <tsaunier@gnome.org>
|
2012-09-10 00:25:54 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2015-11-20 22:33:12 +00:00
|
|
|
#include "test-utils.h"
|
|
|
|
#include "../../../ges/ges-internal.h"
|
2012-09-10 00:25:54 +00:00
|
|
|
#include <ges/ges.h>
|
|
|
|
#include <gst/check/gstcheck.h>
|
|
|
|
|
|
|
|
static GMainLoop *mainloop;
|
|
|
|
|
|
|
|
static void
|
|
|
|
source_asset_created (GObject * source, GAsyncResult * res, gpointer udata)
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
GESAsset *a = ges_asset_request_finish (res, &error);
|
|
|
|
|
|
|
|
fail_unless (a == NULL);
|
|
|
|
assert_equals_int (error->domain, GST_RESOURCE_ERROR);
|
|
|
|
|
2019-01-12 15:12:42 +00:00
|
|
|
g_clear_error (&error);
|
2012-09-10 00:25:54 +00:00
|
|
|
g_main_loop_quit (mainloop);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_START_TEST (test_basic)
|
|
|
|
{
|
|
|
|
ges_init ();
|
|
|
|
|
|
|
|
mainloop = g_main_loop_new (NULL, FALSE);
|
2013-01-20 15:44:57 +00:00
|
|
|
ges_asset_request_async (GES_TYPE_URI_CLIP,
|
2012-09-10 00:25:54 +00:00
|
|
|
"file:///this/is/not/for/real", NULL, source_asset_created, NULL);
|
|
|
|
|
|
|
|
g_main_loop_run (mainloop);
|
|
|
|
g_main_loop_unref (mainloop);
|
2019-01-28 02:24:29 +00:00
|
|
|
ges_deinit ();
|
2012-09-10 00:25:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2015-11-20 22:33:12 +00:00
|
|
|
GST_START_TEST (test_transition_change_asset)
|
2012-09-10 00:25:54 +00:00
|
|
|
{
|
|
|
|
gchar *id;
|
|
|
|
GESAsset *a;
|
|
|
|
GESExtractable *extractable;
|
|
|
|
|
|
|
|
ges_init ();
|
|
|
|
|
2013-01-25 18:16:21 +00:00
|
|
|
a = ges_asset_request (GES_TYPE_TRANSITION_CLIP, "box-wipe-lc", NULL);
|
2012-09-10 00:25:54 +00:00
|
|
|
|
|
|
|
fail_unless (GES_IS_ASSET (a));
|
|
|
|
fail_unless_equals_string (ges_asset_get_id (a), "box-wipe-lc");
|
|
|
|
|
|
|
|
extractable = ges_asset_extract (a, NULL);
|
|
|
|
fail_unless (ges_extractable_get_asset (extractable) == a);
|
|
|
|
|
|
|
|
id = ges_extractable_get_id (extractable);
|
|
|
|
fail_unless_equals_string (id, "box-wipe-lc");
|
|
|
|
g_free (id);
|
|
|
|
|
|
|
|
g_object_set (extractable, "vtype", 2, NULL);
|
|
|
|
|
|
|
|
id = ges_extractable_get_id (extractable);
|
|
|
|
fail_unless_equals_string (id, "bar-wipe-tb");
|
|
|
|
g_free (id);
|
|
|
|
|
|
|
|
fail_if (ges_extractable_get_asset (extractable) == a);
|
|
|
|
gst_object_unref (a);
|
|
|
|
|
|
|
|
a = ges_extractable_get_asset (extractable);
|
|
|
|
fail_unless_equals_string (ges_asset_get_id (a), "bar-wipe-tb");
|
|
|
|
|
|
|
|
/* Now try to set the a and see if the vtype is properly updated */
|
2013-01-25 18:16:21 +00:00
|
|
|
a = ges_asset_request (GES_TYPE_TRANSITION_CLIP, "box-wipe-lc", NULL);
|
2012-09-10 00:25:54 +00:00
|
|
|
ges_extractable_set_asset (extractable, a);
|
2019-01-12 15:12:42 +00:00
|
|
|
gst_object_unref (a);
|
|
|
|
|
2013-01-25 18:16:21 +00:00
|
|
|
fail_unless_equals_int (GES_TRANSITION_CLIP (extractable)->vtype, 26);
|
2012-09-10 00:25:54 +00:00
|
|
|
|
|
|
|
gst_object_unref (extractable);
|
2019-01-28 02:24:29 +00:00
|
|
|
ges_deinit ();
|
2012-09-10 00:25:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2015-11-20 22:33:12 +00:00
|
|
|
GST_START_TEST (test_uri_clip_change_asset)
|
|
|
|
{
|
|
|
|
GESAsset *asset, *asset1;
|
|
|
|
GESExtractable *extractable;
|
2019-01-28 02:24:29 +00:00
|
|
|
GESLayer *layer;
|
|
|
|
gchar *uri;
|
|
|
|
gchar *uri1;
|
|
|
|
GESTimeline *timeline;
|
2015-11-20 22:33:12 +00:00
|
|
|
|
|
|
|
ges_init ();
|
|
|
|
|
2019-01-28 02:24:29 +00:00
|
|
|
layer = ges_layer_new ();
|
|
|
|
uri = ges_test_file_uri ("audio_video.ogg");
|
|
|
|
uri1 = ges_test_file_uri ("audio_only.ogg");
|
|
|
|
timeline = ges_timeline_new_audio_video ();
|
|
|
|
|
|
|
|
ges_timeline_add_layer (timeline, layer);
|
|
|
|
|
2015-11-20 22:33:12 +00:00
|
|
|
asset = GES_ASSET (ges_uri_clip_asset_request_sync (uri, NULL));
|
|
|
|
|
|
|
|
fail_unless (GES_IS_ASSET (asset));
|
|
|
|
fail_unless_equals_string (ges_asset_get_id (asset), uri);
|
|
|
|
|
|
|
|
extractable = GES_EXTRACTABLE (ges_layer_add_asset (layer,
|
|
|
|
asset, 0, 0, GST_CLOCK_TIME_NONE, GES_TRACK_TYPE_UNKNOWN));
|
|
|
|
fail_unless (ges_extractable_get_asset (extractable) == asset);
|
|
|
|
gst_object_unref (asset);
|
|
|
|
|
|
|
|
/* Now try to set the a and see if the vtype is properly updated */
|
|
|
|
asset1 = GES_ASSET (ges_uri_clip_asset_request_sync (uri1, NULL));
|
|
|
|
fail_unless_equals_int (g_list_length (GES_CONTAINER_CHILDREN (extractable)),
|
|
|
|
2);
|
|
|
|
fail_unless (ges_extractable_set_asset (extractable, asset1));
|
|
|
|
fail_unless_equals_int (g_list_length (GES_CONTAINER_CHILDREN (extractable)),
|
|
|
|
1);
|
|
|
|
|
|
|
|
gst_object_unref (extractable);
|
2017-12-20 13:28:33 +00:00
|
|
|
|
|
|
|
g_free (uri);
|
|
|
|
g_free (uri1);
|
2019-01-28 02:24:29 +00:00
|
|
|
|
|
|
|
ges_deinit ();
|
2015-11-20 22:33:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2012-09-10 00:25:54 +00:00
|
|
|
GST_START_TEST (test_list_asset)
|
|
|
|
{
|
|
|
|
GList *assets;
|
|
|
|
GEnumClass *enum_class;
|
2019-01-28 02:24:29 +00:00
|
|
|
|
|
|
|
ges_init ();
|
|
|
|
|
2012-09-10 00:25:54 +00:00
|
|
|
enum_class = g_type_class_peek (GES_VIDEO_STANDARD_TRANSITION_TYPE_TYPE);
|
|
|
|
|
|
|
|
fail_unless (ges_init ());
|
2013-01-17 03:49:43 +00:00
|
|
|
fail_if (ges_list_assets (GES_TYPE_OVERLAY_CLIP));
|
2012-09-10 00:25:54 +00:00
|
|
|
|
2013-01-25 18:16:21 +00:00
|
|
|
assets = ges_list_assets (GES_TYPE_TRANSITION_CLIP);
|
2012-09-10 00:25:54 +00:00
|
|
|
/* note: we do not have a a for value=0 "Transition not set" */
|
|
|
|
assert_equals_int (g_list_length (assets), enum_class->n_values - 1);
|
|
|
|
g_list_free (assets);
|
2019-01-28 02:24:29 +00:00
|
|
|
|
|
|
|
ges_deinit ();
|
2012-09-10 00:25:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_proxy_asset)
|
|
|
|
{
|
|
|
|
GESAsset *identity, *nothing, *nothing_at_all;
|
|
|
|
|
|
|
|
fail_unless (ges_init ());
|
|
|
|
|
2016-01-25 14:57:22 +00:00
|
|
|
identity = ges_asset_request (GES_TYPE_EFFECT, "video identity", NULL);
|
2012-09-10 00:25:54 +00:00
|
|
|
fail_unless (identity != NULL);
|
|
|
|
|
2013-01-26 15:40:51 +00:00
|
|
|
nothing = ges_asset_request (GES_TYPE_EFFECT, "nothing", NULL);
|
2012-09-10 00:25:54 +00:00
|
|
|
fail_if (nothing);
|
|
|
|
|
2013-01-26 15:40:51 +00:00
|
|
|
nothing = ges_asset_cache_lookup (GES_TYPE_EFFECT, "nothing");
|
2012-09-10 00:25:54 +00:00
|
|
|
fail_unless (nothing != NULL);
|
|
|
|
|
2016-01-25 14:57:22 +00:00
|
|
|
fail_unless (ges_asset_try_proxy (nothing, "video identity"));
|
2015-11-20 22:33:12 +00:00
|
|
|
fail_unless (ges_asset_set_proxy (NULL, identity));
|
2012-09-10 00:25:54 +00:00
|
|
|
|
2013-01-26 15:40:51 +00:00
|
|
|
nothing_at_all = ges_asset_request (GES_TYPE_EFFECT, "nothing_at_all", NULL);
|
2012-09-10 00:25:54 +00:00
|
|
|
fail_if (nothing_at_all);
|
|
|
|
|
2013-01-26 15:40:51 +00:00
|
|
|
nothing_at_all = ges_asset_cache_lookup (GES_TYPE_EFFECT, "nothing_at_all");
|
2012-09-10 00:25:54 +00:00
|
|
|
fail_unless (nothing_at_all != NULL);
|
|
|
|
|
|
|
|
/* Now we proxy nothing_at_all to nothing which is itself proxied to identity */
|
2015-11-20 22:33:12 +00:00
|
|
|
fail_unless (ges_asset_try_proxy (nothing_at_all, "nothing"));
|
|
|
|
fail_unless (ges_asset_set_proxy (NULL, nothing));
|
|
|
|
fail_unless_equals_int (g_list_length (ges_asset_list_proxies
|
|
|
|
(nothing_at_all)), 1);
|
|
|
|
|
|
|
|
fail_unless_equals_pointer (ges_asset_get_proxy_target (nothing),
|
|
|
|
nothing_at_all);
|
2012-09-10 00:25:54 +00:00
|
|
|
|
|
|
|
/* If we request nothing_at_all we should get the good proxied identity */
|
2013-01-26 15:40:51 +00:00
|
|
|
nothing_at_all = ges_asset_request (GES_TYPE_EFFECT, "nothing_at_all", NULL);
|
2012-09-10 00:25:54 +00:00
|
|
|
fail_unless (nothing_at_all == identity);
|
|
|
|
|
|
|
|
gst_object_unref (identity);
|
|
|
|
gst_object_unref (nothing_at_all);
|
2019-01-28 02:24:29 +00:00
|
|
|
|
|
|
|
ges_deinit ();
|
2012-09-10 00:25:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
static Suite *
|
|
|
|
ges_suite (void)
|
|
|
|
{
|
|
|
|
Suite *s = suite_create ("ges");
|
|
|
|
TCase *tc_chain = tcase_create ("a");
|
|
|
|
|
|
|
|
suite_add_tcase (s, tc_chain);
|
|
|
|
|
|
|
|
/* Must be first until we implement deinit */
|
|
|
|
tcase_add_test (tc_chain, test_list_asset);
|
|
|
|
tcase_add_test (tc_chain, test_basic);
|
2015-11-20 22:33:12 +00:00
|
|
|
tcase_add_test (tc_chain, test_transition_change_asset);
|
|
|
|
tcase_add_test (tc_chain, test_uri_clip_change_asset);
|
2012-09-10 00:25:54 +00:00
|
|
|
tcase_add_test (tc_chain, test_proxy_asset);
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2013-05-28 02:10:03 +00:00
|
|
|
GST_CHECK_MAIN (ges);
|