gstreamer 0.90.6

Sign up to get free protection for your applications and to get access to all the features.
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,90 @@
1
+
2
+ /*
3
+ * Copyright (C) 2008 Sjoerd Simons <sjoerd@luon.net>
4
+ * Copyright (C) 2003, 2004 Laurent Sansonetti <lrz@gnome.org>
5
+ *
6
+ * This file is part of Ruby/GStreamer.
7
+ *
8
+ * Ruby/GStreamer 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
+ * Ruby/GStreamer 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 Ruby/GStreamer; if not, write to the Free Software
20
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
+ */
22
+
23
+ #include "rbgst.h"
24
+
25
+ #define SELF(obj) (RVAL2GST_PIPELINE(obj))
26
+
27
+ /* Class: Gst::Pipeline
28
+ * In almost all cases, you'll want to use a Gst::Pipeline when creating a
29
+ * filter graph. The Gst::Pipeline will manage all the scheduling issues,
30
+ * including threading, as well as provide simple interfaces to common
31
+ * functions, like 'Play'.
32
+ */
33
+
34
+ /*
35
+ * Class method: new(name=nil)
36
+ * name: a name for the pipeline.
37
+ *
38
+ * Constructs a new Gst::Pipeline object.
39
+ *
40
+ * If element name is ommited (or nil), then the pipeline will receive a guaranteed
41
+ * unique name, consisting of the "pipeline" string and a number.
42
+ * If name is given, it will be given the name supplied.
43
+ *
44
+ * Returns: a newly constructed Gst::Pipeline.
45
+ */
46
+ static VALUE
47
+ rb_gst_pipeline_new (int argc, VALUE *argv, VALUE self)
48
+ {
49
+ GstElement *bin;
50
+ VALUE name;
51
+
52
+ rb_scan_args (argc, argv, "01", &name);
53
+
54
+ bin = gst_pipeline_new (NIL_P (name) ? NULL : RVAL2CSTR(name));
55
+ if (bin != NULL)
56
+ RBGST_INITIALIZE (self, bin);
57
+ return Qnil;
58
+ }
59
+
60
+ static VALUE
61
+ rb_gst_pipeline_get_bus(VALUE self)
62
+ {
63
+ GstBus *bus;
64
+ VALUE ret;
65
+
66
+ bus = gst_pipeline_get_bus(SELF(self));
67
+ if (bus == NULL)
68
+ return Qnil;
69
+
70
+ ret = GST_BUS2RVAL_UNREF(bus);
71
+
72
+ /* Make the bus a child of the pipeline as their (minimum) livetimes are
73
+ * bound together.. A pipeline can potentially change it's bus though, but
74
+ * we have no way to catch that case */
75
+ G_CHILD_ADD(self, ret);
76
+
77
+ return ret;
78
+ }
79
+
80
+ void
81
+ Init_gst_pipeline(void)
82
+ {
83
+ VALUE cPipeline;
84
+
85
+ cPipeline = G_DEF_CLASS(GST_TYPE_PIPELINE, "Pipeline", mGst);
86
+
87
+ rb_define_method(cPipeline, "initialize", rb_gst_pipeline_new, -1);
88
+
89
+ rb_define_method(cPipeline, "bus", rb_gst_pipeline_get_bus, 0);
90
+ }
Binary file
@@ -0,0 +1,134 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2003, 2004 Laurent Sansonetti <lrz@gnome.org>
4
+ * Copyright (C) 2007 Ruby-GNOME2 Project Team
5
+ *
6
+ * This file is part of Ruby/GStreamer.
7
+ *
8
+ * Ruby/GStreamer 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
+ * Ruby/GStreamer 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 Ruby/GStreamer; if not, write to the Free Software
20
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
+ */
22
+
23
+ #include "rbgst.h"
24
+
25
+ #define SELF(self) RVAL2GST_PLUGIN_FEATURE(self)
26
+
27
+ #define RVAL2GST_RANK(rank) RVAL2GENUM(rank, GST_TYPE_RANK)
28
+ #define GST_RANK2RVAL(rank) GENUM2RVAL(rank, GST_TYPE_RANK)
29
+
30
+ /* Class: Gst::PluginFeature
31
+ * This is a base class for anything that can be added to a Gst::Plugin.
32
+ */
33
+
34
+ /* Method: name
35
+ * Returns: the name of the feature.
36
+ */
37
+ static VALUE
38
+ rb_gst_pluginfeature_get_name (VALUE self)
39
+ {
40
+ GstPluginFeature *feature = RGST_PLUGIN_FEATURE (self);
41
+ return CSTR2RVAL (GST_PLUGIN_FEATURE_NAME (feature));
42
+ }
43
+
44
+ gboolean
45
+ is_valid_pluginfeature_type (const GType type)
46
+ {
47
+ return type == GST_TYPE_ELEMENT_FACTORY ||
48
+ type == GST_TYPE_INDEX_FACTORY;
49
+ }
50
+
51
+ VALUE
52
+ instanciate_pluginfeature (GstPluginFeature *feature)
53
+ {
54
+
55
+ if (GST_IS_ELEMENT_FACTORY (feature))
56
+ return RGST_ELEMENT_FACTORY_NEW (feature);
57
+ else if (GST_IS_INDEX_FACTORY (feature))
58
+ return RGST_INDEX_FACTORY_NEW (feature);
59
+ else if (GST_IS_TYPE_FIND_FACTORY (feature))
60
+ return RGST_TYPE_FIND_FACTORY_NEW (feature);
61
+ else
62
+ rb_raise(rb_eArgError,
63
+ "Invalid plugin feature of type ``%s''",
64
+ g_type_name (G_OBJECT_TYPE (feature)));
65
+ return Qnil;
66
+ }
67
+
68
+ static VALUE
69
+ load_bang(VALUE self)
70
+ {
71
+ GstPluginFeature *original, *feature;
72
+
73
+ original = SELF(self);
74
+ feature = gst_plugin_feature_load(original);
75
+ if (feature) {
76
+ if (feature != original)
77
+ G_INITIALIZE(self, feature);
78
+ gst_object_unref(original);
79
+ return Qtrue;
80
+ } else {
81
+ return Qfalse;
82
+ }
83
+ }
84
+
85
+ static VALUE
86
+ loaded_p(VALUE self)
87
+ {
88
+ return CBOOL2RVAL(SELF(self)->loaded);
89
+ }
90
+
91
+ static VALUE
92
+ get_rank(VALUE self)
93
+ {
94
+ return GST_RANK2RVAL(gst_plugin_feature_get_rank(SELF(self)));
95
+ }
96
+
97
+ static VALUE
98
+ set_rank(VALUE self, VALUE rank)
99
+ {
100
+ gst_plugin_feature_set_rank(SELF(self), RVAL2GST_RANK(rank));
101
+ return Qnil;
102
+ }
103
+
104
+ static VALUE
105
+ get_plugin_name(VALUE self)
106
+ {
107
+ return CSTR2RVAL(SELF(self)->plugin_name);
108
+ }
109
+
110
+
111
+ void
112
+ Init_gst_plugin_feature (void)
113
+ {
114
+ VALUE rb_cGstPluginFeature;
115
+
116
+ rb_cGstPluginFeature = G_DEF_CLASS(GST_TYPE_PLUGIN_FEATURE,
117
+ "PluginFeature", mGst);
118
+
119
+ G_DEF_CLASS(GST_TYPE_RANK, "Rank", mGst);
120
+ G_DEF_CONSTANTS(mGst, GST_TYPE_RANK, "GST_");
121
+
122
+ rb_define_method(rb_cGstPluginFeature, "name",
123
+ rb_gst_pluginfeature_get_name, 0);
124
+
125
+ rb_define_method(rb_cGstPluginFeature, "load!", load_bang, 0);
126
+ rb_define_method(rb_cGstPluginFeature, "loaded?", loaded_p, 0);
127
+
128
+ rb_define_method(rb_cGstPluginFeature, "rank", get_rank, 0);
129
+ rb_define_method(rb_cGstPluginFeature, "set_rank", set_rank, 1);
130
+
131
+ rb_define_method(rb_cGstPluginFeature, "plugin_name", get_plugin_name, 0);
132
+
133
+ G_DEF_SETTERS(rb_cGstPluginFeature);
134
+ }
@@ -0,0 +1,164 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2003, 2004 Laurent Sansonetti <lrz@gnome.org>
4
+ * Copyright (C) 2007 Ruby-GNOME2 Project Team
5
+ *
6
+ * This file is part of Ruby/GStreamer.
7
+ *
8
+ * Ruby/GStreamer 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
+ * Ruby/GStreamer 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 Ruby/GStreamer; if not, write to the Free Software
20
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
+ */
22
+
23
+ #include "rbgst.h"
24
+
25
+ #define SELF(self) RVAL2GST_PLUGIN(self)
26
+
27
+ /* Class: Gst::Plugin
28
+ * Dynamically loadable Elements
29
+ */
30
+
31
+ /* Method: loaded?
32
+ * Returns: true if the plugin is loaded into memory, false otherwise.
33
+ */
34
+ static VALUE
35
+ rb_gst_plugin_is_loaded (VALUE self)
36
+ {
37
+ GstPlugin *plugin = RGST_PLUGIN (self);
38
+ return CBOOL2RVAL (gst_plugin_is_loaded (plugin));
39
+ }
40
+
41
+ /* Method: filename
42
+ * Returns: the filename where this plugin comes from.
43
+ */
44
+ static VALUE
45
+ rb_gst_plugin_get_filename (VALUE self)
46
+ {
47
+ return CSTR2RVAL (gst_plugin_get_filename (RGST_PLUGIN (self)));
48
+ }
49
+
50
+ /* Method: description
51
+ * Returns: a long description of the plugin.
52
+ */
53
+ static VALUE
54
+ rb_gst_plugin_get_description (VALUE self)
55
+ {
56
+ return CSTR2RVAL (gst_plugin_get_description (RGST_PLUGIN (self)));
57
+ }
58
+
59
+ /* Method: package
60
+ * Returns: the name of the package this plugin belongs to.
61
+ */
62
+ static VALUE
63
+ rb_gst_plugin_get_package (VALUE self)
64
+ {
65
+ return CSTR2RVAL (gst_plugin_get_package (RGST_PLUGIN (self)));
66
+ }
67
+
68
+ /* Method: license
69
+ * Returns: the effective license of the plugin.
70
+ */
71
+ static VALUE
72
+ rb_gst_plugin_get_license (VALUE self)
73
+ {
74
+ return CSTR2RVAL (gst_plugin_get_license (RGST_PLUGIN (self)));
75
+ }
76
+
77
+ static VALUE
78
+ get_source (VALUE self)
79
+ {
80
+ return CSTR2RVAL(gst_plugin_get_source(SELF(self)));
81
+ }
82
+
83
+ /* Method: origin
84
+ * Returns: the URL to the provider of the plugin.
85
+ */
86
+ static VALUE
87
+ rb_gst_plugin_get_origin (VALUE self)
88
+ {
89
+ return CSTR2RVAL (gst_plugin_get_origin ( RGST_PLUGIN (self)));
90
+ }
91
+
92
+ /* Method: name
93
+ * Returns: the unique name of the plugin.
94
+ */
95
+ static VALUE
96
+ rb_gst_plugin_get_name (VALUE self)
97
+ {
98
+ return CSTR2RVAL (gst_plugin_get_name (RGST_PLUGIN (self)));
99
+ }
100
+
101
+ /* Method: minor_version
102
+ * Returns: the minor version of the core this plugin was compiled for.
103
+ */
104
+ static VALUE
105
+ rb_gst_plugin_get_minor_version (VALUE self)
106
+ {
107
+ return INT2FIX (RGST_PLUGIN (self)->desc.minor_version);
108
+ }
109
+
110
+ /* Method: major_version
111
+ * Returns: the major version of the core this plugin was compiled for.
112
+ */
113
+ static VALUE
114
+ rb_gst_plugin_get_major_version (VALUE self)
115
+ {
116
+ return INT2FIX (RGST_PLUGIN (self)->desc.major_version);
117
+ }
118
+
119
+ /* Method: version
120
+ * Returns: the version of the plugin (note: as a string).
121
+ */
122
+ static VALUE
123
+ rb_gst_plugin_get_version (VALUE self)
124
+ {
125
+ return CSTR2RVAL (RGST_PLUGIN (self)->desc.version);
126
+ }
127
+
128
+ /* Method: ==(plugin)
129
+ * Returns: true if two Gst::Plugin objects are refered by the same file,
130
+ * false otherwise.
131
+ */
132
+ static VALUE
133
+ rb_gst_plugin_is_equal (VALUE self, VALUE other_plugin)
134
+ {
135
+ return NIL_P (other_plugin)
136
+ ? Qfalse
137
+ : rb_equal (rb_gst_plugin_get_filename (self),
138
+ rb_gst_plugin_get_filename (other_plugin));
139
+ }
140
+
141
+ void
142
+ Init_gst_plugin (void)
143
+ {
144
+ VALUE rb_cGstPlugin;
145
+
146
+ rb_cGstPlugin = G_DEF_CLASS(GST_TYPE_PLUGIN, "Plugin", mGst);
147
+
148
+ rb_define_method(rb_cGstPlugin, "loaded?", rb_gst_plugin_is_loaded, 0);
149
+ rb_define_method(rb_cGstPlugin, "==", rb_gst_plugin_is_equal, 1);
150
+
151
+ rb_define_method(rb_cGstPlugin, "filename", rb_gst_plugin_get_filename, 0);
152
+ rb_define_method(rb_cGstPlugin, "major_version",
153
+ rb_gst_plugin_get_major_version, 0);
154
+ rb_define_method(rb_cGstPlugin, "minor_version",
155
+ rb_gst_plugin_get_minor_version, 0);
156
+ rb_define_method(rb_cGstPlugin, "name", rb_gst_plugin_get_name, 0);
157
+ rb_define_method(rb_cGstPlugin, "description",
158
+ rb_gst_plugin_get_description, 0);
159
+ rb_define_method(rb_cGstPlugin, "version", rb_gst_plugin_get_version, 0);
160
+ rb_define_method(rb_cGstPlugin, "license", rb_gst_plugin_get_license, 0);
161
+ rb_define_method(rb_cGstPlugin, "source", get_source, 0);
162
+ rb_define_method(rb_cGstPlugin, "package", rb_gst_plugin_get_package, 0);
163
+ rb_define_method(rb_cGstPlugin, "origin", rb_gst_plugin_get_origin, 0);
164
+ }
Binary file
@@ -0,0 +1,89 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2008 Ruby-GNOME2 Project Team
4
+ *
5
+ * This file is part of Ruby/GStreamer.
6
+ *
7
+ * Ruby/GStreamer is free software; you can redistribute it and/or
8
+ * modify it under the terms of the GNU Lesser General Public
9
+ * License as published by the Free Software Foundation; either
10
+ * version 2.1 of the License, or (at your option) any later version.
11
+ *
12
+ * Ruby/GStreamer is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ * Lesser General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public
18
+ * License along with Ruby/GStreamer; if not, write to the Free Software
19
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
+ */
21
+
22
+ #include "rbgst.h"
23
+ #include "rbgst-private.h"
24
+
25
+ char *
26
+ _rbgst_inspect(VALUE object)
27
+ {
28
+ VALUE inspected;
29
+ inspected = rb_funcall(object, rb_intern("inspect"), 0);
30
+ return StringValueCStr(inspected);
31
+ }
32
+
33
+ void
34
+ _rbgst_define_class_if_need(VALUE klass, GType type, const gchar *prefix)
35
+ {
36
+ VALUE parent;
37
+ const gchar *type_name;
38
+ gchar *class_name = NULL;
39
+ static ID id_gtype = 0;
40
+
41
+ if (rb_class2name(klass)[0] != '#')
42
+ return;
43
+
44
+ type_name = g_type_name(type);
45
+ if (g_str_has_prefix(type_name, "Gst"))
46
+ type_name += 3;
47
+
48
+ if (prefix)
49
+ class_name = g_strconcat(prefix, type_name, NULL);
50
+ G_DEF_CLASS(type, class_name ? class_name : type_name, mGst);
51
+ g_free(class_name);
52
+
53
+ parent = rb_ary_entry(rb_mod_ancestors(klass), 1);
54
+ if (!id_gtype)
55
+ id_gtype = rb_intern("gtype");
56
+ if (rb_respond_to(parent, id_gtype))
57
+ _rbgst_define_class_if_need(parent, CLASS2GTYPE(parent), prefix);
58
+ }
59
+
60
+ VALUE
61
+ _rbgst_collect_elements(GstIterator *iter)
62
+ {
63
+ VALUE elements;
64
+ gboolean done = FALSE;
65
+
66
+ elements = rb_ary_new();
67
+ while (!done) {
68
+ gpointer element;
69
+ switch (gst_iterator_next(iter, &element)) {
70
+ case GST_ITERATOR_OK:
71
+ rb_ary_push(elements, GST_ELEMENT2RVAL(element));
72
+ gst_object_unref(element);
73
+ break;
74
+ case GST_ITERATOR_RESYNC:
75
+ gst_iterator_resync(iter);
76
+ break;
77
+ case GST_ITERATOR_ERROR:
78
+ done = TRUE;
79
+ break;
80
+ case GST_ITERATOR_DONE:
81
+ done = TRUE;
82
+ break;
83
+ }
84
+ }
85
+ gst_iterator_free(iter);
86
+
87
+ return elements;
88
+ }
89
+