gstglcontext.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * GStreamer
  3. * Copyright (C) 2012 Matthew Waters <[email protected]>
  4. *
  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.
  9. *
  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.
  14. *
  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.
  19. */
  20. #ifndef __GST_GL_CONTEXT_H__
  21. #define __GST_GL_CONTEXT_H__
  22. #include <gst/gst.h>
  23. #include <gst/gl/gl.h>
  24. G_BEGIN_DECLS
  25. #define GST_GL_TYPE_CONTEXT (gst_gl_context_get_type())
  26. #define GST_GL_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_GL_TYPE_CONTEXT, GstGLContext))
  27. #define GST_GL_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS((k), GST_GL_TYPE_CONTEXT, GstGLContextClass))
  28. #define GST_GL_IS_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_GL_TYPE_CONTEXT))
  29. #define GST_GL_IS_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_GL_TYPE_CONTEXT))
  30. #define GST_GL_CONTEXT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_GL_TYPE_CONTEXT, GstGLContextClass))
  31. GType gst_gl_context_get_type (void);
  32. #define GST_GL_CONTEXT_ERROR (gst_gl_context_error_quark ())
  33. GQuark gst_gl_context_error_quark (void);
  34. /**
  35. * GstGLContextThreadFunc:
  36. * @context: a #GstGLContext
  37. * @data: user data
  38. *
  39. * Represents a function to run in the GL thread with @context and @data
  40. */
  41. typedef void (*GstGLContextThreadFunc) (GstGLContext * context, gpointer data);
  42. #define GST_GL_CONTEXT_TYPE_CGL "gst.gl.context.CGL"
  43. #define GST_GL_CONTEXT_TYPE_GLX "gst.gl.context.GLX"
  44. #define GST_GL_CONTEXT_TYPE_EGL "gst.gl.context.EGL"
  45. #define GST_GL_CONTEXT_TYPE_WGL "gst.gl.context.WGL"
  46. #define GST_GL_CONTEXT_TYPE_EAGL "gst.gl.context.EAGL"
  47. typedef enum
  48. {
  49. GST_GL_CONTEXT_ERROR_FAILED,
  50. GST_GL_CONTEXT_ERROR_WRONG_CONFIG,
  51. GST_GL_CONTEXT_ERROR_WRONG_API,
  52. GST_GL_CONTEXT_ERROR_OLD_LIBS,
  53. GST_GL_CONTEXT_ERROR_CREATE_CONTEXT,
  54. GST_GL_CONTEXT_ERROR_RESOURCE_UNAVAILABLE,
  55. } GstGLContextError;
  56. /**
  57. * GstGLContext:
  58. *
  59. * Opaque #GstGLContext object
  60. */
  61. struct _GstGLContext {
  62. /*< private >*/
  63. GstObject parent;
  64. GstGLWindow *window;
  65. GstGLFuncs *gl_vtable;
  66. gpointer _reserved[GST_PADDING];
  67. GstGLContextPrivate *priv;
  68. };
  69. /**
  70. * GstGLContextClass:
  71. * @get_gl_context: get the backing platform specific OpenGL context
  72. * @get_gl_api: get the available OpenGL api's that this context can work with
  73. * @get_proc_address: get an function pointer to an OpenGL function
  74. * @activate: call eglMakeCurrent or similar
  75. * @choose_format: choose a format for the framebuffer
  76. * @create_context: create the OpenGL context
  77. * @destroy_context: destroy the OpenGL context
  78. * @swap_buffers: swap the default framebuffer's front/back buffers
  79. */
  80. struct _GstGLContextClass {
  81. GstObjectClass parent_class;
  82. guintptr (*get_gl_context) (GstGLContext *context);
  83. GstGLAPI (*get_gl_api) (GstGLContext *context);
  84. GstGLPlatform (*get_gl_platform) (GstGLContext *context);
  85. gpointer (*get_proc_address) (GstGLContext *context, const gchar *name);
  86. gboolean (*activate) (GstGLContext *context, gboolean activate);
  87. gboolean (*choose_format) (GstGLContext *context, GError **error);
  88. gboolean (*create_context) (GstGLContext *context, GstGLAPI gl_api,
  89. GstGLContext *other_context, GError ** error);
  90. void (*destroy_context) (GstGLContext *context);
  91. void (*swap_buffers) (GstGLContext *context);
  92. gboolean (*check_feature) (GstGLContext *context, const gchar *feature);
  93. /*< private >*/
  94. gpointer _reserved[GST_PADDING];
  95. };
  96. /* methods */
  97. GstGLContext * gst_gl_context_new (GstGLDisplay *display);
  98. GstGLContext * gst_gl_context_new_wrapped (GstGLDisplay *display,
  99. guintptr handle,
  100. GstGLPlatform context_type,
  101. GstGLAPI available_apis);
  102. gboolean gst_gl_context_activate (GstGLContext *context, gboolean activate);
  103. GThread * gst_gl_context_get_thread (GstGLContext *context);
  104. GstGLDisplay * gst_gl_context_get_display (GstGLContext *context);
  105. gpointer gst_gl_context_get_proc_address (GstGLContext *context, const gchar *name);
  106. GstGLPlatform gst_gl_context_get_gl_platform (GstGLContext *context);
  107. GstGLAPI gst_gl_context_get_gl_api (GstGLContext *context);
  108. guintptr gst_gl_context_get_gl_context (GstGLContext *context);
  109. gboolean gst_gl_context_can_share (GstGLContext * context, GstGLContext *other_context);
  110. gboolean gst_gl_context_create (GstGLContext *context, GstGLContext *other_context, GError ** error);
  111. gpointer gst_gl_context_default_get_proc_address (GstGLContext *context, const gchar *name);
  112. gboolean gst_gl_context_set_window (GstGLContext *context, GstGLWindow *window);
  113. GstGLWindow * gst_gl_context_get_window (GstGLContext *context);
  114. void gst_gl_context_get_gl_version (GstGLContext *context, gint *maj, gint *min);
  115. gboolean gst_gl_context_check_gl_version (GstGLContext * context, GstGLAPI api, gint maj, gint min);
  116. gboolean gst_gl_context_check_feature (GstGLContext *context, const gchar *feature);
  117. /* FIXME: remove */
  118. void gst_gl_context_thread_add (GstGLContext * context,
  119. GstGLContextThreadFunc func, gpointer data);
  120. G_END_DECLS
  121. #endif /* __GST_GL_CONTEXT_H__ */