/** @param pad */ public void linkNewInputToPad(Pad pad) { String addedUrl = inputURLs.get(inputURLs.size() - 1); final Element newInput = inputElements.get(addedUrl); EVENT_PROBE probeListener = new EVENT_PROBE() { public boolean eventReceived(Pad pad, Event event) { String type = event.getStructure().toString(); if (DEBUG) System.out.println("eventReceived: " + type); if (type.toLowerCase().indexOf("error") >= 0) { System.out.println("Error"); return false; } return true; } }; adder.getSrcPads().get(0).addEventProbe(probeListener); Element identity = ElementFactory.make("identity", "identity" + INDEX); identity.set("sync", true); identity.set("single-segment", true); // identity.set("silent", false); // Element mux = ElementFactory.make("flvmux", "mux-timestamp" + INDEX); // Element enc = ElementFactory.make("lamemp3enc", "enc-timestamp" + // INDEX); // Element demux = ElementFactory.make("flvdemux", "demux-timestamp" + // INDEX); // Element dec = ElementFactory.make("flump3dec", "dec-timestamp" + // INDEX); // // // identity.set("silent", false); // pipe.addMany(identity, enc, mux, demux, dec); // // identity.setState(State.PAUSED); // mux.setState(State.PAUSED); // enc.setState(State.PAUSED); // demux.setState(State.PAUSED); // dec.setState(State.PAUSED); // pipe.addMany(newInput, identity); PadLinkReturn linked = newInput.getSrcPads().get(0).link(identity.getSinkPads().get(0)); System.out.println("new input linked: " + linked); // // boolean l = Element.linkMany(identity, enc, mux, demux, dec); // System.out.println("mux demux linked: "+l); // // PadLinkReturn linked2 = dec.getSrcPads().get(0).link(pad); // System.out.println("new dec linked: " + linked2); if (pipe.isPlaying()) { State state = State.READY; // newInput.setState(state); pipe.setState(state); } PadLinkReturn linked3 = identity.getSrcPads().get(0).link(pad); System.out.println("new identity linked: " + linked3); }
public void removeInput(final String url) { if (!inputElements.containsKey(url)) return; System.out.println("\n------------\nremoveInput: " + url + "\n-------------\n"); removedInput = inputElements.get(url); boolean playing = pipe.isPlaying(); Pad inputSrcPad = removedInput.getSrcPads().get(0); removedIdentity = inputSrcPad.getPeer().getParentElement(); Pad adderSinkPad = removedIdentity.getSrcPads().get(0).getPeer(); pipe.setState(State.READY); boolean removed = adder.removePad(adderSinkPad); System.out.println("Pad removed: " + removed); inputElements.remove(url); if (playing) { System.out.println("Adder inputs: " + adder.getSinkPads()); pipe.setState(State.PLAYING); } }