title-source: Force format with alpha channels out of videotestsrc
authorThibault Saunier <tsaunier@gnome.org>
Sun, 27 Sep 2015 13:15:10 +0000 (15:15 +0200)
committerThibault Saunier <tsaunier@gnome.org>
Mon, 28 Sep 2015 10:07:07 +0000 (12:07 +0200)
Making sure the user can set a background of the title with an alpha
channel.

Working around https://bugzilla.gnome.org/show_bug.cgi?id=755482 for
the 1.6 branch.

ges/ges-title-source.c

index 51a4da7..02d4266 100644 (file)
@@ -231,7 +231,8 @@ ges_title_source_set_property (GObject * object,
 static GstElement *
 ges_title_source_create_source (GESTrackElement * object)
 {
-  GstElement *topbin, *background, *text;
+  GstCaps *alphacaps;
+  GstElement *topbin, *background, *text, *capsfilter;
   GstPad *src, *pad;
 
   GESTitleSource *self = GES_TITLE_SOURCE (object);
@@ -243,7 +244,11 @@ ges_title_source_create_source (GESTrackElement * object)
 
   topbin = gst_bin_new ("titlesrc-bin");
   background = gst_element_factory_make ("videotestsrc", "titlesrc-bg");
+  capsfilter = gst_element_factory_make ("capsfilter", NULL);
 
+  alphacaps =
+      gst_caps_from_string ("video/x-raw, format={AYUV, AYUV64, ARGB, ARGB64}");
+  g_object_set (capsfilter, "caps", alphacaps, NULL);
   text = gst_element_factory_make ("textoverlay", "titlsrc-text");
   if (priv->text) {
     g_object_set (text, "text", priv->text, NULL);
@@ -263,9 +268,11 @@ ges_title_source_create_source (GESTrackElement * object)
   g_object_set (background, "foreground-color", (guint) self->priv->background,
       NULL);
 
-  gst_bin_add_many (GST_BIN (topbin), background, text, NULL);
+  gst_bin_add_many (GST_BIN (topbin), background, capsfilter, text, NULL);
 
-  gst_element_link_pads_full (background, "src", text, "video_sink",
+  gst_element_link_pads_full (background, "src", capsfilter, "sink",
+      GST_PAD_LINK_CHECK_NOTHING);
+  gst_element_link_pads_full (capsfilter, "src", text, "video_sink",
       GST_PAD_LINK_CHECK_NOTHING);
 
   pad = gst_element_get_static_pad (text, "src");