Hello I tried to port to port http://cgit.freedesktop.org/gstreamer/gstreamer/tr... to ruby. My firsts remarks are : 1) Gst.init method crashes if called more than once. gobject-introspection/loader.rb is redefining the method (line 74). 2) Default argument for Gst.init method is ARGV. Why is that? I would rather use nil or empty string The arguments for the current ruby script have usually nothing to do with gst. 3) ARGV is chaged by Gst.init method. It caused me some troubles. 4) A lot of constant are not defined by introspection (e.g. VERSION, Message::ERROR) 5) Methods returning boolean does not end by ?. 6) The code I used with some more remark. unless uri=ARGV[0] STDERR.puts "usage: #{$0} uri" exit 1 end require 'gst' #p ARGV Gst.init#TODO put it in gst.rb #p Gst.init#2nd call crash the app #p ARGV#Gst.init change ARGV! Gst::Message::ERROR=1<<1#Not defined! Gst::Message::EOS=1<<0 loop=GLib::MainLoop.new(nil, false) playbin=Gst::ElementFactory.make('playbin')#TODO test return playbin.bus.add_watch(1){|_, message|#Need an argument! #p message.parse#no more magic parse based on class! case message.type when Gst::Message::EOS loop.quit when Gst::Message::ERROR p message.parse_error#crash else p message.type end true } uri=Gst.filename_to_uri(uri) unless Gst.uri_is_valid(uri)#use uri_is_valid? for method name playbin.uri=uri playbin.volume=0.2 #playbin.play#No more convenient methods playbin.state=Gst::State::PLAYING at_exit{p 'Exit. TODO: cleaning'} loop.run 7) in lib/gst.rb file module Gst class << self @initialized = false def init(argv=ARGV) return if @initialized At that point @initialized is nil and not false ! module Gst @initialized = false class << self def init(argv=ARGV) return if @initialized seems to do what was expected but I am not sure why. Except for points 2 and 3 I have at the moment no idea on how to improve the code. gobject-introspection is black magic !
on 2013-02-09 19:02
on 2013-02-10 05:41
Hi, In <CAENqjqcu6X1pFYGnkr9WBy8ojirH=tTzNCmA6Mnz636-zd_5sA@mail.gmail.com> "[ruby-gnome2-devel-en] Gstreamer-gi" on Sat, 9 Feb 2013 19:01:45 +0100, Vincent Carmona <vinc4mai@gmail.com> wrote: > I tried to port to port > http://cgit.freedesktop.org/gstreamer/gstreamer/tr... > to > ruby. Thanks for trying it! A Japanese also working on it. And some problems were fixed. He and I are working on gstreamer-gi/ directory: https://github.com/ruby-gnome2/ruby-gnome2/tree/ma... You can use it by the following commands: % git clone https://github.com/ruby-gnome2/ruby-gnome2 % cd ruby-gnome2 [ruby-gnome2]% cd glib2 [glib2]% ruby extconf.rb [glib2]% make [glib2]% cd ../gobject-introspection [gobject-introspection]% ruby extconf.rb [gobject-introspection]% make [gobject-introspection]% cd ../gstreamer-gi [gstreamer-gi]% ruby extconf.rb [gstreamer-gi]% make [gstreamer-gi]% ruby \ -I ../glib2/lib \ -I ../glib2/ext/glib2 \ -I ../gobject-introspection/lib \ -I ../gobject-introspection/ext/gobject-introspection \ helloworld.rb > My firsts remarks are : > 1) > Gst.init method crashes if called more than > once. gobject-introspection/loader.rb is redefining the method (line 74). Thanks. I've fixed it: https://github.com/ruby-gnome2/ruby-gnome2/commit/... > 2) > Default argument for Gst.init method is ARGV. Why is that? I would rather > use nil or empty string$B!D(B The arguments for the current ruby script have > usually nothing to do with gst. Umm... I thought "--gst-debug-level=3" like argument may be useful... You can pass empty arguments by: Gst.init([]) > 3) > ARGV is chaged by Gst.init method. It caused me some troubles. I've fixed it: https://github.com/ruby-gnome2/ruby-gnome2/commit/... > 4) > A lot of constant are not defined by introspection (e.g. VERSION, > Message::ERROR$B!D(B) It had been fixed in master. Could you try master? VERSION -> Gst.version Message::ERROR -> Gst::MessageType::ERROR > 5) > Methods returning boolean does not end by ?. It is Gst.uri_is_valid, isn't it? I've fixed it: https://github.com/ruby-gnome2/ruby-gnome2/commit/... https://github.com/ruby-gnome2/ruby-gnome2/commit/... Gst.uri_is_valid was renamed to Gst.valid_uri? > 6) > The code I used with some more remark. Thanks! > unless uri=ARGV[0] > STDERR.puts "usage: #{$0} uri" > exit 1 > end > > require 'gst' > #p ARGV > Gst.init#TODO put it in gst.rb > #p Gst.init#2nd call crash the app Fixed. > #p ARGV#Gst.init change ARGV! > Gst::Message::ERROR=1<<1#Not defined! > Gst::Message::EOS=1<<0 They can be removed. > loop=GLib::MainLoop.new(nil, false) > playbin=Gst::ElementFactory.make('playbin')#TODO test return > playbin.bus.add_watch(1){|_, message|#Need an argument! Fixed: https://github.com/ruby-gnome2/ruby-gnome2/commit/... > #p message.parse#no more magic parse based on class! > case message.type > when Gst::Message::EOS > loop.quit > when Gst::Message::ERROR > p message.parse_error#crash Umm... I'll consider about it... > #playbin.play#No more convenient methods I've added it: https://github.com/ruby-gnome2/ruby-gnome2/commit/... > playbin.state=Gst::State::PLAYING > at_exit{p 'Exit. TODO: cleaning'} > loop.run > > module Gst > @initialized = false > class << self > def init(argv=ARGV) > return if @initialized > > seems to do what was expected but I am not sure why. Oh! I've fixed it: https://github.com/ruby-gnome2/ruby-gnome2/commit/... > gobject-introspection is black magic ! I think so too. :-) Thanks for your report! It is very helpful! -- kou
on 2013-02-10 10:54
On Sun, 2013-02-10 at 13:40 +0900, Kouhei Sutou wrote: > Thanks. I've fixed it: ... > I've fixed it: ... > It had been fixed in master. Could you try master? ... > Gst.uri_is_valid was renamed to Gst.valid_uri? ... > Fixed. ... > I've added it: ... > Oh! I've fixed it: ... > I think so too. :-) Wow! Amazing response. Thank you Kou for your hard work! Regards Grant
on 2013-02-10 15:51
Thanks for this reply and these fast fixes. One remark: I would have worked on a copy of ARGV inside Gst module, to be sure ARGV is left untouched outside. Then you can set @init_arguments with what you want and undo the last commit in this point. -def init(argv=ARGV) +def init(argv=ARGV.dup)
on 2013-02-11 10:45
Hi, In <CAENqjqf7g14hsNP7aOA98abu_c-s-eQ8rykWQC2Ahp0dmYZOWA@mail.gmail.com> "Re: [ruby-gnome2-devel-en] Gstreamer-gi" on Sun, 10 Feb 2013 15:50:11 +0100, Vincent Carmona <vinc4mai@gmail.com> wrote: > Thanks for this reply and these fast fixes. You're welcome. :-) Now, we have workable script: https://github.com/ruby-gnome2/ruby-gnome2/blob/ma... > One remark: I would have worked on a copy ofARGV inside Gst module, to be > sureARGV is left untouched outside. Then you can set@init_arguments with > what you want and undo the last commit in this point. > > -def init(argv=ARGV) > +def init(argv=ARGV.dup) I stopped using ARGV. Now: def init(*argv) Users who want to customize GStreamer initialization should pass parameters to Gst.init explicitly. For example: Gst.init("--gst-debug-level=3") Thanks, -- kou
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.