Package org.jivesoftware.smackx.packet

Examples of org.jivesoftware.smackx.packet.Jingle


    /**
     * Process the ACK of our list of codecs (our offer).
     */
    private Jingle receiveResult(IQ iq) throws XMPPException {
        Jingle response = null;

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


        // JingleDescription
        // where we announce our payloads...
        audioDescr.addAudioPayloadTypes(localAudioPts);
        jingleContent.setDescription(audioDescr);

        Jingle jingle = new Jingle(JingleActionEnum.CONTENT_ACCEPT);
        jingle.addContent(jingleContent);

        return jingle;
    }
View Full Code Here

                // Process ACKs
                if (isExpectedId(iq.getPacketID())) {
                    removeExpectedId(iq.getPacketID());
                }
            } else if (iq instanceof Jingle) {
                Jingle jingle = (Jingle) iq;

                // There are 1 or more <content> sections in a Jingle packet.
                // Find out which <content> section belongs to this content negotiator, and
                // then dispatch the Jingle packet to the media and transport negotiators.

                for (JingleContent jingleContent : jingle.getContentsList()) {
                    if (jingleContent.getName().equals(name)) {
                        if (mediaNeg != null) {
                            responses.addAll(mediaNeg.dispatchIncomingPacket(iq, id));
                        }
View Full Code Here

      fail("The server did reply with an error packet: " + iqReceived.getError().getCode());
    }
    else {
      assertTrue(iqReceived instanceof Jingle);

      Jingle jin = (Jingle) iqReceived;
     
      System.out.println("Sent:     " + iqSent.toXML());
      System.out.println("Received: " + jin.toXML());
    }   
  }
View Full Code Here

            public boolean accept(Packet pin) {
                if (pin instanceof IQ) {
                    IQ iq = (IQ) pin;
                    if (iq.getType().equals(IQ.Type.SET)) {
                        if (iq instanceof Jingle) {
                            Jingle jin = (Jingle) pin;
                            if (jin.getAction().equals(JingleActionEnum.SESSION_INITIATE)) {
                                return true;
                            }
                        }
                    }
                }
View Full Code Here

                    System.out.println("packet: " + pin.toXML());
                    IQ iq = (IQ) pin;
                    if (iq.getType().equals(IQ.Type.SET)) {
                        System.out.println("packet");
                        if (iq instanceof Jingle) {
                            Jingle jin = (Jingle) pin;
                            if (jin.getAction().equals(JingleActionEnum.SESSION_INITIATE)) {
                                System.out.println("Session initiation packet accepted... ");
                                return true;
                            }
                        }
                    }
View Full Code Here

                        if ((bestRemote != null)
                                && ((getNegotiatorState() == JingleNegotiatorState.PENDING))) {
                            // Accepting the remote candidate
                            if (!acceptedRemoteCandidates.contains(bestRemote)) {
                                Jingle jout = new Jingle(JingleActionEnum.CONTENT_ACCEPT);
                                JingleContent content = parentNegotiator.getJingleContent();
                                content.addJingleTransport(getJingleTransport(bestRemote));
                                jout.addContent(content);

                                // Send the packet
                                js.sendFormattedJingle(jin, jout);
                                acceptedRemoteCandidates.add(bestRemote);
                            }
                            if ((isEstablished()) && (getNegotiatorState() == JingleNegotiatorState.PENDING)) {
                                setNegotiatorState(JingleNegotiatorState.SUCCEEDED);
                                triggerTransportEstablished(getAcceptedLocalCandidate(), bestRemote);
                                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)
                                && ((getNegotiatorState() == JingleNegotiatorState.PENDING))) {
                            if (!acceptedRemoteCandidates.contains(bestRemote)) {
                                Jingle jout = new Jingle(JingleActionEnum.CONTENT_ACCEPT);
                                JingleContent content = parentNegotiator.getJingleContent();
                                content.addJingleTransport(getJingleTransport(bestRemote));
                                jout.addContent(content);

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

        if (!cand.isNull()) {
            // Offer our new candidate...
            addOfferedCandidate(cand);
            JingleContent content = parentNegotiator.getJingleContent();
            content.addJingleTransport(getJingleTransport(cand));
            Jingle jingle = new Jingle(JingleActionEnum.TRANSPORT_INFO);
            jingle.addContent(content);

            // We SHOULD NOT be sending packets directly.
            // This circumvents the state machinery.
            // TODO - work this into the state machinery.
            session.sendFormattedJingle(jingle);
View Full Code Here

                    response = receiveResult(iq);
                    removeExpectedId(iq.getPacketID());
                }
            } else if (iq instanceof Jingle) {
                // Get the action from the Jingle packet
                Jingle jingle = (Jingle) iq;
                JingleActionEnum action = jingle.getAction();

                switch (action) {
                    case CONTENT_ACCEPT:
                        response = receiveContentAcceptAction(jingle);
                        break;
View Full Code Here

     *
     * @return an IQ packet
     * @throws XMPPException
     */
    private Jingle receiveResult(IQ iq) throws XMPPException {
        Jingle response = null;

        sendTransportCandidatesOffer();
        setNegotiatorState(JingleNegotiatorState.PENDING);

        return response;
View Full Code Here

TOP

Related Classes of org.jivesoftware.smackx.packet.Jingle

Copyright © 2018 www.massapicom. 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.