mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-26 22:12:05 +01:00
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7104 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
858b84d912
commit
ed660f73e9
5 changed files with 132 additions and 97 deletions
|
@ -1,5 +1,16 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<module version="4" relativePaths="true" type="JAVA_MODULE">
|
<module version="4" relativePaths="true" type="JAVA_MODULE">
|
||||||
|
<component name="BuildJarSettings">
|
||||||
|
<containerInfo>
|
||||||
|
<containerElement type="module" name="JingleExtension">
|
||||||
|
<attribute name="method" value="1" />
|
||||||
|
<attribute name="URI" value="/" />
|
||||||
|
</containerElement>
|
||||||
|
</containerInfo>
|
||||||
|
<setting name="jarUrl" value="file://$MODULE_DIR$/../../JingleExtension.jar" />
|
||||||
|
<setting name="buildJar" value="true" />
|
||||||
|
<setting name="mainClass" value="" />
|
||||||
|
</component>
|
||||||
<component name="ModuleRootManager" />
|
<component name="ModuleRootManager" />
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
||||||
<output url="file://$MODULE_DIR$/../../classes" />
|
<output url="file://$MODULE_DIR$/../../classes" />
|
||||||
|
@ -30,6 +41,7 @@
|
||||||
</library>
|
</library>
|
||||||
</orderEntry>
|
</orderEntry>
|
||||||
<orderEntry type="module" module-name="Smack" />
|
<orderEntry type="module" module-name="Smack" />
|
||||||
|
<orderEntry type="module" module-name="JingleMedia" />
|
||||||
<orderEntryProperties />
|
<orderEntryProperties />
|
||||||
</component>
|
</component>
|
||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
|
|
|
@ -49,34 +49,34 @@ import java.util.List;
|
||||||
* Jingle is a session establishment protocol defined in (XEP-0166).
|
* Jingle is a session establishment protocol defined in (XEP-0166).
|
||||||
* It defines a framework for negotiating and managing out-of-band ( data that is send and receive through other connection than XMPP connection) data sessions over XMPP.
|
* It defines a framework for negotiating and managing out-of-band ( data that is send and receive through other connection than XMPP connection) data sessions over XMPP.
|
||||||
* With this protocol you can setup VOIP Calls, Video Streaming, File transfers and whatever out-of-band session based transmission.
|
* With this protocol you can setup VOIP Calls, Video Streaming, File transfers and whatever out-of-band session based transmission.
|
||||||
*
|
* <p/>
|
||||||
* To create a Jingle Session you need a Transport method and a Payload type.
|
* To create a Jingle Session you need a Transport method and a Payload type.
|
||||||
*
|
* <p/>
|
||||||
* A transport method is how it will trasmit and receive network packets. Transport MUST have one or more candidates.
|
* A transport method is how it will trasmit and receive network packets. Transport MUST have one or more candidates.
|
||||||
* A transport candidate is an IP Address with a defined port, that other party must send data to.
|
* A transport candidate is an IP Address with a defined port, that other party must send data to.
|
||||||
*
|
* <p/>
|
||||||
* A supported payload type, is the data encoding format that the jmf will be transmitted.
|
* A supported payload type, is the data encoding format that the jmf will be transmitted.
|
||||||
* For instance an Audio Payload "GSM".
|
* For instance an Audio Payload "GSM".
|
||||||
*
|
* <p/>
|
||||||
* A Jingle session negociates a payload type and a pair of transport candidates.
|
* A Jingle session negociates a payload type and a pair of transport candidates.
|
||||||
* Which means that when a Jingle Session is establhished you will have two defined transport candidates with addresses
|
* Which means that when a Jingle Session is establhished you will have two defined transport candidates with addresses
|
||||||
* and a defined Payload type.
|
* and a defined Payload type.
|
||||||
* In other words, you will have two IP address with their respective ports, and a Codec type defined.
|
* In other words, you will have two IP address with their respective ports, and a Codec type defined.
|
||||||
*
|
* <p/>
|
||||||
* The JingleManager is a facade built upon Jabber Jingle (XEP-166) to allow the
|
* The JingleManager is a facade built upon Jabber Jingle (XEP-166) to allow the
|
||||||
* use of Jingle. This implementation allows the user to simply
|
* use of Jingle. This implementation allows the user to simply
|
||||||
* use this class for setting the Jingle parameters, create and receive Jingle Sessions.
|
* use this class for setting the Jingle parameters, create and receive Jingle Sessions.
|
||||||
*
|
* <p/>
|
||||||
* In order to use the Jingle, the user must provide a
|
* In order to use the Jingle, the user must provide a
|
||||||
* TransportManager that will handle the resolution of potential IP addresses taht can be used to transport the streaming (jmf).
|
* TransportManager that will handle the resolution of potential IP addresses taht can be used to transport the streaming (jmf).
|
||||||
* This TransportManager can be initialized with several default resolvers,
|
* This TransportManager can be initialized with several default resolvers,
|
||||||
* including a fixed solver that can be used when the address and port are know
|
* including a fixed solver that can be used when the address and port are know
|
||||||
* in advance.
|
* in advance.
|
||||||
* This API have ready to use Transport Managers, for instance: BasicTransportManager, STUNTransportManager, BridgedTransportManager.
|
* This API have ready to use Transport Managers, for instance: BasicTransportManager, STUNTransportManager, BridgedTransportManager.
|
||||||
*
|
* <p/>
|
||||||
* You should also especify a JingleMediaManager if you want that JingleManager assume Media control
|
* You should also especify a JingleMediaManager if you want that JingleManager assume Media control
|
||||||
* Using a JingleMediaManager implementation is the easier way to implement a Jingle Application.
|
* Using a JingleMediaManager implementation is the easier way to implement a Jingle Application.
|
||||||
*
|
* <p/>
|
||||||
* Otherwise before creating an outgoing connection, the user must create jingle session
|
* Otherwise before creating an outgoing connection, the user must create jingle session
|
||||||
* listeners that will be called when different events happen. The most
|
* listeners that will be called when different events happen. The most
|
||||||
* important event is <i>sessionEstablished()</i>, that will be called when all
|
* important event is <i>sessionEstablished()</i>, that will be called when all
|
||||||
|
@ -84,85 +84,85 @@ import java.util.List;
|
||||||
* transmission as well as the remote and local addresses and ports for the
|
* transmission as well as the remote and local addresses and ports for the
|
||||||
* communication. See JingleSessionListener for a complete list of events that can be
|
* communication. See JingleSessionListener for a complete list of events that can be
|
||||||
* observed.
|
* observed.
|
||||||
*
|
* <p/>
|
||||||
* This is an example of how to use the JingleManager:
|
* This is an example of how to use the JingleManager:
|
||||||
* <i>This example implements a Jingle VOIP Call between two users.</i>
|
* <i>This example implements a Jingle VOIP Call between two users.</i>
|
||||||
*
|
* <p/>
|
||||||
* <pre>
|
* <pre>
|
||||||
*
|
* <p/>
|
||||||
* To wait for an Incoming Jingle Session:
|
* To wait for an Incoming Jingle Session:
|
||||||
*
|
* <p/>
|
||||||
* try {
|
* try {
|
||||||
*
|
* <p/>
|
||||||
* // Connect to a XMPP Server
|
* // Connect to a XMPP Server
|
||||||
* XMPPConnection x1 = new XMPPConnection("xmpp.com");
|
* XMPPConnection x1 = new XMPPConnection("xmpp.com");
|
||||||
* x1.connect();
|
* x1.connect();
|
||||||
* x1.login("juliet", "juliet");
|
* x1.login("juliet", "juliet");
|
||||||
*
|
* <p/>
|
||||||
* // Create a JingleManager using a BasicResolver
|
* // Create a JingleManager using a BasicResolver
|
||||||
* final JingleManager jm1 = new JingleManager(
|
* final JingleManager jm1 = new JingleManager(
|
||||||
* x1, new BasicTransportManager());
|
* x1, new BasicTransportManager());
|
||||||
*
|
* <p/>
|
||||||
* // Create a JingleMediaManager. In this case using Jingle Audio Media API
|
* // Create a JingleMediaManager. In this case using Jingle Audio Media API
|
||||||
* JingleMediaManager jingleMediaManager = new AudioMediaManager();
|
* JingleMediaManager jingleMediaManager = new AudioMediaManager();
|
||||||
*
|
* <p/>
|
||||||
* // Set the JingleMediaManager
|
* // Set the JingleMediaManager
|
||||||
* jm1.setMediaManager(jingleMediaManager);
|
* jm1.setMediaManager(jingleMediaManager);
|
||||||
*
|
* <p/>
|
||||||
* // Listen for incoming calls
|
* // Listen for incoming calls
|
||||||
* jm1.addJingleSessionRequestListener(new JingleSessionRequestListener() {
|
* jm1.addJingleSessionRequestListener(new JingleSessionRequestListener() {
|
||||||
* public void sessionRequested(JingleSessionRequest request) {
|
* public void sessionRequested(JingleSessionRequest request) {
|
||||||
*
|
* <p/>
|
||||||
* try {
|
* try {
|
||||||
* // Accept the call
|
* // Accept the call
|
||||||
* IncomingJingleSession session = request.accept();
|
* IncomingJingleSession session = request.accept();
|
||||||
*
|
* <p/>
|
||||||
*
|
* <p/>
|
||||||
* // Start the call
|
* // Start the call
|
||||||
* session.start();
|
* session.start();
|
||||||
* } catch (XMPPException e) {
|
* } catch (XMPPException e) {
|
||||||
* e.printStackTrace();
|
* e.printStackTrace();
|
||||||
* }
|
* }
|
||||||
*
|
* <p/>
|
||||||
* }
|
* }
|
||||||
* });
|
* });
|
||||||
*
|
* <p/>
|
||||||
* Thread.sleep(15000);
|
* Thread.sleep(15000);
|
||||||
*
|
* <p/>
|
||||||
* } catch (Exception e) {
|
* } catch (Exception e) {
|
||||||
* e.printStackTrace();
|
* e.printStackTrace();
|
||||||
* }
|
* }
|
||||||
*
|
* <p/>
|
||||||
* To create an Outgoing Jingle Session:
|
* To create an Outgoing Jingle Session:
|
||||||
*
|
* <p/>
|
||||||
* try {
|
* try {
|
||||||
*
|
* <p/>
|
||||||
* // Connect to a XMPP Server
|
* // Connect to a XMPP Server
|
||||||
* XMPPConnection x0 = new XMPPConnection("xmpp.com");
|
* XMPPConnection x0 = new XMPPConnection("xmpp.com");
|
||||||
* x0.connect();
|
* x0.connect();
|
||||||
* x0.login("romeo", "romeo");
|
* x0.login("romeo", "romeo");
|
||||||
*
|
* <p/>
|
||||||
* // Create a JingleManager using a BasicResolver
|
* // Create a JingleManager using a BasicResolver
|
||||||
* final JingleManager jm0 = new JingleManager(
|
* final JingleManager jm0 = new JingleManager(
|
||||||
* x0, new BasicTransportManager());
|
* x0, new BasicTransportManager());
|
||||||
*
|
* <p/>
|
||||||
* // Create a JingleMediaManager. In this case using Jingle Audio Media API
|
* // Create a JingleMediaManager. In this case using Jingle Audio Media API
|
||||||
* JingleMediaManager jingleMediaManager = new AudioMediaManager(); // Using Jingle Media API
|
* JingleMediaManager jingleMediaManager = new AudioMediaManager(); // Using Jingle Media API
|
||||||
*
|
* <p/>
|
||||||
* // Set the JingleMediaManager
|
* // Set the JingleMediaManager
|
||||||
* jm0.setMediaManager(jingleMediaManager);
|
* jm0.setMediaManager(jingleMediaManager);
|
||||||
*
|
* <p/>
|
||||||
* // Create a new Jingle Call with a full JID
|
* // Create a new Jingle Call with a full JID
|
||||||
* OutgoingJingleSession js0 = jm0.createOutgoingJingleSession("juliet@xmpp.com/Smack");
|
* OutgoingJingleSession js0 = jm0.createOutgoingJingleSession("juliet@xmpp.com/Smack");
|
||||||
*
|
* <p/>
|
||||||
* // Start the call
|
* // Start the call
|
||||||
* js0.start();
|
* js0.start();
|
||||||
*
|
* <p/>
|
||||||
* Thread.sleep(10000);
|
* Thread.sleep(10000);
|
||||||
* js0.terminate();
|
* js0.terminate();
|
||||||
*
|
* <p/>
|
||||||
* Thread.sleep(3000);
|
* Thread.sleep(3000);
|
||||||
*
|
* <p/>
|
||||||
* } catch (Exception e) {
|
* } catch (Exception e) {
|
||||||
* e.printStackTrace();
|
* e.printStackTrace();
|
||||||
* }
|
* }
|
||||||
|
@ -275,7 +275,8 @@ public class JingleManager implements JingleSessionListener {
|
||||||
if (aux != null)
|
if (aux != null)
|
||||||
try {
|
try {
|
||||||
aux.terminate();
|
aux.terminate();
|
||||||
} catch (XMPPException e) {
|
}
|
||||||
|
catch (XMPPException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -323,8 +324,8 @@ public class JingleManager implements JingleSessionListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables or disables the Jingle support on a given connection.
|
* Enables or disables the Jingle support on a given connection.
|
||||||
*
|
* <p/>
|
||||||
*
|
* <p/>
|
||||||
* Before starting any Jingle jmf session, check that the user can handle
|
* Before starting any Jingle jmf session, check that the user can handle
|
||||||
* it. Enable the Jingle support to indicate that this client handles Jingle
|
* it. Enable the Jingle support to indicate that this client handles Jingle
|
||||||
* messages.
|
* messages.
|
||||||
|
@ -342,7 +343,8 @@ public class JingleManager implements JingleSessionListener {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
ServiceDiscoveryManager.getInstanceFor(connection).addFeature(
|
ServiceDiscoveryManager.getInstanceFor(connection).addFeature(
|
||||||
Jingle.NAMESPACE);
|
Jingle.NAMESPACE);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
ServiceDiscoveryManager.getInstanceFor(connection).removeFeature(
|
ServiceDiscoveryManager.getInstanceFor(connection).removeFeature(
|
||||||
Jingle.NAMESPACE);
|
Jingle.NAMESPACE);
|
||||||
}
|
}
|
||||||
|
@ -475,7 +477,8 @@ public class JingleManager implements JingleSessionListener {
|
||||||
for (CreatedJingleSessionListener createdJingleSessionListener : creationListeners) {
|
for (CreatedJingleSessionListener createdJingleSessionListener : creationListeners) {
|
||||||
try {
|
try {
|
||||||
createdJingleSessionListener.sessionCreated(jingleSession);
|
createdJingleSessionListener.sessionCreated(jingleSession);
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -549,7 +552,8 @@ public class JingleManager implements JingleSessionListener {
|
||||||
for (JingleSession jingleSession : sessions)
|
for (JingleSession jingleSession : sessions)
|
||||||
try {
|
try {
|
||||||
jingleSession.terminate();
|
jingleSession.terminate();
|
||||||
} catch (XMPPException e) {
|
}
|
||||||
|
catch (XMPPException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,8 +670,10 @@ public class JingleManager implements JingleSessionListener {
|
||||||
if (request == null) {
|
if (request == null) {
|
||||||
throw new NullPointerException("JingleMediaManager is not defined");
|
throw new NullPointerException("JingleMediaManager is not defined");
|
||||||
}
|
}
|
||||||
if (jingleMediaManager == null) return null;
|
if (jingleMediaManager != null)
|
||||||
return createIncomingJingleSession(request, jingleMediaManager.getPayloads());
|
return createIncomingJingleSession(request, jingleMediaManager.getPayloads());
|
||||||
|
|
||||||
|
return createIncomingJingleSession(request,null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -682,7 +688,8 @@ public class JingleManager implements JingleSessionListener {
|
||||||
if (jingleSession.getResponder().equals(jid)) {
|
if (jingleSession.getResponder().equals(jid)) {
|
||||||
return jingleSession;
|
return jingleSession;
|
||||||
}
|
}
|
||||||
} else if (jingleSession instanceof IncomingJingleSession) {
|
}
|
||||||
|
else if (jingleSession instanceof IncomingJingleSession) {
|
||||||
if (jingleSession.getInitiator().equals(jid)) {
|
if (jingleSession.getInitiator().equals(jid)) {
|
||||||
return jingleSession;
|
return jingleSession;
|
||||||
}
|
}
|
||||||
|
|
|
@ -343,6 +343,8 @@ public abstract class JingleSession extends JingleNegotiator {
|
||||||
public IQ dispatchIncomingPacket(IQ iq, String id) throws XMPPException {
|
public IQ dispatchIncomingPacket(IQ iq, String id) throws XMPPException {
|
||||||
IQ jout = null;
|
IQ jout = null;
|
||||||
|
|
||||||
|
if (iq != null) System.out.println("L: " + iq.toXML());
|
||||||
|
|
||||||
if (invalidState()) {
|
if (invalidState()) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"Illegal state in dispatch packet in Session manager.");
|
"Illegal state in dispatch packet in Session manager.");
|
||||||
|
@ -377,12 +379,16 @@ public abstract class JingleSession extends JingleNegotiator {
|
||||||
jout = getState().eventInfo(jin);
|
jout = getState().eventInfo(jin);
|
||||||
}
|
}
|
||||||
else if (action.equals(Jingle.Action.SESSIONINITIATE)) {
|
else if (action.equals(Jingle.Action.SESSIONINITIATE)) {
|
||||||
|
if (getState() != null)
|
||||||
jout = getState().eventInitiate(jin);
|
jout = getState().eventInitiate(jin);
|
||||||
}
|
}
|
||||||
else if (action.equals(Jingle.Action.SESSIONREDIRECT)) {
|
else if (action.equals(Jingle.Action.SESSIONREDIRECT)) {
|
||||||
jout = getState().eventRedirect(jin);
|
jout = getState().eventRedirect(jin);
|
||||||
}
|
}
|
||||||
else if (action.equals(Jingle.Action.SESSIONTERMINATE)) {
|
else if (action.equals(Jingle.Action.SESSIONTERMINATE)) {
|
||||||
|
|
||||||
|
System.out.println("SESSION PACKET");
|
||||||
|
|
||||||
jout = getState().eventTerminate(jin);
|
jout = getState().eventTerminate(jin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -417,6 +423,9 @@ public abstract class JingleSession extends JingleNegotiator {
|
||||||
public synchronized IQ respond(IQ iq) throws XMPPException {
|
public synchronized IQ respond(IQ iq) throws XMPPException {
|
||||||
IQ response = null;
|
IQ response = null;
|
||||||
|
|
||||||
|
if (iq != null)
|
||||||
|
System.out.println("TT: " + iq.toXML());
|
||||||
|
|
||||||
if (isValid()) {
|
if (isValid()) {
|
||||||
String responseId = null;
|
String responseId = null;
|
||||||
IQ sessionResponse = null;
|
IQ sessionResponse = null;
|
||||||
|
@ -887,10 +896,10 @@ public abstract class JingleSession extends JingleNegotiator {
|
||||||
if (iq instanceof Jingle) {
|
if (iq instanceof Jingle) {
|
||||||
Jingle jin = (Jingle) iq;
|
Jingle jin = (Jingle) iq;
|
||||||
|
|
||||||
//System.out.println("Jingle: " + iq.toXML());
|
System.out.println("Jingle: " + iq.toXML());
|
||||||
|
|
||||||
String sid = jin.getSid();
|
String sid = jin.getSid();
|
||||||
if (!sid.equals(getSid())) {
|
if (sid == null || !sid.equals(getSid())) {
|
||||||
System.out.println("Ignored Jingle(SID) " + sid + "|" + getSid() + " :" + iq.toXML());
|
System.out.println("Ignored Jingle(SID) " + sid + "|" + getSid() + " :" + iq.toXML());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1091,7 +1100,7 @@ public abstract class JingleSession extends JingleNegotiator {
|
||||||
destroyMediaNeg();
|
destroyMediaNeg();
|
||||||
destroyTransportNeg();
|
destroyTransportNeg();
|
||||||
removePacketListener();
|
removePacketListener();
|
||||||
System.out.println("Negociation Closed");
|
System.out.println("Negociation Closed: "+getConnection().getUser());
|
||||||
closed = true;
|
closed = true;
|
||||||
super.close();
|
super.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,9 @@ public class JingleSessionRequest {
|
||||||
pts);
|
pts);
|
||||||
session.setInitialSessionRequest(this);
|
session.setInitialSessionRequest(this);
|
||||||
// Acknowledge the IQ reception
|
// Acknowledge the IQ reception
|
||||||
session.sendAck(this.getJingle());
|
session.setSid(this.getSessionID());
|
||||||
|
//session.sendAck(this.getJingle());
|
||||||
|
//session.respond(this.getJingle());
|
||||||
}
|
}
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
@ -93,6 +95,11 @@ public class JingleSessionRequest {
|
||||||
synchronized (manager) {
|
synchronized (manager) {
|
||||||
session = manager.createIncomingJingleSession(this);
|
session = manager.createIncomingJingleSession(this);
|
||||||
session.setInitialSessionRequest(this);
|
session.setInitialSessionRequest(this);
|
||||||
|
// Acknowledge the IQ reception
|
||||||
|
session.setSid(this.getSessionID());
|
||||||
|
//session.sendAck(this.getJingle());
|
||||||
|
//session.updatePacketListener();
|
||||||
|
//session.respond(this.getJingle());
|
||||||
}
|
}
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,7 @@ import org.jivesoftware.smackx.jingle.media.PayloadType;
|
||||||
import org.jivesoftware.smackx.jingle.nat.*;
|
import org.jivesoftware.smackx.jingle.nat.*;
|
||||||
import org.jivesoftware.smackx.packet.Jingle;
|
import org.jivesoftware.smackx.packet.Jingle;
|
||||||
import org.jivesoftware.smackx.provider.JingleProvider;
|
import org.jivesoftware.smackx.provider.JingleProvider;
|
||||||
|
import org.jivesoftware.jingleaudio.jmf.JmfMediaManager;
|
||||||
|
|
||||||
import java.net.DatagramPacket;
|
import java.net.DatagramPacket;
|
||||||
import java.net.DatagramSocket;
|
import java.net.DatagramSocket;
|
||||||
|
@ -515,8 +516,8 @@ public class JingleManagerTest extends SmackTestCase {
|
||||||
resetCounter();
|
resetCounter();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
TransportResolver tr1 = new FixedResolver("127.0.0.1", 54222);
|
TransportResolver tr1 = new FixedResolver("127.0.0.1", 22222);
|
||||||
TransportResolver tr2 = new FixedResolver("127.0.0.1", 54567);
|
TransportResolver tr2 = new FixedResolver("127.0.0.1", 22444);
|
||||||
|
|
||||||
final JingleManager man0 = new JingleManager(getConnection(0), tr1);
|
final JingleManager man0 = new JingleManager(getConnection(0), tr1);
|
||||||
final JingleManager man1 = new JingleManager(getConnection(1), tr2);
|
final JingleManager man1 = new JingleManager(getConnection(1), tr2);
|
||||||
|
@ -527,13 +528,13 @@ public class JingleManagerTest extends SmackTestCase {
|
||||||
*/
|
*/
|
||||||
public void sessionRequested(final JingleSessionRequest request) {
|
public void sessionRequested(final JingleSessionRequest request) {
|
||||||
System.out.println("Session request detected, from "
|
System.out.println("Session request detected, from "
|
||||||
+ request.getFrom() + ": rejecting.");
|
+ request.getFrom());
|
||||||
|
|
||||||
// We reject the request
|
// We reject the request
|
||||||
try {
|
try {
|
||||||
IncomingJingleSession session = request.accept(null);
|
IncomingJingleSession session = request.accept(getTestPayloads1());
|
||||||
|
session.setInitialSessionRequest(request);
|
||||||
session.start();
|
session.start();
|
||||||
session.terminate();
|
|
||||||
}
|
}
|
||||||
catch (XMPPException e) {
|
catch (XMPPException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -549,6 +550,7 @@ public class JingleManagerTest extends SmackTestCase {
|
||||||
|
|
||||||
session0.addListener(new JingleSessionListener() {
|
session0.addListener(new JingleSessionListener() {
|
||||||
public void sessionClosed(String reason, JingleSession jingleSession) {
|
public void sessionClosed(String reason, JingleSession jingleSession) {
|
||||||
|
System.out.println("The session has been closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sessionClosedOnError(XMPPException e, JingleSession jingleSession) {
|
public void sessionClosedOnError(XMPPException e, JingleSession jingleSession) {
|
||||||
|
@ -571,6 +573,10 @@ public class JingleManagerTest extends SmackTestCase {
|
||||||
|
|
||||||
session0.start();
|
session0.start();
|
||||||
|
|
||||||
|
Thread.sleep(50000);
|
||||||
|
|
||||||
|
session0.terminate();
|
||||||
|
|
||||||
Thread.sleep(10000);
|
Thread.sleep(10000);
|
||||||
|
|
||||||
assertTrue(valCounter() > 0);
|
assertTrue(valCounter() > 0);
|
||||||
|
@ -594,13 +600,10 @@ public class JingleManagerTest extends SmackTestCase {
|
||||||
ProviderManager.getInstance().addIQProvider(RTPBridge.NAME,
|
ProviderManager.getInstance().addIQProvider(RTPBridge.NAME,
|
||||||
RTPBridge.NAMESPACE, new RTPBridge.Provider());
|
RTPBridge.NAMESPACE, new RTPBridge.Provider());
|
||||||
|
|
||||||
XMPPConnection x2 = new XMPPConnection("thiago");
|
RTPBridge response = RTPBridge.getRTPBridge(getConnection(0), "102");
|
||||||
x2.connect();
|
|
||||||
x2.login("barata6", "barata6");
|
|
||||||
|
|
||||||
RTPBridge response = RTPBridge.getRTPBridge(x2, "102");
|
|
||||||
|
|
||||||
class Listener implements Runnable {
|
class Listener implements Runnable {
|
||||||
|
|
||||||
private byte[] buf = new byte[5000];
|
private byte[] buf = new byte[5000];
|
||||||
private DatagramSocket dataSocket;
|
private DatagramSocket dataSocket;
|
||||||
private DatagramPacket packet;
|
private DatagramPacket packet;
|
||||||
|
@ -617,7 +620,8 @@ public class JingleManagerTest extends SmackTestCase {
|
||||||
dataSocket.receive(packet);
|
dataSocket.receive(packet);
|
||||||
incCounter();
|
incCounter();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -660,14 +664,18 @@ public class JingleManagerTest extends SmackTestCase {
|
||||||
ds0.close();
|
ds0.close();
|
||||||
ds1.close();
|
ds1.close();
|
||||||
|
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
}
|
||||||
|
finally {
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
}
|
||||||
|
finally {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -683,13 +691,8 @@ public class JingleManagerTest extends SmackTestCase {
|
||||||
|
|
||||||
XMPPConnection.DEBUG_ENABLED = true;
|
XMPPConnection.DEBUG_ENABLED = true;
|
||||||
|
|
||||||
XMPPConnection x0 = new XMPPConnection("thiago");
|
XMPPConnection x0 = getConnection(0);
|
||||||
XMPPConnection x1 = new XMPPConnection("thiago");
|
XMPPConnection x1 = getConnection(1);
|
||||||
|
|
||||||
x0.connect();
|
|
||||||
x0.login("barata7", "barata7");
|
|
||||||
x1.connect();
|
|
||||||
x1.login("barata6", "barata6");
|
|
||||||
|
|
||||||
final JingleManager jm0 = new JingleManager(
|
final JingleManager jm0 = new JingleManager(
|
||||||
x0, new STUNResolver() {
|
x0, new STUNResolver() {
|
||||||
|
@ -765,14 +768,15 @@ public class JingleManagerTest extends SmackTestCase {
|
||||||
});
|
});
|
||||||
|
|
||||||
session.start();
|
session.start();
|
||||||
} catch (XMPPException e) {
|
}
|
||||||
|
catch (XMPPException e) {
|
||||||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
OutgoingJingleSession js0 = jm0.createOutgoingJingleSession("barata6@thiago/Smack");
|
OutgoingJingleSession js0 = jm0.createOutgoingJingleSession(x1.getUser());
|
||||||
|
|
||||||
js0.addListener(new JingleSessionListener() {
|
js0.addListener(new JingleSessionListener() {
|
||||||
|
|
||||||
|
@ -807,7 +811,8 @@ public class JingleManagerTest extends SmackTestCase {
|
||||||
assertTrue(valCounter() == 2);
|
assertTrue(valCounter() == 2);
|
||||||
//Thread.sleep(15000);
|
//Thread.sleep(15000);
|
||||||
|
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -824,23 +829,16 @@ public class JingleManagerTest extends SmackTestCase {
|
||||||
|
|
||||||
//XMPPConnection.DEBUG_ENABLED = true;
|
//XMPPConnection.DEBUG_ENABLED = true;
|
||||||
|
|
||||||
XMPPConnection x0 = new XMPPConnection("thiago");
|
XMPPConnection x0 = getConnection(0);
|
||||||
XMPPConnection x1 = new XMPPConnection("thiago");
|
XMPPConnection x1 = getConnection(1);
|
||||||
|
|
||||||
x0.connect();
|
|
||||||
x0.login("barata7", "barata7");
|
|
||||||
x1.connect();
|
|
||||||
x1.login("barata6", "barata6");
|
|
||||||
|
|
||||||
final JingleManager jm0 = new JingleManager(
|
final JingleManager jm0 = new JingleManager(
|
||||||
x0, new FixedResolver("127.0.0.1", 20004));
|
x0, new FixedResolver("127.0.0.1", 20004));
|
||||||
final JingleManager jm1 = new JingleManager(
|
final JingleManager jm1 = new JingleManager(
|
||||||
x1, new FixedResolver("127.0.0.1", 20040));
|
x1, new FixedResolver("127.0.0.1", 20040));
|
||||||
|
|
||||||
// JingleManager jm0 = new JingleSessionManager(
|
//JingleManager jm0 = new ICETransportManager(x0, "stun.xten.net", 3478);
|
||||||
// x0, new ICEResolver());
|
//JingleManager jm1 = new ICETransportManager(x1, "stun.xten.net", 3478);
|
||||||
// JingleManager jm1 = new JingleSessionManager(
|
|
||||||
// x1, new ICEResolver());
|
|
||||||
|
|
||||||
JingleMediaManager jingleMediaManager = new JingleMediaManager() {
|
JingleMediaManager jingleMediaManager = new JingleMediaManager() {
|
||||||
// Media Session Implementation
|
// Media Session Implementation
|
||||||
|
@ -890,14 +888,15 @@ public class JingleManagerTest extends SmackTestCase {
|
||||||
IncomingJingleSession session = request.accept(jm1.getMediaManager().getPayloads());
|
IncomingJingleSession session = request.accept(jm1.getMediaManager().getPayloads());
|
||||||
|
|
||||||
session.start(request);
|
session.start(request);
|
||||||
} catch (XMPPException e) {
|
}
|
||||||
|
catch (XMPPException e) {
|
||||||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
OutgoingJingleSession js0 = jm0.createOutgoingJingleSession("barata6@thiago/Smack");
|
OutgoingJingleSession js0 = jm0.createOutgoingJingleSession(x1.getUser());
|
||||||
|
|
||||||
js0.start();
|
js0.start();
|
||||||
|
|
||||||
|
@ -911,7 +910,8 @@ public class JingleManagerTest extends SmackTestCase {
|
||||||
assertTrue(valCounter() == 8);
|
assertTrue(valCounter() == 8);
|
||||||
//Thread.sleep(15000);
|
//Thread.sleep(15000);
|
||||||
|
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue