diff options
author | Carl-Anton Ingmarsson <ca.ingmarsson@gmail.com> | 2010-07-30 10:55:56 +0200 |
---|---|---|
committer | Carl-Anton Ingmarsson <ca.ingmarsson@gmail.com> | 2010-07-30 11:33:13 +0200 |
commit | 7320eedc04602afc46994256093cf49a8e444d17 (patch) | |
tree | b5f1f89c5b4053837a9a70648075f6ddf814320f | |
parent | 093fcacc20a9a84a12e59f027a0f0921ff02d304 (diff) |
vdpau: add GstVdpBufferPool base class
GstVdpBufferPool will be used to cache GstVdp[Video|Output]Buffers since
creating these can be a costly operation on some hardware.
-rw-r--r-- | sys/vdpau/gstvdp/Makefile.am | 4 | ||||
-rw-r--r-- | sys/vdpau/gstvdp/gstvdpbuffer.c | 86 | ||||
-rw-r--r-- | sys/vdpau/gstvdp/gstvdpbuffer.h | 59 | ||||
-rw-r--r-- | sys/vdpau/gstvdp/gstvdpbufferpool.c | 358 | ||||
-rw-r--r-- | sys/vdpau/gstvdp/gstvdpbufferpool.h | 74 |
5 files changed, 581 insertions, 0 deletions
diff --git a/sys/vdpau/gstvdp/Makefile.am b/sys/vdpau/gstvdp/Makefile.am index 13ba6bdef..44a0b9e95 100644 --- a/sys/vdpau/gstvdp/Makefile.am +++ b/sys/vdpau/gstvdp/Makefile.am | |||
@@ -3,6 +3,8 @@ lib_LTLIBRARIES = libgstvdp-@GST_MAJORMINOR@.la | |||
3 | libgstvdp_@GST_MAJORMINOR@_la_SOURCES = \ | 3 | libgstvdp_@GST_MAJORMINOR@_la_SOURCES = \ |
4 | gstvdpdevice.c \ | 4 | gstvdpdevice.c \ |
5 | gstvdputils.c \ | 5 | gstvdputils.c \ |
6 | gstvdpbuffer.c \ | ||
7 | gstvdpbufferpool.c \ | ||
6 | gstvdpvideobuffer.c \ | 8 | gstvdpvideobuffer.c \ |
7 | gstvdpoutputbuffer.c \ | 9 | gstvdpoutputbuffer.c \ |
8 | gstvdpvideosrcpad.c \ | 10 | gstvdpvideosrcpad.c \ |
@@ -14,6 +16,8 @@ libgstvdp_@GST_MAJORMINOR@includedir = $(includedir)/gstreamer-@GST_MAJORMINOR@/ | |||
14 | libgstvdp_@GST_MAJORMINOR@include_HEADERS = \ | 16 | libgstvdp_@GST_MAJORMINOR@include_HEADERS = \ |
15 | gstvdpdevice.h \ | 17 | gstvdpdevice.h \ |
16 | gstvdputils.h \ | 18 | gstvdputils.h \ |
19 | gstvdpbuffer.h \ | ||
20 | gstvdpbufferpool.h \ | ||
17 | gstvdpvideobuffer.h \ | 21 | gstvdpvideobuffer.h \ |
18 | gstvdpoutputbuffer.h \ | 22 | gstvdpoutputbuffer.h \ |
19 | gstvdpvideosrcpad.h \ | 23 | gstvdpvideosrcpad.h \ |
diff --git a/sys/vdpau/gstvdp/gstvdpbuffer.c b/sys/vdpau/gstvdp/gstvdpbuffer.c new file mode 100644 index 000000000..c2292cd7d --- /dev/null +++ b/sys/vdpau/gstvdp/gstvdpbuffer.c | |||
@@ -0,0 +1,86 @@ | |||
1 | /* | ||
2 | * GStreamer | ||
3 | * Copyright (C) 2009 Carl-Anton Ingmarsson <ca.ingmarsson@gmail.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., 59 Temple Place - Suite 330, | ||
18 | * Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | #ifdef HAVE_CONFIG_H | ||
22 | #include "config.h" | ||
23 | #endif | ||
24 | |||
25 | #include "gstvdpbuffer.h" | ||
26 | |||
27 | static GObjectClass *gst_vdp_buffer_parent_class; | ||
28 | |||
29 | void | ||
30 | gst_vdp_buffer_set_buffer_pool (GstVdpBuffer * buffer, GstVdpBufferPool * bpool) | ||
31 | { | ||
32 | g_return_if_fail (GST_IS_VDP_BUFFER (buffer)); | ||
33 | |||
34 | if (bpool) { | ||
35 | g_return_if_fail (GST_IS_VDP_BUFFER_POOL (bpool)); | ||
36 | g_object_add_weak_pointer (G_OBJECT (bpool), (void **) &buffer->bpool); | ||
37 | } | ||
38 | |||
39 | buffer->bpool = bpool; | ||
40 | } | ||
41 | |||
42 | gboolean | ||
43 | gst_vdp_buffer_revive (GstVdpBuffer * buffer) | ||
44 | { | ||
45 | if (buffer->bpool) | ||
46 | return gst_vdp_buffer_pool_put_buffer (buffer->bpool, buffer); | ||
47 | |||
48 | return FALSE; | ||
49 | } | ||
50 | |||
51 | static void | ||
52 | gst_vdp_buffer_init (GstVdpBuffer * buffer, gpointer g_class) | ||
53 | { | ||
54 | buffer->bpool = NULL; | ||
55 | } | ||
56 | |||
57 | static void | ||
58 | gst_vdp_buffer_class_init (gpointer g_class, gpointer class_data) | ||
59 | { | ||
60 | gst_vdp_buffer_parent_class = g_type_class_peek_parent (g_class); | ||
61 | } | ||
62 | |||
63 | |||
64 | GType | ||
65 | gst_vdp_buffer_get_type (void) | ||
66 | { | ||
67 | static GType _gst_vdp_buffer_type; | ||
68 | |||
69 | if (G_UNLIKELY (_gst_vdp_buffer_type == 0)) { | ||
70 | static const GTypeInfo info = { | ||
71 | sizeof (GstBufferClass), | ||
72 | NULL, | ||
73 | NULL, | ||
74 | gst_vdp_buffer_class_init, | ||
75 | NULL, | ||
76 | NULL, | ||
77 | sizeof (GstVdpBuffer), | ||
78 | 0, | ||
79 | (GInstanceInitFunc) gst_vdp_buffer_init, | ||
80 | NULL | ||
81 | }; | ||
82 | _gst_vdp_buffer_type = g_type_register_static (GST_TYPE_BUFFER, | ||
83 | "GstVdpBuffer", &info, 0); | ||
84 | } | ||
85 | return _gst_vdp_buffer_type; | ||
86 | } | ||
diff --git a/sys/vdpau/gstvdp/gstvdpbuffer.h b/sys/vdpau/gstvdp/gstvdpbuffer.h new file mode 100644 index 000000000..fc8b57812 --- /dev/null +++ b/sys/vdpau/gstvdp/gstvdpbuffer.h | |||
@@ -0,0 +1,59 @@ | |||
1 | /* | ||
2 | * GStreamer | ||
3 | * Copyright (C) 2009 Carl-Anton Ingmarsson <ca.ingmarsson@gmail.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., 59 Temple Place - Suite 330, | ||
18 | * Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | #ifndef _GST_VDP_BUFFER_H_ | ||
22 | #define _GST_VDP_BUFFER_H_ | ||
23 | |||
24 | #include <gst/gst.h> | ||
25 | |||
26 | typedef struct _GstVdpBuffer GstVdpBuffer; | ||
27 | |||
28 | #include "gstvdpbufferpool.h" | ||
29 | |||
30 | #define GST_TYPE_VDP_BUFFER (gst_vdp_buffer_get_type()) | ||
31 | |||
32 | #define GST_IS_VDP_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VDP_BUFFER)) | ||
33 | #define GST_VDP_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VDP_BUFFER, GstVdpBuffer)) | ||
34 | #define GST_VDP_BUFFER_CAST(obj) ((GstVdpBuffer *)obj) | ||
35 | |||
36 | struct _GstVdpBuffer { | ||
37 | GstBuffer buffer; | ||
38 | |||
39 | GstVdpBufferPool *bpool; | ||
40 | }; | ||
41 | |||
42 | void gst_vdp_buffer_set_buffer_pool (GstVdpBuffer *buffer, GstVdpBufferPool *bpool); | ||
43 | gboolean gst_vdp_buffer_revive (GstVdpBuffer * buffer); | ||
44 | |||
45 | static inline GstVdpBuffer * | ||
46 | gst_vdp_buffer_ref (GstVdpBuffer *buffer) | ||
47 | { | ||
48 | return (GstVdpBuffer *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (buffer)); | ||
49 | } | ||
50 | |||
51 | static inline void | ||
52 | gst_vdp_buffer_unref (GstVdpBuffer *buffer) | ||
53 | { | ||
54 | gst_mini_object_unref (GST_MINI_OBJECT_CAST (buffer)); | ||
55 | } | ||
56 | |||
57 | GType gst_vdp_buffer_get_type (void); | ||
58 | |||
59 | #endif \ No newline at end of file | ||
diff --git a/sys/vdpau/gstvdp/gstvdpbufferpool.c b/sys/vdpau/gstvdp/gstvdpbufferpool.c new file mode 100644 index 000000000..fea8aea4f --- /dev/null +++ b/sys/vdpau/gstvdp/gstvdpbufferpool.c | |||
@@ -0,0 +1,358 @@ | |||
1 | /* | ||
2 | * GStreamer | ||
3 | * Copyright (C) 2010 Carl-Anton Ingmarsson <ca.ingmarsson@gmail.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., 59 Temple Place - Suite 330, | ||
18 | * Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | |||
22 | #include "gstvdpbufferpool.h" | ||
23 | |||
24 | struct _GstVdpBufferPoolPrivate | ||
25 | { | ||
26 | GQueue *buffers; | ||
27 | GMutex *mutex; | ||
28 | |||
29 | /* properties */ | ||
30 | guint max_buffers; | ||
31 | GstCaps *caps; | ||
32 | GstVdpDevice *device; | ||
33 | }; | ||
34 | |||
35 | enum | ||
36 | { | ||
37 | PROP_0, | ||
38 | PROP_DEVICE, | ||
39 | PROP_CAPS, | ||
40 | PROP_MAX_BUFFERS | ||
41 | }; | ||
42 | |||
43 | G_DEFINE_TYPE (GstVdpBufferPool, gst_vdp_buffer_pool, G_TYPE_OBJECT); | ||
44 | |||
45 | #define DEFAULT_MAX_BUFFERS 20 | ||
46 | |||
47 | static void | ||
48 | gst_vdp_buffer_free (GstVdpBuffer * buf) | ||
49 | { | ||
50 | gst_vdp_buffer_set_buffer_pool (buf, NULL); | ||
51 | gst_vdp_buffer_unref (buf); | ||
52 | } | ||
53 | |||
54 | static void | ||
55 | gst_vdp_buffer_pool_clear (GstVdpBufferPool * bpool) | ||
56 | { | ||
57 | GstVdpBufferPoolPrivate *priv = bpool->priv; | ||
58 | |||
59 | g_queue_foreach (priv->buffers, (GFunc) gst_vdp_buffer_free, NULL); | ||
60 | g_queue_clear (priv->buffers); | ||
61 | } | ||
62 | |||
63 | gboolean | ||
64 | gst_vdp_buffer_pool_put_buffer (GstVdpBufferPool * bpool, GstVdpBuffer * buf) | ||
65 | { | ||
66 | GstVdpBufferPoolPrivate *priv; | ||
67 | |||
68 | gboolean res; | ||
69 | GstVdpBufferPoolClass *bpool_class; | ||
70 | GstCaps *caps; | ||
71 | |||
72 | g_return_val_if_fail (GST_IS_VDP_BUFFER_POOL (bpool), FALSE); | ||
73 | g_return_val_if_fail (GST_IS_VDP_BUFFER (buf), FALSE); | ||
74 | |||
75 | priv = bpool->priv; | ||
76 | g_return_val_if_fail (priv->caps, FALSE); | ||
77 | |||
78 | g_mutex_lock (priv->mutex); | ||
79 | |||
80 | if (priv->buffers->length == priv->max_buffers) { | ||
81 | res = FALSE; | ||
82 | goto done; | ||
83 | } | ||
84 | |||
85 | bpool_class = GST_VDP_BUFFER_POOL_GET_CLASS (bpool); | ||
86 | caps = GST_BUFFER_CAPS (buf); | ||
87 | if (!caps) | ||
88 | goto no_caps; | ||
89 | |||
90 | if (!bpool_class->check_caps (bpool, caps)) { | ||
91 | res = FALSE; | ||
92 | goto done; | ||
93 | } | ||
94 | |||
95 | gst_vdp_buffer_ref (buf); | ||
96 | g_queue_push_tail (priv->buffers, buf); | ||
97 | res = TRUE; | ||
98 | |||
99 | done: | ||
100 | g_mutex_unlock (priv->mutex); | ||
101 | |||
102 | return res; | ||
103 | |||
104 | no_caps: | ||
105 | GST_WARNING ("Buffer doesn't have any caps"); | ||
106 | res = FALSE; | ||
107 | goto done; | ||
108 | } | ||
109 | |||
110 | GstVdpBuffer * | ||
111 | gst_vdp_buffer_pool_get_buffer (GstVdpBufferPool * bpool, GError ** error) | ||
112 | { | ||
113 | GstVdpBufferPoolPrivate *priv; | ||
114 | GstVdpBuffer *buf; | ||
115 | |||
116 | g_return_val_if_fail (GST_IS_VDP_BUFFER_POOL (bpool), NULL); | ||
117 | |||
118 | priv = bpool->priv; | ||
119 | g_return_val_if_fail (priv->caps, NULL); | ||
120 | |||
121 | g_mutex_lock (priv->mutex); | ||
122 | |||
123 | buf = g_queue_pop_head (priv->buffers); | ||
124 | if (!buf) { | ||
125 | GstVdpBufferPoolClass *bpool_class = GST_VDP_BUFFER_POOL_GET_CLASS (bpool); | ||
126 | |||
127 | buf = bpool_class->alloc_buffer (bpool, error); | ||
128 | if (!buf) | ||
129 | goto done; | ||
130 | gst_buffer_set_caps (GST_BUFFER_CAST (buf), priv->caps); | ||
131 | gst_vdp_buffer_set_buffer_pool (buf, bpool); | ||
132 | } | ||
133 | |||
134 | done: | ||
135 | g_mutex_unlock (priv->mutex); | ||
136 | return buf; | ||
137 | } | ||
138 | |||
139 | void | ||
140 | gst_vdp_buffer_pool_set_max_buffers (GstVdpBufferPool * bpool, | ||
141 | guint max_buffers) | ||
142 | { | ||
143 | GstVdpBufferPoolPrivate *priv; | ||
144 | |||
145 | g_return_if_fail (GST_IS_VDP_BUFFER_POOL (bpool)); | ||
146 | g_return_if_fail (max_buffers >= -1); | ||
147 | |||
148 | priv = bpool->priv; | ||
149 | |||
150 | g_mutex_lock (priv->mutex); | ||
151 | |||
152 | if (max_buffers != -1) { | ||
153 | while (max_buffers < priv->buffers->length) { | ||
154 | GstVdpBuffer *buf; | ||
155 | |||
156 | buf = g_queue_pop_tail (priv->buffers); | ||
157 | gst_vdp_buffer_unref (buf); | ||
158 | } | ||
159 | } | ||
160 | |||
161 | priv->max_buffers = max_buffers; | ||
162 | |||
163 | g_mutex_unlock (priv->mutex); | ||
164 | } | ||
165 | |||
166 | guint | ||
167 | gst_vdp_buffer_pool_get_max_buffers (GstVdpBufferPool * bpool) | ||
168 | { | ||
169 | g_return_val_if_fail (GST_IS_VDP_BUFFER_POOL (bpool), 0); | ||
170 | |||
171 | return bpool->priv->max_buffers; | ||
172 | } | ||
173 | |||
174 | void | ||
175 | gst_vdp_buffer_pool_set_caps (GstVdpBufferPool * bpool, const GstCaps * caps) | ||
176 | { | ||
177 | GstVdpBufferPoolPrivate *priv; | ||
178 | GstVdpBufferPoolClass *bpool_class; | ||
179 | gboolean clear_bufs; | ||
180 | |||
181 | g_return_if_fail (GST_IS_VDP_BUFFER_POOL (bpool)); | ||
182 | g_return_if_fail (GST_IS_CAPS (caps)); | ||
183 | |||
184 | priv = bpool->priv; | ||
185 | bpool_class = GST_VDP_BUFFER_POOL_GET_CLASS (bpool); | ||
186 | |||
187 | g_mutex_lock (priv->mutex); | ||
188 | |||
189 | if (!bpool_class->set_caps (bpool, caps, &clear_bufs)) | ||
190 | goto invalid_caps; | ||
191 | |||
192 | if (clear_bufs) | ||
193 | gst_vdp_buffer_pool_clear (bpool); | ||
194 | |||
195 | if (priv->caps) | ||
196 | gst_caps_unref (priv->caps); | ||
197 | |||
198 | priv->caps = gst_caps_copy (caps); | ||
199 | |||
200 | done: | ||
201 | g_mutex_unlock (priv->mutex); | ||
202 | return; | ||
203 | |||
204 | invalid_caps: | ||
205 | GST_WARNING ("Subclass didn't accept caps: %" GST_PTR_FORMAT, caps); | ||
206 | goto done; | ||
207 | } | ||
208 | |||
209 | const GstCaps * | ||
210 | gst_vdp_buffer_pool_get_caps (GstVdpBufferPool * bpool) | ||
211 | { | ||
212 | g_return_val_if_fail (GST_IS_VDP_BUFFER_POOL (bpool), NULL); | ||
213 | |||
214 | return bpool->priv->caps; | ||
215 | } | ||
216 | |||
217 | GstVdpDevice * | ||
218 | gst_vdp_buffer_pool_get_device (GstVdpBufferPool * bpool) | ||
219 | { | ||
220 | g_return_val_if_fail (GST_IS_VDP_BUFFER_POOL (bpool), NULL); | ||
221 | |||
222 | return bpool->priv->device; | ||
223 | } | ||
224 | |||
225 | static void | ||
226 | gst_vdp_buffer_pool_get_property (GObject * object, guint prop_id, | ||
227 | GValue * value, GParamSpec * pspec) | ||
228 | { | ||
229 | GstVdpBufferPool *bpool = (GstVdpBufferPool *) object; | ||
230 | GstVdpBufferPoolPrivate *priv = bpool->priv; | ||
231 | |||
232 | switch (prop_id) { | ||
233 | case PROP_DEVICE: | ||
234 | g_value_set_object (value, priv->device); | ||
235 | break; | ||
236 | |||
237 | case PROP_CAPS: | ||
238 | g_value_set_pointer (value, priv->caps); | ||
239 | break; | ||
240 | |||
241 | case PROP_MAX_BUFFERS: | ||
242 | g_value_set_uint (value, priv->max_buffers); | ||
243 | break; | ||
244 | |||
245 | |||
246 | default: | ||
247 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | ||
248 | break; | ||
249 | } | ||
250 | } | ||
251 | |||
252 | static void | ||
253 | gst_vdp_buffer_pool_set_property (GObject * object, guint prop_id, | ||
254 | const GValue * value, GParamSpec * pspec) | ||
255 | { | ||
256 | GstVdpBufferPool *bpool = (GstVdpBufferPool *) object; | ||
257 | GstVdpBufferPoolPrivate *priv = bpool->priv; | ||
258 | |||
259 | switch (prop_id) { | ||
260 | case PROP_DEVICE: | ||
261 | priv->device = g_value_get_object (value); | ||
262 | break; | ||
263 | |||
264 | case PROP_CAPS: | ||
265 | gst_vdp_buffer_pool_set_caps (bpool, g_value_get_pointer (value)); | ||
266 | break; | ||
267 | |||
268 | case PROP_MAX_BUFFERS: | ||
269 | gst_vdp_buffer_pool_set_max_buffers (bpool, g_value_get_uint (value)); | ||
270 | break; | ||
271 | |||
272 | default: | ||
273 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | ||
274 | break; | ||
275 | } | ||
276 | } | ||
277 | |||
278 | static void | ||
279 | gst_vdp_buffer_pool_finalize (GObject * object) | ||
280 | { | ||
281 | GstVdpBufferPool *bpool = GST_VDP_BUFFER_POOL (object); | ||
282 | GstVdpBufferPoolPrivate *priv = bpool->priv; | ||
283 | |||
284 | g_mutex_free (priv->mutex); | ||
285 | |||
286 | if (priv->caps) | ||
287 | gst_caps_unref (priv->caps); | ||
288 | |||
289 | G_OBJECT_CLASS (gst_vdp_buffer_pool_parent_class)->finalize (object); | ||
290 | } | ||
291 | |||
292 | static void | ||
293 | gst_vdp_buffer_pool_init (GstVdpBufferPool * bpool) | ||
294 | { | ||
295 | GstVdpBufferPoolPrivate *priv; | ||
296 | |||
297 | bpool->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (bpool, | ||
298 | GST_TYPE_VDP_BUFFER_POOL, GstVdpBufferPoolPrivate); | ||
299 | |||
300 | priv->buffers = g_queue_new (); | ||
301 | priv->mutex = g_mutex_new (); | ||
302 | |||
303 | /* properties */ | ||
304 | priv->caps = NULL; | ||
305 | priv->max_buffers = DEFAULT_MAX_BUFFERS; | ||
306 | } | ||
307 | |||
308 | static void | ||
309 | gst_vdp_buffer_pool_class_init (GstVdpBufferPoolClass * bpool_klass) | ||
310 | { | ||
311 | GObjectClass *object_class = G_OBJECT_CLASS (bpool_klass); | ||
312 | |||
313 | g_type_class_add_private (bpool_klass, sizeof (GstVdpBufferPoolPrivate)); | ||
314 | |||
315 | object_class->get_property = gst_vdp_buffer_pool_get_property; | ||
316 | object_class->set_property = gst_vdp_buffer_pool_set_property; | ||
317 | |||
318 | object_class->finalize = gst_vdp_buffer_pool_finalize; | ||
319 | |||
320 | /** | ||
321 | * GstVdpBufferPool:device: | ||
322 | * | ||
323 | * The #GstVdpDevice this pool is bound to. | ||
324 | */ | ||
325 | g_object_class_install_property | ||
326 | (object_class, | ||
327 | PROP_DEVICE, | ||
328 | g_param_spec_object ("device", | ||
329 | "Device", | ||
330 | "The GstVdpDevice this pool is bound to", | ||
331 | GST_TYPE_VDP_DEVICE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); | ||
332 | |||
333 | /** | ||
334 | * GstVdpBufferPool:caps: | ||
335 | * | ||
336 | * The video object capabilities represented as a #GstCaps. This | ||
337 | * shall hold at least the "width" and "height" properties. | ||
338 | */ | ||
339 | g_object_class_install_property | ||
340 | (object_class, | ||
341 | PROP_CAPS, | ||
342 | g_param_spec_pointer ("caps", | ||
343 | "Caps", "The buffer capabilities", G_PARAM_READWRITE)); | ||
344 | |||
345 | /** | ||
346 | * GstVdpBufferPool:max-buffers: | ||
347 | * | ||
348 | * The maximum number of buffer in the pool. Or -1, the pool | ||
349 | * will hold as many objects as possible. | ||
350 | */ | ||
351 | g_object_class_install_property | ||
352 | (object_class, | ||
353 | PROP_MAX_BUFFERS, | ||
354 | g_param_spec_int ("max-buffers", | ||
355 | "Max Buffers", | ||
356 | "The maximum number of buffers in the pool, or -1 for unlimited", | ||
357 | -1, G_MAXINT32, DEFAULT_MAX_BUFFERS, G_PARAM_READWRITE)); | ||
358 | } | ||
diff --git a/sys/vdpau/gstvdp/gstvdpbufferpool.h b/sys/vdpau/gstvdp/gstvdpbufferpool.h new file mode 100644 index 000000000..4f3d92c68 --- /dev/null +++ b/sys/vdpau/gstvdp/gstvdpbufferpool.h | |||
@@ -0,0 +1,74 @@ | |||
1 | /* | ||
2 | * GStreamer | ||
3 | * Copyright (C) 2009 Carl-Anton Ingmarsson <ca.ingmarsson@gmail.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., 59 Temple Place - Suite 330, | ||
18 | * Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | #ifndef _GST_VDP_BUFFER_POOL_H_ | ||
22 | #define _GST_VDP_BUFFER_POOL_H_ | ||
23 | |||
24 | #include <gst/gst.h> | ||
25 | |||
26 | typedef struct _GstVdpBufferPool GstVdpBufferPool; | ||
27 | |||
28 | #include "gstvdpdevice.h" | ||
29 | #include "gstvdpbuffer.h" | ||
30 | |||
31 | G_BEGIN_DECLS | ||
32 | |||
33 | #define GST_TYPE_VDP_BUFFER_POOL (gst_vdp_buffer_pool_get_type ()) | ||
34 | #define GST_VDP_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VDP_BUFFER_POOL, GstVdpBufferPool)) | ||
35 | #define GST_VDP_BUFFER_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_VDP_BUFFER_POOL, GstVdpBufferPoolClass)) | ||
36 | #define GST_IS_VDP_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VDP_BUFFER_POOL)) | ||
37 | #define GST_IS_VDP_BUFFER_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_VDP_BUFFER_POOL)) | ||
38 | #define GST_VDP_BUFFER_POOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_VDP_BUFFER_POOL, GstVdpBufferPoolClass)) | ||
39 | |||
40 | typedef struct _GstVdpBufferPoolClass GstVdpBufferPoolClass; | ||
41 | typedef struct _GstVdpBufferPoolPrivate GstVdpBufferPoolPrivate; | ||
42 | |||
43 | struct _GstVdpBufferPool | ||
44 | { | ||
45 | GObject object; | ||
46 | |||
47 | GstVdpBufferPoolPrivate *priv; | ||
48 | }; | ||
49 | |||
50 | struct _GstVdpBufferPoolClass | ||
51 | { | ||
52 | GObjectClass object_class; | ||
53 | |||
54 | GstVdpBuffer *(*alloc_buffer) (GstVdpBufferPool *bpool, GError **error); | ||
55 | gboolean (*set_caps) (GstVdpBufferPool *bpool, const GstCaps *caps, gboolean *clear_bufs); | ||
56 | gboolean (*check_caps) (GstVdpBufferPool *bpool, const GstCaps *caps); | ||
57 | }; | ||
58 | |||
59 | gboolean gst_vdp_buffer_pool_put_buffer (GstVdpBufferPool *bpool, GstVdpBuffer *buf); | ||
60 | GstVdpBuffer *gst_vdp_buffer_pool_get_buffer (GstVdpBufferPool * bpool, GError **error); | ||
61 | |||
62 | void gst_vdp_buffer_pool_set_max_buffers (GstVdpBufferPool *bpool, guint max_buffers); | ||
63 | guint gst_vdp_buffer_pool_get_max_buffers (GstVdpBufferPool *bpool); | ||
64 | |||
65 | void gst_vdp_buffer_pool_set_caps (GstVdpBufferPool *bpool, const GstCaps *caps); | ||
66 | const GstCaps *gst_vdp_buffer_pool_get_caps (GstVdpBufferPool * bpool); | ||
67 | |||
68 | GstVdpDevice *gst_vdp_buffer_pool_get_device (GstVdpBufferPool * bpool); | ||
69 | |||
70 | GType gst_vdp_buffer_pool_get_type (void) G_GNUC_CONST; | ||
71 | |||
72 | G_END_DECLS | ||
73 | |||
74 | #endif /* _GST_VDP_BUFFER_POOL_H_ */ | ||