gstreamer 1.2.6 → 2.0.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.
- data/Rakefile +78 -39
- data/ext/gstreamer/extconf.rb +8 -22
- data/ext/gstreamer/rbgst.c +82 -194
- data/lib/gst/base_loader.rb +20 -0
- data/lib/gst/bin.rb +32 -0
- data/lib/gst/bus.rb +24 -0
- data/lib/gst/element.rb +48 -0
- data/lib/gst.rb +87 -22
- data/sample/helloworld.rb +75 -0
- data/sample/mp3parselaunch.rb +74 -0
- data/sample/queue.rb +92 -0
- data/sample/typefind.rb +101 -0
- metadata +29 -84
- data/README +0 -33
- data/ext/gstreamer/misc.c +0 -63
- data/ext/gstreamer/rbgst-bin.c +0 -456
- data/ext/gstreamer/rbgst-buffer.c +0 -363
- data/ext/gstreamer/rbgst-bus.c +0 -92
- data/ext/gstreamer/rbgst-caps.c +0 -446
- data/ext/gstreamer/rbgst-child-proxy.c +0 -34
- data/ext/gstreamer/rbgst-clock.c +0 -108
- data/ext/gstreamer/rbgst-element-factory.c +0 -249
- data/ext/gstreamer/rbgst-element.c +0 -1106
- data/ext/gstreamer/rbgst-event.c +0 -352
- data/ext/gstreamer/rbgst-ghost-pad.c +0 -45
- data/ext/gstreamer/rbgst-index-factory.c +0 -69
- data/ext/gstreamer/rbgst-install-plugins-context.c +0 -87
- data/ext/gstreamer/rbgst-install-plugins-return.c +0 -45
- data/ext/gstreamer/rbgst-install-plugins.c +0 -125
- data/ext/gstreamer/rbgst-message.c +0 -785
- data/ext/gstreamer/rbgst-mini-object.c +0 -221
- data/ext/gstreamer/rbgst-object.c +0 -81
- data/ext/gstreamer/rbgst-pad-template.c +0 -125
- data/ext/gstreamer/rbgst-pad.c +0 -336
- data/ext/gstreamer/rbgst-pipeline.c +0 -91
- data/ext/gstreamer/rbgst-plugin-feature.c +0 -131
- data/ext/gstreamer/rbgst-plugin.c +0 -162
- data/ext/gstreamer/rbgst-private.c +0 -88
- data/ext/gstreamer/rbgst-private.h +0 -97
- data/ext/gstreamer/rbgst-query.c +0 -291
- data/ext/gstreamer/rbgst-seek.c +0 -39
- data/ext/gstreamer/rbgst-static-caps.c +0 -49
- data/ext/gstreamer/rbgst-static-pad-template.c +0 -65
- data/ext/gstreamer/rbgst-structure.c +0 -300
- data/ext/gstreamer/rbgst-system-clock.c +0 -48
- data/ext/gstreamer/rbgst-type-find-factory.c +0 -125
- data/ext/gstreamer/rbgst-value.c +0 -527
- data/ext/gstreamer/rbgst-x-overlay.c +0 -131
- data/ext/gstreamer/rbgst.h +0 -197
- data/ext/gstreamer/rbgstclockentry.c +0 -271
- data/ext/gstreamer/rbgstformat.c +0 -162
- data/ext/gstreamer/rbgstindex.c +0 -315
- data/ext/gstreamer/rbgstindexentry.c +0 -99
- data/ext/gstreamer/rbgstparse.c +0 -69
- data/ext/gstreamer/rbgstquerytype.c +0 -162
- data/ext/gstreamer/rbgstregistry.c +0 -288
- data/ext/gstreamer/rbgsttag.c +0 -113
- data/ext/gstreamer/rbgsttagsetter.c +0 -53
- data/ext/gstreamer/rbgstxml.c +0 -192
- data/sample/audio-player.rb +0 -54
- data/sample/gst-gi.rb +0 -55
- data/sample/gst-inspect.rb +0 -417
- data/sample/install-plugins.rb +0 -40
- data/sample/media-type.rb +0 -55
- data/sample/media-type2.rb +0 -268
- data/sample/ogg-audio-player.rb +0 -54
- data/sample/type-find.rb +0 -46
- data/sample/video-player.rb +0 -57
- data/sample/xml-player.rb +0 -60
- data/test/gst-test-utils.rb +0 -18
- data/test/run-test.rb +0 -25
- data/test/test_bin.rb +0 -167
- data/test/test_buffer.rb +0 -185
- data/test/test_caps.rb +0 -24
- data/test/test_element.rb +0 -85
- data/test/test_element_factory.rb +0 -28
- data/test/test_event.rb +0 -10
- data/test/test_index_factory.rb +0 -7
- data/test/test_install-plugins.rb +0 -18
- data/test/test_message.rb +0 -191
- data/test/test_mini_object.rb +0 -38
- data/test/test_object.rb +0 -10
- data/test/test_pad.rb +0 -68
- data/test/test_plugin.rb +0 -6
- data/test/test_plugin_feature.rb +0 -20
- data/test/test_seek.rb +0 -17
- data/test/test_static_caps.rb +0 -18
- data/test/test_static_pad_template.rb +0 -16
- data/test/test_structure.rb +0 -159
- data/test/test_thread_handling.rb +0 -58
- data/test/test_type_find_factory.rb +0 -8
- data/test/test_value.rb +0 -69
data/lib/gst/element.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# Copyright (C) 2013 Ruby-GNOME2 Project Team
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
module Gst
|
18
|
+
class Element
|
19
|
+
def stop
|
20
|
+
set_state(State::NULL)
|
21
|
+
end
|
22
|
+
|
23
|
+
def ready
|
24
|
+
set_state(State::READY)
|
25
|
+
end
|
26
|
+
|
27
|
+
def pause
|
28
|
+
set_state(State::PAUSED)
|
29
|
+
end
|
30
|
+
|
31
|
+
def play
|
32
|
+
set_state(State::PLAYING)
|
33
|
+
end
|
34
|
+
|
35
|
+
alias_method :link_element, :link
|
36
|
+
def link_elements(*elements)
|
37
|
+
elements.each do |element|
|
38
|
+
link_element(element)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
alias_method :link, :link_elements
|
42
|
+
|
43
|
+
def >>(element)
|
44
|
+
link_element(element)
|
45
|
+
element
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/gst.rb
CHANGED
@@ -1,36 +1,101 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# Copyright (C) 2013 Ruby-GNOME2 Project Team
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
require "gobject-introspection"
|
3
18
|
|
4
19
|
base_dir = Pathname.new(__FILE__).dirname.dirname.expand_path
|
5
20
|
vendor_dir = base_dir + "vendor" + "local"
|
6
21
|
vendor_bin_dir = vendor_dir + "bin"
|
7
|
-
GLib.
|
8
|
-
|
9
|
-
|
10
|
-
require 'gdk_pixbuf2'
|
11
|
-
end
|
12
|
-
begin
|
13
|
-
major, minor, _ = RUBY_VERSION.split(/\./)
|
14
|
-
require "#{major}.#{minor}/gstreamer.so"
|
15
|
-
rescue LoadError
|
16
|
-
require "gstreamer.so"
|
17
|
-
end
|
22
|
+
GLib.prepend_dll_path(vendor_bin_dir)
|
23
|
+
vendor_girepository_dir = vendor_dir + "lib" + "girepository-1.0"
|
24
|
+
GObjectIntrospection.prepend_typelib_path(vendor_girepository_dir)
|
18
25
|
|
19
|
-
|
20
|
-
|
26
|
+
if vendor_dir.exist?
|
27
|
+
require "cairo"
|
28
|
+
require "gdk_pixbuf2"
|
29
|
+
require "pango"
|
21
30
|
end
|
22
|
-
Gst.init(argv_without_help_options)
|
23
31
|
|
24
32
|
module Gst
|
25
|
-
|
26
|
-
|
27
|
-
|
33
|
+
LOG_DOMAIN = "GStreamer"
|
34
|
+
GLib::Log.set_log_domain(LOG_DOMAIN)
|
35
|
+
|
36
|
+
@initialized = false
|
37
|
+
class << self
|
38
|
+
def init(*argv)
|
39
|
+
return if @initialized
|
40
|
+
@initialized = true
|
41
|
+
loader = Loader.new(self, argv)
|
42
|
+
loader.load("Gst")
|
43
|
+
require "gst/bin"
|
44
|
+
require "gst/bus"
|
45
|
+
require "gst/element"
|
46
|
+
init_base
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
def init_base
|
51
|
+
require "gst/base_loader"
|
52
|
+
base_loader = BaseLoader.new(self)
|
53
|
+
base_loader.load("GstBase")
|
28
54
|
end
|
29
55
|
end
|
30
56
|
|
31
|
-
class
|
32
|
-
def
|
33
|
-
super
|
57
|
+
class Loader < GObjectIntrospection::Loader
|
58
|
+
def initialize(base_module, init_arguments)
|
59
|
+
super(base_module)
|
60
|
+
@init_arguments = init_arguments
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
def pre_load(repository, namespace)
|
65
|
+
init_check = repository.find(namespace, "init_check")
|
66
|
+
succeeded, argc, argv, error = init_check.invoke(1 + @init_arguments.size,
|
67
|
+
[$0] + @init_arguments)
|
68
|
+
@init_arguments.replace(argv[1..-1])
|
69
|
+
raise error unless succeeded
|
70
|
+
end
|
71
|
+
|
72
|
+
def post_load(repository, namespace)
|
73
|
+
require_extension
|
74
|
+
self.class.start_callback_dispatch_thread
|
75
|
+
end
|
76
|
+
|
77
|
+
def require_extension
|
78
|
+
begin
|
79
|
+
major, minor, _ = RUBY_VERSION.split(/\./)
|
80
|
+
require "#{major}.#{minor}/gstreamer.so"
|
81
|
+
rescue LoadError
|
82
|
+
require "gstreamer.so"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def load_function_info(info)
|
87
|
+
return if info.name == "init"
|
88
|
+
super
|
89
|
+
end
|
90
|
+
|
91
|
+
RENAME_MAP = {
|
92
|
+
"uri_protocol_is_valid" => "valid_uri_protocol?",
|
93
|
+
"uri_protocol_is_supported" => "supported_uri_protocol?",
|
94
|
+
"uri_is_valid" => "valid_uri?",
|
95
|
+
"uri_has_protocol" => "uri_has_protocol?",
|
96
|
+
}
|
97
|
+
def rubyish_method_name(function_info)
|
98
|
+
RENAME_MAP[function_info.name] || super
|
34
99
|
end
|
35
100
|
end
|
36
101
|
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This sample code is a port of
|
4
|
+
# gstreamer/tests/examples/helloworld/helloworld.c. It is licensed
|
5
|
+
# under the terms of the GNU Library General Public License, version
|
6
|
+
# 2 or (at your option) later.
|
7
|
+
#
|
8
|
+
# Copyright (C) 2013 Ruby-GNOME2 Project Team
|
9
|
+
#
|
10
|
+
# This library is free software; you can redistribute it and/or
|
11
|
+
# modify it under the terms of the GNU Lesser General Public
|
12
|
+
# License as published by the Free Software Foundation; either
|
13
|
+
# version 2.1 of the License, or (at your option) any later version.
|
14
|
+
#
|
15
|
+
# This library is distributed in the hope that it will be useful,
|
16
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
18
|
+
# Lesser General Public License for more details.
|
19
|
+
#
|
20
|
+
# You should have received a copy of the GNU Lesser General Public
|
21
|
+
# License along with this library; if not, write to the Free Software
|
22
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
23
|
+
|
24
|
+
require "gst"
|
25
|
+
|
26
|
+
if ARGV.length < 1
|
27
|
+
puts "usage: #{$0} <media file or uri>"
|
28
|
+
exit(false)
|
29
|
+
end
|
30
|
+
|
31
|
+
Gst.init
|
32
|
+
|
33
|
+
playbin = Gst::ElementFactory.make("playbin")
|
34
|
+
if playbin.nil?
|
35
|
+
puts "'playbin' gstreamer plugin missing"
|
36
|
+
exit(false)
|
37
|
+
end
|
38
|
+
|
39
|
+
# take the commandline argument and ensure that it is a uri
|
40
|
+
if Gst.valid_uri?(ARGV.first)
|
41
|
+
uri = ARGV.first
|
42
|
+
else
|
43
|
+
uri = Gst.filename_to_uri(ARGV.first)
|
44
|
+
end
|
45
|
+
playbin.uri = uri
|
46
|
+
|
47
|
+
# create and event loop feed gstreamer bus messages to it
|
48
|
+
loop = GLib::MainLoop.new
|
49
|
+
|
50
|
+
bus = playbin.bus
|
51
|
+
bus.add_watch do |bus, message|
|
52
|
+
case message.type
|
53
|
+
when Gst::MessageType::EOS
|
54
|
+
puts "End-of-stream"
|
55
|
+
loop.quit
|
56
|
+
when Gst::MessageType::ERROR
|
57
|
+
error, debug = message.parse_error
|
58
|
+
puts "Debugging info: #{debug || 'none'}"
|
59
|
+
puts "Error: #{error.message}"
|
60
|
+
loop.quit
|
61
|
+
end
|
62
|
+
true
|
63
|
+
end
|
64
|
+
|
65
|
+
# start play back and listed to events
|
66
|
+
playbin.play
|
67
|
+
begin
|
68
|
+
loop.run
|
69
|
+
rescue Interrupt
|
70
|
+
puts "Interrupt"
|
71
|
+
rescue => error
|
72
|
+
puts "Error: #{error.message}"
|
73
|
+
ensure
|
74
|
+
playbin.stop
|
75
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
#
|
4
|
+
# This sample code is a port of
|
5
|
+
# gstreamer/tests/examples/launch/mp3parselaunch.c. It is licensed
|
6
|
+
# under the terms of the GNU Library General Public License, version
|
7
|
+
# 2 or (at your option) later.
|
8
|
+
#
|
9
|
+
# Copyright (C) 2013 Ruby-GNOME2 Project Team
|
10
|
+
#
|
11
|
+
# This library is free software; you can redistribute it and/or
|
12
|
+
# modify it under the terms of the GNU Lesser General Public
|
13
|
+
# License as published by the Free Software Foundation; either
|
14
|
+
# version 2.1 of the License, or (at your option) any later version.
|
15
|
+
#
|
16
|
+
# This library is distributed in the hope that it will be useful,
|
17
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
19
|
+
# Lesser General Public License for more details.
|
20
|
+
#
|
21
|
+
# You should have received a copy of the GNU Lesser General Public
|
22
|
+
# License along with this library; if not, write to the Free Software
|
23
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
24
|
+
|
25
|
+
require "gst"
|
26
|
+
|
27
|
+
def event_loop(pipe)
|
28
|
+
running = true
|
29
|
+
bus = pipe.bus
|
30
|
+
|
31
|
+
while running
|
32
|
+
message = bus.poll(Gst::MessageType::ANY, Gst::CLOCK_TIME_NONE)
|
33
|
+
raise "message nil" if message.nil?
|
34
|
+
|
35
|
+
case message.type
|
36
|
+
when Gst::MessageType::EOS
|
37
|
+
running = false
|
38
|
+
when Gst::MessageType::WARNING
|
39
|
+
warning, debug = message.parse_warning
|
40
|
+
puts "Debugging info: #{debug || 'none'}"
|
41
|
+
puts "Warning: #{warning.message}"
|
42
|
+
when Gst::MessageType::ERROR
|
43
|
+
error, debug = message.parse_error
|
44
|
+
puts "Debugging info: #{debug || 'none'}"
|
45
|
+
puts "Error: #{error.message}"
|
46
|
+
running = false
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
Gst.init
|
52
|
+
|
53
|
+
if ARGV.length < 1
|
54
|
+
puts "usage: #{$0} <mp3 file>"
|
55
|
+
exit(false)
|
56
|
+
end
|
57
|
+
|
58
|
+
bin, error = Gst.parse_launch("filesrc name=my_filesrc ! mad ! autoaudiosink")
|
59
|
+
if bin.nil?
|
60
|
+
$stderr.puts "Parse error: #{error.message}"
|
61
|
+
exit(false)
|
62
|
+
end
|
63
|
+
|
64
|
+
filesrc = bin.get_by_name("my_filesrc")
|
65
|
+
filesrc.location = ARGV[0]
|
66
|
+
|
67
|
+
# start playing
|
68
|
+
bin.play
|
69
|
+
|
70
|
+
# Run event loop listening for bus messages until EOS or ERROR
|
71
|
+
event_loop(bin)
|
72
|
+
|
73
|
+
# stop the bin
|
74
|
+
bin.stop
|
data/sample/queue.rb
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
#
|
4
|
+
# This sample code is a port of
|
5
|
+
# gstreamer/tests/examples/queue/queue.c. It is licensed under
|
6
|
+
# the terms of the GNU Library General Public License, version
|
7
|
+
# 2 or (at your option) later.
|
8
|
+
#
|
9
|
+
# Copyright (C) 2013 Ruby-GNOME2 Project Team
|
10
|
+
#
|
11
|
+
# This library is free software; you can redistribute it and/or
|
12
|
+
# modify it under the terms of the GNU Lesser General Public
|
13
|
+
# License as published by the Free Software Foundation; either
|
14
|
+
# version 2.1 of the License, or (at your option) any later version.
|
15
|
+
#
|
16
|
+
# This library is distributed in the hope that it will be useful,
|
17
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
19
|
+
# Lesser General Public License for more details.
|
20
|
+
#
|
21
|
+
# You should have received a copy of the GNU Lesser General Public
|
22
|
+
# License along with this library; if not, write to the Free Software
|
23
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
24
|
+
|
25
|
+
require "gst"
|
26
|
+
|
27
|
+
# This example uses the queue element to create a buffer between 2 elements.
|
28
|
+
# The scheduler automatically uses 2 threads, 1 to feed and another to consume
|
29
|
+
# data from the queue buffer
|
30
|
+
|
31
|
+
# Event loop to listen to events posted on the Gst::Bus from the pipeline. Exits
|
32
|
+
# on EOS or ERROR events
|
33
|
+
def event_loop(pipe)
|
34
|
+
running = true
|
35
|
+
bus = pipe.bus
|
36
|
+
|
37
|
+
while running do
|
38
|
+
message = bus.poll(Gst::MessageType::ANY, -1)
|
39
|
+
|
40
|
+
case message.type
|
41
|
+
when Gst::MessageType::EOS
|
42
|
+
running = false
|
43
|
+
when Gst::MessageType::WARNING
|
44
|
+
warning, debug = message.parse_warning
|
45
|
+
puts "Debugging info: #{debug || 'none'}"
|
46
|
+
puts "Warning: #{warning.message}"
|
47
|
+
when Gst::MessageType::ERROR
|
48
|
+
error, debug = message.parse_error
|
49
|
+
puts "Debugging info: #{debug || 'none'}"
|
50
|
+
puts "Error: #{error.message}"
|
51
|
+
running = false
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
Gst.init
|
57
|
+
|
58
|
+
if ARGV.length < 1
|
59
|
+
puts "usage: #{$0} <filename>"
|
60
|
+
exit(false)
|
61
|
+
end
|
62
|
+
|
63
|
+
# create a new pipeline to hold the elements
|
64
|
+
pipeline = Gst::Pipeline.new("pipeline")
|
65
|
+
raise "'pipeline' gstreamer plugin missing" if pipeline.nil?
|
66
|
+
|
67
|
+
# create a disk reader
|
68
|
+
filesrc = Gst::ElementFactory.make("filesrc", "disk_source")
|
69
|
+
raise "'filesrc' gstreamer plugin missing" if filesrc.nil?
|
70
|
+
filesrc.location = ARGV.first
|
71
|
+
|
72
|
+
decode = Gst::ElementFactory.make("mad", "decode")
|
73
|
+
raise "'mad' gstreamer plugin missing" if decode.nil?
|
74
|
+
|
75
|
+
queue = Gst::ElementFactory.make("queue", "queue")
|
76
|
+
raise "'queue' gstreamer plugin missing" if queue.nil?
|
77
|
+
|
78
|
+
# and an audio sink
|
79
|
+
audiosink = Gst::ElementFactory.make("alsasink", "play_audio")
|
80
|
+
raise "'alsasink' gstreamer plugin missing" if audiosink.nil?
|
81
|
+
|
82
|
+
# add objects to the main pipeline
|
83
|
+
pipeline << filesrc << decode << queue << audiosink
|
84
|
+
filesrc >> decode >> queue >> audiosink
|
85
|
+
|
86
|
+
# start playing
|
87
|
+
pipeline.play
|
88
|
+
|
89
|
+
# listen for EOS
|
90
|
+
event_loop(pipeline)
|
91
|
+
|
92
|
+
pipeline.stop
|
data/sample/typefind.rb
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
#
|
4
|
+
# This sample code is a port of
|
5
|
+
# gstreamer/tests/examples/typefind/typefind.c. It is licensed
|
6
|
+
# under the terms of the GNU Library General Public License, version
|
7
|
+
# 2 or (at your option) later.
|
8
|
+
#
|
9
|
+
# Here is the original copyright header:
|
10
|
+
# Copyright (C) <2005> Stefan Kost
|
11
|
+
# Copyright (C) <2006> Tim-Philipp Müller
|
12
|
+
#
|
13
|
+
# Copyright (C) 2013 Ruby-GNOME2 Project Team
|
14
|
+
#
|
15
|
+
# This library is free software; you can redistribute it and/or
|
16
|
+
# modify it under the terms of the GNU Lesser General Public
|
17
|
+
# License as published by the Free Software Foundation; either
|
18
|
+
# version 2.1 of the License, or (at your option) any later version.
|
19
|
+
#
|
20
|
+
# This library is distributed in the hope that it will be useful,
|
21
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
22
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
23
|
+
# Lesser General Public License for more details.
|
24
|
+
#
|
25
|
+
# You should have received a copy of the GNU Lesser General Public
|
26
|
+
# License along with this library; if not, write to the Free Software
|
27
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
28
|
+
|
29
|
+
require "gst"
|
30
|
+
require "rexml/document"
|
31
|
+
|
32
|
+
def event_loop(pipe)
|
33
|
+
running = true
|
34
|
+
bus = pipe.bus
|
35
|
+
|
36
|
+
while running do
|
37
|
+
message = bus.poll(Gst::MessageType::ANY, Gst::CLOCK_TIME_NONE)
|
38
|
+
raise "message nil" if message.nil?
|
39
|
+
|
40
|
+
case message.type
|
41
|
+
when Gst::MessageType::EOS
|
42
|
+
running = false
|
43
|
+
when Gst::MessageType::WARNING
|
44
|
+
warning, debug = message.parse_warning
|
45
|
+
puts "Debugging info: #{debug || 'none'}"
|
46
|
+
puts "Warning: #{warning.message}"
|
47
|
+
when Gst::MessageType::ERROR
|
48
|
+
error, debug = message.parse_error
|
49
|
+
puts "Debugging info: #{debug || 'none'}"
|
50
|
+
puts "Error: #{error.message}"
|
51
|
+
running = false
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
Gst.init
|
57
|
+
|
58
|
+
if ARGV.length < 1
|
59
|
+
puts "usage: #{$0} <filename>"
|
60
|
+
exit(false)
|
61
|
+
end
|
62
|
+
|
63
|
+
# create a new pipeline to hold the elements
|
64
|
+
pipeline = Gst::Pipeline.new("pipeline")
|
65
|
+
raise "'pipeline' gstreamer plugin missing" if pipeline.nil?
|
66
|
+
|
67
|
+
# create a file reader
|
68
|
+
filesrc = Gst::ElementFactory.make("filesrc", "file_source")
|
69
|
+
raise "'filesrc' gstreamer plugin missing" if filesrc.nil?
|
70
|
+
filesrc.location = ARGV.first
|
71
|
+
|
72
|
+
typefind = Gst::ElementFactory.make("typefind", "typefind")
|
73
|
+
raise "'typefind' gstreamer plugin missing" if typefind.nil?
|
74
|
+
|
75
|
+
sink = Gst::ElementFactory.make("fakesink", "sink")
|
76
|
+
raise "'fakesink' gstreamer plugin missing" if sink.nil?
|
77
|
+
|
78
|
+
# add objects to the main pipeline
|
79
|
+
pipeline << filesrc << typefind << sink
|
80
|
+
|
81
|
+
typefind.signal_connect("have-type") do |element, probability, caps|
|
82
|
+
caps_str = caps.to_s
|
83
|
+
xml = REXML::Document.new
|
84
|
+
xml << REXML::XMLDecl.new
|
85
|
+
capabilities = xml.add_element("Capabilities")
|
86
|
+
cap1 = capabilities.add_element("Cap1")
|
87
|
+
cap1.add_text(caps_str)
|
88
|
+
xml.write($stdout, 2)
|
89
|
+
puts
|
90
|
+
end
|
91
|
+
|
92
|
+
filesrc >> typefind >> sink
|
93
|
+
|
94
|
+
# start playing
|
95
|
+
pipeline.play
|
96
|
+
|
97
|
+
# Run event loop listening for bus messages until EOS or ERROR
|
98
|
+
event_loop(pipeline)
|
99
|
+
|
100
|
+
# stop the bin
|
101
|
+
pipeline.stop
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gstreamer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: glib2
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 2.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,23 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 2.0.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: gobject-introspection
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 2.0.0
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.0.0
|
30
46
|
description: Ruby/GStreamer is a Ruby binding for GStreamer.
|
31
47
|
email: ruby-gnome2-devel-en@lists.sourceforge.net
|
32
48
|
executables: []
|
@@ -34,94 +50,23 @@ extensions:
|
|
34
50
|
- ext/gstreamer/extconf.rb
|
35
51
|
extra_rdoc_files: []
|
36
52
|
files:
|
37
|
-
- README
|
38
53
|
- Rakefile
|
39
54
|
- extconf.rb
|
40
55
|
- lib/gst.rb
|
56
|
+
- lib/gst/base_loader.rb
|
57
|
+
- lib/gst/bin.rb
|
58
|
+
- lib/gst/bus.rb
|
59
|
+
- lib/gst/element.rb
|
41
60
|
- ext/gstreamer/depend
|
42
61
|
- ext/gstreamer/extconf.rb
|
43
|
-
- ext/gstreamer/misc.c
|
44
|
-
- ext/gstreamer/rbgst-bin.c
|
45
|
-
- ext/gstreamer/rbgst-buffer.c
|
46
|
-
- ext/gstreamer/rbgst-bus.c
|
47
|
-
- ext/gstreamer/rbgst-caps.c
|
48
|
-
- ext/gstreamer/rbgst-child-proxy.c
|
49
|
-
- ext/gstreamer/rbgst-clock.c
|
50
|
-
- ext/gstreamer/rbgst-element-factory.c
|
51
|
-
- ext/gstreamer/rbgst-element.c
|
52
|
-
- ext/gstreamer/rbgst-event.c
|
53
|
-
- ext/gstreamer/rbgst-ghost-pad.c
|
54
|
-
- ext/gstreamer/rbgst-index-factory.c
|
55
|
-
- ext/gstreamer/rbgst-install-plugins-context.c
|
56
|
-
- ext/gstreamer/rbgst-install-plugins-return.c
|
57
|
-
- ext/gstreamer/rbgst-install-plugins.c
|
58
|
-
- ext/gstreamer/rbgst-message.c
|
59
|
-
- ext/gstreamer/rbgst-mini-object.c
|
60
|
-
- ext/gstreamer/rbgst-object.c
|
61
|
-
- ext/gstreamer/rbgst-pad-template.c
|
62
|
-
- ext/gstreamer/rbgst-pad.c
|
63
|
-
- ext/gstreamer/rbgst-pipeline.c
|
64
|
-
- ext/gstreamer/rbgst-plugin-feature.c
|
65
|
-
- ext/gstreamer/rbgst-plugin.c
|
66
|
-
- ext/gstreamer/rbgst-private.c
|
67
|
-
- ext/gstreamer/rbgst-private.h
|
68
|
-
- ext/gstreamer/rbgst-query.c
|
69
|
-
- ext/gstreamer/rbgst-seek.c
|
70
|
-
- ext/gstreamer/rbgst-static-caps.c
|
71
|
-
- ext/gstreamer/rbgst-static-pad-template.c
|
72
|
-
- ext/gstreamer/rbgst-structure.c
|
73
|
-
- ext/gstreamer/rbgst-system-clock.c
|
74
|
-
- ext/gstreamer/rbgst-type-find-factory.c
|
75
|
-
- ext/gstreamer/rbgst-value.c
|
76
|
-
- ext/gstreamer/rbgst-x-overlay.c
|
77
62
|
- ext/gstreamer/rbgst.c
|
78
|
-
-
|
79
|
-
-
|
80
|
-
-
|
81
|
-
-
|
82
|
-
- ext/gstreamer/rbgstindexentry.c
|
83
|
-
- ext/gstreamer/rbgstparse.c
|
84
|
-
- ext/gstreamer/rbgstquerytype.c
|
85
|
-
- ext/gstreamer/rbgstregistry.c
|
86
|
-
- ext/gstreamer/rbgsttag.c
|
87
|
-
- ext/gstreamer/rbgsttagsetter.c
|
88
|
-
- ext/gstreamer/rbgstxml.c
|
89
|
-
- sample/audio-player.rb
|
90
|
-
- sample/gst-gi.rb
|
91
|
-
- sample/gst-inspect.rb
|
92
|
-
- sample/install-plugins.rb
|
93
|
-
- sample/media-type.rb
|
94
|
-
- sample/media-type2.rb
|
95
|
-
- sample/ogg-audio-player.rb
|
96
|
-
- sample/type-find.rb
|
97
|
-
- sample/video-player.rb
|
98
|
-
- sample/xml-player.rb
|
99
|
-
- test/gst-test-utils.rb
|
100
|
-
- test/run-test.rb
|
101
|
-
- test/test_bin.rb
|
102
|
-
- test/test_buffer.rb
|
103
|
-
- test/test_caps.rb
|
104
|
-
- test/test_element.rb
|
105
|
-
- test/test_element_factory.rb
|
106
|
-
- test/test_event.rb
|
107
|
-
- test/test_index_factory.rb
|
108
|
-
- test/test_install-plugins.rb
|
109
|
-
- test/test_message.rb
|
110
|
-
- test/test_mini_object.rb
|
111
|
-
- test/test_object.rb
|
112
|
-
- test/test_pad.rb
|
113
|
-
- test/test_plugin.rb
|
114
|
-
- test/test_plugin_feature.rb
|
115
|
-
- test/test_seek.rb
|
116
|
-
- test/test_static_caps.rb
|
117
|
-
- test/test_static_pad_template.rb
|
118
|
-
- test/test_structure.rb
|
119
|
-
- test/test_thread_handling.rb
|
120
|
-
- test/test_type_find_factory.rb
|
121
|
-
- test/test_value.rb
|
63
|
+
- sample/helloworld.rb
|
64
|
+
- sample/mp3parselaunch.rb
|
65
|
+
- sample/queue.rb
|
66
|
+
- sample/typefind.rb
|
122
67
|
homepage: http://ruby-gnome2.sourceforge.jp/
|
123
68
|
licenses: []
|
124
|
-
post_install_message:
|
69
|
+
post_install_message:
|
125
70
|
rdoc_options: []
|
126
71
|
require_paths:
|
127
72
|
- lib
|
data/README
DELETED
@@ -1,33 +0,0 @@
|
|
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
|