[cheese/three-point-oh] Added control_valve property to Effect, so it can be turned on and off



commit 56c63bdbe640d3e308535df76e92b903abbdb53c
Author: Yuvaraj Pandian T <yuvipanda gmail com>
Date:   Fri Jul 9 01:12:07 2010 +0530

    Added control_valve property to Effect, so it can be turned on and off

 libcheese/cheese-camera.c |    9 +++++++--
 libcheese/cheese-effect.c |   22 +++++++++++++++++++++-
 2 files changed, 28 insertions(+), 3 deletions(-)
---
diff --git a/libcheese/cheese-camera.c b/libcheese/cheese-camera.c
index b474114..af95f75 100644
--- a/libcheese/cheese-camera.c
+++ b/libcheese/cheese-camera.c
@@ -810,6 +810,7 @@ cheese_camera_connect_effect_texture (CheeseCamera *camera, CheeseEffect *effect
   GstElement *effect_filter;
   GstElement *display_element;
   GstElement *display_queue;
+  GstElement *control_valve;
   gboolean ok;
   gboolean is_playing;
 
@@ -817,14 +818,18 @@ cheese_camera_connect_effect_texture (CheeseCamera *camera, CheeseEffect *effect
 
   cheese_camera_stop (camera);
 
+  control_valve = gst_element_factory_make ("valve", NULL);
+  g_object_set (G_OBJECT (effect), "control_valve", control_valve, NULL);
+  
   display_queue = gst_element_factory_make ("queue", NULL);
 
   effect_filter = cheese_camera_element_from_effect (camera, effect);
+
   display_element = clutter_gst_video_sink_new (texture);
   g_object_set (G_OBJECT (display_element), "async", FALSE, NULL);
     
-  gst_bin_add_many (GST_BIN (priv->pipeline), effect_filter, display_queue, display_element, NULL);
-  ok = gst_element_link_many (priv->effects_tee, effect_filter, display_queue, display_element, NULL);
+  gst_bin_add_many (GST_BIN (priv->pipeline), control_valve, effect_filter, display_queue, display_element, NULL);
+  ok = gst_element_link_many (priv->effects_tee, control_valve, effect_filter, display_queue, display_element, NULL);
 
   if (is_playing)
     cheese_camera_play (camera);
diff --git a/libcheese/cheese-effect.c b/libcheese/cheese-effect.c
index b324029..9e995d4 100644
--- a/libcheese/cheese-effect.c
+++ b/libcheese/cheese-effect.c
@@ -1,10 +1,13 @@
+#include <gst/gst.h>
+
 #include "cheese-effect.h"
 
 enum 
 {
   PROP_O,
   PROP_NAME,
-  PROP_PIPELINE_DESC
+  PROP_PIPELINE_DESC,
+  PROP_CONTROL_VALVE
 };
 
 G_DEFINE_TYPE (CheeseEffect, cheese_effect, G_TYPE_OBJECT)
@@ -17,6 +20,7 @@ typedef struct _CheeseEffectPrivate CheeseEffectPrivate;
 struct _CheeseEffectPrivate {
   char *name;
   char *pipeline_desc;
+  GstElement *control_valve;
 };
 
 static void
@@ -32,6 +36,9 @@ cheese_effect_get_property (GObject *object, guint property_id,
   case PROP_PIPELINE_DESC:
     g_value_set_string (value, priv->pipeline_desc);
     break;
+  case PROP_CONTROL_VALVE:
+    g_value_set_object (value, priv->control_valve);
+    break;
   default:
     G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
   }
@@ -52,6 +59,12 @@ cheese_effect_set_property (GObject *object, guint property_id,
     g_free (priv->pipeline_desc);
     priv->pipeline_desc = g_value_dup_string (value);
     break;
+  case PROP_CONTROL_VALVE:
+    if (priv->control_valve != NULL)
+      g_object_unref (G_OBJECT (priv->control_valve));
+    priv->control_valve = GST_ELEMENT (g_value_get_object (value));
+    g_object_ref (G_OBJECT (priv->control_valve));
+    break;
   default:
     G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
   }
@@ -79,6 +92,13 @@ cheese_effect_class_init (CheeseEffectClass *klass)
 							NULL,
 							"",
 							G_PARAM_READWRITE));
+  g_object_class_install_property (object_class, PROP_CONTROL_VALVE,
+				   g_param_spec_object ("control_valve",
+							NULL,
+							NULL,
+							GST_TYPE_ELEMENT,
+							G_PARAM_READWRITE));
+
 }
 
 static void



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