Search in sources :

Example 16 with JingleMediaManager

use of org.jivesoftware.smackx.jingle.media.JingleMediaManager in project Smack by igniterealtime.

the class JingleMediaTest method testCompleteWithBridge.

public void testCompleteWithBridge() {
    for (int i = 0; i < 1; i += 2) {
        final int n = i;
        Thread t = new Thread(new Runnable() {

            public void run() {
                try {
                    XMPPTCPConnection x0 = getConnection(n);
                    XMPPTCPConnection x1 = getConnection(n + 1);
                    BridgedTransportManager btm0 = new BridgedTransportManager(x0);
                    BridgedTransportManager btm1 = new BridgedTransportManager(x1);
                    JingleMediaManager jingleMediaManager0 = new JmfMediaManager(btm0);
                    JingleMediaManager jingleMediaManager1 = new JmfMediaManager(btm1);
                    List<JingleMediaManager> jml0 = new ArrayList<JingleMediaManager>();
                    List<JingleMediaManager> jml1 = new ArrayList<JingleMediaManager>();
                    jml0.add(jingleMediaManager0);
                    jml1.add(jingleMediaManager1);
                    final JingleManager jm0 = new JingleManager(x0, jml0);
                    final JingleManager jm1 = new JingleManager(x1, jml1);
                    jm0.addCreationListener(btm0);
                    jm1.addCreationListener(btm1);
                    jm1.addJingleSessionRequestListener(new JingleSessionRequestListener() {

                        public void sessionRequested(final JingleSessionRequest request) {
                            try {
                                JingleSession session = request.accept();
                                session.startIncoming();
                            } catch (XMPPException e) {
                                LOGGER.log(Level.WARNING, "exception", e);
                            }
                        }
                    });
                    JingleSession js0 = jm0.createOutgoingJingleSession(x1.getUser());
                    js0.startOutgoing();
                    Thread.sleep(20000);
                    //js0.sendFormattedError(JingleError.UNSUPPORTED_TRANSPORTS);
                    js0.sendStanza(js0.createJingleError(null, JingleError.UNSUPPORTED_TRANSPORTS));
                    Thread.sleep(20000);
                    js0.terminate();
                    Thread.sleep(3000);
                    x0.disconnect();
                    x1.disconnect();
                } catch (Exception e) {
                    LOGGER.log(Level.WARNING, "exception", e);
                }
            }
        });
        t.start();
    }
    try {
        Thread.sleep(250000);
    } catch (InterruptedException e) {
        LOGGER.log(Level.WARNING, "exception", e);
    }
}
Also used : JmfMediaManager(org.jivesoftware.smackx.jingle.mediaimpl.jmf.JmfMediaManager) JingleSessionRequestListener(org.jivesoftware.smackx.jingle.listeners.JingleSessionRequestListener) XMPPException(org.jivesoftware.smack.XMPPException) JingleMediaManager(org.jivesoftware.smackx.jingle.media.JingleMediaManager) ArrayList(java.util.ArrayList) List(java.util.List) XMPPException(org.jivesoftware.smack.XMPPException) BridgedTransportManager(org.jivesoftware.smackx.jingle.nat.BridgedTransportManager)

Example 17 with JingleMediaManager

use of org.jivesoftware.smackx.jingle.media.JingleMediaManager in project Smack by igniterealtime.

the class JingleMediaTest method testCompleteScreenShare.

public void testCompleteScreenShare() {
    try {
        XMPPTCPConnection x0 = getConnection(0);
        XMPPTCPConnection x1 = getConnection(1);
        ICETransportManager icetm0 = new ICETransportManager(x0, "stun.xten.net", 3478);
        ICETransportManager icetm1 = new ICETransportManager(x1, "stun.xten.net", 3478);
        JingleMediaManager jingleMediaManager0 = new ScreenShareMediaManager(icetm0);
        JingleMediaManager jingleMediaManager1 = new ScreenShareMediaManager(icetm1);
        List<JingleMediaManager> jml0 = new ArrayList<JingleMediaManager>();
        List<JingleMediaManager> jml1 = new ArrayList<JingleMediaManager>();
        jml0.add(jingleMediaManager0);
        jml1.add(jingleMediaManager1);
        final JingleManager jm0 = new JingleManager(x0, jml0);
        final JingleManager jm1 = new JingleManager(x1, jml1);
        jm1.addJingleSessionRequestListener(new JingleSessionRequestListener() {

            public void sessionRequested(final JingleSessionRequest request) {
                try {
                    JingleSession session = request.accept();
                    session.startIncoming();
                } catch (XMPPException e) {
                    LOGGER.log(Level.WARNING, "exception", e);
                }
            }
        });
        JingleSession js0 = jm0.createOutgoingJingleSession(x1.getUser());
        js0.startOutgoing();
        Thread.sleep(150000);
        js0.terminate();
        Thread.sleep(6000);
        x0.disconnect();
        x1.disconnect();
    } catch (Exception e) {
        LOGGER.log(Level.WARNING, "exception", e);
    }
}
Also used : ICETransportManager(org.jivesoftware.smackx.jingle.nat.ICETransportManager) JingleMediaManager(org.jivesoftware.smackx.jingle.media.JingleMediaManager) ArrayList(java.util.ArrayList) ScreenShareMediaManager(org.jivesoftware.smackx.jingle.mediaimpl.sshare.ScreenShareMediaManager) XMPPException(org.jivesoftware.smack.XMPPException) JingleSessionRequestListener(org.jivesoftware.smackx.jingle.listeners.JingleSessionRequestListener) XMPPException(org.jivesoftware.smack.XMPPException)

Aggregations

ArrayList (java.util.ArrayList)17 JingleMediaManager (org.jivesoftware.smackx.jingle.media.JingleMediaManager)17 XMPPException (org.jivesoftware.smack.XMPPException)15 JingleSessionRequestListener (org.jivesoftware.smackx.jingle.listeners.JingleSessionRequestListener)15 FixedResolver (org.jivesoftware.smackx.jingle.nat.FixedResolver)9 FixedTransportManager (org.jivesoftware.smackx.jingle.nat.FixedTransportManager)9 TestMediaManager (org.jivesoftware.smackx.jingle.mediaimpl.test.TestMediaManager)8 PayloadType (org.jivesoftware.smackx.jingle.media.PayloadType)6 JingleSessionListener (org.jivesoftware.smackx.jingle.listeners.JingleSessionListener)5 JmfMediaManager (org.jivesoftware.smackx.jingle.mediaimpl.jmf.JmfMediaManager)5 TransportCandidate (org.jivesoftware.smackx.jingle.nat.TransportCandidate)5 ICETransportManager (org.jivesoftware.smackx.jingle.nat.ICETransportManager)4 SpeexMediaManager (org.jivesoftware.smackx.jingle.mediaimpl.jspeex.SpeexMediaManager)3 List (java.util.List)2 JingleManager (org.jivesoftware.smackx.jingle.JingleManager)2 JingleSessionRequest (org.jivesoftware.smackx.jingle.JingleSessionRequest)2 ScreenShareMediaManager (org.jivesoftware.smackx.jingle.mediaimpl.sshare.ScreenShareMediaManager)2 BridgedTransportManager (org.jivesoftware.smackx.jingle.nat.BridgedTransportManager)2 UtilityException (de.javawi.jstun.util.UtilityException)1 SocketException (java.net.SocketException)1