From ea2b814fba795a0b1025ce9b1a7e2a3c43cce3ff Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Mon, 16 Jun 2014 11:38:29 +0200 Subject: [PATCH] ges: Use registry to select the compositor element --- ges/ges-internal.h | 2 ++ ges/ges-smart-video-mixer.c | 4 ++-- ges/ges-utils.c | 39 +++++++++++++++++++++++++++++++++++++ ges/ges-video-transition.c | 2 +- 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/ges/ges-internal.h b/ges/ges-internal.h index 4aca1d15fe..9e557e2e2d 100644 --- a/ges/ges-internal.h +++ b/ges/ges-internal.h @@ -261,6 +261,8 @@ G_GNUC_INTERNAL gint element_start_compare (GESTimelineElement * GESTimelineElement * b); G_GNUC_INTERNAL gint element_end_compare (GESTimelineElement * a, GESTimelineElement * b); +G_GNUC_INTERNAL GstElementFactory * +ges_get_compositor_factory (void); void ges_base_xml_formatter_set_timeline_properties(GESBaseXmlFormatter * self, diff --git a/ges/ges-smart-video-mixer.c b/ges/ges-smart-video-mixer.c index bd916d0952..7b8ab152c4 100644 --- a/ges/ges-smart-video-mixer.c +++ b/ges/ges-smart-video-mixer.c @@ -209,10 +209,10 @@ static void ges_smart_mixer_init (GESSmartMixer * self) { GstPad *pad; - g_mutex_init (&self->lock); - self->mixer = gst_element_factory_make ("videomixer", "smart-mixer-mixer"); + self->mixer = gst_element_factory_create (ges_get_compositor_factory (), + "smart-mixer-mixer"); g_object_set (self->mixer, "background", 1, NULL); gst_bin_add (GST_BIN (self), self->mixer); diff --git a/ges/ges-utils.c b/ges/ges-utils.c index 487dd6c86b..d9529e280b 100644 --- a/ges/ges-utils.c +++ b/ges/ges-utils.c @@ -31,6 +31,8 @@ #include "ges-layer.h" #include "ges.h" +static GstElementFactory *compositor_factory = NULL; + /** * ges_timeline_new_audio_video: * @@ -122,3 +124,40 @@ ges_pspec_hash (gconstpointer key_spec) return h; } + +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; +} diff --git a/ges/ges-video-transition.c b/ges/ges-video-transition.c index f19eb55202..833afc6da5 100644 --- a/ges/ges-video-transition.c +++ b/ges/ges-video-transition.c @@ -311,7 +311,7 @@ ges_video_transition_create_element (GESTrackElement * object) gst_bin_add_many (GST_BIN (topbin), iconva, iconvb, oconv, NULL); - mixer = gst_element_factory_make ("videomixer", NULL); + mixer = gst_element_factory_create (ges_get_compositor_factory (), NULL); g_assert (mixer); g_object_set (G_OBJECT (mixer), "background", 1, NULL); gst_bin_add (GST_BIN (topbin), mixer);