Examples of Jingle


Examples of nu.fw.jeti.plugins.jingle.packet.Jingle

     * @param iq the packet received
     * @return the new Jingle packet to send.
     * @throws XMPPException
     */
    public Jingle dispatchIncomingPacket(Jingle iq, String id) throws XMPPException {
        Jingle jout = null;
               
        if (invalidState()) {
            if (iq == null) {
                // With a null packet, we are just inviting the other end...
                setState(inviting);
                jout = getState().eventInvite();
            }
            else {
                if (iq instanceof Jingle) {
                    // If there is no specific jmf action associated, then we
                    // are being invited to a new session...
                    setState(accepting);
                    jout = getState().eventInitiate((Jingle) iq);
                }
                else {
                    throw new IllegalStateException(
                            "Invitation IQ received is not a Jingle packet in Media negotiator.");
                }
            }
        }
        else {
            if (iq == null) {
                return null;
            }
            else {
                if (iq.getType().equals("error")) {
                    // Process errors
                    getState().eventError(iq);
                }
                else if (iq.getType().equals("result")) {
                    // Process ACKs
                  System.out.println("trying to ack " + iq.getPacketID());
                 
                    if (isExpectedId(iq.getPacketID())) {
                      //System.out.println("media ack " + iq.getPacketID());
                      //System.out.println(getState());
                        jout = getState().eventAck(iq);
                        removeExpectedId(iq.getPacketID());
                    }
                }
                else if (iq instanceof Jingle) {
                    // Get the action from the Jingle packet
                    Jingle jin = (Jingle) iq;
                    Jingle.Action action = jin.getAction();
//System.out.println("ac= " + action);
                    if (action != null) {
                        if (action.equals(Jingle.Action.CONTENTACCEPT)) {
                            jout = getState().eventAccept(jin);
                        }
View Full Code Here

Examples of nu.fw.jeti.plugins.jingle.packet.Jingle

        // Add the list of payloads for audio and create a
        // JingleContentDescription
        // where we announce our payloads...
        audioDescr.addAudioPayloadTypes(localAudioPts);

        return new Jingle(audioDescr);
    }
View Full Code Here

Examples of nu.fw.jeti.plugins.jingle.packet.Jingle

    /**
     * Create an IQ "accept" message.
     */
    private Jingle createAcceptMessage() {
        Jingle jout = null;

        // If we hava a common best codec, send an accept right now...
        jout = new Jingle(Jingle.Action.CONTENTACCEPT);
        jout.addDescription(new JingleContentDescription.Audio(
                new JinglePayloadType.Audio(bestCommonAudioPt)));

        return jout;
    }
View Full Code Here

Examples of nu.fw.jeti.plugins.jingle.packet.Jingle

         * Process the ACK of our list of codecs (our offer).
         *
         * @see org.jivesoftware.smackx.jingle.JingleNegotiator.State#eventAck(org.jivesoftware.smack.packet.IQ)
         */
        public Jingle eventAck(Jingle iq) throws XMPPException {
            Jingle response = null;

            if (!remoteAudioPts.isEmpty()) {
                // Calculate the best common codec
                bestCommonAudioPt = calculateBestCommonAudioPt(remoteAudioPts);

View Full Code Here

Examples of nu.fw.jeti.plugins.jingle.packet.Jingle

         * @throws JingleException
         */
        public Jingle eventInfo(Jingle jin) throws JingleException {
            PayloadType.Audio oldBestCommonAudioPt = bestCommonAudioPt;
            List offeredPayloads;
            Jingle response = null;
            boolean ptChange = false;

            offeredPayloads = obtainPayloads(jin);
            if (!offeredPayloads.isEmpty()) {

View Full Code Here

Examples of nu.fw.jeti.plugins.jingle.packet.Jingle

         * @throws JingleException
         */
        public Jingle eventAccept(Jingle jin) throws JingleException {
            PayloadType.Audio agreedCommonAudioPt;
            List offeredPayloads = new ArrayList();
            Jingle response = null;

            if (bestCommonAudioPt == null) {
                // Update the best common audio PT
                bestCommonAudioPt = calculateBestCommonAudioPt(remoteAudioPts);
                response = createAcceptMessage();
View Full Code Here

Examples of nu.fw.jeti.plugins.jingle.packet.Jingle

                        State state = getState();
System.out.println("state " + state);
                        if (bestRemote != null && (state == pending || state == active)) {
                            // Accepting the remote candidate
                            if (!acceptedRemoteCandidates.contains(bestRemote)) {
                                Jingle jout = new Jingle(Jingle.Action.TRANSPORTACCEPT);
                                jout.addTransport(getJingleTransport(bestRemote));

                                // Send the packet
                                js.sendFormattedJingle(jin, jout);
                                acceptedRemoteCandidates.add(bestRemote);
                            }
                            if (isEstablished()) {
                                setState(active);
                                break;
                            }
                        }
                    }

                    // Once we are in pending state, look for any valid remote
                    // candidate, and send an "accept" if we have one...
                    TransportCandidate bestRemote = getBestRemoteCandidate();

                    if (bestRemote == null) {
                        boolean foundRemoteRelay = false;
                        for (TransportCandidate candidate : remoteCandidates) {
                            if (candidate instanceof ICECandidate) {
                                ICECandidate iceCandidate = (ICECandidate) candidate;
                                if (iceCandidate.getType().equals("relay")) {
                                    //TODO Check if the relay is reacheable
                                    addValidRemoteCandidate(iceCandidate);
                                    foundRemoteRelay = true;
                                }
                            }
                        }

                        // If not found, check if we offered a relay. If yes, we should accept any remote candidate.
                        // We should accept the Public One if we received it, otherwise, accepts any.
                        if (!foundRemoteRelay) {
                            boolean foundLocalRelay = false;
                            for (TransportCandidate candidate : offeredCandidates) {
                                if (candidate instanceof ICECandidate) {
                                    ICECandidate iceCandidate = (ICECandidate) candidate;
                                    if (iceCandidate.getType().equals("relay")) {
                                        foundLocalRelay = true;
                                    }
                                }
                            }
                            if (foundLocalRelay) {
                                boolean foundRemotePublic = false;
                                for (TransportCandidate candidate : remoteCandidates) {
                                    if (candidate instanceof ICECandidate) {
                                        ICECandidate iceCandidate = (ICECandidate) candidate;
                                        if (iceCandidate.getType().equals(ICECandidate.Type.srflx)) {
                                            addValidRemoteCandidate(iceCandidate);
                                            foundRemotePublic = true;
                                        }
                                    }
                                }
                                if (!foundRemotePublic) {
                                    for (TransportCandidate candidate : remoteCandidates) {
                                        if (candidate instanceof ICECandidate) {
                                            ICECandidate iceCandidate = (ICECandidate) candidate;
                                            addValidRemoteCandidate(iceCandidate);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    for (int i = 0; i < 6; i++) {
                        try {
                            Thread.sleep(500);
                        }
                        catch (InterruptedException e) {
                            e.printStackTrace();
                        }

                        bestRemote = getBestRemoteCandidate();
                        State state = getState();
                        if (bestRemote != null && (state == pending || state == active)) {
                            if (!acceptedRemoteCandidates.contains(bestRemote)) {
                                Jingle jout = new Jingle(Jingle.Action.TRANSPORTACCEPT);
                                jout.addTransport(getJingleTransport(bestRemote));

                                // Send the packet
                                js.sendFormattedJingle(jin, jout);
                                acceptedRemoteCandidates.add(bestRemote);
                            }
View Full Code Here

Examples of nu.fw.jeti.plugins.jingle.packet.Jingle

     */
    private synchronized void sendTransportCandidateOffer(TransportCandidate cand) {
        if (!cand.isNull()) {
            // Offer our new candidate...
            addOfferedCandidate(cand);
            session.sendFormattedJingle(new Jingle(getJingleTransport(cand)));
        }
    }
View Full Code Here

Examples of nu.fw.jeti.plugins.jingle.packet.Jingle

     * @return the new Jingle packet to send.
     * @throws XMPPException
     */
    public final Jingle dispatchIncomingPacket(Jingle iq, String id) throws XMPPException {
      System.out.println("transport info dispatching");
        Jingle jout = null;

        if (invalidState()) {
            if (iq == null) {
                // With a null packet, we are just inviting the other end...
                setState(inviting);
                jout = getState().eventInvite();

            }
            else {
                if (iq instanceof Jingle) {
                    // If there is no specific jmf action associated, then we
                    // are being invited to a new session...
                    setState(accepting);
                    jout = getState().eventInitiate((Jingle) iq);
                }
                else {
                    throw new IllegalStateException(
                            "Invitation IQ received is not a Jingle packet in Transport negotiator.");
                }
            }
        }
        else {
            if (iq == null) {
                return null;
            }
            else {
                if (iq.getType().equals("error")) {
                    // Process errors
                    getState().eventError(iq);
                }
                else if (iq.getType().equals("result")) {
                  System.err.println("acking " + iq.getPacketID());
                    // Process ACKs
                    if (isExpectedId(iq.getPacketID())) {
                      System.err.println("acked " + iq.getPacketID());
                        jout = getState().eventAck(iq);
                        removeExpectedId(iq.getPacketID());
                    }
                }
                else if (iq instanceof Jingle) {
                    // Get the action from the Jingle packet
                    Jingle jin = (Jingle) iq;
                    Jingle.Action action = jin.getAction();

                    if (action != null) {
                        if (action.equals(Jingle.Action.TRANSPORTACCEPT)) {
                            jout = getState().eventAccept(jin);
                        }
View Full Code Here

Examples of nu.fw.jeti.plugins.jingle.packet.Jingle

        /**
         * Create an initial Jingle packet with an empty transport.
         */
        public Jingle eventInvite() {
            return new Jingle(getJingleTransport(null));
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.