gstreamer 1.2.6 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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/sample/media-type2.rb
DELETED
@@ -1,268 +0,0 @@
|
|
1
|
-
|
2
|
-
# This is a Ruby implementation of the GStreamer media-info library,
|
3
|
-
# graciously provided by Nikolai Weilbull <lone-star@home.se>.
|
4
|
-
#
|
5
|
-
# It works exactly like media-type.rb.
|
6
|
-
|
7
|
-
require 'gst'
|
8
|
-
|
9
|
-
class MediaInfoStream
|
10
|
-
def initialize
|
11
|
-
@length_tracks = 0
|
12
|
-
@length_time = 0
|
13
|
-
@bitrate = 0
|
14
|
-
@seekable = false
|
15
|
-
@path = nil
|
16
|
-
@mime = nil
|
17
|
-
@tracks = []
|
18
|
-
end
|
19
|
-
attr_accessor :length_time, :length_tracks, :path, :mime, :bitrate, :tracks
|
20
|
-
end
|
21
|
-
|
22
|
-
class MediaInfoTrack
|
23
|
-
def initialize
|
24
|
-
@metadata = nil
|
25
|
-
@streaminfo = nil
|
26
|
-
@format = nil
|
27
|
-
@length_time = 0
|
28
|
-
@con_streams = nil
|
29
|
-
end
|
30
|
-
|
31
|
-
attr_accessor :metadata, :streaminfo, :format
|
32
|
-
end
|
33
|
-
|
34
|
-
class MediaInfo
|
35
|
-
# TODO: add signals
|
36
|
-
INFO_ALL = (0..4).to_a.length - 1
|
37
|
-
INFO_STREAM, INFO_MIME, INFO_METADATA, INFO_STREAMINFO, INFO_FORMAT = *(0..4).to_a
|
38
|
-
def initialize(source_element)
|
39
|
-
@pipeline = Gst::Pipeline.new 'media-info'
|
40
|
-
@typefind = Gst::ElementFactory.make 'typefind', 'typefind'
|
41
|
-
@source_element = source_element
|
42
|
-
@source = Gst::ElementFactory.make @source_element, 'source'
|
43
|
-
if @source != nil
|
44
|
-
@pipeline.add @source
|
45
|
-
else
|
46
|
-
@source_element = nil
|
47
|
-
@source = nil
|
48
|
-
end
|
49
|
-
@decoder = @type = @format = @metadata = @stream = nil
|
50
|
-
@decoders = Hash.new
|
51
|
-
@pipeline.signal_connect 'deep_notify' do |obj, origin, pspec|
|
52
|
-
case pspec.name
|
53
|
-
when 'metadata'
|
54
|
-
@metadata = origin.metadata
|
55
|
-
when 'caps'
|
56
|
-
@format = origin.caps if origin == @decoder_pad
|
57
|
-
when 'streaminfo'
|
58
|
-
@streaminfo = origin.streaminfo
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def reset
|
64
|
-
@format = nil
|
65
|
-
@metadata = nil
|
66
|
-
@stream = nil
|
67
|
-
end
|
68
|
-
|
69
|
-
def seek_to_track(track)
|
70
|
-
track_format = Gst::Format.find 'logical_stream'
|
71
|
-
return false if track_format == nil
|
72
|
-
@pipeline.play
|
73
|
-
# XXX: todo, need Gst::Event
|
74
|
-
event = gst_event_new_seek(format.id | Gst::EventSeek::METHOD_SET |
|
75
|
-
Gst::EventSeek::FLAG_FLUSH)
|
76
|
-
return false if event == nil
|
77
|
-
@metadata = nil
|
78
|
-
@streaminfo = nil
|
79
|
-
return true
|
80
|
-
end
|
81
|
-
|
82
|
-
def get_decoder(mime)
|
83
|
-
decoder = @decoders[mime]
|
84
|
-
if decoder == nil
|
85
|
-
factories = {
|
86
|
-
'application/x-ogg' => 'vorbisfile',
|
87
|
-
'audio/x-mp3' => 'mad',
|
88
|
-
'audio/x-wav' => 'wavparse'
|
89
|
-
}
|
90
|
-
factory = factories[mime]
|
91
|
-
return nil if factory == nil
|
92
|
-
decoder = Gst::ElementFactory.make factory, 'decoder'
|
93
|
-
@decoders[mime] = decoder if decoder != nil
|
94
|
-
end
|
95
|
-
return decoder
|
96
|
-
end
|
97
|
-
|
98
|
-
def find_type(location)
|
99
|
-
@type = nil
|
100
|
-
@pipeline.add @typefind
|
101
|
-
@source.location = location
|
102
|
-
@source >> @typefind
|
103
|
-
@typefind.signal_connect 'have-type' do |typefind, type|
|
104
|
-
@type = type
|
105
|
-
end
|
106
|
-
@pipeline.play
|
107
|
-
while @type == nil && @pipeline.iterate do end
|
108
|
-
@pipeline.ready
|
109
|
-
# TODO: this is different
|
110
|
-
@source.unlink_pads @typefind
|
111
|
-
@pipeline.remove @typefind
|
112
|
-
end
|
113
|
-
|
114
|
-
def get_stream(stream)
|
115
|
-
@pipeline.play
|
116
|
-
while @format == nil && @pipeline.iterate do end
|
117
|
-
@pipeline.pause
|
118
|
-
return nil if @format == nil
|
119
|
-
track_format = Gst::Format.find 'logical_stream'
|
120
|
-
@decoder_pad.formats.each do |format|
|
121
|
-
value = @decoder_pad.query(Gst::QueryType::TOTAL, format.type_id)
|
122
|
-
case format.type_id
|
123
|
-
when Gst::Format::TIME
|
124
|
-
stream.length_time = value ? value : 1
|
125
|
-
else
|
126
|
-
stream.length_tracks = value if format == track_format && value != nil
|
127
|
-
end
|
128
|
-
end
|
129
|
-
stream.length_tracks = 1 if stream.length_tracks == 0
|
130
|
-
value = @source_pad.query(Gst::QueryType::TOTAL, Gst::Format::BYTES)
|
131
|
-
if value
|
132
|
-
seconds = stream.length_time.to_f / Gst::SECOND
|
133
|
-
bits = value * 8
|
134
|
-
stream.bitrate = bits / seconds
|
135
|
-
end
|
136
|
-
return stream
|
137
|
-
end
|
138
|
-
|
139
|
-
def find_metadata
|
140
|
-
@pipeline.play
|
141
|
-
while @metadata == nil && @pipeline.iterate do end
|
142
|
-
@pipeline.pause
|
143
|
-
metadata = @metadata
|
144
|
-
@metadata = nil
|
145
|
-
return metadata
|
146
|
-
end
|
147
|
-
|
148
|
-
def find_streaminfo
|
149
|
-
@pipeline.play
|
150
|
-
while @streaminfo == nil && @pipeline.iterate do end
|
151
|
-
@pipeline.pause
|
152
|
-
streaminfo = @streaminfo
|
153
|
-
@streaminfo = nil
|
154
|
-
|
155
|
-
track_format = Gst::Format.find 'logical_stream'
|
156
|
-
if track_format != nil
|
157
|
-
start = @decoder_pad.query(Gst::QueryType::POSITION, track_format.type_id)
|
158
|
-
track_num = start
|
159
|
-
# XXX: need Gst::Pad#convert
|
160
|
-
end
|
161
|
-
return streaminfo
|
162
|
-
end
|
163
|
-
|
164
|
-
def find_format
|
165
|
-
@pipeline.play
|
166
|
-
while @format == nil && @pipeline.iterate do end
|
167
|
-
@pipeline.pause
|
168
|
-
format = @format
|
169
|
-
@format = nil
|
170
|
-
return format
|
171
|
-
end
|
172
|
-
|
173
|
-
def clear_decoder
|
174
|
-
if @decoder != nil
|
175
|
-
@pipeline.ready
|
176
|
-
@source.unlink_pads @decoder
|
177
|
-
@pipeline.remove @decoder
|
178
|
-
@decoder = nil
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
def set_decoder(decoder)
|
183
|
-
@decoder = decoder
|
184
|
-
@pipeline.add @decoder
|
185
|
-
@source >> @decoder
|
186
|
-
@decoder_pad = @decoder.get_pad 'src'
|
187
|
-
@source_pad = @source.get_pad 'src'
|
188
|
-
end
|
189
|
-
|
190
|
-
def set_source(source)
|
191
|
-
src = Gst::ElementFactory.make source, 'new-source'
|
192
|
-
return false if src == nil
|
193
|
-
if @source != nil
|
194
|
-
@pipeline.remove @source
|
195
|
-
@source_element = nil if @source_element != nil
|
196
|
-
end
|
197
|
-
src.name = 'source'
|
198
|
-
@pipeline.add src
|
199
|
-
@source = src
|
200
|
-
@source_element = source
|
201
|
-
return true
|
202
|
-
end
|
203
|
-
|
204
|
-
def read(location, flags)
|
205
|
-
reset
|
206
|
-
find_type location
|
207
|
-
return nil if @type == nil
|
208
|
-
stream = MediaInfoStream.new
|
209
|
-
mime = @type.mime
|
210
|
-
stream.mime = mime if flags & INFO_MIME
|
211
|
-
stream.path = location
|
212
|
-
decoder = get_decoder mime
|
213
|
-
return nil if decoder == nil
|
214
|
-
set_decoder decoder
|
215
|
-
stream = get_stream stream
|
216
|
-
stream.length_tracks.times do |i|
|
217
|
-
track = MediaInfoTrack.new
|
218
|
-
track.metadata = find_metadata if flags & INFO_METADATA
|
219
|
-
track.streaminfo = find_streaminfo if flags & INFO_STREAMINFO
|
220
|
-
track.format = find_format if flags & INFO_FORMAT
|
221
|
-
stream.tracks << track
|
222
|
-
end
|
223
|
-
clear_decoder
|
224
|
-
return stream
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
def usage
|
229
|
-
puts "Usage: #{__FILE__} FILE..."
|
230
|
-
exit 1
|
231
|
-
end
|
232
|
-
|
233
|
-
def print_caps(caps)
|
234
|
-
return if caps == nil
|
235
|
-
caps.each_property do |name, value, fixed|
|
236
|
-
puts " #{name}: #{value}"
|
237
|
-
end
|
238
|
-
end
|
239
|
-
|
240
|
-
def print_info(path, stream)
|
241
|
-
if stream
|
242
|
-
puts "#{path}:"
|
243
|
-
puts " mime type: #{stream.mime}"
|
244
|
-
puts " length: #{stream.length_time / Gst::SECOND} seconds"
|
245
|
-
puts " bitrate: #{stream.bitrate / 1000.0} kbps"
|
246
|
-
puts " number of tracks: #{stream.length_tracks}"
|
247
|
-
puts " tracks:"
|
248
|
-
stream.tracks.each_with_index do |track, i|
|
249
|
-
puts " - track #{i + 1}:"
|
250
|
-
puts " metadata:"
|
251
|
-
print_caps track.metadata
|
252
|
-
puts " streaminfo:"
|
253
|
-
print_caps track.streaminfo
|
254
|
-
puts " format:"
|
255
|
-
print_caps track.format
|
256
|
-
end
|
257
|
-
else
|
258
|
-
puts "No media info found for file #{path}"
|
259
|
-
end
|
260
|
-
end
|
261
|
-
|
262
|
-
usage if ARGV.empty?
|
263
|
-
Gst.init
|
264
|
-
mediainfo = MediaInfo.new 'filesrc'
|
265
|
-
ARGV.each do |path|
|
266
|
-
print_info path, mediainfo.read(path, MediaInfo::INFO_ALL)
|
267
|
-
end
|
268
|
-
|
data/sample/ogg-audio-player.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
if ARGV.size != 1
|
4
|
-
puts "Usage: #{$0} ogg-audio-file"
|
5
|
-
exit
|
6
|
-
end
|
7
|
-
|
8
|
-
require 'gst'
|
9
|
-
|
10
|
-
loop = GLib::MainLoop.new(nil, false)
|
11
|
-
|
12
|
-
pipeline = Gst::Pipeline.new("ogg-audio-player")
|
13
|
-
source = Gst::ElementFactory.make("filesrc", "file-source")
|
14
|
-
parser = Gst::ElementFactory.make("oggdemux", "ogg-parser")
|
15
|
-
decoder = Gst::ElementFactory.make("vorbisdec", "vorbis-decoder")
|
16
|
-
converter = Gst::ElementFactory.make("audioconvert", "converter")
|
17
|
-
sink = Gst::ElementFactory.make("alsasink", "alsa-output")
|
18
|
-
|
19
|
-
source.location = ARGV.shift
|
20
|
-
|
21
|
-
bus = pipeline.bus
|
22
|
-
bus.add_watch do |bus, message|
|
23
|
-
case message.type
|
24
|
-
when Gst::Message::EOS
|
25
|
-
loop.quit
|
26
|
-
when Gst::Message::ERROR
|
27
|
-
p message.parse
|
28
|
-
loop.quit
|
29
|
-
end
|
30
|
-
true
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
pipeline.add(source, parser, decoder, converter, sink)
|
35
|
-
source >> parser
|
36
|
-
decoder >> converter >> sink
|
37
|
-
|
38
|
-
parser.signal_connect("pad-added") do |element, pad|
|
39
|
-
sink_pad = decoder.get_pad("sink")
|
40
|
-
pad.link(sink_pad)
|
41
|
-
end
|
42
|
-
|
43
|
-
puts "Setting to PLAYING"
|
44
|
-
pipeline.play
|
45
|
-
puts "Running"
|
46
|
-
begin
|
47
|
-
loop.run
|
48
|
-
print "Returned, "
|
49
|
-
rescue Interrupt
|
50
|
-
print "Interrupted, "
|
51
|
-
ensure
|
52
|
-
puts "stopping playback"
|
53
|
-
pipeline.stop
|
54
|
-
end
|
data/sample/type-find.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'gst'
|
4
|
-
|
5
|
-
def type_find(file)
|
6
|
-
pipeline = Gst::Pipeline.new("pipeline")
|
7
|
-
|
8
|
-
source = Gst::ElementFactory.make("filesrc", "source")
|
9
|
-
type_find = Gst::ElementFactory.make("typefind", "type-find")
|
10
|
-
sink = Gst::ElementFactory.make("fakesink", "sink")
|
11
|
-
|
12
|
-
pipeline.add(source, type_find, sink)
|
13
|
-
source >> type_find >> sink
|
14
|
-
|
15
|
-
found_caps = nil
|
16
|
-
type_find.signal_connect("have-type") do |element, probability, caps|
|
17
|
-
found_caps = caps
|
18
|
-
end
|
19
|
-
|
20
|
-
loop = GLib::MainLoop.new
|
21
|
-
source.location = file
|
22
|
-
bus = pipeline.bus
|
23
|
-
bus.add_watch do |bus, message|
|
24
|
-
case message.type
|
25
|
-
when Gst::Message::STATE_CHANGED, Gst::Message::EOS
|
26
|
-
loop.quit
|
27
|
-
when Gst::Message::ERROR
|
28
|
-
p message.parse
|
29
|
-
loop.quit
|
30
|
-
end
|
31
|
-
true
|
32
|
-
end
|
33
|
-
pipeline.pause
|
34
|
-
loop.run
|
35
|
-
pipeline.stop
|
36
|
-
|
37
|
-
if found_caps
|
38
|
-
puts("#{file} - #{found_caps}")
|
39
|
-
else
|
40
|
-
puts("#{file} - No type found")
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
ARGV.each do |file|
|
45
|
-
type_find(file)
|
46
|
-
end
|
data/sample/video-player.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
if ARGV.size != 1
|
4
|
-
$stderr.puts "Usage: #{$0} uri"
|
5
|
-
exit 1
|
6
|
-
end
|
7
|
-
|
8
|
-
require 'gtk2'
|
9
|
-
require 'gst'
|
10
|
-
require 'uri'
|
11
|
-
|
12
|
-
def normalize_uri(uri)
|
13
|
-
uri = URI(uri)
|
14
|
-
uri.scheme ||= "file"
|
15
|
-
if uri.scheme == "file"
|
16
|
-
"file://#{uri.path}"
|
17
|
-
else
|
18
|
-
uri.to_s
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
play_bin = Gst::ElementFactory.make('playbin')
|
23
|
-
bus = play_bin.bus
|
24
|
-
bus.add_watch do |bus, message|
|
25
|
-
case message.type
|
26
|
-
when Gst::Message::EOS
|
27
|
-
puts "end of stream"
|
28
|
-
Gtk.main_quit
|
29
|
-
when Gst::Message::ERROR
|
30
|
-
$stderr.puts "Error: #{message.parse}"
|
31
|
-
Gtk.main_quit
|
32
|
-
end
|
33
|
-
true
|
34
|
-
end
|
35
|
-
|
36
|
-
play_bin.uri = normalize_uri(ARGV.first)
|
37
|
-
video_sink = Gst::ElementFactory.make('xvimagesink')
|
38
|
-
play_bin.video_sink = video_sink
|
39
|
-
|
40
|
-
window = Gtk::Window.new
|
41
|
-
window.signal_connect('destroy') do
|
42
|
-
play_bin.stop
|
43
|
-
Gtk.main_quit
|
44
|
-
end
|
45
|
-
window.signal_connect('expose-event') do
|
46
|
-
video_sink.xwindow_id = window.window.xid
|
47
|
-
end
|
48
|
-
window.show_all
|
49
|
-
|
50
|
-
puts "Streaming #{play_bin.uri}..."
|
51
|
-
play_bin.play
|
52
|
-
|
53
|
-
begin
|
54
|
-
Gtk.main
|
55
|
-
rescue Interrupt
|
56
|
-
window.destroy
|
57
|
-
end
|
data/sample/xml-player.rb
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
### TODO: I want to set link in build_pipeline.
|
4
|
-
|
5
|
-
unless ARGV.size == 1
|
6
|
-
puts "Usage: #{$0} [file]"
|
7
|
-
exit 1
|
8
|
-
end
|
9
|
-
|
10
|
-
require 'gst'
|
11
|
-
|
12
|
-
XML_FILE = "/tmp/pipeline.xml"
|
13
|
-
PIPELINE_NAME = "our-pipeline"
|
14
|
-
|
15
|
-
def build_pipeline(file)
|
16
|
-
source = Gst::ElementFactory.make("filesrc")
|
17
|
-
decoder = Gst::ElementFactory.make("decodebin")
|
18
|
-
audio_converter = Gst::ElementFactory.make("audioconvert")
|
19
|
-
audio_resample = Gst::ElementFactory.make("audioresample")
|
20
|
-
audio_sink = Gst::ElementFactory.make("autoaudiosink")
|
21
|
-
source.location = file
|
22
|
-
pipeline = Gst::Pipeline.new(PIPELINE_NAME)
|
23
|
-
pipeline.add(source, decoder, audio_converter, audio_resample, audio_sink)
|
24
|
-
pipeline
|
25
|
-
end
|
26
|
-
|
27
|
-
def write_pipeline(pipeline, file)
|
28
|
-
Gst::XML.write_file(pipeline, file)
|
29
|
-
end
|
30
|
-
|
31
|
-
def read_pipeline(file)
|
32
|
-
xml = Gst::XML.new
|
33
|
-
xml.parse_file(file)
|
34
|
-
pipeline = xml.get_element(PIPELINE_NAME)
|
35
|
-
children = pipeline.children
|
36
|
-
source, decoder, audio_converter, audio_resample, audio_sink = children
|
37
|
-
source >> decoder
|
38
|
-
audio_converter >> audio_resample >> audio_sink
|
39
|
-
decoder.signal_connect("new-decoded-pad") do |element, pad|
|
40
|
-
sink_pad = audio_converter.get_pad("sink")
|
41
|
-
pad.link(sink_pad)
|
42
|
-
end
|
43
|
-
pipeline
|
44
|
-
end
|
45
|
-
|
46
|
-
def play_pipeline(pipeline)
|
47
|
-
pipeline.play
|
48
|
-
loop = GLib::MainLoop.new(nil, false)
|
49
|
-
begin
|
50
|
-
loop.run
|
51
|
-
rescue Interrupt
|
52
|
-
ensure
|
53
|
-
pipeline.stop
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
pipeline = build_pipeline(ARGV.first)
|
58
|
-
write_pipeline(pipeline, XML_FILE)
|
59
|
-
pipeline = read_pipeline(XML_FILE)
|
60
|
-
play_pipeline(pipeline)
|
data/test/gst-test-utils.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
module GstTestUtils
|
2
|
-
private
|
3
|
-
def only_gst_version(major, minor, micro)
|
4
|
-
unless Gst.check_version?(major, minor, micro)
|
5
|
-
omit("Require GStreamer >= #{major}.#{minor}.#{micro}")
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
def find_element_factory(name)
|
10
|
-
factory = Gst::ElementFactory.find(name)
|
11
|
-
assert_not_nil(factory, "#{name}'s factory should be found.")
|
12
|
-
factory
|
13
|
-
end
|
14
|
-
|
15
|
-
def create_element(element_name, name=nil)
|
16
|
-
find_element_factory(element_name).create(name)
|
17
|
-
end
|
18
|
-
end
|
data/test/run-test.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# ENV["GST_DEBUG"] = "GST_BUFFER:5"
|
4
|
-
|
5
|
-
base_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
6
|
-
|
7
|
-
if system("which make > /dev/null")
|
8
|
-
system("cd #{base_dir.dump} && make > /dev/null") or exit(1)
|
9
|
-
end
|
10
|
-
|
11
|
-
glib_dir = File.expand_path(File.join(base_dir, "..", "glib2"))
|
12
|
-
$LOAD_PATH.unshift(File.join(glib_dir, "test"))
|
13
|
-
require 'glib-test-init'
|
14
|
-
|
15
|
-
$LOAD_PATH.unshift(File.join(glib_dir, "ext", "glib2"))
|
16
|
-
$LOAD_PATH.unshift(File.join(glib_dir, "lib"))
|
17
|
-
|
18
|
-
$LOAD_PATH.unshift(File.join(base_dir, "ext", "gstreamer"))
|
19
|
-
$LOAD_PATH.unshift(File.join(base_dir, "lib"))
|
20
|
-
require "gst"
|
21
|
-
|
22
|
-
$LOAD_PATH.unshift(File.join(base_dir, "test"))
|
23
|
-
require 'gst-test-utils'
|
24
|
-
|
25
|
-
exit Test::Unit::AutoRunner.run(true)
|
data/test/test_bin.rb
DELETED
@@ -1,167 +0,0 @@
|
|
1
|
-
class TestBin < Test::Unit::TestCase
|
2
|
-
include GstTestUtils
|
3
|
-
|
4
|
-
def test_children
|
5
|
-
bin = Gst::Bin.new
|
6
|
-
|
7
|
-
element = create_element("filesink")
|
8
|
-
no_interface_element = create_element("fakesink")
|
9
|
-
bin << element << no_interface_element
|
10
|
-
|
11
|
-
assert_equal([no_interface_element, element], bin.children)
|
12
|
-
assert_equal([element], bin.children(Gst::ElementURIHandler))
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_size
|
16
|
-
bin = Gst::Bin.new
|
17
|
-
assert_equal(0, bin.size)
|
18
|
-
bin << create_element("fakesink")
|
19
|
-
assert_equal(1, bin.size)
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_children_cookie
|
23
|
-
bin = Gst::Bin.new
|
24
|
-
cookie = bin.children_cookie
|
25
|
-
assert_equal(cookie, bin.children_cookie)
|
26
|
-
bin << create_element("fakesink")
|
27
|
-
assert_not_equal(cookie, bin.children_cookie)
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_child_bus
|
31
|
-
bin = Gst::Bin.new
|
32
|
-
assert_not_nil(bin.child_bus)
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_messages
|
36
|
-
bin = Gst::Bin.new
|
37
|
-
assert_equal([], bin.messages)
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_polling?
|
41
|
-
bin = Gst::Bin.new
|
42
|
-
assert(!bin.polling?)
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_clock_dirty?
|
46
|
-
bin = Gst::Bin.new
|
47
|
-
assert(!bin.clock_dirty?)
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_provided_clock
|
51
|
-
bin = Gst::Bin.new
|
52
|
-
assert_nil(bin.provided_clock)
|
53
|
-
bin.provided_clock = Gst::SystemClock.new
|
54
|
-
assert_not_nil(bin.provided_clock)
|
55
|
-
bin.provided_clock = nil
|
56
|
-
assert_nil(bin.provided_clock)
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_clock_provider
|
60
|
-
bin = Gst::Bin.new
|
61
|
-
assert_nil(bin.clock_provider)
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_add
|
65
|
-
bin = Gst::Bin.new
|
66
|
-
element = create_element("fakesink")
|
67
|
-
bin << element
|
68
|
-
assert_equal(element, bin.children[0])
|
69
|
-
assert_raise(TypeError) do
|
70
|
-
bin << "XXX"
|
71
|
-
end
|
72
|
-
|
73
|
-
element2 = create_element("fakesink")
|
74
|
-
element3 = create_element("fakesink")
|
75
|
-
bin.add(element2, element3)
|
76
|
-
assert_equal([element3, element2], bin.children[0, 2])
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_remove
|
80
|
-
bin = Gst::Bin.new
|
81
|
-
element1 = create_element("fakesink")
|
82
|
-
element2 = create_element("fakesink")
|
83
|
-
bin << element1 << element2
|
84
|
-
assert_equal(2, bin.size)
|
85
|
-
bin.remove(element1, element2)
|
86
|
-
assert_equal(0, bin.size)
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_clear
|
90
|
-
bin = Gst::Bin.new
|
91
|
-
element1 = create_element("fakesink")
|
92
|
-
element2 = create_element("fakesink")
|
93
|
-
bin << element1 << element2
|
94
|
-
assert_equal(2, bin.size)
|
95
|
-
bin.clear
|
96
|
-
assert_equal(0, bin.size)
|
97
|
-
end
|
98
|
-
|
99
|
-
def test_refer_by_name
|
100
|
-
bin = Gst::Bin.new
|
101
|
-
sub_bin = Gst::Bin.new
|
102
|
-
bin << sub_bin
|
103
|
-
|
104
|
-
element = create_element("fakesink")
|
105
|
-
assert_nil(bin.get_child(element.name))
|
106
|
-
assert_nil(sub_bin.get_child(element.name))
|
107
|
-
assert_nil(sub_bin.get_child(element.name, true))
|
108
|
-
|
109
|
-
bin << element
|
110
|
-
assert_equal(element, bin.get_child(element.name))
|
111
|
-
assert_equal(element, bin.get_child(element.name, true))
|
112
|
-
assert_nil(sub_bin.get_child(element.name))
|
113
|
-
assert_equal(element, sub_bin.get_child(element.name, true))
|
114
|
-
end
|
115
|
-
|
116
|
-
def test_refer_by_interface
|
117
|
-
bin = Gst::Bin.new
|
118
|
-
element = create_element("filesink")
|
119
|
-
|
120
|
-
assert_nil(bin.get_child(Gst::ElementURIHandler))
|
121
|
-
|
122
|
-
bin << create_element("fakesink")
|
123
|
-
assert_nil(bin.get_child(Gst::ElementURIHandler))
|
124
|
-
|
125
|
-
bin << element
|
126
|
-
assert_equal(element, bin.get_child(Gst::ElementURIHandler))
|
127
|
-
end
|
128
|
-
|
129
|
-
def test_refer_by_index
|
130
|
-
bin = Gst::Bin.new
|
131
|
-
element1 = create_element("filesink")
|
132
|
-
element2 = create_element("fakesink")
|
133
|
-
|
134
|
-
assert_nil(bin.get_child(0))
|
135
|
-
assert_nil(bin.get_child(1))
|
136
|
-
assert_nil(bin.get_child(2))
|
137
|
-
|
138
|
-
bin << element1 << element2
|
139
|
-
assert_equal(element2, bin.get_child(0))
|
140
|
-
assert_equal(element1, bin.get_child(1))
|
141
|
-
assert_nil(bin.get_child(2))
|
142
|
-
end
|
143
|
-
|
144
|
-
def test_sinks
|
145
|
-
bin = Gst::Bin.new
|
146
|
-
sink1 = create_element("filesink")
|
147
|
-
sink2 = create_element("fakesink")
|
148
|
-
src = create_element("fakesrc")
|
149
|
-
|
150
|
-
assert_equal([], bin.sinks)
|
151
|
-
|
152
|
-
bin << src << sink1 << sink2
|
153
|
-
assert_equal([sink2, sink1], bin.sinks)
|
154
|
-
end
|
155
|
-
|
156
|
-
def test_sources
|
157
|
-
bin = Gst::Bin.new
|
158
|
-
src1 = create_element("filesrc")
|
159
|
-
src2 = create_element("fakesrc")
|
160
|
-
sink = create_element("fakesink")
|
161
|
-
|
162
|
-
assert_equal([], bin.sources)
|
163
|
-
|
164
|
-
bin << src1 << src2 << sink
|
165
|
-
assert_equal([src2, src1], bin.sources)
|
166
|
-
end
|
167
|
-
end
|