2008-11-05 01:06:33 +00:00
|
|
|
/*
|
2008-10-22 23:40:52 +00:00
|
|
|
* GStreamer
|
|
|
|
* Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
|
2012-11-14 09:36:16 +00:00
|
|
|
* Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
|
2008-10-22 23:40:52 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-08 11:53:56 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2008-10-22 23:40:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GST_GL_WINDOW_H__
|
|
|
|
#define __GST_GL_WINDOW_H__
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
|
|
|
|
2013-07-11 09:03:31 +00:00
|
|
|
#include <gst/gl/gstgl_fwd.h>
|
2013-11-23 11:57:49 +00:00
|
|
|
#include <gst/gl/gstglcontext.h>
|
|
|
|
#include <gst/gl/gstgldisplay.h>
|
2012-11-14 09:36:16 +00:00
|
|
|
|
2008-10-22 23:40:52 +00:00
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
2016-10-05 01:19:12 +00:00
|
|
|
GST_EXPORT
|
|
|
|
GType gst_gl_window_get_type (void);
|
|
|
|
#define GST_TYPE_GL_WINDOW (gst_gl_window_get_type())
|
|
|
|
|
|
|
|
/* FIXME: remove this when moving to -base */
|
2017-03-04 09:15:58 +00:00
|
|
|
#ifndef GST_DISABLE_DEPRECATED
|
2017-03-04 09:47:04 +00:00
|
|
|
#define GST_GL_TYPE_WINDOW GST_TYPE_GL_WINDOW
|
2017-03-04 09:15:58 +00:00
|
|
|
#endif
|
2016-10-05 01:19:12 +00:00
|
|
|
#define GST_GL_WINDOW(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_GL_WINDOW, GstGLWindow))
|
|
|
|
#define GST_GL_WINDOW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GST_TYPE_GL_WINDOW, GstGLWindowClass))
|
|
|
|
#define GST_IS_GL_WINDOW(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_GL_WINDOW))
|
|
|
|
#define GST_IS_GL_WINDOW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_GL_WINDOW))
|
|
|
|
#define GST_GL_WINDOW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_GL_WINDOW, GstGLWindowClass))
|
2008-10-22 23:40:52 +00:00
|
|
|
|
2013-11-25 09:34:06 +00:00
|
|
|
#define GST_GL_WINDOW_LOCK(w) g_mutex_lock(&GST_GL_WINDOW(w)->lock)
|
|
|
|
#define GST_GL_WINDOW_UNLOCK(w) g_mutex_unlock(&GST_GL_WINDOW(w)->lock)
|
2012-11-13 11:12:20 +00:00
|
|
|
#define GST_GL_WINDOW_GET_LOCK(w) (&GST_GL_WINDOW(w)->lock)
|
|
|
|
|
2016-10-05 01:19:12 +00:00
|
|
|
GST_EXPORT
|
|
|
|
GQuark gst_gl_window_error_quark (void);
|
2017-07-28 10:00:12 +00:00
|
|
|
/**
|
|
|
|
* GST_GL_WINDOW_ERROR:
|
|
|
|
*
|
|
|
|
* Error domain for GStreamer's GL window module. Errors in this domain will be
|
|
|
|
* from the #GstGLWindowError enumeration
|
|
|
|
*/
|
2008-10-22 23:40:52 +00:00
|
|
|
#define GST_GL_WINDOW_ERROR (gst_gl_window_error_quark ())
|
|
|
|
|
2016-11-03 01:03:24 +00:00
|
|
|
/**
|
|
|
|
* GstGLWindowError:
|
|
|
|
* @GST_GL_WINDOW_ERROR_FAILED: failed for a unspecified reason
|
|
|
|
* @GST_GL_WINDOW_ERROR_OLD_LIBS: the implementation is too old
|
|
|
|
* @GST_GL_WINDOW_ERROR_RESOURCE_UNAVAILABLE: no such resource was found
|
|
|
|
*/
|
2012-12-08 22:30:48 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
GST_GL_WINDOW_ERROR_FAILED,
|
2013-01-08 06:40:39 +00:00
|
|
|
GST_GL_WINDOW_ERROR_OLD_LIBS,
|
2012-12-08 22:30:48 +00:00
|
|
|
GST_GL_WINDOW_ERROR_RESOURCE_UNAVAILABLE,
|
|
|
|
} GstGLWindowError;
|
|
|
|
|
2012-11-13 11:12:20 +00:00
|
|
|
typedef void (*GstGLWindowCB) (gpointer data);
|
|
|
|
typedef void (*GstGLWindowResizeCB) (gpointer data, guint width, guint height);
|
2008-10-22 23:40:52 +00:00
|
|
|
|
2017-07-28 10:00:12 +00:00
|
|
|
/**
|
|
|
|
* GST_GL_WINDOW_CB:
|
|
|
|
* @f: the function to cast
|
|
|
|
*
|
|
|
|
* Cast to the currect function type for generic window callbacks
|
|
|
|
*/
|
2008-11-05 01:06:33 +00:00
|
|
|
#define GST_GL_WINDOW_CB(f) ((GstGLWindowCB) (f))
|
2017-07-28 10:00:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GST_GL_WINDOW_RESIZE_CB:
|
|
|
|
* @f: the function to cast
|
|
|
|
*
|
|
|
|
* Cast to the currect function type for window resize callbacks
|
|
|
|
*/
|
2012-11-13 11:12:20 +00:00
|
|
|
#define GST_GL_WINDOW_RESIZE_CB(f) ((GstGLWindowResizeCB) (f))
|
|
|
|
|
2013-11-23 11:57:49 +00:00
|
|
|
/**
|
|
|
|
* GstGLWindow:
|
|
|
|
*
|
|
|
|
* #GstGLWindow is an opaque struct and should only be accessed through the
|
|
|
|
* provided api.
|
|
|
|
*/
|
2008-10-22 23:40:52 +00:00
|
|
|
struct _GstGLWindow {
|
|
|
|
/*< private >*/
|
2014-05-08 05:30:49 +00:00
|
|
|
GstObject parent;
|
2012-11-13 11:12:20 +00:00
|
|
|
|
|
|
|
GMutex lock;
|
|
|
|
|
2013-11-25 22:32:32 +00:00
|
|
|
GstGLDisplay *display;
|
2013-08-14 00:44:19 +00:00
|
|
|
GWeakRef context_ref;
|
|
|
|
|
2016-12-14 13:59:45 +00:00
|
|
|
/*< protected >*/
|
2013-11-06 21:55:49 +00:00
|
|
|
gboolean is_drawing;
|
|
|
|
|
2012-11-13 11:12:20 +00:00
|
|
|
GstGLWindowCB draw;
|
|
|
|
gpointer draw_data;
|
2013-07-15 13:58:04 +00:00
|
|
|
GDestroyNotify draw_notify;
|
2012-11-13 11:12:20 +00:00
|
|
|
GstGLWindowCB close;
|
|
|
|
gpointer close_data;
|
2013-07-15 13:58:04 +00:00
|
|
|
GDestroyNotify close_notify;
|
2012-11-13 11:12:20 +00:00
|
|
|
GstGLWindowResizeCB resize;
|
|
|
|
gpointer resize_data;
|
2013-07-15 13:58:04 +00:00
|
|
|
GDestroyNotify resize_notify;
|
2012-11-13 11:12:20 +00:00
|
|
|
|
2015-09-17 07:06:37 +00:00
|
|
|
gboolean queue_resize;
|
|
|
|
|
2016-12-14 13:59:45 +00:00
|
|
|
GMainContext *main_context; /* default main_context */
|
|
|
|
|
2012-11-13 11:12:20 +00:00
|
|
|
/*< private >*/
|
2013-06-12 13:17:30 +00:00
|
|
|
GstGLWindowPrivate *priv;
|
2015-01-23 05:39:44 +00:00
|
|
|
|
|
|
|
gpointer _reserved[GST_PADDING];
|
2008-10-22 23:40:52 +00:00
|
|
|
};
|
|
|
|
|
2013-11-23 11:57:49 +00:00
|
|
|
/**
|
|
|
|
* GstGLWindowClass:
|
|
|
|
* @parent_class: Parent class
|
|
|
|
* @get_display: Gets the current windowing system display connection
|
2016-10-26 05:30:43 +00:00
|
|
|
* @set_window_handle: Set a window handle to render into
|
|
|
|
* @get_window_handle: Gets the current window handle that this #GstGLWindow is
|
|
|
|
* rendering into. This may return a different value to
|
|
|
|
* what is passed into @set_window_handle
|
2013-11-23 11:57:49 +00:00
|
|
|
* @draw: redraw the window with the specified dimensions
|
|
|
|
* @run: run the mainloop
|
|
|
|
* @quit: send a quit to the mainloop
|
|
|
|
* @send_message: invoke a function on the window thread. Required to be reentrant.
|
|
|
|
* @send_message_async: invoke a function on the window thread. @run may or may
|
|
|
|
* not have been called. Required to be reentrant.
|
|
|
|
* @open: open the connection to the display
|
|
|
|
* @close: close the connection to the display
|
2015-01-23 05:39:44 +00:00
|
|
|
* @handle_events: whether to handle 'extra' events from the windowing system.
|
|
|
|
* Basic events like surface moves and resizes are still valid
|
|
|
|
* things to listen for.
|
|
|
|
* @set_preferred_size: request that the window change surface size. The
|
|
|
|
* implementation is free to ignore this information.
|
2016-11-03 01:03:24 +00:00
|
|
|
* @show: request that the window be shown to the user
|
|
|
|
* @set_render_rectangle: request a rectangle to render into. See #GstVideoOverlay
|
|
|
|
* @queue_resize: request a resize to occur when possible
|
2013-11-23 11:57:49 +00:00
|
|
|
*/
|
2008-10-22 23:40:52 +00:00
|
|
|
struct _GstGLWindowClass {
|
2014-05-08 05:30:49 +00:00
|
|
|
GstObjectClass parent_class;
|
2012-11-14 09:36:16 +00:00
|
|
|
|
2013-08-15 07:09:04 +00:00
|
|
|
guintptr (*get_display) (GstGLWindow *window);
|
2017-01-10 09:07:09 +00:00
|
|
|
void (*set_window_handle) (GstGLWindow *window, guintptr handle);
|
2013-08-15 07:09:04 +00:00
|
|
|
guintptr (*get_window_handle) (GstGLWindow *window);
|
2015-01-23 03:11:48 +00:00
|
|
|
void (*draw) (GstGLWindow *window);
|
2012-12-03 04:04:49 +00:00
|
|
|
void (*run) (GstGLWindow *window);
|
2013-07-15 13:58:04 +00:00
|
|
|
void (*quit) (GstGLWindow *window);
|
2012-12-03 04:04:49 +00:00
|
|
|
void (*send_message) (GstGLWindow *window, GstGLWindowCB callback, gpointer data);
|
2013-09-25 02:26:57 +00:00
|
|
|
void (*send_message_async) (GstGLWindow *window, GstGLWindowCB callback, gpointer data, GDestroyNotify destroy);
|
2012-11-13 11:12:20 +00:00
|
|
|
|
2013-06-13 06:04:40 +00:00
|
|
|
gboolean (*open) (GstGLWindow *window, GError **error);
|
|
|
|
void (*close) (GstGLWindow *window);
|
2014-10-29 11:24:16 +00:00
|
|
|
void (*handle_events) (GstGLWindow *window, gboolean handle_events);
|
2015-01-23 03:11:48 +00:00
|
|
|
void (*set_preferred_size) (GstGLWindow *window, gint width, gint height);
|
2015-01-29 11:25:00 +00:00
|
|
|
void (*show) (GstGLWindow *window);
|
2015-05-29 08:03:52 +00:00
|
|
|
gboolean (*set_render_rectangle)(GstGLWindow *window, gint x, gint y, gint width, gint height);
|
2015-09-17 07:06:37 +00:00
|
|
|
void (*queue_resize) (GstGLWindow *window);
|
2013-06-13 06:04:40 +00:00
|
|
|
|
2012-11-13 11:12:20 +00:00
|
|
|
/*< private >*/
|
|
|
|
gpointer _reserved[GST_PADDING];
|
2008-10-22 23:40:52 +00:00
|
|
|
};
|
|
|
|
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2013-06-12 13:17:30 +00:00
|
|
|
GstGLWindow * gst_gl_window_new (GstGLDisplay *display);
|
2012-11-13 11:12:20 +00:00
|
|
|
|
2015-01-23 05:39:44 +00:00
|
|
|
/* callbacks */
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2015-01-23 05:39:44 +00:00
|
|
|
void gst_gl_window_set_draw_callback (GstGLWindow *window,
|
|
|
|
GstGLWindowCB callback,
|
|
|
|
gpointer data,
|
|
|
|
GDestroyNotify destroy_notify);
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2015-01-23 05:39:44 +00:00
|
|
|
void gst_gl_window_set_resize_callback (GstGLWindow *window,
|
|
|
|
GstGLWindowResizeCB callback,
|
|
|
|
gpointer data,
|
|
|
|
GDestroyNotify destroy_notify);
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2015-01-23 05:39:44 +00:00
|
|
|
void gst_gl_window_set_close_callback (GstGLWindow *window,
|
|
|
|
GstGLWindowCB callback,
|
|
|
|
gpointer data,
|
|
|
|
GDestroyNotify destroy_notify);
|
2012-11-13 11:12:20 +00:00
|
|
|
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2012-11-13 11:12:20 +00:00
|
|
|
void gst_gl_window_set_window_handle (GstGLWindow *window, guintptr handle);
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2012-11-13 11:12:20 +00:00
|
|
|
guintptr gst_gl_window_get_window_handle (GstGLWindow *window);
|
2015-01-23 05:39:44 +00:00
|
|
|
|
|
|
|
/* loop/events */
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2012-11-13 11:12:20 +00:00
|
|
|
void gst_gl_window_run (GstGLWindow *window);
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2013-07-15 13:58:04 +00:00
|
|
|
void gst_gl_window_quit (GstGLWindow *window);
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2015-01-23 05:39:44 +00:00
|
|
|
void gst_gl_window_send_message (GstGLWindow *window,
|
|
|
|
GstGLWindowCB callback,
|
|
|
|
gpointer data);
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2015-01-23 05:39:44 +00:00
|
|
|
void gst_gl_window_send_message_async (GstGLWindow *window,
|
|
|
|
GstGLWindowCB callback,
|
|
|
|
gpointer data,
|
|
|
|
GDestroyNotify destroy);
|
|
|
|
|
|
|
|
/* navigation */
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2015-01-23 05:39:44 +00:00
|
|
|
void gst_gl_window_handle_events (GstGLWindow * window,
|
|
|
|
gboolean handle_events);
|
2015-12-21 10:27:09 +00:00
|
|
|
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2015-01-23 05:39:44 +00:00
|
|
|
void gst_gl_window_send_key_event (GstGLWindow * window,
|
|
|
|
const char * event_type,
|
|
|
|
const char * key_str);
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2015-01-23 05:39:44 +00:00
|
|
|
void gst_gl_window_send_mouse_event (GstGLWindow * window,
|
|
|
|
const char * event_type,
|
|
|
|
int button,
|
|
|
|
double posx,
|
|
|
|
double posy);
|
|
|
|
|
|
|
|
/* surfaces/rendering */
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2015-09-17 07:06:37 +00:00
|
|
|
void gst_gl_window_queue_resize (GstGLWindow *window);
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2015-01-23 05:39:44 +00:00
|
|
|
void gst_gl_window_draw (GstGLWindow *window);
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2015-01-29 11:25:00 +00:00
|
|
|
void gst_gl_window_show (GstGLWindow *window);
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2015-01-23 05:39:44 +00:00
|
|
|
void gst_gl_window_set_preferred_size (GstGLWindow * window,
|
|
|
|
gint width,
|
|
|
|
gint height);
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2015-01-23 05:39:44 +00:00
|
|
|
void gst_gl_window_get_surface_dimensions (GstGLWindow * window,
|
|
|
|
guint * width,
|
|
|
|
guint * height);
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2015-05-29 08:03:52 +00:00
|
|
|
gboolean gst_gl_window_set_render_rectangle (GstGLWindow * window,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height);
|
2015-01-23 05:39:44 +00:00
|
|
|
|
2015-09-17 07:06:37 +00:00
|
|
|
/* subclass usage only */
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2015-09-17 07:06:37 +00:00
|
|
|
void gst_gl_window_resize (GstGLWindow *window, guint width, guint height);
|
|
|
|
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2015-01-23 05:39:44 +00:00
|
|
|
GstGLContext * gst_gl_window_get_context (GstGLWindow *window);
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2015-01-23 05:39:44 +00:00
|
|
|
guintptr gst_gl_window_get_display (GstGLWindow *window);
|
2014-07-06 20:39:47 +00:00
|
|
|
|
2008-10-22 23:40:52 +00:00
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* __GST_GL_WINDOW_H__ */
|