mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-01 06:01:04 +00:00
parent
5943045bf6
commit
5fef0569f0
2 changed files with 196 additions and 40 deletions
|
@ -73,9 +73,13 @@ enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_LOCATION,
|
PROP_LOCATION,
|
||||||
PROP_XPOS,
|
PROP_XPOS_PNG,
|
||||||
PROP_YPOS,
|
PROP_YPOS_PNG,
|
||||||
PROP_SIZE
|
PROP_SIZE_PNG,
|
||||||
|
PROP_XPOS_VIDEO,
|
||||||
|
PROP_YPOS_VIDEO,
|
||||||
|
PROP_SIZE_VIDEO,
|
||||||
|
PROP_VIDEOTOP
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -127,24 +131,51 @@ gst_gl_overlay_class_init (GstGLOverlayClass * klass)
|
||||||
"Location of the image", NULL, G_PARAM_READWRITE));
|
"Location of the image", NULL, G_PARAM_READWRITE));
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_XPOS,
|
PROP_XPOS_PNG,
|
||||||
g_param_spec_int ("xpos",
|
g_param_spec_int ("xpos-png",
|
||||||
"X position of overlay image in percents",
|
"X position of overlay image in percents",
|
||||||
"X position of overlay image in percents",
|
"X position of overlay image in percents",
|
||||||
0, 100, 0, G_PARAM_READWRITE));
|
0, 100, 0, G_PARAM_READWRITE));
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_YPOS,
|
PROP_YPOS_PNG,
|
||||||
g_param_spec_int ("ypos",
|
g_param_spec_int ("ypos-png",
|
||||||
"Y position of overlay image in percents",
|
"Y position of overlay image in percents",
|
||||||
"Y position of overlay image in percents",
|
"Y position of overlay image in percents",
|
||||||
0, 100, 0, G_PARAM_READWRITE));
|
0, 100, 0, G_PARAM_READWRITE));
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_SIZE,
|
PROP_SIZE_PNG,
|
||||||
g_param_spec_int ("proportion",
|
g_param_spec_int ("proportion-png",
|
||||||
"Relative size of overlay image, in percents",
|
"Relative size of overlay image, in percents",
|
||||||
"Relative size of iverlay image, in percents",
|
"Relative size of iverlay image, in percents",
|
||||||
0, 100, 0, G_PARAM_READWRITE));
|
0, 100, 0, G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_XPOS_VIDEO,
|
||||||
|
g_param_spec_int ("xpos-video",
|
||||||
|
"X position of overlay video in percents",
|
||||||
|
"X position of overlay video in percents",
|
||||||
|
0, 100, 0, G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_YPOS_VIDEO,
|
||||||
|
g_param_spec_int ("ypos-video",
|
||||||
|
"Y position of overlay video in percents",
|
||||||
|
"Y position of overlay video in percents",
|
||||||
|
0, 100, 0, G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_SIZE_VIDEO,
|
||||||
|
g_param_spec_int ("proportion-video",
|
||||||
|
"Relative size of overlay video, in percents",
|
||||||
|
"Relative size of iverlay video, in percents",
|
||||||
|
0, 100, 0, G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_VIDEOTOP,
|
||||||
|
g_param_spec_boolean ("video-top",
|
||||||
|
"Video-top", "Video is over png image", FALSE, G_PARAM_READWRITE));
|
||||||
/*
|
/*
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_STRETCH,
|
PROP_STRETCH,
|
||||||
|
@ -155,8 +186,87 @@ gst_gl_overlay_class_init (GstGLOverlayClass * klass)
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
gst_gl_overlay_draw_texture (GstGLOverlay * overlay, GLuint tex)
|
gst_gl_overlay_draw_texture_video_on_png (GstGLOverlay * overlay, GLuint tex)
|
||||||
|
{
|
||||||
|
GstGLFilter *filter = GST_GL_FILTER (overlay);
|
||||||
|
|
||||||
|
gfloat posx = 0.0;
|
||||||
|
gfloat posy = 0.0;
|
||||||
|
gfloat size = 0.0;
|
||||||
|
gfloat width = (gfloat) overlay->width;
|
||||||
|
gfloat height = (gfloat) overlay->height;
|
||||||
|
|
||||||
|
if (overlay->pbuftexture == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// if (overlay->stretch) {
|
||||||
|
// width = (gfloat) overlay->width;
|
||||||
|
// height = (gfloat) overlay->height;
|
||||||
|
// }
|
||||||
|
|
||||||
|
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
glEnable (GL_BLEND);
|
||||||
|
|
||||||
|
glEnable (GL_TEXTURE_RECTANGLE_ARB);
|
||||||
|
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, overlay->pbuftexture);
|
||||||
|
|
||||||
|
glBegin (GL_QUADS);
|
||||||
|
|
||||||
|
size = (overlay->size_png) / 50.0;
|
||||||
|
posx = (overlay->pos_x_png - 50.0) / 50.0;
|
||||||
|
posx =
|
||||||
|
(posx - (size / 2) < -1.00) ? (-1.0 + size / 2) : (posx + (size / 2) >
|
||||||
|
1.00) ? (1.0 - size / 2) : posx;
|
||||||
|
posy = (overlay->pos_y_png - 50.0) / 50.0;
|
||||||
|
posy =
|
||||||
|
(posy - (size / 2) < -1.00) ? (-1.0 + size / 2) : (posy + (size / 2) >
|
||||||
|
1.00) ? (1.0 - size / 2) : posy;
|
||||||
|
|
||||||
|
glTexCoord2f (0.0, 0.0);
|
||||||
|
glVertex2f (posx - (size / 2), posy - (size / 2));
|
||||||
|
glTexCoord2f (width, 0.0);
|
||||||
|
glVertex2f (posx + (size / 2), posy - (size / 2));
|
||||||
|
glTexCoord2f (width, height);
|
||||||
|
glVertex2f (posx + (size / 2), posy + (size / 2));
|
||||||
|
glTexCoord2f (0.0, height);
|
||||||
|
glVertex2f (posx - (size / 2), posy + (size / 2));
|
||||||
|
|
||||||
|
glEnd ();
|
||||||
|
|
||||||
|
width = (gfloat) filter->width;
|
||||||
|
height = (gfloat) filter->height;
|
||||||
|
glActiveTexture (GL_TEXTURE0);
|
||||||
|
glEnable (GL_TEXTURE_RECTANGLE_ARB);
|
||||||
|
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, tex);
|
||||||
|
|
||||||
|
glBegin (GL_QUADS);
|
||||||
|
|
||||||
|
size = (overlay->size_video) / 50.0;
|
||||||
|
posx = (overlay->pos_x_video - 50.0) / 50.0;
|
||||||
|
posx =
|
||||||
|
(posx - (size / 2) < -1.00) ? (-1.0 + size / 2) : (posx + (size / 2) >
|
||||||
|
1.00) ? (1.0 - size / 2) : posx;
|
||||||
|
posy = (overlay->pos_y_video - 50.0) / 50.0;
|
||||||
|
posy =
|
||||||
|
(posy - (size / 2) < -1.00) ? (-1.0 + size / 2) : (posy + (size / 2) >
|
||||||
|
1.00) ? (1.0 - size / 2) : posy;
|
||||||
|
|
||||||
|
glTexCoord2f (0.0, 0.0);
|
||||||
|
glVertex2f (posx - (size / 2), posy - (size / 2));
|
||||||
|
glTexCoord2f (width, 0.0);
|
||||||
|
glVertex2f (posx + (size / 2), posy - (size / 2));
|
||||||
|
glTexCoord2f (width, height);
|
||||||
|
glVertex2f (posx + (size / 2), posy + (size / 2));
|
||||||
|
glTexCoord2f (0.0, height);
|
||||||
|
glVertex2f (posx - (size / 2), posy + (size / 2));
|
||||||
|
glEnd ();
|
||||||
|
|
||||||
|
glFlush ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_gl_overlay_draw_texture_png_on_video (GstGLOverlay * overlay, GLuint tex)
|
||||||
{
|
{
|
||||||
GstGLFilter *filter = GST_GL_FILTER (overlay);
|
GstGLFilter *filter = GST_GL_FILTER (overlay);
|
||||||
|
|
||||||
|
@ -172,14 +282,24 @@ gst_gl_overlay_draw_texture (GstGLOverlay * overlay, GLuint tex)
|
||||||
|
|
||||||
glBegin (GL_QUADS);
|
glBegin (GL_QUADS);
|
||||||
|
|
||||||
|
size = (overlay->size_video) / 50.0;
|
||||||
|
posx = (overlay->pos_x_video - 50.0) / 50.0;
|
||||||
|
posx =
|
||||||
|
(posx - (size / 2) < -1.00) ? (-1.0 + size / 2) : (posx + (size / 2) >
|
||||||
|
1.00) ? (1.0 - size / 2) : posx;
|
||||||
|
posy = (overlay->pos_y_video - 50.0) / 50.0;
|
||||||
|
posy =
|
||||||
|
(posy - (size / 2) < -1.00) ? (-1.0 + size / 2) : (posy + (size / 2) >
|
||||||
|
1.00) ? (1.0 - size / 2) : posy;
|
||||||
|
|
||||||
glTexCoord2f (0.0, 0.0);
|
glTexCoord2f (0.0, 0.0);
|
||||||
glVertex2f (-1.0, -1.0);
|
glVertex2f (posx - (size / 2), posy - (size / 2));
|
||||||
glTexCoord2f (width, 0.0);
|
glTexCoord2f (width, 0.0);
|
||||||
glVertex2f (1.0, -1.0);
|
glVertex2f (posx + (size / 2), posy - (size / 2));
|
||||||
glTexCoord2f (width, height);
|
glTexCoord2f (width, height);
|
||||||
glVertex2f (1.0, 1.0);
|
glVertex2f (posx + (size / 2), posy + (size / 2));
|
||||||
glTexCoord2f (0.0, height);
|
glTexCoord2f (0.0, height);
|
||||||
glVertex2f (-1.0, 1.0);
|
glVertex2f (posx - (size / 2), posy + (size / 2));
|
||||||
|
|
||||||
glEnd ();
|
glEnd ();
|
||||||
|
|
||||||
|
@ -199,12 +319,12 @@ gst_gl_overlay_draw_texture (GstGLOverlay * overlay, GLuint tex)
|
||||||
|
|
||||||
glBegin (GL_QUADS);
|
glBegin (GL_QUADS);
|
||||||
|
|
||||||
size = (overlay->size) / 50.0;
|
size = (overlay->size_png) / 50.0;
|
||||||
posx = (overlay->pos_x - 50.0) / 50.0;
|
posx = (overlay->pos_x_png - 50.0) / 50.0;
|
||||||
posx =
|
posx =
|
||||||
(posx - (size / 2) < -1.00) ? (-1.0 + size / 2) : (posx + (size / 2) >
|
(posx - (size / 2) < -1.00) ? (-1.0 + size / 2) : (posx + (size / 2) >
|
||||||
1.00) ? (1.0 - size / 2) : posx;
|
1.00) ? (1.0 - size / 2) : posx;
|
||||||
posy = (overlay->pos_y - 50.0) / 50.0;
|
posy = (overlay->pos_y_png - 50.0) / 50.0;
|
||||||
posy =
|
posy =
|
||||||
(posy - (size / 2) < -1.00) ? (-1.0 + size / 2) : (posy + (size / 2) >
|
(posy - (size / 2) < -1.00) ? (-1.0 + size / 2) : (posy + (size / 2) >
|
||||||
1.00) ? (1.0 - size / 2) : posy;
|
1.00) ? (1.0 - size / 2) : posy;
|
||||||
|
@ -220,10 +340,11 @@ gst_gl_overlay_draw_texture (GstGLOverlay * overlay, GLuint tex)
|
||||||
|
|
||||||
glEnd ();
|
glEnd ();
|
||||||
|
|
||||||
|
|
||||||
glFlush ();
|
glFlush ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_gl_overlay_init (GstGLOverlay * overlay, GstGLOverlayClass * klass)
|
gst_gl_overlay_init (GstGLOverlay * overlay, GstGLOverlayClass * klass)
|
||||||
{
|
{
|
||||||
|
@ -233,9 +354,13 @@ gst_gl_overlay_init (GstGLOverlay * overlay, GstGLOverlayClass * klass)
|
||||||
overlay->pbuftexture = 0;
|
overlay->pbuftexture = 0;
|
||||||
overlay->width = 0;
|
overlay->width = 0;
|
||||||
overlay->height = 0;
|
overlay->height = 0;
|
||||||
overlay->pos_x = 0.0;
|
overlay->pos_x_png = 0.0;
|
||||||
overlay->pos_y = 0.0;
|
overlay->pos_y_png = 0.0;
|
||||||
overlay->size = 100;
|
overlay->size_png = 100;
|
||||||
|
overlay->pos_x_video = 0.0;
|
||||||
|
overlay->pos_y_video = 0.0;
|
||||||
|
overlay->size_video = 100;
|
||||||
|
overlay->video_top = FALSE;
|
||||||
// overlay->stretch = TRUE;
|
// overlay->stretch = TRUE;
|
||||||
overlay->pbuf_has_changed = FALSE;
|
overlay->pbuf_has_changed = FALSE;
|
||||||
}
|
}
|
||||||
|
@ -259,14 +384,26 @@ gst_gl_overlay_set_property (GObject * object, guint prop_id,
|
||||||
overlay->pbuf_has_changed = TRUE;
|
overlay->pbuf_has_changed = TRUE;
|
||||||
overlay->location = g_value_dup_string (value);
|
overlay->location = g_value_dup_string (value);
|
||||||
break;
|
break;
|
||||||
case PROP_XPOS:
|
case PROP_XPOS_PNG:
|
||||||
overlay->pos_x = g_value_get_int (value);
|
overlay->pos_x_png = g_value_get_int (value);
|
||||||
break;
|
break;
|
||||||
case PROP_YPOS:
|
case PROP_YPOS_PNG:
|
||||||
overlay->pos_y = g_value_get_int (value);
|
overlay->pos_y_png = g_value_get_int (value);
|
||||||
break;
|
break;
|
||||||
case PROP_SIZE:
|
case PROP_SIZE_PNG:
|
||||||
overlay->size = g_value_get_int (value);
|
overlay->size_png = g_value_get_int (value);
|
||||||
|
break;
|
||||||
|
case PROP_XPOS_VIDEO:
|
||||||
|
overlay->pos_x_video = g_value_get_int (value);
|
||||||
|
break;
|
||||||
|
case PROP_YPOS_VIDEO:
|
||||||
|
overlay->pos_y_video = g_value_get_int (value);
|
||||||
|
break;
|
||||||
|
case PROP_SIZE_VIDEO:
|
||||||
|
overlay->size_video = g_value_get_int (value);
|
||||||
|
break;
|
||||||
|
case PROP_VIDEOTOP:
|
||||||
|
overlay->video_top = g_value_get_boolean (value);
|
||||||
break;
|
break;
|
||||||
/* case PROP_STRETCH:
|
/* case PROP_STRETCH:
|
||||||
overlay->stretch = g_value_get_boolean (value);
|
overlay->stretch = g_value_get_boolean (value);
|
||||||
|
@ -288,14 +425,26 @@ gst_gl_overlay_get_property (GObject * object, guint prop_id,
|
||||||
case PROP_LOCATION:
|
case PROP_LOCATION:
|
||||||
g_value_set_string (value, overlay->location);
|
g_value_set_string (value, overlay->location);
|
||||||
break;
|
break;
|
||||||
case PROP_XPOS:
|
case PROP_XPOS_PNG:
|
||||||
g_value_set_int (value, overlay->pos_x);
|
g_value_set_int (value, overlay->pos_x_png);
|
||||||
break;
|
break;
|
||||||
case PROP_YPOS:
|
case PROP_YPOS_PNG:
|
||||||
g_value_set_int (value, overlay->pos_y);
|
g_value_set_int (value, overlay->pos_y_png);
|
||||||
break;
|
break;
|
||||||
case PROP_SIZE:
|
case PROP_SIZE_PNG:
|
||||||
g_value_set_int (value, overlay->size);
|
g_value_set_int (value, overlay->size_png);
|
||||||
|
break;
|
||||||
|
case PROP_XPOS_VIDEO:
|
||||||
|
g_value_set_int (value, overlay->pos_x_video);
|
||||||
|
break;
|
||||||
|
case PROP_YPOS_VIDEO:
|
||||||
|
g_value_set_int (value, overlay->pos_y_video);
|
||||||
|
break;
|
||||||
|
case PROP_SIZE_VIDEO:
|
||||||
|
g_value_set_int (value, overlay->size_video);
|
||||||
|
break;
|
||||||
|
case PROP_VIDEOTOP:
|
||||||
|
g_value_set_boolean (value, overlay->video_top);
|
||||||
break;
|
break;
|
||||||
/* case PROP_STRETCH:
|
/* case PROP_STRETCH:
|
||||||
g_value_set_boolean (value, overlay->stretch);
|
g_value_set_boolean (value, overlay->stretch);
|
||||||
|
@ -321,7 +470,10 @@ gst_gl_overlay_callback (gint width, gint height, guint texture, gpointer stuff)
|
||||||
glMatrixMode (GL_PROJECTION);
|
glMatrixMode (GL_PROJECTION);
|
||||||
glLoadIdentity ();
|
glLoadIdentity ();
|
||||||
|
|
||||||
gst_gl_overlay_draw_texture (overlay, texture);
|
if (overlay->video_top)
|
||||||
|
gst_gl_overlay_draw_texture_video_on_png (overlay, texture);
|
||||||
|
else
|
||||||
|
gst_gl_overlay_draw_texture_png_on_video (overlay, texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -40,9 +40,13 @@ struct _GstGLOverlay
|
||||||
gchar *location;
|
gchar *location;
|
||||||
gboolean pbuf_has_changed;
|
gboolean pbuf_has_changed;
|
||||||
|
|
||||||
gint8 pos_x;
|
gint8 pos_x_png;
|
||||||
gint8 pos_y;
|
gint8 pos_y_png;
|
||||||
guint8 size;
|
guint8 size_png;
|
||||||
|
gint8 pos_x_video;
|
||||||
|
gint8 pos_y_video;
|
||||||
|
guint8 size_video;
|
||||||
|
gboolean video_top;
|
||||||
guchar *pixbuf;
|
guchar *pixbuf;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
GLuint pbuftexture;
|
GLuint pbuftexture;
|
||||||
|
|
Loading…
Reference in a new issue