mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 17:50:36 +00:00
parent
32e401427f
commit
a7a5c7ee8a
2 changed files with 195 additions and 130 deletions
|
@ -79,7 +79,11 @@ enum
|
|||
PROP_XPOS_VIDEO,
|
||||
PROP_YPOS_VIDEO,
|
||||
PROP_SIZE_VIDEO,
|
||||
PROP_VIDEOTOP
|
||||
PROP_VIDEOTOP,
|
||||
PROP_ROTATE_PNG,
|
||||
PROP_ROTATE_VIDEO,
|
||||
PROP_ANGLE_PNG,
|
||||
PROP_ANGLE_VIDEO
|
||||
};
|
||||
|
||||
|
||||
|
@ -176,6 +180,34 @@ gst_gl_overlay_class_init (GstGLOverlayClass * klass)
|
|||
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,
|
||||
PROP_ROTATE_PNG,
|
||||
g_param_spec_int ("rotate_png",
|
||||
"choose rotation axis for the moment only Y axis is implemented",
|
||||
"choose rotation axis for the moment only Y axis is implemented",
|
||||
0, 3, 0, G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_ROTATE_VIDEO,
|
||||
g_param_spec_int ("rotate_video",
|
||||
"choose rotation axis for the moment only Y axis is implemented",
|
||||
"choose rotation axis for the moment only Y axis is implemented",
|
||||
0, 3, 0, G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_ANGLE_PNG,
|
||||
g_param_spec_int ("angle_png",
|
||||
"choose angle in axis to choosen between -90 and 90",
|
||||
"choose angle in axis to choosen between -90 and 90",
|
||||
-90, 90, 0, G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_ANGLE_VIDEO,
|
||||
g_param_spec_int ("angle_video",
|
||||
"choose angle in axis to choosen between -90 and 90",
|
||||
"choose angle in axis to choosen between -90 and 90",
|
||||
-90, 90, 0, G_PARAM_READWRITE));
|
||||
/*
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_STRETCH,
|
||||
|
@ -190,13 +222,122 @@ static void
|
|||
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;
|
||||
gfloat width = (gfloat) filter->width;
|
||||
gfloat height = (gfloat) filter->height;
|
||||
gfloat ratio = 0.0;
|
||||
gfloat translate = 0.0;
|
||||
|
||||
// if (overlay->stretch) {
|
||||
// width = (gfloat) overlay->width;
|
||||
// height = (gfloat) overlay->height;
|
||||
// }
|
||||
if (overlay->pbuftexture != 0) {
|
||||
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;
|
||||
ratio = ((posx + (size / 2)) - (posx - (size / 2))) * height / width;
|
||||
translate = overlay->size_png / 400.0;
|
||||
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, overlay->pbuftexture);
|
||||
glLoadIdentity ();
|
||||
glTranslatef (0.0f, translate, -1.0f);
|
||||
if (overlay->rotate_png == 2)
|
||||
glRotatef (overlay->angle_png, 0, 1, 0);
|
||||
glBegin (GL_QUADS);
|
||||
glTexCoord3f (0.0, 0.0, 0.0);
|
||||
glVertex3f (posx - (size / 2), posy - (size / 2), 0.0);
|
||||
glTexCoord3f (width, 0.0, 0.0);
|
||||
glVertex3f (posx + (size / 2), posy - (size / 2), 0.0);
|
||||
glTexCoord3f (width, height, 0.0);
|
||||
glVertex3f (posx + (size / 2), posy - (size / 2) + ratio, 0.0);
|
||||
glTexCoord3f (0.0, height, 0.0);
|
||||
glVertex3f (posx - (size / 2), posy - (size / 2) + ratio, 0.0);
|
||||
glEnd ();
|
||||
}
|
||||
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;
|
||||
ratio = ((posx + (size / 2)) - (posx - (size / 2))) * height / width;
|
||||
translate = overlay->size_video / 400.0;
|
||||
glActiveTexture (GL_TEXTURE0);
|
||||
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, tex);
|
||||
glLoadIdentity ();
|
||||
glTranslatef (0.0f, translate, -1.0f);
|
||||
if (overlay->rotate_video)
|
||||
glRotatef (overlay->angle_video, 0, 1, 0);
|
||||
glBegin (GL_QUADS);
|
||||
glTexCoord3f (0.0, 0.0, 0.0);
|
||||
glVertex3f (posx - (size / 2), posy - (size / 2), 0.0);
|
||||
glTexCoord3f (width, 0.0, 0.0);
|
||||
glVertex3f (posx + (size / 2), posy - (size / 2), 0.0);
|
||||
glTexCoord3f (width, height, 0.0);
|
||||
glVertex3f (posx + (size / 2), posy - (size / 2) + ratio, 0.0);
|
||||
glTexCoord3f (0.0, height, 0.0);
|
||||
glVertex3f (posx - (size / 2), posy - (size / 2) + ratio, 0.0);
|
||||
glEnd ();
|
||||
glFlush ();
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_overlay_draw_texture_png_on_video (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) filter->width;
|
||||
gfloat height = (gfloat) filter->height;
|
||||
gfloat ratio = 0.0;
|
||||
gfloat translate = 0.0;
|
||||
|
||||
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;
|
||||
ratio = ((posx + (size / 2)) - (posx - (size / 2))) * height / width;
|
||||
translate = overlay->size_video / 400.0;
|
||||
glActiveTexture (GL_TEXTURE0);
|
||||
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, tex);
|
||||
glLoadIdentity ();
|
||||
glTranslatef (0.0f, translate, -1.0f);
|
||||
if (overlay->rotate_video)
|
||||
glRotatef (overlay->angle_video, 0, 1, 0);
|
||||
glBegin (GL_QUADS);
|
||||
glTexCoord3f (0.0, 0.0, 0.0);
|
||||
glVertex3f (posx - (size / 2), posy - (size / 2), 0.0);
|
||||
glTexCoord3f (width, 0.0, 0.0);
|
||||
glVertex3f (posx + (size / 2), posy - (size / 2), 0.0);
|
||||
glTexCoord3f (width, height, 0.0);
|
||||
glVertex3f (posx + (size / 2), posy - (size / 2) + ratio, 0.0);
|
||||
glTexCoord3f (0.0, height, 0.0);
|
||||
glVertex3f (posx - (size / 2), posy - (size / 2) + ratio, 0.0);
|
||||
glEnd ();
|
||||
if (overlay->pbuftexture == 0)
|
||||
return;
|
||||
|
||||
|
@ -204,142 +345,34 @@ gst_gl_overlay_draw_texture_video_on_png (GstGLOverlay * overlay, GLuint tex)
|
|||
//width = (gfloat) overlay->width;
|
||||
//height = (gfloat) overlay->height;
|
||||
// }
|
||||
|
||||
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;
|
||||
ratio = ((posx + (size / 2)) - (posx - (size / 2))) * height / width;
|
||||
translate = overlay->size_png / 400.0;
|
||||
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable (GL_BLEND);
|
||||
|
||||
glEnable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, overlay->pbuftexture);
|
||||
|
||||
glLoadIdentity ();
|
||||
glTranslatef (0.0f, translate, -1.0f);
|
||||
if (overlay->rotate_png == 2)
|
||||
glRotatef (overlay->angle_png, 0, 1, 0);
|
||||
glBegin (GL_QUADS);
|
||||
|
||||
size = (overlay->size_png) / 50.0f;
|
||||
posx = (overlay->pos_x_png - 50.0f) / 50.0f;
|
||||
posx =
|
||||
(posx - (size / 2) < -1.00) ? (-1.0f + size / 2) : (posx + (size / 2) >
|
||||
1.00) ? (1.0f - size / 2) : posx;
|
||||
posy = (overlay->pos_y_png - 50.0f) / 50.0f;
|
||||
posy =
|
||||
(posy - (size / 2) < -1.00) ? (-1.0f + size / 2) : (posy + (size / 2) >
|
||||
1.00) ? (1.0f - size / 2) : posy;
|
||||
|
||||
glTexCoord2f (0.0f, 0.0f);
|
||||
glVertex2f (posx - (size / 2), posy - (size / 2));
|
||||
glTexCoord2f (width, 0.0f);
|
||||
glVertex2f (posx + (size / 2), posy - (size / 2));
|
||||
glTexCoord2f (width, height);
|
||||
glVertex2f (posx + (size / 2), posy + (size / 2));
|
||||
glTexCoord2f (0.0f, height);
|
||||
glVertex2f (posx - (size / 2), posy + (size / 2));
|
||||
|
||||
glTexCoord3f (0.0, 0.0, 0.0);
|
||||
glVertex3f (posx - (size / 2), posy - (size / 2), 0.0);
|
||||
glTexCoord3f (width, 0.0, 0.0);
|
||||
glVertex3f (posx + (size / 2), posy - (size / 2), 0.0);
|
||||
glTexCoord3f (width, height, 0.0);
|
||||
glVertex3f (posx + (size / 2), posy - (size / 2) + ratio, 0.0);
|
||||
glTexCoord3f (0.0, height, 0.0);
|
||||
glVertex3f (posx - (size / 2), posy - (size / 2) + ratio, 0.0);
|
||||
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.0f;
|
||||
posx = (overlay->pos_x_video - 50.0f) / 50.0f;
|
||||
posx =
|
||||
(posx - (size / 2) < -1.00) ? (-1.0f + size / 2) : (posx + (size / 2) >
|
||||
1.00) ? (1.0f - size / 2) : posx;
|
||||
posy = (overlay->pos_y_video - 50.0f) / 50.0f;
|
||||
posy =
|
||||
(posy - (size / 2) < -1.00) ? (-1.0f + size / 2) : (posy + (size / 2) >
|
||||
1.00) ? (1.0f - 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);
|
||||
|
||||
gfloat posx = 0.0;
|
||||
gfloat posy = 0.0;
|
||||
gfloat size = 0.0;
|
||||
gfloat width = (gfloat) filter->width;
|
||||
gfloat 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.0f;
|
||||
posx = (overlay->pos_x_video - 50.0f) / 50.0f;
|
||||
posx =
|
||||
(posx - (size / 2) < -1.00) ? (-1.0f + size / 2) : (posx + (size / 2) >
|
||||
1.00) ? (1.0f - size / 2) : posx;
|
||||
posy = (overlay->pos_y_video - 50.0f) / 50.0f;
|
||||
posy =
|
||||
(posy - (size / 2) < -1.00) ? (-1.0f + size / 2) : (posy + (size / 2) >
|
||||
1.00) ? (1.0f - 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 ();
|
||||
|
||||
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.0f;
|
||||
posx = (overlay->pos_x_png - 50.0f) / 50.0f;
|
||||
posx =
|
||||
(posx - (size / 2) < -1.00) ? (-1.0f + size / 2) : (posx + (size / 2) >
|
||||
1.00) ? (1.0f - size / 2) : posx;
|
||||
posy = (overlay->pos_y_png - 50.0f) / 50.0f;
|
||||
posy =
|
||||
(posy - (size / 2) < -1.00) ? (-1.0f + size / 2) : (posy + (size / 2) >
|
||||
1.00) ? (1.0f - size / 2) : posy;
|
||||
|
||||
glTexCoord2f (0.0f, 0.0f);
|
||||
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 ();
|
||||
}
|
||||
|
||||
|
@ -354,13 +387,17 @@ gst_gl_overlay_init (GstGLOverlay * overlay, GstGLOverlayClass * klass)
|
|||
overlay->pbuftexture = 0;
|
||||
overlay->width = 0;
|
||||
overlay->height = 0;
|
||||
overlay->pos_x_png = 0;
|
||||
overlay->pos_y_png = 0;
|
||||
overlay->pos_x_png = 0.0;
|
||||
overlay->pos_y_png = 0.0;
|
||||
overlay->size_png = 100;
|
||||
overlay->pos_x_video = 0;
|
||||
overlay->pos_y_video = 0;
|
||||
overlay->pos_x_video = 0.0;
|
||||
overlay->pos_y_video = 0.0;
|
||||
overlay->size_video = 100;
|
||||
overlay->video_top = FALSE;
|
||||
overlay->rotate_png = 0;
|
||||
overlay->rotate_video = 0;
|
||||
overlay->angle_png = 0;
|
||||
overlay->angle_video = 0;
|
||||
// overlay->stretch = TRUE;
|
||||
overlay->pbuf_has_changed = FALSE;
|
||||
}
|
||||
|
@ -405,6 +442,18 @@ gst_gl_overlay_set_property (GObject * object, guint prop_id,
|
|||
case PROP_VIDEOTOP:
|
||||
overlay->video_top = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_ROTATE_PNG:
|
||||
overlay->rotate_png = g_value_get_int (value);
|
||||
break;
|
||||
case PROP_ROTATE_VIDEO:
|
||||
overlay->rotate_video = g_value_get_int (value);
|
||||
break;
|
||||
case PROP_ANGLE_PNG:
|
||||
overlay->angle_png = g_value_get_int (value);
|
||||
break;
|
||||
case PROP_ANGLE_VIDEO:
|
||||
overlay->angle_video = g_value_get_int (value);
|
||||
break;
|
||||
/* case PROP_STRETCH:
|
||||
overlay->stretch = g_value_get_boolean (value);
|
||||
break;
|
||||
|
@ -446,6 +495,18 @@ gst_gl_overlay_get_property (GObject * object, guint prop_id,
|
|||
case PROP_VIDEOTOP:
|
||||
g_value_set_boolean (value, overlay->video_top);
|
||||
break;
|
||||
case PROP_ROTATE_PNG:
|
||||
g_value_set_int (value, overlay->rotate_png);
|
||||
break;
|
||||
case PROP_ROTATE_VIDEO:
|
||||
g_value_set_int (value, overlay->rotate_video);
|
||||
break;
|
||||
case PROP_ANGLE_PNG:
|
||||
g_value_set_int (value, overlay->angle_png);
|
||||
break;
|
||||
case PROP_ANGLE_VIDEO:
|
||||
g_value_set_int (value, overlay->angle_video);
|
||||
break;
|
||||
/* case PROP_STRETCH:
|
||||
g_value_set_boolean (value, overlay->stretch);
|
||||
break;
|
||||
|
@ -469,7 +530,9 @@ gst_gl_overlay_callback (gint width, gint height, guint texture, gpointer stuff)
|
|||
|
||||
glMatrixMode (GL_PROJECTION);
|
||||
glLoadIdentity ();
|
||||
|
||||
gluPerspective (70.0f, (GLfloat) width / (GLfloat) height, 0.0f, 1000.0f);
|
||||
glMatrixMode (GL_MODELVIEW);
|
||||
glLoadIdentity ();
|
||||
if (overlay->video_top)
|
||||
gst_gl_overlay_draw_texture_video_on_png (overlay, texture);
|
||||
else
|
||||
|
|
|
@ -36,10 +36,8 @@ typedef struct _GstGLOverlayClass GstGLOverlayClass;
|
|||
struct _GstGLOverlay
|
||||
{
|
||||
GstGLFilter filter;
|
||||
|
||||
gchar *location;
|
||||
gboolean pbuf_has_changed;
|
||||
|
||||
gint8 pos_x_png;
|
||||
gint8 pos_y_png;
|
||||
guint8 size_png;
|
||||
|
@ -47,6 +45,10 @@ struct _GstGLOverlay
|
|||
gint8 pos_y_video;
|
||||
guint8 size_video;
|
||||
gboolean video_top;
|
||||
guint8 rotate_png;
|
||||
guint8 rotate_video;
|
||||
gint8 angle_png;
|
||||
gint8 angle_video;
|
||||
guchar *pixbuf;
|
||||
gint width, height;
|
||||
GLuint pbuftexture;
|
||||
|
|
Loading…
Reference in a new issue