[cheese] svg overlay effects can now be added



commit 364fb9316a5bb1dd7c396c932f3dc5ba9d9bc5a1
Author: Laura Lucas Alday <lauralucasalday gmail com>
Date:   Tue Jan 25 19:06:20 2011 -0300

    svg overlay effects can now be added

 libcheese/cheese-camera.c |   21 ++++++++++++++++++---
 src/cheese-window.vala    |    9 ++++-----
 2 files changed, 22 insertions(+), 8 deletions(-)
---
diff --git a/libcheese/cheese-camera.c b/libcheese/cheese-camera.c
index b66c274..f74b948 100644
--- a/libcheese/cheese-camera.c
+++ b/libcheese/cheese-camera.c
@@ -624,16 +624,19 @@ cheese_camera_element_from_effect (CheeseCamera *camera, CheeseEffect *effect)
   GstElement *effect_filter;
   GError     *err = NULL;
   char       *effect_desc;
+  GstElement *colorspace1;
+  GstElement *colorspace2;
+  GstPad     *pad;
 
   g_object_get (G_OBJECT (effect),
                 "pipeline_desc", &effect_desc,
                 "name", &name, NULL);
 
-  effects_pipeline_desc = g_strconcat ("ffmpegcolorspace ! ",
+  effects_pipeline_desc = g_strconcat ("ffmpegcolorspace name=colorspace1 ! ",
                                        effect_desc,
-                                       " ! ffmpegcolorspace",
+                                       " ! ffmpegcolorspace name=colorspace2",
                                        NULL);
-  effect_filter = gst_parse_bin_from_description (effects_pipeline_desc, TRUE, &err);
+  effect_filter = gst_parse_bin_from_description (effects_pipeline_desc, FALSE, &err);
   if (!effect_filter || (err != NULL))
   {
     g_error_free (err);
@@ -642,6 +645,18 @@ cheese_camera_element_from_effect (CheeseCamera *camera, CheeseEffect *effect)
   }
   g_free (effects_pipeline_desc);
 
+  /* Add ghost pads to effect_filter bin */
+  colorspace1 = gst_bin_get_by_name (GST_BIN (effect_filter), "colorspace1");
+  colorspace2 = gst_bin_get_by_name (GST_BIN (effect_filter), "colorspace2");
+
+  pad = gst_element_get_static_pad (colorspace1, "sink");
+  gst_element_add_pad (effect_filter, gst_ghost_pad_new ("sink", pad));
+  gst_object_unref (GST_OBJECT (pad));
+
+  pad = gst_element_get_static_pad (colorspace2, "src");
+  gst_element_add_pad (effect_filter, gst_ghost_pad_new ("src", pad));
+  gst_object_unref (GST_OBJECT (pad));
+
   return effect_filter;
 }
 
diff --git a/src/cheese-window.vala b/src/cheese-window.vala
index 04b657a..797be80 100644
--- a/src/cheese-window.vala
+++ b/src/cheese-window.vala
@@ -1081,6 +1081,10 @@ public class Cheese.MainWindow : Gtk.Window
     {
       if (!is_camera_actions_sensitive)
         toggle_camera_actions_sensitivities (true);
+
+      Effect effect = effects_manager.get_effect (settings.get_string ("selected-effect"));
+      if (effect != null)
+        camera.set_effect (effect);
     }
   }
 
@@ -1232,7 +1236,6 @@ public class Cheese.MainWindow : Gtk.Window
   public void setup_camera (string ? uri)
   {
     string device;
-    Effect effect;
     double value;
 
     if (uri != null && uri.length > 0)
@@ -1258,10 +1261,6 @@ public class Cheese.MainWindow : Gtk.Window
       return;
     }
 
-    effect = effects_manager.get_effect (settings.get_string ("selected-effect"));
-    if (effect != null)
-      camera.set_effect (effect);
-
     value = settings.get_double ("brightness");
     if (value != 0.0)
       camera.set_balance_property ("brightness", value);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]