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,96 @@
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::IndexEntry
24
+ * An index's entry.
25
+ */
26
+
27
+ /*
28
+ * Method: data
29
+ *
30
+ * Gets the internal data stored in the entry. The data depends of the type
31
+ * of the entry:
32
+ * * Gst::IndexEntry::ID: the description of the ID, as a String.
33
+ * * Gst::IndexEntry::ASSOCIATION: an Array that contains the number of associations, a Gst::Format, the value of the format and the association flags (see Gst::Index::AssocFlags).
34
+ * * Gst::IndexEntry::FORMAT: an Array that contains a Gst::Format and its value.
35
+ * * Gst::IndexEntry::OBJECt: not yet implemented.
36
+ *
37
+ * Returns: the internal data of the entry.
38
+ */
39
+ static VALUE
40
+ rb_gst_index_entry_get_data (VALUE self)
41
+ {
42
+ GstIndexEntry *entry;
43
+ VALUE data;
44
+
45
+ entry = RGST_INDEX_ENTRY (self);
46
+ switch (entry->type) {
47
+ case GST_INDEX_ENTRY_ID:
48
+ data = CSTR2RVAL (entry->data.id.description);
49
+ break;
50
+
51
+ case GST_INDEX_ENTRY_ASSOCIATION:
52
+ data = rb_ary_new ();
53
+ rb_ary_push (data, INT2FIX (entry->data.assoc.nassocs));
54
+ rb_ary_push (data, RGST_FORMAT_NEW (entry->data.assoc.assocs->format));
55
+ rb_ary_push (data, ULL2NUM (entry->data.assoc.assocs->value));
56
+ rb_ary_push (data,
57
+ GFLAGS2RVAL (entry->data.assoc.flags,
58
+ GST_TYPE_ASSOC_FLAGS));
59
+ break;
60
+
61
+ case GST_INDEX_ENTRY_FORMAT:
62
+ data = rb_ary_new ();
63
+ rb_ary_push (data, RGST_FORMAT_NEW (entry->data.format.format));
64
+ rb_ary_push (data, CSTR2RVAL (entry->data.format.key));
65
+ break;
66
+
67
+ case GST_INDEX_ENTRY_OBJECT: /* TODO */
68
+ default:
69
+ data = Qnil;
70
+ }
71
+ return data;
72
+ }
73
+
74
+ /* Method: entry_type
75
+ * Returns: the type of the entry (see Gst::IndexEntry::Types).
76
+ */
77
+ static VALUE
78
+ rb_gst_index_entry_get_type (VALUE self)
79
+ {
80
+ GstIndexEntry *entry = RGST_INDEX_ENTRY (self);
81
+
82
+ return GENUM2RVAL (entry->type, GST_TYPE_INDEX_ENTRY_TYPE);
83
+ }
84
+
85
+ void
86
+ Init_gst_indexentry (void)
87
+ {
88
+ VALUE c = G_DEF_CLASS (GST_TYPE_INDEX_ENTRY, "IndexEntry", mGst);
89
+
90
+ rb_undef_method (c, "initialize");
91
+ rb_define_method (c, "data", rb_gst_index_entry_get_data, 0);
92
+ rb_define_method (c, "entry_type", rb_gst_index_entry_get_type, 0);
93
+
94
+ G_DEF_CLASS (GST_TYPE_INDEX_ENTRY_TYPE, "Types", c);
95
+ G_DEF_CONSTANTS (c, GST_TYPE_INDEX_ENTRY_TYPE, "GST_INDEX_ENTRY_");
96
+ }
Binary file
@@ -0,0 +1,66 @@
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
+ /* Module: Gst::Parse
24
+ * Parses command-line syntax into a pipeline.
25
+ */
26
+
27
+ /*
28
+ * Class method: launch(command)
29
+ * command: a command line.
30
+ *
31
+ * Creates a new pipeline based on command line syntax.
32
+ * On failure, an exception is thrown with a specific
33
+ * error message.
34
+ *
35
+ * Returns: a reference to a new Gst::Bin on success,
36
+ * an exception on failure.
37
+ */
38
+ static VALUE
39
+ rb_gst_parse_launch (VALUE self, VALUE command)
40
+ {
41
+ #if !defined(GST_DISABLE_PARSE)
42
+ GError *error;
43
+ GstBin *bin;
44
+
45
+ error = NULL;
46
+ bin = (GstBin*)gst_parse_launch (RVAL2CSTR (command), &error);
47
+ if (bin != NULL)
48
+ return RGST_BIN_NEW (bin);
49
+ RAISE_GERROR(error);
50
+ #else
51
+ rb_raise (rb_eRuntimeError,
52
+ "This function has been disabled "
53
+ "when GStreamer was compiled");
54
+ #endif
55
+ return Qnil;
56
+ }
57
+
58
+ void
59
+ Init_gst_parse (void)
60
+ {
61
+ VALUE c = rb_define_module_under (mGst, "Parse");
62
+ rb_define_module_function (c, "launch", rb_gst_parse_launch, 1);
63
+
64
+ G_DEF_ERROR(GST_PARSE_ERROR, "ParseError", mGst, rb_eRuntimeError,
65
+ GST_TYPE_PARSE_ERROR);
66
+ }
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::QueryType
24
+ * Dynamically register new query types.
25
+ */
26
+
27
+ static GstQueryType *
28
+ query_type_copy (const GstQueryType* query_type)
29
+ {
30
+ GstQueryType *new_query_type;
31
+ g_return_val_if_fail (query_type != NULL, NULL);
32
+ new_query_type = g_new (GstQueryType, 1);
33
+ *new_query_type = *query_type;
34
+ return new_query_type;
35
+ }
36
+
37
+ GType
38
+ gst_query_type_get_type2 (void)
39
+ {
40
+ static GType our_type = 0;
41
+ if (our_type == 0)
42
+ our_type = g_boxed_type_register_static ("GstQueryTypeClass",
43
+ (GBoxedCopyFunc)query_type_copy,
44
+ (GBoxedFreeFunc)g_free);
45
+ return our_type;
46
+ }
47
+
48
+ /*
49
+ * Class method: find(nick)
50
+ * nick: the nick of an existing query type.
51
+ *
52
+ * Returns: a reference to the Gst::QueryType object registered with the
53
+ * given nick, or nil if this query was not registered.
54
+ */
55
+ static VALUE
56
+ rb_gst_querytype_find (VALUE self, VALUE nick)
57
+ {
58
+ GstQueryType type = gst_query_type_get_by_nick (RVAL2CSTR (nick));
59
+ return type != GST_QUERY_NONE
60
+ ? RGST_QUERY_TYPE_NEW (&type)
61
+ : Qnil;
62
+ }
63
+
64
+ /*
65
+ * Class method: each { |query_type| block }
66
+ *
67
+ * Calls the block for each registered query type, passing a reference
68
+ * to the Gst::QueryType object as parameter.
69
+ *
70
+ * Returns: always nil.
71
+ */
72
+ static VALUE
73
+ rb_gst_querytype_each (VALUE self)
74
+ {
75
+ GstIterator *iter;
76
+ gpointer value;
77
+
78
+ iter = gst_query_type_iterate_definitions();
79
+ while (gst_iterator_next(iter, &value) == GST_ITERATOR_OK) {
80
+ GstQueryTypeDefinition *definition = value;
81
+ rb_yield(RGST_QUERY_TYPE_NEW(&(definition->value)));
82
+ }
83
+ gst_iterator_free(iter);
84
+ return Qnil;
85
+ }
86
+
87
+ /* Method: type_id
88
+ * Returns: the type id of this query type (see Gst::QueryType::Type).
89
+ */
90
+ static VALUE
91
+ rb_gst_querytype_get_type_id (VALUE self)
92
+ {
93
+ GstQueryType *querytype = RGST_QUERY_TYPE (self);
94
+ return INT2FIX (*querytype);
95
+ }
96
+
97
+ /* Method: nick
98
+ * Returns: the short nick of the query type.
99
+ */
100
+ static VALUE
101
+ rb_gst_querytype_get_nick (VALUE self)
102
+ {
103
+ GstQueryType *querytype = RGST_QUERY_TYPE (self);
104
+ return CSTR2RVAL (gst_query_type_get_details (*querytype)->nick);
105
+ }
106
+
107
+ /* Method: description
108
+ * Returns: a longer description of the query type.
109
+ */
110
+ static VALUE
111
+ rb_gst_querytype_get_description (VALUE self)
112
+ {
113
+ GstQueryType *querytype = RGST_QUERY_TYPE (self);
114
+ return CSTR2RVAL (gst_query_type_get_details (*querytype)->description);
115
+ }
116
+
117
+ /*
118
+ * Method: ==(query_type)
119
+ * query_type: a Gst::QueryType object.
120
+ *
121
+ * Checks if two Gst::QueryType objects are registered under the
122
+ * same nick.
123
+ *
124
+ * Returns: true on success, false on failure.
125
+ */
126
+ static VALUE
127
+ rb_gst_querytype_is_equal (VALUE self, VALUE other_query)
128
+ {
129
+ GstQueryType *q1, *q2;
130
+ gchar *n1, *n2;
131
+
132
+ if (NIL_P (other_query))
133
+ return Qfalse;
134
+
135
+ q1 = RGST_QUERY_TYPE (self);
136
+ q2 = RGST_QUERY_TYPE (other_query);
137
+
138
+ n1 = gst_query_type_get_details (*q1)->nick;
139
+ n2 = gst_query_type_get_details (*q2)->nick;
140
+
141
+ return CBOOL2RVAL( strcmp (n1, n2) == 0);
142
+ }
143
+
144
+ void
145
+ Init_gst_querytype (void)
146
+ {
147
+ VALUE c = G_DEF_CLASS (GST_TYPE_QUERY_TYPE2, "QueryType", mGst);
148
+
149
+ rb_define_singleton_method (c, "each", rb_gst_querytype_each, 0);
150
+ rb_define_singleton_method (c, "find", rb_gst_querytype_find, 1);
151
+
152
+ rb_define_method (c, "type_id", rb_gst_querytype_get_type_id, 0);
153
+ rb_define_method (c, "nick", rb_gst_querytype_get_nick, 0);
154
+ rb_define_method (c, "description", rb_gst_querytype_get_description, 0);
155
+ rb_define_method (c, "==", rb_gst_querytype_is_equal, 1);
156
+
157
+ G_DEF_CLASS (GST_TYPE_QUERY_TYPE, "Type", c);
158
+ G_DEF_CONSTANTS (c, GST_TYPE_QUERY_TYPE, "GST_QUERY_");
159
+ }
Binary file
@@ -0,0 +1,278 @@
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::Registry
24
+ * Abstract class for managing plugins.
25
+ */
26
+
27
+ static VALUE
28
+ rb_gst_registry_get_default(VALUE self)
29
+ {
30
+ return RGST_REGISTRY_NEW(gst_registry_get_default());
31
+ }
32
+
33
+ /*
34
+ * Method: plugins
35
+ *
36
+ * Gets a list of all plugins in the pool.
37
+ *
38
+ * Returns: an array of Gst::Plugin objects.
39
+ */
40
+ static VALUE
41
+ rb_gst_registry_get_plugins(VALUE self)
42
+ {
43
+ GList *list, *node;
44
+ VALUE arr;
45
+
46
+ arr = rb_ary_new();
47
+ list = gst_registry_get_plugin_list(RGST_REGISTRY(self));
48
+ for (node = list;
49
+ node != NULL;
50
+ node = g_list_next(node)) {
51
+ GstPlugin *plugin = (GstPlugin *)node->data;
52
+ rb_ary_push(arr, RGST_PLUGIN_NEW(plugin));
53
+ }
54
+ g_list_free(list);
55
+ return arr;
56
+ }
57
+
58
+ /*
59
+ * Method: each_plugin { |plugin| ... }
60
+ *
61
+ * Calls the block for each plugin in the pool, passing a reference to
62
+ * the Gst::Plugin as parameter.
63
+ *
64
+ * Returns: always nil.
65
+ */
66
+ static VALUE
67
+ rb_gst_registry_each_plugin (VALUE self)
68
+ {
69
+ return rb_ary_yield (rb_gst_registry_get_plugins (self));
70
+ }
71
+
72
+ /*
73
+ * Method: get_features(feature_type_or_plugin_name)
74
+ * feature_type_or_plugin_name: a feature type or plugin name.
75
+ *
76
+ * Gets a list of all plugin features of the given type in the pool.
77
+ *
78
+ * Valid features types are Gst::AutoplugFactory, Gst::ElementFactory,
79
+ * Gst::IndexFactory, Gst::SchedulerFactory and Gst::TypeFactory.
80
+ *
81
+ * Returns: an array of Gst::PluginFeature objects.
82
+ */
83
+ static VALUE
84
+ rb_gst_registry_get_features(VALUE self, VALUE type_or_plugin_name)
85
+ {
86
+ GList *list, *node;
87
+ GType gtype;
88
+ VALUE arr;
89
+
90
+ if (RVAL2CBOOL(rb_obj_is_kind_of(type_or_plugin_name, rb_cString))) {
91
+ list = gst_registry_get_feature_list_by_plugin(RGST_REGISTRY(self),
92
+ RVAL2CSTR(type_or_plugin_name));
93
+ } else {
94
+ gtype = CLASS2GTYPE(type_or_plugin_name);
95
+ if (!is_valid_pluginfeature_type(gtype))
96
+ rb_raise (rb_eArgError, "Invalid feature type.");
97
+
98
+ list = gst_registry_get_feature_list(RGST_REGISTRY(self), gtype);
99
+ }
100
+
101
+ arr = rb_ary_new();
102
+ for (node = list; node != NULL; node = g_list_next(node)) {
103
+ rb_ary_push(arr, instanciate_pluginfeature(GST_PLUGIN_FEATURE(node->data)));
104
+ }
105
+ g_list_free (list);
106
+
107
+ return arr;
108
+ }
109
+
110
+ /*
111
+ * Method: each_feature(feature_type) { |plugin_feature| ... }
112
+ *
113
+ * Calls the block for each plugin features of the given type in the pool,
114
+ * passing a reference to the Gst::PluginFeature as parameter.
115
+ *
116
+ * Valid features types are Gst::AutoplugFactory, Gst::ElementFactory,
117
+ * Gst::IndexFactory, Gst::SchedulerFactory and Gst::TypeFactory.
118
+ *
119
+ * Returns: always nil.
120
+ */
121
+ static VALUE
122
+ rb_gst_registry_each_feature (VALUE self, VALUE type)
123
+ {
124
+ return rb_ary_yield (rb_gst_registry_get_features (self, type));
125
+ }
126
+
127
+ /*
128
+ * Method: paths
129
+ *
130
+ * Gets a list of paths of the registry.
131
+ *
132
+ * Returns: an array of strings.
133
+ */
134
+ static VALUE
135
+ rb_gst_registry_get_paths (VALUE self)
136
+ {
137
+ GList *list;
138
+ VALUE arr;
139
+
140
+ arr = rb_ary_new ();
141
+ for (list = gst_registry_get_path_list (RGST_REGISTRY (self));
142
+ list != NULL;
143
+ list = g_list_next (list))
144
+ rb_ary_push (arr, CSTR2RVAL ((gchar *) list->data));
145
+ g_list_free (list);
146
+ return arr;
147
+ }
148
+
149
+ /*
150
+ * Method: each_path { |path| ... }
151
+ *
152
+ * Calls the block for each path of the registry, passing a reference to
153
+ * the path (a String object) as parameter.
154
+ *
155
+ * Returns: always nil.
156
+ */
157
+ static VALUE
158
+ rb_gst_registry_each_path (VALUE self)
159
+ {
160
+ return rb_ary_yield (rb_gst_registry_get_paths (self));
161
+ }
162
+
163
+ /*
164
+ * Method: add_path(path)
165
+ * path: a path (a String object).
166
+ *
167
+ * Add the given path to the registry.
168
+ * The syntax of the path is specific to the registry.
169
+ * If the path has already been added, do nothing.
170
+ *
171
+ * Returns: nil.
172
+ */
173
+ static VALUE
174
+ rb_gst_registry_add_path(VALUE self, VALUE path)
175
+ {
176
+ gst_registry_add_path(RGST_REGISTRY(self), RVAL2CSTR(path));
177
+ return Qnil;
178
+ }
179
+
180
+ /*
181
+ * Method: add_plugin(plugin)
182
+ * plugin: a Gst::Plugin.
183
+ *
184
+ * Adds a plugin to the registry. The 'plugin-added' signal will be emitted.
185
+ *
186
+ * Returns: true on success, false otherwise.
187
+ */
188
+ static VALUE
189
+ rb_gst_registry_add_plugin(VALUE self, VALUE plugin)
190
+ {
191
+ return CBOOL2RVAL(gst_registry_add_plugin(RGST_REGISTRY (self),
192
+ RGST_PLUGIN (plugin)));
193
+ }
194
+
195
+ /*
196
+ * Method: remove_plugin(plugin)
197
+ * plugin: a Gst::Plugin.
198
+ *
199
+ * Removes a plugin from the registry.
200
+ *
201
+ * Returns: self.
202
+ */
203
+ static VALUE
204
+ rb_gst_registry_remove_plugin (VALUE self, VALUE plugin)
205
+ {
206
+ gst_registry_remove_plugin (RGST_REGISTRY (self),
207
+ RGST_PLUGIN (plugin));
208
+ return self;
209
+ }
210
+
211
+ /*
212
+ * Method: find_plugin(name)
213
+ * name: a plugin name.
214
+ *
215
+ * Finds the plugin with the given name in the registry.
216
+ *
217
+ * Returns: a reference to a Gst::Plugin object if found,
218
+ * otherwise returns nil.
219
+ */
220
+ static VALUE
221
+ rb_gst_registry_find_plugin (VALUE self, VALUE name)
222
+ {
223
+ GstPlugin *plugin = gst_registry_find_plugin (RGST_REGISTRY (self),
224
+ RVAL2CSTR (name));
225
+ return plugin != NULL
226
+ ? RGST_PLUGIN_NEW (plugin)
227
+ : Qnil;
228
+ }
229
+
230
+ /*
231
+ * Method: find_feature(feature_name, feature_type)
232
+ * feature_name: a feature name.
233
+ * feature_type: a feature type.
234
+ *
235
+ * Finds the plugin feature with the given name and type in the registry.
236
+ *
237
+ * Valid features types are Gst::AutoplugFactory, Gst::ElementFactory,
238
+ * Gst::IndexFactory, Gst::SchedulerFactory and Gst::TypeFactory.
239
+ *
240
+ * Returns: a reference to a Gst::PluginFeature on success, or nil if the
241
+ * named plugin feature is not found.
242
+ */
243
+ static VALUE
244
+ rb_gst_registry_find_feature(VALUE self, VALUE name, VALUE type)
245
+ {
246
+ GstPluginFeature *feature;
247
+ GType gtype;
248
+
249
+ gtype = CLASS2GTYPE (type);
250
+ if (!is_valid_pluginfeature_type (gtype))
251
+ rb_raise (rb_eArgError, "Invalid feature type.");
252
+ feature = gst_registry_find_feature (RGST_REGISTRY (self),
253
+ RVAL2CSTR (name),
254
+ gtype);
255
+ return feature != NULL
256
+ ? instanciate_pluginfeature (feature)
257
+ : Qnil;
258
+ }
259
+
260
+ void
261
+ Init_gst_registry (void)
262
+ {
263
+ VALUE c = G_DEF_CLASS (GST_TYPE_REGISTRY, "Registry", mGst);
264
+
265
+ rb_define_singleton_method(c, "default", rb_gst_registry_get_default, 0);
266
+
267
+ rb_define_method(c, "plugins", rb_gst_registry_get_plugins, 0);
268
+ rb_define_method(c, "each_plugin", rb_gst_registry_each_plugin, 0);
269
+ rb_define_method(c, "get_features", rb_gst_registry_get_features, 1);
270
+ rb_define_method(c, "each_feature", rb_gst_registry_each_feature, 1);
271
+ rb_define_method(c, "paths", rb_gst_registry_get_paths, 0);
272
+ rb_define_method(c, "each_path", rb_gst_registry_each_path, 0);
273
+ rb_define_method(c, "add_path", rb_gst_registry_add_path, 1);
274
+ rb_define_method(c, "add_plugin", rb_gst_registry_add_plugin, 1);
275
+ rb_define_method(c, "remove_plugin", rb_gst_registry_remove_plugin, 1);
276
+ rb_define_method(c, "find_plugin", rb_gst_registry_find_plugin, 1);
277
+ rb_define_method(c, "find_feature", rb_gst_registry_find_feature, 2);
278
+ }