[cheese/tpo: 3/6] Added new CheeseEffect class that enscapulates an user loadable effect.
- From: Yuvaraj Pandian <yuvipanda src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cheese/tpo: 3/6] Added new CheeseEffect class that enscapulates an user loadable effect.
- Date: Fri, 25 Jun 2010 11:22:12 +0000 (UTC)
commit aaaf30ab152b88e1f4a8df5b13b460553cc4bc3e
Author: Yuvaraj Pandian T <yuvipanda gmail com>
Date: Fri Jun 25 02:20:24 2010 +0530
Added new CheeseEffect class that enscapulates an user loadable effect.
libcheese/Makefile.am | 2 +
libcheese/cheese-camera.c | 63 +++------------------------
libcheese/cheese-camera.h | 20 +--------
libcheese/cheese-effect.c | 93 +++++++++++++++++++++++++++++++++++++++
libcheese/cheese-effect.h | 40 +++++++++++++++++
valasrc/cheese-window.vala | 7 +++-
valasrc/vapi/cheese-common.vapi | 13 +++++-
7 files changed, 161 insertions(+), 77 deletions(-)
---
diff --git a/libcheese/Makefile.am b/libcheese/Makefile.am
index 524f6f7..32de009 100644
--- a/libcheese/Makefile.am
+++ b/libcheese/Makefile.am
@@ -43,6 +43,8 @@ libcheesecommon_la_SOURCES = \
cheese-flash.c \
cheese-countdown.c \
cheese-countdown.h \
+ cheese-effect.c \
+ cheese-effect.h \
$(BUILT_SOURCES)
libcheese_gtk_la_SOURCES = \
diff --git a/libcheese/cheese-camera.c b/libcheese/cheese-camera.c
index cb37d70..476bb3c 100644
--- a/libcheese/cheese-camera.c
+++ b/libcheese/cheese-camera.c
@@ -107,37 +107,6 @@ enum
static guint camera_signals[LAST_SIGNAL];
-typedef enum
-{
- RGB,
- YUV
-} VideoColorSpace;
-
-typedef struct
-{
- CheeseCameraEffect effect;
- const char *pipeline_desc;
- VideoColorSpace colorspace; /* The color space the effect works in */
-} EffectToPipelineDesc;
-
-
-static const EffectToPipelineDesc EFFECT_TO_PIPELINE_DESC[] = {
- {CHEESE_CAMERA_EFFECT_NO_EFFECT, "identity", RGB},
- {CHEESE_CAMERA_EFFECT_MAUVE, "videobalance saturation=1.5 hue=+0.5", YUV},
- {CHEESE_CAMERA_EFFECT_NOIR_BLANC, "videobalance saturation=0", YUV},
- {CHEESE_CAMERA_EFFECT_SATURATION, "videobalance saturation=2", YUV},
- {CHEESE_CAMERA_EFFECT_HULK, "videobalance saturation=1.5 hue=-0.5", YUV},
- {CHEESE_CAMERA_EFFECT_VERTICAL_FLIP, "videoflip method=5", YUV},
- {CHEESE_CAMERA_EFFECT_HORIZONTAL_FLIP, "videoflip method=4", YUV},
- {CHEESE_CAMERA_EFFECT_SHAGADELIC, "shagadelictv", RGB},
- {CHEESE_CAMERA_EFFECT_VERTIGO, "vertigotv", RGB},
- {CHEESE_CAMERA_EFFECT_EDGE, "edgetv", RGB},
- {CHEESE_CAMERA_EFFECT_DICE, "dicetv", RGB},
- {CHEESE_CAMERA_EFFECT_WARP, "warptv", RGB}
-};
-
-static const int NUM_EFFECTS = G_N_ELEMENTS (EFFECT_TO_PIPELINE_DESC);
-
GST_DEBUG_CATEGORY (cheese_camera_cat);
#define GST_CAT_DEFAULT cheese_camera_cat
@@ -807,37 +776,19 @@ cheese_camera_change_effect_filter (CheeseCamera *camera, GstElement *new_filter
}
void
-cheese_camera_set_effect (CheeseCamera *camera, CheeseCameraEffect effect)
+cheese_camera_set_effect (CheeseCamera *camera, CheeseEffect *effect)
{
- GString *rgb_effects_str = g_string_new ("");
- GString *yuv_effects_str = g_string_new ("");
char *effects_pipeline_desc;
- int i;
GstElement *effect_filter;
GError *err = NULL;
+ char *effect_desc;
+
+ g_object_get (CHEESE_EFFECT (effect), "pipeline_desc", &effect_desc, NULL);
- for (i = 0; i < NUM_EFFECTS; i++)
- {
- if (effect & EFFECT_TO_PIPELINE_DESC[i].effect)
- {
- if (EFFECT_TO_PIPELINE_DESC[i].colorspace == RGB)
- {
- g_string_append (rgb_effects_str, EFFECT_TO_PIPELINE_DESC[i].pipeline_desc);
- g_string_append (rgb_effects_str, " ! ");
- }
- else
- {
- g_string_append (yuv_effects_str, " ! ");
- g_string_append (yuv_effects_str, EFFECT_TO_PIPELINE_DESC[i].pipeline_desc);
- }
- }
- }
effects_pipeline_desc = g_strconcat ("ffmpegcolorspace ! ",
- rgb_effects_str->str,
- "ffmpegcolorspace",
- yuv_effects_str->str,
+ effect_desc,
+ " ! ffmpegcolorspace",
NULL);
-
effect_filter = gst_parse_bin_from_description (effects_pipeline_desc, TRUE, &err);
if (!effect_filter || (err != NULL))
{
@@ -847,8 +798,6 @@ cheese_camera_set_effect (CheeseCamera *camera, CheeseCameraEffect effect)
cheese_camera_change_effect_filter (camera, effect_filter);
g_free (effects_pipeline_desc);
- g_string_free (rgb_effects_str, TRUE);
- g_string_free (yuv_effects_str, TRUE);
}
void
diff --git a/libcheese/cheese-camera.h b/libcheese/cheese-camera.h
index 9348086..815ef3b 100644
--- a/libcheese/cheese-camera.h
+++ b/libcheese/cheese-camera.h
@@ -28,6 +28,7 @@
#include <gst/interfaces/xoverlay.h>
#include <clutter/clutter.h>
#include <cheese-camera-device.h>
+#include <cheese-effect.h>
G_BEGIN_DECLS
@@ -38,23 +39,6 @@ G_BEGIN_DECLS
#define CHEESE_IS_CAMERA_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CHEESE_TYPE_CAMERA))
#define CHEESE_CAMERA_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CHEESE_TYPE_CAMERA, CheeseCameraClass))
-typedef enum
-{
- CHEESE_CAMERA_EFFECT_NO_EFFECT = (0),
- CHEESE_CAMERA_EFFECT_MAUVE = (1 << 0),
- CHEESE_CAMERA_EFFECT_NOIR_BLANC = (1 << 1),
- CHEESE_CAMERA_EFFECT_SATURATION = (1 << 2),
- CHEESE_CAMERA_EFFECT_HULK = (1 << 3),
- CHEESE_CAMERA_EFFECT_VERTICAL_FLIP = (1 << 4),
- CHEESE_CAMERA_EFFECT_HORIZONTAL_FLIP = (1 << 5),
- CHEESE_CAMERA_EFFECT_SHAGADELIC = (1 << 6),
- CHEESE_CAMERA_EFFECT_VERTIGO = (1 << 7),
- CHEESE_CAMERA_EFFECT_EDGE = (1 << 8),
- CHEESE_CAMERA_EFFECT_DICE = (1 << 9),
- CHEESE_CAMERA_EFFECT_WARP = (1 << 10),
-}
-CheeseCameraEffect;
-
typedef struct
{
GObject parent;
@@ -85,7 +69,7 @@ const CheeseVideoFormat *cheese_camera_get_current_video_format (CheeseCamera *c
void cheese_camera_setup (CheeseCamera *camera, char *udi, GError **error);
void cheese_camera_play (CheeseCamera *camera);
void cheese_camera_stop (CheeseCamera *camera);
-void cheese_camera_set_effect (CheeseCamera *camera, CheeseCameraEffect effect);
+void cheese_camera_set_effect (CheeseCamera *camera, CheeseEffect *effect);
void cheese_camera_start_video_recording (CheeseCamera *camera, char *filename);
void cheese_camera_stop_video_recording (CheeseCamera *camera);
gboolean cheese_camera_take_photo (CheeseCamera *camera, char *filename);
diff --git a/libcheese/cheese-effect.c b/libcheese/cheese-effect.c
new file mode 100644
index 0000000..b324029
--- /dev/null
+++ b/libcheese/cheese-effect.c
@@ -0,0 +1,93 @@
+#include "cheese-effect.h"
+
+enum
+{
+ PROP_O,
+ PROP_NAME,
+ PROP_PIPELINE_DESC
+};
+
+G_DEFINE_TYPE (CheeseEffect, cheese_effect, G_TYPE_OBJECT)
+
+#define CHEESE_EFFECT_GET_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), CHEESE_TYPE_EFFECT, CheeseEffectPrivate))
+
+typedef struct _CheeseEffectPrivate CheeseEffectPrivate;
+
+struct _CheeseEffectPrivate {
+ char *name;
+ char *pipeline_desc;
+};
+
+static void
+cheese_effect_get_property (GObject *object, guint property_id,
+ GValue *value, GParamSpec *pspec)
+{
+ CheeseEffectPrivate *priv = CHEESE_EFFECT_GET_PRIVATE (object);
+
+ switch (property_id) {
+ case PROP_NAME:
+ g_value_set_string (value, priv->name);
+ break;
+ case PROP_PIPELINE_DESC:
+ g_value_set_string (value, priv->pipeline_desc);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+cheese_effect_set_property (GObject *object, guint property_id,
+ const GValue *value, GParamSpec *pspec)
+{
+ CheeseEffectPrivate *priv = CHEESE_EFFECT_GET_PRIVATE (object);
+
+ switch (property_id) {
+ case PROP_NAME:
+ g_free (priv->name);
+ priv->name = g_value_dup_string (value);
+ break;
+ case PROP_PIPELINE_DESC:
+ g_free (priv->pipeline_desc);
+ priv->pipeline_desc = g_value_dup_string (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+cheese_effect_class_init (CheeseEffectClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (CheeseEffectPrivate));
+
+ object_class->get_property = cheese_effect_get_property;
+ object_class->set_property = cheese_effect_set_property;
+
+ g_object_class_install_property (object_class, PROP_NAME,
+ g_param_spec_string ("name",
+ NULL,
+ NULL,
+ "",
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_PIPELINE_DESC,
+ g_param_spec_string ("pipeline_desc",
+ NULL,
+ NULL,
+ "",
+ G_PARAM_READWRITE));
+}
+
+static void
+cheese_effect_init (CheeseEffect *self)
+{
+}
+
+CheeseEffect*
+cheese_effect_new (void)
+{
+ return g_object_new (CHEESE_TYPE_EFFECT, NULL);
+}
diff --git a/libcheese/cheese-effect.h b/libcheese/cheese-effect.h
new file mode 100644
index 0000000..81ffc59
--- /dev/null
+++ b/libcheese/cheese-effect.h
@@ -0,0 +1,40 @@
+#ifndef _CHEESE_EFFECT_H_
+#define _CHEESE_EFFECT_H_
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define CHEESE_TYPE_EFFECT cheese_effect_get_type()
+
+#define CHEESE_EFFECT(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHEESE_TYPE_EFFECT, CheeseEffect))
+
+#define CHEESE_EFFECT_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), CHEESE_TYPE_EFFECT, CheeseEffectClass))
+
+#define CHEESE_IS_EFFECT(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHEESE_TYPE_EFFECT))
+
+#define CHEESE_IS_EFFECT_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), CHEESE_TYPE_EFFECT))
+
+#define CHEESE_EFFECT_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), CHEESE_TYPE_EFFECT, CheeseEffectClass))
+
+typedef struct {
+ GObject parent;
+} CheeseEffect;
+
+typedef struct {
+ GObjectClass parent_class;
+} CheeseEffectClass;
+
+GType cheese_effect_get_type (void);
+
+CheeseEffect* cheese_effect_new (void);
+
+G_END_DECLS
+
+#endif /* _CHEESE_EFFECT_H_ */
+
diff --git a/valasrc/cheese-window.vala b/valasrc/cheese-window.vala
index 347da77..e31b0c2 100644
--- a/valasrc/cheese-window.vala
+++ b/valasrc/cheese-window.vala
@@ -437,7 +437,7 @@ public class Cheese.MainWindow : Gtk.Window
video_mode_action = (Gtk.Action)gtk_builder.get_object ("video_mode");
burst_mode_action = (Gtk.Action)gtk_builder.get_object ("burst_mode");
effects_toggle_action = (Gtk.Action)gtk_builder.get_object ("effects_toggle");
- countdown_toggle_action= (Gtk.Action)gtk_builder.get_object ("countdown");
+ countdown_action= (Gtk.Action)gtk_builder.get_object ("countdown");
wide_mode_action = (Gtk.Action)gtk_builder.get_object("wide_mode");
/* Array contains all 'buttons', for easier manipulation
@@ -470,6 +470,11 @@ public class Cheese.MainWindow : Gtk.Window
camera.setup (conf.gconf_prop_camera);
camera.play ();
+ Effect e = new Effect();
+ e.name = "blah";
+ e.pipeline_desc = "warptv";
+ camera.set_effect(e);
+
set_wide_mode (conf.gconf_prop_wide_mode, true);
set_mode (MediaMode.PHOTO);
diff --git a/valasrc/vapi/cheese-common.vapi b/valasrc/vapi/cheese-common.vapi
index f9da177..9019ccb 100644
--- a/valasrc/vapi/cheese-common.vapi
+++ b/valasrc/vapi/cheese-common.vapi
@@ -3,6 +3,17 @@
[CCode (cprefix = "Cheese", lower_case_cprefix = "cheese_")]
namespace Cheese
{
+ [CCode (cheader_filename = "cheese-effect.h")]
+ public class Effect : GLib.Object
+ {
+ [CCode (has_construct_function = false)]
+ public Effect ();
+ [NoAccessorMethod]
+ public string name {get; set;}
+ [NoAccessorMethod]
+ public string pipeline_desc {get; set;}
+ }
+
[CCode (cheader_filename = "cheese-camera.h")]
public class Camera : GLib.Object
{
@@ -19,7 +30,7 @@ namespace Cheese
public void set_balance_property (string property, double value);
public void set_device_by_dev_file (string file);
public void set_device_by_dev_udi (string udi);
- public void set_effect (Cheese.CameraEffect effect);
+ public void set_effect (Cheese.Effect effect);
public void set_video_format (Cheese.VideoFormat format);
public void setup (string udi) throws GLib.Error;
public void start_video_recording (string filename);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]