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
data/README ADDED
@@ -0,0 +1,33 @@
1
+ Ruby/GStreamer
2
+ ==============
3
+
4
+ Ruby/GStreamer is a Ruby binding for GStreamer.
5
+
6
+ Requirements
7
+ ------------
8
+
9
+ Ruby: http://www.ruby-lang.org/
10
+ GStreamer: http://gstreamer.freedesktop.org/
11
+
12
+ Install
13
+ -------
14
+
15
+ 0. install Ruby (>= 1.8.x) and GStreamer (>= 0.10.x).
16
+ 1. ruby extconf.rb
17
+ 2. make
18
+ 3. su
19
+ 4. make install
20
+
21
+ Copying
22
+ -------
23
+
24
+ Copyright (c) 2002-2005 Ruby-GNOME2 Project Team
25
+
26
+ This program is free software.
27
+ You can distribute/modify this program under the terms of
28
+ the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1.
29
+
30
+ Project Website
31
+ ---------------
32
+
33
+ http://ruby-gnome2.sourceforge.jp
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ # -*- ruby -*-
2
+
3
+ require './../glib2/lib/gnome2-raketask'
4
+
5
+ package = GNOME2Package.new do |_package|
6
+ _package.summary = "Ruby/GStreamer is a Ruby binding for GStreamer."
7
+ _package.description = "Ruby/GStreamer is a Ruby binding for GStreamer."
8
+ _package.dependency.gem.runtime = ["glib2"]
9
+ # TODO: use http://code.google.com/p/ossbuild/downloads/list ???
10
+ _package.win32.packages = []
11
+ _package.win32.dependencies = []
12
+ _package.post_install_message = "This library is experimental."
13
+ end
14
+ package.define_tasks
15
+
@@ -0,0 +1,162 @@
1
+
2
+ SHELL = /bin/sh
3
+
4
+ #### Start of system configuration section. ####
5
+
6
+ srcdir = /home/kou/work/ruby/ruby-gnome2/gstreamer/ext/gstreamer
7
+ topdir = /usr/lib/ruby/1.8/x86_64-linux
8
+ hdrdir = $(topdir)
9
+ VPATH = $(srcdir):$(topdir):$(hdrdir)
10
+ exec_prefix = $(prefix)
11
+ prefix = $(DESTDIR)/usr
12
+ sharedstatedir = $(prefix)/com
13
+ mandir = $(prefix)/share/man
14
+ psdir = $(docdir)
15
+ oldincludedir = $(DESTDIR)/usr/include
16
+ localedir = $(datarootdir)/locale
17
+ bindir = $(exec_prefix)/bin
18
+ libexecdir = $(prefix)/lib/ruby1.8
19
+ sitedir = $(DESTDIR)/usr/local/lib/site_ruby
20
+ htmldir = $(docdir)
21
+ vendorarchdir = $(vendorlibdir)/$(sitearch)
22
+ includedir = $(prefix)/include
23
+ infodir = $(prefix)/share/info
24
+ vendorlibdir = $(vendordir)/$(ruby_version)
25
+ sysconfdir = $(DESTDIR)/etc
26
+ libdir = $(exec_prefix)/lib
27
+ sbindir = $(exec_prefix)/sbin
28
+ rubylibdir = $(libdir)/ruby/$(ruby_version)
29
+ docdir = $(datarootdir)/doc/$(PACKAGE)
30
+ dvidir = $(docdir)
31
+ vendordir = $(libdir)/ruby/vendor_ruby
32
+ datarootdir = $(prefix)/share
33
+ pdfdir = $(docdir)
34
+ archdir = $(rubylibdir)/$(arch)
35
+ sitearchdir = $(sitelibdir)/$(sitearch)
36
+ datadir = $(datarootdir)
37
+ localstatedir = $(DESTDIR)/var
38
+ sitelibdir = $(sitedir)/$(ruby_version)
39
+
40
+ CC = gcc
41
+ LIBRUBY = $(LIBRUBY_SO)
42
+ LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
43
+ LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
44
+ LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
45
+
46
+ RUBY_EXTCONF_H =
47
+ CFLAGS = -fPIC -fno-strict-aliasing -g -g -O2 -fPIC $(cflags) -Wall -I/usr/include/gstreamer-0.10 -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -pthread -I/usr/include/gstreamer-0.10 -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -pthread -DHAVE_GST_OVERLAY -I/usr/include/gstreamer-0.10 -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -pthread -DHAVE_GST_PBUTILS
48
+ INCFLAGS = -I. -I/home/kou/work/ruby/ruby-gnome2/glib2/ext/glib2 -I/home/kou/work/ruby/ruby-gnome2/glib2/ext/glib2 -I/home/kou/work/ruby/ruby-gnome2/glib2/ext/glib2 -I. -I/usr/lib/ruby/1.8/x86_64-linux -I/home/kou/work/ruby/ruby-gnome2/gstreamer/ext/gstreamer
49
+ DEFS =
50
+ CPPFLAGS = -DHAVE_RB_DEFINE_ALLOC_FUNC -DHAVE_RB_BLOCK_PROC -DHAVE_OBJECT_ALLOCATE -DHAVE_NODE_ATTRASGN -DHAVE_UNISTD_H -DHAVE_GST_INTERFACES_XOVERLAY_H -DRUBY_GST_COMPILATION
51
+ CXXFLAGS = $(CFLAGS)
52
+ ldflags = -L. -rdynamic -Wl,-export-dynamic -pthread -pthread -pthread
53
+ dldflags =
54
+ archflag =
55
+ DLDFLAGS = $(ldflags) $(dldflags) $(archflag)
56
+ LDSHARED = $(CC) -shared
57
+ AR = ar
58
+ EXEEXT =
59
+
60
+ RUBY_INSTALL_NAME = ruby1.8
61
+ RUBY_SO_NAME = ruby1.8
62
+ arch = x86_64-linux
63
+ sitearch = x86_64-linux
64
+ ruby_version = 1.8
65
+ ruby = /usr/bin/ruby1.8
66
+ RUBY = $(ruby)
67
+ RM = rm -f
68
+ MAKEDIRS = mkdir -p
69
+ INSTALL = /usr/bin/install -c
70
+ INSTALL_PROG = $(INSTALL) -m 0755
71
+ INSTALL_DATA = $(INSTALL) -m 644
72
+ COPY = cp
73
+
74
+ #### End of system configuration section. ####
75
+
76
+ preload =
77
+
78
+ libpath = . $(libdir)
79
+ LIBPATH = -L. -L$(libdir)
80
+ DEFFILE =
81
+
82
+ CLEANFILES = mkmf.log
83
+ DISTCLEANFILES =
84
+
85
+ extout =
86
+ extout_prefix =
87
+ target_prefix =
88
+ LOCAL_LIBS =
89
+ LIBS = $(LIBRUBYARG_SHARED) -lgstinterfaces-0.10 -lgstreamer-0.10 -lglib-2.0 -lgobject-2.0 -lgthread-2.0 -lrt -lgmodule-2.0 -lxml2 -lgstreamer-0.10 -lglib-2.0 -lgobject-2.0 -lgthread-2.0 -lrt -lgmodule-2.0 -lxml2 -lgstpbutils-0.10 -lgstreamer-0.10 -lglib-2.0 -lgobject-2.0 -lgthread-2.0 -lrt -lgmodule-2.0 -lxml2 -lpthread -lrt -ldl -lcrypt -lm -lc
90
+ SRCS = rbgstxml.c rbgsttagsetter.c rbgstindex.c rbgst-message.c rbgst-clock.c rbgst-pad.c rbgstquerytype.c rbgstformat.c rbgst-seek.c rbgst-index-factory.c misc.c rbgst-event.c rbgst-pad-template.c rbgst.c rbgstregistry.c rbgstparse.c rbgst-static-pad-template.c rbgst-structure.c rbgst-system-clock.c rbgst-type-find-factory.c rbgst-plugin.c rbgst-static-caps.c rbgst-bus.c rbgst-mini-object.c rbgst-object.c rbgst-private.c rbgst-element-factory.c rbgstclockentry.c rbgst-bin.c rbgst-ghost-pad.c rbgstindexentry.c rbgst-plugin-feature.c rbgst-pipeline.c rbgst-child-proxy.c rbgsttag.c rbgst-buffer.c rbgst-query.c rbgst-x-overlay.c rbgst-caps.c rbgst-element.c rbgst-value.c
91
+ OBJS = rbgstxml.o rbgsttagsetter.o rbgstindex.o rbgst-message.o rbgst-clock.o rbgst-pad.o rbgstquerytype.o rbgstformat.o rbgst-seek.o rbgst-index-factory.o misc.o rbgst-event.o rbgst-pad-template.o rbgst.o rbgstregistry.o rbgstparse.o rbgst-static-pad-template.o rbgst-structure.o rbgst-system-clock.o rbgst-type-find-factory.o rbgst-plugin.o rbgst-static-caps.o rbgst-bus.o rbgst-mini-object.o rbgst-object.o rbgst-private.o rbgst-element-factory.o rbgstclockentry.o rbgst-bin.o rbgst-ghost-pad.o rbgstindexentry.o rbgst-plugin-feature.o rbgst-pipeline.o rbgst-child-proxy.o rbgsttag.o rbgst-buffer.o rbgst-query.o rbgst-x-overlay.o rbgst-caps.o rbgst-element.o rbgst-value.o
92
+ TARGET = gst
93
+ DLLIB = $(TARGET).so
94
+ EXTSTATIC =
95
+ STATIC_LIB =
96
+
97
+ BINDIR = $(bindir)
98
+ RUBYCOMMONDIR = $(sitedir)$(target_prefix)
99
+ RUBYLIBDIR = $(sitelibdir)$(target_prefix)
100
+ RUBYARCHDIR = $(sitearchdir)$(target_prefix)
101
+
102
+ TARGET_SO = $(DLLIB)
103
+ CLEANLIBS = $(TARGET).so $(TARGET).il? $(TARGET).tds $(TARGET).map
104
+ CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
105
+
106
+ all: $(DLLIB)
107
+ static: $(STATIC_LIB)
108
+
109
+ clean:
110
+ @-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
111
+
112
+ distclean: clean
113
+ @-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
114
+ @-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
115
+
116
+ realclean: distclean
117
+ install: install-so install-rb
118
+
119
+ install-so: $(RUBYARCHDIR)
120
+ install-so: $(RUBYARCHDIR)/$(DLLIB)
121
+ $(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
122
+ $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
123
+ install-rb: pre-install-rb install-rb-default
124
+ install-rb-default: pre-install-rb-default
125
+ pre-install-rb: Makefile
126
+ pre-install-rb-default: Makefile
127
+ $(RUBYARCHDIR):
128
+ $(MAKEDIRS) $@
129
+
130
+ site-install: site-install-so site-install-rb
131
+ site-install-so: install-so
132
+ site-install-rb: install-rb
133
+
134
+ .SUFFIXES: .c .m .cc .cxx .cpp .C .o
135
+
136
+ .cc.o:
137
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
138
+
139
+ .cxx.o:
140
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
141
+
142
+ .cpp.o:
143
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
144
+
145
+ .C.o:
146
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
147
+
148
+ .c.o:
149
+ $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
150
+
151
+ $(DLLIB): $(OBJS) Makefile
152
+ @-$(RM) $@
153
+ $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
154
+
155
+
156
+
157
+ ###
158
+ install:
159
+ if test -n "$(pkgconfigdir)"; then \
160
+ $(MAKEDIRS) $(pkgconfigdir); \
161
+ $(INSTALL_DATA) ../ruby-gstreamer.pc $(pkgconfigdir); \
162
+ fi
@@ -0,0 +1,5 @@
1
+ install:
2
+ if test -n "$(pkgconfigdir)"; then \
3
+ $(MAKEDIRS) $(pkgconfigdir); \
4
+ $(INSTALL_DATA) ../ruby-gstreamer.pc $(pkgconfigdir); \
5
+ fi
@@ -0,0 +1,63 @@
1
+ =begin
2
+ extconf.rb for Ruby/GStreamer extention library
3
+ =end
4
+
5
+ require 'pathname'
6
+
7
+ base_dir = Pathname(__FILE__).dirname.parent.parent.expand_path
8
+ top_dir = base_dir.parent
9
+ top_build_dir = Pathname(".").parent.parent.parent.expand_path
10
+
11
+ mkmf_gnome2_dir = top_dir + "glib2" + 'lib'
12
+ version_suffix = ""
13
+ unless mkmf_gnome2_dir.exist?
14
+ if /(-\d+\.\d+\.\d+)\z/ =~ base_dir.basename.to_s
15
+ version_suffix = $1
16
+ mkmf_gnome2_dir = top_dir + "glib2#{version_suffix}" + 'lib'
17
+ end
18
+ end
19
+
20
+ $LOAD_PATH.unshift(mkmf_gnome2_dir.to_s)
21
+
22
+ module_name = "gst"
23
+ package_id = "gstreamer-0.10"
24
+
25
+ require 'mkmf-gnome2'
26
+
27
+ setup_win32(module_name, base_dir)
28
+
29
+ PKGConfig.have_package(package_id) or exit 1
30
+ PKGConfig.have_package('gstreamer-plugins-base-0.10') or exit 1
31
+
32
+ have_header("unistd.h")
33
+ have_header("io.h")
34
+
35
+ if have_library("gstinterfaces-0.10") and
36
+ have_header("gst/interfaces/xoverlay.h")
37
+ $CFLAGS += " -DHAVE_GST_OVERLAY"
38
+ end
39
+
40
+ if PKGConfig.have_package("gstreamer-pbutils-0.10")
41
+ $CFLAGS += " -DHAVE_GST_PBUTILS"
42
+ end
43
+
44
+ ["glib2"].each do |package|
45
+ directory = "#{package}#{version_suffix}"
46
+ build_dir = "#{directory}/tmp/#{RUBY_PLATFORM}/#{package}/#{RUBY_VERSION}"
47
+ add_depend_package(package, "#{directory}/ext/#{package}",
48
+ top_dir.to_s,
49
+ :top_build_dir => top_build_dir.to_s,
50
+ :target_build_dir => build_dir)
51
+ end
52
+
53
+ create_pkg_config_file("Ruby/GStreamer", package_id)
54
+ $defs << "-DRUBY_GST_COMPILATION"
55
+ create_makefile(module_name)
56
+ pkg_config_dir = with_config("pkg-config-dir")
57
+ if pkg_config_dir.is_a?(String)
58
+ File.open("Makefile", "ab") do |makefile|
59
+ makefile.puts
60
+ makefile.puts("pkgconfigdir=#{pkg_config_dir}")
61
+ end
62
+ end
63
+
Binary file
@@ -0,0 +1,62 @@
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
+ VALUE
24
+ rb_str_new_with_format (char *fmt, ...)
25
+ {
26
+ char buf[1000];
27
+ va_list ap;
28
+
29
+ va_start (ap, fmt);
30
+ vsnprintf (buf, sizeof buf, fmt, ap);
31
+ va_end (ap);
32
+ return CSTR2RVAL (buf);
33
+ }
34
+
35
+ VALUE
36
+ rb_ary_yield (VALUE arr)
37
+ {
38
+ if (rb_block_given_p () == Qfalse)
39
+ rb_raise (rb_eArgError, "No block given");
40
+ rb_ary_each (arr);
41
+ return Qnil;
42
+ }
43
+
44
+ VALUE
45
+ rbgst_new_gstobject (void *o)
46
+ {
47
+ GType gtype = G_OBJECT_TYPE (o);
48
+ const gchar *gtypename = g_type_name (gtype);
49
+ if (strncmp (gtypename, "Gst", 3) == 0)
50
+ gtypename += 3;
51
+ if (!rb_const_defined_at (mGst, rb_intern (gtypename)))
52
+ G_DEF_CLASS (gtype, gtypename, mGst);
53
+ return GOBJ2RVAL (o);
54
+ }
55
+
56
+ void
57
+ rbgst_initialize_gstobject(VALUE obj, GstObject *gstobj)
58
+ {
59
+ gstobj = gst_object_ref (gstobj);
60
+ gst_object_sink (gstobj);
61
+ G_INITIALIZE (obj, gstobj);
62
+ }
Binary file
@@ -0,0 +1,466 @@
1
+ /*
2
+ * Copyright (C) 2003, 2004 Laurent Sansonetti <lrz@gnome.org>
3
+ * 2004 Erwan Loisant <erwan@loisant.org>
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
+ #define SELF(self) RVAL2GST_BIN(self)
26
+
27
+ /* Class: Gst::Bin
28
+ * Base container element.
29
+ */
30
+
31
+ /*
32
+ * Class method: new(name=nil)
33
+ * name: a name for the bin.
34
+ *
35
+ * Constructs a new Gst::Bin object.
36
+ *
37
+ * If element name is ommited (or nil), then the bin will receive a guaranteed
38
+ * unique name, consisting of the "bin" string and a number.
39
+ * If name is given, it will be given the name supplied.
40
+ *
41
+ * Returns: a newly allocated Gst::Bin object.
42
+ */
43
+ static VALUE
44
+ rb_gst_bin_initialize(int argc, VALUE *argv, VALUE self)
45
+ {
46
+ GstElement *bin;
47
+ VALUE name;
48
+
49
+ rb_scan_args(argc, argv, "01", &name);
50
+
51
+ bin = gst_bin_new(RVAL2CSTR_ACCEPT_NIL(name));
52
+ if (bin)
53
+ RBGST_INITIALIZE(self, bin);
54
+ return Qnil;
55
+ }
56
+
57
+ /*
58
+ * Method: size
59
+ *
60
+ * Returns: the number of elements in the container.
61
+ */
62
+ static VALUE
63
+ rb_gst_bin_size(VALUE self)
64
+ {
65
+ return INT2NUM(GST_BIN_NUMCHILDREN(SELF(self)));
66
+ }
67
+
68
+ /*
69
+ * Method: children(interface=nil)
70
+ * interface: an interface (Ruby class).
71
+ *
72
+ * Returns: If interface is nil, an array of all
73
+ * Gst::Element objects in the container. Otherwise, an
74
+ * array of Gst::Element objects in the container that
75
+ * implements the interface.
76
+ */
77
+ static VALUE
78
+ rb_gst_bin_get_children(int argc, VALUE *argv, VALUE self)
79
+ {
80
+ VALUE children, iface;
81
+
82
+ rb_scan_args(argc, argv, "01", &iface);
83
+
84
+ if (NIL_P(iface)) {
85
+ const GList *node;
86
+ children = rb_ary_new();
87
+ for (node = GST_BIN_CHILDREN(SELF(self));
88
+ node;
89
+ node = g_list_next(node)) {
90
+ rb_ary_push(children, GST_ELEMENT2RVAL(node->data));
91
+ }
92
+ } else {
93
+ GstIterator *iter;
94
+ iter = gst_bin_iterate_all_by_interface(SELF(self),
95
+ CLASS2GTYPE(iface));
96
+ children = _rbgst_collect_elements(iter);
97
+ }
98
+
99
+ return children;
100
+ }
101
+
102
+ /*
103
+ * Method: children_recurse()
104
+ *
105
+ * Returns: an array of all Gst::Element objects in the container and child
106
+ * bins.
107
+ */
108
+ static VALUE
109
+ rb_gst_bin_get_children_recurse(VALUE self)
110
+ {
111
+ GstIterator *iter;
112
+ VALUE children;
113
+
114
+ iter = gst_bin_iterate_recurse(SELF(self));
115
+ children = _rbgst_collect_elements(iter);
116
+
117
+ return children;
118
+ }
119
+
120
+ static VALUE
121
+ rb_gst_bin_get_children_cookie(VALUE self)
122
+ {
123
+ return UINT2NUM(GST_BIN_CHILDREN_COOKIE(SELF(self)));
124
+ }
125
+
126
+ static VALUE
127
+ rb_gst_bin_get_child_bus(VALUE self)
128
+ {
129
+ return GST_BUS2RVAL(SELF(self)->child_bus);
130
+ }
131
+
132
+ static VALUE
133
+ rb_gst_bin_get_messages(VALUE self)
134
+ {
135
+ GList *node;
136
+ VALUE messages;
137
+
138
+ messages = rb_ary_new();
139
+ for (node = SELF(self)->messages; node; node = g_list_next(node)) {
140
+ rb_ary_push(messages, GST_MSG2RVAL(node->data));
141
+ }
142
+
143
+ return messages;
144
+ }
145
+
146
+ static VALUE
147
+ rb_gst_bin_polling_p(VALUE self)
148
+ {
149
+ return CBOOL2RVAL(SELF(self)->polling);
150
+ }
151
+
152
+ static VALUE
153
+ rb_gst_bin_clock_dirty_p(VALUE self)
154
+ {
155
+ return CBOOL2RVAL(SELF(self)->clock_dirty);
156
+ }
157
+
158
+ /*
159
+ * Method: provided_clock
160
+ *
161
+ * Gets the current clock of the (scheduler of the) bin,
162
+ * as a Gst::Clock object.
163
+ *
164
+ * Returns: a Gst::Clock object, or nil.
165
+ */
166
+ static VALUE
167
+ rb_gst_bin_get_provided_clock(VALUE self)
168
+ {
169
+ return GST_CLOCK2RVAL(SELF(self)->provided_clock);
170
+ }
171
+
172
+ /*
173
+ * Method: provided_clock=(clock)
174
+ * clock: a Gst::Clock.
175
+ *
176
+ * Forces the bin to use the given clock. Use nil to force it
177
+ * to use no clock at all.
178
+ *
179
+ * Returns: self.
180
+ */
181
+ static VALUE
182
+ rb_gst_bin_set_provided_clock(VALUE self, VALUE clock)
183
+ {
184
+ GstBin *bin;
185
+
186
+ bin = SELF(self);
187
+ if (bin->provided_clock)
188
+ g_object_unref(bin->provided_clock);
189
+
190
+ bin->provided_clock = RVAL2GST_CLOCK(clock);
191
+ if (bin->provided_clock)
192
+ g_object_ref(bin->provided_clock);
193
+
194
+ return self;
195
+ }
196
+
197
+ static VALUE
198
+ rb_gst_bin_get_clock_provider(VALUE self)
199
+ {
200
+ return GST_ELEMENT2RVAL(SELF(self)->clock_provider);
201
+ }
202
+
203
+ /*
204
+ * Method: <<(element)
205
+ * element: a Gst::Element object.
206
+ *
207
+ * Adds a Gst::Element object to the bin.
208
+ *
209
+ * Returns: self.
210
+ */
211
+ static VALUE
212
+ rb_gst_bin_add(VALUE self, VALUE element)
213
+ {
214
+ VALUE klass = GTYPE2CLASS(GST_TYPE_ELEMENT);
215
+
216
+ if (!RVAL2CBOOL(rb_obj_is_kind_of(element, klass))) {
217
+ rb_raise(rb_eTypeError, "Gst::Element expected");
218
+ }
219
+ gst_bin_add(SELF(self), RVAL2GST_ELEMENT(element));
220
+ G_CHILD_ADD(self, element);
221
+ return self;
222
+ }
223
+
224
+ /*
225
+ * Method: add(*elements)
226
+ * elements: a list of Gst::Element objects.
227
+ *
228
+ * Adds one or more Gst::Element objects to the bin.
229
+ *
230
+ * Returns: nil.
231
+ */
232
+ static VALUE
233
+ rb_gst_bin_add_multi(int argc, VALUE *argv, VALUE self)
234
+ {
235
+ int i;
236
+
237
+ for (i = 0; i < argc; i++) {
238
+ rb_gst_bin_add(self, argv[i]);
239
+ }
240
+ return Qnil;
241
+ }
242
+
243
+
244
+ /*
245
+ * Method: remove(*elements)
246
+ * elements: a list of Gst::Element objects.
247
+ *
248
+ * Removes one or more Gst::Element objects from the bin, unparenting
249
+ * as well.
250
+ *
251
+ * Returns: nil.
252
+ */
253
+ static VALUE
254
+ rb_gst_bin_remove(int argc, VALUE *argv, VALUE self)
255
+ {
256
+ int i;
257
+ GstBin *bin;
258
+
259
+ bin = SELF(self);
260
+ for (i = 0; i < argc; i++) {
261
+ G_CHILD_REMOVE(self, argv[i]);
262
+ gst_bin_remove(bin, RVAL2GST_ELEMENT(argv[i]));
263
+ }
264
+ return Qnil;
265
+ }
266
+
267
+ /*
268
+ * Method: clear
269
+ *
270
+ * Removes all Gst::Element objects in the bin.
271
+ *
272
+ * Returns: nil.
273
+ */
274
+ static VALUE
275
+ rb_gst_bin_clear(VALUE self)
276
+ {
277
+ GstBin *bin;
278
+ GList *node, *children;
279
+
280
+ bin = SELF(self);
281
+ children = g_list_copy(GST_BIN_CHILDREN(bin));
282
+ for (node = children; node; node = g_list_next(node)) {
283
+ gst_bin_remove(bin, node->data);
284
+ }
285
+ g_list_free(children);
286
+ return Qnil;
287
+ }
288
+
289
+ /*
290
+ * Method: each(interface=nil) {|element| ...}
291
+ *
292
+ * Calls the block for each element in the bin, passing a reference to
293
+ * the Gst::Element as parameter. If the interface isn't nil,
294
+ * iterated elements should implement the interface.
295
+ *
296
+ * Returns: always nil.
297
+ */
298
+ static VALUE
299
+ rb_gst_bin_each_element(int argc, VALUE *argv, VALUE self)
300
+ {
301
+ return rb_ary_yield(rb_gst_bin_get_children(argc, argv, self));
302
+ }
303
+
304
+ /*
305
+ * Method: each_recurse() {|element| ...}
306
+ *
307
+ * Calls the block for each element in the bin and its child bins, passing a
308
+ * reference to the Gst::Element as parameter.
309
+ *
310
+ * Returns: always nil.
311
+ */
312
+ static VALUE
313
+ rb_gst_bin_each_recurse_element(VALUE self)
314
+ {
315
+ return rb_ary_yield(rb_gst_bin_get_children_recurse(self));
316
+ }
317
+
318
+ /*
319
+ * Method: get_child(index)
320
+ * Method: get_child(name, recurse=false)
321
+ * Method: get_child(interface)
322
+ * index: an index.
323
+ * name: a name.
324
+ * recurse: search recursively.
325
+ * interface: an interface (Ruby class).
326
+ *
327
+ * 1st: Gets the index-th element.
328
+ *
329
+ * 2nd: Gets the element with the given name from the
330
+ * bin, as a reference to a Gst::Element object. If the
331
+ * element is not found and recurse is true, a recursion is
332
+ * performed on the parent bin.
333
+ *
334
+ * 3nd: Looks for the first element inside the bin that implements the
335
+ * given interface. If such an element is found, it returns the element.
336
+ * If you want all elements that implement the interface, use
337
+ * Gst::Bin#get_all_by_interface. The method recurses bins inside bins.
338
+ *
339
+ * Returns: a Gst::Element reference, or nil if the bin does not contain
340
+ * an element with the given name nor implementing the interface.
341
+ */
342
+ static VALUE
343
+ rb_gst_bin_get(int argc, VALUE *argv, VALUE self)
344
+ {
345
+ VALUE index_or_name_or_interface, recurse;
346
+ GstElement *element = NULL;
347
+
348
+ rb_scan_args(argc, argv, "11", &index_or_name_or_interface, &recurse);
349
+
350
+ if (RVAL2CBOOL(rb_obj_is_kind_of(index_or_name_or_interface, rb_cInteger))) {
351
+ int index;
352
+ GList *node;
353
+ index = NUM2INT(index_or_name_or_interface);
354
+ node = g_list_nth(GST_BIN_CHILDREN(SELF(self)), index);
355
+ if (node)
356
+ element = node->data;
357
+ } else if (RVAL2CBOOL(rb_obj_is_kind_of(index_or_name_or_interface,
358
+ rb_cString))) {
359
+ char *name;
360
+ name = RVAL2CSTR(index_or_name_or_interface);
361
+
362
+ if (RVAL2CBOOL(recurse)) {
363
+ element = gst_bin_get_by_name_recurse_up(SELF(self), name);
364
+ } else {
365
+ element = gst_bin_get_by_name(SELF(self), name);
366
+ }
367
+ } else {
368
+ GType iface;
369
+ iface = CLASS2GTYPE(index_or_name_or_interface);
370
+ element = gst_bin_get_by_interface(SELF(self), iface);
371
+ }
372
+
373
+ return GST_ELEMENT2RVAL(element);
374
+ }
375
+
376
+ static VALUE
377
+ rb_gst_bin_get_sinks(VALUE self)
378
+ {
379
+ return _rbgst_collect_elements(gst_bin_iterate_sinks(SELF(self)));
380
+ }
381
+
382
+ static VALUE
383
+ rb_gst_bin_get_sources(VALUE self)
384
+ {
385
+ return _rbgst_collect_elements(gst_bin_iterate_sources(SELF(self)));
386
+ }
387
+
388
+ #ifdef GST_DEBUG_BIN_TO_DOT_FILE
389
+ static VALUE
390
+ rb_gst_bin_to_dot_file(VALUE self, VALUE details, VALUE filename)
391
+ {
392
+ GST_DEBUG_BIN_TO_DOT_FILE(SELF(self), NUM2INT(details), RVAL2CSTR(filename));
393
+ return Qnil;
394
+ }
395
+
396
+ static VALUE
397
+ rb_gst_bin_to_dot_file_with_ts(VALUE self, VALUE details, VALUE filename)
398
+ {
399
+ GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(SELF(self),
400
+ NUM2INT(details),
401
+ RVAL2CSTR(filename));
402
+ return Qnil;
403
+ }
404
+ #endif
405
+
406
+ void
407
+ Init_gst_bin (void)
408
+ {
409
+ VALUE rb_cGstBin;
410
+
411
+ rb_cGstBin = G_DEF_CLASS(GST_TYPE_BIN, "Bin", mGst);
412
+
413
+ rb_include_module(rb_cGstBin, rb_mEnumerable);
414
+
415
+ rb_define_method(rb_cGstBin, "initialize", rb_gst_bin_initialize, -1);
416
+
417
+ rb_define_method(rb_cGstBin, "size", rb_gst_bin_size, 0);
418
+ rb_define_alias(rb_cGstBin, "length", "size");
419
+
420
+ rb_define_method(rb_cGstBin, "children", rb_gst_bin_get_children, -1);
421
+ rb_define_method(rb_cGstBin, "each", rb_gst_bin_each_element, -1);
422
+
423
+ rb_define_method(rb_cGstBin, "children_recurse",
424
+ rb_gst_bin_get_children_recurse, 0);
425
+ rb_define_method(rb_cGstBin, "each_recurse",
426
+ rb_gst_bin_each_recurse_element, 0);
427
+
428
+ rb_define_method(rb_cGstBin, "children_cookie",
429
+ rb_gst_bin_get_children_cookie, 0);
430
+ rb_define_method(rb_cGstBin, "child_bus", rb_gst_bin_get_child_bus, 0);
431
+ rb_define_method(rb_cGstBin, "messages", rb_gst_bin_get_messages, 0);
432
+ rb_define_method(rb_cGstBin, "polling?", rb_gst_bin_polling_p, 0);
433
+ rb_define_method(rb_cGstBin, "clock_dirty?", rb_gst_bin_clock_dirty_p, 0);
434
+ rb_define_method(rb_cGstBin, "provided_clock",
435
+ rb_gst_bin_get_provided_clock, 0);
436
+ rb_define_method(rb_cGstBin, "set_provided_clock",
437
+ rb_gst_bin_set_provided_clock, 1);
438
+ rb_define_method(rb_cGstBin, "clock_provider",
439
+ rb_gst_bin_get_clock_provider, 0);
440
+
441
+
442
+ rb_define_method(rb_cGstBin, "<<", rb_gst_bin_add, 1);
443
+ rb_define_method(rb_cGstBin, "add", rb_gst_bin_add_multi, -1);
444
+ rb_define_method(rb_cGstBin, "remove", rb_gst_bin_remove, -1);
445
+ rb_define_method(rb_cGstBin, "clear", rb_gst_bin_clear, 0);
446
+
447
+ rb_define_method(rb_cGstBin, "get_child", rb_gst_bin_get, -1);
448
+
449
+ rb_define_method(rb_cGstBin, "sinks", rb_gst_bin_get_sinks, 0);
450
+ rb_define_method(rb_cGstBin, "sources", rb_gst_bin_get_sources, 0);
451
+
452
+ #ifdef GST_DEBUG_BIN_TO_DOT_FILE
453
+ rb_define_method(rb_cGstBin, "to_dot_file", rb_gst_bin_to_dot_file, 2);
454
+ rb_define_method(rb_cGstBin, "to_dot_file_with_ts",
455
+ rb_gst_bin_to_dot_file_with_ts, 2);
456
+ #endif
457
+
458
+ G_DEF_SETTERS(rb_cGstBin);
459
+
460
+ G_DEF_CLASS(GST_TYPE_BIN_FLAGS, "Flags", rb_cGstBin);
461
+ G_DEF_CONSTANTS(rb_cGstBin, GST_TYPE_BIN_FLAGS, "GST_BIN_");
462
+ #ifdef GST_DEBUG_BIN_TO_DOT_FILE
463
+ G_DEF_CONSTANTS(rb_cGstBin, GST_TYPE_DEBUG_GRAPH_DETAILS,
464
+ "GST_DEBUG_GRAPH_");
465
+ #endif
466
+ }