gstreamer 1.2.6 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +78 -39
- data/ext/gstreamer/extconf.rb +8 -22
- data/ext/gstreamer/rbgst.c +82 -194
- data/lib/gst/base_loader.rb +20 -0
- data/lib/gst/bin.rb +32 -0
- data/lib/gst/bus.rb +24 -0
- data/lib/gst/element.rb +48 -0
- data/lib/gst.rb +87 -22
- data/sample/helloworld.rb +75 -0
- data/sample/mp3parselaunch.rb +74 -0
- data/sample/queue.rb +92 -0
- data/sample/typefind.rb +101 -0
- metadata +29 -84
- data/README +0 -33
- data/ext/gstreamer/misc.c +0 -63
- data/ext/gstreamer/rbgst-bin.c +0 -456
- data/ext/gstreamer/rbgst-buffer.c +0 -363
- data/ext/gstreamer/rbgst-bus.c +0 -92
- data/ext/gstreamer/rbgst-caps.c +0 -446
- data/ext/gstreamer/rbgst-child-proxy.c +0 -34
- data/ext/gstreamer/rbgst-clock.c +0 -108
- data/ext/gstreamer/rbgst-element-factory.c +0 -249
- data/ext/gstreamer/rbgst-element.c +0 -1106
- data/ext/gstreamer/rbgst-event.c +0 -352
- data/ext/gstreamer/rbgst-ghost-pad.c +0 -45
- data/ext/gstreamer/rbgst-index-factory.c +0 -69
- data/ext/gstreamer/rbgst-install-plugins-context.c +0 -87
- data/ext/gstreamer/rbgst-install-plugins-return.c +0 -45
- data/ext/gstreamer/rbgst-install-plugins.c +0 -125
- data/ext/gstreamer/rbgst-message.c +0 -785
- data/ext/gstreamer/rbgst-mini-object.c +0 -221
- data/ext/gstreamer/rbgst-object.c +0 -81
- data/ext/gstreamer/rbgst-pad-template.c +0 -125
- data/ext/gstreamer/rbgst-pad.c +0 -336
- data/ext/gstreamer/rbgst-pipeline.c +0 -91
- data/ext/gstreamer/rbgst-plugin-feature.c +0 -131
- data/ext/gstreamer/rbgst-plugin.c +0 -162
- data/ext/gstreamer/rbgst-private.c +0 -88
- data/ext/gstreamer/rbgst-private.h +0 -97
- data/ext/gstreamer/rbgst-query.c +0 -291
- data/ext/gstreamer/rbgst-seek.c +0 -39
- data/ext/gstreamer/rbgst-static-caps.c +0 -49
- data/ext/gstreamer/rbgst-static-pad-template.c +0 -65
- data/ext/gstreamer/rbgst-structure.c +0 -300
- data/ext/gstreamer/rbgst-system-clock.c +0 -48
- data/ext/gstreamer/rbgst-type-find-factory.c +0 -125
- data/ext/gstreamer/rbgst-value.c +0 -527
- data/ext/gstreamer/rbgst-x-overlay.c +0 -131
- data/ext/gstreamer/rbgst.h +0 -197
- data/ext/gstreamer/rbgstclockentry.c +0 -271
- data/ext/gstreamer/rbgstformat.c +0 -162
- data/ext/gstreamer/rbgstindex.c +0 -315
- data/ext/gstreamer/rbgstindexentry.c +0 -99
- data/ext/gstreamer/rbgstparse.c +0 -69
- data/ext/gstreamer/rbgstquerytype.c +0 -162
- data/ext/gstreamer/rbgstregistry.c +0 -288
- data/ext/gstreamer/rbgsttag.c +0 -113
- data/ext/gstreamer/rbgsttagsetter.c +0 -53
- data/ext/gstreamer/rbgstxml.c +0 -192
- data/sample/audio-player.rb +0 -54
- data/sample/gst-gi.rb +0 -55
- data/sample/gst-inspect.rb +0 -417
- data/sample/install-plugins.rb +0 -40
- data/sample/media-type.rb +0 -55
- data/sample/media-type2.rb +0 -268
- data/sample/ogg-audio-player.rb +0 -54
- data/sample/type-find.rb +0 -46
- data/sample/video-player.rb +0 -57
- data/sample/xml-player.rb +0 -60
- data/test/gst-test-utils.rb +0 -18
- data/test/run-test.rb +0 -25
- data/test/test_bin.rb +0 -167
- data/test/test_buffer.rb +0 -185
- data/test/test_caps.rb +0 -24
- data/test/test_element.rb +0 -85
- data/test/test_element_factory.rb +0 -28
- data/test/test_event.rb +0 -10
- data/test/test_index_factory.rb +0 -7
- data/test/test_install-plugins.rb +0 -18
- data/test/test_message.rb +0 -191
- data/test/test_mini_object.rb +0 -38
- data/test/test_object.rb +0 -10
- data/test/test_pad.rb +0 -68
- data/test/test_plugin.rb +0 -6
- data/test/test_plugin_feature.rb +0 -20
- data/test/test_seek.rb +0 -17
- data/test/test_static_caps.rb +0 -18
- data/test/test_static_pad_template.rb +0 -16
- data/test/test_structure.rb +0 -159
- data/test/test_thread_handling.rb +0 -58
- data/test/test_type_find_factory.rb +0 -8
- data/test/test_value.rb +0 -69
@@ -1,1106 +0,0 @@
|
|
1
|
-
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
/*
|
3
|
-
* Copyright (C) 2011-2013 Ruby-GNOME2 Project Team
|
4
|
-
* Copyright (C) 2007, 2008 Ruby-GNOME2 Project Team
|
5
|
-
* Copyright (C) 2006, 2008 Sjoerd Simons <sjoerd@luon.net>
|
6
|
-
* Copyright (C) 2003, 2004 Laurent Sansonetti <lrz@gnome.org>
|
7
|
-
*
|
8
|
-
* This library is free software; you can redistribute it and/or
|
9
|
-
* modify it under the terms of the GNU Lesser General Public
|
10
|
-
* License as published by the Free Software Foundation; either
|
11
|
-
* version 2.1 of the License, or (at your option) any later version.
|
12
|
-
*
|
13
|
-
* This library is distributed in the hope that it will be useful,
|
14
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
16
|
-
* Lesser General Public License for more details.
|
17
|
-
*
|
18
|
-
* You should have received a copy of the GNU Lesser General Public
|
19
|
-
* License along with this library; if not, write to the Free Software
|
20
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
21
|
-
* MA 02110-1301 USA
|
22
|
-
*/
|
23
|
-
|
24
|
-
#include "rbgst-private.h"
|
25
|
-
|
26
|
-
#ifdef G_OS_WIN32
|
27
|
-
# ifdef HAVE_IO_H
|
28
|
-
# include <io.h>
|
29
|
-
# define pipe(phandles) _pipe(phandles, 128, _O_BINARY)
|
30
|
-
# endif
|
31
|
-
#else
|
32
|
-
# ifdef HAVE_UNISTD_H
|
33
|
-
# include <unistd.h>
|
34
|
-
# endif
|
35
|
-
#endif
|
36
|
-
#include <fcntl.h>
|
37
|
-
#include <errno.h>
|
38
|
-
|
39
|
-
#define RG_TARGET_NAMESPACE cElement
|
40
|
-
#define SELF(self) RVAL2GST_ELEMENT(self)
|
41
|
-
|
42
|
-
#define GST_STATE_CHANGE_RETURN2RVAL(object) \
|
43
|
-
(GENUM2RVAL(object, GST_TYPE_STATE_CHANGE_RETURN))
|
44
|
-
|
45
|
-
#define NOTIFY_MESSAGE "R"
|
46
|
-
#define NOTIFY_MESSAGE_SIZE 1
|
47
|
-
|
48
|
-
typedef struct _SetStateData {
|
49
|
-
GstStateChangeReturn result;
|
50
|
-
GstState state;
|
51
|
-
} SetStateData;
|
52
|
-
|
53
|
-
typedef struct _GetStateData {
|
54
|
-
GstStateChangeReturn result;
|
55
|
-
GstState state;
|
56
|
-
GstState pending;
|
57
|
-
GstClockTime timeout;
|
58
|
-
} GetStateData;
|
59
|
-
|
60
|
-
typedef struct _QueryData {
|
61
|
-
gboolean result;
|
62
|
-
GstQuery *query;
|
63
|
-
} QueryData;
|
64
|
-
|
65
|
-
typedef struct _SendEventData {
|
66
|
-
gboolean result;
|
67
|
-
GstEvent *event;
|
68
|
-
} SendEventData;
|
69
|
-
|
70
|
-
typedef struct _ThreadData {
|
71
|
-
GstElement *element;
|
72
|
-
gint notify_write_fd;
|
73
|
-
gint notify_read_fd;
|
74
|
-
gint errno_on_write;
|
75
|
-
const gchar *context;
|
76
|
-
union {
|
77
|
-
SetStateData set_state_data;
|
78
|
-
GetStateData get_state_data;
|
79
|
-
QueryData query_data;
|
80
|
-
SendEventData send_event_data;
|
81
|
-
} data;
|
82
|
-
} ThreadData;
|
83
|
-
|
84
|
-
static VALUE RG_TARGET_NAMESPACE;
|
85
|
-
static ID id_gtype;
|
86
|
-
static GThreadPool *set_state_thread_pool;
|
87
|
-
static GThreadPool *get_state_thread_pool;
|
88
|
-
static GThreadPool *query_thread_pool;
|
89
|
-
static GThreadPool *send_event_thread_pool;
|
90
|
-
|
91
|
-
static void
|
92
|
-
define_class_if_need(VALUE klass, GType type)
|
93
|
-
{
|
94
|
-
_rbgst_define_class_if_need(klass, type, "Element");
|
95
|
-
}
|
96
|
-
|
97
|
-
static VALUE
|
98
|
-
instance2robj(gpointer instance, gpointer user_data)
|
99
|
-
{
|
100
|
-
VALUE klass;
|
101
|
-
GType type;
|
102
|
-
|
103
|
-
type = G_TYPE_FROM_INSTANCE(instance);
|
104
|
-
klass = GTYPE2CLASS(type);
|
105
|
-
define_class_if_need(klass, type);
|
106
|
-
return rbgst_object_instance2robj(instance, user_data);
|
107
|
-
}
|
108
|
-
|
109
|
-
/* Class: Gst::Element
|
110
|
-
* Base class for all pipeline elements.
|
111
|
-
*/
|
112
|
-
|
113
|
-
static void
|
114
|
-
do_in_thread(GThreadPool *pool, ThreadData *data)
|
115
|
-
{
|
116
|
-
int notify_fds[2];
|
117
|
-
GError *error = NULL;
|
118
|
-
|
119
|
-
if (pipe(notify_fds) != 0)
|
120
|
-
rb_sys_fail("failed to create a pipe to synchronize threaded operation");
|
121
|
-
|
122
|
-
data->errno_on_write = 0;
|
123
|
-
data->notify_read_fd = notify_fds[0];
|
124
|
-
data->notify_write_fd = notify_fds[1];
|
125
|
-
g_thread_pool_push(pool, data, &error);
|
126
|
-
if (error) {
|
127
|
-
close(notify_fds[0]);
|
128
|
-
close(notify_fds[1]);
|
129
|
-
RAISE_GERROR(error);
|
130
|
-
}
|
131
|
-
|
132
|
-
rb_thread_wait_fd(notify_fds[0]);
|
133
|
-
|
134
|
-
#define BUFFER_SIZE 512
|
135
|
-
if (data->errno_on_write == 0) {
|
136
|
-
char buf[NOTIFY_MESSAGE_SIZE];
|
137
|
-
ssize_t read_size;
|
138
|
-
int saved_errno = 0;
|
139
|
-
read_size = read(notify_fds[0], buf, NOTIFY_MESSAGE_SIZE);
|
140
|
-
if (read_size != NOTIFY_MESSAGE_SIZE) {
|
141
|
-
saved_errno = errno;
|
142
|
-
}
|
143
|
-
|
144
|
-
close(notify_fds[0]);
|
145
|
-
close(notify_fds[1]);
|
146
|
-
|
147
|
-
if (saved_errno != 0) {
|
148
|
-
char buffer[BUFFER_SIZE];
|
149
|
-
snprintf(buffer, BUFFER_SIZE - 1,
|
150
|
-
"failed to read notify pipe on %s", data->context);
|
151
|
-
errno = saved_errno;
|
152
|
-
rb_sys_fail(buffer);
|
153
|
-
}
|
154
|
-
} else {
|
155
|
-
char buffer[BUFFER_SIZE];
|
156
|
-
snprintf(buffer, BUFFER_SIZE - 1,
|
157
|
-
"failed to write notify pipe on %s", data->context);
|
158
|
-
errno = data->errno_on_write;
|
159
|
-
rb_sys_fail(buffer);
|
160
|
-
}
|
161
|
-
#undef BUFFER_SIZE
|
162
|
-
}
|
163
|
-
|
164
|
-
static void
|
165
|
-
notify(ThreadData *thread_data)
|
166
|
-
{
|
167
|
-
ssize_t written_size;
|
168
|
-
|
169
|
-
written_size = write(thread_data->notify_write_fd,
|
170
|
-
NOTIFY_MESSAGE, NOTIFY_MESSAGE_SIZE);
|
171
|
-
if (written_size != NOTIFY_MESSAGE_SIZE) {
|
172
|
-
int read_fd = thread_data->notify_read_fd;
|
173
|
-
int write_fd = thread_data->notify_write_fd;
|
174
|
-
thread_data->errno_on_write = errno;
|
175
|
-
thread_data->notify_read_fd = -1;
|
176
|
-
thread_data->notify_write_fd = -1;
|
177
|
-
close(write_fd);
|
178
|
-
close(read_fd);
|
179
|
-
}
|
180
|
-
}
|
181
|
-
|
182
|
-
static void
|
183
|
-
set_state_in_thread(gpointer data, G_GNUC_UNUSED gpointer user_data)
|
184
|
-
{
|
185
|
-
ThreadData *thread_data = (ThreadData *)data;
|
186
|
-
SetStateData *set_state_data;
|
187
|
-
|
188
|
-
set_state_data = &(thread_data->data.set_state_data);
|
189
|
-
set_state_data->result = gst_element_set_state(thread_data->element,
|
190
|
-
set_state_data->state);
|
191
|
-
notify(thread_data);
|
192
|
-
}
|
193
|
-
|
194
|
-
static VALUE
|
195
|
-
rb_gst_element_set_state_internal(VALUE self, GstState state)
|
196
|
-
{
|
197
|
-
VALUE result;
|
198
|
-
ThreadData thread_data;
|
199
|
-
SetStateData *set_state_data;
|
200
|
-
|
201
|
-
thread_data.element = SELF(self);
|
202
|
-
thread_data.context = "set_state";
|
203
|
-
set_state_data = &(thread_data.data.set_state_data);
|
204
|
-
set_state_data->state = state;
|
205
|
-
|
206
|
-
do_in_thread(set_state_thread_pool, &thread_data);
|
207
|
-
|
208
|
-
result = GST_STATE_CHANGE_RETURN2RVAL(set_state_data->result);
|
209
|
-
|
210
|
-
return result;
|
211
|
-
}
|
212
|
-
|
213
|
-
/*
|
214
|
-
* Method: set_state(state)
|
215
|
-
* state: the state you want to set (see Gst::Element::State).
|
216
|
-
*
|
217
|
-
* Sets the state of the element.
|
218
|
-
*
|
219
|
-
* This method will try to set the requested state by going through all
|
220
|
-
* the intermediary states and calling the class's state change function
|
221
|
-
* for each.
|
222
|
-
*
|
223
|
-
* Returns: a code (see Gst::Element::StateChangeReturn).
|
224
|
-
*/
|
225
|
-
static VALUE
|
226
|
-
rg_set_state(VALUE self, VALUE state)
|
227
|
-
{
|
228
|
-
return rb_gst_element_set_state_internal(self,
|
229
|
-
RVAL2GENUM(state, GST_TYPE_STATE));
|
230
|
-
}
|
231
|
-
|
232
|
-
static void
|
233
|
-
get_state_in_thread(gpointer data, G_GNUC_UNUSED gpointer user_data)
|
234
|
-
{
|
235
|
-
ThreadData *thread_data = (ThreadData *)data;
|
236
|
-
GetStateData *get_state_data;
|
237
|
-
|
238
|
-
get_state_data = &(thread_data->data.get_state_data);
|
239
|
-
get_state_data->result = gst_element_get_state(thread_data->element,
|
240
|
-
&(get_state_data->state),
|
241
|
-
&(get_state_data->pending),
|
242
|
-
get_state_data->timeout);
|
243
|
-
notify(thread_data);
|
244
|
-
}
|
245
|
-
|
246
|
-
/* Method: get_state(timeout=nil)
|
247
|
-
*/
|
248
|
-
static VALUE
|
249
|
-
rg_get_state(int argc, VALUE *argv, VALUE self)
|
250
|
-
{
|
251
|
-
VALUE result, timeout;
|
252
|
-
ThreadData thread_data;
|
253
|
-
GetStateData *get_state_data;
|
254
|
-
|
255
|
-
rb_scan_args(argc, argv, "01", &timeout);
|
256
|
-
|
257
|
-
thread_data.element = SELF(self);
|
258
|
-
thread_data.context = "get_state";
|
259
|
-
get_state_data = &(thread_data.data.get_state_data);
|
260
|
-
if (NIL_P(timeout))
|
261
|
-
get_state_data->timeout = GST_CLOCK_TIME_NONE;
|
262
|
-
else
|
263
|
-
get_state_data->timeout = NUM2ULL(timeout);
|
264
|
-
|
265
|
-
do_in_thread(get_state_thread_pool, &thread_data);
|
266
|
-
|
267
|
-
result = rb_ary_new3(3,
|
268
|
-
GST_STATE_CHANGE_RETURN2RVAL(get_state_data->result),
|
269
|
-
GST_STATE2RVAL(get_state_data->state),
|
270
|
-
GST_STATE2RVAL(get_state_data->pending));
|
271
|
-
|
272
|
-
return result;
|
273
|
-
}
|
274
|
-
|
275
|
-
/*
|
276
|
-
* Method: stop
|
277
|
-
*
|
278
|
-
* This method calls Gst::Element#set_state with Gst::Element::STATE_NULL.
|
279
|
-
*
|
280
|
-
* Returns: a code (see Gst::Element::StateChangeReturn).
|
281
|
-
*/
|
282
|
-
static VALUE
|
283
|
-
rg_stop(VALUE self)
|
284
|
-
{
|
285
|
-
return rb_gst_element_set_state_internal(self, GST_STATE_NULL);
|
286
|
-
}
|
287
|
-
|
288
|
-
/*
|
289
|
-
* Method: ready
|
290
|
-
*
|
291
|
-
* This method calls Gst::Element#set_state with Gst::Element::STATE_READY.
|
292
|
-
*
|
293
|
-
* Returns: a code (see Gst::Element::StateChangeReturn).
|
294
|
-
*/
|
295
|
-
static VALUE
|
296
|
-
rg_ready(VALUE self)
|
297
|
-
{
|
298
|
-
return rb_gst_element_set_state_internal(self, GST_STATE_READY);
|
299
|
-
}
|
300
|
-
|
301
|
-
/*
|
302
|
-
* Method: pause
|
303
|
-
*
|
304
|
-
* This method calls Gst::Element#set_state with Gst::Element::STATE_PAUSED.
|
305
|
-
*
|
306
|
-
* Returns: a code (see Gst::Element::StateChangedReturn).
|
307
|
-
*/
|
308
|
-
static VALUE
|
309
|
-
rg_pause(VALUE self)
|
310
|
-
{
|
311
|
-
return rb_gst_element_set_state_internal(self, GST_STATE_PAUSED);
|
312
|
-
}
|
313
|
-
|
314
|
-
/*
|
315
|
-
* Method: play
|
316
|
-
*
|
317
|
-
* This method calls Gst::Element#set_state with Gst::Element::STATE_PLAYING.
|
318
|
-
*
|
319
|
-
* Returns: a code (see Gst::Element::StateChangedReturn).
|
320
|
-
*/
|
321
|
-
static VALUE
|
322
|
-
rg_play(VALUE self)
|
323
|
-
{
|
324
|
-
return rb_gst_element_set_state_internal(self, GST_STATE_PLAYING);
|
325
|
-
}
|
326
|
-
|
327
|
-
/*
|
328
|
-
* Method: link(element)
|
329
|
-
* element: a Gst::Element object.
|
330
|
-
*
|
331
|
-
* Links this element (source) to the provided element (destination).
|
332
|
-
*
|
333
|
-
* The method looks for existing pads and request pads that
|
334
|
-
* aren't linked yet. If multiple links are possible, only one
|
335
|
-
* is established.
|
336
|
-
*
|
337
|
-
* Returns: the destination element, or nil if the link failed.
|
338
|
-
*/
|
339
|
-
static VALUE
|
340
|
-
rg_link(VALUE self, VALUE other_element)
|
341
|
-
{
|
342
|
-
GstElement *element1, *element2;
|
343
|
-
|
344
|
-
element1 = SELF(self);
|
345
|
-
element2 = SELF(other_element);
|
346
|
-
return gst_element_link(element1, element2) == TRUE ? other_element : Qnil;
|
347
|
-
}
|
348
|
-
|
349
|
-
/*
|
350
|
-
* Method: unlink(element)
|
351
|
-
* element: a Gst::Element object.
|
352
|
-
*
|
353
|
-
* Unlinks this element (source) to the provided element (destination).
|
354
|
-
*
|
355
|
-
* The method looks for all source pads of the source elemnt that are
|
356
|
-
* linked to the destination element and unlinkes them.
|
357
|
-
*
|
358
|
-
*/
|
359
|
-
static VALUE
|
360
|
-
rg_unlink(VALUE self, VALUE other_element)
|
361
|
-
{
|
362
|
-
GstElement *element1, *element2;
|
363
|
-
|
364
|
-
element1 = SELF(self);
|
365
|
-
element2 = SELF(other_element);
|
366
|
-
gst_element_unlink(element1, element2);
|
367
|
-
return self;
|
368
|
-
}
|
369
|
-
|
370
|
-
/*
|
371
|
-
* Method: link_filtered(element, caps)
|
372
|
-
* element: a Gst::Element object.
|
373
|
-
* caps: a Gst::Caps object.
|
374
|
-
*
|
375
|
-
* Links this element (source) to the provided element (destination),
|
376
|
-
* filtered by the given caps.
|
377
|
-
*
|
378
|
-
* The method looks for existing pads and request pads that
|
379
|
-
* aren't linked yet. If multiple links are possible, only one
|
380
|
-
* is established.
|
381
|
-
*
|
382
|
-
* Returns: the destination element, or nil if the link failed.
|
383
|
-
*/
|
384
|
-
static VALUE
|
385
|
-
rg_link_filtered(VALUE self, VALUE other_element, VALUE rcaps)
|
386
|
-
{
|
387
|
-
GstElement *element1, *element2;
|
388
|
-
GstCaps *caps;
|
389
|
-
|
390
|
-
element1 = SELF(self);
|
391
|
-
element2 = SELF(other_element);
|
392
|
-
caps = RGST_CAPS(rcaps);
|
393
|
-
return gst_element_link_filtered(element1, element2, caps)
|
394
|
-
? other_element
|
395
|
-
: Qnil;
|
396
|
-
}
|
397
|
-
|
398
|
-
/* Method: requires_clock?
|
399
|
-
* Returns: true if the element requires a clock, false otherwise.
|
400
|
-
*/
|
401
|
-
static VALUE
|
402
|
-
rg_requires_clock_p(VALUE self)
|
403
|
-
{
|
404
|
-
return CBOOL2RVAL(gst_element_requires_clock(SELF(self)));
|
405
|
-
}
|
406
|
-
|
407
|
-
/* Method: provides_clock?
|
408
|
-
* Returns: true if the element provides a clock, false otherwise.
|
409
|
-
*/
|
410
|
-
static VALUE
|
411
|
-
rg_provides_clock_p(VALUE self)
|
412
|
-
{
|
413
|
-
return CBOOL2RVAL(gst_element_provides_clock(SELF(self)));
|
414
|
-
}
|
415
|
-
|
416
|
-
/* Method: clock
|
417
|
-
* Returns: the clock of the element (as a Gst::Clock object), or nil
|
418
|
-
* if this element does not provide a clock.
|
419
|
-
*/
|
420
|
-
static VALUE
|
421
|
-
rg_clock(VALUE self)
|
422
|
-
{
|
423
|
-
GstClock *clock;
|
424
|
-
|
425
|
-
clock = gst_element_get_clock(SELF(self));
|
426
|
-
return clock != NULL ? RGST_CLOCK_NEW(clock)
|
427
|
-
: Qnil;
|
428
|
-
}
|
429
|
-
|
430
|
-
/*
|
431
|
-
* Method: set_clock(clock)
|
432
|
-
* clock: the Gst::Clock to set for the element.
|
433
|
-
*
|
434
|
-
* Sets the clock for the element.
|
435
|
-
*
|
436
|
-
* Returns: self.
|
437
|
-
*/
|
438
|
-
static VALUE
|
439
|
-
rg_set_clock(VALUE self, VALUE clock)
|
440
|
-
{
|
441
|
-
gst_element_set_clock(SELF(self), RVAL2GST_CLOCK(clock));
|
442
|
-
return self;
|
443
|
-
}
|
444
|
-
|
445
|
-
typedef void (*EachPadCallback)(VALUE pad, VALUE user_data);
|
446
|
-
typedef struct _EachPadData {
|
447
|
-
VALUE self;
|
448
|
-
EachPadCallback callback;
|
449
|
-
VALUE user_data;
|
450
|
-
GstIterator *iterator;
|
451
|
-
} EachPadData;
|
452
|
-
|
453
|
-
static VALUE
|
454
|
-
rb_gst_element_each_pad_body(VALUE user_data)
|
455
|
-
{
|
456
|
-
GstPad *pad;
|
457
|
-
gboolean done = FALSE;
|
458
|
-
EachPadData *data;
|
459
|
-
|
460
|
-
data = (EachPadData *)user_data;
|
461
|
-
|
462
|
-
while (!done) {
|
463
|
-
switch (gst_iterator_next(data->iterator, (gpointer)&pad)) {
|
464
|
-
case GST_ITERATOR_OK:
|
465
|
-
data->callback(GST_PAD2RVAL(pad), data->user_data);
|
466
|
-
gst_object_unref(pad);
|
467
|
-
break;
|
468
|
-
case GST_ITERATOR_RESYNC:
|
469
|
-
gst_iterator_resync(data->iterator);
|
470
|
-
break;
|
471
|
-
case GST_ITERATOR_ERROR:
|
472
|
-
rb_raise(rb_eIndexError, "Pad iteration failed");
|
473
|
-
break;
|
474
|
-
case GST_ITERATOR_DONE:
|
475
|
-
done = TRUE;
|
476
|
-
break;
|
477
|
-
}
|
478
|
-
}
|
479
|
-
|
480
|
-
return Qnil;
|
481
|
-
}
|
482
|
-
|
483
|
-
static VALUE
|
484
|
-
rb_gst_element_each_pad_ensure(VALUE user_data)
|
485
|
-
{
|
486
|
-
EachPadData *data = (EachPadData *)user_data;
|
487
|
-
|
488
|
-
gst_iterator_free(data->iterator);
|
489
|
-
return Qnil;
|
490
|
-
}
|
491
|
-
|
492
|
-
static VALUE
|
493
|
-
rb_gst_element_each_pad_with_callback(VALUE self,
|
494
|
-
EachPadCallback callback,
|
495
|
-
VALUE user_data)
|
496
|
-
{
|
497
|
-
EachPadData data;
|
498
|
-
|
499
|
-
data.self = self;
|
500
|
-
data.callback = callback;
|
501
|
-
data.user_data = user_data;
|
502
|
-
data.iterator = gst_element_iterate_pads(SELF(self));
|
503
|
-
return rb_ensure(rb_gst_element_each_pad_body, (VALUE)(&data),
|
504
|
-
rb_gst_element_each_pad_ensure, (VALUE)(&data));
|
505
|
-
}
|
506
|
-
|
507
|
-
/*
|
508
|
-
* Method: each_pad { |pad| ... }
|
509
|
-
*
|
510
|
-
* Calls the block for each pad associated with the element, passing a
|
511
|
-
* reference to the Gst::Pad as parameter. Throws an IndexError on errors.
|
512
|
-
* Note that the elements might be yielded multiple times if the iterator had
|
513
|
-
* to resync.
|
514
|
-
*
|
515
|
-
* Returns: always nil.
|
516
|
-
*/
|
517
|
-
static VALUE
|
518
|
-
rg_each_pad(VALUE self)
|
519
|
-
{
|
520
|
-
rb_gst_element_each_pad_with_callback(self, (EachPadCallback)rb_yield, Qnil);
|
521
|
-
return Qnil;
|
522
|
-
}
|
523
|
-
|
524
|
-
static void
|
525
|
-
collect_pad(VALUE pad, VALUE pads)
|
526
|
-
{
|
527
|
-
rb_ary_push(pads, pad);
|
528
|
-
}
|
529
|
-
|
530
|
-
static VALUE
|
531
|
-
rg_pads(VALUE self)
|
532
|
-
{
|
533
|
-
VALUE pads;
|
534
|
-
|
535
|
-
pads = rb_ary_new();
|
536
|
-
rb_gst_element_each_pad_with_callback(self, collect_pad, pads);
|
537
|
-
return pads;
|
538
|
-
}
|
539
|
-
|
540
|
-
/*
|
541
|
-
* Method: get_pad(name)
|
542
|
-
* name: the name of a pad.
|
543
|
-
*
|
544
|
-
* Retrieves a Gst::Pad object from the element by name.
|
545
|
-
*
|
546
|
-
* Returns: a Gst::Pad object, or nil if the pad cannot be found.
|
547
|
-
*/
|
548
|
-
static VALUE
|
549
|
-
rg_get_pad(VALUE self, VALUE pad_name)
|
550
|
-
{
|
551
|
-
GstPad *pad = gst_element_get_pad(SELF(self),
|
552
|
-
RVAL2CSTR(pad_name));
|
553
|
-
|
554
|
-
return pad != NULL ? RGST_PAD_NEW(pad)
|
555
|
-
: Qnil;
|
556
|
-
}
|
557
|
-
|
558
|
-
/*
|
559
|
-
* Method: link_pads(source_pad_name, element, destination_pad_name)
|
560
|
-
* element: a Gst::Element.
|
561
|
-
*
|
562
|
-
* Links the source_pad_name pad of the current element to the
|
563
|
-
* destination_pad_name pad of the destination element, returning
|
564
|
-
* true on success.
|
565
|
-
*
|
566
|
-
* Returns: true on success, false on failure.
|
567
|
-
*/
|
568
|
-
static VALUE
|
569
|
-
rg_link_pads(VALUE self, VALUE source_pad_name,
|
570
|
-
VALUE other_element, VALUE destination_pad_name)
|
571
|
-
{
|
572
|
-
return CBOOL2RVAL(gst_element_link_pads(SELF(self),
|
573
|
-
RVAL2CSTR(source_pad_name),
|
574
|
-
SELF(other_element),
|
575
|
-
RVAL2CSTR(destination_pad_name)));
|
576
|
-
}
|
577
|
-
|
578
|
-
/*
|
579
|
-
* Method: unlink_pads(source_pad_name, element, destination_pad_name)
|
580
|
-
* element: a Gst::Element.
|
581
|
-
*
|
582
|
-
* Unlinks the source_pad_name named pad of the current element from the
|
583
|
-
* destination_pad_name named pad of the destination element.
|
584
|
-
*
|
585
|
-
* Returns: self.
|
586
|
-
*/
|
587
|
-
static VALUE
|
588
|
-
rg_unlink_pads(VALUE self, VALUE source_pad_name,
|
589
|
-
VALUE other_element, VALUE destination_pad_name)
|
590
|
-
{
|
591
|
-
gst_element_unlink_pads(SELF(self),
|
592
|
-
RVAL2CSTR(source_pad_name),
|
593
|
-
SELF(other_element),
|
594
|
-
RVAL2CSTR(destination_pad_name));
|
595
|
-
return self;
|
596
|
-
}
|
597
|
-
|
598
|
-
/* Method: indexable?
|
599
|
-
* Returns: true if the element can be indexed, false otherwise.
|
600
|
-
*/
|
601
|
-
static VALUE
|
602
|
-
rg_indexable_p(VALUE self)
|
603
|
-
{
|
604
|
-
return CBOOL2RVAL(gst_element_is_indexable(SELF(self)));
|
605
|
-
}
|
606
|
-
|
607
|
-
static void
|
608
|
-
query_in_thread(gpointer data, G_GNUC_UNUSED gpointer user_data)
|
609
|
-
{
|
610
|
-
ThreadData *thread_data = (ThreadData *)data;
|
611
|
-
QueryData *query_data;
|
612
|
-
|
613
|
-
query_data = &(thread_data->data.query_data);
|
614
|
-
query_data->result = gst_element_query(thread_data->element,
|
615
|
-
query_data->query);
|
616
|
-
notify(thread_data);
|
617
|
-
}
|
618
|
-
|
619
|
-
/*
|
620
|
-
* Method: query(query)
|
621
|
-
* query: a query type (see Gst::Query).
|
622
|
-
*
|
623
|
-
* Performs a query on the element.
|
624
|
-
*
|
625
|
-
* Returns: true if the query is performed, false otherwise.
|
626
|
-
*/
|
627
|
-
static VALUE
|
628
|
-
rg_query(VALUE self, VALUE query)
|
629
|
-
{
|
630
|
-
VALUE result;
|
631
|
-
ThreadData thread_data;
|
632
|
-
QueryData *query_data;
|
633
|
-
|
634
|
-
thread_data.element = SELF(self);
|
635
|
-
thread_data.context = "query";
|
636
|
-
query_data = &(thread_data.data.query_data);
|
637
|
-
query_data->query = RVAL2GST_QUERY(query);
|
638
|
-
|
639
|
-
do_in_thread(query_thread_pool, &thread_data);
|
640
|
-
|
641
|
-
result = CBOOL2RVAL(query_data->result);
|
642
|
-
|
643
|
-
return result;
|
644
|
-
}
|
645
|
-
|
646
|
-
static void
|
647
|
-
send_event_in_thread(gpointer data, G_GNUC_UNUSED gpointer user_data)
|
648
|
-
{
|
649
|
-
ThreadData *thread_data = (ThreadData *)data;
|
650
|
-
SendEventData *send_event_data;
|
651
|
-
|
652
|
-
send_event_data = &(thread_data->data.send_event_data);
|
653
|
-
send_event_data->result = gst_element_send_event(thread_data->element,
|
654
|
-
send_event_data->event);
|
655
|
-
notify(thread_data);
|
656
|
-
}
|
657
|
-
/*
|
658
|
-
* Method: send_event(event)
|
659
|
-
* event: a Gst::Event object.
|
660
|
-
*
|
661
|
-
* Sends an event to an element, through a Gst::Event object.
|
662
|
-
* If the element doesn't implement an event handler, the event will be
|
663
|
-
* forwarded to a random sink pad.
|
664
|
-
*
|
665
|
-
* Returns: true if the request event was successfully handled, false
|
666
|
-
* otherwise.
|
667
|
-
*/
|
668
|
-
static VALUE
|
669
|
-
rg_send_event(VALUE self, VALUE event)
|
670
|
-
{
|
671
|
-
VALUE result;
|
672
|
-
ThreadData thread_data;
|
673
|
-
SendEventData *send_event_data;
|
674
|
-
|
675
|
-
thread_data.element = SELF(self);
|
676
|
-
thread_data.context = "send_event";
|
677
|
-
send_event_data = &(thread_data.data.send_event_data);
|
678
|
-
send_event_data->event = RVAL2GST_EVENT(event);
|
679
|
-
|
680
|
-
gst_event_ref(send_event_data->event);
|
681
|
-
do_in_thread(send_event_thread_pool, &thread_data);
|
682
|
-
|
683
|
-
result = CBOOL2RVAL(send_event_data->result);
|
684
|
-
|
685
|
-
return result;
|
686
|
-
}
|
687
|
-
|
688
|
-
/*
|
689
|
-
* Method: base_time
|
690
|
-
*
|
691
|
-
* Queries the element's time.
|
692
|
-
*
|
693
|
-
* Returns: the current stream time (in nanoseconds) in Gst::Element::STATE_PLAYING, the
|
694
|
-
* element base time in Gst::Element::STATE_PAUSED, or -1 otherwise.
|
695
|
-
*/
|
696
|
-
static VALUE
|
697
|
-
rg_base_time(VALUE self)
|
698
|
-
{
|
699
|
-
return ULL2NUM(gst_element_get_base_time(SELF(self)));
|
700
|
-
}
|
701
|
-
|
702
|
-
/*
|
703
|
-
* Method: set_base_time(time)
|
704
|
-
* time: time to set (in nanoseconds).
|
705
|
-
*
|
706
|
-
* Sets the current time of the element. This method can be used when handling discont events.
|
707
|
-
* You can only call this method on an element with a clock in Gst::Element::STATE_PAUSED or
|
708
|
-
* Gst::Element::STATE_PLAYING. You might want to have a look at Gst::Element#adjust_time, if
|
709
|
-
* you want to adjust by a difference as that is more accurate.
|
710
|
-
*
|
711
|
-
* Returns: self.
|
712
|
-
*/
|
713
|
-
static VALUE
|
714
|
-
rg_set_base_time(VALUE self, VALUE time)
|
715
|
-
{
|
716
|
-
gst_element_set_base_time(SELF(self), NUM2ULL(time));
|
717
|
-
return Qnil;
|
718
|
-
}
|
719
|
-
|
720
|
-
/*
|
721
|
-
* Method: index
|
722
|
-
*
|
723
|
-
* Gets the index from the element.
|
724
|
-
*
|
725
|
-
* Returns: a Gst::Index or nil when no index was set on the element.
|
726
|
-
*/
|
727
|
-
static VALUE
|
728
|
-
rg_index(VALUE self)
|
729
|
-
{
|
730
|
-
GstIndex *index = gst_element_get_index(SELF(self));
|
731
|
-
|
732
|
-
return index != NULL ? RGST_INDEX_NEW(index)
|
733
|
-
: Qnil;
|
734
|
-
}
|
735
|
-
|
736
|
-
/*
|
737
|
-
* Method: set_index(index)
|
738
|
-
* index: the index to set, as a Gst::Index.
|
739
|
-
*
|
740
|
-
* Sets the specified index on the element.
|
741
|
-
*
|
742
|
-
* Returns: self.
|
743
|
-
*/
|
744
|
-
static VALUE
|
745
|
-
rg_set_index(VALUE self, VALUE index)
|
746
|
-
{
|
747
|
-
gst_element_set_index(SELF(self), RGST_INDEX(index));
|
748
|
-
return self;
|
749
|
-
}
|
750
|
-
|
751
|
-
/*
|
752
|
-
* Method: get_static_pad(name)
|
753
|
-
* name: the name of the static Gst::Pad to retrieve.
|
754
|
-
*
|
755
|
-
* Retrieves a pad from the element by name. This version only retrieves
|
756
|
-
* already existing (i.e. 'static') pads.
|
757
|
-
*
|
758
|
-
* Returns: the requested Gst::Pad if found, otherwise nil.
|
759
|
-
*/
|
760
|
-
static VALUE
|
761
|
-
rg_get_static_pad(VALUE self, VALUE name)
|
762
|
-
{
|
763
|
-
GstPad *pad =
|
764
|
-
gst_element_get_static_pad(SELF(self), RVAL2CSTR(name));
|
765
|
-
return pad != NULL ? RGST_PAD_NEW(pad) : Qnil;
|
766
|
-
}
|
767
|
-
|
768
|
-
/*
|
769
|
-
* Method: get_request_pad(name)
|
770
|
-
* name: the name of the request Gst::Pad to retrieve.
|
771
|
-
*
|
772
|
-
* Retrieves a pad from the element by name. This version only retrieves
|
773
|
-
* request pads.
|
774
|
-
*
|
775
|
-
* Returns: the requested Gst::Pad if found, otherwise nil.
|
776
|
-
*/
|
777
|
-
static VALUE
|
778
|
-
rg_get_request_pad(VALUE self, VALUE name)
|
779
|
-
{
|
780
|
-
GstPad *pad =
|
781
|
-
gst_element_get_request_pad(SELF(self), RVAL2CSTR(name));
|
782
|
-
return pad != NULL ? GST_PAD2RVAL_UNREF(pad) : Qnil;
|
783
|
-
}
|
784
|
-
|
785
|
-
/*
|
786
|
-
* Method: release_request_pad(pad)
|
787
|
-
* pad: the Gst::Pad to release.
|
788
|
-
*
|
789
|
-
* Makes the element free the previously requested pad ass obtained with
|
790
|
-
* Gst::Element#get_requested_pad.
|
791
|
-
*
|
792
|
-
* Returns: self.
|
793
|
-
*/
|
794
|
-
static VALUE
|
795
|
-
rg_release_request_pad(VALUE self, VALUE pad)
|
796
|
-
{
|
797
|
-
gst_element_release_request_pad(SELF(self), RGST_PAD(pad));
|
798
|
-
return self;
|
799
|
-
}
|
800
|
-
|
801
|
-
/*
|
802
|
-
* Method: add_pad(pad)
|
803
|
-
* pad: the Gst::Pad to add to the element.
|
804
|
-
*
|
805
|
-
* Adds a pad (link point) to the element. Pads are automatically activated
|
806
|
-
* when the element is in state Gst::Element::PLAYING.
|
807
|
-
*
|
808
|
-
* Returns: self.
|
809
|
-
*/
|
810
|
-
static VALUE
|
811
|
-
rg_add_pad(VALUE self, VALUE pad)
|
812
|
-
{
|
813
|
-
gst_element_add_pad(SELF(self), RGST_PAD(pad));
|
814
|
-
G_CHILD_ADD(self, pad);
|
815
|
-
return self;
|
816
|
-
}
|
817
|
-
|
818
|
-
/*
|
819
|
-
* Method: remove_pad(pad)
|
820
|
-
* pad: the Gst::Pad to remove from the element.
|
821
|
-
*
|
822
|
-
* Removes the given pad from the element.
|
823
|
-
*
|
824
|
-
* Returns: self.
|
825
|
-
*/
|
826
|
-
static VALUE
|
827
|
-
rg_remove_pad(VALUE self, VALUE pad)
|
828
|
-
{
|
829
|
-
gst_element_remove_pad(SELF(self), RGST_PAD(pad));
|
830
|
-
return self;
|
831
|
-
}
|
832
|
-
|
833
|
-
/*
|
834
|
-
* Class Method: get_pad_template(name)
|
835
|
-
* name: the name of the Gst::PadTemplate to get.
|
836
|
-
*
|
837
|
-
* Retrieves a Gst::PadTemplate from this element with the given name.
|
838
|
-
*
|
839
|
-
* Returns: the Gst::PadTemplate with the given name, or nil if none was found.
|
840
|
-
*/
|
841
|
-
static VALUE
|
842
|
-
rg_s_get_pad_template(VALUE self, VALUE name)
|
843
|
-
{
|
844
|
-
GstElementClass *element_class;
|
845
|
-
GstPadTemplate *template;
|
846
|
-
|
847
|
-
element_class = g_type_class_peek(CLASS2GTYPE(self));
|
848
|
-
template = gst_element_class_get_pad_template(element_class,
|
849
|
-
RVAL2CSTR(name));
|
850
|
-
return template == NULL ? Qnil : RGST_PAD_TEMPLATE_NEW(template);
|
851
|
-
}
|
852
|
-
|
853
|
-
/*
|
854
|
-
* Class Method: pad_templates
|
855
|
-
*
|
856
|
-
* Retrieves a list of pad templates associated with the element.
|
857
|
-
*
|
858
|
-
* Returns: an Array of Gst::PadTemplate objects.
|
859
|
-
*/
|
860
|
-
static VALUE
|
861
|
-
rg_s_pad_templates(VALUE self)
|
862
|
-
{
|
863
|
-
GstElementClass *element_class;
|
864
|
-
GList *list, *node;
|
865
|
-
VALUE ary;
|
866
|
-
|
867
|
-
ary = rb_ary_new();
|
868
|
-
|
869
|
-
element_class = g_type_class_peek(CLASS2GTYPE(self));
|
870
|
-
list = gst_element_class_get_pad_template_list(element_class);
|
871
|
-
for (node = list; node != NULL; node = g_list_next(node)) {
|
872
|
-
rb_ary_push(ary, RGST_PAD_TEMPLATE_NEW(node->data));
|
873
|
-
}
|
874
|
-
g_list_free(list);
|
875
|
-
return ary;
|
876
|
-
}
|
877
|
-
|
878
|
-
/*
|
879
|
-
* Class Method: each_pad_template { |pad_template| ... }
|
880
|
-
*
|
881
|
-
* Calls the block for each pad template associated with the element,
|
882
|
-
* passing a reference to a Gst::PadTemplate object as parameter.
|
883
|
-
*
|
884
|
-
* Returns: always nil.
|
885
|
-
*/
|
886
|
-
static VALUE
|
887
|
-
rg_s_each_pad_template(VALUE self)
|
888
|
-
{
|
889
|
-
return rb_ary_yield(rg_s_pad_templates(self));
|
890
|
-
}
|
891
|
-
|
892
|
-
/*
|
893
|
-
* Method: seek_simple(format, flags, position)
|
894
|
-
* format: the format to use for seeking (see Gst::Format::Type).
|
895
|
-
* flags: seek options (see Gst::Seek::FlAG_*)
|
896
|
-
* position: the position to seek to.
|
897
|
-
*
|
898
|
-
* Sends a seek event (Gst::EventSseek) to the element.
|
899
|
-
*
|
900
|
-
* Returns: true if the event was handled.
|
901
|
-
*/
|
902
|
-
static VALUE
|
903
|
-
rg_seek_simple(VALUE self, VALUE format, VALUE flags, VALUE position)
|
904
|
-
{
|
905
|
-
return CBOOL2RVAL(gst_element_seek_simple(SELF(self),
|
906
|
-
RVAL2GENUM(format, GST_TYPE_FORMAT),
|
907
|
-
RVAL2GFLAGS(flags, GST_TYPE_SEEK_FLAGS),
|
908
|
-
NUM2LL(position)));
|
909
|
-
}
|
910
|
-
|
911
|
-
/*
|
912
|
-
* Method: seek(seek_type, offset)
|
913
|
-
* seek_type: the method to use for seeking (see Gst::EventSeek::Type).
|
914
|
-
* offset: the offset to seek to.
|
915
|
-
*
|
916
|
-
* Sends a seek event (Gst::EventSseek) to the element.
|
917
|
-
*
|
918
|
-
* Returns: true if the event was handled.
|
919
|
-
*/
|
920
|
-
static VALUE
|
921
|
-
rg_seek(VALUE self, VALUE rate, VALUE format, VALUE flags,
|
922
|
-
VALUE cur_type, VALUE cur, VALUE stop_type, VALUE stop)
|
923
|
-
{
|
924
|
-
return CBOOL2RVAL(gst_element_seek(SELF(self),
|
925
|
-
NUM2DBL(rate),
|
926
|
-
RVAL2GENUM(format, GST_TYPE_FORMAT),
|
927
|
-
RVAL2GFLAGS(flags, GST_TYPE_SEEK_FLAGS),
|
928
|
-
RVAL2GENUM(cur_type, GST_TYPE_SEEK_TYPE),
|
929
|
-
NUM2LL(cur),
|
930
|
-
RVAL2GENUM(stop_type, GST_TYPE_SEEK_TYPE),
|
931
|
-
NUM2LL(stop)));
|
932
|
-
}
|
933
|
-
|
934
|
-
/*
|
935
|
-
* Method: locked_state?
|
936
|
-
*
|
937
|
-
* Checks if the state of an element is locked. If the state of an element is
|
938
|
-
* locked, state changes of the parent don't affect the element. This way you
|
939
|
-
* can leave currently unused elements inside bins. Just lock their state
|
940
|
-
* before changing the state from Gst::Element::STATE_NULL.
|
941
|
-
*
|
942
|
-
* Returns: true if the element's state is locked.
|
943
|
-
*/
|
944
|
-
static VALUE
|
945
|
-
rg_locked_state_p(VALUE self)
|
946
|
-
{
|
947
|
-
return CBOOL2RVAL(gst_element_is_locked_state(SELF(self)));
|
948
|
-
}
|
949
|
-
|
950
|
-
/*
|
951
|
-
* Method: set_locked_state(state)
|
952
|
-
* state: whether to lock the element's state.
|
953
|
-
*
|
954
|
-
* Locks the state of an element, so state changes of the parent don't affect
|
955
|
-
* this element anymore.
|
956
|
-
*
|
957
|
-
* Returns: self.
|
958
|
-
*/
|
959
|
-
static VALUE
|
960
|
-
rg_set_locked_state(VALUE self, VALUE state)
|
961
|
-
{
|
962
|
-
gst_element_set_locked_state(SELF(self), RVAL2CBOOL(state));
|
963
|
-
return self;
|
964
|
-
}
|
965
|
-
|
966
|
-
/*
|
967
|
-
* Method: sync_state_with_parent
|
968
|
-
*
|
969
|
-
* Tries to change the state of the element to the same as its parent. If this
|
970
|
-
* method returns false, the state of element is undefined.
|
971
|
-
*
|
972
|
-
* Returns: true if the element's state could be synced to the parent's state.
|
973
|
-
*/
|
974
|
-
static VALUE
|
975
|
-
rg_sync_state_with_parent(VALUE self)
|
976
|
-
{
|
977
|
-
return
|
978
|
-
CBOOL2RVAL(gst_element_sync_state_with_parent(SELF(self)));
|
979
|
-
}
|
980
|
-
|
981
|
-
/*
|
982
|
-
* Method: no_more_pads
|
983
|
-
*
|
984
|
-
* Uses this method to signal that the element does not expect any more pads
|
985
|
-
* to show up in the current pipeline. This method should be called whenever
|
986
|
-
* pads have been added by the element itself.
|
987
|
-
* Elements with Gst::Pad::SOMETIMES pad templates use this in combination
|
988
|
-
* with autopluggers to figure out that the element is done initializing its
|
989
|
-
* pads.
|
990
|
-
*
|
991
|
-
* Returns: self.
|
992
|
-
*/
|
993
|
-
static VALUE
|
994
|
-
rg_no_more_pads(VALUE self)
|
995
|
-
{
|
996
|
-
gst_element_no_more_pads(SELF(self));
|
997
|
-
return self;
|
998
|
-
}
|
999
|
-
|
1000
|
-
static VALUE
|
1001
|
-
rb_gst_element_found_tag_sig(G_GNUC_UNUSED guint n, const GValue *values)
|
1002
|
-
{
|
1003
|
-
GstElement *element, *source;
|
1004
|
-
GstTagList *tag_list;
|
1005
|
-
|
1006
|
-
element = g_value_get_object(&values[0]);
|
1007
|
-
source = g_value_get_object(&values[1]);
|
1008
|
-
tag_list = g_value_get_boxed(&values[2]);
|
1009
|
-
|
1010
|
-
return rb_ary_new3(3,
|
1011
|
-
GST_ELEMENT2RVAL(element),
|
1012
|
-
GST_ELEMENT2RVAL(source),
|
1013
|
-
GST_STRUCT2RVAL(tag_list));
|
1014
|
-
}
|
1015
|
-
|
1016
|
-
static void
|
1017
|
-
initialize_thread_pool(GThreadPool **pool, GFunc function)
|
1018
|
-
{
|
1019
|
-
GError *error = NULL;
|
1020
|
-
|
1021
|
-
*pool = g_thread_pool_new(function, NULL, -1, FALSE, &error);
|
1022
|
-
if (error)
|
1023
|
-
RAISE_GERROR(error);
|
1024
|
-
}
|
1025
|
-
|
1026
|
-
void
|
1027
|
-
Init_gst_element(VALUE mGst)
|
1028
|
-
{
|
1029
|
-
RGConvertTable table;
|
1030
|
-
memset(&table, 0, sizeof(table));
|
1031
|
-
table.type = GST_TYPE_ELEMENT;
|
1032
|
-
table.klass = Qnil;
|
1033
|
-
table.instance2robj = instance2robj;
|
1034
|
-
RG_DEF_CONVERSION(&table);
|
1035
|
-
|
1036
|
-
id_gtype = rb_intern("gtype");
|
1037
|
-
|
1038
|
-
initialize_thread_pool(&set_state_thread_pool, set_state_in_thread);
|
1039
|
-
initialize_thread_pool(&get_state_thread_pool, get_state_in_thread);
|
1040
|
-
initialize_thread_pool(&query_thread_pool, query_in_thread);
|
1041
|
-
initialize_thread_pool(&send_event_thread_pool, send_event_in_thread);
|
1042
|
-
|
1043
|
-
RG_TARGET_NAMESPACE = G_DEF_CLASS(GST_TYPE_ELEMENT, "Element", mGst);
|
1044
|
-
|
1045
|
-
RG_DEF_SMETHOD(get_pad_template, 1);
|
1046
|
-
RG_DEF_SMETHOD(pad_templates, 0);
|
1047
|
-
RG_DEF_SMETHOD(each_pad_template, 0);
|
1048
|
-
|
1049
|
-
RG_DEF_METHOD(set_state, 1);
|
1050
|
-
RG_DEF_METHOD(get_state, -1);
|
1051
|
-
RG_DEF_METHOD(stop, 0);
|
1052
|
-
RG_DEF_METHOD(ready, 0);
|
1053
|
-
RG_DEF_METHOD(pause, 0);
|
1054
|
-
RG_DEF_METHOD(play, 0);
|
1055
|
-
RG_DEF_METHOD(link, 1);
|
1056
|
-
RG_DEF_ALIAS(">>", "link");
|
1057
|
-
RG_DEF_METHOD(unlink, 1);
|
1058
|
-
RG_DEF_METHOD(link_filtered, 2);
|
1059
|
-
RG_DEF_METHOD_P(provides_clock, 0);
|
1060
|
-
RG_DEF_ALIAS("provide_clock?", "provides_clock?");
|
1061
|
-
RG_DEF_METHOD_P(requires_clock, 0);
|
1062
|
-
RG_DEF_ALIAS("require_clock?", "requires_clock?");
|
1063
|
-
RG_DEF_METHOD(clock, 0);
|
1064
|
-
RG_DEF_METHOD(set_clock, 1);
|
1065
|
-
RG_DEF_METHOD(base_time, 0);
|
1066
|
-
RG_DEF_METHOD(set_base_time, 1);
|
1067
|
-
RG_DEF_METHOD(each_pad, 0);
|
1068
|
-
RG_DEF_METHOD(pads, 0);
|
1069
|
-
RG_DEF_METHOD(get_pad, 1);
|
1070
|
-
RG_DEF_ALIAS("[]", "get_pad");
|
1071
|
-
RG_DEF_METHOD(get_static_pad, 1);
|
1072
|
-
RG_DEF_METHOD(get_request_pad, 1);
|
1073
|
-
RG_DEF_METHOD(release_request_pad, 1);
|
1074
|
-
RG_DEF_METHOD(link_pads, 3);
|
1075
|
-
RG_DEF_METHOD(unlink_pads, 3);
|
1076
|
-
RG_DEF_METHOD(add_pad, 1);
|
1077
|
-
RG_DEF_METHOD(remove_pad, 1);
|
1078
|
-
RG_DEF_METHOD_P(indexable, 0);
|
1079
|
-
RG_DEF_METHOD(query, 1);
|
1080
|
-
RG_DEF_METHOD(send_event, 1);
|
1081
|
-
RG_DEF_METHOD(seek_simple, 3);
|
1082
|
-
RG_DEF_METHOD(seek, 7);
|
1083
|
-
RG_DEF_METHOD(index, 0);
|
1084
|
-
RG_DEF_METHOD(set_index, 1);
|
1085
|
-
RG_DEF_METHOD_P(locked_state, 0);
|
1086
|
-
RG_DEF_METHOD(set_locked_state, 1);
|
1087
|
-
RG_DEF_METHOD(sync_state_with_parent, 0);
|
1088
|
-
RG_DEF_METHOD(no_more_pads, 0);
|
1089
|
-
|
1090
|
-
G_DEF_CLASS(GST_TYPE_STATE, "State", mGst);
|
1091
|
-
G_DEF_CONSTANTS(mGst, GST_TYPE_STATE, "GST_");
|
1092
|
-
G_DEF_CLASS(GST_TYPE_STATE_CHANGE_RETURN, "StateChangeReturn", mGst);
|
1093
|
-
G_DEF_CONSTANTS(mGst, GST_TYPE_STATE_CHANGE_RETURN, "GST_");
|
1094
|
-
G_DEF_CLASS(GST_TYPE_STATE_CHANGE, "StateChange", mGst);
|
1095
|
-
G_DEF_CONSTANTS(mGst, GST_TYPE_STATE_CHANGE, "GST_");
|
1096
|
-
G_DEF_CLASS(GST_TYPE_ELEMENT_FLAGS, "Flags", RG_TARGET_NAMESPACE);
|
1097
|
-
G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GST_TYPE_ELEMENT_FLAGS, "GST_ELEMENT_");
|
1098
|
-
|
1099
|
-
/*
|
1100
|
-
* TODO:
|
1101
|
-
* gst_element_clock_wait()
|
1102
|
-
*/
|
1103
|
-
|
1104
|
-
G_DEF_SIGNAL_FUNC(RG_TARGET_NAMESPACE, "found-tag",
|
1105
|
-
(GValToRValSignalFunc)rb_gst_element_found_tag_sig);
|
1106
|
-
}
|