Search in sources :

Example 1 with TransportCandidate

use of org.jivesoftware.smackx.jingleold.nat.TransportCandidate in project Smack by igniterealtime.

the class ContentNegotiator method triggerContentEstablished.

/**
     * Trigger a session established event.
     * @throws NotConnectedException 
     * @throws InterruptedException 
     */
private void triggerContentEstablished(PayloadType pt, TransportCandidate rc, TransportCandidate lc) throws NotConnectedException, InterruptedException {
    // Let the session know that we've established a content/media segment.
    JingleSession session = getSession();
    if (session != null) {
        List<JingleListener> listeners = session.getListenersList();
        for (JingleListener li : listeners) {
            if (li instanceof JingleSessionListener) {
                JingleSessionListener sli = (JingleSessionListener) li;
                sli.sessionEstablished(pt, rc, lc, session);
            }
        }
    }
    // Create a media session for each media manager in the session.
    if (mediaNeg.getMediaManager() != null) {
        rc.removeCandidateEcho();
        lc.removeCandidateEcho();
        jingleMediaSession = getMediaNegotiator().getMediaManager().createMediaSession(pt, rc, lc, session);
        jingleMediaSession.addMediaReceivedListener(session);
        if (jingleMediaSession != null) {
            jingleMediaSession.startTrasmit();
            jingleMediaSession.startReceive();
            for (TransportCandidate candidate : getTransportNegotiator().getOfferedCandidates()) candidate.removeCandidateEcho();
        }
        JingleMediaManager mediaManager = getMediaNegotiator().getMediaManager();
        getSession().addJingleMediaSession(mediaManager.getName(), jingleMediaSession);
    }
}
Also used : JingleListener(org.jivesoftware.smackx.jingleold.listeners.JingleListener) TransportCandidate(org.jivesoftware.smackx.jingleold.nat.TransportCandidate) JingleMediaManager(org.jivesoftware.smackx.jingleold.media.JingleMediaManager) JingleSessionListener(org.jivesoftware.smackx.jingleold.listeners.JingleSessionListener)

Example 2 with TransportCandidate

use of org.jivesoftware.smackx.jingleold.nat.TransportCandidate in project Smack by igniterealtime.

the class JingleSession method triggerSessionClosedOnError.

/**
     * Trigger a session closed event due to an error.
     */
protected void triggerSessionClosedOnError(XMPPException exc) {
    for (ContentNegotiator contentNegotiator : contentNegotiators) {
        contentNegotiator.stopJingleMediaSession();
        for (TransportCandidate candidate : contentNegotiator.getTransportNegotiator().getOfferedCandidates()) candidate.removeCandidateEcho();
    }
    List<JingleListener> listeners = getListenersList();
    for (JingleListener li : listeners) {
        if (li instanceof JingleSessionListener) {
            JingleSessionListener sli = (JingleSessionListener) li;
            sli.sessionClosedOnError(exc, this);
        }
    }
    close();
}
Also used : JingleListener(org.jivesoftware.smackx.jingleold.listeners.JingleListener) TransportCandidate(org.jivesoftware.smackx.jingleold.nat.TransportCandidate) JingleSessionListener(org.jivesoftware.smackx.jingleold.listeners.JingleSessionListener)

Example 3 with TransportCandidate

use of org.jivesoftware.smackx.jingleold.nat.TransportCandidate in project Smack by igniterealtime.

the class JingleSession method close.

/**
     * Terminate negotiations.
     */
@Override
public void close() {
    if (isClosed())
        return;
    // Set the session state to ENDED.
    setSessionState(JingleSessionStateEnded.getInstance());
    for (ContentNegotiator contentNegotiator : contentNegotiators) {
        contentNegotiator.stopJingleMediaSession();
        for (TransportCandidate candidate : contentNegotiator.getTransportNegotiator().getOfferedCandidates()) candidate.removeCandidateEcho();
        contentNegotiator.close();
    }
    removeAsyncPacketListener();
    removeConnectionListener();
    getConnection().removeConnectionListener(connectionListener);
    LOGGER.fine("Negotiation Closed: " + getConnection().getUser() + " " + sid);
    super.close();
}
Also used : TransportCandidate(org.jivesoftware.smackx.jingleold.nat.TransportCandidate)

Example 4 with TransportCandidate

use of org.jivesoftware.smackx.jingleold.nat.TransportCandidate in project Smack by igniterealtime.

the class ContentNegotiator method triggerContentEstablished.

public void triggerContentEstablished() throws NotConnectedException, InterruptedException {
    PayloadType bestCommonAudioPt = getMediaNegotiator().getBestCommonAudioPt();
    TransportCandidate bestRemoteCandidate = getTransportNegotiator().getBestRemoteCandidate();
    TransportCandidate acceptedLocalCandidate = getTransportNegotiator().getAcceptedLocalCandidate();
    // Trigger the session established flag
    triggerContentEstablished(bestCommonAudioPt, bestRemoteCandidate, acceptedLocalCandidate);
}
Also used : TransportCandidate(org.jivesoftware.smackx.jingleold.nat.TransportCandidate) PayloadType(org.jivesoftware.smackx.jingleold.media.PayloadType)

Example 5 with TransportCandidate

use of org.jivesoftware.smackx.jingleold.nat.TransportCandidate in project Smack by igniterealtime.

the class JingleSession method setupListeners.

/**
     * Setup the listeners that act on events coming from the lower level negotiators.
     */
public void setupListeners() {
    JingleMediaListener jingleMediaListener = new JingleMediaListener() {

        @Override
        public void mediaClosed(PayloadType cand) {
        }

        @Override
        public void mediaEstablished(PayloadType pt) throws NotConnectedException, InterruptedException {
            if (isFullyEstablished()) {
                Jingle jout = new Jingle(JingleActionEnum.SESSION_ACCEPT);
                // Build up a response packet from each media manager.
                for (ContentNegotiator contentNegotiator : contentNegotiators) {
                    if (contentNegotiator.getNegotiatorState() == JingleNegotiatorState.SUCCEEDED)
                        jout.addContent(contentNegotiator.getJingleContent());
                }
                // Send the "accept" and wait for the ACK
                addExpectedId(jout.getStanzaId());
                sendStanza(jout);
            //triggerSessionEstablished();
            }
        }
    };
    JingleTransportListener jingleTransportListener = new JingleTransportListener() {

        @Override
        public void transportEstablished(TransportCandidate local, TransportCandidate remote) throws NotConnectedException, InterruptedException {
            if (isFullyEstablished()) {
                // CHECKSTYLE:OFF
                // Indicate that this session is active.
                setSessionState(JingleSessionStateActive.getInstance());
                for (ContentNegotiator contentNegotiator : contentNegotiators) {
                    // CHECKSTYLE:ON
                    if (contentNegotiator.getNegotiatorState() == JingleNegotiatorState.SUCCEEDED)
                        contentNegotiator.triggerContentEstablished();
                }
                if (getSessionState().equals(JingleSessionStatePending.getInstance())) {
                    Jingle jout = new Jingle(JingleActionEnum.SESSION_ACCEPT);
                    // Build up a response packet from each media manager.
                    for (ContentNegotiator contentNegotiator : contentNegotiators) {
                        if (contentNegotiator.getNegotiatorState() == JingleNegotiatorState.SUCCEEDED)
                            jout.addContent(contentNegotiator.getJingleContent());
                    }
                    // Send the "accept" and wait for the ACK
                    addExpectedId(jout.getStanzaId());
                    sendStanza(jout);
                }
            }
        }

        @Override
        public void transportClosed(TransportCandidate cand) {
        }

        @Override
        public void transportClosedOnError(XMPPException e) {
        }
    };
    addMediaListener(jingleMediaListener);
    addTransportListener(jingleTransportListener);
}
Also used : Jingle(org.jivesoftware.smackx.jingleold.packet.Jingle) TransportCandidate(org.jivesoftware.smackx.jingleold.nat.TransportCandidate) JingleMediaListener(org.jivesoftware.smackx.jingleold.listeners.JingleMediaListener) XMPPException(org.jivesoftware.smack.XMPPException) PayloadType(org.jivesoftware.smackx.jingleold.media.PayloadType) JingleTransportListener(org.jivesoftware.smackx.jingleold.listeners.JingleTransportListener)

Aggregations

TransportCandidate (org.jivesoftware.smackx.jingleold.nat.TransportCandidate)5 JingleListener (org.jivesoftware.smackx.jingleold.listeners.JingleListener)2 JingleSessionListener (org.jivesoftware.smackx.jingleold.listeners.JingleSessionListener)2 PayloadType (org.jivesoftware.smackx.jingleold.media.PayloadType)2 XMPPException (org.jivesoftware.smack.XMPPException)1 JingleMediaListener (org.jivesoftware.smackx.jingleold.listeners.JingleMediaListener)1 JingleTransportListener (org.jivesoftware.smackx.jingleold.listeners.JingleTransportListener)1 JingleMediaManager (org.jivesoftware.smackx.jingleold.media.JingleMediaManager)1 Jingle (org.jivesoftware.smackx.jingleold.packet.Jingle)1