1 /*
2  * GStreamer
3  * Copyright (C) 2014 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_SYNC_META_H__
22 #define __GST_GL_SYNC_META_H__
23 
24 #include <gst/gl/gstgl_fwd.h>
25 
26 G_BEGIN_DECLS
27 
28 #define GST_GL_SYNC_META_API_TYPE (gst_gl_sync_meta_api_get_type())
29 #define GST_GL_SYNC_META_INFO     (gst_gl_sync_meta_get_info())
30 typedef struct _GstGLSyncMeta GstGLSyncMeta;
31 
32 /**
33  * GST_BUFFER_POOL_OPTION_GL_SYNC_META:
34  *
35  * An option that can be activated on bufferpools to request OpenGL
36  * synchronization metadata on buffers from the pool.
37  */
38 #define GST_BUFFER_POOL_OPTION_GL_SYNC_META "GstBufferPoolOptionGLSyncMeta"
39 
40 /**
41  * GstGLSyncMeta:
42  * @parent: the parent #GstMeta
43  * @context: the #GstGLContext used to allocate the meta
44  * @data: a custom data pointer for the implementation
45  * @set_sync: set a sync point in the OpenGL command stream
46  * @set_sync_gl: the same as @set_sync but called from @context's thread
47  * @wait: execute a wait on the previously set sync point into the OpenGL command stream
48  * @wait_gl: the same as @wait but called from @context's thread
49  * @wait_cpu: wait for the previously set sync point to pass from the CPU
50  * @wait_cpu_gl: the same as @wait_cpu but called from @context's thread
51  * @copy: copy @data into a new #GstGLSyncMeta
52  * @free: free @data
53  * @free_gl: free @data in @context's thread
54  */
55 struct _GstGLSyncMeta
56 {
57   GstMeta parent;
58 
59   GstGLContext *context;
60 
61   gpointer      data;
62 
63   void (*set_sync) (GstGLSyncMeta * sync, GstGLContext * context);
64   void (*set_sync_gl) (GstGLSyncMeta * sync, GstGLContext * context);
65   void (*wait) (GstGLSyncMeta * sync, GstGLContext * context);
66   void (*wait_gl) (GstGLSyncMeta * sync, GstGLContext * context);
67   void (*wait_cpu) (GstGLSyncMeta * sync, GstGLContext * context);
68   void (*wait_cpu_gl) (GstGLSyncMeta * sync, GstGLContext * context);
69   void (*copy) (GstGLSyncMeta * src, GstBuffer * sbuffer, GstGLSyncMeta * dest, GstBuffer * dbuffer);
70   void (*free) (GstGLSyncMeta * sync, GstGLContext * context);
71   void (*free_gl) (GstGLSyncMeta * sync, GstGLContext * context);
72 };
73 
74 GST_GL_API
75 GType gst_gl_sync_meta_api_get_type (void);
76 GST_GL_API
77 const GstMetaInfo * gst_gl_sync_meta_get_info (void);
78 
79 #define gst_buffer_get_gl_sync_meta(b) ((GstGLSyncMeta*)gst_buffer_get_meta((b),GST_GL_SYNC_META_API_TYPE))
80 
81 GST_GL_API
82 GstGLSyncMeta *     gst_buffer_add_gl_sync_meta         (GstGLContext * context, GstBuffer *buffer);
83 GST_GL_API
84 GstGLSyncMeta *     gst_buffer_add_gl_sync_meta_full    (GstGLContext * context, GstBuffer * buffer,
85                                                          gpointer data);
86 GST_GL_API
87 void                gst_gl_sync_meta_set_sync_point     (GstGLSyncMeta * sync_meta, GstGLContext * context);
88 GST_GL_API
89 void                gst_gl_sync_meta_wait               (GstGLSyncMeta * sync_meta, GstGLContext * context);
90 GST_GL_API
91 void                gst_gl_sync_meta_wait_cpu           (GstGLSyncMeta * sync_meta, GstGLContext * context);
92 
93 G_END_DECLS
94 
95 #endif /* __GST_GL_SYNC_META_H__ */
96