mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 01:30:38 +00:00
[406/906] glimagesink: add a client-data property
Also add it to glfilterapp. Fixes #559131
This commit is contained in:
parent
a6a5ee2839
commit
3e1bffc802
6 changed files with 47 additions and 6 deletions
|
@ -150,6 +150,7 @@ gst_gl_display_init (GstGLDisplay * display, GstGLDisplayClass * klass)
|
|||
//client callbacks
|
||||
display->clientReshapeCallback = NULL;
|
||||
display->clientDrawCallback = NULL;
|
||||
display->client_data = NULL;
|
||||
|
||||
//upload
|
||||
display->upload_fbo = 0;
|
||||
|
@ -521,6 +522,8 @@ gst_gl_display_finalize (GObject * object)
|
|||
display->clientReshapeCallback = NULL;
|
||||
if (display->clientDrawCallback)
|
||||
display->clientDrawCallback = NULL;
|
||||
if (display->client_data)
|
||||
display->client_data = NULL;
|
||||
if (display->use_fbo_scene_cb)
|
||||
display->use_fbo_scene_cb = NULL;
|
||||
if (display->use_fbo_scene_cb_v2)
|
||||
|
@ -1808,7 +1811,7 @@ gst_gl_display_on_resize (GstGLDisplay * display, gint width, gint height)
|
|||
{
|
||||
//check if a client reshape callback is registered
|
||||
if (display->clientReshapeCallback)
|
||||
display->clientReshapeCallback (width, height);
|
||||
display->clientReshapeCallback (width, height, display->client_data);
|
||||
|
||||
//default reshape
|
||||
else {
|
||||
|
@ -1860,7 +1863,8 @@ gst_gl_display_on_draw (GstGLDisplay * display)
|
|||
if (display->clientDrawCallback) {
|
||||
gboolean doRedisplay =
|
||||
display->clientDrawCallback (display->redisplay_texture,
|
||||
display->redisplay_texture_width, display->redisplay_texture_height);
|
||||
display->redisplay_texture_width, display->redisplay_texture_height,
|
||||
display->client_data);
|
||||
|
||||
if (doRedisplay && display->gl_window)
|
||||
gst_gl_window_draw_unlocked (display->gl_window,
|
||||
|
@ -2483,6 +2487,14 @@ gst_gl_display_set_client_draw_callback (GstGLDisplay * display, CDCB cb)
|
|||
gst_gl_display_unlock (display);
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_display_set_client_data (GstGLDisplay * display, gpointer data)
|
||||
{
|
||||
gst_gl_display_lock (display);
|
||||
display->client_data = data;
|
||||
gst_gl_display_unlock (display);
|
||||
}
|
||||
|
||||
gulong
|
||||
gst_gl_display_get_internal_gl_context (GstGLDisplay * display)
|
||||
{
|
||||
|
|
|
@ -66,8 +66,8 @@ typedef struct _GstGLDisplayTex
|
|||
|
||||
|
||||
//Client callbacks
|
||||
typedef void (*CRCB) (GLuint, GLuint);
|
||||
typedef gboolean (*CDCB) (GLuint, GLuint, GLuint);
|
||||
typedef void (*CRCB) (GLuint, GLuint, gpointer);
|
||||
typedef gboolean (*CDCB) (GLuint, GLuint, GLuint, gpointer);
|
||||
|
||||
typedef void (*GstGLDisplayThreadFunc) (GstGLDisplay * display, gpointer data);
|
||||
|
||||
|
@ -117,6 +117,7 @@ struct _GstGLDisplay
|
|||
//client callbacks
|
||||
CRCB clientReshapeCallback;
|
||||
CDCB clientDrawCallback;
|
||||
gpointer client_data;
|
||||
|
||||
//upload
|
||||
GLuint upload_fbo;
|
||||
|
@ -283,6 +284,7 @@ void gst_gl_display_set_window_id (GstGLDisplay * display, gulong window_id);
|
|||
void gst_gl_display_set_client_reshape_callback (GstGLDisplay * display,
|
||||
CRCB cb);
|
||||
void gst_gl_display_set_client_draw_callback (GstGLDisplay * display, CDCB cb);
|
||||
void gst_gl_display_set_client_data (GstGLDisplay * display, gpointer data);
|
||||
|
||||
gulong gst_gl_display_get_internal_gl_context (GstGLDisplay * display);
|
||||
void gst_gl_display_activate_gl_context (GstGLDisplay * display, gboolean activate);
|
||||
|
|
|
@ -55,7 +55,8 @@ enum
|
|||
{
|
||||
PROP_0,
|
||||
PROP_CLIENT_RESHAPE_CALLBACK,
|
||||
PROP_CLIENT_DRAW_CALLBACK
|
||||
PROP_CLIENT_DRAW_CALLBACK,
|
||||
PROP_CLIENT_DATA
|
||||
};
|
||||
|
||||
#define DEBUG_INIT(bla) \
|
||||
|
@ -106,6 +107,10 @@ gst_gl_filter_app_class_init (GstGLFilterAppClass * klass)
|
|||
g_object_class_install_property (gobject_class, PROP_CLIENT_DRAW_CALLBACK,
|
||||
g_param_spec_pointer ("client_draw_callback", "Client draw callback",
|
||||
"Define a custom draw callback in a client code", G_PARAM_WRITABLE));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_CLIENT_DATA,
|
||||
g_param_spec_pointer ("client_data", "Client data",
|
||||
"Pass data to the draw and reshape callbacks", G_PARAM_WRITABLE));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -113,6 +118,7 @@ gst_gl_filter_app_init (GstGLFilterApp * filter, GstGLFilterAppClass * klass)
|
|||
{
|
||||
filter->clientReshapeCallback = NULL;
|
||||
filter->clientDrawCallback = NULL;
|
||||
filter->client_data = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -132,6 +138,11 @@ gst_gl_filter_app_set_property (GObject * object, guint prop_id,
|
|||
filter->clientDrawCallback = g_value_get_pointer (value);
|
||||
break;
|
||||
}
|
||||
case PROP_CLIENT_DATA:
|
||||
{
|
||||
filter->client_data = g_value_get_pointer (value);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -172,7 +183,7 @@ gst_gl_filter_app_filter (GstGLFilter * filter, GstGLBuffer * inbuf,
|
|||
filter->fbo, filter->depthbuffer, outbuf->texture,
|
||||
app_filter->clientDrawCallback, inbuf->width, inbuf->height,
|
||||
inbuf->texture, 45, (gfloat) filter->width / (gfloat) filter->height,
|
||||
0.1, 100, GST_GL_DISPLAY_PROJECTION_PERSPECTIVE, NULL);
|
||||
0.1, 100, GST_GL_DISPLAY_PROJECTION_PERSPECTIVE, app_filter->client_data);
|
||||
}
|
||||
//default
|
||||
else {
|
||||
|
|
|
@ -40,6 +40,7 @@ struct _GstGLFilterApp
|
|||
|
||||
CRCB clientReshapeCallback;
|
||||
GLCB clientDrawCallback;
|
||||
gpointer client_data;
|
||||
};
|
||||
|
||||
struct _GstGLFilterAppClass
|
||||
|
|
|
@ -156,6 +156,7 @@ enum
|
|||
ARG_DISPLAY,
|
||||
PROP_CLIENT_RESHAPE_CALLBACK,
|
||||
PROP_CLIENT_DRAW_CALLBACK,
|
||||
PROP_CLIENT_DATA,
|
||||
PROP_FORCE_ASPECT_RATIO
|
||||
};
|
||||
|
||||
|
@ -226,6 +227,10 @@ gst_glimage_sink_class_init (GstGLImageSinkClass * klass)
|
|||
g_param_spec_pointer ("client_draw_callback", "Client draw callback",
|
||||
"Define a custom draw callback in a client code", G_PARAM_WRITABLE));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_CLIENT_DATA,
|
||||
g_param_spec_pointer ("client_data", "Client data",
|
||||
"Pass data to the draw and reshape callbacks", G_PARAM_WRITABLE));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_FORCE_ASPECT_RATIO,
|
||||
g_param_spec_boolean ("force-aspect-ratio",
|
||||
"Force aspect ratio",
|
||||
|
@ -254,6 +259,7 @@ gst_glimage_sink_init (GstGLImageSink * glimage_sink,
|
|||
glimage_sink->stored_buffer = NULL;
|
||||
glimage_sink->clientReshapeCallback = NULL;
|
||||
glimage_sink->clientDrawCallback = NULL;
|
||||
glimage_sink->client_data = NULL;
|
||||
glimage_sink->keep_aspect_ratio = FALSE;
|
||||
}
|
||||
|
||||
|
@ -284,6 +290,11 @@ gst_glimage_sink_set_property (GObject * object, guint prop_id,
|
|||
glimage_sink->clientDrawCallback = g_value_get_pointer (value);
|
||||
break;
|
||||
}
|
||||
case PROP_CLIENT_DATA:
|
||||
{
|
||||
glimage_sink->client_data = g_value_get_pointer (value);
|
||||
break;
|
||||
}
|
||||
case PROP_FORCE_ASPECT_RATIO:
|
||||
{
|
||||
glimage_sink->keep_aspect_ratio = g_value_get_boolean (value);
|
||||
|
@ -485,6 +496,9 @@ gst_glimage_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
|
|||
gst_gl_display_set_client_draw_callback (glimage_sink->display,
|
||||
glimage_sink->clientDrawCallback);
|
||||
|
||||
gst_gl_display_set_client_data (glimage_sink->display,
|
||||
glimage_sink->client_data);
|
||||
|
||||
ok &= gst_video_parse_caps_framerate (caps, &fps_n, &fps_d);
|
||||
ok &= gst_video_parse_caps_pixel_aspect_ratio (caps, &par_n, &par_d);
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ struct _GstGLImageSink
|
|||
|
||||
CRCB clientReshapeCallback;
|
||||
CDCB clientDrawCallback;
|
||||
gpointer client_data;
|
||||
|
||||
gboolean keep_aspect_ratio;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue