Search in sources :

Example 1 with JingleMediaListener

use of org.jivesoftware.smackx.jingleold.listeners.JingleMediaListener in project Smack by igniterealtime.

the class MediaNegotiator method triggerMediaEstablished.

// Events
/**
     * Trigger a session established event.
     * 
     * @param bestPt
     *            payload type that has been agreed.
     * @throws NotConnectedException 
     * @throws InterruptedException 
     */
protected void triggerMediaEstablished(PayloadType bestPt) throws NotConnectedException, InterruptedException {
    List<JingleListener> listeners = getListenersList();
    for (JingleListener li : listeners) {
        if (li instanceof JingleMediaListener) {
            JingleMediaListener mli = (JingleMediaListener) li;
            mli.mediaEstablished(bestPt);
        }
    }
}
Also used : JingleListener(org.jivesoftware.smackx.jingleold.listeners.JingleListener) JingleMediaListener(org.jivesoftware.smackx.jingleold.listeners.JingleMediaListener)

Example 2 with JingleMediaListener

use of org.jivesoftware.smackx.jingleold.listeners.JingleMediaListener in project Smack by igniterealtime.

the class MediaNegotiator method triggerMediaClosed.

/**
     * Trigger a jmf closed event.
     * 
     * @param currPt
     *            current payload type that is cancelled.
     */
protected void triggerMediaClosed(PayloadType currPt) {
    List<JingleListener> listeners = getListenersList();
    for (JingleListener li : listeners) {
        if (li instanceof JingleMediaListener) {
            JingleMediaListener mli = (JingleMediaListener) li;
            mli.mediaClosed(currPt);
        }
    }
}
Also used : JingleListener(org.jivesoftware.smackx.jingleold.listeners.JingleListener) JingleMediaListener(org.jivesoftware.smackx.jingleold.listeners.JingleMediaListener)

Example 3 with JingleMediaListener

use of org.jivesoftware.smackx.jingleold.listeners.JingleMediaListener 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

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