2007-05-08 22:31:46 +02:00
|
|
|
package org.jivesoftware.smackx.jingle;
|
|
|
|
|
2007-03-10 19:07:04 +01:00
|
|
|
/**
|
2008-05-20 00:54:19 +02:00
|
|
|
* $RCSfile: JingleMediaTest.java,v $
|
|
|
|
* $Revision: 1.2 $
|
2007-03-10 19:07:04 +01:00
|
|
|
* $Date: 09/11/2006
|
|
|
|
* <p/>
|
|
|
|
* Copyright 2003-2006 Jive Software.
|
|
|
|
* <p/>
|
|
|
|
* All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
* <p/>
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
* <p/>
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import org.jivesoftware.smack.XMPPConnection;
|
|
|
|
import org.jivesoftware.smack.XMPPException;
|
|
|
|
import org.jivesoftware.smack.test.SmackTestCase;
|
2008-05-20 00:54:19 +02:00
|
|
|
import org.jivesoftware.smackx.jingle.listeners.JingleSessionRequestListener;
|
|
|
|
import org.jivesoftware.smackx.jingle.media.JingleMediaManager;
|
2007-03-10 19:07:04 +01:00
|
|
|
import org.jivesoftware.smackx.jingle.mediaimpl.jmf.AudioChannel;
|
2008-05-20 00:54:19 +02:00
|
|
|
import org.jivesoftware.smackx.jingle.mediaimpl.jmf.JmfMediaManager;
|
2007-03-10 19:07:04 +01:00
|
|
|
import org.jivesoftware.smackx.jingle.mediaimpl.jspeex.SpeexMediaManager;
|
|
|
|
import org.jivesoftware.smackx.jingle.mediaimpl.multi.MultiMediaManager;
|
2007-05-02 21:55:59 +02:00
|
|
|
import org.jivesoftware.smackx.jingle.mediaimpl.sshare.ScreenShareMediaManager;
|
2007-03-10 19:07:04 +01:00
|
|
|
import org.jivesoftware.smackx.jingle.nat.BridgedTransportManager;
|
|
|
|
import org.jivesoftware.smackx.jingle.nat.ICETransportManager;
|
|
|
|
import org.jivesoftware.smackx.jingle.nat.STUNTransportManager;
|
2007-04-16 17:44:55 +02:00
|
|
|
import org.jivesoftware.smackx.packet.JingleError;
|
2007-03-10 19:07:04 +01:00
|
|
|
|
|
|
|
import javax.media.MediaLocator;
|
|
|
|
import javax.media.format.AudioFormat;
|
|
|
|
import java.net.InetAddress;
|
2008-05-20 00:54:19 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2007-03-10 19:07:04 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test the Jingle Media using the high level API
|
|
|
|
* </p>
|
|
|
|
*
|
|
|
|
* @author Thiago Camargo
|
|
|
|
*/
|
|
|
|
public class JingleMediaTest extends SmackTestCase {
|
|
|
|
|
|
|
|
public JingleMediaTest(final String name) {
|
|
|
|
super(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void testCompleteJmf() {
|
|
|
|
|
|
|
|
XMPPConnection x0 = getConnection(0);
|
|
|
|
XMPPConnection x1 = getConnection(1);
|
|
|
|
|
2007-03-20 19:52:57 +01:00
|
|
|
for (int i = 0; i < 1; i++)
|
2007-03-17 21:13:05 +01:00
|
|
|
try {
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2007-03-17 21:13:05 +01:00
|
|
|
ICETransportManager icetm0 = new ICETransportManager(x0, "jivesoftware.com", 3478);
|
|
|
|
ICETransportManager icetm1 = new ICETransportManager(x1, "jivesoftware.com", 3478);
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
JingleMediaManager jingleMediaManager0 = new JmfMediaManager(icetm0);
|
|
|
|
JingleMediaManager jingleMediaManager1 = new JmfMediaManager(icetm1);
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
List<JingleMediaManager> jml0 = new ArrayList<JingleMediaManager>();
|
|
|
|
List<JingleMediaManager> jml1 = new ArrayList<JingleMediaManager>();
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
jml0.add(jingleMediaManager0);
|
|
|
|
jml1.add(jingleMediaManager1);
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
final JingleManager jm0 = new JingleManager(x0, jml0);
|
|
|
|
final JingleManager jm1 = new JingleManager(x1, jml1);
|
|
|
|
|
|
|
|
jm0.addCreationListener(icetm0);
|
|
|
|
jm1.addCreationListener(icetm1);
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2007-03-17 21:13:05 +01:00
|
|
|
JingleSessionRequestListener jingleSessionRequestListener = new JingleSessionRequestListener() {
|
|
|
|
public void sessionRequested(final JingleSessionRequest request) {
|
|
|
|
try {
|
2008-05-20 00:54:19 +02:00
|
|
|
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) {
|
2007-03-17 21:13:05 +01:00
|
|
|
e.printStackTrace();
|
|
|
|
}
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2007-03-17 21:13:05 +01:00
|
|
|
}
|
|
|
|
};
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2007-03-17 21:13:05 +01:00
|
|
|
jm1.addJingleSessionRequestListener(jingleSessionRequestListener);
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
JingleSession js0 = jm0.createOutgoingJingleSession(x1.getUser());
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
js0.startOutgoing();
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2007-03-20 19:52:57 +01:00
|
|
|
Thread.sleep(20000);
|
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
JingleSession incomingJingleSession = jm1.getSession(js0.getConnection().getUser());
|
|
|
|
//JingleSession.removeAllStateListeners();
|
2007-03-20 19:52:57 +01:00
|
|
|
|
|
|
|
Thread.sleep(15000);
|
|
|
|
|
2007-03-17 21:13:05 +01:00
|
|
|
js0.terminate();
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2007-03-17 21:13:05 +01:00
|
|
|
jm1.removeJingleSessionRequestListener(jingleSessionRequestListener);
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2007-03-20 19:52:57 +01:00
|
|
|
Thread.sleep(60000);
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
} catch (Exception e) {
|
2007-03-17 21:13:05 +01:00
|
|
|
e.printStackTrace();
|
|
|
|
}
|
2007-03-10 19:07:04 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public void testCompleteMulti() {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
XMPPConnection x0 = getConnection(0);
|
|
|
|
XMPPConnection x1 = getConnection(1);
|
|
|
|
|
|
|
|
ICETransportManager icetm0 = new ICETransportManager(x0, "jivesoftware.com", 3478);
|
|
|
|
ICETransportManager icetm1 = new ICETransportManager(x1, "jivesoftware.com", 3478);
|
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
MultiMediaManager jingleMediaManager0 = new MultiMediaManager(icetm0);
|
|
|
|
jingleMediaManager0.addMediaManager(new JmfMediaManager(icetm0));
|
|
|
|
jingleMediaManager0.addMediaManager(new SpeexMediaManager(icetm0));
|
2007-03-20 19:52:57 +01:00
|
|
|
jingleMediaManager0.setPreferredPayloadType(jingleMediaManager0.getPayloads().get(1));
|
2008-05-20 00:54:19 +02:00
|
|
|
List<JingleMediaManager> jml0 = new ArrayList<JingleMediaManager>();
|
|
|
|
jml0.add(jingleMediaManager0);
|
|
|
|
|
|
|
|
MultiMediaManager jingleMediaManager1 = new MultiMediaManager(icetm1);
|
|
|
|
jingleMediaManager1.addMediaManager(new JmfMediaManager(icetm1));
|
|
|
|
jingleMediaManager1.addMediaManager(new SpeexMediaManager(icetm1));
|
2007-03-17 21:13:05 +01:00
|
|
|
jingleMediaManager1.setPreferredPayloadType(jingleMediaManager1.getPayloads().get(2));
|
2008-05-20 00:54:19 +02:00
|
|
|
List<JingleMediaManager> jml1 = new ArrayList<JingleMediaManager>();
|
|
|
|
jml1.add(jingleMediaManager1);
|
|
|
|
|
|
|
|
final JingleManager jm0 = new JingleManager(x0, jml0);
|
|
|
|
final JingleManager jm1 = new JingleManager(x1, jml1);
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
jm0.addCreationListener(icetm0);
|
|
|
|
jm1.addCreationListener(icetm1);
|
2007-03-10 19:07:04 +01:00
|
|
|
|
|
|
|
jm1.addJingleSessionRequestListener(new JingleSessionRequestListener() {
|
|
|
|
public void sessionRequested(final JingleSessionRequest request) {
|
|
|
|
|
|
|
|
try {
|
2008-05-20 00:54:19 +02:00
|
|
|
JingleSession session = request.accept();
|
2007-03-27 17:44:07 +02:00
|
|
|
try {
|
2007-04-06 06:37:44 +02:00
|
|
|
Thread.sleep(12000);
|
2008-05-20 00:54:19 +02:00
|
|
|
} catch (InterruptedException e) {
|
2007-03-27 17:44:07 +02:00
|
|
|
e.printStackTrace();
|
|
|
|
}
|
2008-05-20 00:54:19 +02:00
|
|
|
session.startIncoming();
|
|
|
|
} catch (XMPPException e) {
|
2007-03-10 19:07:04 +01:00
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2007-03-27 17:44:07 +02:00
|
|
|
for (int i = 0; i < 10; i++) {
|
2007-03-27 06:24:18 +02:00
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
JingleSession js0 = jm0.createOutgoingJingleSession(x1.getUser());
|
2007-03-27 06:24:18 +02:00
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
// 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() + "|||");
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// });
|
2007-03-27 06:24:18 +02:00
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
js0.startOutgoing();
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2007-03-27 17:44:07 +02:00
|
|
|
Thread.sleep(45000);
|
2007-03-27 06:24:18 +02:00
|
|
|
js0.terminate();
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2007-03-27 06:24:18 +02:00
|
|
|
Thread.sleep(1500);
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2007-03-27 06:24:18 +02:00
|
|
|
}
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
} catch (Exception e) {
|
2007-03-10 19:07:04 +01:00
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public void testCompleteSpeex() {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
//XMPPConnection.DEBUG_ENABLED = true;
|
|
|
|
|
|
|
|
XMPPConnection x0 = getConnection(0);
|
|
|
|
XMPPConnection x1 = getConnection(1);
|
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
JingleMediaManager jingleMediaManager0 = new SpeexMediaManager(new STUNTransportManager());
|
|
|
|
JingleMediaManager jingleMediaManager1 = new SpeexMediaManager(new STUNTransportManager());
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
List<JingleMediaManager> jml0 = new ArrayList<JingleMediaManager>();
|
|
|
|
List<JingleMediaManager> jml1 = new ArrayList<JingleMediaManager>();
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
jml0.add(jingleMediaManager0);
|
|
|
|
jml1.add(jingleMediaManager1);
|
|
|
|
|
|
|
|
final JingleManager jm0 = new JingleManager(x0, jml0);
|
|
|
|
final JingleManager jm1 = new JingleManager(x1, jml1);
|
2007-05-02 21:55:59 +02:00
|
|
|
|
|
|
|
jm1.addJingleSessionRequestListener(new JingleSessionRequestListener() {
|
|
|
|
public void sessionRequested(final JingleSessionRequest request) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
JingleSession session = request.accept();
|
2007-05-02 21:55:59 +02:00
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
session.startIncoming();
|
|
|
|
} catch (XMPPException e) {
|
2007-05-02 21:55:59 +02:00
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
JingleSession js0 = jm0.createOutgoingJingleSession(x1.getUser());
|
2007-05-02 21:55:59 +02:00
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
js0.startOutgoing();
|
2007-05-02 21:55:59 +02:00
|
|
|
|
|
|
|
Thread.sleep(150000);
|
|
|
|
js0.terminate();
|
|
|
|
|
|
|
|
Thread.sleep(6000);
|
|
|
|
|
|
|
|
x0.disconnect();
|
|
|
|
x1.disconnect();
|
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
} catch (Exception e) {
|
2007-05-02 21:55:59 +02:00
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
public void testCompleteScreenShare() {
|
2007-05-02 21:55:59 +02:00
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
XMPPConnection x0 = getConnection(0);
|
|
|
|
XMPPConnection x1 = getConnection(1);
|
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
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);
|
2007-05-02 21:55:59 +02:00
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
List<JingleMediaManager> jml0 = new ArrayList<JingleMediaManager>();
|
|
|
|
List<JingleMediaManager> jml1 = new ArrayList<JingleMediaManager>();
|
2007-05-02 21:55:59 +02:00
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
jml0.add(jingleMediaManager0);
|
|
|
|
jml1.add(jingleMediaManager1);
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
final JingleManager jm0 = new JingleManager(x0, jml0);
|
|
|
|
final JingleManager jm1 = new JingleManager(x1, jml1);
|
|
|
|
|
2007-03-10 19:07:04 +01:00
|
|
|
jm1.addJingleSessionRequestListener(new JingleSessionRequestListener() {
|
|
|
|
public void sessionRequested(final JingleSessionRequest request) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
JingleSession session = request.accept();
|
|
|
|
|
|
|
|
session.startIncoming();
|
|
|
|
} catch (XMPPException e) {
|
2007-03-10 19:07:04 +01:00
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
JingleSession js0 = jm0.createOutgoingJingleSession(x1.getUser());
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
js0.startOutgoing();
|
2007-03-10 19:07:04 +01:00
|
|
|
|
|
|
|
Thread.sleep(150000);
|
|
|
|
js0.terminate();
|
|
|
|
|
|
|
|
Thread.sleep(6000);
|
|
|
|
|
|
|
|
x0.disconnect();
|
|
|
|
x1.disconnect();
|
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
} catch (Exception e) {
|
2007-03-10 19:07:04 +01:00
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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 {
|
|
|
|
|
|
|
|
XMPPConnection x0 = getConnection(n);
|
|
|
|
XMPPConnection x1 = getConnection(n + 1);
|
2008-05-20 00:54:19 +02:00
|
|
|
|
2007-03-10 19:07:04 +01:00
|
|
|
BridgedTransportManager btm0 = new BridgedTransportManager(x0);
|
|
|
|
BridgedTransportManager btm1 = new BridgedTransportManager(x1);
|
|
|
|
|
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
JingleMediaManager jingleMediaManager0 = new JmfMediaManager(btm0);
|
|
|
|
JingleMediaManager jingleMediaManager1 = new JmfMediaManager(btm1);
|
|
|
|
|
|
|
|
List<JingleMediaManager> jml0 = new ArrayList<JingleMediaManager>();
|
|
|
|
List<JingleMediaManager> jml1 = new ArrayList<JingleMediaManager>();
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
jml0.add(jingleMediaManager0);
|
|
|
|
jml1.add(jingleMediaManager1);
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
final JingleManager jm0 = new JingleManager(x0, jml0);
|
|
|
|
final JingleManager jm1 = new JingleManager(x1, jml1);
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
jm0.addCreationListener(btm0);
|
|
|
|
jm1.addCreationListener(btm1);
|
|
|
|
|
2007-03-10 19:07:04 +01:00
|
|
|
jm1.addJingleSessionRequestListener(new JingleSessionRequestListener() {
|
|
|
|
public void sessionRequested(final JingleSessionRequest request) {
|
|
|
|
|
|
|
|
try {
|
2008-05-20 00:54:19 +02:00
|
|
|
JingleSession session = request.accept();
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
session.startIncoming();
|
|
|
|
} catch (XMPPException e) {
|
2007-03-10 19:07:04 +01:00
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
JingleSession js0 = jm0.createOutgoingJingleSession(x1.getUser());
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
js0.startOutgoing();
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2007-04-16 17:44:55 +02:00
|
|
|
Thread.sleep(20000);
|
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
//js0.sendFormattedError(JingleError.UNSUPPORTED_TRANSPORTS);
|
|
|
|
js0.sendPacket(js0.createJingleError(null, JingleError.UNSUPPORTED_TRANSPORTS));
|
|
|
|
|
2007-04-16 17:44:55 +02:00
|
|
|
|
|
|
|
Thread.sleep(20000);
|
2007-03-10 19:07:04 +01:00
|
|
|
|
|
|
|
js0.terminate();
|
|
|
|
|
|
|
|
Thread.sleep(3000);
|
|
|
|
|
|
|
|
x0.disconnect();
|
|
|
|
x1.disconnect();
|
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
} catch (Exception e) {
|
2007-03-10 19:07:04 +01:00
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
t.start();
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
Thread.sleep(250000);
|
2008-05-20 00:54:19 +02:00
|
|
|
} catch (InterruptedException e) {
|
2007-03-10 19:07:04 +01:00
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void testCompleteWithBridgeB() {
|
|
|
|
try {
|
|
|
|
|
|
|
|
//XMPPConnection.DEBUG_ENABLED = true;
|
|
|
|
|
|
|
|
XMPPConnection x0 = getConnection(0);
|
|
|
|
XMPPConnection x1 = getConnection(1);
|
|
|
|
|
|
|
|
BridgedTransportManager btm0 = new BridgedTransportManager(x0);
|
|
|
|
BridgedTransportManager btm1 = new BridgedTransportManager(x1);
|
|
|
|
|
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
JingleMediaManager jingleMediaManager0 = new JmfMediaManager(btm0);
|
|
|
|
JingleMediaManager jingleMediaManager1 = new JmfMediaManager(btm1);
|
|
|
|
|
|
|
|
List<JingleMediaManager> jml0 = new ArrayList<JingleMediaManager>();
|
|
|
|
List<JingleMediaManager> jml1 = new ArrayList<JingleMediaManager>();
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
jml0.add(jingleMediaManager0);
|
|
|
|
jml1.add(jingleMediaManager1);
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
final JingleManager jm0 = new JingleManager(x0, jml0);
|
|
|
|
final JingleManager jm1 = new JingleManager(x1, jml1);
|
2007-03-10 19:07:04 +01:00
|
|
|
|
|
|
|
jm1.addJingleSessionRequestListener(new JingleSessionRequestListener() {
|
|
|
|
public void sessionRequested(final JingleSessionRequest request) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
JingleSession session = request.accept();
|
|
|
|
|
|
|
|
session.startIncoming();
|
|
|
|
} catch (XMPPException e) {
|
2007-03-10 19:07:04 +01:00
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
JingleSession js0 = jm0.createOutgoingJingleSession(x1.getUser());
|
2007-03-10 19:07:04 +01:00
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
js0.startOutgoing();
|
2007-03-10 19:07:04 +01:00
|
|
|
|
|
|
|
Thread.sleep(20000);
|
|
|
|
|
|
|
|
js0.terminate();
|
|
|
|
|
|
|
|
Thread.sleep(3000);
|
|
|
|
|
|
|
|
js0 = jm0.createOutgoingJingleSession(x1.getUser());
|
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
js0.startOutgoing();
|
2007-03-10 19:07:04 +01:00
|
|
|
|
|
|
|
Thread.sleep(20000);
|
|
|
|
|
|
|
|
js0.terminate();
|
|
|
|
|
|
|
|
Thread.sleep(3000);
|
|
|
|
|
|
|
|
x0.disconnect();
|
|
|
|
x1.disconnect();
|
|
|
|
|
2008-05-20 00:54:19 +02:00
|
|
|
} catch (Exception e) {
|
2007-03-10 19:07:04 +01:00
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public void testAudioChannelOpenClose() {
|
|
|
|
for (int i = 0; i < 5; i++) {
|
|
|
|
try {
|
2008-05-20 00:54:19 +02:00
|
|
|
AudioChannel audioChannel0 = new AudioChannel(new MediaLocator("javasound://"), InetAddress.getLocalHost()
|
|
|
|
.getHostAddress(), InetAddress.getLocalHost().getHostAddress(), 7002, 7020, new AudioFormat(
|
|
|
|
AudioFormat.GSM_RTP), null);
|
|
|
|
AudioChannel audioChannel1 = new AudioChannel(new MediaLocator("javasound://"), InetAddress.getLocalHost()
|
|
|
|
.getHostAddress(), InetAddress.getLocalHost().getHostAddress(), 7020, 7002, new AudioFormat(
|
|
|
|
AudioFormat.GSM_RTP), null);
|
2007-03-10 19:07:04 +01:00
|
|
|
|
|
|
|
audioChannel0.start();
|
|
|
|
audioChannel1.start();
|
|
|
|
|
|
|
|
try {
|
|
|
|
Thread.sleep(10000);
|
2008-05-20 00:54:19 +02:00
|
|
|
} catch (InterruptedException e) {
|
2007-03-10 19:07:04 +01:00
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
audioChannel0.stop();
|
|
|
|
audioChannel1.stop();
|
|
|
|
|
|
|
|
try {
|
|
|
|
Thread.sleep(3000);
|
2008-05-20 00:54:19 +02:00
|
|
|
} catch (InterruptedException e) {
|
2007-03-10 19:07:04 +01:00
|
|
|
e.printStackTrace();
|
|
|
|
}
|
2008-05-20 00:54:19 +02:00
|
|
|
} catch (Exception e) {
|
2007-03-10 19:07:04 +01:00
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void testAudioChannelStartStop() {
|
|
|
|
|
|
|
|
try {
|
2008-05-20 00:54:19 +02:00
|
|
|
AudioChannel audioChannel0 = new AudioChannel(new MediaLocator("javasound://"), InetAddress.getLocalHost()
|
|
|
|
.getHostAddress(), InetAddress.getLocalHost().getHostAddress(), 7002, 7020,
|
|
|
|
new AudioFormat(AudioFormat.GSM_RTP), null);
|
|
|
|
AudioChannel audioChannel1 = new AudioChannel(new MediaLocator("javasound://"), InetAddress.getLocalHost()
|
|
|
|
.getHostAddress(), InetAddress.getLocalHost().getHostAddress(), 7020, 7002,
|
|
|
|
new AudioFormat(AudioFormat.GSM_RTP), null);
|
2007-03-10 19:07:04 +01:00
|
|
|
|
|
|
|
for (int i = 0; i < 5; i++) {
|
|
|
|
|
|
|
|
audioChannel0.start();
|
|
|
|
audioChannel1.start();
|
|
|
|
|
|
|
|
try {
|
|
|
|
Thread.sleep(10000);
|
2008-05-20 00:54:19 +02:00
|
|
|
} catch (InterruptedException e) {
|
2007-03-10 19:07:04 +01:00
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
audioChannel0.stop();
|
|
|
|
audioChannel1.stop();
|
|
|
|
|
|
|
|
try {
|
|
|
|
Thread.sleep(3000);
|
2008-05-20 00:54:19 +02:00
|
|
|
} catch (InterruptedException e) {
|
2007-03-10 19:07:04 +01:00
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
2008-05-20 00:54:19 +02:00
|
|
|
} catch (Exception e) {
|
2007-03-10 19:07:04 +01:00
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected int getMaxConnections() {
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
}
|