[388/906] just fix builds and indent

This commit is contained in:
Julien Isorce 2009-10-23 10:52:39 +02:00 committed by Tim-Philipp Müller
parent b85ffef956
commit 525701cfca
7 changed files with 199 additions and 93 deletions

View file

@ -23,6 +23,7 @@ add_library (gstgl STATIC
gstgldisplay.c gstgldisplay.c
gstglbuffer.c gstglbuffer.c
gstglfilter.c gstglfilter.c
gstglmixer.c
gstglshader.c) gstglshader.c)
target_link_libraries(gstgl target_link_libraries(gstgl
@ -36,17 +37,18 @@ target_link_libraries(gstgl
else (WIN32) else (WIN32)
if (APPLE) if (APPLE)
include_directories(AFTER include_directories(AFTER
../../..) ../../..)
add_library (gstgl STATIC add_library (gstgl STATIC
gstglwindow_cocoa.m gstglwindow_cocoa.m
gstgldisplay.c gstgldisplay.c
gstglbuffer.c gstglbuffer.c
gstglfilter.c gstglfilter.c
gstglmixer.c
gstglshader.c) gstglshader.c)
target_link_libraries(gstgl target_link_libraries(gstgl
general ${OPENGL_LIBRARIES} general ${OPENGL_LIBRARIES}
general ${GLEW_LIBRARY} general ${GLEW_LIBRARY}
@ -58,23 +60,24 @@ else (WIN32)
"-framework Cocoa") "-framework Cocoa")
else (APPLE) else (APPLE)
include_directories(AFTER include_directories(AFTER
../../..) ../../..)
add_library (gstgl STATIC add_library (gstgl STATIC
gstglwindow_x11.c gstglwindow_x11.c
gstgldisplay.c gstgldisplay.c
gstglbuffer.c gstglbuffer.c
gstglfilter.c gstglfilter.c
gstglmixer.c
gstglshader.c) gstglshader.c)
target_link_libraries(gstgl target_link_libraries(gstgl
general ${OPENGL_LIBRARIES} general ${OPENGL_LIBRARIES}
general ${GLEW_LIBRARY} general ${GLEW_LIBRARY}
general ${GLIB2_LIBRARIES} general ${GLIB2_LIBRARIES}
general ${GSTREAMER_LIBRARIES}) general ${GSTREAMER_LIBRARIES})
endif (APPLE) endif (APPLE)
endif (WIN32) endif (WIN32)

View file

@ -12,6 +12,7 @@ libgstgl_@GST_MAJORMINOR@_la_SOURCES = \
gstgldisplay.c \ gstgldisplay.c \
gstglbuffer.c \ gstglbuffer.c \
gstglfilter.c \ gstglfilter.c \
gstglmixer.c \
gstglshader.c gstglshader.c
if GL_BACKEND_WIN32 if GL_BACKEND_WIN32
@ -33,10 +34,11 @@ libgstgl_@GST_MAJORMINOR@include_HEADERS = \
gstgldisplay.h \ gstgldisplay.h \
gstglbuffer.h \ gstglbuffer.h \
gstglfilter.h \ gstglfilter.h \
gstglmixer.h \
gstglshader.h gstglshader.h
libgstgl_@GST_MAJORMINOR@_la_LIBADD = \ libgstgl_@GST_MAJORMINOR@_la_LIBADD = \
$(GST_PLUGINS_BASE_LIBS) -lgstvideo-$(GST_MAJORMINOR) \ $(GST_PLUGINS_BASE_LIBS) -lgstvideo-$(GST_MAJORMINOR) -lgstcontroller-$(GST_MAJORMINOR) \
$(GST_BASE_LIBS) $(GST_LIBS) \ $(GST_BASE_LIBS) $(GST_LIBS) \
$(GL_LIBS) $(GL_LIBS)

View file

@ -55,7 +55,7 @@ static void gst_gl_filter_set_property (GObject * object, guint prop_id,
static void gst_gl_filter_get_property (GObject * object, guint prop_id, static void gst_gl_filter_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec); GValue * value, GParamSpec * pspec);
static gboolean gst_gl_filter_src_query (GstPad *pad, GstQuery * query); static gboolean gst_gl_filter_src_query (GstPad * pad, GstQuery * query);
static GstCaps *gst_gl_filter_transform_caps (GstBaseTransform * bt, static GstCaps *gst_gl_filter_transform_caps (GstBaseTransform * bt,
GstPadDirection direction, GstCaps * caps); GstPadDirection direction, GstCaps * caps);
@ -121,7 +121,7 @@ static void
gst_gl_filter_init (GstGLFilter * filter, GstGLFilterClass * klass) gst_gl_filter_init (GstGLFilter * filter, GstGLFilterClass * klass)
{ {
GstBaseTransform *base_trans = GST_BASE_TRANSFORM (filter); GstBaseTransform *base_trans = GST_BASE_TRANSFORM (filter);
gst_pad_set_query_function (base_trans->srcpad, gst_pad_set_query_function (base_trans->srcpad,
GST_DEBUG_FUNCPTR (gst_gl_filter_src_query)); GST_DEBUG_FUNCPTR (gst_gl_filter_src_query));
@ -167,10 +167,13 @@ gst_gl_filter_src_query (GstPad * pad, GstQuery * query)
GstStructure *structure = gst_query_get_structure (query); GstStructure *structure = gst_query_get_structure (query);
if (filter->display) { if (filter->display) {
/* this gl filter is a sink in terms of the gl chain */ /* this gl filter is a sink in terms of the gl chain */
gst_structure_set (structure, "gstgldisplay", G_TYPE_POINTER, filter->display, NULL); gst_structure_set (structure, "gstgldisplay", G_TYPE_POINTER,
filter->display, NULL);
} else { } else {
/* at least one gl element is after in our gl chain */ /* at least one gl element is after in our gl chain */
res = g_strcmp0 (gst_element_get_name (parent), gst_structure_get_name (structure)) == 0; res =
g_strcmp0 (gst_element_get_name (parent),
gst_structure_get_name (structure)) == 0;
} }
if (!res) if (!res)
res = gst_pad_query_default (pad, query); res = gst_pad_query_default (pad, query);
@ -214,16 +217,19 @@ gst_gl_filter_start (GstBaseTransform * bt)
GstGLFilter *filter = GST_GL_FILTER (bt); GstGLFilter *filter = GST_GL_FILTER (bt);
GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter); GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
GstElement *parent = GST_ELEMENT (gst_element_get_parent (filter)); GstElement *parent = GST_ELEMENT (gst_element_get_parent (filter));
GstStructure *structure = gst_structure_new (gst_element_get_name (filter), NULL); GstStructure *structure =
gst_structure_new (gst_element_get_name (filter), NULL);
GstQuery *query = gst_query_new_application (GST_QUERY_CUSTOM, structure); GstQuery *query = gst_query_new_application (GST_QUERY_CUSTOM, structure);
gboolean isPerformed = gst_element_query (parent, query); gboolean isPerformed = gst_element_query (parent, query);
if (isPerformed) { if (isPerformed) {
const GValue *id_value = gst_structure_get_value (structure, "gstgldisplay"); const GValue *id_value =
gst_structure_get_value (structure, "gstgldisplay");
if (G_VALUE_HOLDS_POINTER (id_value)) if (G_VALUE_HOLDS_POINTER (id_value))
/* at least one gl element is after in our gl chain */ /* at least one gl element is after in our gl chain */
filter->display = g_object_ref (GST_GL_DISPLAY (g_value_get_pointer (id_value))); filter->display =
g_object_ref (GST_GL_DISPLAY (g_value_get_pointer (id_value)));
else { else {
/* this gl filter is a sink in terms of the gl chain */ /* this gl filter is a sink in terms of the gl chain */
filter->display = gst_gl_display_new (); filter->display = gst_gl_display_new ();
@ -325,7 +331,6 @@ gst_gl_filter_prepare_output_buffer (GstBaseTransform * trans,
GstBuffer * inbuf, gint size, GstCaps * caps, GstBuffer ** buf) GstBuffer * inbuf, gint size, GstCaps * caps, GstBuffer ** buf)
{ {
GstGLFilter *filter = NULL; GstGLFilter *filter = NULL;
GstGLBuffer *gl_inbuf = GST_GL_BUFFER (inbuf);
GstGLBuffer *gl_outbuf = NULL; GstGLBuffer *gl_outbuf = NULL;
filter = GST_GL_FILTER (trans); filter = GST_GL_FILTER (trans);
@ -360,8 +365,7 @@ gst_gl_filter_set_caps (GstBaseTransform * bt, GstCaps * incaps,
&filter->fbo, &filter->depthbuffer); &filter->fbo, &filter->depthbuffer);
if (filter_class->display_init_cb != NULL) { if (filter_class->display_init_cb != NULL) {
gst_gl_display_thread_add (filter->display, gst_gl_filter_start_gl, gst_gl_display_thread_add (filter->display, gst_gl_filter_start_gl, filter);
filter);
} }
if (filter_class->onInitFBO) if (filter_class->onInitFBO)

View file

@ -1,5 +1,5 @@
/* Generic video mixer plugin /* Generic video mixer plugin
/* *
* GStreamer * GStreamer
* Copyright (C) 2009 Julien Isorce <julien.isorce@gmail.com> * Copyright (C) 2009 Julien Isorce <julien.isorce@gmail.com>
* *
@ -58,8 +58,6 @@ static void gst_gl_mixer_pad_set_property (GObject * object, guint prop_id,
static gboolean gst_gl_mixer_src_event (GstPad * pad, GstEvent * event); static gboolean gst_gl_mixer_src_event (GstPad * pad, GstEvent * event);
static gboolean gst_gl_mixer_sink_event (GstPad * pad, GstEvent * event); static gboolean gst_gl_mixer_sink_event (GstPad * pad, GstEvent * event);
static void gst_gl_mixer_sort_pads (GstGLMixer * mix);
enum enum
{ {
@ -110,7 +108,7 @@ gst_gl_mixer_set_master_geometry (GstGLMixer * mix)
gint fps_n = 0; gint fps_n = 0;
gint fps_d = 0; gint fps_d = 0;
GstGLMixerPad *master = NULL; GstGLMixerPad *master = NULL;
while (walk) { while (walk) {
GstGLMixerPad *mixpad = GST_GL_MIXER_PAD (walk->data); GstGLMixerPad *mixpad = GST_GL_MIXER_PAD (walk->data);
@ -129,9 +127,7 @@ gst_gl_mixer_set_master_geometry (GstGLMixer * mix)
} }
/* set results */ /* set results */
if (mix->master != master || if (mix->master != master || mix->fps_n != fps_n || mix->fps_d != fps_d) {
mix->fps_n != fps_n ||
mix->fps_d != fps_d) {
mix->setcaps = TRUE; mix->setcaps = TRUE;
mix->sendseg = TRUE; mix->sendseg = TRUE;
mix->master = master; mix->master = master;
@ -146,7 +142,7 @@ gst_gl_mixer_pad_sink_setcaps (GstPad * pad, GstCaps * vscaps)
GstGLMixer *mix = GST_GL_MIXER (gst_pad_get_parent (pad)); GstGLMixer *mix = GST_GL_MIXER (gst_pad_get_parent (pad));
GstGLMixerPad *mixpad = GST_GL_MIXER_PAD (pad); GstGLMixerPad *mixpad = GST_GL_MIXER_PAD (pad);
GstStructure *structure = gst_caps_get_structure (vscaps, 0); GstStructure *structure = gst_caps_get_structure (vscaps, 0);
gint width = 0; gint width = 0;
gint height = 0; gint height = 0;
gboolean ret = FALSE; gboolean ret = FALSE;
const GValue *framerate = gst_structure_get_value (structure, "framerate"); const GValue *framerate = gst_structure_get_value (structure, "framerate");
@ -154,8 +150,7 @@ gst_gl_mixer_pad_sink_setcaps (GstPad * pad, GstCaps * vscaps)
GST_INFO_OBJECT (mix, "Setting caps %" GST_PTR_FORMAT, vscaps); GST_INFO_OBJECT (mix, "Setting caps %" GST_PTR_FORMAT, vscaps);
if (!gst_structure_get_int (structure, "width", &width) || if (!gst_structure_get_int (structure, "width", &width) ||
!gst_structure_get_int (structure, "height", &height) || !gst_structure_get_int (structure, "height", &height) || !framerate)
! framerate)
goto beach; goto beach;
GST_GL_MIXER_STATE_LOCK (mix); GST_GL_MIXER_STATE_LOCK (mix);
@ -310,8 +305,7 @@ gst_gl_mixer_class_init (GstGLMixerClass * klass)
gstelement_class->request_new_pad = gstelement_class->request_new_pad =
GST_DEBUG_FUNCPTR (gst_gl_mixer_request_new_pad); GST_DEBUG_FUNCPTR (gst_gl_mixer_request_new_pad);
gstelement_class->release_pad = gstelement_class->release_pad = GST_DEBUG_FUNCPTR (gst_gl_mixer_release_pad);
GST_DEBUG_FUNCPTR (gst_gl_mixer_release_pad);
gstelement_class->change_state = gstelement_class->change_state =
GST_DEBUG_FUNCPTR (gst_gl_mixer_change_state); GST_DEBUG_FUNCPTR (gst_gl_mixer_change_state);
@ -379,8 +373,7 @@ gst_gl_mixer_init (GstGLMixer * mix, GstGLMixerClass * g_class)
mix->collect = gst_collect_pads_new (); mix->collect = gst_collect_pads_new ();
gst_collect_pads_set_function (mix->collect, gst_collect_pads_set_function (mix->collect,
(GstCollectPadsFunction) GST_DEBUG_FUNCPTR (gst_gl_mixer_collected), (GstCollectPadsFunction) GST_DEBUG_FUNCPTR (gst_gl_mixer_collected), mix);
mix);
mix->state_lock = g_mutex_new (); mix->state_lock = g_mutex_new ();
@ -599,14 +592,18 @@ gst_gl_mixer_query (GstPad * pad, GstQuery * query)
GSList *walk = mix->sinkpads; GSList *walk = mix->sinkpads;
GstStructure *structure = gst_query_get_structure (query); GstStructure *structure = gst_query_get_structure (query);
const gchar* name = gst_structure_get_name (structure); res =
res = g_strcmp0 (gst_element_get_name (mix), gst_structure_get_name (structure)) == 0; g_strcmp0 (gst_element_get_name (mix),
gst_structure_get_name (structure)) == 0;
if (!res) { if (!res) {
/* id_value is set by upstream element of itself when going to paused state */ /* id_value is set by upstream element of itself when going to paused state */
const GValue *id_value = gst_structure_get_value (structure, "gstgldisplay"); const GValue *id_value =
GstGLDisplay *foreign_display = GST_GL_DISPLAY (g_value_get_pointer (id_value)); gst_structure_get_value (structure, "gstgldisplay");
gulong foreign_gl_context = gst_gl_display_get_internal_gl_context (foreign_display); GstGLDisplay *foreign_display =
GST_GL_DISPLAY (g_value_get_pointer (id_value));
gulong foreign_gl_context =
gst_gl_display_get_internal_gl_context (foreign_display);
/* iterate on each sink pad until reaching the gl element /* iterate on each sink pad until reaching the gl element
* that requested the query */ * that requested the query */
@ -623,8 +620,9 @@ gst_gl_mixer_query (GstPad * pad, GstQuery * query)
gst_gl_display_activate_gl_context (foreign_display, TRUE); gst_gl_display_activate_gl_context (foreign_display, TRUE);
gst_structure_set (structure, "gstgldisplay", G_TYPE_POINTER, sink_pad->display, NULL); gst_structure_set (structure, "gstgldisplay", G_TYPE_POINTER,
sink_pad->display, NULL);
/* does not work: /* does not work:
* res = gst_pad_query_default (GST_PAD_CAST (sink_pad), query);*/ * res = gst_pad_query_default (GST_PAD_CAST (sink_pad), query);*/
res = gst_pad_query (peer, query); res = gst_pad_query (peer, query);
@ -652,9 +650,10 @@ gst_gl_mixer_getcaps (GstPad * pad)
GstStructure *structure = gst_caps_get_structure (caps, 0); GstStructure *structure = gst_caps_get_structure (caps, 0);
gst_structure_set (structure, "width", G_TYPE_INT, 8000, NULL); gst_structure_set (structure, "width", G_TYPE_INT, 8000, NULL);
gst_structure_set (structure, "height", G_TYPE_INT, /*G_MAXINT*/6000, NULL); gst_structure_set (structure, "height", G_TYPE_INT, /*G_MAXINT */ 6000, NULL);
if (mix->fps_d != 0) if (mix->fps_d != 0)
gst_structure_set (structure, "framerate", GST_TYPE_FRACTION, mix->fps_n, mix->fps_d, NULL); gst_structure_set (structure, "framerate", GST_TYPE_FRACTION, mix->fps_n,
mix->fps_d, NULL);
gst_object_unref (mix); gst_object_unref (mix);
@ -667,7 +666,7 @@ gst_gl_mixer_setcaps (GstPad * pad, GstCaps * caps)
GstGLMixer *mix = GST_GL_MIXER (gst_pad_get_parent_element (pad)); GstGLMixer *mix = GST_GL_MIXER (gst_pad_get_parent_element (pad));
GstGLMixerClass *mixer_class = GST_GL_MIXER_GET_CLASS (mix); GstGLMixerClass *mixer_class = GST_GL_MIXER_GET_CLASS (mix);
GstStructure *structure = gst_caps_get_structure (caps, 0); GstStructure *structure = gst_caps_get_structure (caps, 0);
gint width = 0; gint width = 0;
gint height = 0; gint height = 0;
GST_INFO_OBJECT (mix, "set src caps: %" GST_PTR_FORMAT, caps); GST_INFO_OBJECT (mix, "set src caps: %" GST_PTR_FORMAT, caps);
@ -1010,9 +1009,8 @@ gst_gl_mixer_collected (GstCollectPads * pads, GstGLMixer * mix)
if (!ret) if (!ret)
goto error; goto error;
gl_outbuf = gst_gl_buffer_new (mix->display, gl_outbuf = gst_gl_buffer_new (mix->display, mix->width, mix->height);
mix->width, mix->height);
outbuf = GST_BUFFER (gl_outbuf); outbuf = GST_BUFFER (gl_outbuf);
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (mix->srcpad)); gst_buffer_set_caps (outbuf, GST_PAD_CAPS (mix->srcpad));
@ -1217,21 +1215,24 @@ gst_gl_mixer_change_state (GstElement * element, GstStateChange transition)
GSList *walk = mix->sinkpads; GSList *walk = mix->sinkpads;
GstElement *parent = GST_ELEMENT (gst_element_get_parent (mix)); GstElement *parent = GST_ELEMENT (gst_element_get_parent (mix));
GstStructure *structure = gst_structure_new (gst_element_get_name (mix), NULL); GstStructure *structure =
gst_structure_new (gst_element_get_name (mix), NULL);
GstQuery *query = gst_query_new_application (GST_QUERY_CUSTOM, structure); GstQuery *query = gst_query_new_application (GST_QUERY_CUSTOM, structure);
/* retrieve the gldisplay that is owned by gl elements after the gl mixer */ /* retrieve the gldisplay that is owned by gl elements after the gl mixer */
gboolean isPerformed = gst_element_query (parent, query); gboolean isPerformed = gst_element_query (parent, query);
if (isPerformed) { if (isPerformed) {
const GValue *id_value = gst_structure_get_value (structure, "gstgldisplay"); const GValue *id_value =
gst_structure_get_value (structure, "gstgldisplay");
if (G_VALUE_HOLDS_POINTER (id_value)) if (G_VALUE_HOLDS_POINTER (id_value))
/* at least one gl element is after in our gl chain */ /* at least one gl element is after in our gl chain */
mix->display = g_object_ref (GST_GL_DISPLAY (g_value_get_pointer (id_value))); mix->display =
g_object_ref (GST_GL_DISPLAY (g_value_get_pointer (id_value)));
else else
/* this gl filter is a sink in terms of the gl chain */ /* this gl filter is a sink in terms of the gl chain */
mix->display = gst_gl_display_new (); mix->display = gst_gl_display_new ();
gst_gl_display_create_context (mix->display, 0); gst_gl_display_create_context (mix->display, 0);
} }
gst_query_unref (query); gst_query_unref (query);
@ -1244,12 +1245,13 @@ gst_gl_mixer_change_state (GstElement * element, GstStateChange transition)
sink_pad->display = gst_gl_display_new (); sink_pad->display = gst_gl_display_new ();
} }
mix->array_buffers = mix->array_buffers =
g_array_sized_new (FALSE, TRUE, sizeof (GstBuffer *), mix->next_sinkpad); g_array_sized_new (FALSE, TRUE, sizeof (GstBuffer *),
mix->next_sinkpad);
GST_LOG_OBJECT (mix, "starting collectpads"); GST_LOG_OBJECT (mix, "starting collectpads");
gst_collect_pads_start (mix->collect); gst_collect_pads_start (mix->collect);
break; break;
} }
case GST_STATE_CHANGE_PAUSED_TO_READY: case GST_STATE_CHANGE_PAUSED_TO_READY:
{ {
GSList *walk = mix->sinkpads; GSList *walk = mix->sinkpads;
GST_LOG_OBJECT (mix, "stopping collectpads"); GST_LOG_OBJECT (mix, "stopping collectpads");

View file

@ -197,29 +197,30 @@ gst_gl_window_error_quark (void)
} }
gulong gulong
gst_gl_window_get_internal_gl_context (GstGLWindow *window) gst_gl_window_get_internal_gl_context (GstGLWindow * window)
{ {
GstGLWindowPrivate *priv = window->priv; GstGLWindowPrivate *priv = window->priv;
return (gulong) priv->gl_context; return (gulong) priv->gl_context;
} }
void void
callback_activate_gl_context (GstGLWindowPrivate *priv) callback_activate_gl_context (GstGLWindowPrivate * priv)
{ {
/*if (!wglMakeCurrent (priv->device, priv->gl_context)) if (!eglMakeCurrent (priv->gl_display, priv->gl_surface, priv->gl_surface,
g_debug ("failed to activate opengl context %lud\n", GetLastError ());*/ priv->gl_context))
g_debug ("failed to activate opengl context %lud\n", GetLastError ());
} }
void void
callback_inactivate_gl_context (GstGLWindowPrivate *priv) callback_inactivate_gl_context (GstGLWindowPrivate * priv)
{ {
/*if (!wglMakeCurrent (NULL, NULL)) if (!eglMakeCurrent (priv->device, EGL_NO_SURFACE, EGL_NO_SURFACE,
g_debug ("failed to inactivate opengl context %lud\n", GetLastError ());*/ EGL_NO_CONTEXT))
g_debug ("failed to inactivate opengl context %lud\n", GetLastError ());
} }
void void
gst_gl_window_activate_gl_context (GstGLWindow *window, gboolean activate) gst_gl_window_activate_gl_context (GstGLWindow * window, gboolean activate)
{ {
GstGLWindowPrivate *priv = window->priv; GstGLWindowPrivate *priv = window->priv;
if (activate) if (activate)
@ -237,10 +238,10 @@ gst_gl_window_set_external_window_id (GstGLWindow * window, gulong id)
HWND parent_id = GetProp (priv->internal_win_id, "gl_window_parent_id"); HWND parent_id = GetProp (priv->internal_win_id, "gl_window_parent_id");
if (priv->visible) { if (priv->visible) {
ShowWindow (priv->internal_win_id, SW_HIDE); ShowWindow (priv->internal_win_id, SW_HIDE);
priv->visible = FALSE; priv->visible = FALSE;
} }
if (parent_id) { if (parent_id) {
WNDPROC parent_proc = GetProp (parent_id, "gl_window_parent_proc"); WNDPROC parent_proc = GetProp (parent_id, "gl_window_parent_proc");
@ -254,7 +255,6 @@ gst_gl_window_set_external_window_id (GstGLWindow * window, gulong id)
RemoveProp (parent_id, "gl_window_parent_proc"); RemoveProp (parent_id, "gl_window_parent_proc");
RemoveProp (priv->internal_win_id, "gl_window_parent_id"); RemoveProp (priv->internal_win_id, "gl_window_parent_id");
} }
//not 0 //not 0
if (id) { if (id) {
WNDPROC window_parent_proc = WNDPROC window_parent_proc =
@ -282,7 +282,7 @@ gst_gl_window_set_external_window_id (GstGLWindow * window, gulong id)
} else { } else {
//no parent so the internal window needs borders and system menu //no parent so the internal window needs borders and system menu
SetWindowLongPtr (priv->internal_win_id, GWL_STYLE, SetWindowLongPtr (priv->internal_win_id, GWL_STYLE,
WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW); WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW);
} }
} }
@ -339,8 +339,11 @@ gst_gl_window_draw (GstGLWindow * window, gint width, gint height)
RECT rect; RECT rect;
GetClientRect (priv->internal_win_id, &rect); GetClientRect (priv->internal_win_id, &rect);
width += 2 * GetSystemMetrics (SM_CXSIZEFRAME); width += 2 * GetSystemMetrics (SM_CXSIZEFRAME);
height += 2 * GetSystemMetrics (SM_CYSIZEFRAME) + GetSystemMetrics (SM_CYCAPTION); height +=
MoveWindow (priv->internal_win_id, rect.left, rect.top, width, height, FALSE); 2 * GetSystemMetrics (SM_CYSIZEFRAME) +
GetSystemMetrics (SM_CYCAPTION);
MoveWindow (priv->internal_win_id, rect.left, rect.top, width, height,
FALSE);
} }
ShowWindowAsync (priv->internal_win_id, SW_SHOW); ShowWindowAsync (priv->internal_win_id, SW_SHOW);
priv->visible = TRUE; priv->visible = TRUE;
@ -471,11 +474,12 @@ window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
eglCreateContext (priv->display, config, priv->external_gl_context, eglCreateContext (priv->display, config, priv->external_gl_context,
contextAttribs); contextAttribs);
if (priv->gl_context != EGL_NO_CONTEXT) if (priv->gl_context != EGL_NO_CONTEXT)
g_debug ("gl context created: %lud, external: %lud\n", (gulong) priv->gl_context, g_debug ("gl context created: %lud, external: %lud\n",
(gulong) priv->external_gl_context); (gulong) priv->gl_context, (gulong) priv->external_gl_context);
else else
g_debug ("failed to create glcontext %lud, extenal: %lud, win: %lud, %s\n", g_debug
(gulong) priv->gl_context, (gulong) priv->external_gl_context, ("failed to create glcontext %lud, extenal: %lud, win: %lud, %s\n",
(gulong) priv->gl_context, (gulong) priv->external_gl_context,
(gulong) hWnd, EGLErrorString ()); (gulong) hWnd, EGLErrorString ());
ReleaseDC (hWnd, priv->display); ReleaseDC (hWnd, priv->display);

View file

@ -239,7 +239,7 @@ gst_gl_window_init (GstGLWindow * window)
/* Must be called in the gl thread */ /* Must be called in the gl thread */
GstGLWindow * GstGLWindow *
gst_gl_window_new (gint width, gint height, gulong external_gl_context) gst_gl_window_new (gulong external_gl_context)
{ {
GstGLWindow *window = g_object_new (GST_GL_TYPE_WINDOW, NULL); GstGLWindow *window = g_object_new (GST_GL_TYPE_WINDOW, NULL);
GstGLWindowPrivate *priv = window->priv; GstGLWindowPrivate *priv = window->priv;
@ -348,20 +348,20 @@ gst_gl_window_new (gint width, gint height, gulong external_gl_context)
mask = CWBackPixmap | CWBorderPixel | CWColormap | CWEventMask; mask = CWBackPixmap | CWBorderPixel | CWColormap | CWEventMask;
priv->internal_win_id = XCreateWindow (priv->device, priv->root, x, y,
width, height, 0, priv->visual_info->depth, InputOutput,
priv->visual_info->visual, mask, &win_attr);
x += 20; x += 20;
y += 20; y += 20;
priv->internal_win_id = XCreateWindow (priv->device, priv->root, x, y,
1, 1, 0, priv->visual_info->depth, InputOutput,
priv->visual_info->visual, mask, &win_attr);
XSync (priv->device, FALSE); XSync (priv->device, FALSE);
XSetWindowBackgroundPixmap (priv->device, priv->internal_win_id, None); XSetWindowBackgroundPixmap (priv->device, priv->internal_win_id, None);
g_debug ("gl window id: %lud\n", (gulong) priv->internal_win_id); g_debug ("gl window id: %lud\n", (gulong) priv->internal_win_id);
g_debug ("gl window props: x:%d y:%d w:%d h:%d\n", x, y, width, height); g_debug ("gl window props: x:%d y:%d\n", x, y);
wm_atoms[0] = XInternAtom (priv->device, "WM_DELETE_WINDOW", True); wm_atoms[0] = XInternAtom (priv->device, "WM_DELETE_WINDOW", True);
if (wm_atoms[0] == None) if (wm_atoms[0] == None)
@ -410,6 +410,7 @@ gst_gl_window_new (gint width, gint height, gulong external_gl_context)
g_mutex_unlock (priv->x_lock); g_mutex_unlock (priv->x_lock);
return window; return window;
no_display: no_display:
g_mutex_unlock (priv->x_lock); g_mutex_unlock (priv->x_lock);
g_object_unref (window); g_object_unref (window);
@ -422,6 +423,41 @@ gst_gl_window_error_quark (void)
return g_quark_from_static_string ("gst-gl-window-error"); return g_quark_from_static_string ("gst-gl-window-error");
} }
gulong
gst_gl_window_get_internal_gl_context (GstGLWindow * window)
{
GstGLWindowPrivate *priv = window->priv;
return (gulong) priv->gl_context;
}
void
callback_activate_gl_context (GstGLWindowPrivate * priv)
{
if (!glXMakeCurrent (priv->device, priv->internal_win_id, priv->gl_context))
g_debug ("failed to activate opengl context %lud\n",
(gulong) priv->gl_context);
}
void
callback_inactivate_gl_context (GstGLWindowPrivate * priv)
{
if (!glXMakeCurrent (priv->device, None, NULL))
g_debug ("failed to inactivate opengl context %lud\n",
(gulong) priv->gl_context);
}
void
gst_gl_window_activate_gl_context (GstGLWindow * window, gboolean activate)
{
GstGLWindowPrivate *priv = window->priv;
if (activate)
gst_gl_window_send_message (window,
GST_GL_WINDOW_CB (callback_activate_gl_context), priv);
else
gst_gl_window_send_message (window,
GST_GL_WINDOW_CB (callback_inactivate_gl_context), priv);
}
/* Not called by the gl thread */ /* Not called by the gl thread */
void void
gst_gl_window_set_external_window_id (GstGLWindow * window, gulong id) gst_gl_window_set_external_window_id (GstGLWindow * window, gulong id)
@ -494,7 +530,7 @@ gst_gl_window_set_close_callback (GstGLWindow * window, GstGLWindowCB callback,
/* Called in the gl thread */ /* Called in the gl thread */
void void
gst_gl_window_draw_unlocked (GstGLWindow * window) gst_gl_window_draw_unlocked (GstGLWindow * window, gint width, gint height)
{ {
GstGLWindowPrivate *priv = window->priv; GstGLWindowPrivate *priv = window->priv;
@ -522,7 +558,7 @@ gst_gl_window_draw_unlocked (GstGLWindow * window)
/* Not called by the gl thread */ /* Not called by the gl thread */
void void
gst_gl_window_draw (GstGLWindow * window) gst_gl_window_draw (GstGLWindow * window, gint width, gint height)
{ {
if (window) { if (window) {
GstGLWindowPrivate *priv = window->priv; GstGLWindowPrivate *priv = window->priv;
@ -533,13 +569,22 @@ gst_gl_window_draw (GstGLWindow * window)
XEvent event; XEvent event;
XWindowAttributes attr; XWindowAttributes attr;
XGetWindowAttributes (priv->disp_send, priv->internal_win_id, &attr);
if (!priv->visible) { if (!priv->visible) {
if (!priv->parent) {
attr.width = width;
attr.height = height;
XResizeWindow (priv->disp_send, priv->internal_win_id,
attr.width, attr.height);
XSync (priv->disp_send, FALSE);
}
XMapWindow (priv->disp_send, priv->internal_win_id); XMapWindow (priv->disp_send, priv->internal_win_id);
priv->visible = TRUE; priv->visible = TRUE;
} }
XGetWindowAttributes (priv->disp_send, priv->internal_win_id, &attr);
if (priv->parent) { if (priv->parent) {
XWindowAttributes attr_parent; XWindowAttributes attr_parent;
XGetWindowAttributes (priv->disp_send, priv->parent, &attr_parent); XGetWindowAttributes (priv->disp_send, priv->parent, &attr_parent);

View file

@ -247,7 +247,7 @@ gst_gl_window_init (GstGLWindow * window)
/* Must be called in the gl thread */ /* Must be called in the gl thread */
GstGLWindow * GstGLWindow *
gst_gl_window_new (gint width, gint height, gulong external_gl_context) gst_gl_window_new (gulong external_gl_context)
{ {
GstGLWindow *window = g_object_new (GST_GL_TYPE_WINDOW, NULL); GstGLWindow *window = g_object_new (GST_GL_TYPE_WINDOW, NULL);
GstGLWindowPrivate *priv = window->priv; GstGLWindowPrivate *priv = window->priv;
@ -329,20 +329,20 @@ gst_gl_window_new (gint width, gint height, gulong external_gl_context)
mask = CWBackPixmap | CWBorderPixel | CWColormap | CWEventMask; mask = CWBackPixmap | CWBorderPixel | CWColormap | CWEventMask;
priv->internal_win_id = XCreateWindow (priv->device, priv->root, x, y,
width, height, 0, priv->visual_info->depth, InputOutput,
priv->visual_info->visual, mask, &win_attr);
x += 20; x += 20;
y += 20; y += 20;
priv->internal_win_id = XCreateWindow (priv->device, priv->root, x, y,
1, 1, 0, priv->visual_info->depth, InputOutput,
priv->visual_info->visual, mask, &win_attr);
XSync (priv->device, FALSE); XSync (priv->device, FALSE);
XSetWindowBackgroundPixmap (priv->device, priv->internal_win_id, None); XSetWindowBackgroundPixmap (priv->device, priv->internal_win_id, None);
g_debug ("gl window id: %lud\n", (gulong) priv->internal_win_id); g_debug ("gl window id: %lud\n", (gulong) priv->internal_win_id);
g_debug ("gl window props: x:%d y:%d w:%d h:%d\n", x, y, width, height); g_debug ("gl window props: x:%d y:%d\n", x, y);
wm_atoms[0] = XInternAtom (priv->device, "WM_DELETE_WINDOW", True); wm_atoms[0] = XInternAtom (priv->device, "WM_DELETE_WINDOW", True);
if (wm_atoms[0] == None) if (wm_atoms[0] == None)
@ -420,6 +420,43 @@ gst_gl_window_error_quark (void)
return g_quark_from_static_string ("gst-gl-window-error"); return g_quark_from_static_string ("gst-gl-window-error");
} }
gulong
gst_gl_window_get_internal_gl_context (GstGLWindow * window)
{
GstGLWindowPrivate *priv = window->priv;
return (gulong) priv->gl_context;
}
void
callback_activate_gl_context (GstGLWindowPrivate * priv)
{
if (!eglMakeCurrent (priv->gl_display, priv->gl_surface, priv->gl_surface,
priv->gl_context))
g_debug ("failed to activate opengl context %lud\n",
(gulong) priv->gl_context);
}
void
callback_inactivate_gl_context (GstGLWindowPrivate * priv)
{
if (!eglMakeCurrent (priv->device, EGL_NO_SURFACE, EGL_NO_SURFACE,
EGL_NO_CONTEXT))
g_debug ("failed to inactivate opengl context %lud\n",
(gulong) priv->gl_context);
}
void
gst_gl_window_activate_gl_context (GstGLWindow * window, gboolean activate)
{
GstGLWindowPrivate *priv = window->priv;
if (activate)
gst_gl_window_send_message (window,
GST_GL_WINDOW_CB (callback_activate_gl_context), priv);
else
gst_gl_window_send_message (window,
GST_GL_WINDOW_CB (callback_inactivate_gl_context), priv);
}
/* Not called by the gl thread */ /* Not called by the gl thread */
void void
gst_gl_window_set_external_window_id (GstGLWindow * window, gulong id) gst_gl_window_set_external_window_id (GstGLWindow * window, gulong id)
@ -492,7 +529,7 @@ gst_gl_window_set_close_callback (GstGLWindow * window, GstGLWindowCB callback,
/* Called in the gl thread */ /* Called in the gl thread */
void void
gst_gl_window_draw_unlocked (GstGLWindow * window) gst_gl_window_draw_unlocked (GstGLWindow * window, gint width, gint height)
{ {
GstGLWindowPrivate *priv = window->priv; GstGLWindowPrivate *priv = window->priv;
@ -520,7 +557,7 @@ gst_gl_window_draw_unlocked (GstGLWindow * window)
/* Not called by the gl thread */ /* Not called by the gl thread */
void void
gst_gl_window_draw (GstGLWindow * window) gst_gl_window_draw (GstGLWindow * window, gint width, gint height)
{ {
if (window) { if (window) {
GstGLWindowPrivate *priv = window->priv; GstGLWindowPrivate *priv = window->priv;
@ -531,13 +568,22 @@ gst_gl_window_draw (GstGLWindow * window)
XEvent event; XEvent event;
XWindowAttributes attr; XWindowAttributes attr;
XGetWindowAttributes (priv->disp_send, priv->internal_win_id, &attr);
if (!priv->visible) { if (!priv->visible) {
if (!priv->parent) {
attr.width = width;
attr.height = height;
XResizeWindow (priv->disp_send, priv->internal_win_id,
attr.width, attr.height);
XSync (priv->disp_send, FALSE);
}
XMapWindow (priv->disp_send, priv->internal_win_id); XMapWindow (priv->disp_send, priv->internal_win_id);
priv->visible = TRUE; priv->visible = TRUE;
} }
XGetWindowAttributes (priv->disp_send, priv->internal_win_id, &attr);
if (priv->parent) { if (priv->parent) {
XWindowAttributes attr_parent; XWindowAttributes attr_parent;
XGetWindowAttributes (priv->disp_send, priv->parent, &attr_parent); XGetWindowAttributes (priv->disp_send, priv->parent, &attr_parent);