From 7364319bfd40329ecdb01a500d75b7daef8e3794 Mon Sep 17 00:00:00 2001 From: Filippo Argiolas Date: Thu, 14 Aug 2008 22:28:19 +0200 Subject: [PATCH] [174/906] add a property to gleffects to switch video left to right, useful with webcams to resemble a mirror --- gst/gl/gstgleffects.c | 44 +++++++++++++++++++++++++++++++------------- gst/gl/gstgleffects.h | 5 ++++- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/gst/gl/gstgleffects.c b/gst/gl/gstgleffects.c index 2170aa3..465ef4c 100644 --- a/gst/gl/gstgleffects.c +++ b/gst/gl/gstgleffects.c @@ -222,6 +222,14 @@ gst_gl_effects_class_init (GstGLEffectsClass * klass) GST_TYPE_GL_EFFECTS_EFFECT, GST_GL_EFFECT_IDENTITY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property ( + gobject_class, + PROP_HSWAP, + g_param_spec_boolean ("hswap", + "Horizontal Swap", + "Switch video texture left to right, useful with webcams", + FALSE, + G_PARAM_READWRITE)); } void @@ -247,21 +255,21 @@ gst_gl_effects_draw_texture (GstGLEffects * effects, GLuint tex) glEnd (); } -/* static void */ -/* set_orizonthal_switch (GstGLDisplay *display, gpointer data) */ -/* { */ -/* // GstGLEffects *effects = GST_GL_EFFECTS (data); */ +static void +set_horizontal_swap (GstGLDisplay *display, gpointer data) +{ +// GstGLEffects *effects = GST_GL_EFFECTS (data); -/* const double mirrormatrix[16] = { */ -/* -1.0, 0.0, 0.0, 0.0, */ -/* 0.0, 1.0, 0.0, 0.0, */ -/* 0.0, 0.0, 1.0, 0.0, */ -/* 0.0, 0.0, 0.0, 1.0 */ -/* }; */ + const double mirrormatrix[16] = { + -1.0, 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0, 1.0 + }; -/* glMatrixMode (GL_MODELVIEW); */ -/* glLoadMatrixd (mirrormatrix); */ -/* } */ + glMatrixMode (GL_MODELVIEW); + glLoadMatrixd (mirrormatrix); +} static void gst_gl_effects_init (GstGLEffects * effects, GstGLEffectsClass * klass) @@ -276,6 +284,7 @@ gst_gl_effects_init (GstGLEffects * effects, GstGLEffectsClass * klass) } effects->effect = gst_gl_effects_identity; + effects->horizontal_swap = FALSE; } static void @@ -297,6 +306,9 @@ gst_gl_effects_set_property (GObject * object, guint prop_id, case PROP_EFFECT: gst_gl_effects_set_effect (effects, g_value_get_enum (value)); break; + case PROP_HSWAP: + effects->horizontal_swap = g_value_get_boolean (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -313,6 +325,9 @@ gst_gl_effects_get_property (GObject * object, guint prop_id, case PROP_EFFECT: g_value_set_enum (value, effects->current_effect); break; + case PROP_HSWAP: + g_value_set_boolean (value, effects->horizontal_swap); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -334,6 +349,9 @@ gst_gl_effects_filter (GstGLFilter* filter, GstGLBuffer* inbuf, effects->intexture = inbuf->texture; effects->outtexture = outbuf->texture; + if (effects->horizontal_swap == TRUE) + gst_gl_display_thread_add (filter->display, set_horizontal_swap, effects); + effects->effect (effects); return TRUE; diff --git a/gst/gl/gstgleffects.h b/gst/gl/gstgleffects.h index 4af9d24..3781ded 100644 --- a/gst/gl/gstgleffects.h +++ b/gst/gl/gstgleffects.h @@ -67,6 +67,8 @@ struct _GstGLEffects GLuint curve[GST_GL_EFFECTS_N_CURVES]; GHashTable *shaderstable; + + gboolean horizontal_swap; /* switch left to right */ }; struct _GstGLEffectsClass @@ -77,7 +79,8 @@ struct _GstGLEffectsClass enum { PROP_0, - PROP_EFFECT + PROP_EFFECT, + PROP_HSWAP }; -- 2.7.4