Examples of JingleContent


Examples of org.jivesoftware.smackx.packet.JingleContent

                        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

Examples of org.jivesoftware.smackx.packet.JingleContent

     */
    private synchronized void sendTransportCandidateOffer(TransportCandidate cand) {
        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.
View Full Code Here

Examples of org.jivesoftware.smackx.packet.JingleContent

    *
    * @return a new Jingle packet with the list of audio Payload Types
    */
    private Jingle createAudioPayloadTypesOffer() {

        JingleContent jingleContent = new JingleContent(parentNegotiator.getCreator(), parentNegotiator.getName());
        JingleDescription audioDescr = new JingleDescription.Audio();

        // Add the list of payloads for audio and create a
        // 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

Examples of org.jivesoftware.smackx.packet.JingleContent

    /**
     * Called from above when starting a new session.
     */
    protected void doStart() {
        JingleContent result = new JingleContent(creator, name);

        //        result.setDescription(mediaNeg.start());
        //        result.addJingleTransport(transNeg.start());
        //
        //        return result;
View Full Code Here

Examples of org.jivesoftware.smackx.packet.JingleContent

        return result;
    }

    public JingleContent getJingleContent() {
        JingleContent result = new JingleContent(creator, name);

        //            PayloadType.Audio bestCommonAudioPt = getMediaNegotiator().getBestCommonAudioPt();
        //            TransportCandidate bestRemoteCandidate = getTransportNegotiator().getBestRemoteCandidate();
        //   
        //            // Ok, send a packet saying that we accept this session
        //            // with the audio payload type and the transport
        //            // candidate
        //            result.setDescription(new JingleDescription.Audio(new PayloadType(bestCommonAudioPt)));
        //            result.addJingleTransport(this.getTransportNegotiator().getJingleTransport(bestRemoteCandidate));
        if (mediaNeg != null) {
            result.setDescription(mediaNeg.getJingleDescription());
        }
        if (transNeg != null) {
            result.addJingleTransport(transNeg.getJingleTransport());
        }

        return result;
    }
View Full Code Here

Examples of org.jivesoftware.smackx.packet.JingleContent

        String elementName = parser.getName();
        String creator = parser.getAttributeValue("", JingleContent.CREATOR);
        String name = parser.getAttributeValue("", JingleContent.NAME);

        // Try to get an Audio content info
        result = new JingleContent(creator, name);

        return result;
    }
View Full Code Here

Examples of org.jivesoftware.smackx.packet.JingleContent

                        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

Examples of org.jivesoftware.smackx.packet.JingleContent

     */
    private synchronized void sendTransportCandidateOffer(TransportCandidate cand) {
        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.
View Full Code Here

Examples of org.jivesoftware.smackx.packet.JingleContent

    *
    * @return a new Jingle packet with the list of audio Payload Types
    */
    private Jingle createAudioPayloadTypesOffer() {

        JingleContent jingleContent = new JingleContent(parentNegotiator.getCreator(), parentNegotiator.getName());
        JingleDescription audioDescr = new JingleDescription.Audio();

        // Add the list of payloads for audio and create a
        // 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

Examples of org.jivesoftware.smackx.packet.JingleContent

    /**
     * Called from above when starting a new session.
     */
    protected void doStart() {
        JingleContent result = new JingleContent(creator, name);

        //        result.setDescription(mediaNeg.start());
        //        result.addJingleTransport(transNeg.start());
        //
        //        return result;
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.