gstreamer 1.0.3 → 1.1.0

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 (55) hide show
  1. data/Rakefile +201 -3
  2. data/ext/gstreamer/extconf.rb +10 -10
  3. data/ext/gstreamer/misc.c +16 -15
  4. data/ext/gstreamer/rbgst-bin.c +75 -83
  5. data/ext/gstreamer/rbgst-buffer.c +91 -91
  6. data/ext/gstreamer/rbgst-bus.c +21 -21
  7. data/ext/gstreamer/rbgst-caps.c +98 -91
  8. data/ext/gstreamer/rbgst-child-proxy.c +19 -18
  9. data/ext/gstreamer/rbgst-clock.c +34 -32
  10. data/ext/gstreamer/rbgst-element-factory.c +79 -85
  11. data/ext/gstreamer/rbgst-element.c +245 -210
  12. data/ext/gstreamer/rbgst-event.c +18 -18
  13. data/ext/gstreamer/rbgst-ghost-pad.c +24 -21
  14. data/ext/gstreamer/rbgst-index-factory.c +31 -29
  15. data/ext/gstreamer/rbgst-install-plugins-context.c +86 -0
  16. data/ext/gstreamer/rbgst-install-plugins-return.c +45 -0
  17. data/ext/gstreamer/rbgst-install-plugins.c +45 -111
  18. data/ext/gstreamer/rbgst-message.c +15 -16
  19. data/ext/gstreamer/rbgst-mini-object.c +37 -37
  20. data/ext/gstreamer/rbgst-object.c +29 -26
  21. data/ext/gstreamer/rbgst-pad-template.c +36 -35
  22. data/ext/gstreamer/rbgst-pad.c +96 -96
  23. data/ext/gstreamer/rbgst-pipeline.c +32 -31
  24. data/ext/gstreamer/rbgst-plugin-feature.c +47 -48
  25. data/ext/gstreamer/rbgst-plugin.c +62 -64
  26. data/ext/gstreamer/rbgst-private.c +14 -15
  27. data/ext/gstreamer/rbgst-private.h +76 -16
  28. data/ext/gstreamer/rbgst-query.c +22 -20
  29. data/ext/gstreamer/rbgst-seek.c +22 -19
  30. data/ext/gstreamer/rbgst-static-caps.c +26 -24
  31. data/ext/gstreamer/rbgst-static-pad-template.c +27 -26
  32. data/ext/gstreamer/rbgst-structure.c +61 -59
  33. data/ext/gstreamer/rbgst-system-clock.c +23 -20
  34. data/ext/gstreamer/rbgst-type-find-factory.c +44 -43
  35. data/ext/gstreamer/rbgst-value.c +40 -28
  36. data/ext/gstreamer/rbgst-x-overlay.c +32 -31
  37. data/ext/gstreamer/rbgst.c +78 -128
  38. data/ext/gstreamer/rbgst.h +16 -16
  39. data/ext/gstreamer/rbgstclockentry.c +46 -43
  40. data/ext/gstreamer/rbgstformat.c +64 -61
  41. data/ext/gstreamer/rbgstindex.c +67 -64
  42. data/ext/gstreamer/rbgstindexentry.c +31 -28
  43. data/ext/gstreamer/rbgstparse.c +32 -29
  44. data/ext/gstreamer/rbgstquerytype.c +64 -61
  45. data/ext/gstreamer/rbgstregistry.c +79 -76
  46. data/ext/gstreamer/rbgsttag.c +34 -32
  47. data/ext/gstreamer/rbgsttagsetter.c +22 -19
  48. data/ext/gstreamer/rbgstxml.c +78 -75
  49. data/lib/gst.rb +15 -1
  50. data/test/test_buffer.rb +5 -2
  51. data/test/test_element.rb +7 -9
  52. data/test/test_value.rb +2 -2
  53. metadata +11 -11
  54. data/ChangeLog +0 -1202
  55. data/test/test_clock.rb +0 -7
@@ -1,27 +1,28 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
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
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2007 Ruby-GNOME2 Project Team
5
+ * Copyright (C) 2003, 2004 Laurent Sansonetti <lrz@gnome.org>
6
+ *
7
+ * This library 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
+ * This library 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 this library; if not, write to the Free Software
19
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
+ * MA 02110-1301 USA
21
21
  */
22
22
 
23
- #include "rbgst.h"
23
+ #include "rbgst-private.h"
24
24
 
25
+ #define RG_TARGET_NAMESPACE cElementFactory
25
26
  #define SELF(self) RVAL2GST_ELEMENT_FACTORY(self)
26
27
 
27
28
  /* Class: Gst::ElementFactory
@@ -39,16 +40,16 @@
39
40
  * unique name, consisting of the element factory name and a number.
40
41
  * If name is given, it will be given the name supplied.
41
42
  *
42
- * # Creates a 'mad' GStreamer element, named 'foo':
43
- * elem1 = Gst::ElementFactory.make("mad", "foo")
44
- *
45
- * # This line does exactly the same thing:
46
- * elem2 = Gst::ElementFactory.find("mad").create("foo")
43
+ * # Creates a 'mad' GStreamer element, named 'foo':
44
+ * elem1 = Gst::ElementFactory.make("mad", "foo")
45
+ *
46
+ * # This line does exactly the same thing:
47
+ * elem2 = Gst::ElementFactory.find("mad").create("foo")
47
48
  *
48
49
  * Returns: a newly created object based on Gst::Element.
49
50
  */
50
51
  static VALUE
51
- rb_gst_elementfactory_make(int argc, VALUE *argv, VALUE self)
52
+ rg_s_make(int argc, VALUE *argv, VALUE self)
52
53
  {
53
54
  GstElement *element;
54
55
  VALUE fname, ename;
@@ -57,7 +58,7 @@ rb_gst_elementfactory_make(int argc, VALUE *argv, VALUE self)
57
58
  rb_scan_args(argc, argv, "11", &fname, &ename);
58
59
 
59
60
  element = gst_element_factory_make(RVAL2CSTR(fname),
60
- RVAL2CSTR_ACCEPT_NIL(ename));
61
+ RVAL2CSTR_ACCEPT_NIL(ename));
61
62
 
62
63
  if (element == NULL)
63
64
  return Qnil;
@@ -78,12 +79,12 @@ rb_gst_elementfactory_make(int argc, VALUE *argv, VALUE self)
78
79
  * Returns: a Gst::ElementFactory object if found, nil otherwise.
79
80
  */
80
81
  static VALUE
81
- rb_gst_elementfactory_find (VALUE self, VALUE factory_name)
82
+ rg_s_find (VALUE self, VALUE factory_name)
82
83
  {
83
- GstElementFactory *factory = gst_element_factory_find (RVAL2CSTR (factory_name));
84
- return factory != NULL
85
- ? RGST_ELEMENT_FACTORY_NEW (factory)
86
- : Qnil;
84
+ GstElementFactory *factory = gst_element_factory_find (RVAL2CSTR (factory_name));
85
+ return factory != NULL
86
+ ? RGST_ELEMENT_FACTORY_NEW (factory)
87
+ : Qnil;
87
88
  }
88
89
 
89
90
  /*
@@ -99,7 +100,7 @@ rb_gst_elementfactory_find (VALUE self, VALUE factory_name)
99
100
  * Returns: a newly created object based on Gst::Element.
100
101
  */
101
102
  static VALUE
102
- create(int argc, VALUE *argv, VALUE self)
103
+ rg_create(int argc, VALUE *argv, VALUE self)
103
104
  {
104
105
  GstElement *element;
105
106
  VALUE name;
@@ -111,12 +112,12 @@ create(int argc, VALUE *argv, VALUE self)
111
112
  }
112
113
 
113
114
  static VALUE
114
- rb_gst_elementfactory_to_s (VALUE self)
115
+ rg_to_s (VALUE self)
115
116
  {
116
- GstElementFactory *factory = RGST_ELEMENT_FACTORY (self);
117
- return rb_str_new_with_format ("Element: %s (%s)",
118
- GST_PLUGIN_FEATURE_NAME(factory),
119
- factory->details.longname);
117
+ GstElementFactory *factory = RGST_ELEMENT_FACTORY (self);
118
+ return rb_str_new_with_format ("Element: %s (%s)",
119
+ GST_PLUGIN_FEATURE_NAME(factory),
120
+ factory->details.longname);
120
121
  }
121
122
 
122
123
  /*
@@ -127,7 +128,7 @@ rb_gst_elementfactory_to_s (VALUE self)
127
128
  * Returns: an array of Gst::PadTemplate objects.
128
129
  */
129
130
  static VALUE
130
- rb_gst_elementfactory_get_pad_templates (VALUE self)
131
+ rg_pad_templates (VALUE self)
131
132
  {
132
133
  GstElementFactory *factory;
133
134
  const GList *list;
@@ -153,9 +154,9 @@ rb_gst_elementfactory_get_pad_templates (VALUE self)
153
154
  * Returns: always nil.
154
155
  */
155
156
  static VALUE
156
- rb_gst_elementfactory_each_pad_template (VALUE self)
157
+ rg_each_pad_template (VALUE self)
157
158
  {
158
- return rb_ary_yield (rb_gst_elementfactory_get_pad_templates (self));
159
+ return rb_ary_yield (rg_pad_templates (self));
159
160
  }
160
161
 
161
162
  /*
@@ -174,82 +175,75 @@ rb_gst_elementfactory_each_pad_template (VALUE self)
174
175
  *
175
176
  * Here is an example.
176
177
  *
177
- * # Prints all details related to the 'mad' element:
178
- * Gst::ElementFactory.find("mad").details do |k, v|
179
- * p "#{k}: #{v}"
180
- * end
178
+ * # Prints all details related to the 'mad' element:
179
+ * Gst::ElementFactory.find("mad").details do |k, v|
180
+ * p "#{k}: #{v}"
181
+ * end
181
182
  *
182
183
  * Returns: a Hash.
183
184
  */
184
185
  static VALUE
185
- rb_gst_elementfactory_get_details (VALUE self)
186
+ rg_details (VALUE self)
186
187
  {
187
- GstElementFactory *factory;
188
- VALUE hash;
189
-
190
- factory = RGST_ELEMENT_FACTORY (self);
191
-
192
- hash = rb_hash_new();
193
-
194
- rb_hash_aset (hash, CSTR2RVAL ("longname"), CSTR2RVAL (factory->details.longname));
195
- rb_hash_aset (hash, CSTR2RVAL ("klass"), CSTR2RVAL (factory->details.klass));
196
- rb_hash_aset (hash, CSTR2RVAL ("description"), CSTR2RVAL (factory->details.description));
197
- rb_hash_aset (hash, CSTR2RVAL ("author"), CSTR2RVAL (factory->details.author));
198
-
199
- return hash;
188
+ GstElementFactory *factory;
189
+ VALUE hash;
190
+
191
+ factory = RGST_ELEMENT_FACTORY (self);
192
+
193
+ hash = rb_hash_new();
194
+
195
+ rb_hash_aset (hash, CSTR2RVAL ("longname"), CSTR2RVAL (factory->details.longname));
196
+ rb_hash_aset (hash, CSTR2RVAL ("klass"), CSTR2RVAL (factory->details.klass));
197
+ rb_hash_aset (hash, CSTR2RVAL ("description"), CSTR2RVAL (factory->details.description));
198
+ rb_hash_aset (hash, CSTR2RVAL ("author"), CSTR2RVAL (factory->details.author));
199
+
200
+ return hash;
200
201
  }
201
202
 
202
203
  static VALUE
203
- get_long_name(VALUE self)
204
+ rg_long_name(VALUE self)
204
205
  {
205
206
  return CSTR2RVAL(gst_element_factory_get_longname(SELF(self)));
206
207
  }
207
208
 
208
209
  static VALUE
209
- get_klass(VALUE self)
210
+ rg_klass(VALUE self)
210
211
  {
211
212
  return CSTR2RVAL(gst_element_factory_get_klass(SELF(self)));
212
213
  }
213
214
 
214
215
  static VALUE
215
- get_description(VALUE self)
216
+ rg_description(VALUE self)
216
217
  {
217
218
  return CSTR2RVAL(gst_element_factory_get_description(SELF(self)));
218
219
  }
219
220
 
220
221
  static VALUE
221
- get_author(VALUE self)
222
+ rg_author(VALUE self)
222
223
  {
223
224
  return CSTR2RVAL(gst_element_factory_get_author(SELF(self)));
224
225
  }
225
226
 
226
-
227
227
  void
228
- Init_gst_elementfactory (void)
228
+ Init_gst_elementfactory (VALUE mGst)
229
229
  {
230
- VALUE rb_cGstElementFactory;
230
+ VALUE RG_TARGET_NAMESPACE;
231
231
 
232
- rb_cGstElementFactory = G_DEF_CLASS(GST_TYPE_ELEMENT_FACTORY,
232
+ RG_TARGET_NAMESPACE = G_DEF_CLASS(GST_TYPE_ELEMENT_FACTORY,
233
233
  "ElementFactory",
234
234
  mGst);
235
235
 
236
- rb_define_singleton_method(rb_cGstElementFactory, "make",
237
- rb_gst_elementfactory_make, -1);
238
- rb_define_singleton_method(rb_cGstElementFactory, "find",
239
- rb_gst_elementfactory_find, 1);
240
-
241
- rb_define_method(rb_cGstElementFactory, "create", create, -1);
242
- rb_define_method(rb_cGstElementFactory, "details",
243
- rb_gst_elementfactory_get_details, 0);
244
- rb_define_method(rb_cGstElementFactory, "to_s",
245
- rb_gst_elementfactory_to_s, 0);
246
- rb_define_method(rb_cGstElementFactory, "pad_templates",
247
- rb_gst_elementfactory_get_pad_templates, 0);
248
- rb_define_method(rb_cGstElementFactory, "each_pad_template",
249
- rb_gst_elementfactory_each_pad_template, 0);
250
-
251
- rb_define_method(rb_cGstElementFactory, "long_name", get_long_name, 0);
252
- rb_define_method(rb_cGstElementFactory, "klass", get_klass, 0);
253
- rb_define_method(rb_cGstElementFactory, "description", get_description, 0);
254
- rb_define_method(rb_cGstElementFactory, "author", get_author, 0);
236
+ RG_DEF_SMETHOD(make, -1);
237
+ RG_DEF_SMETHOD(find, 1);
238
+
239
+ RG_DEF_METHOD(create, -1);
240
+ RG_DEF_METHOD(details, 0);
241
+ RG_DEF_METHOD(to_s, 0);
242
+ RG_DEF_METHOD(pad_templates, 0);
243
+ RG_DEF_METHOD(each_pad_template, 0);
244
+
245
+ RG_DEF_METHOD(long_name, 0);
246
+ RG_DEF_METHOD(klass, 0);
247
+ RG_DEF_METHOD(description, 0);
248
+ RG_DEF_METHOD(author, 0);
255
249
  }
@@ -1,39 +1,42 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2003, 2004 Laurent Sansonetti <lrz@gnome.org>
4
- * Copyright (C) 2007, 2008 Ruby-GNOME2 Project Team
5
- * Copyright (C) 2006, 2008 Sjoerd Simons <sjoerd@luon.net>
6
- *
7
- * This file is part of Ruby/GStreamer.
8
- *
9
- * Ruby/GStreamer is free software; you can redistribute it and/or
10
- * modify it under the terms of the GNU Lesser General Public
11
- * License as published by the Free Software Foundation; either
12
- * version 2.1 of the License, or (at your option) any later version.
13
- *
14
- * Ruby/GStreamer is distributed in the hope that it will be useful,
15
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
- * Lesser General Public License for more details.
18
- *
19
- * You should have received a copy of the GNU Lesser General Public
20
- * License along with Ruby/GStreamer; if not, write to the Free Software
21
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3
+ * Copyright (C) 2011-2012 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2007, 2008 Ruby-GNOME2 Project Team
5
+ * Copyright (C) 2006, 2008 Sjoerd Simons <sjoerd@luon.net>
6
+ * Copyright (C) 2003, 2004 Laurent Sansonetti <lrz@gnome.org>
7
+ *
8
+ * This library 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
+ * This library 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 this library; if not, write to the Free Software
20
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21
+ * MA 02110-1301 USA
22
22
  */
23
23
 
24
- #include "rbgst.h"
25
24
  #include "rbgst-private.h"
26
25
 
27
- #ifdef HAVE_UNISTD_H
28
- # include <unistd.h>
29
- #endif
30
- #ifdef HAVE_IO_H
31
- # include <io.h>
32
- # define pipe(phandles) _pipe(phandles, 128, _O_BINARY)
26
+ #ifdef G_OS_WIN32
27
+ # ifdef HAVE_IO_H
28
+ # include <io.h>
29
+ # define pipe(phandles) _pipe(phandles, 128, _O_BINARY)
30
+ # endif
31
+ #else
32
+ # ifdef HAVE_UNISTD_H
33
+ # include <unistd.h>
34
+ # endif
33
35
  #endif
34
36
  #include <fcntl.h>
35
37
  #include <errno.h>
36
38
 
39
+ #define RG_TARGET_NAMESPACE cElement
37
40
  #define SELF(self) RVAL2GST_ELEMENT(self)
38
41
 
39
42
  #define GST_STATE_CHANGE_RETURN2RVAL(object) \
@@ -66,17 +69,20 @@ typedef struct _SendEventData {
66
69
 
67
70
  typedef struct _ThreadData {
68
71
  GstElement *element;
69
- int notify_fd;
72
+ gint notify_write_fd;
73
+ gint notify_read_fd;
74
+ gint errno_on_write;
75
+ const gchar *context;
70
76
  union {
71
- SetStateData set_state_data;
72
- GetStateData get_state_data;
73
- QueryData query_data;
74
- SendEventData send_event_data;
77
+ SetStateData set_state_data;
78
+ GetStateData get_state_data;
79
+ QueryData query_data;
80
+ SendEventData send_event_data;
75
81
  } data;
76
82
  } ThreadData;
77
83
 
78
- static RGConvertTable table = {0};
79
- static VALUE rb_cGstElement;
84
+ static RGConvertTable table;
85
+ static VALUE RG_TARGET_NAMESPACE;
80
86
  static ID id_gtype;
81
87
  static GThreadPool *set_state_thread_pool;
82
88
  static GThreadPool *get_state_thread_pool;
@@ -101,7 +107,6 @@ instance2robj(gpointer instance)
101
107
  return rbgst_object_instance2robj(instance);
102
108
  }
103
109
 
104
-
105
110
  /* Class: Gst::Element
106
111
  * Base class for all pipeline elements.
107
112
  */
@@ -110,13 +115,14 @@ static void
110
115
  do_in_thread(GThreadPool *pool, ThreadData *data)
111
116
  {
112
117
  int notify_fds[2];
113
- char buf[NOTIFY_MESSAGE_SIZE];
114
118
  GError *error = NULL;
115
119
 
116
120
  if (pipe(notify_fds) != 0)
117
121
  rb_sys_fail("failed to create a pipe to synchronize threaded operation");
118
122
 
119
- data->notify_fd = notify_fds[1];
123
+ data->errno_on_write = 0;
124
+ data->notify_read_fd = notify_fds[0];
125
+ data->notify_write_fd = notify_fds[1];
120
126
  g_thread_pool_push(pool, data, &error);
121
127
  if (error) {
122
128
  close(notify_fds[0]);
@@ -126,15 +132,56 @@ do_in_thread(GThreadPool *pool, ThreadData *data)
126
132
 
127
133
  rb_thread_wait_fd(notify_fds[0]);
128
134
 
129
- read(notify_fds[0], buf, NOTIFY_MESSAGE_SIZE);
135
+ #define BUFFER_SIZE 512
136
+ if (data->errno_on_write == 0) {
137
+ char buf[NOTIFY_MESSAGE_SIZE];
138
+ ssize_t read_size;
139
+ int saved_errno = 0;
140
+ read_size = read(notify_fds[0], buf, NOTIFY_MESSAGE_SIZE);
141
+ if (read_size != NOTIFY_MESSAGE_SIZE) {
142
+ saved_errno = errno;
143
+ }
130
144
 
145
+ close(notify_fds[0]);
146
+ close(notify_fds[1]);
131
147
 
132
- close(notify_fds[0]);
133
- close(notify_fds[1]);
148
+ if (saved_errno != 0) {
149
+ char buffer[BUFFER_SIZE];
150
+ snprintf(buffer, BUFFER_SIZE - 1,
151
+ "failed to read notify pipe on %s", data->context);
152
+ errno = saved_errno;
153
+ rb_sys_fail(buffer);
154
+ }
155
+ } else {
156
+ char buffer[BUFFER_SIZE];
157
+ snprintf(buffer, BUFFER_SIZE - 1,
158
+ "failed to write notify pipe on %s", data->context);
159
+ errno = data->errno_on_write;
160
+ rb_sys_fail(buffer);
161
+ }
162
+ #undef BUFFER_SIZE
134
163
  }
135
164
 
136
165
  static void
137
- set_state_in_thread(gpointer data, gpointer user_data)
166
+ notify(ThreadData *thread_data)
167
+ {
168
+ ssize_t written_size;
169
+
170
+ written_size = write(thread_data->notify_write_fd,
171
+ NOTIFY_MESSAGE, NOTIFY_MESSAGE_SIZE);
172
+ if (written_size != NOTIFY_MESSAGE_SIZE) {
173
+ int read_fd = thread_data->notify_read_fd;
174
+ int write_fd = thread_data->notify_write_fd;
175
+ thread_data->errno_on_write = errno;
176
+ thread_data->notify_read_fd = -1;
177
+ thread_data->notify_write_fd = -1;
178
+ close(write_fd);
179
+ close(read_fd);
180
+ }
181
+ }
182
+
183
+ static void
184
+ set_state_in_thread(gpointer data, G_GNUC_UNUSED gpointer user_data)
138
185
  {
139
186
  ThreadData *thread_data = (ThreadData *)data;
140
187
  SetStateData *set_state_data;
@@ -142,27 +189,25 @@ set_state_in_thread(gpointer data, gpointer user_data)
142
189
  set_state_data = &(thread_data->data.set_state_data);
143
190
  set_state_data->result = gst_element_set_state(thread_data->element,
144
191
  set_state_data->state);
145
- write(thread_data->notify_fd, NOTIFY_MESSAGE, NOTIFY_MESSAGE_SIZE);
192
+ notify(thread_data);
146
193
  }
147
194
 
148
195
  static VALUE
149
196
  rb_gst_element_set_state_internal(VALUE self, GstState state)
150
197
  {
151
198
  VALUE result;
152
- ThreadData *thread_data;
199
+ ThreadData thread_data;
153
200
  SetStateData *set_state_data;
154
201
 
155
- thread_data = g_slice_new(ThreadData);
156
- thread_data->element = SELF(self);
157
- set_state_data = &(thread_data->data.set_state_data);
202
+ thread_data.element = SELF(self);
203
+ thread_data.context = "set_state";
204
+ set_state_data = &(thread_data.data.set_state_data);
158
205
  set_state_data->state = state;
159
206
 
160
- do_in_thread(set_state_thread_pool, thread_data);
207
+ do_in_thread(set_state_thread_pool, &thread_data);
161
208
 
162
209
  result = GST_STATE_CHANGE_RETURN2RVAL(set_state_data->result);
163
210
 
164
- g_slice_free(ThreadData, thread_data);
165
-
166
211
  return result;
167
212
  }
168
213
 
@@ -179,53 +224,51 @@ rb_gst_element_set_state_internal(VALUE self, GstState state)
179
224
  * Returns: a code (see Gst::Element::StateChangeReturn).
180
225
  */
181
226
  static VALUE
182
- rb_gst_element_set_state(VALUE self, VALUE state)
227
+ rg_set_state(VALUE self, VALUE state)
183
228
  {
184
229
  return rb_gst_element_set_state_internal(self,
185
- RVAL2GENUM(state, GST_TYPE_STATE));
230
+ RVAL2GENUM(state, GST_TYPE_STATE));
186
231
  }
187
232
 
188
233
  static void
189
- get_state_in_thread(gpointer data, gpointer user_data)
234
+ get_state_in_thread(gpointer data, G_GNUC_UNUSED gpointer user_data)
190
235
  {
191
236
  ThreadData *thread_data = (ThreadData *)data;
192
237
  GetStateData *get_state_data;
193
238
 
194
239
  get_state_data = &(thread_data->data.get_state_data);
195
240
  get_state_data->result = gst_element_get_state(thread_data->element,
196
- &(get_state_data->state),
197
- &(get_state_data->pending),
198
- get_state_data->timeout);
199
- write(thread_data->notify_fd, NOTIFY_MESSAGE, NOTIFY_MESSAGE_SIZE);
241
+ &(get_state_data->state),
242
+ &(get_state_data->pending),
243
+ get_state_data->timeout);
244
+ notify(thread_data);
200
245
  }
201
246
 
202
247
  /* Method: get_state(timeout=nil)
203
248
  */
204
249
  static VALUE
205
- rb_gst_element_get_state(int argc, VALUE *argv, VALUE self)
250
+ rg_get_state(int argc, VALUE *argv, VALUE self)
206
251
  {
207
252
  VALUE result, timeout;
208
- ThreadData *thread_data;
253
+ ThreadData thread_data;
209
254
  GetStateData *get_state_data;
210
255
 
211
256
  rb_scan_args(argc, argv, "01", &timeout);
212
257
 
213
- thread_data = g_slice_new(ThreadData);
214
- thread_data->element = SELF(self);
215
- get_state_data = &(thread_data->data.get_state_data);
258
+ thread_data.element = SELF(self);
259
+ thread_data.context = "get_state";
260
+ get_state_data = &(thread_data.data.get_state_data);
216
261
  if (NIL_P(timeout))
217
- get_state_data->timeout = GST_CLOCK_TIME_NONE;
262
+ get_state_data->timeout = GST_CLOCK_TIME_NONE;
218
263
  else
219
- get_state_data->timeout = NUM2ULL(timeout);
264
+ get_state_data->timeout = NUM2ULL(timeout);
220
265
 
221
- do_in_thread(get_state_thread_pool, thread_data);
266
+ do_in_thread(get_state_thread_pool, &thread_data);
222
267
 
223
268
  result = rb_ary_new3(3,
224
- GST_STATE_CHANGE_RETURN2RVAL(get_state_data->result),
225
- GST_STATE2RVAL(get_state_data->state),
226
- GST_STATE2RVAL(get_state_data->pending));
227
-
228
- g_slice_free(ThreadData, thread_data);
269
+ GST_STATE_CHANGE_RETURN2RVAL(get_state_data->result),
270
+ GST_STATE2RVAL(get_state_data->state),
271
+ GST_STATE2RVAL(get_state_data->pending));
229
272
 
230
273
  return result;
231
274
  }
@@ -238,7 +281,7 @@ rb_gst_element_get_state(int argc, VALUE *argv, VALUE self)
238
281
  * Returns: a code (see Gst::Element::StateChangeReturn).
239
282
  */
240
283
  static VALUE
241
- rb_gst_element_stop(VALUE self)
284
+ rg_stop(VALUE self)
242
285
  {
243
286
  return rb_gst_element_set_state_internal(self, GST_STATE_NULL);
244
287
  }
@@ -251,7 +294,7 @@ rb_gst_element_stop(VALUE self)
251
294
  * Returns: a code (see Gst::Element::StateChangeReturn).
252
295
  */
253
296
  static VALUE
254
- rb_gst_element_ready(VALUE self)
297
+ rg_ready(VALUE self)
255
298
  {
256
299
  return rb_gst_element_set_state_internal(self, GST_STATE_READY);
257
300
  }
@@ -264,7 +307,7 @@ rb_gst_element_ready(VALUE self)
264
307
  * Returns: a code (see Gst::Element::StateChangedReturn).
265
308
  */
266
309
  static VALUE
267
- rb_gst_element_pause(VALUE self)
310
+ rg_pause(VALUE self)
268
311
  {
269
312
  return rb_gst_element_set_state_internal(self, GST_STATE_PAUSED);
270
313
  }
@@ -277,7 +320,7 @@ rb_gst_element_pause(VALUE self)
277
320
  * Returns: a code (see Gst::Element::StateChangedReturn).
278
321
  */
279
322
  static VALUE
280
- rb_gst_element_play(VALUE self)
323
+ rg_play(VALUE self)
281
324
  {
282
325
  return rb_gst_element_set_state_internal(self, GST_STATE_PLAYING);
283
326
  }
@@ -295,7 +338,7 @@ rb_gst_element_play(VALUE self)
295
338
  * Returns: the destination element, or nil if the link failed.
296
339
  */
297
340
  static VALUE
298
- rb_gst_element_link(VALUE self, VALUE other_element)
341
+ rg_link(VALUE self, VALUE other_element)
299
342
  {
300
343
  GstElement *element1, *element2;
301
344
 
@@ -315,7 +358,7 @@ rb_gst_element_link(VALUE self, VALUE other_element)
315
358
  *
316
359
  */
317
360
  static VALUE
318
- rb_gst_element_unlink(VALUE self, VALUE other_element)
361
+ rg_unlink(VALUE self, VALUE other_element)
319
362
  {
320
363
  GstElement *element1, *element2;
321
364
 
@@ -340,11 +383,11 @@ rb_gst_element_unlink(VALUE self, VALUE other_element)
340
383
  * Returns: the destination element, or nil if the link failed.
341
384
  */
342
385
  static VALUE
343
- rb_gst_element_link_filtered(VALUE self, VALUE other_element, VALUE rcaps)
386
+ rg_link_filtered(VALUE self, VALUE other_element, VALUE rcaps)
344
387
  {
345
388
  GstElement *element1, *element2;
346
389
  GstCaps *caps;
347
-
390
+
348
391
  element1 = SELF(self);
349
392
  element2 = SELF(other_element);
350
393
  caps = RGST_CAPS(rcaps);
@@ -357,7 +400,7 @@ rb_gst_element_link_filtered(VALUE self, VALUE other_element, VALUE rcaps)
357
400
  * Returns: true if the element requires a clock, false otherwise.
358
401
  */
359
402
  static VALUE
360
- rb_gst_element_requires_clock(VALUE self)
403
+ rg_requires_clock_p(VALUE self)
361
404
  {
362
405
  return CBOOL2RVAL(gst_element_requires_clock(SELF(self)));
363
406
  }
@@ -366,7 +409,7 @@ rb_gst_element_requires_clock(VALUE self)
366
409
  * Returns: true if the element provides a clock, false otherwise.
367
410
  */
368
411
  static VALUE
369
- rb_gst_element_provides_clock(VALUE self)
412
+ rg_provides_clock_p(VALUE self)
370
413
  {
371
414
  return CBOOL2RVAL(gst_element_provides_clock(SELF(self)));
372
415
  }
@@ -376,7 +419,7 @@ rb_gst_element_provides_clock(VALUE self)
376
419
  * if this element does not provide a clock.
377
420
  */
378
421
  static VALUE
379
- rb_gst_element_get_clock(VALUE self)
422
+ rg_clock(VALUE self)
380
423
  {
381
424
  GstClock *clock;
382
425
 
@@ -394,7 +437,7 @@ rb_gst_element_get_clock(VALUE self)
394
437
  * Returns: self.
395
438
  */
396
439
  static VALUE
397
- rb_gst_element_set_clock(VALUE self, VALUE clock)
440
+ rg_set_clock(VALUE self, VALUE clock)
398
441
  {
399
442
  gst_element_set_clock(SELF(self), RVAL2GST_CLOCK(clock));
400
443
  return self;
@@ -419,19 +462,19 @@ rb_gst_element_each_pad_body(VALUE user_data)
419
462
 
420
463
  while (!done) {
421
464
  switch (gst_iterator_next(data->iterator, (gpointer)&pad)) {
422
- case GST_ITERATOR_OK:
423
- data->callback(GST_PAD2RVAL(pad), data->user_data);
424
- gst_object_unref(pad);
425
- break;
426
- case GST_ITERATOR_RESYNC:
427
- gst_iterator_resync(data->iterator);
428
- break;
429
- case GST_ITERATOR_ERROR:
430
- rb_raise(rb_eIndexError, "Pad iteration failed");
431
- break;
432
- case GST_ITERATOR_DONE:
433
- done = TRUE;
434
- break;
465
+ case GST_ITERATOR_OK:
466
+ data->callback(GST_PAD2RVAL(pad), data->user_data);
467
+ gst_object_unref(pad);
468
+ break;
469
+ case GST_ITERATOR_RESYNC:
470
+ gst_iterator_resync(data->iterator);
471
+ break;
472
+ case GST_ITERATOR_ERROR:
473
+ rb_raise(rb_eIndexError, "Pad iteration failed");
474
+ break;
475
+ case GST_ITERATOR_DONE:
476
+ done = TRUE;
477
+ break;
435
478
  }
436
479
  }
437
480
 
@@ -449,8 +492,8 @@ rb_gst_element_each_pad_ensure(VALUE user_data)
449
492
 
450
493
  static VALUE
451
494
  rb_gst_element_each_pad_with_callback(VALUE self,
452
- EachPadCallback callback,
453
- VALUE user_data)
495
+ EachPadCallback callback,
496
+ VALUE user_data)
454
497
  {
455
498
  EachPadData data;
456
499
 
@@ -459,7 +502,7 @@ rb_gst_element_each_pad_with_callback(VALUE self,
459
502
  data.user_data = user_data;
460
503
  data.iterator = gst_element_iterate_pads(SELF(self));
461
504
  return rb_ensure(rb_gst_element_each_pad_body, (VALUE)(&data),
462
- rb_gst_element_each_pad_ensure, (VALUE)(&data));
505
+ rb_gst_element_each_pad_ensure, (VALUE)(&data));
463
506
  }
464
507
 
465
508
  /*
@@ -473,7 +516,7 @@ rb_gst_element_each_pad_with_callback(VALUE self,
473
516
  * Returns: always nil.
474
517
  */
475
518
  static VALUE
476
- rb_gst_element_each_pad(VALUE self)
519
+ rg_each_pad(VALUE self)
477
520
  {
478
521
  rb_gst_element_each_pad_with_callback(self, (EachPadCallback)rb_yield, Qnil);
479
522
  return Qnil;
@@ -486,7 +529,7 @@ collect_pad(VALUE pad, VALUE pads)
486
529
  }
487
530
 
488
531
  static VALUE
489
- rb_gst_element_get_pads(VALUE self)
532
+ rg_pads(VALUE self)
490
533
  {
491
534
  VALUE pads;
492
535
 
@@ -504,7 +547,7 @@ rb_gst_element_get_pads(VALUE self)
504
547
  * Returns: a Gst::Pad object, or nil if the pad cannot be found.
505
548
  */
506
549
  static VALUE
507
- rb_gst_element_get_pad(VALUE self, VALUE pad_name)
550
+ rg_get_pad(VALUE self, VALUE pad_name)
508
551
  {
509
552
  GstPad *pad = gst_element_get_pad(SELF(self),
510
553
  RVAL2CSTR(pad_name));
@@ -524,13 +567,13 @@ rb_gst_element_get_pad(VALUE self, VALUE pad_name)
524
567
  * Returns: true on success, false on failure.
525
568
  */
526
569
  static VALUE
527
- rb_gst_element_link_pads(VALUE self, VALUE source_pad_name,
528
- VALUE other_element, VALUE destination_pad_name)
570
+ rg_link_pads(VALUE self, VALUE source_pad_name,
571
+ VALUE other_element, VALUE destination_pad_name)
529
572
  {
530
573
  return CBOOL2RVAL(gst_element_link_pads(SELF(self),
531
- RVAL2CSTR(source_pad_name),
532
- SELF(other_element),
533
- RVAL2CSTR(destination_pad_name)));
574
+ RVAL2CSTR(source_pad_name),
575
+ SELF(other_element),
576
+ RVAL2CSTR(destination_pad_name)));
534
577
  }
535
578
 
536
579
  /*
@@ -543,13 +586,13 @@ rb_gst_element_link_pads(VALUE self, VALUE source_pad_name,
543
586
  * Returns: self.
544
587
  */
545
588
  static VALUE
546
- rb_gst_element_unlink_pads(VALUE self, VALUE source_pad_name,
547
- VALUE other_element, VALUE destination_pad_name)
589
+ rg_unlink_pads(VALUE self, VALUE source_pad_name,
590
+ VALUE other_element, VALUE destination_pad_name)
548
591
  {
549
592
  gst_element_unlink_pads(SELF(self),
550
- RVAL2CSTR(source_pad_name),
551
- SELF(other_element),
552
- RVAL2CSTR(destination_pad_name));
593
+ RVAL2CSTR(source_pad_name),
594
+ SELF(other_element),
595
+ RVAL2CSTR(destination_pad_name));
553
596
  return self;
554
597
  }
555
598
 
@@ -557,21 +600,21 @@ rb_gst_element_unlink_pads(VALUE self, VALUE source_pad_name,
557
600
  * Returns: true if the element can be indexed, false otherwise.
558
601
  */
559
602
  static VALUE
560
- rb_gst_element_is_indexable(VALUE self)
603
+ rg_indexable_p(VALUE self)
561
604
  {
562
605
  return CBOOL2RVAL(gst_element_is_indexable(SELF(self)));
563
606
  }
564
607
 
565
608
  static void
566
- query_in_thread(gpointer data, gpointer user_data)
609
+ query_in_thread(gpointer data, G_GNUC_UNUSED gpointer user_data)
567
610
  {
568
611
  ThreadData *thread_data = (ThreadData *)data;
569
612
  QueryData *query_data;
570
613
 
571
614
  query_data = &(thread_data->data.query_data);
572
615
  query_data->result = gst_element_query(thread_data->element,
573
- query_data->query);
574
- write(thread_data->notify_fd, NOTIFY_MESSAGE, NOTIFY_MESSAGE_SIZE);
616
+ query_data->query);
617
+ notify(thread_data);
575
618
  }
576
619
 
577
620
  /*
@@ -583,36 +626,34 @@ query_in_thread(gpointer data, gpointer user_data)
583
626
  * Returns: true if the query is performed, false otherwise.
584
627
  */
585
628
  static VALUE
586
- rb_gst_element_query(VALUE self, VALUE query)
629
+ rg_query(VALUE self, VALUE query)
587
630
  {
588
631
  VALUE result;
589
- ThreadData *thread_data;
632
+ ThreadData thread_data;
590
633
  QueryData *query_data;
591
634
 
592
- thread_data = g_slice_new(ThreadData);
593
- thread_data->element = SELF(self);
594
- query_data = &(thread_data->data.query_data);
635
+ thread_data.element = SELF(self);
636
+ thread_data.context = "query";
637
+ query_data = &(thread_data.data.query_data);
595
638
  query_data->query = RVAL2GST_QUERY(query);
596
639
 
597
- do_in_thread(query_thread_pool, thread_data);
640
+ do_in_thread(query_thread_pool, &thread_data);
598
641
 
599
642
  result = CBOOL2RVAL(query_data->result);
600
643
 
601
- g_slice_free(ThreadData, thread_data);
602
-
603
644
  return result;
604
645
  }
605
646
 
606
647
  static void
607
- send_event_in_thread(gpointer data, gpointer user_data)
648
+ send_event_in_thread(gpointer data, G_GNUC_UNUSED gpointer user_data)
608
649
  {
609
650
  ThreadData *thread_data = (ThreadData *)data;
610
651
  SendEventData *send_event_data;
611
652
 
612
653
  send_event_data = &(thread_data->data.send_event_data);
613
654
  send_event_data->result = gst_element_send_event(thread_data->element,
614
- send_event_data->event);
615
- write(thread_data->notify_fd, NOTIFY_MESSAGE, NOTIFY_MESSAGE_SIZE);
655
+ send_event_data->event);
656
+ notify(thread_data);
616
657
  }
617
658
  /*
618
659
  * Method: send_event(event)
@@ -626,24 +667,22 @@ send_event_in_thread(gpointer data, gpointer user_data)
626
667
  * otherwise.
627
668
  */
628
669
  static VALUE
629
- rb_gst_element_send_event(VALUE self, VALUE event)
670
+ rg_send_event(VALUE self, VALUE event)
630
671
  {
631
672
  VALUE result;
632
- ThreadData *thread_data;
673
+ ThreadData thread_data;
633
674
  SendEventData *send_event_data;
634
675
 
635
- thread_data = g_slice_new(ThreadData);
636
- thread_data->element = SELF(self);
637
- send_event_data = &(thread_data->data.send_event_data);
676
+ thread_data.element = SELF(self);
677
+ thread_data.context = "send_event";
678
+ send_event_data = &(thread_data.data.send_event_data);
638
679
  send_event_data->event = RVAL2GST_EVENT(event);
639
680
 
640
681
  gst_event_ref(send_event_data->event);
641
- do_in_thread(send_event_thread_pool, thread_data);
682
+ do_in_thread(send_event_thread_pool, &thread_data);
642
683
 
643
684
  result = CBOOL2RVAL(send_event_data->result);
644
685
 
645
- g_slice_free(ThreadData, thread_data);
646
-
647
686
  return result;
648
687
  }
649
688
 
@@ -656,7 +695,7 @@ rb_gst_element_send_event(VALUE self, VALUE event)
656
695
  * element base time in Gst::Element::STATE_PAUSED, or -1 otherwise.
657
696
  */
658
697
  static VALUE
659
- rb_gst_element_get_base_time(VALUE self)
698
+ rg_base_time(VALUE self)
660
699
  {
661
700
  return ULL2NUM(gst_element_get_base_time(SELF(self)));
662
701
  }
@@ -673,7 +712,7 @@ rb_gst_element_get_base_time(VALUE self)
673
712
  * Returns: self.
674
713
  */
675
714
  static VALUE
676
- rb_gst_element_set_base_time(VALUE self, VALUE time)
715
+ rg_set_base_time(VALUE self, VALUE time)
677
716
  {
678
717
  gst_element_set_base_time(SELF(self), NUM2ULL(time));
679
718
  return Qnil;
@@ -687,7 +726,7 @@ rb_gst_element_set_base_time(VALUE self, VALUE time)
687
726
  * Returns: a Gst::Index or nil when no index was set on the element.
688
727
  */
689
728
  static VALUE
690
- rb_gst_element_get_index(VALUE self)
729
+ rg_index(VALUE self)
691
730
  {
692
731
  GstIndex *index = gst_element_get_index(SELF(self));
693
732
 
@@ -704,7 +743,7 @@ rb_gst_element_get_index(VALUE self)
704
743
  * Returns: self.
705
744
  */
706
745
  static VALUE
707
- rb_gst_element_set_index(VALUE self, VALUE index)
746
+ rg_set_index(VALUE self, VALUE index)
708
747
  {
709
748
  gst_element_set_index(SELF(self), RGST_INDEX(index));
710
749
  return self;
@@ -720,7 +759,7 @@ rb_gst_element_set_index(VALUE self, VALUE index)
720
759
  * Returns: the requested Gst::Pad if found, otherwise nil.
721
760
  */
722
761
  static VALUE
723
- rb_gst_element_get_static_pad(VALUE self, VALUE name)
762
+ rg_get_static_pad(VALUE self, VALUE name)
724
763
  {
725
764
  GstPad *pad =
726
765
  gst_element_get_static_pad(SELF(self), RVAL2CSTR(name));
@@ -737,7 +776,7 @@ rb_gst_element_get_static_pad(VALUE self, VALUE name)
737
776
  * Returns: the requested Gst::Pad if found, otherwise nil.
738
777
  */
739
778
  static VALUE
740
- rb_gst_element_get_request_pad(VALUE self, VALUE name)
779
+ rg_get_request_pad(VALUE self, VALUE name)
741
780
  {
742
781
  GstPad *pad =
743
782
  gst_element_get_request_pad(SELF(self), RVAL2CSTR(name));
@@ -754,7 +793,7 @@ rb_gst_element_get_request_pad(VALUE self, VALUE name)
754
793
  * Returns: self.
755
794
  */
756
795
  static VALUE
757
- rb_gst_element_release_request_pad(VALUE self, VALUE pad)
796
+ rg_release_request_pad(VALUE self, VALUE pad)
758
797
  {
759
798
  gst_element_release_request_pad(SELF(self), RGST_PAD(pad));
760
799
  return self;
@@ -770,7 +809,7 @@ rb_gst_element_release_request_pad(VALUE self, VALUE pad)
770
809
  * Returns: self.
771
810
  */
772
811
  static VALUE
773
- rb_gst_element_add_pad(VALUE self, VALUE pad)
812
+ rg_add_pad(VALUE self, VALUE pad)
774
813
  {
775
814
  gst_element_add_pad(SELF(self), RGST_PAD(pad));
776
815
  G_CHILD_ADD(self, pad);
@@ -786,7 +825,7 @@ rb_gst_element_add_pad(VALUE self, VALUE pad)
786
825
  * Returns: self.
787
826
  */
788
827
  static VALUE
789
- rb_gst_element_remove_pad(VALUE self, VALUE pad)
828
+ rg_remove_pad(VALUE self, VALUE pad)
790
829
  {
791
830
  gst_element_remove_pad(SELF(self), RGST_PAD(pad));
792
831
  return self;
@@ -801,7 +840,7 @@ rb_gst_element_remove_pad(VALUE self, VALUE pad)
801
840
  * Returns: the Gst::PadTemplate with the given name, or nil if none was found.
802
841
  */
803
842
  static VALUE
804
- rb_gst_element_get_pad_template(VALUE self, VALUE name)
843
+ rg_s_get_pad_template(VALUE self, VALUE name)
805
844
  {
806
845
  GstElementClass *element_class;
807
846
  GstPadTemplate *template;
@@ -820,7 +859,7 @@ rb_gst_element_get_pad_template(VALUE self, VALUE name)
820
859
  * Returns: an Array of Gst::PadTemplate objects.
821
860
  */
822
861
  static VALUE
823
- rb_gst_element_get_pad_templates(VALUE self)
862
+ rg_s_pad_templates(VALUE self)
824
863
  {
825
864
  GstElementClass *element_class;
826
865
  GList *list, *node;
@@ -846,9 +885,9 @@ rb_gst_element_get_pad_templates(VALUE self)
846
885
  * Returns: always nil.
847
886
  */
848
887
  static VALUE
849
- rb_gst_element_each_pad_template(VALUE self)
888
+ rg_s_each_pad_template(VALUE self)
850
889
  {
851
- return rb_ary_yield(rb_gst_element_get_pad_templates(self));
890
+ return rb_ary_yield(rg_s_pad_templates(self));
852
891
  }
853
892
 
854
893
  /*
@@ -861,7 +900,7 @@ rb_gst_element_each_pad_template(VALUE self)
861
900
  * Returns: true if the event was handled.
862
901
  */
863
902
  static VALUE
864
- rb_gst_element_seek(VALUE self, VALUE rate, VALUE format, VALUE flags,
903
+ rg_seek(VALUE self, VALUE rate, VALUE format, VALUE flags,
865
904
  VALUE cur_type, VALUE cur, VALUE stop_type, VALUE stop)
866
905
  {
867
906
  return CBOOL2RVAL(gst_element_seek(SELF(self),
@@ -885,7 +924,7 @@ rb_gst_element_seek(VALUE self, VALUE rate, VALUE format, VALUE flags,
885
924
  * Returns: true if the element's state is locked.
886
925
  */
887
926
  static VALUE
888
- rb_gst_element_is_locked_state(VALUE self)
927
+ rg_locked_state_p(VALUE self)
889
928
  {
890
929
  return CBOOL2RVAL(gst_element_is_locked_state(SELF(self)));
891
930
  }
@@ -900,7 +939,7 @@ rb_gst_element_is_locked_state(VALUE self)
900
939
  * Returns: self.
901
940
  */
902
941
  static VALUE
903
- rb_gst_element_set_locked_state(VALUE self, VALUE state)
942
+ rg_set_locked_state(VALUE self, VALUE state)
904
943
  {
905
944
  gst_element_set_locked_state(SELF(self), RVAL2CBOOL(state));
906
945
  return self;
@@ -915,7 +954,7 @@ rb_gst_element_set_locked_state(VALUE self, VALUE state)
915
954
  * Returns: true if the element's state could be synced to the parent's state.
916
955
  */
917
956
  static VALUE
918
- rb_gst_element_sync_state_with_parent(VALUE self)
957
+ rg_sync_state_with_parent(VALUE self)
919
958
  {
920
959
  return
921
960
  CBOOL2RVAL(gst_element_sync_state_with_parent(SELF(self)));
@@ -934,14 +973,14 @@ rb_gst_element_sync_state_with_parent(VALUE self)
934
973
  * Returns: self.
935
974
  */
936
975
  static VALUE
937
- rb_gst_element_no_more_pads(VALUE self)
976
+ rg_no_more_pads(VALUE self)
938
977
  {
939
978
  gst_element_no_more_pads(SELF(self));
940
979
  return self;
941
980
  }
942
981
 
943
- static VALUE
944
- rb_gst_element_found_tag_sig(guint num, const GValue *values)
982
+ static VALUE
983
+ rb_gst_element_found_tag_sig(G_GNUC_UNUSED guint n, const GValue *values)
945
984
  {
946
985
  GstElement *element, *source;
947
986
  GstTagList *tag_list;
@@ -963,13 +1002,15 @@ initialize_thread_pool(GThreadPool **pool, GFunc function)
963
1002
 
964
1003
  *pool = g_thread_pool_new(function, NULL, -1, FALSE, &error);
965
1004
  if (error)
966
- RAISE_GERROR(error);
1005
+ RAISE_GERROR(error);
967
1006
  }
968
1007
 
969
1008
  void
970
- Init_gst_element(void)
1009
+ Init_gst_element(VALUE mGst)
971
1010
  {
1011
+ memset(&table, 0, sizeof(table));
972
1012
  table.type = GST_TYPE_ELEMENT;
1013
+ table.klass = Qnil;
973
1014
  table.instance2robj = instance2robj;
974
1015
  RG_DEF_CONVERSION(&table);
975
1016
 
@@ -980,59 +1021,53 @@ Init_gst_element(void)
980
1021
  initialize_thread_pool(&query_thread_pool, query_in_thread);
981
1022
  initialize_thread_pool(&send_event_thread_pool, send_event_in_thread);
982
1023
 
983
- rb_cGstElement = G_DEF_CLASS(GST_TYPE_ELEMENT, "Element", mGst);
984
-
985
- rb_define_singleton_method(rb_cGstElement, "get_pad_template",
986
- rb_gst_element_get_pad_template, 1);
987
- rb_define_singleton_method(rb_cGstElement, "pad_templates",
988
- rb_gst_element_get_pad_templates, 0);
989
- rb_define_singleton_method(rb_cGstElement, "each_pad_template",
990
- rb_gst_element_each_pad_template, 0);
991
-
992
- rb_define_method(rb_cGstElement, "set_state", rb_gst_element_set_state, 1);
993
- rb_define_method(rb_cGstElement, "get_state", rb_gst_element_get_state, -1);
994
- rb_define_method(rb_cGstElement, "stop", rb_gst_element_stop, 0);
995
- rb_define_method(rb_cGstElement, "ready", rb_gst_element_ready, 0);
996
- rb_define_method(rb_cGstElement, "pause", rb_gst_element_pause, 0);
997
- rb_define_method(rb_cGstElement, "play", rb_gst_element_play, 0);
998
- rb_define_method(rb_cGstElement, "link", rb_gst_element_link, 1);
999
- rb_define_alias(rb_cGstElement, ">>", "link");
1000
- rb_define_method(rb_cGstElement, "unlink", rb_gst_element_unlink, 1);
1001
- rb_define_method(rb_cGstElement, "link_filtered", rb_gst_element_link_filtered, 2);
1002
- rb_define_method(rb_cGstElement, "provides_clock?", rb_gst_element_provides_clock, 0);
1003
- rb_define_alias(rb_cGstElement, "provide_clock?", "provides_clock?");
1004
- rb_define_method(rb_cGstElement, "requires_clock?", rb_gst_element_requires_clock, 0);
1005
- rb_define_alias(rb_cGstElement, "require_clock?", "requires_clock?");
1006
- rb_define_method(rb_cGstElement, "clock", rb_gst_element_get_clock, 0);
1007
- rb_define_method(rb_cGstElement, "set_clock", rb_gst_element_set_clock, 1);
1008
- rb_define_method(rb_cGstElement, "base_time", rb_gst_element_get_base_time, 0);
1009
- rb_define_method(rb_cGstElement, "set_base_time", rb_gst_element_set_base_time, 1);
1010
- rb_define_method(rb_cGstElement, "each_pad", rb_gst_element_each_pad, 0);
1011
- rb_define_method(rb_cGstElement, "pads", rb_gst_element_get_pads, 0);
1012
- rb_define_method(rb_cGstElement, "get_pad", rb_gst_element_get_pad, 1);
1013
- rb_define_alias(rb_cGstElement, "[]", "get_pad");
1014
- rb_define_method(rb_cGstElement, "get_static_pad", rb_gst_element_get_static_pad, 1);
1015
- rb_define_method(rb_cGstElement, "get_request_pad", rb_gst_element_get_request_pad, 1);
1016
- rb_define_method(rb_cGstElement, "release_request_pad",
1017
- rb_gst_element_release_request_pad, 1);
1018
- rb_define_method(rb_cGstElement, "link_pads", rb_gst_element_link_pads, 3);
1019
- rb_define_method(rb_cGstElement, "unlink_pads", rb_gst_element_unlink_pads, 3);
1020
- rb_define_method(rb_cGstElement, "add_pad", rb_gst_element_add_pad, 1);
1021
- rb_define_method(rb_cGstElement, "remove_pad", rb_gst_element_remove_pad, 1);
1022
- rb_define_method(rb_cGstElement, "indexable?", rb_gst_element_is_indexable, 0);
1023
- rb_define_method(rb_cGstElement, "query", rb_gst_element_query, 1);
1024
- rb_define_method(rb_cGstElement, "send_event", rb_gst_element_send_event, 1);
1025
- rb_define_method(rb_cGstElement, "seek", rb_gst_element_seek, 7);
1026
- rb_define_method(rb_cGstElement, "index", rb_gst_element_get_index, 0);
1027
- rb_define_method(rb_cGstElement, "set_index", rb_gst_element_set_index, 1);
1028
- rb_define_method(rb_cGstElement, "locked_state?", rb_gst_element_is_locked_state, 0);
1029
- rb_define_method(rb_cGstElement, "set_locked_state", rb_gst_element_set_locked_state,
1030
- 1);
1031
- rb_define_method(rb_cGstElement, "sync_state_with_parent",
1032
- rb_gst_element_sync_state_with_parent, 0);
1033
- rb_define_method(rb_cGstElement, "no_more_pads", rb_gst_element_no_more_pads, 0);
1034
-
1035
- G_DEF_SETTERS(rb_cGstElement);
1024
+ RG_TARGET_NAMESPACE = G_DEF_CLASS(GST_TYPE_ELEMENT, "Element", mGst);
1025
+
1026
+ RG_DEF_SMETHOD(get_pad_template, 1);
1027
+ RG_DEF_SMETHOD(pad_templates, 0);
1028
+ RG_DEF_SMETHOD(each_pad_template, 0);
1029
+
1030
+ RG_DEF_METHOD(set_state, 1);
1031
+ RG_DEF_METHOD(get_state, -1);
1032
+ RG_DEF_METHOD(stop, 0);
1033
+ RG_DEF_METHOD(ready, 0);
1034
+ RG_DEF_METHOD(pause, 0);
1035
+ RG_DEF_METHOD(play, 0);
1036
+ RG_DEF_METHOD(link, 1);
1037
+ RG_DEF_ALIAS(">>", "link");
1038
+ RG_DEF_METHOD(unlink, 1);
1039
+ RG_DEF_METHOD(link_filtered, 2);
1040
+ RG_DEF_METHOD_P(provides_clock, 0);
1041
+ RG_DEF_ALIAS("provide_clock?", "provides_clock?");
1042
+ RG_DEF_METHOD_P(requires_clock, 0);
1043
+ RG_DEF_ALIAS("require_clock?", "requires_clock?");
1044
+ RG_DEF_METHOD(clock, 0);
1045
+ RG_DEF_METHOD(set_clock, 1);
1046
+ RG_DEF_METHOD(base_time, 0);
1047
+ RG_DEF_METHOD(set_base_time, 1);
1048
+ RG_DEF_METHOD(each_pad, 0);
1049
+ RG_DEF_METHOD(pads, 0);
1050
+ RG_DEF_METHOD(get_pad, 1);
1051
+ RG_DEF_ALIAS("[]", "get_pad");
1052
+ RG_DEF_METHOD(get_static_pad, 1);
1053
+ RG_DEF_METHOD(get_request_pad, 1);
1054
+ RG_DEF_METHOD(release_request_pad, 1);
1055
+ RG_DEF_METHOD(link_pads, 3);
1056
+ RG_DEF_METHOD(unlink_pads, 3);
1057
+ RG_DEF_METHOD(add_pad, 1);
1058
+ RG_DEF_METHOD(remove_pad, 1);
1059
+ RG_DEF_METHOD_P(indexable, 0);
1060
+ RG_DEF_METHOD(query, 1);
1061
+ RG_DEF_METHOD(send_event, 1);
1062
+ RG_DEF_METHOD(seek, 7);
1063
+ RG_DEF_METHOD(index, 0);
1064
+ RG_DEF_METHOD(set_index, 1);
1065
+ RG_DEF_METHOD_P(locked_state, 0);
1066
+ RG_DEF_METHOD(set_locked_state, 1);
1067
+ RG_DEF_METHOD(sync_state_with_parent, 0);
1068
+ RG_DEF_METHOD(no_more_pads, 0);
1069
+
1070
+ G_DEF_SETTERS(RG_TARGET_NAMESPACE);
1036
1071
 
1037
1072
  G_DEF_CLASS(GST_TYPE_STATE, "State", mGst);
1038
1073
  G_DEF_CONSTANTS(mGst, GST_TYPE_STATE, "GST_");
@@ -1040,14 +1075,14 @@ Init_gst_element(void)
1040
1075
  G_DEF_CONSTANTS(mGst, GST_TYPE_STATE_CHANGE_RETURN, "GST_");
1041
1076
  G_DEF_CLASS(GST_TYPE_STATE_CHANGE, "StateChange", mGst);
1042
1077
  G_DEF_CONSTANTS(mGst, GST_TYPE_STATE_CHANGE, "GST_");
1043
- G_DEF_CLASS(GST_TYPE_ELEMENT_FLAGS, "Flags", rb_cGstElement);
1044
- G_DEF_CONSTANTS(rb_cGstElement, GST_TYPE_ELEMENT_FLAGS, "GST_ELEMENT_");
1078
+ G_DEF_CLASS(GST_TYPE_ELEMENT_FLAGS, "Flags", RG_TARGET_NAMESPACE);
1079
+ G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GST_TYPE_ELEMENT_FLAGS, "GST_ELEMENT_");
1045
1080
 
1046
1081
  /*
1047
1082
  * TODO:
1048
1083
  * gst_element_clock_wait()
1049
1084
  */
1050
1085
 
1051
- G_DEF_SIGNAL_FUNC(rb_cGstElement, "found-tag",
1086
+ G_DEF_SIGNAL_FUNC(RG_TARGET_NAMESPACE, "found-tag",
1052
1087
  (GValToRValSignalFunc)rb_gst_element_found_tag_sig);
1053
1088
  }