summaryrefslogtreecommitdiff
path: root/libcheese
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2013-06-11 09:35:14 +0200
committerDavid King <amigadave@amigadave.com>2013-06-24 21:41:48 +0100
commite8fd44e92d12db016eb549ed230be2a54a5632f0 (patch)
treef074e03f2e0de73da04d1349db09e46d073aa261 /libcheese
parent0b07047af57927c5954bb8199bcaeddb2926e1e3 (diff)
Avoid setting the same effect again
Check for the current effect being the same as the one set and if so, ignore the change. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'libcheese')
-rw-r--r--libcheese/cheese-camera.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/libcheese/cheese-camera.c b/libcheese/cheese-camera.c
index cd3b20ce..45972940 100644
--- a/libcheese/cheese-camera.c
+++ b/libcheese/cheese-camera.c
@@ -80,6 +80,7 @@ struct _CheeseCameraPrivate
GstElement *video_balance;
GstElement *camera_tee, *effects_tee;
GstElement *main_valve, *effects_valve;
+ gchar *current_effect_desc;
gboolean is_recording;
gboolean pipeline_is_playing;
@@ -599,6 +600,7 @@ cheese_camera_create_video_filter_bin (CheeseCamera *camera, GError **error)
cheese_camera_set_error_element_not_found (error, "identity");
return FALSE;
}
+ priv->current_effect_desc = g_strdup("identity");
if ((priv->video_balance = gst_element_factory_make ("videobalance", "video_balance")) == NULL)
{
cheese_camera_set_error_element_not_found (error, "videobalance");
@@ -915,16 +917,29 @@ cheese_camera_element_from_effect (CheeseCamera *camera, CheeseEffect *effect)
void
cheese_camera_set_effect (CheeseCamera *camera, CheeseEffect *effect)
{
+ const gchar *effect_desc = cheese_effect_get_pipeline_desc (effect);
GstElement *effect_filter;
g_return_if_fail (CHEESE_IS_CAMERA (camera));
- if (strcmp (cheese_effect_get_pipeline_desc (effect), "identity") == 0)
+ if (strcmp (camera->priv->current_effect_desc, effect_desc) == 0)
+ {
+ GST_INFO_OBJECT (camera, "Effect is: \"%s\", not updating", effect_desc);
+ return;
+ }
+
+ GST_INFO_OBJECT (camera, "Changing effect to: \"%s\"", effect_desc);
+
+ if (strcmp (effect_desc, "identity") == 0)
effect_filter = gst_element_factory_make ("identity", "effect");
else
effect_filter = cheese_camera_element_from_effect (camera, effect);
if (effect_filter != NULL)
+ {
cheese_camera_change_effect_filter (camera, effect_filter);
+ g_free (camera->priv->current_effect_desc);
+ camera->priv->current_effect_desc = g_strdup(effect_desc);
+ }
}
/**
@@ -1232,6 +1247,7 @@ cheese_camera_finalize (GObject *object)
if (priv->photo_filename)
g_free (priv->photo_filename);
+ g_free (priv->current_effect_desc);
g_free (priv->device_node);
g_boxed_free (CHEESE_TYPE_VIDEO_FORMAT, priv->current_format);