gstreamer 1.2.6 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,363 +0,0 @@
|
|
1
|
-
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
/*
|
3
|
-
* Copyright (C) 2011-2012 Ruby-GNOME2 Project Team
|
4
|
-
* Copyright (C) 2007 Ruby-GNOME2 Project Team
|
5
|
-
*
|
6
|
-
* This library is free software; you can redistribute it and/or
|
7
|
-
* modify it under the terms of the GNU Lesser General Public
|
8
|
-
* License as published by the Free Software Foundation; either
|
9
|
-
* version 2.1 of the License, or (at your option) any later version.
|
10
|
-
*
|
11
|
-
* This library is distributed in the hope that it will be useful,
|
12
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
-
* Lesser General Public License for more details.
|
15
|
-
*
|
16
|
-
* You should have received a copy of the GNU Lesser General Public
|
17
|
-
* License along with this library; if not, write to the Free Software
|
18
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19
|
-
* MA 02110-1301 USA
|
20
|
-
*/
|
21
|
-
|
22
|
-
#include "rbgst-private.h"
|
23
|
-
|
24
|
-
#define RG_TARGET_NAMESPACE cBuffer
|
25
|
-
#define SELF(obj) (RVAL2GST_BUF(obj))
|
26
|
-
#define RVAL2GST_FLAGS(flags) \
|
27
|
-
(RVAL2GFLAGS(flags, GST_TYPE_BUFFER_FLAG))
|
28
|
-
#define GST_FLAGS2RVAL(flags) \
|
29
|
-
(GFLAGS2RVAL(flags, GST_TYPE_BUFFER_FLAG))
|
30
|
-
#define RVAL2GST_COPY_FLAGS(flags) \
|
31
|
-
(RVAL2GFLAGS(flags, GST_TYPE_BUFFER_COPY_FLAGS))
|
32
|
-
#define GST_COPY_FLAGS2RVAL(flags) \
|
33
|
-
(GFLAGS2RVAL(flags, GST_TYPE_BUFFER_COPY_FLAGS))
|
34
|
-
|
35
|
-
static VALUE
|
36
|
-
rg_initialize(int argc, VALUE *argv, VALUE self)
|
37
|
-
{
|
38
|
-
VALUE size;
|
39
|
-
GstBuffer *buffer;
|
40
|
-
|
41
|
-
rb_scan_args(argc, argv, "01", &size);
|
42
|
-
|
43
|
-
if (NIL_P(size))
|
44
|
-
buffer = gst_buffer_new();
|
45
|
-
else
|
46
|
-
buffer = gst_buffer_new_and_alloc(NUM2UINT(size));
|
47
|
-
|
48
|
-
G_INITIALIZE(self, buffer);
|
49
|
-
|
50
|
-
return Qnil;
|
51
|
-
}
|
52
|
-
|
53
|
-
static VALUE
|
54
|
-
rg_flags(VALUE self)
|
55
|
-
{
|
56
|
-
return GST_FLAGS2RVAL(GST_BUFFER_FLAGS(SELF(self)));
|
57
|
-
}
|
58
|
-
|
59
|
-
static VALUE
|
60
|
-
rg_set_flags(VALUE self, VALUE flag)
|
61
|
-
{
|
62
|
-
GST_BUFFER_FLAGS(SELF(self)) = RVAL2GST_FLAGS(flag);
|
63
|
-
return Qnil;
|
64
|
-
}
|
65
|
-
|
66
|
-
static VALUE
|
67
|
-
rg_raise_flag(VALUE self, VALUE flag)
|
68
|
-
{
|
69
|
-
GST_MINI_OBJECT_FLAG_SET(SELF(self), RVAL2GST_FLAGS(flag));
|
70
|
-
return Qnil;
|
71
|
-
}
|
72
|
-
|
73
|
-
static VALUE
|
74
|
-
rg_lower_flag(VALUE self, VALUE flag)
|
75
|
-
{
|
76
|
-
GST_MINI_OBJECT_FLAG_UNSET(SELF(self), RVAL2GST_FLAGS(flag));
|
77
|
-
return Qnil;
|
78
|
-
}
|
79
|
-
|
80
|
-
static VALUE
|
81
|
-
rg_flag_raised_p(VALUE self, VALUE flag)
|
82
|
-
{
|
83
|
-
return CBOOL2RVAL(GST_MINI_OBJECT_FLAG_IS_SET(SELF(self),
|
84
|
-
RVAL2GST_FLAGS(flag)));
|
85
|
-
}
|
86
|
-
|
87
|
-
static VALUE
|
88
|
-
rg_data(VALUE self)
|
89
|
-
{
|
90
|
-
GstBuffer *buffer;
|
91
|
-
guint size;
|
92
|
-
|
93
|
-
buffer = SELF(self);
|
94
|
-
size = GST_BUFFER_SIZE(buffer);
|
95
|
-
|
96
|
-
if (size == 0)
|
97
|
-
return Qnil;
|
98
|
-
else
|
99
|
-
return rb_str_new((char *)GST_BUFFER_DATA(buffer), size);
|
100
|
-
}
|
101
|
-
|
102
|
-
static VALUE
|
103
|
-
rg_set_data(VALUE self, VALUE data)
|
104
|
-
{
|
105
|
-
GstBuffer *buffer;
|
106
|
-
buffer = SELF(self);
|
107
|
-
|
108
|
-
rb_ivar_set(self, rb_intern("data"), data);
|
109
|
-
if (NIL_P(data)) {
|
110
|
-
gst_buffer_set_data(buffer, NULL, 0);
|
111
|
-
} else {
|
112
|
-
gst_buffer_set_data(buffer,
|
113
|
-
(guint8 *)RVAL2CSTR(data),
|
114
|
-
RSTRING_LEN(data));
|
115
|
-
}
|
116
|
-
return Qnil;
|
117
|
-
}
|
118
|
-
|
119
|
-
static VALUE
|
120
|
-
rg_size(VALUE self)
|
121
|
-
{
|
122
|
-
return UINT2NUM(GST_BUFFER_SIZE(SELF(self)));
|
123
|
-
}
|
124
|
-
|
125
|
-
static VALUE
|
126
|
-
rg_set_size(VALUE self, VALUE size)
|
127
|
-
{
|
128
|
-
GST_BUFFER_SIZE(SELF(self)) = NUM2UINT(size);
|
129
|
-
return Qnil;
|
130
|
-
}
|
131
|
-
|
132
|
-
static VALUE
|
133
|
-
rg_timestamp(VALUE self)
|
134
|
-
{
|
135
|
-
return ULL2NUM(GST_BUFFER_TIMESTAMP(SELF(self)));
|
136
|
-
}
|
137
|
-
|
138
|
-
static VALUE
|
139
|
-
rg_set_timestamp(VALUE self, VALUE timestamp)
|
140
|
-
{
|
141
|
-
GST_BUFFER_TIMESTAMP(SELF(self)) = NUM2ULL(timestamp);
|
142
|
-
return Qnil;
|
143
|
-
}
|
144
|
-
|
145
|
-
static VALUE
|
146
|
-
rg_valid_timestamp_p(VALUE self)
|
147
|
-
{
|
148
|
-
return CBOOL2RVAL(GST_BUFFER_TIMESTAMP_IS_VALID(SELF(self)));
|
149
|
-
}
|
150
|
-
|
151
|
-
static VALUE
|
152
|
-
rg_duration(VALUE self)
|
153
|
-
{
|
154
|
-
return ULL2NUM(GST_BUFFER_DURATION(SELF(self)));
|
155
|
-
}
|
156
|
-
|
157
|
-
static VALUE
|
158
|
-
rg_set_duration(VALUE self, VALUE duration)
|
159
|
-
{
|
160
|
-
GST_BUFFER_DURATION(SELF(self)) = NUM2ULL(duration);
|
161
|
-
return Qnil;
|
162
|
-
}
|
163
|
-
|
164
|
-
static VALUE
|
165
|
-
rg_valid_duration_p(VALUE self)
|
166
|
-
{
|
167
|
-
return CBOOL2RVAL(GST_BUFFER_DURATION_IS_VALID(SELF(self)));
|
168
|
-
}
|
169
|
-
|
170
|
-
static VALUE
|
171
|
-
rg_caps(VALUE self)
|
172
|
-
{
|
173
|
-
return GST_CAPS2RVAL(GST_BUFFER_CAPS(SELF(self)));
|
174
|
-
}
|
175
|
-
|
176
|
-
static VALUE
|
177
|
-
rg_set_caps(VALUE self, VALUE caps)
|
178
|
-
{
|
179
|
-
gst_buffer_set_caps(SELF(self), RVAL2GST_CAPS(caps));
|
180
|
-
return Qnil;
|
181
|
-
}
|
182
|
-
|
183
|
-
static VALUE
|
184
|
-
rg_offset(VALUE self)
|
185
|
-
{
|
186
|
-
return ULL2NUM(GST_BUFFER_OFFSET(SELF(self)));
|
187
|
-
}
|
188
|
-
|
189
|
-
static VALUE
|
190
|
-
rg_set_offset(VALUE self, VALUE offset)
|
191
|
-
{
|
192
|
-
GST_BUFFER_OFFSET(SELF(self)) = NUM2ULL(offset);
|
193
|
-
return Qnil;
|
194
|
-
}
|
195
|
-
|
196
|
-
static VALUE
|
197
|
-
rg_valid_offset_p(VALUE self)
|
198
|
-
{
|
199
|
-
return CBOOL2RVAL(GST_BUFFER_OFFSET_IS_VALID(SELF(self)));
|
200
|
-
}
|
201
|
-
|
202
|
-
static VALUE
|
203
|
-
rg_offset_end(VALUE self)
|
204
|
-
{
|
205
|
-
return ULL2NUM(GST_BUFFER_OFFSET_END(SELF(self)));
|
206
|
-
}
|
207
|
-
|
208
|
-
static VALUE
|
209
|
-
rg_set_offset_end(VALUE self, VALUE offset_end)
|
210
|
-
{
|
211
|
-
GST_BUFFER_OFFSET_END(SELF(self)) = NUM2ULL(offset_end);
|
212
|
-
return Qnil;
|
213
|
-
}
|
214
|
-
|
215
|
-
static VALUE
|
216
|
-
rg_valid_offset_end_p(VALUE self)
|
217
|
-
{
|
218
|
-
return CBOOL2RVAL(GST_BUFFER_OFFSET_END_IS_VALID(SELF(self)));
|
219
|
-
}
|
220
|
-
|
221
|
-
static VALUE
|
222
|
-
rg_discontinuity_p(VALUE self)
|
223
|
-
{
|
224
|
-
return CBOOL2RVAL(GST_BUFFER_IS_DISCONT(SELF(self)));
|
225
|
-
}
|
226
|
-
|
227
|
-
static VALUE
|
228
|
-
rg_copy_metadata(int argc, VALUE *argv, VALUE self)
|
229
|
-
{
|
230
|
-
VALUE arg1, arg2, copied_dest;
|
231
|
-
GstBuffer *dest;
|
232
|
-
GstBufferCopyFlags flags;
|
233
|
-
|
234
|
-
rb_scan_args(argc, argv, "11", &arg1, &arg2);
|
235
|
-
if (argc == 1) {
|
236
|
-
dest = gst_buffer_new();
|
237
|
-
flags = RVAL2GST_COPY_FLAGS(arg1);
|
238
|
-
} else {
|
239
|
-
dest = SELF(arg1);
|
240
|
-
flags = RVAL2GST_COPY_FLAGS(arg2);
|
241
|
-
}
|
242
|
-
|
243
|
-
gst_buffer_copy_metadata(dest, SELF(self), flags);
|
244
|
-
copied_dest = GOBJ2RVAL(dest);
|
245
|
-
if (argc == 1)
|
246
|
-
gst_buffer_unref(dest);
|
247
|
-
|
248
|
-
return copied_dest;
|
249
|
-
}
|
250
|
-
|
251
|
-
static VALUE
|
252
|
-
rg_metadata_writable_p(VALUE self)
|
253
|
-
{
|
254
|
-
return CBOOL2RVAL(gst_buffer_is_metadata_writable(SELF(self)));
|
255
|
-
}
|
256
|
-
|
257
|
-
static VALUE
|
258
|
-
rg_metadata_writable_bang(VALUE self)
|
259
|
-
{
|
260
|
-
GstBuffer *orig_buffer, *buffer;
|
261
|
-
VALUE rb_buffer;
|
262
|
-
|
263
|
-
orig_buffer = SELF(self);
|
264
|
-
buffer = gst_buffer_make_metadata_writable(orig_buffer);
|
265
|
-
rb_buffer = GOBJ2RVAL(buffer);
|
266
|
-
DATA_PTR(self) = buffer;
|
267
|
-
if (buffer != orig_buffer)
|
268
|
-
gst_buffer_unref(orig_buffer);
|
269
|
-
return rb_buffer;
|
270
|
-
}
|
271
|
-
|
272
|
-
static VALUE
|
273
|
-
rg_create_sub(VALUE self, VALUE offset, VALUE size)
|
274
|
-
{
|
275
|
-
GstBuffer *buffer;
|
276
|
-
VALUE rb_buffer;
|
277
|
-
|
278
|
-
buffer = gst_buffer_create_sub(SELF(self), NUM2UINT(offset), NUM2UINT(size));
|
279
|
-
rb_buffer = GOBJ2RVAL(buffer);
|
280
|
-
return rb_buffer;
|
281
|
-
}
|
282
|
-
|
283
|
-
static VALUE
|
284
|
-
rg_span(VALUE self, VALUE offset, VALUE other, VALUE length)
|
285
|
-
{
|
286
|
-
return GOBJ2RVAL(gst_buffer_span(SELF(self), NUM2UINT(offset),
|
287
|
-
SELF(other), NUM2UINT(length)));
|
288
|
-
}
|
289
|
-
|
290
|
-
static VALUE
|
291
|
-
rg_span_p(VALUE self, VALUE other)
|
292
|
-
{
|
293
|
-
return CBOOL2RVAL(gst_buffer_is_span_fast(SELF(self), SELF(other)));
|
294
|
-
}
|
295
|
-
|
296
|
-
void
|
297
|
-
Init_gst_buffer(VALUE mGst)
|
298
|
-
{
|
299
|
-
VALUE RG_TARGET_NAMESPACE, rb_cGstBufferCopyFlags;
|
300
|
-
|
301
|
-
RG_TARGET_NAMESPACE = G_DEF_CLASS(GST_TYPE_BUFFER, "Buffer", mGst);
|
302
|
-
|
303
|
-
rb_define_const(RG_TARGET_NAMESPACE, "OFFSET_NONE",
|
304
|
-
ULL2NUM(GST_BUFFER_OFFSET_NONE));
|
305
|
-
|
306
|
-
G_DEF_CLASS(GST_TYPE_BUFFER_FLAG, "Flags", RG_TARGET_NAMESPACE);
|
307
|
-
G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GST_TYPE_BUFFER_FLAG, "GST_BUFFER_");
|
308
|
-
|
309
|
-
rb_cGstBufferCopyFlags = G_DEF_CLASS(GST_TYPE_BUFFER_COPY_FLAGS,
|
310
|
-
"CopyFlags", RG_TARGET_NAMESPACE);
|
311
|
-
G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GST_TYPE_BUFFER_COPY_FLAGS, "GST_BUFFER_");
|
312
|
-
rb_define_const(rb_cGstBufferCopyFlags, "ALL",
|
313
|
-
GST_COPY_FLAGS2RVAL(GST_BUFFER_COPY_ALL));
|
314
|
-
rb_define_const(RG_TARGET_NAMESPACE, "COPY_ALL",
|
315
|
-
GST_COPY_FLAGS2RVAL(GST_BUFFER_COPY_ALL));
|
316
|
-
|
317
|
-
RG_DEF_METHOD(initialize, -1);
|
318
|
-
|
319
|
-
RG_DEF_METHOD(flags, 0);
|
320
|
-
RG_DEF_METHOD(set_flags, 1);
|
321
|
-
RG_DEF_METHOD(raise_flag, 1);
|
322
|
-
RG_DEF_METHOD(lower_flag, 1);
|
323
|
-
RG_DEF_METHOD_P(flag_raised, 1);
|
324
|
-
|
325
|
-
RG_DEF_METHOD(data, 0);
|
326
|
-
RG_DEF_METHOD(set_data, 1);
|
327
|
-
|
328
|
-
RG_DEF_METHOD(size, 0);
|
329
|
-
RG_DEF_METHOD(set_size, 1);
|
330
|
-
RG_DEF_ALIAS("length", "size");
|
331
|
-
RG_DEF_ALIAS("set_length", "set_size");
|
332
|
-
|
333
|
-
RG_DEF_METHOD(timestamp, 0);
|
334
|
-
RG_DEF_METHOD(set_timestamp, 1);
|
335
|
-
RG_DEF_METHOD_P(valid_timestamp, 0);
|
336
|
-
|
337
|
-
RG_DEF_METHOD(duration, 0);
|
338
|
-
RG_DEF_METHOD(set_duration, 1);
|
339
|
-
RG_DEF_METHOD_P(valid_duration, 0);
|
340
|
-
|
341
|
-
RG_DEF_METHOD(caps, 0);
|
342
|
-
RG_DEF_METHOD(set_caps, 1);
|
343
|
-
|
344
|
-
RG_DEF_METHOD(offset, 0);
|
345
|
-
RG_DEF_METHOD(set_offset, 1);
|
346
|
-
RG_DEF_METHOD_P(valid_offset, 0);
|
347
|
-
|
348
|
-
RG_DEF_METHOD(offset_end, 0);
|
349
|
-
RG_DEF_METHOD(set_offset_end, 1);
|
350
|
-
RG_DEF_METHOD_P(valid_offset_end, 0);
|
351
|
-
|
352
|
-
RG_DEF_METHOD_P(discontinuity, 0);
|
353
|
-
|
354
|
-
RG_DEF_METHOD(copy_metadata, -1);
|
355
|
-
|
356
|
-
RG_DEF_METHOD_P(metadata_writable, 0);
|
357
|
-
RG_DEF_METHOD_BANG(metadata_writable, 0);
|
358
|
-
|
359
|
-
RG_DEF_METHOD(create_sub, 2);
|
360
|
-
|
361
|
-
RG_DEF_METHOD(span, 3);
|
362
|
-
RG_DEF_METHOD_P(span, 1);
|
363
|
-
}
|
data/ext/gstreamer/rbgst-bus.c
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
/*
|
3
|
-
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
-
* Copyright (C) 2007 Ruby-GNOME2 Project Team
|
5
|
-
*
|
6
|
-
* This library is free software; you can redistribute it and/or
|
7
|
-
* modify it under the terms of the GNU Lesser General Public
|
8
|
-
* License as published by the Free Software Foundation; either
|
9
|
-
* version 2.1 of the License, or (at your option) any later version.
|
10
|
-
*
|
11
|
-
* This library is distributed in the hope that it will be useful,
|
12
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
-
* Lesser General Public License for more details.
|
15
|
-
*
|
16
|
-
* You should have received a copy of the GNU Lesser General Public
|
17
|
-
* License along with this library; if not, write to the Free Software
|
18
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19
|
-
* MA 02110-1301 USA
|
20
|
-
*/
|
21
|
-
|
22
|
-
#include "rbgst-private.h"
|
23
|
-
|
24
|
-
/* Class: Gst::Bus
|
25
|
-
* Asynchronous message bus subsystem.
|
26
|
-
*/
|
27
|
-
|
28
|
-
#define RG_TARGET_NAMESPACE cBus
|
29
|
-
#define SELF(obj) (RVAL2GST_BUS(obj))
|
30
|
-
|
31
|
-
static ID id_call;
|
32
|
-
|
33
|
-
typedef struct _callback_info_t
|
34
|
-
{
|
35
|
-
VALUE bus;
|
36
|
-
VALUE callback;
|
37
|
-
guint id;
|
38
|
-
} callback_info_t;
|
39
|
-
|
40
|
-
static gboolean
|
41
|
-
invoke_watch_func(GstBus *bus, GstMessage *message, gpointer data)
|
42
|
-
{
|
43
|
-
callback_info_t *info = data;
|
44
|
-
|
45
|
-
return RVAL2CBOOL(rb_funcall(info->callback, id_call, 2,
|
46
|
-
RGST_BUS2RVAL(bus),
|
47
|
-
GST_MSG2RVAL(message)));
|
48
|
-
}
|
49
|
-
|
50
|
-
static void
|
51
|
-
destroy_watch_func(gpointer data)
|
52
|
-
{
|
53
|
-
callback_info_t *info = data;
|
54
|
-
|
55
|
-
G_CHILD_REMOVE(info->bus, info->callback);
|
56
|
-
g_free(info);
|
57
|
-
}
|
58
|
-
|
59
|
-
static VALUE
|
60
|
-
rg_add_watch(int argc, VALUE *argv, VALUE self)
|
61
|
-
{
|
62
|
-
VALUE rb_priority, block, rb_id;
|
63
|
-
gint priority;
|
64
|
-
callback_info_t *info;
|
65
|
-
|
66
|
-
rb_scan_args(argc, argv, "01&", &rb_priority, &block);
|
67
|
-
|
68
|
-
priority = NIL_P(rb_priority) ? G_PRIORITY_DEFAULT : INT2NUM(rb_priority);
|
69
|
-
info = g_new(callback_info_t, 1);
|
70
|
-
info->bus = self;
|
71
|
-
info->callback = block;
|
72
|
-
info->id = gst_bus_add_watch_full(SELF(self),
|
73
|
-
priority,
|
74
|
-
invoke_watch_func,
|
75
|
-
(gpointer)info,
|
76
|
-
destroy_watch_func);
|
77
|
-
rb_id = UINT2NUM(info->id);
|
78
|
-
G_CHILD_ADD(self, block);
|
79
|
-
return rb_id;
|
80
|
-
}
|
81
|
-
|
82
|
-
void
|
83
|
-
Init_gst_bus (VALUE mGst)
|
84
|
-
{
|
85
|
-
VALUE RG_TARGET_NAMESPACE;
|
86
|
-
|
87
|
-
id_call = rb_intern("call");
|
88
|
-
|
89
|
-
RG_TARGET_NAMESPACE = G_DEF_CLASS(GST_TYPE_BUS, "Bus", mGst);
|
90
|
-
|
91
|
-
RG_DEF_METHOD(add_watch, -1);
|
92
|
-
}
|