Multiple pipelines and unit testing

331 views
Skip to first unread message

thor

unread,
Aug 29, 2008, 4:30:56 AM8/29/08
to gstreamer-java
So I've been setting up multiple pipelines which I'm feeding various
media files to run some stability tests.

This is all done through junit, but I'm having trouble running more
that one test at a time probably because of lack of understanding of
the init/deinit procedure.

I'm currently doing this in each test
......

private void init() {
Gst.init()
pipeline = new Pipeline();
Bus bus = pipeline.getBus();

bus.connect(new Bus.ERROR() {
public void errorMessage(GstObject source, int code, String
message) {
logger.error("Error: code=" + code + " message=" + message);
pipeline.setState(State.NULL);
setError(true);
setErrorMessage(message);
Gst.quit();
}
});

bus.connect(new Bus.EOS() {
public void endOfStream(GstObject source) {
pipeline.setState(State.NULL);
logger.info("End of stream reached exiting normally");
Gst.quit();
}
});
}

****************************
then I set up the pipeline with the different element and call
.....
pipeline.play();
Gst.main();

// make sure to remove all references before deinitializing
.... //freeing all element stuff

pipeline = null;

Gst.deinit();

if (error)
throw new Exception(getErrorMessage());
.....
// end of test
***************************

So everything runs great in the first unittest but the second time I
try to create a pipeline I get this

java.lang.IllegalArgumentException: Invalid native pointer
at org.gstreamer.lowlevel.NativeObject.initializer(NativeObject.java:
66)
at org.gstreamer.GstObject.initializer(GstObject.java:62)
at org.gstreamer.Pipeline.<init>(Pipeline.java:99)


Any help appreciated...

/Thor



talos

unread,
Aug 29, 2008, 7:26:37 AM8/29/08
to gstreamer-java
Thor, I think you might have stumbled upon two possible bugs:

1. After a call to Gst.deinit() you can not create/use anymore
pipelines.
2. Even if you comment out Gst.deinit() and try to use Gst.main()/
Gst.quit() it works only once.

I have written a JUnit test case in the spirit of your code below with
a work around these problems, where Gst.deinit() is commented out. I
also use Object.wait()/Object.notify() instead of Gst.main()/
Gst.quit():

Instructions:
1. Download the test case from http://gstreamer-java.googlegroups.com/web/ThorTest.java
and add to your favorite IDE
2. Download the test audio file http://gstreamer-java.googlegroups.com/web/bong.wav
and place it under '/tmp'

Wayne Meissner

unread,
Aug 29, 2008, 10:29:57 AM8/29/08
to gstream...@googlegroups.com
2008/8/29 talos <tsh...@gmail.com>:

>
> Thor, I think you might have stumbled upon two possible bugs:
>
> 1. After a call to Gst.deinit() you can not create/use anymore
> pipelines.

Has anyone tried the same thing under C or python to see if its a
gstreamer problem, or something in the java bindings?

> 2. Even if you comment out Gst.deinit() and try to use Gst.main()/
> Gst.quit() it works only once.

This should now work. There is an example in
src/org/gstreamer/example/DoubleQuit.java that sets up a pipeline,
calls Gst.main, and quits from it a second later, then does the whole
thing all over again.

thor

unread,
Aug 29, 2008, 10:54:12 AM8/29/08
to gstreamer-java
Thanks Wayne, will try it out over the weekend....

Have a good one by the way :-)
/thor

talos

unread,
Aug 29, 2008, 10:40:50 PM8/29/08
to gstreamer-java
I have tried a test case by-passing as much of gstreamer-java wrapper
code as possible - i.e. calling gst_init(), gst_deinit() and
gst_parse_launch() directly via their JNA interface. The pipeline
works only once. After calling gst_deinit() and then gst_init()
subsequent pipeline creation using the same pipeline spec fails with
lowlevel error message complaining about 'no element "videotestsrc"'

Under the gst-python binding I could not find any wrapping of
gst_deinit(). I think maybe they did not bother

Need to write the test in C and file a bug report against upstream if
it fails.

Wayne Meissner

unread,
Aug 30, 2008, 12:34:14 AM8/30/08
to gstream...@googlegroups.com
Thanks for doing all that work, Talos!

2008/8/30 talos <tsh...@gmail.com>:

talos

unread,
Aug 30, 2008, 7:10:48 AM8/30/08
to gstreamer-java
It is only fair to put something back sometimes. It is also self-
serving, Wayne; I hope it helps conserving your time and energy for
the real difficult ones, eh?

On Aug 30, 7:34 am, "Wayne Meissner" <wmeiss...@gmail.com> wrote:
> Thanks for doing all that work, Talos!
>
> 2008/8/30 talos <tsha...@gmail.com>:

thor

unread,
Sep 4, 2008, 5:50:48 AM9/4/08
to gstreamer-java
Thanks talos

That solved things sofar in my end. I'm able to run all my unit tests
now :-)

/thor


On Aug 29, 1:26 pm, talos <tsha...@gmail.com> wrote:
> Thor, I think you might have stumbled upon two possible bugs:
>
> 1. After a call to Gst.deinit() you can not create/use anymore
> pipelines.
> 2. Even if you comment out Gst.deinit() and try to use Gst.main()/
> Gst.quit() it works only once.
>
> I have written a JUnit test case in the spirit of your code below with
> a work around these problems, where Gst.deinit() is commented out. I
> also use Object.wait()/Object.notify() instead of Gst.main()/
> Gst.quit():
>
> Instructions:
> 1. Download the test case fromhttp://gstreamer-java.googlegroups.com/web/ThorTest.java
> and add to your favorite IDE
> 2. Download the test audio filehttp://gstreamer-java.googlegroups.com/web/bong.wav
Reply all
Reply to author
Forward
0 new messages