jruby and gstreamer-java

24 views
Skip to first unread message

LeonB

unread,
Mar 19, 2008, 6:50:27 PM3/19/08
to gstreamer-java
Hi all,

I'm having some dificulties with gettings started with gstreamer-java.
I have this jruby script:

#!/usr/bin/env jruby

include Java
require '/home/leon/Desktop/jna-3.0.jar'
require '/home/leon/Desktop/gstreamer-java-0.6.jar'
import org.gstreamer.Gst
#import org.gstreamer.GMainLoop

gst = Gst.init('AudioPlayer', '??')

When I run it:

leon@polly:~$ jruby jruby_require_test.rb
jruby_require_test.rb:3: no init with arguments matching [class
java.lang.String, class java.lang.String] on object JavaUtilities
(NameError)

What should be the second parameter of Gst.init() ?
Also, when I do: Playbin.new() I get:

uninitialized constant Playbin (NameError)

Can somebody help me with this?

Wayne Meissner

unread,
Mar 21, 2008, 5:04:47 AM3/21/08
to gstream...@googlegroups.com
Gst.init() takes two parameters: the name of the program (use whatever
you want) as a java.lang.String, and a second parameter that is an
array of java.lang.String which contains the arguments passed into the
program.

So you should call it something like (my JRuby is a bit rusty):

args = Gst.init('AudioPlayer', [ "" ].to_java(:String))

As for the PlayBin error, I think you have to import
org.gstreamer.elements.PlayBin as well (and all other gstreamer-java
classes you want to use)

e.g.
import Java::org.gstreamer.elements.PlayBin

player = PlayBin.new("my-playbin")

LeonB

unread,
Mar 24, 2008, 3:39:37 AM3/24/08
to gstreamer-java
Thanks Wayne!

Sorry I didn't respond any sooner.
Your example worked great! Gonna try and make it all work.

LeonB

unread,
Mar 24, 2008, 5:15:39 PM3/24/08
to gstreamer-java
Hi Wayne,

I'm trying to do something like:

import org.gstreamer.Gst
import org.gstreamer.elements.PlayBin
import org.gstreamer.ElementFactory
import org.gstreamer.State

with this:

module Gstreamer
include_package 'import org.gstreamer
end

But then I can't access org.gstreamer.Gst via the Gstreamer module.
When I try to do:
Gstreamer.Gst.init()

I get the following error message:
NameError: uninitialized constant Gstreamer::Gst

I really wanted to do something like:
import org.gstreamer.*

but I read that can't be done in Jruby.

Leon

LeonB

unread,
Mar 24, 2008, 6:04:54 PM3/24/08
to gstreamer-java
Sorry for being such a dumbass... but would you happen to now how I
implement something like:

playbin.getBus().connect(new Bus.STATE_CHANGED() {
public void stateChanged(GstObject source, State old,
State current, State pending) {
if (source == playbin) {
System.out.println("Pipeline state changed from "
+ old + " to " + current);
}
}
});

that in jruby? I thought it looked like a Proc. But trying that
resulted in an error message :)

LeonB

unread,
Mar 26, 2008, 7:07:15 PM3/26/08
to gstreamer-java
Got it! The answer can be found here: http://pastie.caboo.se/171249

Wayne Meissner

unread,
Mar 26, 2008, 7:27:45 PM3/26/08
to gstream...@googlegroups.com
Here is a different take on it:

include Java
require 'gstreamer-java.jar'
import org.gstreamer.Gst
import org.gstreamer.ElementFactory
import org.gstreamer.Bin

Gst.init("foo", java.lang.String[0].new)
foo = ElementFactory.make("fakesrc", "foo")
elementAdded = Bin::ELEMENT_ADDED.impl { |bin, element|
puts "Element #{element} added to bin"
}
bin = Bin.new("foo-bin")
bin.connect(elementAdded)
bin.add(foo)


That should be a bit cleaner than the way you did it (which, I think,
was overriding the callback for all the listener instances)

LeonB

unread,
Mar 27, 2008, 4:03:17 AM3/27/08
to gstreamer-java
Thanks Wayne.

Why are you, in your example, using the Bin class and nog the Playbin
class?

Wayne Meissner

unread,
Mar 27, 2008, 4:25:24 AM3/27/08
to gstream...@googlegroups.com
I just used Bin because I needed something I could write in a hurry,
and I could remember what signals Bin emitted without looking at the
documentation.

On 27/03/2008, LeonB <le...@tim-online.nl> wrote:
>

Reply all
Reply to author
Forward
0 new messages