2010-05-20 08:44:01 +00:00
|
|
|
/* GStreamer Editing Services
|
|
|
|
* Copyright (C) 2010 Edward Hervey <edward.hervey@collabora.co.uk>
|
|
|
|
*
|
|
|
|
* 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
|
2012-11-04 00:25:20 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2010-05-20 08:44:01 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:ges-utils
|
|
|
|
* @short_description: Convenience methods
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2013-05-16 06:10:35 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2010-05-20 08:44:01 +00:00
|
|
|
#include "ges-internal.h"
|
|
|
|
#include "ges-timeline.h"
|
|
|
|
#include "ges-track.h"
|
2013-04-23 23:04:04 +00:00
|
|
|
#include "ges-layer.h"
|
2010-05-20 08:44:01 +00:00
|
|
|
#include "ges.h"
|
|
|
|
|
2014-06-16 09:38:29 +00:00
|
|
|
static GstElementFactory *compositor_factory = NULL;
|
|
|
|
|
2010-07-06 14:26:26 +00:00
|
|
|
/**
|
|
|
|
* ges_timeline_new_audio_video:
|
|
|
|
*
|
2011-01-11 16:55:25 +00:00
|
|
|
* Creates a new #GESTimeline containing a raw audio and a
|
2010-07-06 14:26:26 +00:00
|
|
|
* raw video track.
|
|
|
|
*
|
2012-07-29 01:45:03 +00:00
|
|
|
* Returns: The newly created #GESTimeline.
|
2010-07-06 14:26:26 +00:00
|
|
|
*/
|
|
|
|
|
2010-05-20 08:44:01 +00:00
|
|
|
GESTimeline *
|
|
|
|
ges_timeline_new_audio_video (void)
|
|
|
|
{
|
|
|
|
GESTrack *tracka, *trackv;
|
|
|
|
GESTimeline *timeline;
|
|
|
|
|
|
|
|
/* This is our main GESTimeline */
|
|
|
|
timeline = ges_timeline_new ();
|
|
|
|
|
2013-03-28 17:51:45 +00:00
|
|
|
tracka = GES_TRACK (ges_audio_track_new ());
|
|
|
|
trackv = GES_TRACK (ges_video_track_new ());
|
2010-05-20 08:44:01 +00:00
|
|
|
|
|
|
|
if (!ges_timeline_add_track (timeline, trackv) ||
|
|
|
|
!ges_timeline_add_track (timeline, tracka)) {
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (timeline);
|
2010-05-20 08:44:01 +00:00
|
|
|
timeline = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return timeline;
|
|
|
|
}
|
2013-01-10 14:15:32 +00:00
|
|
|
|
|
|
|
/* Internal utilities */
|
|
|
|
gint
|
2013-01-15 13:52:17 +00:00
|
|
|
element_start_compare (GESTimelineElement * a, GESTimelineElement * b)
|
2013-01-10 14:15:32 +00:00
|
|
|
{
|
|
|
|
if (a->start == b->start) {
|
|
|
|
if (a->priority < b->priority)
|
|
|
|
return -1;
|
|
|
|
if (a->priority > b->priority)
|
|
|
|
return 1;
|
|
|
|
if (a->duration < b->duration)
|
|
|
|
return -1;
|
|
|
|
if (a->duration > b->duration)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
2013-03-23 04:33:39 +00:00
|
|
|
} else if (a->start < b->start)
|
2013-01-10 14:15:32 +00:00
|
|
|
return -1;
|
2013-03-23 04:33:39 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
element_end_compare (GESTimelineElement * a, GESTimelineElement * b)
|
|
|
|
{
|
|
|
|
if (GES_TIMELINE_ELEMENT_END (a) == GES_TIMELINE_ELEMENT_END (b)) {
|
|
|
|
if (a->priority < b->priority)
|
|
|
|
return -1;
|
|
|
|
if (a->priority > b->priority)
|
|
|
|
return 1;
|
|
|
|
if (a->duration < b->duration)
|
|
|
|
return -1;
|
|
|
|
if (a->duration > b->duration)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
} else if (GES_TIMELINE_ELEMENT_END (a) < (GES_TIMELINE_ELEMENT_END (b)))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 1;
|
2013-01-10 14:15:32 +00:00
|
|
|
}
|
2013-05-16 06:10:35 +00:00
|
|
|
|
|
|
|
gboolean
|
2013-11-13 12:18:00 +00:00
|
|
|
ges_pspec_equal (gconstpointer key_spec_1, gconstpointer key_spec_2)
|
2013-05-16 06:10:35 +00:00
|
|
|
{
|
|
|
|
const GParamSpec *key1 = key_spec_1;
|
|
|
|
const GParamSpec *key2 = key_spec_2;
|
|
|
|
|
|
|
|
return (key1->owner_type == key2->owner_type &&
|
|
|
|
strcmp (key1->name, key2->name) == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
guint
|
2013-11-13 12:18:00 +00:00
|
|
|
ges_pspec_hash (gconstpointer key_spec)
|
2013-05-16 06:10:35 +00:00
|
|
|
{
|
|
|
|
const GParamSpec *key = key_spec;
|
|
|
|
const gchar *p;
|
|
|
|
guint h = key->owner_type;
|
|
|
|
|
|
|
|
for (p = key->name; *p; p++)
|
|
|
|
h = (h << 5) - h + *p;
|
|
|
|
|
|
|
|
return h;
|
|
|
|
}
|
2014-06-16 09:38:29 +00:00
|
|
|
|
|
|
|
static gboolean
|
|
|
|
find_compositor (GstPluginFeatureFilter * feature, gpointer udata)
|
|
|
|
{
|
|
|
|
const gchar *klass;
|
|
|
|
|
|
|
|
if (G_UNLIKELY (!GST_IS_ELEMENT_FACTORY (feature)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
klass = gst_element_factory_get_metadata (GST_ELEMENT_FACTORY_CAST (feature),
|
|
|
|
GST_ELEMENT_METADATA_KLASS);
|
|
|
|
|
|
|
|
return (strstr (klass, "Compositor") != NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GstElementFactory *
|
|
|
|
ges_get_compositor_factory (void)
|
|
|
|
{
|
|
|
|
GList *result;
|
|
|
|
|
|
|
|
if (compositor_factory)
|
|
|
|
return compositor_factory;
|
|
|
|
|
|
|
|
result = gst_registry_feature_filter (gst_registry_get (),
|
|
|
|
(GstPluginFeatureFilter) find_compositor, FALSE, NULL);
|
|
|
|
|
|
|
|
/* sort on rank and name */
|
|
|
|
result = g_list_sort (result, gst_plugin_feature_rank_compare_func);
|
|
|
|
g_assert (result);
|
|
|
|
|
|
|
|
compositor_factory = result->data;
|
|
|
|
gst_plugin_feature_list_free (result);
|
|
|
|
|
|
|
|
return compositor_factory;
|
|
|
|
}
|