gstreamer 1.2.6 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. data/Rakefile +78 -39
  2. data/ext/gstreamer/extconf.rb +8 -22
  3. data/ext/gstreamer/rbgst.c +82 -194
  4. data/lib/gst/base_loader.rb +20 -0
  5. data/lib/gst/bin.rb +32 -0
  6. data/lib/gst/bus.rb +24 -0
  7. data/lib/gst/element.rb +48 -0
  8. data/lib/gst.rb +87 -22
  9. data/sample/helloworld.rb +75 -0
  10. data/sample/mp3parselaunch.rb +74 -0
  11. data/sample/queue.rb +92 -0
  12. data/sample/typefind.rb +101 -0
  13. metadata +29 -84
  14. data/README +0 -33
  15. data/ext/gstreamer/misc.c +0 -63
  16. data/ext/gstreamer/rbgst-bin.c +0 -456
  17. data/ext/gstreamer/rbgst-buffer.c +0 -363
  18. data/ext/gstreamer/rbgst-bus.c +0 -92
  19. data/ext/gstreamer/rbgst-caps.c +0 -446
  20. data/ext/gstreamer/rbgst-child-proxy.c +0 -34
  21. data/ext/gstreamer/rbgst-clock.c +0 -108
  22. data/ext/gstreamer/rbgst-element-factory.c +0 -249
  23. data/ext/gstreamer/rbgst-element.c +0 -1106
  24. data/ext/gstreamer/rbgst-event.c +0 -352
  25. data/ext/gstreamer/rbgst-ghost-pad.c +0 -45
  26. data/ext/gstreamer/rbgst-index-factory.c +0 -69
  27. data/ext/gstreamer/rbgst-install-plugins-context.c +0 -87
  28. data/ext/gstreamer/rbgst-install-plugins-return.c +0 -45
  29. data/ext/gstreamer/rbgst-install-plugins.c +0 -125
  30. data/ext/gstreamer/rbgst-message.c +0 -785
  31. data/ext/gstreamer/rbgst-mini-object.c +0 -221
  32. data/ext/gstreamer/rbgst-object.c +0 -81
  33. data/ext/gstreamer/rbgst-pad-template.c +0 -125
  34. data/ext/gstreamer/rbgst-pad.c +0 -336
  35. data/ext/gstreamer/rbgst-pipeline.c +0 -91
  36. data/ext/gstreamer/rbgst-plugin-feature.c +0 -131
  37. data/ext/gstreamer/rbgst-plugin.c +0 -162
  38. data/ext/gstreamer/rbgst-private.c +0 -88
  39. data/ext/gstreamer/rbgst-private.h +0 -97
  40. data/ext/gstreamer/rbgst-query.c +0 -291
  41. data/ext/gstreamer/rbgst-seek.c +0 -39
  42. data/ext/gstreamer/rbgst-static-caps.c +0 -49
  43. data/ext/gstreamer/rbgst-static-pad-template.c +0 -65
  44. data/ext/gstreamer/rbgst-structure.c +0 -300
  45. data/ext/gstreamer/rbgst-system-clock.c +0 -48
  46. data/ext/gstreamer/rbgst-type-find-factory.c +0 -125
  47. data/ext/gstreamer/rbgst-value.c +0 -527
  48. data/ext/gstreamer/rbgst-x-overlay.c +0 -131
  49. data/ext/gstreamer/rbgst.h +0 -197
  50. data/ext/gstreamer/rbgstclockentry.c +0 -271
  51. data/ext/gstreamer/rbgstformat.c +0 -162
  52. data/ext/gstreamer/rbgstindex.c +0 -315
  53. data/ext/gstreamer/rbgstindexentry.c +0 -99
  54. data/ext/gstreamer/rbgstparse.c +0 -69
  55. data/ext/gstreamer/rbgstquerytype.c +0 -162
  56. data/ext/gstreamer/rbgstregistry.c +0 -288
  57. data/ext/gstreamer/rbgsttag.c +0 -113
  58. data/ext/gstreamer/rbgsttagsetter.c +0 -53
  59. data/ext/gstreamer/rbgstxml.c +0 -192
  60. data/sample/audio-player.rb +0 -54
  61. data/sample/gst-gi.rb +0 -55
  62. data/sample/gst-inspect.rb +0 -417
  63. data/sample/install-plugins.rb +0 -40
  64. data/sample/media-type.rb +0 -55
  65. data/sample/media-type2.rb +0 -268
  66. data/sample/ogg-audio-player.rb +0 -54
  67. data/sample/type-find.rb +0 -46
  68. data/sample/video-player.rb +0 -57
  69. data/sample/xml-player.rb +0 -60
  70. data/test/gst-test-utils.rb +0 -18
  71. data/test/run-test.rb +0 -25
  72. data/test/test_bin.rb +0 -167
  73. data/test/test_buffer.rb +0 -185
  74. data/test/test_caps.rb +0 -24
  75. data/test/test_element.rb +0 -85
  76. data/test/test_element_factory.rb +0 -28
  77. data/test/test_event.rb +0 -10
  78. data/test/test_index_factory.rb +0 -7
  79. data/test/test_install-plugins.rb +0 -18
  80. data/test/test_message.rb +0 -191
  81. data/test/test_mini_object.rb +0 -38
  82. data/test/test_object.rb +0 -10
  83. data/test/test_pad.rb +0 -68
  84. data/test/test_plugin.rb +0 -6
  85. data/test/test_plugin_feature.rb +0 -20
  86. data/test/test_seek.rb +0 -17
  87. data/test/test_static_caps.rb +0 -18
  88. data/test/test_static_pad_template.rb +0 -16
  89. data/test/test_structure.rb +0 -159
  90. data/test/test_thread_handling.rb +0 -58
  91. data/test/test_type_find_factory.rb +0 -8
  92. data/test/test_value.rb +0 -69
@@ -1,288 +0,0 @@
1
- /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /*
3
- * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
- * Copyright (C) 2003, 2004 Laurent Sansonetti <lrz@gnome.org>
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 cRegistry
25
-
26
- /* Class: Gst::Registry
27
- * Abstract class for managing plugins.
28
- */
29
-
30
- static VALUE
31
- rg_s_default(G_GNUC_UNUSED VALUE self)
32
- {
33
- return RGST_REGISTRY_NEW(gst_registry_get_default());
34
- }
35
-
36
- static VALUE
37
- rg_s_update(G_GNUC_UNUSED VALUE self)
38
- {
39
- return CBOOL2RVAL(gst_update_registry());
40
- }
41
-
42
- /*
43
- * Method: plugins
44
- *
45
- * Gets a list of all plugins in the pool.
46
- *
47
- * Returns: an array of Gst::Plugin objects.
48
- */
49
- static VALUE
50
- rg_plugins(VALUE self)
51
- {
52
- GList *list, *node;
53
- VALUE arr;
54
-
55
- arr = rb_ary_new();
56
- list = gst_registry_get_plugin_list(RGST_REGISTRY(self));
57
- for (node = list;
58
- node != NULL;
59
- node = g_list_next(node)) {
60
- GstPlugin *plugin = (GstPlugin *)node->data;
61
- rb_ary_push(arr, RGST_PLUGIN_NEW(plugin));
62
- }
63
- g_list_free(list);
64
- return arr;
65
- }
66
-
67
- /*
68
- * Method: each_plugin { |plugin| ... }
69
- *
70
- * Calls the block for each plugin in the pool, passing a reference to
71
- * the Gst::Plugin as parameter.
72
- *
73
- * Returns: always nil.
74
- */
75
- static VALUE
76
- rg_each_plugin (VALUE self)
77
- {
78
- return rb_ary_yield (rg_plugins (self));
79
- }
80
-
81
- /*
82
- * Method: get_features(feature_type_or_plugin_name)
83
- * feature_type_or_plugin_name: a feature type or plugin name.
84
- *
85
- * Gets a list of all plugin features of the given type in the pool.
86
- *
87
- * Valid features types are Gst::AutoplugFactory, Gst::ElementFactory,
88
- * Gst::IndexFactory, Gst::SchedulerFactory and Gst::TypeFactory.
89
- *
90
- * Returns: an array of Gst::PluginFeature objects.
91
- */
92
- static VALUE
93
- rg_get_features(VALUE self, VALUE type_or_plugin_name)
94
- {
95
- GList *list, *node;
96
- GType gtype;
97
- VALUE arr;
98
-
99
- if (RVAL2CBOOL(rb_obj_is_kind_of(type_or_plugin_name, rb_cString))) {
100
- list = gst_registry_get_feature_list_by_plugin(RGST_REGISTRY(self),
101
- RVAL2CSTR(type_or_plugin_name));
102
- } else {
103
- gtype = CLASS2GTYPE(type_or_plugin_name);
104
- if (!is_valid_pluginfeature_type(gtype))
105
- rb_raise (rb_eArgError, "Invalid feature type.");
106
-
107
- list = gst_registry_get_feature_list(RGST_REGISTRY(self), gtype);
108
- }
109
-
110
- arr = rb_ary_new();
111
- for (node = list; node != NULL; node = g_list_next(node)) {
112
- rb_ary_push(arr, instanciate_pluginfeature(GST_PLUGIN_FEATURE(node->data)));
113
- }
114
- g_list_free (list);
115
-
116
- return arr;
117
- }
118
-
119
- /*
120
- * Method: each_feature(feature_type) { |plugin_feature| ... }
121
- *
122
- * Calls the block for each plugin features of the given type in the pool,
123
- * passing a reference to the Gst::PluginFeature as parameter.
124
- *
125
- * Valid features types are Gst::AutoplugFactory, Gst::ElementFactory,
126
- * Gst::IndexFactory, Gst::SchedulerFactory and Gst::TypeFactory.
127
- *
128
- * Returns: always nil.
129
- */
130
- static VALUE
131
- rg_each_feature (VALUE self, VALUE type)
132
- {
133
- return rb_ary_yield (rg_get_features (self, type));
134
- }
135
-
136
- /*
137
- * Method: paths
138
- *
139
- * Gets a list of paths of the registry.
140
- *
141
- * Returns: an array of strings.
142
- */
143
- static VALUE
144
- rg_paths (VALUE self)
145
- {
146
- GList *list;
147
- VALUE arr;
148
-
149
- arr = rb_ary_new ();
150
- for (list = gst_registry_get_path_list (RGST_REGISTRY (self));
151
- list != NULL;
152
- list = g_list_next (list))
153
- rb_ary_push (arr, CSTR2RVAL ((gchar *) list->data));
154
- g_list_free (list);
155
- return arr;
156
- }
157
-
158
- /*
159
- * Method: each_path { |path| ... }
160
- *
161
- * Calls the block for each path of the registry, passing a reference to
162
- * the path (a String object) as parameter.
163
- *
164
- * Returns: always nil.
165
- */
166
- static VALUE
167
- rg_each_path (VALUE self)
168
- {
169
- return rb_ary_yield (rg_paths (self));
170
- }
171
-
172
- /*
173
- * Method: add_path(path)
174
- * path: a path (a String object).
175
- *
176
- * Add the given path to the registry.
177
- * The syntax of the path is specific to the registry.
178
- * If the path has already been added, do nothing.
179
- *
180
- * Returns: nil.
181
- */
182
- static VALUE
183
- rg_add_path(VALUE self, VALUE path)
184
- {
185
- gst_registry_add_path(RGST_REGISTRY(self), RVAL2CSTR(path));
186
- return Qnil;
187
- }
188
-
189
- /*
190
- * Method: add_plugin(plugin)
191
- * plugin: a Gst::Plugin.
192
- *
193
- * Adds a plugin to the registry. The 'plugin-added' signal will be emitted.
194
- *
195
- * Returns: true on success, false otherwise.
196
- */
197
- static VALUE
198
- rg_add_plugin(VALUE self, VALUE plugin)
199
- {
200
- return CBOOL2RVAL(gst_registry_add_plugin(RGST_REGISTRY (self),
201
- RGST_PLUGIN (plugin)));
202
- }
203
-
204
- /*
205
- * Method: remove_plugin(plugin)
206
- * plugin: a Gst::Plugin.
207
- *
208
- * Removes a plugin from the registry.
209
- *
210
- * Returns: self.
211
- */
212
- static VALUE
213
- rg_remove_plugin (VALUE self, VALUE plugin)
214
- {
215
- gst_registry_remove_plugin (RGST_REGISTRY (self),
216
- RGST_PLUGIN (plugin));
217
- return self;
218
- }
219
-
220
- /*
221
- * Method: find_plugin(name)
222
- * name: a plugin name.
223
- *
224
- * Finds the plugin with the given name in the registry.
225
- *
226
- * Returns: a reference to a Gst::Plugin object if found,
227
- * otherwise returns nil.
228
- */
229
- static VALUE
230
- rg_find_plugin (VALUE self, VALUE name)
231
- {
232
- GstPlugin *plugin = gst_registry_find_plugin (RGST_REGISTRY (self),
233
- RVAL2CSTR (name));
234
- return plugin != NULL
235
- ? RGST_PLUGIN_NEW (plugin)
236
- : Qnil;
237
- }
238
-
239
- /*
240
- * Method: find_feature(feature_name, feature_type)
241
- * feature_name: a feature name.
242
- * feature_type: a feature type.
243
- *
244
- * Finds the plugin feature with the given name and type in the registry.
245
- *
246
- * Valid features types are Gst::AutoplugFactory, Gst::ElementFactory,
247
- * Gst::IndexFactory, Gst::SchedulerFactory and Gst::TypeFactory.
248
- *
249
- * Returns: a reference to a Gst::PluginFeature on success, or nil if the
250
- * named plugin feature is not found.
251
- */
252
- static VALUE
253
- rg_find_feature(VALUE self, VALUE name, VALUE type)
254
- {
255
- GstPluginFeature *feature;
256
- GType gtype;
257
-
258
- gtype = CLASS2GTYPE (type);
259
- if (!is_valid_pluginfeature_type (gtype))
260
- rb_raise (rb_eArgError, "Invalid feature type.");
261
- feature = gst_registry_find_feature (RGST_REGISTRY (self),
262
- RVAL2CSTR (name),
263
- gtype);
264
- return feature != NULL
265
- ? instanciate_pluginfeature (feature)
266
- : Qnil;
267
- }
268
-
269
- void
270
- Init_gst_registry (VALUE mGst)
271
- {
272
- VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS (GST_TYPE_REGISTRY, "Registry", mGst);
273
-
274
- RG_DEF_SMETHOD(default, 0);
275
- RG_DEF_SMETHOD(update, 0);
276
-
277
- RG_DEF_METHOD(plugins, 0);
278
- RG_DEF_METHOD(each_plugin, 0);
279
- RG_DEF_METHOD(get_features, 1);
280
- RG_DEF_METHOD(each_feature, 1);
281
- RG_DEF_METHOD(paths, 0);
282
- RG_DEF_METHOD(each_path, 0);
283
- RG_DEF_METHOD(add_path, 1);
284
- RG_DEF_METHOD(add_plugin, 1);
285
- RG_DEF_METHOD(remove_plugin, 1);
286
- RG_DEF_METHOD(find_plugin, 1);
287
- RG_DEF_METHOD(find_feature, 2);
288
- }
@@ -1,113 +0,0 @@
1
- /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /*
3
- * Copyright (C) 2011-2012 Ruby-GNOME2 Project Team
4
- * Copyright (C) 2003-2005 Laurent Sansonetti <lrz@gnome.org>
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 mTag
25
-
26
- /* Module: Gst::Tag
27
- * Helper module to the tagging interface.
28
- */
29
-
30
- /*
31
- * Class method: exists?(tag)
32
- * tag: the name of the tag.
33
- *
34
- * Checks if the given tag is already registered.
35
- *
36
- * Returns: true if the tag is registered, false otherwise.
37
- */
38
- static VALUE
39
- rg_s_exists_p (G_GNUC_UNUSED VALUE self, VALUE tag)
40
- {
41
- return CBOOL2RVAL (gst_tag_exists (RVAL2CSTR (tag)));
42
- }
43
-
44
- /*
45
- * Class method: fixed?(tag)
46
- * tag: the name of the tag.
47
- *
48
- * Checks if the given tag is fixed. A fixed tag can only contain one value.
49
- * Unfixed tags can contain lists of values.
50
- *
51
- * Returns: true if the tag is fixed, false otherwise.
52
- */
53
- static VALUE
54
- rg_s_fixed_p (G_GNUC_UNUSED VALUE self, VALUE tag)
55
- {
56
- return CBOOL2RVAL (gst_tag_is_fixed (RVAL2CSTR (tag)));
57
- }
58
-
59
- /*
60
- * Class method: get_nick(tag)
61
- * tag: the name of the tag.
62
- *
63
- * Returns: the human-readable name of this tag.
64
- */
65
- static VALUE
66
- rg_s_get_nick (G_GNUC_UNUSED VALUE self, VALUE tag)
67
- {
68
- return CSTR2RVAL (gst_tag_get_nick (RVAL2CSTR (tag)));
69
- }
70
-
71
- /*
72
- * Class method: get_description(tag)
73
- * tag: the name of the tag.
74
- *
75
- * Returns: the human-readable description of this tag.
76
- */
77
- static VALUE
78
- rg_s_get_description (G_GNUC_UNUSED VALUE self, VALUE tag)
79
- {
80
- return CSTR2RVAL (gst_tag_get_description (RVAL2CSTR (tag)));
81
- }
82
-
83
- /*
84
- * Class method: get_flag(tag)
85
- * tag: the name of the tag.
86
- *
87
- * Gets the flag of the given tag.
88
- *
89
- * Returns: the flag of this tag (see Gst::Tag::Flag).
90
- */
91
- static VALUE
92
- rg_s_get_flag (G_GNUC_UNUSED VALUE self, VALUE tag)
93
- {
94
- return GFLAGS2RVAL (gst_tag_get_flag (RVAL2CSTR (tag)),
95
- GST_TYPE_TAG_FLAG);
96
- }
97
-
98
- void
99
- Init_gst_tag (VALUE mGst)
100
- {
101
- VALUE RG_TARGET_NAMESPACE = rb_define_module_under (mGst, "Tag");
102
-
103
- RG_DEF_SMETHOD_P(exists, 1);
104
- RG_DEF_SMETHOD(get_nick, 1);
105
- RG_DEF_SMETHOD(get_description, 1);
106
- RG_DEF_SMETHOD(get_flag, 1);
107
- RG_DEF_SMETHOD_P(fixed, 1);
108
-
109
- G_DEF_CLASS (GST_TYPE_TAG_FLAG, "Flag", RG_TARGET_NAMESPACE);
110
- G_DEF_CONSTANTS (RG_TARGET_NAMESPACE, GST_TYPE_TAG_FLAG, "GST_TAG_");
111
- G_DEF_CLASS (GST_TYPE_TAG_MERGE_MODE, "MergeMode", RG_TARGET_NAMESPACE);
112
- G_DEF_CONSTANTS (RG_TARGET_NAMESPACE, GST_TYPE_TAG_MERGE_MODE, "GST_TAG_");
113
- }
@@ -1,53 +0,0 @@
1
- /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /*
3
- * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
- * Copyright (C) 2003-2005 Laurent Sansonetti <lrz@gnome.org>
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 mTagSetter
25
-
26
- /* Class: Gst::TagSetter
27
- * Element interface that allows the setting and retrieval of media metadata.
28
- */
29
-
30
- /*
31
- * Method: merge(structure, merge_mode)
32
- * structure: a Ruby hash representing the tag list of merge from.
33
- * merge_mode: the mode to merge with (see Gst::Tag::MergeMode).
34
- *
35
- * Merges the given tag list in the setter's list using the given mode.
36
- *
37
- * Returns: self.
38
- */
39
- static VALUE
40
- rg_merge (VALUE self, VALUE structure, VALUE merge_mode)
41
- {
42
- gst_tag_setter_merge_tags(RGST_TAG_SETTER(self),
43
- RVAL2GST_STRUCT(structure),
44
- RVAL2GENUM(merge_mode, GST_TYPE_TAG_MERGE_MODE));
45
- return self;
46
- }
47
-
48
- void
49
- Init_gst_tag_setter (VALUE mGst)
50
- {
51
- VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE (GST_TYPE_TAG_SETTER, "TagSetter", mGst);
52
- RG_DEF_METHOD(merge, 2);
53
- }
@@ -1,192 +0,0 @@
1
- /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /*
3
- * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
- * Copyright (C) 2003, 2004 Laurent Sansonetti <lrz@gnome.org>
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 cXML
25
-
26
- /* Class: Gst::XML
27
- * Convert Gst::Element objects into an XML presentation.
28
- */
29
-
30
- /*
31
- * Class method: new
32
- *
33
- * Creates a new Gst::XML parser object.
34
- *
35
- * Returns: a newly created Gst::XML object.
36
- */
37
- static VALUE
38
- rg_initialize (VALUE self)
39
- {
40
- GstXML *xml = gst_xml_new ();
41
- if (xml != NULL)
42
- G_INITIALIZE (self, xml);
43
- return Qnil;
44
- }
45
-
46
- /*
47
- * Class method: write_file(element, filename)
48
- * element: a Gst::Element.
49
- * filename: a file name.
50
- *
51
- * Converts the given element into XML and writes the formatted XML
52
- * to the specified file name.
53
- *
54
- * Returns: true on success, false on failure.
55
- */
56
- static VALUE
57
- rg_s_write_file (G_GNUC_UNUSED VALUE self, VALUE element, VALUE filename)
58
- {
59
- FILE *file = fopen (RVAL2CSTR (filename), "w");
60
- gboolean ret = FALSE;
61
- if (file != NULL) {
62
- ret = gst_xml_write_file (RGST_ELEMENT (element), file) != -1;
63
- fclose (file);
64
- }
65
- return CBOOL2RVAL (ret);
66
- }
67
-
68
- /*
69
- * Method: parse_file(filename, rootname=nil)
70
- * filename: a file name.
71
- * rootname: a root name (optional).
72
- *
73
- * Fills the Gst::XML object with the corresponding elements from
74
- * the XML file name. Optionally it will only build the element
75
- * from the element node root (if it is not nil).
76
- *
77
- * This feature is useful if you only want to build a specific
78
- * element from an XML file but not the pipeline it is embedded in.
79
- *
80
- * Pass "-" as file name to read from stdin. You can also pass a
81
- * URI of any format that libxml supports, including http.
82
- *
83
- * Returns: true on success, false on failure.
84
- */
85
- static VALUE
86
- rg_parse_file (int argc, VALUE *argv, VALUE self)
87
- {
88
- VALUE fname, rootname;
89
- rb_scan_args (argc, argv, "11", &fname, &rootname);
90
- return CBOOL2RVAL (gst_xml_parse_file (RGST_XML (self),
91
- (const guchar*) RVAL2CSTR (fname),
92
- (const guchar*)(NIL_P (rootname)
93
- ? NULL
94
- : RVAL2CSTR (rootname))));
95
- }
96
-
97
- /*
98
- * Method: parse_memory(string, rootname=nil)
99
- * string: an XML description inside a string.
100
- * rootname: a root name (optional).
101
- *
102
- * Basically the same as Gst::XML#parse_file except that this method will
103
- * take the XML directly from the memory.
104
- *
105
- * Returns: true on success, false on failure.
106
- */
107
- static VALUE
108
- rg_parse_memory (int argc, VALUE *argv, VALUE self)
109
- {
110
- VALUE memory, rootname;
111
- gchar *cstr;
112
-
113
- rb_scan_args (argc, argv, "11", &memory, &rootname);
114
- cstr = RVAL2CSTR (memory);
115
- return CBOOL2RVAL (gst_xml_parse_memory (RGST_XML (self),
116
- (guchar*)cstr,
117
- strlen (cstr),
118
- (const gchar*)(NIL_P (rootname)
119
- ? NULL
120
- : RVAL2CSTR (rootname))));
121
- }
122
-
123
- /*
124
- * Method: get_element(element_name)
125
- * element_name: the name of an element.
126
- *
127
- * This method is used to get a reference to the Gst::Element
128
- * corresponding to name in the pipeline description. You would use
129
- * this if you have to do anything to the element after loading.
130
- *
131
- * Returns: a reference to a Gst::Element object if found, otherwise
132
- * returns nil.
133
- */
134
- static VALUE
135
- rg_get_element (VALUE self, VALUE element_name)
136
- {
137
- GstElement *element = gst_xml_get_element (RGST_XML (self),
138
- (const guchar*)RVAL2CSTR (element_name));
139
- return element != NULL
140
- ? RGST_ELEMENT_NEW (element)
141
- : Qnil;
142
- }
143
-
144
- /*
145
- * Method: topelements
146
- *
147
- * Retrieves a list of all toplevel elements.
148
- *
149
- * Returns: an array of Gst::Element objects.
150
- */
151
- static VALUE
152
- rg_topelements (VALUE self)
153
- {
154
- GList *list;
155
- VALUE arr;
156
-
157
- arr = rb_ary_new ();
158
- for (list = gst_xml_get_topelements (RGST_XML (self));
159
- list != NULL;
160
- list = g_list_next (list))
161
- rb_ary_push (arr, RGST_ELEMENT_NEW (list->data));
162
- return arr;
163
- }
164
-
165
- /*
166
- * Method: each_topelement { |element| ... }
167
- *
168
- * Calls the block for each topelement, passing a reference to
169
- * a Gst::Element object as parameter.
170
- *
171
- * Returns: always nil.
172
- */
173
- static VALUE
174
- rg_each_topelement (VALUE self)
175
- {
176
- return rb_ary_yield (rg_topelements (self));
177
- }
178
-
179
- void
180
- Init_gst_xml (VALUE mGst)
181
- {
182
- VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS (GST_TYPE_XML, "XML", mGst);
183
-
184
- RG_DEF_SMETHOD(write_file, 2);
185
-
186
- RG_DEF_METHOD(initialize, 0);
187
- RG_DEF_METHOD(parse_file, -1);
188
- RG_DEF_METHOD(parse_memory, -1);
189
- RG_DEF_METHOD(get_element, 1);
190
- RG_DEF_METHOD(topelements, 0);
191
- RG_DEF_METHOD(each_topelement, 0);
192
- }
@@ -1,54 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'gst'
4
-
5
- if ARGV.size != 1
6
- puts "Usage: #{$0} audio-file"
7
- exit
8
- end
9
-
10
- file = ARGV.first
11
-
12
- pipeline = Gst::Pipeline.new
13
-
14
- file_src = Gst::ElementFactory.make("filesrc")
15
- file_src.location = file
16
-
17
- decoder = Gst::ElementFactory.make("decodebin")
18
-
19
- audio_convert = Gst::ElementFactory.make("audioconvert")
20
-
21
- audio_resample = Gst::ElementFactory.make("audioresample")
22
-
23
- audio_sink = Gst::ElementFactory.make("autoaudiosink")
24
-
25
- pipeline.add(file_src, decoder, audio_convert, audio_resample, audio_sink)
26
- file_src >> decoder
27
- audio_convert >> audio_resample >> audio_sink
28
-
29
- decoder.signal_connect("new-decoded-pad") do |element, pad|
30
- sink_pad = audio_convert["sink"]
31
- pad.link(sink_pad)
32
- end
33
-
34
- loop = GLib::MainLoop.new(nil, false)
35
-
36
- bus = pipeline.bus
37
- bus.add_watch do |bus, message|
38
- case message.type
39
- when Gst::Message::EOS
40
- loop.quit
41
- when Gst::Message::ERROR
42
- p message.parse
43
- loop.quit
44
- end
45
- true
46
- end
47
-
48
- pipeline.play
49
- begin
50
- loop.run
51
- rescue Interrupt
52
- ensure
53
- pipeline.stop
54
- end