• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_BUFFER_H_
22 #define _GST_GL_BUFFER_H_
23 
24 #include <gst/gl/gstglbasememory.h>
25 
26 G_BEGIN_DECLS
27 
28 #define GST_TYPE_GL_BUFFER_ALLOCATOR (gst_gl_buffer_allocator_get_type())
29 GST_GL_API
30 GType gst_gl_buffer_allocator_get_type(void);
31 
32 #define GST_IS_GL_BUFFER_ALLOCATOR(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_GL_ALLOCATOR))
33 #define GST_IS_GL_BUFFER_ALLOCATOR_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_GL_BUFFER_ALLOCATOR))
34 #define GST_GL_BUFFER_ALLOCATOR_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_GL_BUFFER_ALLOCATOR, GstGLBufferAllocatorClass))
35 #define GST_GL_BUFFER_ALLOCATOR(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_GL_BUFFER_ALLOCATOR, GstGLBufferAllocator))
36 #define GST_GL_BUFFER_ALLOCATOR_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_GL_BUFFER_ALLOCATOR, GstGLBufferAllocatorClass))
37 #define GST_GL_BUFFER_ALLOCATOR_CAST(obj)            ((GstGLBufferAllocator *)(obj))
38 
39 /**
40  * GstGLBuffer:
41  * @mem: the parent object
42  * @id: the buffer id for this memory
43  * @target: the OpenGL target of this texture for binding purposes
44  * @usage_hints: the OpenGL usage hints this buffer was created with
45  *
46  * Represents information about a GL buffer
47  */
48 struct _GstGLBuffer
49 {
50   GstGLBaseMemory       mem;
51 
52   guint                 id;
53   guint                 target;         /* XXX: put this in the allocator? */
54   guint                 usage_hints;     /* XXX: put this in the allocator? */
55 };
56 
57 typedef struct _GstGLBufferAllocationParams GstGLBufferAllocationParams;
58 
59 #define GST_TYPE_GL_BUFFER_ALLOCATION_PARAMS (gst_gl_buffer_allocation_params_get_type())
60 GST_GL_API
61 GType gst_gl_buffer_allocation_params_get_type (void);
62 
63 /**
64  * GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_BUFFER:
65  *
66  * GL allocation flag indicating the allocation of a GL buffer.
67  */
68 #define GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_BUFFER (1 << 4)
69 
70 /**
71  * GstGLBufferAllocationParams:
72  * @parent: parent object
73  * @gl_target: the OpenGL target to bind the buffer to
74  * @gl_usage: the OpenGL usage hint to create the buffer with
75  */
76 struct _GstGLBufferAllocationParams
77 {
78   GstGLAllocationParams     parent;
79 
80   guint                     gl_target;
81   guint                     gl_usage;
82 
83   /*< private >*/
84   gpointer                  _padding[GST_PADDING];
85 };
86 
87 GST_GL_API
88 GstGLBufferAllocationParams *   gst_gl_buffer_allocation_params_new     (GstGLContext * context,
89                                                                          gsize alloc_size,
90                                                                          const GstAllocationParams * alloc_params,
91                                                                          guint gl_target,
92                                                                          guint gl_usage);
93 
94 /**
95  * GstGLBufferAllocator:
96  *
97  * Opaque #GstGLBufferAllocator struct
98  */
99 struct _GstGLBufferAllocator
100 {
101   GstGLBaseMemoryAllocator parent;
102 
103   /*< private >*/
104   gpointer _padding[GST_PADDING];
105 };
106 
107 /**
108  * GstGLBufferAllocatorClass:
109  *
110  * The #GstGLBufferAllocatorClass only contains private data
111  */
112 struct _GstGLBufferAllocatorClass
113 {
114   GstGLBaseMemoryAllocatorClass parent_class;
115 
116   /*< private >*/
117   gpointer _padding[GST_PADDING];
118 };
119 
120 /**
121  * GST_CAPS_FEATURE_MEMORY_GL_BUFFER:
122  *
123  * Name of the caps feature indicating the use of GL buffers
124  */
125 #define GST_CAPS_FEATURE_MEMORY_GL_BUFFER "memory:GLBuffer"
126 
127 /**
128  * GST_GL_BUFFER_ALLOCATOR_NAME:
129  *
130  * The name of the GL buffer allocator
131  */
132 #define GST_GL_BUFFER_ALLOCATOR_NAME   "GLBuffer"
133 
134 /**
135  * GST_TYPE_GL_BUFFER:
136  *
137  * Since: 1.20
138  */
139 #define GST_TYPE_GL_BUFFER (gst_gl_buffer_get_type())
140 GST_GL_API
141 GType gst_gl_buffer_get_type(void);
142 
143 GST_GL_API
144 void          gst_gl_buffer_init_once (void);
145 GST_GL_API
146 gboolean      gst_is_gl_buffer        (GstMemory * mem);
147 
148 G_END_DECLS
149 
150 #endif /* _GST_GL_BUFFER_H_ */
151