mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
[174/906] add a property to gleffects to switch video left to right, useful with webcams to resemble a mirror
This commit is contained in:
parent
5db4fa5f1e
commit
7364319bfd
2 changed files with 35 additions and 14 deletions
|
@ -222,6 +222,14 @@ gst_gl_effects_class_init (GstGLEffectsClass * klass)
|
||||||
GST_TYPE_GL_EFFECTS_EFFECT,
|
GST_TYPE_GL_EFFECTS_EFFECT,
|
||||||
GST_GL_EFFECT_IDENTITY,
|
GST_GL_EFFECT_IDENTITY,
|
||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
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
|
void
|
||||||
|
@ -247,21 +255,21 @@ gst_gl_effects_draw_texture (GstGLEffects * effects, GLuint tex)
|
||||||
glEnd ();
|
glEnd ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static void */
|
static void
|
||||||
/* set_orizonthal_switch (GstGLDisplay *display, gpointer data) */
|
set_horizontal_swap (GstGLDisplay *display, gpointer data)
|
||||||
/* { */
|
{
|
||||||
/* // GstGLEffects *effects = GST_GL_EFFECTS (data); */
|
// GstGLEffects *effects = GST_GL_EFFECTS (data);
|
||||||
|
|
||||||
/* const double mirrormatrix[16] = { */
|
const double mirrormatrix[16] = {
|
||||||
/* -1.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, 1.0, 0.0, 0.0,
|
||||||
/* 0.0, 0.0, 1.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, 1.0
|
||||||
/* }; */
|
};
|
||||||
|
|
||||||
/* glMatrixMode (GL_MODELVIEW); */
|
glMatrixMode (GL_MODELVIEW);
|
||||||
/* glLoadMatrixd (mirrormatrix); */
|
glLoadMatrixd (mirrormatrix);
|
||||||
/* } */
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_gl_effects_init (GstGLEffects * effects, GstGLEffectsClass * klass)
|
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->effect = gst_gl_effects_identity;
|
||||||
|
effects->horizontal_swap = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -297,6 +306,9 @@ gst_gl_effects_set_property (GObject * object, guint prop_id,
|
||||||
case PROP_EFFECT:
|
case PROP_EFFECT:
|
||||||
gst_gl_effects_set_effect (effects, g_value_get_enum (value));
|
gst_gl_effects_set_effect (effects, g_value_get_enum (value));
|
||||||
break;
|
break;
|
||||||
|
case PROP_HSWAP:
|
||||||
|
effects->horizontal_swap = g_value_get_boolean (value);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -313,6 +325,9 @@ gst_gl_effects_get_property (GObject * object, guint prop_id,
|
||||||
case PROP_EFFECT:
|
case PROP_EFFECT:
|
||||||
g_value_set_enum (value, effects->current_effect);
|
g_value_set_enum (value, effects->current_effect);
|
||||||
break;
|
break;
|
||||||
|
case PROP_HSWAP:
|
||||||
|
g_value_set_boolean (value, effects->horizontal_swap);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -334,6 +349,9 @@ gst_gl_effects_filter (GstGLFilter* filter, GstGLBuffer* inbuf,
|
||||||
effects->intexture = inbuf->texture;
|
effects->intexture = inbuf->texture;
|
||||||
effects->outtexture = outbuf->texture;
|
effects->outtexture = outbuf->texture;
|
||||||
|
|
||||||
|
if (effects->horizontal_swap == TRUE)
|
||||||
|
gst_gl_display_thread_add (filter->display, set_horizontal_swap, effects);
|
||||||
|
|
||||||
effects->effect (effects);
|
effects->effect (effects);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
@ -67,6 +67,8 @@ struct _GstGLEffects
|
||||||
GLuint curve[GST_GL_EFFECTS_N_CURVES];
|
GLuint curve[GST_GL_EFFECTS_N_CURVES];
|
||||||
|
|
||||||
GHashTable *shaderstable;
|
GHashTable *shaderstable;
|
||||||
|
|
||||||
|
gboolean horizontal_swap; /* switch left to right */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstGLEffectsClass
|
struct _GstGLEffectsClass
|
||||||
|
@ -77,7 +79,8 @@ struct _GstGLEffectsClass
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_EFFECT
|
PROP_EFFECT,
|
||||||
|
PROP_HSWAP
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue