Element decodeQueue = ElementFactory.make("queue", "Decode Queue");
pipe.addMany(src, decodeQueue, decodeBin);
Element.linkMany(src, decodeQueue, decodeBin);
/* create audio output */
final Bin audioBin = new Bin("Audio Bin");
Element conv = ElementFactory.make("audioconvert", "Audio Convert");
Element resample = ElementFactory.make("audioresample", "Audio Resample");
Element sink = ElementFactory.make("autoaudiosink", "sink");
audioBin.addMany(conv, resample, sink);
Element.linkMany(conv, resample, sink);
audioBin.addPad(new GhostPad("sink", conv.getStaticPad("sink")));
pipe.add(audioBin);
decodeBin.connect(new DecodeBin2.NEW_DECODED_PAD() {
public void newDecodedPad(DecodeBin2 elem, Pad pad, boolean last) {
/* only link once */
if (pad.isLinked()) {
return;
}
/* check media type */
Caps caps = pad.getCaps();
Structure struct = caps.getStructure(0);
if (struct.getName().startsWith("audio/")) {
System.out.println("Linking audio pad: " + struct.getName());
pad.link(audioBin.getStaticPad("sink"));
} else if (struct.getName().startsWith("video/")) {
System.out.println("Linking video pad: " + struct.getName());
pad.link(videoComponent.getElement().getStaticPad("sink"));
// Make the video frame visible