Search in sources :

Example 1 with JmfMediaManager

use of org.jivesoftware.smackx.jingle.mediaimpl.jmf.JmfMediaManager in project Smack by igniterealtime.

the class JingleMediaTest method testCompleteJmf.

public void testCompleteJmf() {
    XMPPTCPConnection x0 = getConnection(0);
    XMPPTCPConnection x1 = getConnection(1);
    for (int i = 0; i < 1; i++) try {
        ICETransportManager icetm0 = new ICETransportManager(x0, "jivesoftware.com", 3478);
        ICETransportManager icetm1 = new ICETransportManager(x1, "jivesoftware.com", 3478);
        JingleMediaManager jingleMediaManager0 = new JmfMediaManager(icetm0);
        JingleMediaManager jingleMediaManager1 = new JmfMediaManager(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);
        jm0.addCreationListener(icetm0);
        jm1.addCreationListener(icetm1);
        JingleSessionRequestListener jingleSessionRequestListener = new JingleSessionRequestListener() {

            public void sessionRequested(final JingleSessionRequest request) {
                try {
                    JingleSession session = request.accept();
                    session.startIncoming();
                //                            session.addStateListener(new JingleSessionStateListener() {
                //                                public void beforeChange(JingleNegotiator.State old, JingleNegotiator.State newOne)
                //                                        throws JingleNegotiator.JingleException {
                //                                    if (newOne instanceof IncomingJingleSession.Active) {
                //                                        throw new JingleNegotiator.JingleException();
                //                                    }
                //                                }
                //
                //                                public void afterChanged(JingleNegotiator.State old, JingleNegotiator.State newOne) {
                //
                //                                }
                //                            });
                } catch (XMPPException e) {
                    LOGGER.log(Level.WARNING, "exception", e);
                }
            }
        };
        jm1.addJingleSessionRequestListener(jingleSessionRequestListener);
        JingleSession js0 = jm0.createOutgoingJingleSession(x1.getUser());
        js0.startOutgoing();
        Thread.sleep(20000);
        JingleSession incomingJingleSession = jm1.getSession(js0.getConnection().getUser());
        //JingleSession.removeAllStateListeners();
        Thread.sleep(15000);
        js0.terminate();
        jm1.removeJingleSessionRequestListener(jingleSessionRequestListener);
        Thread.sleep(60000);
    } catch (Exception e) {
        LOGGER.log(Level.WARNING, "exception", e);
    }
}
Also used : JmfMediaManager(org.jivesoftware.smackx.jingle.mediaimpl.jmf.JmfMediaManager) ICETransportManager(org.jivesoftware.smackx.jingle.nat.ICETransportManager) 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)

Example 2 with JmfMediaManager

use of org.jivesoftware.smackx.jingle.mediaimpl.jmf.JmfMediaManager in project Smack by igniterealtime.

the class JingleManagerTest method testFullTest.

/**
     * This is a full test in the Jingle API.
     */
public void testFullTest() {
    resetCounter();
    XMPPTCPConnection x0 = getConnection(0);
    XMPPTCPConnection x1 = getConnection(1);
    XMPPSmackConfiguration.DEBUG = true;
    FixedResolver tr0 = new FixedResolver("127.0.0.1", 20080);
    FixedTransportManager ftm0 = new FixedTransportManager(tr0);
    JmfMediaManager jmf0 = new JmfMediaManager(ftm0);
    List<JingleMediaManager> trl0 = new ArrayList<JingleMediaManager>();
    trl0.add(jmf0);
    FixedResolver tr1 = new FixedResolver("127.0.0.1", 20040);
    FixedTransportManager ftm1 = new FixedTransportManager(tr1);
    JmfMediaManager jmf1 = new JmfMediaManager(ftm1);
    List<JingleMediaManager> trl1 = new ArrayList<JingleMediaManager>();
    trl1.add(jmf1);
    JingleManager man0 = new JingleManager(x0, trl0);
    JingleManager man1 = new JingleManager(x1, trl1);
    man1.addJingleSessionRequestListener(new JingleSessionRequestListener() {

        public void sessionRequested(final JingleSessionRequest request) {
            try {
                JingleSession session = request.accept();
                session.addListener(new JingleSessionListener() {

                    public void sessionEstablished(PayloadType pt, TransportCandidate rc, TransportCandidate lc, JingleSession jingleSession) {
                        incCounter();
                        System.out.println("Establish In");
                    }

                    public void sessionDeclined(String reason, JingleSession jingleSession) {
                    }

                    public void sessionRedirected(String redirection, JingleSession jingleSession) {
                    }

                    public void sessionClosed(String reason, JingleSession jingleSession) {
                    //  incCounter();
                    }

                    public void sessionMediaReceived(JingleSession jingleSession, String participant) {
                    // Do Nothing
                    }

                    public void sessionClosedOnError(XMPPException e, JingleSession jingleSession) {
                    //  incCounter();
                    }
                });
                session.startIncoming();
            } catch (XMPPException e) {
                LOGGER.log(Level.WARNING, "exception", e);
            }
        }
    });
    for (int i = 0; i < 3; i++) try {
        JingleSession js0 = man0.createOutgoingJingleSession(x1.getUser());
        js0.addListener(new JingleSessionListener() {

            public void sessionEstablished(PayloadType pt, TransportCandidate rc, TransportCandidate lc, JingleSession jingleSession) {
                incCounter();
                System.out.println("Establish Out");
            }

            public void sessionDeclined(String reason, JingleSession jingleSession) {
            }

            public void sessionRedirected(String redirection, JingleSession jingleSession) {
            }

            public void sessionClosed(String reason, JingleSession jingleSession) {
            // incCounter();
            }

            public void sessionMediaReceived(JingleSession jingleSession, String participant) {
            // Do Nothing
            }

            public void sessionClosedOnError(XMPPException e, JingleSession jingleSession) {
            //  incCounter();
            }
        });
        js0.startOutgoing();
        Thread.sleep(8000);
        js0.terminate();
        Thread.sleep(3000);
    } catch (Exception e) {
        LOGGER.log(Level.WARNING, "exception", e);
    }
    System.out.println(valCounter());
    assertTrue(valCounter() == 6);
}
Also used : FixedResolver(org.jivesoftware.smackx.jingle.nat.FixedResolver) FixedTransportManager(org.jivesoftware.smackx.jingle.nat.FixedTransportManager) JmfMediaManager(org.jivesoftware.smackx.jingle.mediaimpl.jmf.JmfMediaManager) ArrayList(java.util.ArrayList) JingleSessionRequestListener(org.jivesoftware.smackx.jingle.listeners.JingleSessionRequestListener) PayloadType(org.jivesoftware.smackx.jingle.media.PayloadType) XMPPException(org.jivesoftware.smack.XMPPException) JingleMediaManager(org.jivesoftware.smackx.jingle.media.JingleMediaManager) TransportCandidate(org.jivesoftware.smackx.jingle.nat.TransportCandidate) XMPPException(org.jivesoftware.smack.XMPPException) JingleSessionListener(org.jivesoftware.smackx.jingle.listeners.JingleSessionListener)

Example 3 with JmfMediaManager

use of org.jivesoftware.smackx.jingle.mediaimpl.jmf.JmfMediaManager in project Smack by igniterealtime.

the class JingleMediaTest method testCompleteMulti.

public void testCompleteMulti() {
    try {
        XMPPTCPConnection x0 = getConnection(0);
        XMPPTCPConnection x1 = getConnection(1);
        ICETransportManager icetm0 = new ICETransportManager(x0, "jivesoftware.com", 3478);
        ICETransportManager icetm1 = new ICETransportManager(x1, "jivesoftware.com", 3478);
        MultiMediaManager jingleMediaManager0 = new MultiMediaManager(icetm0);
        jingleMediaManager0.addMediaManager(new JmfMediaManager(icetm0));
        jingleMediaManager0.addMediaManager(new SpeexMediaManager(icetm0));
        jingleMediaManager0.setPreferredPayloadType(jingleMediaManager0.getPayloads().get(1));
        List<JingleMediaManager> jml0 = new ArrayList<JingleMediaManager>();
        jml0.add(jingleMediaManager0);
        MultiMediaManager jingleMediaManager1 = new MultiMediaManager(icetm1);
        jingleMediaManager1.addMediaManager(new JmfMediaManager(icetm1));
        jingleMediaManager1.addMediaManager(new SpeexMediaManager(icetm1));
        jingleMediaManager1.setPreferredPayloadType(jingleMediaManager1.getPayloads().get(2));
        List<JingleMediaManager> jml1 = new ArrayList<JingleMediaManager>();
        jml1.add(jingleMediaManager1);
        final JingleManager jm0 = new JingleManager(x0, jml0);
        final JingleManager jm1 = new JingleManager(x1, jml1);
        jm0.addCreationListener(icetm0);
        jm1.addCreationListener(icetm1);
        jm1.addJingleSessionRequestListener(new JingleSessionRequestListener() {

            public void sessionRequested(final JingleSessionRequest request) {
                try {
                    JingleSession session = request.accept();
                    try {
                        Thread.sleep(12000);
                    } catch (InterruptedException e) {
                        LOGGER.log(Level.WARNING, "exception", e);
                    }
                    session.startIncoming();
                } catch (XMPPException e) {
                    LOGGER.log(Level.WARNING, "exception", e);
                }
            }
        });
        for (int i = 0; i < 10; i++) {
            JingleSession js0 = jm0.createOutgoingJingleSession(x1.getUser());
            //                js0.addStateListener(new JingleSessionStateListener() {
            //
            //                    public void beforeChange(JingleNegotiator.State old, JingleNegotiator.State newOne)
            //                            throws JingleNegotiator.JingleException {
            //                    }
            //
            //                    public void afterChanged(JingleNegotiator.State old, JingleNegotiator.State newOne) {
            //                        if (newOne != null) {
            //                            if ((newOne instanceof OutgoingJingleSession.Active))
            //                                System.err.println("|||" + newOne.getClass().getCanonicalName() + "|||");
            //                        }
            //                    }
            //                });
            js0.startOutgoing();
            Thread.sleep(45000);
            js0.terminate();
            Thread.sleep(1500);
        }
    } catch (Exception e) {
        LOGGER.log(Level.WARNING, "exception", e);
    }
}
Also used : JmfMediaManager(org.jivesoftware.smackx.jingle.mediaimpl.jmf.JmfMediaManager) ICETransportManager(org.jivesoftware.smackx.jingle.nat.ICETransportManager) ArrayList(java.util.ArrayList) MultiMediaManager(org.jivesoftware.smackx.jingle.mediaimpl.multi.MultiMediaManager) JingleSessionRequestListener(org.jivesoftware.smackx.jingle.listeners.JingleSessionRequestListener) XMPPException(org.jivesoftware.smack.XMPPException) JingleMediaManager(org.jivesoftware.smackx.jingle.media.JingleMediaManager) SpeexMediaManager(org.jivesoftware.smackx.jingle.mediaimpl.jspeex.SpeexMediaManager) XMPPException(org.jivesoftware.smack.XMPPException)

Example 4 with JmfMediaManager

use of org.jivesoftware.smackx.jingle.mediaimpl.jmf.JmfMediaManager in project Smack by igniterealtime.

the class JingleMediaTest method testCompleteWithBridgeB.

public void testCompleteWithBridgeB() {
    try {
        //SmackConfiguration.DEBUG = true;
        XMPPTCPConnection x0 = getConnection(0);
        XMPPTCPConnection x1 = getConnection(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);
        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.terminate();
        Thread.sleep(3000);
        js0 = jm0.createOutgoingJingleSession(x1.getUser());
        js0.startOutgoing();
        Thread.sleep(20000);
        js0.terminate();
        Thread.sleep(3000);
        x0.disconnect();
        x1.disconnect();
    } catch (Exception e) {
        LOGGER.log(Level.WARNING, "exception", e);
    }
}
Also used : JmfMediaManager(org.jivesoftware.smackx.jingle.mediaimpl.jmf.JmfMediaManager) JingleMediaManager(org.jivesoftware.smackx.jingle.media.JingleMediaManager) ArrayList(java.util.ArrayList) XMPPException(org.jivesoftware.smack.XMPPException) JingleSessionRequestListener(org.jivesoftware.smackx.jingle.listeners.JingleSessionRequestListener) XMPPException(org.jivesoftware.smack.XMPPException) BridgedTransportManager(org.jivesoftware.smackx.jingle.nat.BridgedTransportManager)

Example 5 with JmfMediaManager

use of org.jivesoftware.smackx.jingle.mediaimpl.jmf.JmfMediaManager 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)

Aggregations

ArrayList (java.util.ArrayList)5 XMPPException (org.jivesoftware.smack.XMPPException)5 JingleSessionRequestListener (org.jivesoftware.smackx.jingle.listeners.JingleSessionRequestListener)5 JingleMediaManager (org.jivesoftware.smackx.jingle.media.JingleMediaManager)5 JmfMediaManager (org.jivesoftware.smackx.jingle.mediaimpl.jmf.JmfMediaManager)5 List (java.util.List)2 BridgedTransportManager (org.jivesoftware.smackx.jingle.nat.BridgedTransportManager)2 ICETransportManager (org.jivesoftware.smackx.jingle.nat.ICETransportManager)2 JingleSessionListener (org.jivesoftware.smackx.jingle.listeners.JingleSessionListener)1 PayloadType (org.jivesoftware.smackx.jingle.media.PayloadType)1 SpeexMediaManager (org.jivesoftware.smackx.jingle.mediaimpl.jspeex.SpeexMediaManager)1 MultiMediaManager (org.jivesoftware.smackx.jingle.mediaimpl.multi.MultiMediaManager)1 FixedResolver (org.jivesoftware.smackx.jingle.nat.FixedResolver)1 FixedTransportManager (org.jivesoftware.smackx.jingle.nat.FixedTransportManager)1 TransportCandidate (org.jivesoftware.smackx.jingle.nat.TransportCandidate)1