gstreamer 0.90.6

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.
Files changed (126) hide show
  1. data/ChangeLog +1157 -0
  2. data/README +33 -0
  3. data/Rakefile +15 -0
  4. data/ext/gstreamer/Makefile +162 -0
  5. data/ext/gstreamer/depend +5 -0
  6. data/ext/gstreamer/extconf.rb +63 -0
  7. data/ext/gstreamer/gst.so +0 -0
  8. data/ext/gstreamer/misc.c +62 -0
  9. data/ext/gstreamer/misc.o +0 -0
  10. data/ext/gstreamer/rbgst-bin.c +466 -0
  11. data/ext/gstreamer/rbgst-bin.o +0 -0
  12. data/ext/gstreamer/rbgst-buffer.c +365 -0
  13. data/ext/gstreamer/rbgst-buffer.o +0 -0
  14. data/ext/gstreamer/rbgst-bus.c +92 -0
  15. data/ext/gstreamer/rbgst-bus.o +0 -0
  16. data/ext/gstreamer/rbgst-caps.c +441 -0
  17. data/ext/gstreamer/rbgst-caps.o +0 -0
  18. data/ext/gstreamer/rbgst-child-proxy.c +33 -0
  19. data/ext/gstreamer/rbgst-child-proxy.o +0 -0
  20. data/ext/gstreamer/rbgst-clock.c +108 -0
  21. data/ext/gstreamer/rbgst-clock.o +0 -0
  22. data/ext/gstreamer/rbgst-element-factory.c +255 -0
  23. data/ext/gstreamer/rbgst-element-factory.o +0 -0
  24. data/ext/gstreamer/rbgst-element.c +1053 -0
  25. data/ext/gstreamer/rbgst-element.o +0 -0
  26. data/ext/gstreamer/rbgst-event.c +351 -0
  27. data/ext/gstreamer/rbgst-event.o +0 -0
  28. data/ext/gstreamer/rbgst-ghost-pad.c +42 -0
  29. data/ext/gstreamer/rbgst-ghost-pad.o +0 -0
  30. data/ext/gstreamer/rbgst-index-factory.c +67 -0
  31. data/ext/gstreamer/rbgst-index-factory.o +0 -0
  32. data/ext/gstreamer/rbgst-message.c +784 -0
  33. data/ext/gstreamer/rbgst-message.o +0 -0
  34. data/ext/gstreamer/rbgst-mini-object.c +220 -0
  35. data/ext/gstreamer/rbgst-mini-object.o +0 -0
  36. data/ext/gstreamer/rbgst-object.c +81 -0
  37. data/ext/gstreamer/rbgst-object.o +0 -0
  38. data/ext/gstreamer/rbgst-pad-template.c +124 -0
  39. data/ext/gstreamer/rbgst-pad-template.o +0 -0
  40. data/ext/gstreamer/rbgst-pad.c +338 -0
  41. data/ext/gstreamer/rbgst-pad.o +0 -0
  42. data/ext/gstreamer/rbgst-pipeline.c +90 -0
  43. data/ext/gstreamer/rbgst-pipeline.o +0 -0
  44. data/ext/gstreamer/rbgst-plugin-feature.c +134 -0
  45. data/ext/gstreamer/rbgst-plugin-feature.o +0 -0
  46. data/ext/gstreamer/rbgst-plugin.c +164 -0
  47. data/ext/gstreamer/rbgst-plugin.o +0 -0
  48. data/ext/gstreamer/rbgst-private.c +89 -0
  49. data/ext/gstreamer/rbgst-private.h +37 -0
  50. data/ext/gstreamer/rbgst-private.o +0 -0
  51. data/ext/gstreamer/rbgst-query.c +289 -0
  52. data/ext/gstreamer/rbgst-query.o +0 -0
  53. data/ext/gstreamer/rbgst-seek.c +36 -0
  54. data/ext/gstreamer/rbgst-seek.o +0 -0
  55. data/ext/gstreamer/rbgst-static-caps.c +49 -0
  56. data/ext/gstreamer/rbgst-static-caps.o +0 -0
  57. data/ext/gstreamer/rbgst-static-pad-template.c +64 -0
  58. data/ext/gstreamer/rbgst-static-pad-template.o +0 -0
  59. data/ext/gstreamer/rbgst-structure.c +300 -0
  60. data/ext/gstreamer/rbgst-structure.o +0 -0
  61. data/ext/gstreamer/rbgst-system-clock.c +45 -0
  62. data/ext/gstreamer/rbgst-system-clock.o +0 -0
  63. data/ext/gstreamer/rbgst-type-find-factory.c +124 -0
  64. data/ext/gstreamer/rbgst-type-find-factory.o +0 -0
  65. data/ext/gstreamer/rbgst-value.c +517 -0
  66. data/ext/gstreamer/rbgst-value.o +0 -0
  67. data/ext/gstreamer/rbgst-x-overlay.c +132 -0
  68. data/ext/gstreamer/rbgst-x-overlay.o +0 -0
  69. data/ext/gstreamer/rbgst.c +279 -0
  70. data/ext/gstreamer/rbgst.h +197 -0
  71. data/ext/gstreamer/rbgst.o +0 -0
  72. data/ext/gstreamer/rbgstclockentry.c +268 -0
  73. data/ext/gstreamer/rbgstclockentry.o +0 -0
  74. data/ext/gstreamer/rbgstformat.c +159 -0
  75. data/ext/gstreamer/rbgstformat.o +0 -0
  76. data/ext/gstreamer/rbgstindex.c +314 -0
  77. data/ext/gstreamer/rbgstindex.o +0 -0
  78. data/ext/gstreamer/rbgstindexentry.c +96 -0
  79. data/ext/gstreamer/rbgstindexentry.o +0 -0
  80. data/ext/gstreamer/rbgstparse.c +66 -0
  81. data/ext/gstreamer/rbgstparse.o +0 -0
  82. data/ext/gstreamer/rbgstquerytype.c +159 -0
  83. data/ext/gstreamer/rbgstquerytype.o +0 -0
  84. data/ext/gstreamer/rbgstregistry.c +278 -0
  85. data/ext/gstreamer/rbgstregistry.o +0 -0
  86. data/ext/gstreamer/rbgsttag.c +111 -0
  87. data/ext/gstreamer/rbgsttag.o +0 -0
  88. data/ext/gstreamer/rbgsttagsetter.c +50 -0
  89. data/ext/gstreamer/rbgsttagsetter.o +0 -0
  90. data/ext/gstreamer/rbgstxml.c +189 -0
  91. data/ext/gstreamer/rbgstxml.o +0 -0
  92. data/ext/gstreamer/ruby-gstreamer.pc +3 -0
  93. data/extconf.rb +49 -0
  94. data/lib/gst.rb +19 -0
  95. data/sample/audio-player.rb +54 -0
  96. data/sample/gst-inspect.rb +417 -0
  97. data/sample/media-type.rb +55 -0
  98. data/sample/media-type2.rb +268 -0
  99. data/sample/ogg-audio-player.rb +54 -0
  100. data/sample/type-find.rb +46 -0
  101. data/sample/video-player.rb +57 -0
  102. data/sample/xml-player.rb +60 -0
  103. data/test/gst-test-utils.rb +18 -0
  104. data/test/run-test.rb +25 -0
  105. data/test/test_bin.rb +167 -0
  106. data/test/test_buffer.rb +174 -0
  107. data/test/test_caps.rb +24 -0
  108. data/test/test_clock.rb +7 -0
  109. data/test/test_element.rb +87 -0
  110. data/test/test_element_factory.rb +28 -0
  111. data/test/test_event.rb +10 -0
  112. data/test/test_index_factory.rb +7 -0
  113. data/test/test_message.rb +191 -0
  114. data/test/test_mini_object.rb +38 -0
  115. data/test/test_object.rb +10 -0
  116. data/test/test_pad.rb +68 -0
  117. data/test/test_plugin.rb +6 -0
  118. data/test/test_plugin_feature.rb +20 -0
  119. data/test/test_seek.rb +17 -0
  120. data/test/test_static_caps.rb +18 -0
  121. data/test/test_static_pad_template.rb +16 -0
  122. data/test/test_structure.rb +159 -0
  123. data/test/test_thread_handling.rb +58 -0
  124. data/test/test_type_find_factory.rb +8 -0
  125. data/test/test_value.rb +69 -0
  126. metadata +208 -0
Binary file
@@ -0,0 +1,268 @@
1
+ /*
2
+ * Copyright (C) 2003, 2004 Laurent Sansonetti <lrz@gnome.org>
3
+ *
4
+ * This file is part of Ruby/GStreamer.
5
+ *
6
+ * Ruby/GStreamer 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
+ * Ruby/GStreamer 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 Ruby/GStreamer; if not, write to the Free Software
18
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
+ */
20
+
21
+ #include "rbgst.h"
22
+
23
+ /* Class: Gst::ClockEntry
24
+ * A wrapper for GstClockID, used to create and start timers
25
+ * on Gst::Clock objects.
26
+ */
27
+
28
+ static GstClockEntry *
29
+ clock_entry_copy (const GstClockEntry * clock_entry)
30
+ {
31
+ GstClockEntry *new_clock_entry;
32
+
33
+ g_return_val_if_fail (clock_entry != NULL, NULL);
34
+ new_clock_entry = g_new (GstClockEntry, sizeof (GstClockEntry));
35
+ *new_clock_entry = *clock_entry;
36
+ return new_clock_entry;
37
+ }
38
+
39
+ GType
40
+ gst_clock_entry_get_type (void)
41
+ {
42
+ static GType our_type = 0;
43
+
44
+ if (our_type == 0) {
45
+ our_type = g_boxed_type_register_static ("GstClockID",
46
+ (GBoxedCopyFunc)
47
+ clock_entry_copy,
48
+ (GBoxedFreeFunc) g_free);
49
+ }
50
+ return our_type;
51
+ }
52
+
53
+ /*
54
+ * Class method: new(clock, time, interval=nil)
55
+ * clock: a Gst::Clock.
56
+ * time: a time period, in nanoseconds.
57
+ * interval: an interval period, in nanoseconds.
58
+ *
59
+ * Creates a new Gst::ClockEntry object based on the given Gst::Clock.
60
+ *
61
+ * Two types of Gst::ClockEntry objects can be created:
62
+ *
63
+ * * One-shot: if the interval is ommited or nil, the entry will trigger a single shot notification, at the requested time (in nanoseconds);
64
+ * * Periodic: if the interval is not nil, the timer entry will trigger a periodic notification, starting at time (in nanoseconds), and be fired with the given interval (also in nanoseconds).
65
+ *
66
+ * The timer will be issued after Gst::ClockEntry#wait or
67
+ * Gst::ClockEntry#wait_async.
68
+ *
69
+ * Returns: a new Gst::ClockEntry object.
70
+ */
71
+ static VALUE
72
+ rb_gst_clock_entry_new (int argc, VALUE * argv, VALUE self)
73
+ {
74
+ VALUE clock, time, interval;
75
+ GstClockID id;
76
+
77
+ rb_scan_args (argc, argv, "21", &clock, &time, &interval);
78
+
79
+ /*
80
+ * Single-shot
81
+ */
82
+ if (NIL_P (interval))
83
+ id = gst_clock_new_single_shot_id (RVAL2GST_CLOCK (clock), NUM2ULL (time));
84
+ /*
85
+ * Periodic
86
+ */
87
+ else
88
+ id = gst_clock_new_periodic_id (RVAL2GST_CLOCK (clock),
89
+ NUM2ULL (time), NUM2ULL (interval));
90
+
91
+ G_INITIALIZE (self, GST_CLOCK_ENTRY (id));
92
+ return Qnil;
93
+ }
94
+
95
+ /* Method: single_shot?
96
+ * Returns: true if the entry is single-shot, false otherwise.
97
+ */
98
+ static VALUE
99
+ rb_gst_clock_entry_is_single_shot (VALUE self)
100
+ {
101
+ return CBOOL2RVAL (GST_CLOCK_ENTRY_TYPE (RGST_CLOCK_ENTRY (self)) ==
102
+ GST_CLOCK_ENTRY_SINGLE);
103
+ }
104
+
105
+ /* Method: periodic?
106
+ * Returns: true if the entry is periodic, false otherwise.
107
+ */
108
+ static VALUE
109
+ rb_gst_clock_entry_is_periodic (VALUE self)
110
+ {
111
+ return CBOOL2RVAL (GST_CLOCK_ENTRY_TYPE (RGST_CLOCK_ENTRY (self)) ==
112
+ GST_CLOCK_ENTRY_PERIODIC);
113
+ }
114
+
115
+ /*
116
+ * Method: unschedule
117
+ *
118
+ * Cancels an outstanding async notification request.
119
+ *
120
+ * Returns: self.
121
+ */
122
+ static VALUE
123
+ rb_gst_clock_entry_unschedule (VALUE self)
124
+ {
125
+ gst_clock_id_unschedule (RGST_CLOCK_ENTRY (self));
126
+ return self;
127
+ }
128
+
129
+ /*
130
+ * Method: wait
131
+ *
132
+ * Performs a blocking wait on the entry.
133
+ *
134
+ * Returns: a return code (see Gst::Clock::Return).
135
+ */
136
+ static VALUE
137
+ rb_gst_clock_entry_wait (VALUE self)
138
+ {
139
+ return GENUM2RVAL (gst_clock_id_wait (RGST_CLOCK_ENTRY (self), NULL),
140
+ GST_TYPE_CLOCK_RETURN);
141
+ }
142
+
143
+ struct __callback {
144
+ GstClockID id;
145
+ VALUE callback;
146
+ };
147
+
148
+ static GSList *__callbacks = NULL;
149
+
150
+ static struct __callback *
151
+ __callback_get (GstClockID id)
152
+ {
153
+ GSList *i;
154
+
155
+ for (i = __callbacks; i != NULL; i = g_slist_next (i)) {
156
+ struct __callback *e = (struct __callback *)i->data;
157
+
158
+ if (e->id == id)
159
+ return e;
160
+ }
161
+ return NULL;
162
+ }
163
+
164
+ static gboolean
165
+ __callback_dispatcher (GstClock * clock, GstClockTime time, GstClockID id,
166
+ gpointer user_data)
167
+ {
168
+ struct __callback *e = __callback_get (id);
169
+
170
+ g_assert (e != NULL);
171
+ return RVAL2CBOOL (rb_funcall (e->callback,
172
+ rb_intern ("call"),
173
+ 3,
174
+ RGST_CLOCK_NEW (clock),
175
+ ULL2NUM (time), RGST_CLOCK_ENTRY_NEW (id)));
176
+ }
177
+
178
+ /*
179
+ * Method: wait_async { |clock, time, clock_entry| ... }
180
+ *
181
+ * Registers a block code, which will be called passing references
182
+ * to the Gst::Clock, the time (in nanoseconds) and the Gst::ClockEntry as
183
+ * parameters.
184
+ *
185
+ * Returns: a return code (see Gst::Clock::Return).
186
+ */
187
+ static VALUE
188
+ rb_gst_clock_entry_wait_async (VALUE self)
189
+ {
190
+ GstClockID id = (GstClockID) RGST_CLOCK_ENTRY (self);
191
+
192
+ if (__callback_get (id) != NULL)
193
+ rb_raise (rb_eRuntimeError,
194
+ "An asynch callback is already registred to this entry.");
195
+ else {
196
+ struct __callback *e = g_malloc (sizeof (struct __callback));
197
+
198
+ g_assert (e != NULL);
199
+ e->id = id;
200
+ e->callback = rb_block_proc ();
201
+ __callbacks = g_slist_append (__callbacks, e);
202
+ return GENUM2RVAL (INT2FIX (gst_clock_id_wait_async (id,
203
+ __callback_dispatcher,
204
+ NULL)),
205
+ GST_TYPE_CLOCK_RETURN);
206
+ }
207
+ return Qnil;
208
+ }
209
+
210
+ /* Method: time
211
+ * Returns: the requested time of the entry, in nanoseconds.
212
+ */
213
+ static VALUE
214
+ rb_gst_clock_entry_get_time (VALUE self)
215
+ {
216
+ return ULL2NUM (GST_CLOCK_ENTRY_TIME (RGST_CLOCK_ENTRY (self)));
217
+ }
218
+
219
+ /* Method: interval
220
+ * Returns: the interval of the entry (in nanoseconds), or 0
221
+ * if the entry is not periodic.
222
+ */
223
+ static VALUE
224
+ rb_gst_clock_entry_get_interval (VALUE self)
225
+ {
226
+ return ULL2NUM (GST_CLOCK_ENTRY_INTERVAL (RGST_CLOCK_ENTRY (self)));
227
+ }
228
+
229
+ /* Method: clock
230
+ * Returns: the owner clock of the entry, as a Gst::Clock object.
231
+ */
232
+ static VALUE
233
+ rb_gst_clock_entry_get_clock (VALUE self)
234
+ {
235
+ return RGST_CLOCK_NEW (GST_CLOCK_ENTRY_CLOCK (RGST_CLOCK_ENTRY (self)));
236
+ }
237
+
238
+ /* Method: status
239
+ * Returns: the status of the entry (see Gst::ClockEntry::Return).
240
+ */
241
+ static VALUE
242
+ rb_gst_clock_entry_get_status (VALUE self)
243
+ {
244
+ return GENUM2RVAL(GST_CLOCK_ENTRY_STATUS(RGST_CLOCK_ENTRY (self)),
245
+ GST_TYPE_CLOCK_RETURN);
246
+ }
247
+
248
+ void
249
+ Init_gst_clock_entry (void)
250
+ {
251
+ VALUE c = G_DEF_CLASS (GST_TYPE_CLOCK_ENTRY, "ClockEntry", mGst);
252
+
253
+ rb_define_method (c, "initialize", rb_gst_clock_entry_new, -1);
254
+ rb_define_method (c, "single_shot?", rb_gst_clock_entry_is_single_shot, 0);
255
+ rb_define_method (c, "periodic?", rb_gst_clock_entry_is_periodic, 0);
256
+ rb_define_method (c, "wait", rb_gst_clock_entry_wait, 0);
257
+ rb_define_method (c, "wait_async", rb_gst_clock_entry_wait_async, 0);
258
+ rb_define_method (c, "unschedule", rb_gst_clock_entry_unschedule, 0);
259
+ rb_define_method (c, "clock", rb_gst_clock_entry_get_clock, 0);
260
+ rb_define_method (c, "time", rb_gst_clock_entry_get_time, 0);
261
+ rb_define_method (c, "interval", rb_gst_clock_entry_get_interval, 0);
262
+ rb_define_method (c, "status", rb_gst_clock_entry_get_status, 0);
263
+
264
+ G_DEF_CLASS (GST_TYPE_CLOCK_ENTRY_TYPE, "Type", c);
265
+ G_DEF_CONSTANTS (c, GST_TYPE_CLOCK_ENTRY_TYPE, "GST_CLOCK_ENTRY_");
266
+ G_DEF_CLASS (GST_TYPE_CLOCK_RETURN, "Return", c);
267
+ G_DEF_CONSTANTS (c, GST_TYPE_CLOCK_RETURN, "GST_CLOCK_");
268
+ }
Binary file
@@ -0,0 +1,159 @@
1
+ /*
2
+ * Copyright (C) 2003, 2004 Laurent Sansonetti <lrz@gnome.org>
3
+ *
4
+ * This file is part of Ruby/GStreamer.
5
+ *
6
+ * Ruby/GStreamer 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
+ * Ruby/GStreamer 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 Ruby/GStreamer; if not, write to the Free Software
18
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
+ */
20
+
21
+ #include "rbgst.h"
22
+
23
+ /* Class: Gst::Format
24
+ * Dynamically register new formats.
25
+ */
26
+
27
+ static GstFormat *
28
+ format_copy (const GstFormat* format)
29
+ {
30
+ GstFormat *new_format;
31
+ g_return_val_if_fail (format != NULL, NULL);
32
+ new_format = g_new (GstFormat, sizeof (GstFormat));
33
+ *new_format = *format;
34
+ return new_format;
35
+ }
36
+
37
+ GType
38
+ gst_format_get_type2 (void)
39
+ {
40
+ static GType our_type = 0;
41
+ if (our_type == 0)
42
+ our_type = g_boxed_type_register_static ("GstFormatClass",
43
+ (GBoxedCopyFunc)format_copy,
44
+ (GBoxedFreeFunc)g_free);
45
+ return our_type;
46
+ }
47
+
48
+ /*
49
+ * Class method: find(nick)
50
+ * nick: the nick of an existing format.
51
+ *
52
+ * Returns: a reference to the Gst::Format object registered with the
53
+ * given nick, or nil if this query was not registered.
54
+ */
55
+ static VALUE
56
+ rb_gst_format_find (VALUE self, VALUE nick)
57
+ {
58
+ GstFormat format = gst_format_get_by_nick (RVAL2CSTR (nick));
59
+ return format != GST_FORMAT_UNDEFINED
60
+ ? RGST_FORMAT_NEW (&format)
61
+ : Qnil;
62
+ }
63
+
64
+ /*
65
+ * Class method: each { |format| ... }
66
+ *
67
+ * Calls the block for each registered format, passing a reference
68
+ * to the Gst::Format object as parameter.
69
+ *
70
+ * Returns: always nil.
71
+ */
72
+ static VALUE
73
+ rb_gst_format_each (VALUE self)
74
+ {
75
+ GstIterator *iter;
76
+ gpointer value;
77
+
78
+ iter = gst_format_iterate_definitions();
79
+ while (gst_iterator_next(iter, &value) == GST_ITERATOR_OK) {
80
+ GstFormatDefinition *def = (GstFormatDefinition *)value;
81
+ rb_yield(RGST_FORMAT_NEW(&(def->value)));
82
+ }
83
+ gst_iterator_free(iter);
84
+ return Qnil;
85
+ }
86
+
87
+ /* Method: type_id
88
+ * Returns: the type id of this format (see Gst::Format::Type).
89
+ */
90
+ static VALUE
91
+ rb_gst_format_get_type_id (VALUE self)
92
+ {
93
+ GstFormat *format = RGST_FORMAT (self);
94
+ return GENUM2RVAL (*format, GST_TYPE_FORMAT);
95
+ }
96
+
97
+ /* Method: nick
98
+ * Returns: the short nick of the format.
99
+ */
100
+ static VALUE
101
+ rb_gst_format_get_nick (VALUE self)
102
+ {
103
+ GstFormat *format = RGST_FORMAT (self);
104
+ return CSTR2RVAL (gst_format_get_details (*format)->nick);
105
+ }
106
+
107
+ /* Method: description
108
+ * Returns: a longer description of the format.
109
+ */
110
+ static VALUE
111
+ rb_gst_format_get_description (VALUE self)
112
+ {
113
+ GstFormat *format = RGST_FORMAT (self);
114
+ return CSTR2RVAL (gst_format_get_details (*format)->description);
115
+ }
116
+
117
+ /*
118
+ * Method: ==(format)
119
+ * format: a Gst::Format.
120
+ *
121
+ * Checks if two Gst::Format objects are registered under the
122
+ * same nick.
123
+ *
124
+ * Returns: true on success, false on failure.
125
+ */
126
+ static VALUE
127
+ rb_gst_format_is_equal (VALUE self, VALUE other_format)
128
+ {
129
+ GstFormat *f1, *f2;
130
+ gchar *n1, *n2;
131
+
132
+ if (NIL_P (other_format))
133
+ return Qfalse;
134
+
135
+ f1 = RGST_FORMAT (self);
136
+ f2 = RGST_FORMAT (other_format);
137
+
138
+ n1 = gst_format_get_details (*f1)->nick;
139
+ n2 = gst_format_get_details (*f2)->nick;
140
+
141
+ return CBOOL2RVAL (strcmp (n1, n2) == 0);
142
+ }
143
+
144
+ void
145
+ Init_gst_format (void)
146
+ {
147
+ VALUE c = G_DEF_CLASS (GST_TYPE_FORMAT2, "Format", mGst);
148
+
149
+ rb_define_singleton_method (c, "each", rb_gst_format_each, 0);
150
+ rb_define_singleton_method (c, "find", rb_gst_format_find, 1);
151
+
152
+ rb_define_method (c, "type_id", rb_gst_format_get_type_id, 0);
153
+ rb_define_method (c, "nick", rb_gst_format_get_nick, 0);
154
+ rb_define_method (c, "description", rb_gst_format_get_description, 0);
155
+ rb_define_method (c, "==", rb_gst_format_is_equal, 1);
156
+
157
+ G_DEF_CLASS (GST_TYPE_FORMAT, "Type", c);
158
+ G_DEF_CONSTANTS (c, GST_TYPE_FORMAT, "GST_FORMAT_");
159
+ }
Binary file
@@ -0,0 +1,314 @@
1
+ /*
2
+ * Copyright (C) 2003, 2004 Laurent Sansonetti <lrz@gnome.org>
3
+ *
4
+ * This file is part of Ruby/GStreamer.
5
+ *
6
+ * Ruby/GStreamer 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
+ * Ruby/GStreamer 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 Ruby/GStreamer; if not, write to the Free Software
18
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
+ */
20
+
21
+ #include "rbgst.h"
22
+
23
+ /* Class: Gst::Index
24
+ * Generates indexes on objects.
25
+ */
26
+
27
+ /* Class method: new
28
+ * Returns: a newly allocated Gst::Index object.
29
+ */
30
+ static VALUE
31
+ rb_gst_index_new (VALUE self)
32
+ {
33
+ GstIndex *index = gst_index_new ();
34
+
35
+ if (index != NULL)
36
+ RBGST_INITIALIZE (self, index);
37
+ return Qnil;
38
+ }
39
+
40
+ /* Method: readable?
41
+ * Returns: whether the index can be read.
42
+ */
43
+ static VALUE
44
+ rb_gst_index_is_readable (VALUE self)
45
+ {
46
+ return CBOOL2RVAL (GST_INDEX_IS_READABLE (RGST_INDEX (self)));
47
+ }
48
+
49
+ /* Method: writable?
50
+ * Returns: whether the index can be written.
51
+ */
52
+ static VALUE
53
+ rb_gst_index_is_writable (VALUE self)
54
+ {
55
+ return CBOOL2RVAL (GST_INDEX_IS_WRITABLE (RGST_INDEX (self)));
56
+ }
57
+
58
+ /*
59
+ * Method: commit(id)
60
+ * id: the writer that committed the index.
61
+ *
62
+ * Tells the index that the writer with the given ID is done with
63
+ * this index and is not going to write any more entries to it.
64
+ *
65
+ * Returns: self.
66
+ */
67
+ static VALUE
68
+ rb_gst_index_commit (VALUE self, VALUE id)
69
+ {
70
+ gst_index_commit (RGST_INDEX (self), FIX2INT (id));
71
+ return self;
72
+ }
73
+
74
+ /* Method: group
75
+ * Returns: the ID of the current group.
76
+ */
77
+ static VALUE
78
+ rb_gst_index_get_group (VALUE self)
79
+ {
80
+ return INT2FIX (gst_index_get_group (RGST_INDEX (self)));
81
+ }
82
+
83
+ /*
84
+ * Method: new_group
85
+ *
86
+ * Creates a new group for the given index. It will be set as the current
87
+ * group.
88
+ *
89
+ * Returns: the ID of the newly created group.
90
+ */
91
+ static VALUE
92
+ rb_gst_index_new_group (VALUE self)
93
+ {
94
+ return INT2FIX (gst_index_new_group (RGST_INDEX (self)));
95
+ }
96
+
97
+ /*
98
+ * Method: set_group(group)
99
+ * group: the number of the group to set.
100
+ *
101
+ * Sets the current group number to the given argument.
102
+ *
103
+ * Returns: true if the operation succeeded, false if the group did not exist.
104
+ */
105
+ static VALUE
106
+ rb_gst_index_set_group (VALUE self, VALUE group)
107
+ {
108
+ return
109
+ CBOOL2RVAL (gst_index_set_group (RGST_INDEX (self), FIX2INT (group)));
110
+ }
111
+
112
+ /* Method: certainty
113
+ * Returns: the certainty of the index (see Gst::Index::Certainty).
114
+ */
115
+ static VALUE
116
+ rb_gst_index_get_certainty (VALUE self)
117
+ {
118
+ return GENUM2RVAL (gst_index_get_certainty (RGST_INDEX (self)),
119
+ GST_TYPE_INDEX_CERTAINTY);
120
+ }
121
+
122
+ /*
123
+ * Method: set_certainty(certainty)
124
+ * certainty: the certainty to set (see Gst::Index::Certainty).
125
+ *
126
+ * Sets the certainty of the index.
127
+ *
128
+ * Returns: self.
129
+ */
130
+ static VALUE
131
+ rb_gst_index_set_certainty (VALUE self, VALUE certainty)
132
+ {
133
+ gst_index_set_certainty (RGST_INDEX (self),
134
+ RVAL2GENUM (certainty, GST_TYPE_INDEX_CERTAINTY));
135
+ return self;
136
+ }
137
+
138
+ #if 0
139
+ static gboolean
140
+ __filter (GstIndex * index, GstIndexEntry * entry)
141
+ {
142
+
143
+ }
144
+
145
+ static VALUE
146
+ rb_gst_index_set_filter (VALUE self)
147
+ {
148
+ /*
149
+ * TODO
150
+ */
151
+ return self;
152
+ }
153
+
154
+ static gboolean
155
+ __resolver (GstIndex * index, GstObject * writer, gchar ** writer_string,
156
+ gpointer user_data)
157
+ {
158
+ VALUE block = (VALUE) user_data;
159
+
160
+ return
161
+ RVAL2CBOOL (rb_funcall
162
+ (block, 2, RGST_INDEX_NEW (index),
163
+ RGST_OBJECT_NEW (writer)));
164
+ }
165
+
166
+ static VALUE
167
+ rb_gst_index_set_resolver (VALUE self)
168
+ {
169
+ gst_index_set_resolver (RGST_INDEX (self), __resolver,
170
+ (gpointer) rb_block_proc ());
171
+ return self;
172
+ }
173
+ #endif
174
+
175
+ /*
176
+ * Method: add(id, *args)
177
+ * id: the ID of the index writer.
178
+ * args: additional parameters, see below.
179
+ *
180
+ * Adds an entry into the index. The type of the entry depends of
181
+ * the number and kind of additional parameters.
182
+ *
183
+ * * For an ID type, args must be a String.
184
+ * * For a FORMAT type, args must be a Gst::Format.
185
+ * * For an ASSOCIATION type, args must contains an association flag (see Gst::Index::AssocFlags), a Gst::Format and a value for the format.
186
+ * * For an OBJECT type, well you must wait, because it is not yet implemented.
187
+ *
188
+ * Returns: a reference to the newly allocated entry in the index, as a Gst::EntryIndex object.
189
+ */
190
+ static VALUE
191
+ rb_gst_index_add (int argc, VALUE * argv, VALUE self)
192
+ {
193
+ GstIndexEntry *index_entry;
194
+ VALUE id;
195
+
196
+ if (argc == 2) {
197
+ VALUE var;
198
+
199
+ rb_scan_args (argc, argv, "2", &id, &var);
200
+
201
+ index_entry = CLASS2GTYPE (CLASS_OF (var)) == GST_TYPE_FORMAT2
202
+ ? gst_index_add_format (RGST_INDEX (self), FIX2INT (id),
203
+ *RGST_FORMAT (var))
204
+ : gst_index_add_id (RGST_INDEX (self), FIX2INT (id),
205
+ RVAL2CSTR (var));
206
+
207
+ } else {
208
+ VALUE flags, format, value;
209
+
210
+ rb_scan_args (argc, argv, "4", &id, &flags, &format, &value);
211
+
212
+ index_entry =
213
+ gst_index_add_association (RGST_INDEX (self), FIX2INT (id),
214
+ RVAL2GFLAGS (flags,
215
+ GST_TYPE_ASSOC_FLAGS),
216
+ *RGST_FORMAT (format), NUM2ULL (value));
217
+ }
218
+
219
+ return index_entry != NULL ? RGST_INDEX_ENTRY_NEW (index_entry)
220
+ : Qnil;
221
+ }
222
+
223
+ static gint
224
+ __compare (gconstpointer a, gconstpointer b, gpointer user_data)
225
+ {
226
+ VALUE block = (VALUE) user_data;
227
+
228
+ return
229
+ FIX2INT (rb_funcall
230
+ (block, rb_intern ("call"), 2, RGST_INDEX_ENTRY_NEW (a),
231
+ RGST_INDEX_ENTRY_NEW (b)));
232
+ }
233
+
234
+ /*
235
+ * Method: get_assoc_entry(id, method, flags, format, value) { ... }
236
+ * id: the ID of the index writer.
237
+ * method: the lookup method to use (see Gst::Index::LookupMethod).
238
+ * flags: flags for the entry (see Gst::Index::AssocFlags).
239
+ * format: a Gst::Format object.
240
+ * value: the value to find.
241
+ *
242
+ * Finds the given format/value in the index. If a block is given, it will be
243
+ * called as a compare function, passing references to 2 Gst::IndexEntry objects,
244
+ * and waiting for a boolean as the return value.
245
+ *
246
+ * Returns: the entry associated with the value (as a Gst::IndexEntry object), or nil
247
+ * if the value is not found.
248
+ */
249
+ static VALUE
250
+ rb_gst_index_get_assoc_entry (VALUE self, VALUE id, VALUE method, VALUE flags,
251
+ VALUE format, VALUE value)
252
+ {
253
+ GstIndexEntry *index_entry;
254
+
255
+ if (rb_block_given_p () == Qfalse)
256
+ index_entry =
257
+ gst_index_get_assoc_entry (RGST_INDEX (self), FIX2INT (id),
258
+ RVAL2GENUM (method,
259
+ GST_TYPE_INDEX_LOOKUP_METHOD),
260
+ RVAL2GFLAGS (flags,
261
+ GST_TYPE_ASSOC_FLAGS),
262
+ *RGST_FORMAT (format), NUM2ULL (value));
263
+ else
264
+ index_entry =
265
+ gst_index_get_assoc_entry_full (RGST_INDEX (self), FIX2INT (id),
266
+ RVAL2GENUM (method,
267
+ GST_TYPE_INDEX_LOOKUP_METHOD),
268
+ RVAL2GFLAGS (flags,
269
+ GST_TYPE_ASSOC_FLAGS),
270
+ *RGST_FORMAT (format),
271
+ NUM2ULL (value), __compare,
272
+ (gpointer) rb_block_proc ());
273
+
274
+ return index_entry != NULL ? RGST_INDEX_ENTRY_NEW (index_entry)
275
+ : Qnil;
276
+ }
277
+
278
+ void
279
+ Init_gst_index (void)
280
+ {
281
+ VALUE c = G_DEF_CLASS (GST_TYPE_INDEX, "Index", mGst);
282
+
283
+ rb_define_method (c, "initialize", rb_gst_index_new, 0);
284
+ rb_define_method (c, "readable?", rb_gst_index_is_readable, 0);
285
+ rb_define_method (c, "writable?", rb_gst_index_is_writable, 0);
286
+ rb_define_method (c, "commit", rb_gst_index_commit, 1);
287
+ rb_define_method (c, "group", rb_gst_index_get_group, 0);
288
+ rb_define_method (c, "new_group", rb_gst_index_new_group, 0);
289
+ rb_define_method (c, "set_group", rb_gst_index_set_group, 1);
290
+ rb_define_method (c, "certainty", rb_gst_index_get_certainty, 0);
291
+ rb_define_method (c, "set_certainty", rb_gst_index_set_certainty, 1);
292
+ #if 0
293
+ rb_define_method (c, "set_filter", rb_gst_index_set_filter, 0);
294
+ rb_define_method (c, "set_resolver", rb_gst_index_set_resolver, 0);
295
+ #endif
296
+ rb_define_method (c, "add", rb_gst_index_add, -1);
297
+ rb_define_method (c, "get_assoc_entry", rb_gst_index_get_assoc_entry, 5);
298
+
299
+ G_DEF_CLASS (GST_TYPE_INDEX_CERTAINTY, "Certainty", c);
300
+ G_DEF_CONSTANTS (c, GST_TYPE_INDEX_CERTAINTY, "GST_INDEX_");
301
+ G_DEF_CLASS (GST_TYPE_INDEX_LOOKUP_METHOD, "LookupMethod", c);
302
+ G_DEF_CONSTANTS (c, GST_TYPE_INDEX_LOOKUP_METHOD, "GST_INDEX_");
303
+ G_DEF_CLASS (GST_TYPE_ASSOC_FLAGS, "AssocFlags", c);
304
+ G_DEF_CONSTANTS (c, GST_TYPE_ASSOC_FLAGS, "GST_");
305
+ G_DEF_CLASS (GST_TYPE_INDEX_RESOLVER_METHOD, "ResolverMethod", c);
306
+ G_DEF_CONSTANTS (c, GST_TYPE_INDEX_RESOLVER_METHOD, "GST_INDEX_");
307
+ G_DEF_CLASS (GST_TYPE_INDEX_FLAGS, "Flags", c);
308
+ G_DEF_CONSTANTS (c, GST_TYPE_INDEX_FLAGS, "GST_INDEX_");
309
+
310
+ G_DEF_SETTERS (c);
311
+
312
+ rb_undef_method (c, "resolver");
313
+ rb_undef_method (c, "resolver=");
314
+ }