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,220 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2007 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
+ /* Class: Gst::MiniObject
26
+ * Base class for refcounted lightweight objects.
27
+ */
28
+
29
+ #define SELF(object) (RVAL2GST_MINI_OBJ(object))
30
+ #define RVAL2GST_FLAGS(flags) \
31
+ (RVAL2GFLAGS(flags, GST_TYPE_MINI_OBJECT_FLAGS))
32
+ #define GST_FLAGS2RVAL(flags) \
33
+ (GFLAGS2RVAL(flags, GST_TYPE_MINI_OBJECT_FLAGS))
34
+
35
+ VALUE rb_cGstMiniObject;
36
+
37
+ static RGConvertTable table = {0};
38
+
39
+ void
40
+ _rbgst_mini_object_free(void *ptr)
41
+ {
42
+ if (ptr) {
43
+ gst_mini_object_unref((GstMiniObject *)ptr);
44
+ }
45
+ }
46
+
47
+ static VALUE
48
+ rbgst_mini_object_get_superclass(void)
49
+ {
50
+ return rb_cObject;
51
+ }
52
+
53
+ static VALUE
54
+ initialize_with_abstract_check(int argc, VALUE *argv, VALUE self)
55
+ {
56
+ GType gtype = CLASS2GTYPE(CLASS_OF(self));
57
+
58
+ if (G_TYPE_IS_ABSTRACT(gtype))
59
+ rb_raise(rb_eTypeError, "initializing abstract class");
60
+
61
+ return rb_call_super(argc, argv);
62
+ }
63
+
64
+ static void
65
+ rbgst_mini_object_type_init_hook(VALUE klass)
66
+ {
67
+ if (G_TYPE_IS_ABSTRACT(CLASS2GTYPE(klass)))
68
+ rb_define_method(klass, "initialize",
69
+ initialize_with_abstract_check, -1);
70
+ }
71
+
72
+ static VALUE
73
+ gvalue2rvalue(const GValue *value)
74
+ {
75
+ GstMiniObject* obj;
76
+ obj = gst_value_get_mini_object(value);
77
+ return obj ? GOBJ2RVAL(obj) : Qnil;
78
+ }
79
+
80
+ static void
81
+ rvalue2gvalue(VALUE value, GValue *result)
82
+ {
83
+ gst_value_set_mini_object(result, NIL_P(value) ? NULL : RVAL2GOBJ(value));
84
+ }
85
+
86
+ static void
87
+ rbgst_mini_object_initialize(VALUE object, gpointer instance)
88
+ {
89
+ DATA_PTR(object) = instance;
90
+ }
91
+
92
+ static gpointer
93
+ rbgst_mini_object_robj2instance(VALUE object)
94
+ {
95
+ gpointer instance;
96
+
97
+ if (!RVAL2CBOOL(rb_obj_is_kind_of(object, rb_cGstMiniObject))) {
98
+ rb_raise(rb_eTypeError, "not a Gst::MiniObject");
99
+ }
100
+ Data_Get_Struct(object, GstMiniObject, instance);
101
+ return instance;
102
+ }
103
+
104
+ static void
105
+ rbgst_mini_object_define_class_if_need(VALUE klass, GType type)
106
+ {
107
+ _rbgst_define_class_if_need(klass, type, NULL);
108
+ }
109
+
110
+ static VALUE
111
+ rbgst_mini_object_instance2robj(gpointer instance)
112
+ {
113
+ VALUE klass;
114
+ GType type;
115
+
116
+ type = G_TYPE_FROM_INSTANCE(instance);
117
+ klass = GTYPE2CLASS(type);
118
+ rbgst_mini_object_define_class_if_need(klass, type);
119
+ gst_mini_object_ref(instance);
120
+ return Data_Wrap_Struct(klass, NULL, _rbgst_mini_object_free, instance);
121
+ }
122
+
123
+ static void
124
+ rbgst_mini_object_unref(gpointer instance)
125
+ {
126
+ gst_mini_object_unref(instance);
127
+ }
128
+
129
+ static VALUE
130
+ s_allocate(VALUE klass)
131
+ {
132
+ return Data_Wrap_Struct(klass, NULL, _rbgst_mini_object_free, NULL);
133
+ }
134
+
135
+ static VALUE
136
+ get_flags(VALUE self)
137
+ {
138
+ return GST_FLAGS2RVAL(GST_MINI_OBJECT_FLAGS(SELF(self)));
139
+ }
140
+
141
+ static VALUE
142
+ set_flags(VALUE self, VALUE flag)
143
+ {
144
+ GST_MINI_OBJECT_FLAGS(SELF(self)) = RVAL2GST_FLAGS(flag);
145
+ return Qnil;
146
+ }
147
+
148
+ static VALUE
149
+ raise_flag(VALUE self, VALUE flag)
150
+ {
151
+ GST_MINI_OBJECT_FLAG_SET(SELF(self), RVAL2GST_FLAGS(flag));
152
+ return Qnil;
153
+ }
154
+
155
+ static VALUE
156
+ lower_flag(VALUE self, VALUE flag)
157
+ {
158
+ GST_MINI_OBJECT_FLAG_UNSET(SELF(self), RVAL2GST_FLAGS(flag));
159
+ return Qnil;
160
+ }
161
+
162
+ static VALUE
163
+ flag_raised_p(VALUE self, VALUE flag)
164
+ {
165
+ return CBOOL2RVAL(GST_MINI_OBJECT_FLAG_IS_SET(SELF(self),
166
+ RVAL2GST_FLAGS(flag)));
167
+ }
168
+
169
+ static VALUE
170
+ writable_p(VALUE self)
171
+ {
172
+ return CBOOL2RVAL(gst_mini_object_is_writable(SELF(self)));
173
+ }
174
+
175
+ static VALUE
176
+ writable_bang(VALUE self)
177
+ {
178
+ GstMiniObject *original, *writable;
179
+
180
+ original = SELF(self);
181
+ writable = gst_mini_object_make_writable(original);
182
+ DATA_PTR(self) = writable;
183
+ if (original == writable)
184
+ gst_mini_object_unref(original);
185
+ return self;
186
+ }
187
+
188
+ void
189
+ Init_gst_mini_object(void)
190
+ {
191
+ table.type = GST_TYPE_MINI_OBJECT;
192
+ table.get_superclass = rbgst_mini_object_get_superclass;
193
+ table.type_init_hook = rbgst_mini_object_type_init_hook;
194
+ table.rvalue2gvalue = rvalue2gvalue;
195
+ table.gvalue2rvalue = gvalue2rvalue;
196
+ table.initialize = rbgst_mini_object_initialize;
197
+ table.robj2instance = rbgst_mini_object_robj2instance;
198
+ table.instance2robj = rbgst_mini_object_instance2robj;
199
+ table.unref = rbgst_mini_object_unref;
200
+
201
+ RG_DEF_CONVERSION(&table);
202
+
203
+ rb_cGstMiniObject = G_DEF_CLASS(GST_TYPE_MINI_OBJECT, "MiniObject", mGst);
204
+
205
+ G_DEF_CLASS(GST_TYPE_MINI_OBJECT_FLAGS, "Flags", rb_cGstMiniObject);
206
+ G_DEF_CONSTANTS(rb_cGstMiniObject, GST_TYPE_MINI_OBJECT_FLAGS,
207
+ "GST_MINI_OBJECT_");
208
+
209
+ rb_define_alloc_func(rb_cGstMiniObject, s_allocate);
210
+
211
+ rb_define_method(rb_cGstMiniObject, "flags", get_flags, 0);
212
+ rb_define_method(rb_cGstMiniObject, "set_flags", set_flags, 1);
213
+ rb_define_method(rb_cGstMiniObject, "raise_flag", raise_flag, 1);
214
+ rb_define_method(rb_cGstMiniObject, "lower_flag", lower_flag, 1);
215
+ rb_define_method(rb_cGstMiniObject, "flag_raised?", flag_raised_p, 1);
216
+ rb_define_method(rb_cGstMiniObject, "writable?", writable_p, 0);
217
+ rb_define_method(rb_cGstMiniObject, "writable!", writable_bang, 0);
218
+
219
+ G_DEF_SETTERS(rb_cGstMiniObject);
220
+ }
Binary file
@@ -0,0 +1,81 @@
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
+ #include "rbgprivate.h"
25
+
26
+ #define SELF(self) (RVAL2GST_OBJ(self))
27
+
28
+ static RGConvertTable table = {0};
29
+
30
+ /* Class: Gst::Object
31
+ * Basis for the GST object hierarchy.
32
+ */
33
+
34
+ VALUE
35
+ rbgst_object_instance2robj(gpointer instance)
36
+ {
37
+ if (GST_OBJECT_IS_FLOATING(instance)) {
38
+ gst_object_ref(instance);
39
+ gst_object_sink(instance);
40
+ }
41
+
42
+ return rbgobj_get_ruby_object_from_gobject(instance, TRUE);
43
+ }
44
+
45
+ void
46
+ rbgst_object_initialize(VALUE obj, gpointer cobj)
47
+ {
48
+ if (GST_OBJECT_IS_FLOATING(cobj)) {
49
+ gst_object_ref(cobj);
50
+ gst_object_sink(cobj);
51
+ }
52
+
53
+ rbgobj_gobject_initialize(obj, cobj);
54
+ }
55
+
56
+ static VALUE
57
+ object_set_name(VALUE self, VALUE name)
58
+ {
59
+ return CBOOL2RVAL(gst_object_set_name(SELF(self), RVAL2CSTR(name)));
60
+ }
61
+
62
+ void
63
+ Init_gst_object(void)
64
+ {
65
+ VALUE cGstObject;
66
+
67
+ table.type = GST_TYPE_OBJECT;
68
+ table.instance2robj = rbgst_object_instance2robj;
69
+ table.initialize = rbgst_object_initialize;
70
+
71
+ RG_DEF_CONVERSION(&table);
72
+
73
+ cGstObject = G_DEF_CLASS(GST_TYPE_OBJECT, "Object", mGst);
74
+
75
+ rb_define_method(cGstObject, "set_name", object_set_name, 1);
76
+
77
+ G_DEF_SETTERS(cGstObject);
78
+
79
+ G_DEF_CLASS(GST_TYPE_OBJECT_FLAGS, "Flags", cGstObject);
80
+ G_DEF_CONSTANTS(cGstObject, GST_TYPE_OBJECT_FLAGS, "GST_");
81
+ }
Binary file
@@ -0,0 +1,124 @@
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_PAD_TEMPLATE(self)
26
+
27
+ /* Class: Gst::PadTemplate
28
+ * Describe the media type of a Gst::Pad.
29
+ */
30
+
31
+ /*
32
+ * Method: name
33
+ *
34
+ * Gets the name of the pad template.
35
+ * This overrides Gst::Object#name.
36
+ *
37
+ * Returns: the name of the pad template.
38
+ */
39
+ static VALUE
40
+ get_name(VALUE self)
41
+ {
42
+ /*
43
+ * We can't call Gst::Object#name since the real name
44
+ * of the pad template is in the "name_template" field of
45
+ * GstPadTemplate.
46
+ */
47
+ return CSTR2RVAL(GST_PAD_TEMPLATE_NAME_TEMPLATE(SELF(self)));
48
+ }
49
+
50
+ /* Method: presence
51
+ * Returns: the pad's presence (see Gst::Pad::Presence).
52
+ */
53
+ static VALUE
54
+ get_presence(VALUE self)
55
+ {
56
+ return GENUM2RVAL(GST_PAD_TEMPLATE_PRESENCE(SELF(self)),
57
+ GST_TYPE_PAD_PRESENCE);
58
+ }
59
+
60
+ /* Method: direction
61
+ * Returns: the pad's direction (see Gst::Pad::Direction).
62
+ */
63
+ static VALUE
64
+ get_direction(VALUE self)
65
+ {
66
+ return GENUM2RVAL(GST_PAD_TEMPLATE_DIRECTION(SELF(self)),
67
+ GST_TYPE_PAD_DIRECTION);
68
+ }
69
+
70
+ /*
71
+ * Method: caps
72
+ *
73
+ * Gets the capabilities of the pad template element.
74
+ *
75
+ * Returns: a Gst::Caps object.
76
+ */
77
+ static VALUE
78
+ get_caps(VALUE self)
79
+ {
80
+ return GST_CAPS2RVAL(gst_pad_template_get_caps(RGST_PAD_TEMPLATE(self)));
81
+ }
82
+
83
+ /*
84
+ * Method: each_caps { |caps| ... }
85
+ *
86
+ * Calls the block for each capability of the pad template,
87
+ * passing a reference to the Gst::Caps object as parameter.
88
+ *
89
+ * Returns: always nil.
90
+ */
91
+ static VALUE
92
+ each_caps(VALUE self)
93
+ {
94
+ return rb_ary_yield(get_caps(self));
95
+ }
96
+
97
+ /* Method: has_caps?
98
+ * Returns: true if the pad template has capabilities, false otherwise.
99
+ */
100
+ static VALUE
101
+ has_caps_p(VALUE self)
102
+ {
103
+ return CBOOL2RVAL(SELF(self)->caps != NULL);
104
+ }
105
+
106
+ void
107
+ Init_gst_pad_template (void)
108
+ {
109
+ VALUE cGstPadTemplate;
110
+
111
+ cGstPadTemplate = G_DEF_CLASS(GST_TYPE_PAD_TEMPLATE, "PadTemplate", mGst);
112
+
113
+ rb_define_method(cGstPadTemplate, "name", get_name, 0);
114
+ rb_define_method(cGstPadTemplate, "presence", get_presence, 0);
115
+ rb_define_method(cGstPadTemplate, "direction", get_direction, 0);
116
+ rb_define_method(cGstPadTemplate, "caps", get_caps, 0);
117
+ rb_define_method(cGstPadTemplate, "each_caps", each_caps, 0);
118
+ rb_define_method(cGstPadTemplate, "has_caps?", has_caps_p, 0);
119
+ rb_define_alias(cGstPadTemplate, "have_caps?", "has_caps?");
120
+
121
+ G_DEF_CLASS(GST_TYPE_PAD_TEMPLATE_FLAGS, "Flags", cGstPadTemplate);
122
+ G_DEF_CONSTANTS(cGstPadTemplate, GST_TYPE_PAD_TEMPLATE_FLAGS,
123
+ "GST_PAD_TEMPLATE_");
124
+ }
Binary file
@@ -0,0 +1,338 @@
1
+ /*
2
+ * Copyright (C) 2003, 2004 Laurent Sansonetti <lrz@gnome.org>
3
+ * Copyright (C) 2006, 2008 Sjoerd Simons <sjoerd@luon.net>
4
+ * Copyright (C) 2008 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_PAD(self)
26
+
27
+ static VALUE cGstPad;
28
+
29
+ /* Class: Gst::Pad
30
+ * The link between Gst::Element objects.
31
+ */
32
+
33
+ /* Method: name
34
+ * Returns: the pad's name.
35
+ */
36
+
37
+ static VALUE
38
+ rb_gst_pad_get_name (VALUE self)
39
+ {
40
+ GstPad *pad = RGST_PAD (self);
41
+ return CSTR2RVAL (gst_pad_get_name (pad));
42
+ }
43
+
44
+ /* Method: direction
45
+ * Returns: the pad's direction (see Gst::Pad::Direction).
46
+ */
47
+
48
+ static VALUE
49
+ rb_gst_pad_get_direction (VALUE self)
50
+ {
51
+ GstPad *pad = RGST_PAD (self);
52
+ return GENUM2RVAL (GST_PAD_DIRECTION(pad), GST_TYPE_PAD_DIRECTION);
53
+ }
54
+
55
+ /* Method: pad_template
56
+ * Returns: the Gst::PadTemplate object of this pad.
57
+ */
58
+ static VALUE
59
+ rb_gst_pad_get_pad_template(VALUE self)
60
+ {
61
+ GstPadTemplate *templ = gst_pad_get_pad_template (RGST_PAD (self));
62
+ if (templ != NULL) {
63
+ gst_object_ref (GST_OBJECT (templ));
64
+ return RGST_PAD_TEMPLATE_NEW (templ);
65
+ }
66
+ return Qnil;
67
+ }
68
+
69
+ /*
70
+ * Method: provides_query_types?
71
+ *
72
+ * Checks if the pad supports query types not handled by
73
+ * the default query types dispatcher.
74
+ *
75
+ * Returns: true if supported, false otherwise.
76
+ */
77
+ static VALUE
78
+ rb_gst_pad_provides_query_types (VALUE self)
79
+ {
80
+ GstPad *pad = RGST_PAD (self);
81
+ return CBOOL2RVAL (GST_PAD_QUERYTYPEFUNC (pad) != gst_pad_get_query_types_default);
82
+ }
83
+
84
+ /*
85
+ * Method: query_types
86
+ *
87
+ * Gets a list of supported queries that can be performed on the pad.
88
+ *
89
+ * Returns: an array of Gst::QueryType objects.
90
+ */
91
+ static VALUE
92
+ rb_gst_pad_get_query_types (VALUE self)
93
+ {
94
+ const GstQueryType *types;
95
+ VALUE arr;
96
+
97
+ arr = rb_ary_new ();
98
+ types = gst_pad_get_query_types (RGST_PAD (self));
99
+
100
+ while (types && *types) {
101
+ rb_ary_push (arr, RGST_QUERY_TYPE_NEW ((GstQueryType *)types));
102
+ types++;
103
+ }
104
+ return arr;
105
+ }
106
+
107
+ /*
108
+ * Method: each_query_type { |query_type| ... }
109
+ *
110
+ * Calls the block for each supported query from the pad, passing
111
+ * a reference to the Gst::QueryType object as parameter.
112
+ *
113
+ * Returns: always nil.
114
+ */
115
+ static VALUE
116
+ rb_gst_pad_each_query_type (VALUE self)
117
+ {
118
+ return rb_ary_yield (rb_gst_pad_get_query_types (self));
119
+ }
120
+
121
+ static VALUE
122
+ rb_gst_pad_is_linked(VALUE self)
123
+ {
124
+ return CBOOL2RVAL(gst_pad_is_linked(SELF(self)));
125
+ }
126
+
127
+ static GstPadLinkReturn
128
+ rb_gst_pad_link_raw(VALUE self, VALUE other_pad)
129
+ {
130
+ GstPad *src_pad;
131
+ GstPad *sink_pad;
132
+
133
+ src_pad = SELF(self);
134
+ if (!RVAL2CBOOL(rb_obj_is_kind_of(other_pad, cGstPad))) {
135
+ rb_raise(rb_eTypeError, "Not a Gst::Pad");
136
+ }
137
+
138
+ sink_pad = RVAL2GST_PAD(other_pad);
139
+ return gst_pad_link(src_pad, sink_pad);
140
+ }
141
+
142
+ /*
143
+ * Method: link(other_pad)
144
+ * other_pad: a Gst::Pad.
145
+ *
146
+ * Links the current pad (source) to an other pad (sink).
147
+ *
148
+ * Returns: a Gst::Pad::LinkReturn
149
+ */
150
+ static VALUE
151
+ rb_gst_pad_link(VALUE self, VALUE other_pad)
152
+ {
153
+ return GENUM2RVAL(rb_gst_pad_link_raw(self, other_pad),
154
+ GST_TYPE_PAD_LINK_RETURN);
155
+ }
156
+
157
+ /*
158
+ * Method: >> other_pad
159
+ * other_pad: a Gst::Pad.
160
+ *
161
+ * Links the current pad (source) to an other pad (sink).
162
+ *
163
+ * Returns: the destination pad, or nil if the link failed.
164
+ * (I can't understand why the return value is
165
+ * useful. Because I can't write like the
166
+ * following:
167
+ * element1["src"] >> element2["sink"] >> element2["src"] >> element3["sink"]
168
+ * I need to write like the following:
169
+ * element1["src"] >> element2["sink"]
170
+ * element2["src"] >> element3["sink"]
171
+ * Return values aren't used in this case.)
172
+ */
173
+ static VALUE
174
+ rb_gst_pad_link_shift(VALUE self, VALUE other_pad)
175
+ {
176
+ if (rb_gst_pad_link_raw(self, other_pad) == GST_PAD_LINK_OK)
177
+ return other_pad;
178
+ else
179
+ return Qnil;
180
+ }
181
+
182
+ /*
183
+ * Method: unlink(other_pad)
184
+ * other_pad: a Gst::Pad.
185
+ *
186
+ * Unlinks the current pad (source) from an other pad (sink).
187
+ *
188
+ * Returns: true if the pads were unlinked and false if the pads weren't linked.
189
+ */
190
+ static VALUE
191
+ rb_gst_pad_unlink(VALUE self, VALUE other_pad)
192
+ {
193
+ GstPad *src_pad;
194
+ GstPad *sink_pad;
195
+
196
+ src_pad = SELF(self);
197
+ if (!CBOOL2RVAL(rb_obj_is_kind_of(other_pad, cGstPad))) {
198
+ rb_raise(rb_eTypeError, "Not a Gst::Pad");
199
+ }
200
+ sink_pad = RVAL2GST_PAD(other_pad);
201
+
202
+ return CBOOL2RVAL(gst_pad_unlink(src_pad, sink_pad));
203
+ }
204
+
205
+ /*
206
+ * Method: query(query)
207
+ * query: a query (see Gst::Query).
208
+ *
209
+ * Performs a query on the pad.
210
+ *
211
+ * Returns: the query result value, or nil if the query could not be performed.
212
+ */
213
+ /*
214
+ * Method: query
215
+ */
216
+ static VALUE
217
+ rb_gst_pad_query(VALUE self, VALUE query)
218
+ {
219
+ return CBOOL2RVAL(gst_pad_query(SELF(self), RVAL2GST_QUERY(query)));
220
+ }
221
+
222
+ /*
223
+ * Method: send_event(event)
224
+ * event: a Gst::Event.
225
+ *
226
+ * Sends an event to the pad, through a Gst::Event object.
227
+ *
228
+ * Returns: true if the request event was successfully handled, false
229
+ * otherwise.
230
+ */
231
+ static VALUE
232
+ rb_gst_pad_send_event (VALUE self, VALUE event)
233
+ {
234
+ return CBOOL2RVAL (gst_pad_send_event (RGST_PAD (self),
235
+ RGST_EVENT (event)));
236
+ }
237
+
238
+ /*
239
+ * Method: caps
240
+ *
241
+ * Gets the capabilities of the pad element.
242
+ *
243
+ * Returns: a Gst::Caps object.
244
+ */
245
+ static VALUE
246
+ rb_gst_pad_get_caps(VALUE self)
247
+ {
248
+ return GST_CAPS2RVAL_UNREF(gst_pad_get_caps(SELF(self)));
249
+ }
250
+
251
+ /*
252
+ * Method: negotiated_caps
253
+ *
254
+ * Gets the capabilities of the pad element.
255
+ *
256
+ * Returns: a Gst::Caps object.
257
+ */
258
+ static VALUE
259
+ rb_gst_pad_get_negotiated_caps(VALUE self)
260
+ {
261
+ return GST_CAPS2RVAL_UNREF(gst_pad_get_negotiated_caps(SELF(self)));
262
+ }
263
+
264
+ /*
265
+ * Method: set_caps
266
+ *
267
+ * Sets the capabilities of the pad element.
268
+ *
269
+ * Returns: true if the setting succeeded
270
+ */
271
+ static VALUE
272
+ rb_gst_pad_set_caps(VALUE self, VALUE caps)
273
+ {
274
+ return CBOOL2RVAL(gst_pad_set_caps(SELF(self), RVAL2GST_CAPS(caps)));
275
+ }
276
+
277
+ /*
278
+ * Method: set_active
279
+ *
280
+ * Sets the active state of the pad.
281
+ *
282
+ * Returns: true if the setting succeeded
283
+ */
284
+ static VALUE
285
+ rb_gst_pad_set_active(VALUE self, VALUE active)
286
+ {
287
+ return CBOOL2RVAL(gst_pad_set_active(SELF(self), RVAL2CBOOL(active)));
288
+ }
289
+
290
+ /*
291
+ * Method: peer
292
+ *
293
+ * Get the peer of a pad
294
+ *
295
+ * Returns: Returns the peer pad or Qnil if there is none
296
+ */
297
+ static VALUE
298
+ rb_gst_pad_get_peer(VALUE self)
299
+ {
300
+ return GST_PAD2RVAL_UNREF(gst_pad_get_peer(SELF(self)));
301
+ }
302
+
303
+
304
+ void
305
+ Init_gst_pad (void)
306
+ {
307
+ cGstPad = G_DEF_CLASS (GST_TYPE_PAD, "Pad", mGst);
308
+
309
+ rb_define_method(cGstPad, "direction", rb_gst_pad_get_direction, 0);
310
+ rb_define_method(cGstPad, "name", rb_gst_pad_get_name, 0);
311
+ rb_define_method(cGstPad, "pad_template", rb_gst_pad_get_pad_template, 0);
312
+ rb_define_method(cGstPad, "provides_query_types?", rb_gst_pad_provides_query_types, 0);
313
+ rb_define_method(cGstPad, "query_types", rb_gst_pad_get_query_types, 0);
314
+ rb_define_method(cGstPad, "each_query_type", rb_gst_pad_each_query_type, 0);
315
+ rb_define_method(cGstPad, "linked?", rb_gst_pad_is_linked, 0);
316
+ rb_define_method(cGstPad, "link", rb_gst_pad_link, 1);
317
+ rb_define_method(cGstPad, ">>", rb_gst_pad_link_shift, 1);
318
+ rb_define_method(cGstPad, "unlink", rb_gst_pad_unlink, 1);
319
+ rb_define_method(cGstPad, "query", rb_gst_pad_query, 1);
320
+ rb_define_method(cGstPad, "send_event", rb_gst_pad_send_event, 1);
321
+ rb_define_method(cGstPad, "caps", rb_gst_pad_get_caps, 0);
322
+ rb_define_method(cGstPad, "negotiated_caps", rb_gst_pad_get_negotiated_caps, 0);
323
+ rb_define_method(cGstPad, "set_caps", rb_gst_pad_set_caps, 1);
324
+ rb_define_method(cGstPad, "set_active", rb_gst_pad_set_active, 1);
325
+ rb_define_method(cGstPad, "peer", rb_gst_pad_get_peer, 0);
326
+
327
+ G_DEF_SETTERS(cGstPad);
328
+
329
+
330
+ G_DEF_CLASS(GST_TYPE_PAD_LINK_RETURN, "LinkReturn", cGstPad);
331
+ G_DEF_CONSTANTS(cGstPad, GST_TYPE_PAD_LINK_RETURN, "GST_PAD_");
332
+ G_DEF_CLASS(GST_TYPE_PAD_DIRECTION, "Direction", cGstPad);
333
+ G_DEF_CONSTANTS(cGstPad, GST_TYPE_PAD_DIRECTION, "GST_PAD_");
334
+ G_DEF_CLASS(GST_TYPE_PAD_FLAGS, "Flags", cGstPad);
335
+ G_DEF_CONSTANTS(cGstPad, GST_TYPE_PAD_FLAGS, "GST_PAD_");
336
+ G_DEF_CLASS(GST_TYPE_PAD_PRESENCE, "Presence", cGstPad);
337
+ G_DEF_CONSTANTS(cGstPad, GST_TYPE_PAD_PRESENCE, "GST_PAD_");
338
+ }