1 | /* |
2 | * GStreamer |
3 | * Copyright (C) 2016 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_QUERY_H__ |
22 | #define __GST_GL_QUERY_H__ |
23 | |
24 | #include <gst/gl/gstgl_fwd.h> |
25 | #include <gst/gl/gstgldebug.h> |
26 | |
27 | G_BEGIN_DECLS |
28 | |
29 | /** |
30 | * GstGLQueryType: |
31 | * @GST_GL_QUERY_NONE: no query |
32 | * @GST_GL_QUERY_TIME_ELAPSED: query the time elapsed |
33 | * @GST_GL_QUERY_TIMESTAMP: query the current time |
34 | */ |
35 | typedef enum |
36 | { |
37 | GST_GL_QUERY_NONE, |
38 | GST_GL_QUERY_TIME_ELAPSED, |
39 | GST_GL_QUERY_TIMESTAMP, |
40 | } GstGLQueryType; |
41 | |
42 | /** |
43 | * GstGLQuery: |
44 | * |
45 | * Opaque #GstGLQuery struct |
46 | */ |
47 | struct _GstGLQuery |
48 | { |
49 | /*< private >*/ |
50 | GstGLContext * context; |
51 | guint query_type; |
52 | guint query_id; |
53 | gboolean supported; |
54 | |
55 | gboolean start_called; |
56 | GstGLAsyncDebug debug; |
57 | |
58 | gpointer _padding[GST_PADDING]; |
59 | }; |
60 | |
61 | GST_GL_API |
62 | void gst_gl_query_init (GstGLQuery * query, |
63 | GstGLContext * context, |
64 | GstGLQueryType query_type); |
65 | GST_GL_API |
66 | void gst_gl_query_unset (GstGLQuery * query); |
67 | GST_GL_API |
68 | GstGLQuery * gst_gl_query_new (GstGLContext * context, |
69 | GstGLQueryType query_type); |
70 | GST_GL_API |
71 | void gst_gl_query_free (GstGLQuery * query); |
72 | |
73 | GST_GL_API |
74 | void gst_gl_query_start (GstGLQuery * query); |
75 | GST_GL_API |
76 | void gst_gl_query_end (GstGLQuery * query); |
77 | GST_GL_API |
78 | void gst_gl_query_counter (GstGLQuery * query); |
79 | GST_GL_API |
80 | guint64 gst_gl_query_result (GstGLQuery * query); |
81 | |
82 | #define gst_gl_query_start_log_valist(query,cat,level,object,format,varargs) \ |
83 | G_STMT_START { \ |
84 | GST_GL_ASYNC_CAT_LEVEL_LOG_valist (&(query)->debug, cat, level, object, format, varargs); \ |
85 | gst_gl_async_debug_freeze (&(query)->debug); \ |
86 | gst_gl_query_start (query); \ |
87 | gst_gl_async_debug_thaw (&(query)->debug); \ |
88 | } G_STMT_END |
89 | |
90 | #define gst_gl_query_counter_log_valist(query,cat,level,object,format,varargs) \ |
91 | G_STMT_START { \ |
92 | GST_GL_ASYNC_CAT_LEVEL_LOG_valist (&(query)->debug, cat, level, object, format, varargs); \ |
93 | gst_gl_async_debug_freeze (&(query)->debug); \ |
94 | gst_gl_query_counter (query); \ |
95 | gst_gl_async_debug_thaw (&(query)->debug); \ |
96 | } G_STMT_END |
97 | |
98 | #ifdef G_HAVE_ISO_VARARGS |
99 | |
100 | #define gst_gl_query_start_log(query,cat,level,object,format,...) \ |
101 | G_STMT_START { \ |
102 | GST_GL_ASYNC_CAT_LEVEL_LOG (&(query)->debug, cat, level, object, format, __VA_ARGS__); \ |
103 | gst_gl_async_debug_freeze (&(query)->debug); \ |
104 | gst_gl_query_start (query); \ |
105 | gst_gl_async_debug_thaw (&(query)->debug); \ |
106 | } G_STMT_END |
107 | #define gst_gl_query_counter_log(query,cat,level,object,format,...) \ |
108 | G_STMT_START { \ |
109 | GST_GL_ASYNC_CAT_LEVEL_LOG (&(query)->debug, cat, level, object, format, __VA_ARGS__); \ |
110 | gst_gl_async_debug_freeze (&(query)->debug); \ |
111 | gst_gl_query_counter (query); \ |
112 | gst_gl_async_debug_thaw (&(query)->debug); \ |
113 | } G_STMT_END |
114 | |
115 | #else /* G_HAVE_ISO_VARARGS */ |
116 | #if G_HAVE_GNUC_VARARGS |
117 | |
118 | #define gst_gl_query_start_log(query,cat,level,object,format,args...) \ |
119 | G_STMT_START { \ |
120 | GST_GL_ASYNC_CAT_LEVEL_LOG (&(query)->debug, cat, level, object, format, ##args); \ |
121 | gst_gl_async_debug_freeze (&(query)->debug); \ |
122 | gst_gl_query_start (query); \ |
123 | gst_gl_async_debug_thaw (&(query)->debug); \ |
124 | } G_STMT_END |
125 | #define gst_gl_query_counter_log(query,cat,level,object,format,args...) \ |
126 | G_STMT_START { \ |
127 | GST_GL_ASYNC_CAT_LEVEL_LOG (&(query)->debug, cat, level, object, format, ##args); \ |
128 | gst_gl_async_debug_freeze (&(query)->debug); \ |
129 | gst_gl_query_counter (query); \ |
130 | gst_gl_async_debug_thaw (&(query)->debug); \ |
131 | } G_STMT_END |
132 | |
133 | #else /* G_HAVE_GNUC_VARARGS */ |
134 | |
135 | static inline void |
136 | gst_gl_query_start_log(GstGLQuery * query, GstDebugCategory * cat, |
137 | GstDebugLevel level, GObject * object, const gchar * format, ...) |
138 | { |
139 | va_list varargs; |
140 | |
141 | va_start (varargs, format); |
142 | gst_gl_query_start_log_valist (query, cat, level, object, format, varargs); |
143 | va_end (varargs); |
144 | } |
145 | |
146 | static inline void |
147 | gst_gl_query_counter_log(GstGLQuery * query, GstDebugCategory * cat, |
148 | GstDebugLevel level, GObject * object, const gchar * format, ...) |
149 | { |
150 | va_list varargs; |
151 | |
152 | va_start (varargs, format); |
153 | gst_gl_query_counter_log_valist (query, cat, level, object, format, varargs); |
154 | va_end (varargs); |
155 | } |
156 | |
157 | #endif /* G_HAVE_GNUC_VARARGS */ |
158 | #endif /* G_HAVE_ISO_VARARGS */ |
159 | |
160 | G_END_DECLS |
161 | |
162 | #endif /* __GST_GL_QUERY_H__ */ |
163 | |