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
@@ -0,0 +1,417 @@
1
+ #!/usr/bin/evn ruby
2
+
3
+ require 'optparse'
4
+ require 'ostruct'
5
+
6
+ argv = ARGV.dup
7
+ ARGV.clear
8
+
9
+ require 'gst'
10
+
11
+ def parse(argv)
12
+ options = OpenStruct.new
13
+ options.print_all = false
14
+ options.print_auto_install_info = false
15
+
16
+ opts = OptionParser.new do |opts|
17
+ opts.banner += " [ELEMENT-NAME|PLUGIN-NAME]"
18
+
19
+ opts.version = Gst.version
20
+
21
+ opts.separator("")
22
+ opts.on("-a", "--print-all", "Print all elements") do
23
+ options.print_all = true
24
+ end
25
+
26
+ opts.on("--print-plugin-auto-install-info",
27
+ "Print a machine-parsable list of features",
28
+ "the specified plugin provides.",
29
+ "Useful in connection with external",
30
+ "automatic plugin installation mechanisms") do
31
+ options.print_auto_install_info = true
32
+ end
33
+ end
34
+ opts.parse!(argv)
35
+
36
+ [options, argv.first]
37
+ end
38
+
39
+ class Inspector
40
+ def initialize
41
+ @prefix = ""
42
+ end
43
+
44
+ def print_list(print_all)
45
+ plugins = {}
46
+ n_features = 0
47
+ each_feature do |plugin, feature|
48
+ plugins[plugin.name] = nil
49
+ n_features += 1
50
+ if print_all
51
+ if feature.is_a?(Gst::ElementFactory)
52
+ print_element_factory(feature, true)
53
+ end
54
+ else
55
+ print_feature(plugin, feature)
56
+ end
57
+ end
58
+ puts
59
+ puts("Total count: #{plugins.size} plugins, #{n_features} features")
60
+ end
61
+
62
+ def print_element(name)
63
+ factory = Gst::ElementFactory.find(name)
64
+ print_element_factory(factory, false)
65
+ end
66
+
67
+ private
68
+ def puts(*args)
69
+ if args.empty?
70
+ super(@prefix)
71
+ else
72
+ super(*(args.collect {|arg| "#{@prefix}#{arg}"}))
73
+ end
74
+ end
75
+
76
+ def prefix(new_prefix)
77
+ prefix, @prefix = @prefix, new_prefix
78
+ yield
79
+ ensure
80
+ @prefix = prefix
81
+ end
82
+
83
+ def each_feature
84
+ registry = Gst::Registry.default
85
+ registry.plugins.sort_by {|plugin| plugin.name}.each do |plugin|
86
+ features = registry.get_features(plugin.name)
87
+ features.sort_by {|feature| feature.name}.each do |feature|
88
+ yield(plugin, feature)
89
+ end
90
+ end
91
+ end
92
+
93
+ def print_factory_details_info(factory)
94
+ rank_name = factory.rank.name
95
+ rank_name ||= "unknown"
96
+ rank_name = rank_name.gsub(/GST_RANK_/, '').downcase
97
+
98
+ puts("Factory Details:",
99
+ " Long name:\t#{factory.long_name}",
100
+ " Class:\t#{factory.klass}",
101
+ " Description:\t#{factory.description}",
102
+ " Author(s):\t#{factory.author}",
103
+ " Rank:\t\t#{rank_name} (#{factory.rank.to_i})",
104
+ "")
105
+ end
106
+
107
+ def print_plugin_info(name)
108
+ return if name.nil?
109
+ registry = Gst::Registry.default
110
+ plugin = registry.find_plugin(name)
111
+ return if plugin.nil?
112
+
113
+ puts("Plugin Details:",
114
+ " Name:\t\t\t#{plugin.name}",
115
+ " Description:\t\t#{plugin.description}",
116
+ " Filename:\t\t#{plugin.filename || '(null)'}",
117
+ " Version:\t\t#{plugin.version}",
118
+ " License:\t\t#{plugin.license}",
119
+ " Source module:\t#{plugin.source}",
120
+ " Binary package:\t#{plugin.package}",
121
+ " Origin URL:\t\t#{plugin.origin}",
122
+ "")
123
+ end
124
+
125
+ def print_hierarchy(element)
126
+ ancestors = []
127
+ type = element.gtype
128
+ while type
129
+ ancestors << type
130
+ type = type.parent
131
+ end
132
+ ancestors.reverse.each_with_index do |klass, i|
133
+ if i.zero?
134
+ mark = ""
135
+ else
136
+ mark = " " + (" " * (i - 1)) + "+----"
137
+ end
138
+ puts("#{mark}#{klass.name}")
139
+ end
140
+ puts
141
+ end
142
+
143
+ def print_interfaces(element)
144
+ interfaces = element.gtype.interfaces
145
+ return if interfaces.empty?
146
+
147
+ puts("Implemented Interfaces:")
148
+ interfaces.each do |interface|
149
+ puts(" #{interface.name}")
150
+ end
151
+ puts
152
+ end
153
+
154
+ def print_caps(caps)
155
+ if caps.any?
156
+ puts("ANY")
157
+ return
158
+ end
159
+ if caps.empty?
160
+ puts("EMPTY")
161
+ return
162
+ end
163
+
164
+ caps.each do |structure|
165
+ puts(structure.name)
166
+ structure.each do |key, value|
167
+ puts(" %15s: %s" % [key, value.inspect])
168
+ end
169
+ end
170
+ end
171
+
172
+ def print_pad_template_info(template)
173
+ prefix("#{@prefix} ") do
174
+ puts("#{template.direction.nick.upcase} template: '#{template.name}'")
175
+ prefix("#{@prefix} ") do
176
+ if template.presence == Gst::Pad::REQUEST
177
+ puts("Availability: On request")
178
+ else
179
+ puts("Availability: #{template.presence.nick.capitalize}")
180
+ end
181
+ end
182
+ end
183
+
184
+ static_caps = template.caps
185
+ return if static_caps.description.nil?
186
+ prefix("#{@prefix} ") do
187
+ puts("Capabilities:")
188
+ prefix("#{@prefix} ") do
189
+ print_caps(static_caps.to_caps)
190
+ end
191
+ end
192
+ puts
193
+ end
194
+
195
+ def print_pad_templates_info(element, factory)
196
+ puts("Pad Templates:")
197
+ templates = factory.pad_templates
198
+
199
+ if templates.empty?
200
+ puts(" none")
201
+ return
202
+ end
203
+
204
+ templates.each do |template|
205
+ print_pad_template_info(template)
206
+ end
207
+ end
208
+
209
+ def print_element_flag_info(element)
210
+ puts("Element Flags")
211
+ puts(" no flags set")
212
+ puts
213
+
214
+ return unless element.is_a?(Gst::Bin)
215
+ puts("Bin Flags:")
216
+ puts(" no flags set")
217
+ puts
218
+ end
219
+
220
+ def print_implementation_info(element)
221
+ puts("Element Implementation:")
222
+ puts(" not supported")
223
+ puts
224
+ end
225
+
226
+ def print_clocking_info(element)
227
+ if !element.require_clock? and
228
+ !element.provide_clock? and
229
+ element.clock.nil?
230
+ puts("Element has no clocking capabilities.")
231
+ puts
232
+ return
233
+ end
234
+
235
+ puts("Clocking Interaction:")
236
+ puts(" element requires a clock") if element.require_clock?
237
+ if element.provide_clock?
238
+ clock = element.clock
239
+ if clock.nil?
240
+ puts(" element is supported tot provide a clock but returned nil")
241
+ else
242
+ puts(" element provides a clock: #{clock.name}")
243
+ end
244
+ end
245
+ puts
246
+ end
247
+
248
+ def print_index_info(element)
249
+ if element.indexable?
250
+ puts("Indexing capabilities:")
251
+ puts(" element can do indexing")
252
+ else
253
+ puts("Element has no indexing capabilities.")
254
+ end
255
+ puts
256
+ end
257
+
258
+ def print_pad_info(element)
259
+ puts("Pads:")
260
+ pads = element.pads
261
+ if pads.empty?
262
+ puts(" none")
263
+ return
264
+ end
265
+
266
+ pads.each do |pad|
267
+ prefix("#{@prefix} ") do
268
+ puts("#{pad.direction.nick.upcase}: '#{pad.name}'")
269
+ prefix("#{@prefix} ") do
270
+ template = pad.template
271
+ puts("Pad Template: '#{template.name}'") if template
272
+
273
+ caps = pad.caps
274
+ break if caps.nil?
275
+ puts("Capabilities:")
276
+ prefix("#{@prefix} ") do
277
+ print_caps(caps)
278
+ end
279
+ end
280
+ end
281
+ end
282
+ puts
283
+ end
284
+
285
+ def print_element_properties_info(element)
286
+ puts("Element Properties:")
287
+ properties = element.class.properties
288
+ if properties.empty?
289
+ puts(" none")
290
+ return
291
+ end
292
+
293
+ properties.each do |name|
294
+ param = element.class.property(name)
295
+ puts(" %-20s: %s" % [param.name, param.blurb])
296
+
297
+ flags = []
298
+ flags << "readable" if param.readable?
299
+ flags << "writable" if param.writable?
300
+ # flags << "controllable" if param.controllable?
301
+
302
+ prefix("#{@prefix}#{' ' * 23} ") do
303
+ puts("flags: #{flags.join(', ')}")
304
+ type_name = param.value_type.name
305
+ if param.readable?
306
+ current_value = element.get_property(name)
307
+ value = "Default: #{param.default.inspect} "
308
+ value << "Current: #{current_value.inspect}"
309
+ end
310
+ write_only = param.readable? ? "" : " Write only"
311
+ puts("#{type_name}. #{value}#{write_only}")
312
+ end
313
+ end
314
+ puts
315
+ end
316
+
317
+ def print_signal_info(element, signal)
318
+ args = ["object(#{element.class})"]
319
+ signal.param_types.each_with_index do |name, i|
320
+ args << "arg#{i}(#{name})"
321
+ end
322
+ args = args.join(", ")
323
+ signature = "{|#{args}| ...} # => #{signal.return_type}"
324
+ puts(" #{signal.name.inspect}: #{signature}")
325
+ end
326
+
327
+ def print_signals_info(element)
328
+ signals = []
329
+ actions = []
330
+ element.class.signals.each do |name|
331
+ signal = element.class.signal(name)
332
+ next if signal.owner >= Gst::Element
333
+ if signal.action?
334
+ actions << signal
335
+ else
336
+ signals << signal
337
+ end
338
+ end
339
+
340
+ [[signals, "Signals"],
341
+ [actions, "Actions"]].each do |target_signals, description|
342
+ unless target_signals.empty?
343
+ puts("Element #{description}:")
344
+ target_signals.each do |signal|
345
+ print_signal_info(element, signal)
346
+ end
347
+ end
348
+ end
349
+ puts
350
+ end
351
+
352
+ def print_children_info(element)
353
+ return unless element.is_a?(Gst::Bin)
354
+ children = element.children
355
+ return if children.empty?
356
+
357
+ puts("Children:")
358
+ children.each do |child|
359
+ puts(" #{child.name}")
360
+ end
361
+ end
362
+
363
+ def print_element_factory(factory, print_names)
364
+ if !factory.load!
365
+ puts("element plugin (#{factory.name}) couldn't be loaded\n")
366
+ return
367
+ end
368
+
369
+ element = factory.create
370
+
371
+ prefix(print_names ? "#{factory.name}: " : "") do
372
+ print_factory_details_info(factory)
373
+ print_plugin_info(factory.plugin_name)
374
+
375
+ print_hierarchy(element)
376
+ print_interfaces(element)
377
+
378
+ print_pad_templates_info(element, factory)
379
+ print_element_flag_info(element)
380
+ print_implementation_info(element)
381
+ print_clocking_info(element)
382
+ print_index_info(element)
383
+ print_pad_info(element)
384
+ print_element_properties_info(element)
385
+ print_signals_info(element)
386
+ print_children_info(element)
387
+ end
388
+ end
389
+
390
+ def print_feature(plugin, feature)
391
+ prefix("#{plugin.name}: #{feature.name}") do
392
+ case feature
393
+ when Gst::ElementFactory
394
+ puts(": #{feature.long_name}")
395
+ when Gst::IndexFactory
396
+ puts(": #{feature.description}")
397
+ when Gst::TypeFindFactory
398
+ if feature.extensions.empty?
399
+ message = "no extensions"
400
+ else
401
+ message = feature.extensions.join(", ")
402
+ end
403
+ puts(": #{message}")
404
+ else
405
+ puts(" (#{feature.gtype})")
406
+ end
407
+ end
408
+ end
409
+ end
410
+
411
+ options, element_name = parse(argv)
412
+ inspector = Inspector.new
413
+ if element_name
414
+ inspector.print_element(element_name)
415
+ else
416
+ inspector.print_list(options.print_all)
417
+ end
@@ -0,0 +1,55 @@
1
+
2
+ # This program uses the media-info library to display information
3
+ # embedded in media files (tags in MP3/OGG files for instance).
4
+
5
+ require 'gst'
6
+
7
+ def print_hash(hash)
8
+ hash.each { |key, val| puts " #{key}: #{val}" }
9
+ end
10
+
11
+ def print_info(stream)
12
+ puts "- mime type: #{stream.mime}"
13
+ puts "- length: #{stream.length_time / Gst::SECOND} seconds"
14
+ puts "- bitrate: #{stream.bitrate / 1000.0} kbps"
15
+ puts "- number of tracks: #{stream.length_tracks}"
16
+ i = 0
17
+ stream.tracks.each do |x|
18
+ puts "- track #{i += 1}:"
19
+ puts " - metadata:"
20
+ if hash = x.metadata
21
+ print_hash(hash)
22
+ end
23
+ puts " - streaminfo:"
24
+ if hash = x.streaminfo
25
+ print_hash(hash)
26
+ end
27
+ puts " - format:"
28
+ if caps = x.format
29
+ caps.length.times { |i| print_hash(caps.get_structure(i)) }
30
+ end
31
+ end
32
+ end
33
+
34
+ Gst.init
35
+
36
+ if ARGV.empty?
37
+ $stderr.puts "Usage: #{__FILE__} files..."
38
+ exit 1
39
+ end
40
+
41
+ begin
42
+ info = Gst::MediaInfo.new
43
+ info.source = "filesrc"
44
+
45
+ ARGV.each do |x|
46
+ if stream = info.read(x)
47
+ print_info(stream)
48
+ else
49
+ $stderr.puts "No media info found for file #{x}."
50
+ end
51
+ end
52
+ rescue => e
53
+ $stderr.puts "Media error: #{e}."
54
+ exit 1
55
+ end