1/*
2 * GStreamer
3 * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
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
21#ifndef __GST_GL_DEBUG_H__
22#define __GST_GL_DEBUG_H__
23
24#include <gst/gl/gstgl_fwd.h>
25
26G_BEGIN_DECLS
27
28typedef gchar * (*GstGLAsyncDebugLogGetMessage) (gpointer user_data);
29
30/**
31 * GstGLAsyncDebug:
32 *
33 * #GstGLAsyncDebug an opaque structure and should only be accessed through the
34 * provided API.
35 */
36struct _GstGLAsyncDebug
37{
38 /*< private >*/
39 guint state_flags;
40 GstDebugCategory *cat;
41 GstDebugLevel level;
42 const gchar *file;
43 const gchar *function;
44 gint line;
45 GObject *object;
46 gchar *debug_msg;
47
48 /*< protected >*/
49 GstGLAsyncDebugLogGetMessage callback;
50 gpointer user_data;
51 GDestroyNotify notify;
52
53 gpointer _padding[GST_PADDING];
54};
55
56GST_GL_API
57GstGLAsyncDebug * gst_gl_async_debug_new (void);
58GST_GL_API
59void gst_gl_async_debug_free (GstGLAsyncDebug * ad);
60GST_GL_API
61void gst_gl_async_debug_init (GstGLAsyncDebug * ad);
62GST_GL_API
63void gst_gl_async_debug_unset (GstGLAsyncDebug * ad);
64GST_GL_API
65void gst_gl_async_debug_freeze (GstGLAsyncDebug * ad);
66GST_GL_API
67void gst_gl_async_debug_thaw (GstGLAsyncDebug * ad);
68
69/**
70 * GST_GL_ASYNC_CAT_LEVEL_LOG_valist:
71 * @ad: the #GstGLAsyncDebug to store the message in
72 * @cat: the #GstDebugCategory to output the message in
73 * @level: the #GstDebugLevel
74 * @object: (allow-none): a #GObject to associate with the debug message
75 * @format: a printf style format string
76 * @varargs: the list of arguments for @format
77 *
78 * Stores a debug message in @ad for later output
79 */
80#define GST_GL_ASYNC_CAT_LEVEL_LOG_valist(ad,cat,level,object,format,varargs) \
81 gst_gl_async_debug_store_log_msg_valist (ad, cat, level, __FILE__, \
82 GST_FUNCTION, __LINE__, object, format, varargs)
83
84/**
85 * GST_GL_ASYNC_CAT_LEVEL_LOG:
86 * @ad: the #GstGLAsyncDebug to store the message in
87 * @cat: the #GstDebugCategory to output the message in
88 * @level: the #GstDebugLevel
89 * @object: (allow-none): a #GObject to associate with the debug message
90 * @format: a printf style format string
91 * @...: the list of arguments for @format
92 *
93 * Stores a debug message in @ad for later output
94 */
95#ifdef G_HAVE_ISO_VARARGS
96#define GST_GL_ASYNC_CAT_LEVEL_LOG(ad,cat,level,object,format,...) \
97 gst_gl_async_debug_store_log_msg (ad, cat, level, __FILE__, GST_FUNCTION, \
98 __LINE__, object, format, __VA_ARGS__)
99#else /* G_HAVE_ISO_VARARGS */
100#if G_HAVE_GNUC_VARARGS
101#define GST_GL_ASYNC_CAT_LEVEL_LOG(ad,cat,level,object,format,args...) \
102 gst_gl_async_debug_store_log_msg (ad, cat, level, __FILE__, GST_FUNCTION, \
103 __LINE__, object, format, ##args)
104#else /* G_HAVE_GNUC_VARARGS */
105static inline void
106GST_GL_ASYNC_CAT_LEVEL_LOG(GstGLAsyncDebug * ad, GstDebugCategory * cat,
107 GstDebugLevel level, GObject * object, const gchar * format, ...)
108{
109 va_list varargs;
110
111 va_start (varargs, format);
112 GST_GL_ASYNC_CAT_LEVEL_LOG_valist (ad, cat, level, object, format, varargs);
113 va_end (varargs);
114}
115#endif /* G_HAVE_GNUC_VARARGS */
116#endif /* G_HAVE_ISO_VARARGS */
117
118#if !defined(GST_DISABLE_GST_DEBUG)
119
120GST_GL_API
121void gst_gl_insert_debug_marker (GstGLContext * context,
122 const gchar * format, ...) G_GNUC_PRINTF (2, 3);
123GST_GL_API
124void gst_gl_async_debug_output_log_msg (GstGLAsyncDebug * ad);
125GST_GL_API
126void gst_gl_async_debug_store_log_msg (GstGLAsyncDebug * ad,
127 GstDebugCategory * cat,
128 GstDebugLevel level,
129 const gchar * file,
130 const gchar * function,
131 gint line,
132 GObject * object,
133 const gchar * format, ...) G_GNUC_PRINTF (8, 9);
134GST_GL_API
135void gst_gl_async_debug_store_log_msg_valist (GstGLAsyncDebug * ad,
136 GstDebugCategory * cat,
137 GstDebugLevel level,
138 const gchar * file,
139 const gchar * function,
140 gint line,
141 GObject * object,
142 const gchar * format,
143 va_list varargs) G_GNUC_PRINTF (8, 0);
144
145#else /* GST_DISABLE_GST_DEBUG */
146
147#define gst_gl_async_debug_output_log_msg(ad) G_STMT_START{ }G_STMT_END
148#define gst_gl_async_debug_store_log_msg_valist(ad,cat,level,file,function,line,object,format,args) G_STMT_START{ }G_STMT_END
149
150#ifdef G_HAVE_ISO_VARARGS
151
152#define gst_gl_insert_debug_marker(...) G_STMT_START{ }G_STMT_END
153#define gst_gl_async_debug_store_log_msg(...) G_STMT_START{ }G_STMT_END
154
155#else /* G_HAVE_ISO_VARARGS */
156#if G_HAVE_GNUC_VARARGS
157
158#define gst_gl_insert_debug_marker(args...) G_STMT_START{ }G_STMT_END
159#define gst_gl_async_debug_store_log_msg(args...) G_STMT_START{ }G_STMT_END
160
161#else /* G_HAVE_GNUC_VARARGS */
162
163static inline void
164gst_gl_insert_debug_marker (GstGLContext * context, const gchar * format, ...)
165{
166}
167
168static inline void
169gst_gl_async_debug_store_log_msg (GstGLAsyncDebug * ad,
170 GstDebugCategory * cat, GstDebugLevel level, const gchar * file,
171 const gchar * function, gint line, GstObject * object,
172 const gchar * format, ...)
173{
174}
175
176#endif /* G_HAVE_GNUC_VARARGS */
177#endif /* G_HAVE_ISO_VARARGS */
178#endif /* GST_DISABLE_GST_DEBUG */
179
180G_END_DECLS
181
182#endif /* __GST_GL_DEBUG_H__ */
183

source code of include/gstreamer-1.0/gst/gl/gstgldebug.h