// Instead of using a playbin, it would be possible to use a pipe
// a typefind element and a demux and wire them up manually.
//
final PlayBin2 pipe = new PlayBin2(progname);
pipe.setInputFile(new File(args[0]));
FakeSink audio = (FakeSink) ElementFactory.make("fakesink", "audio-sink");
FakeSink video = (FakeSink) ElementFactory.make("fakesink", "video-sink");
pipe.setAudioSink(audio);
pipe.setVideoSink(video);
pipe.getBus().connect(new Bus.TAG() {
public void tagsFound(GstObject source, TagList tagList) {
for (String tag : tagList.getTagNames()) {
System.out.println("Found tag " + tag + " = "
+ tagList.getValue(tag, 0));
}
}
});
//
// In theory, an ASYNC_DONE from the pipeline corresponds with the demux
// completing parsing the media file
//
pipe.getBus().connect(new Bus.ASYNC_DONE() {
public void asyncDone(GstObject source) {
pipe.stop();
done.countDown();
}
});
audio.set("signal-handoffs", true);
video.set("signal-handoffs", true);
//
// As soon as data starts to flow, it means all tags have been found
//
BaseSink.HANDOFF handoff = new BaseSink.HANDOFF() {
public void handoff(BaseSink sink, Buffer buffer, Pad pad) {
pipe.stop();
done.countDown();
}
};
audio.connect(handoff);
video.connect(handoff);
// Start the pipeline playing
pipe.pause();
try {
done.await();