3 * Copyright (C) 2019 Nirbheek Chauhan <nirbheek@centricular.com>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
24 #include <gst/gl/gstglcontext.h>
25 #include <gst/gl/egl/gstglcontext_egl.h>
27 #include "gstglwindow_winrt_egl.h"
28 #include "../gstglwindow_private.h"
30 #define GST_CAT_DEFAULT gst_gl_window_debug
32 #define GST_GL_WINDOW_WINRT_EGL_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
33 GST_TYPE_GL_WINDOW_WINRT_EGL, GstGLWindowWinRTEGLPrivate))
36 G_DEFINE_TYPE (GstGLWindowWinRTEGL, gst_gl_window_winrt_egl,
39 static guintptr gst_gl_window_winrt_egl_get_display (GstGLWindow * window);
40 static guintptr gst_gl_window_winrt_egl_get_window_handle (GstGLWindow *
42 static void gst_gl_window_winrt_egl_set_window_handle (GstGLWindow * window,
46 gst_gl_window_winrt_egl_class_init (GstGLWindowWinRTEGLClass * klass)
48 GstGLWindowClass *window_class = (GstGLWindowClass *) klass;
50 window_class->get_display =
51 GST_DEBUG_FUNCPTR (gst_gl_window_winrt_egl_get_display);
52 window_class->get_window_handle =
53 GST_DEBUG_FUNCPTR (gst_gl_window_winrt_egl_get_window_handle);
54 window_class->set_window_handle =
55 GST_DEBUG_FUNCPTR (gst_gl_window_winrt_egl_set_window_handle);
59 gst_gl_window_winrt_egl_init (GstGLWindowWinRTEGL * window_winrt)
64 gst_gl_window_winrt_egl_set_window_handle (GstGLWindow * window,
67 GstGLWindowWinRTEGL *window_egl = GST_GL_WINDOW_WINRT_EGL (window);
69 GST_INFO_OBJECT (window, "Setting WinRT EGL window handle: %p", handle);
71 window_egl->window = (EGLNativeWindowType) handle;
75 gst_gl_window_winrt_egl_get_window_handle (GstGLWindow * window)
77 GstGLWindowWinRTEGL *window_egl = GST_GL_WINDOW_WINRT_EGL (window);
79 GST_INFO_OBJECT (window, "Getting WinRT EGL window handle");
81 return (guintptr) window_egl->window;
84 /* Must be called in the gl thread */
86 gst_gl_window_winrt_egl_new (GstGLDisplay * display)
88 GstGLWindowWinRTEGL *window_egl;
90 GST_INFO_OBJECT (display, "Trying to create WinRT EGL window");
92 if ((gst_gl_display_get_handle_type (display) & GST_GL_DISPLAY_TYPE_EGL) == 0)
93 /* we require an EGL display to create windows */
96 GST_INFO_OBJECT (display, "Creating WinRT EGL window");
98 window_egl = g_object_new (GST_TYPE_GL_WINDOW_WINRT_EGL, NULL);
104 gst_gl_window_winrt_egl_get_display (GstGLWindow * window)
106 /* EGL_DEFAULT_DISPLAY */