Work in progress on emission Trickle ICE support
This commit is contained in:
parent
ce75f1e7b1
commit
8b3280cf93
@ -194,7 +194,7 @@ class ConnectivityCheckServer
|
|||||||
|
|
||||||
if(parentAgent.getCompatibilityMode() == CompatibilityMode.GTALK)
|
if(parentAgent.getCompatibilityMode() == CompatibilityMode.GTALK)
|
||||||
{
|
{
|
||||||
/* add Mapped address */
|
/* add Mapped address and remove the XOR_MAPPED_ADDRESS one*/
|
||||||
Attribute mappedAddressAttribute =
|
Attribute mappedAddressAttribute =
|
||||||
AttributeFactory.createMappedAddressAttribute(
|
AttributeFactory.createMappedAddressAttribute(
|
||||||
evt.getRemoteAddress());
|
evt.getRemoteAddress());
|
||||||
|
|||||||
@ -9,6 +9,7 @@ package test;
|
|||||||
|
|
||||||
import java.beans.*;
|
import java.beans.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.logging.*;
|
||||||
|
|
||||||
import org.ice4j.*;
|
import org.ice4j.*;
|
||||||
import org.ice4j.ice.*;
|
import org.ice4j.ice.*;
|
||||||
@ -24,6 +25,12 @@ import org.ice4j.security.*;
|
|||||||
*/
|
*/
|
||||||
public class Ice
|
public class Ice
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* The <tt>Logger</tt> used by the <tt>Ice</tt>
|
||||||
|
* class and its instances for logging output.
|
||||||
|
*/
|
||||||
|
private static final Logger logger
|
||||||
|
= Logger.getLogger(Ice.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The indicator which determines whether the <tt>Ice</tt> application (i.e.
|
* The indicator which determines whether the <tt>Ice</tt> application (i.e.
|
||||||
@ -49,10 +56,10 @@ public class Ice
|
|||||||
{
|
{
|
||||||
startTime = System.currentTimeMillis();
|
startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
Agent localAgent = createAgent(9090);
|
Agent localAgent = createAgent(9090, false);
|
||||||
localAgent.setNominationStrategy(
|
localAgent.setNominationStrategy(
|
||||||
NominationStrategy.NOMINATE_HIGHEST_PRIO);
|
NominationStrategy.NOMINATE_HIGHEST_PRIO);
|
||||||
Agent remotePeer = createAgent(6060);
|
Agent remotePeer = createAgent(6060, false);
|
||||||
|
|
||||||
localAgent.addStateChangeListener(new IceProcessingListener());
|
localAgent.addStateChangeListener(new IceProcessingListener());
|
||||||
|
|
||||||
@ -78,22 +85,22 @@ public class Ice
|
|||||||
stream.setRemotePassword(localAgent.getLocalPassword());
|
stream.setRemotePassword(localAgent.getLocalPassword());
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Total candidate gathering time: "
|
logger.info("Total candidate gathering time: "
|
||||||
+ (endTime - startTime) + "ms");
|
+ (endTime - startTime) + "ms");
|
||||||
System.out.println("LocalAgent:\n" + localAgent);
|
logger.info("LocalAgent:\n" + localAgent);
|
||||||
|
|
||||||
localAgent.startConnectivityEstablishment();
|
localAgent.startConnectivityEstablishment();
|
||||||
|
|
||||||
if (START_CONNECTIVITY_ESTABLISHMENT_OF_REMOTE_PEER)
|
if (START_CONNECTIVITY_ESTABLISHMENT_OF_REMOTE_PEER)
|
||||||
remotePeer.startConnectivityEstablishment();
|
remotePeer.startConnectivityEstablishment();
|
||||||
|
|
||||||
System.out.println("Local audio clist:\n"
|
logger.info("Local audio clist:\n"
|
||||||
+ localAgent.getStream("audio").getCheckList());
|
+ localAgent.getStream("audio").getCheckList());
|
||||||
|
|
||||||
IceMediaStream videoStream = localAgent.getStream("video");
|
IceMediaStream videoStream = localAgent.getStream("video");
|
||||||
|
|
||||||
if(videoStream != null)
|
if(videoStream != null)
|
||||||
System.out.println("Local video clist:\n"
|
logger.info("Local video clist:\n"
|
||||||
+ videoStream.getCheckList());
|
+ videoStream.getCheckList());
|
||||||
|
|
||||||
//Give processing enough time to finish. We'll System.exit() anyway
|
//Give processing enough time to finish. We'll System.exit() anyway
|
||||||
@ -120,11 +127,11 @@ public class Ice
|
|||||||
|
|
||||||
Object iceProcessingState = evt.getNewValue();
|
Object iceProcessingState = evt.getNewValue();
|
||||||
|
|
||||||
System.out.println(
|
logger.info(
|
||||||
"Agent entered the " + iceProcessingState + " state.");
|
"Agent entered the " + iceProcessingState + " state.");
|
||||||
if(iceProcessingState == IceProcessingState.COMPLETED)
|
if(iceProcessingState == IceProcessingState.COMPLETED)
|
||||||
{
|
{
|
||||||
System.out.println(
|
logger.info(
|
||||||
"Total ICE processing time: "
|
"Total ICE processing time: "
|
||||||
+ (processingEndTime - startTime) + "ms");
|
+ (processingEndTime - startTime) + "ms");
|
||||||
Agent agent = (Agent)evt.getSource();
|
Agent agent = (Agent)evt.getSource();
|
||||||
@ -133,26 +140,29 @@ public class Ice
|
|||||||
for(IceMediaStream stream : streams)
|
for(IceMediaStream stream : streams)
|
||||||
{
|
{
|
||||||
String streamName = stream.getName();
|
String streamName = stream.getName();
|
||||||
System.out.println(
|
logger.info(
|
||||||
"Pairs selected for stream: " + streamName);
|
"Pairs selected for stream: " + streamName);
|
||||||
List<Component> components = stream.getComponents();
|
List<Component> components = stream.getComponents();
|
||||||
|
|
||||||
for(Component cmp : components)
|
for(Component cmp : components)
|
||||||
{
|
{
|
||||||
String cmpName = cmp.getName();
|
String cmpName = cmp.getName();
|
||||||
System.out.println(cmpName + ": "
|
logger.info(cmpName + ": "
|
||||||
+ cmp.getSelectedPair());
|
+ cmp.getSelectedPair());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Printing the completed check lists:");
|
logger.info("Printing the completed check lists:");
|
||||||
for(IceMediaStream stream : streams)
|
for(IceMediaStream stream : streams)
|
||||||
{
|
{
|
||||||
String streamName = stream.getName();
|
String streamName = stream.getName();
|
||||||
System.out.println("Check list for stream: " + streamName);
|
logger.info("Check list for stream: " + streamName);
|
||||||
//uncomment for a more verbose output
|
//uncomment for a more verbose output
|
||||||
System.out.println(stream.getCheckList());
|
logger.info(stream.getCheckList().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.info("Total ICE processing time to completion: "
|
||||||
|
+ (System.currentTimeMillis() - startTime));
|
||||||
}
|
}
|
||||||
else if(iceProcessingState == IceProcessingState.TERMINATED
|
else if(iceProcessingState == IceProcessingState.TERMINATED
|
||||||
|| iceProcessingState == IceProcessingState.FAILED)
|
|| iceProcessingState == IceProcessingState.FAILED)
|
||||||
@ -164,6 +174,8 @@ public class Ice
|
|||||||
*/
|
*/
|
||||||
((Agent) evt.getSource()).free();
|
((Agent) evt.getSource()).free();
|
||||||
|
|
||||||
|
logger.info("Total ICE processing time: "
|
||||||
|
+ (System.currentTimeMillis() - startTime));
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -325,7 +337,7 @@ public class Ice
|
|||||||
long endTime = System.currentTimeMillis();
|
long endTime = System.currentTimeMillis();
|
||||||
long total = endTime - startTime;
|
long total = endTime - startTime;
|
||||||
|
|
||||||
System.out.println("Total harvesting time: " + total + "ms.");
|
logger.info("Total harvesting time: " + total + "ms.");
|
||||||
|
|
||||||
return agent;
|
return agent;
|
||||||
}
|
}
|
||||||
@ -361,7 +373,7 @@ public class Ice
|
|||||||
stream, Transport.UDP, rtpPort, rtpPort, rtpPort + 100);
|
stream, Transport.UDP, rtpPort, rtpPort, rtpPort + 100);
|
||||||
|
|
||||||
long endTime = System.currentTimeMillis();
|
long endTime = System.currentTimeMillis();
|
||||||
System.out.println("RTP Component created in "
|
logger.info("RTP Component created in "
|
||||||
+ (endTime - startTime) + " ms");
|
+ (endTime - startTime) + " ms");
|
||||||
startTime = endTime;
|
startTime = endTime;
|
||||||
//rtcpComp
|
//rtcpComp
|
||||||
@ -369,7 +381,7 @@ public class Ice
|
|||||||
stream, Transport.UDP, rtpPort + 1, rtpPort + 1, rtpPort + 101);
|
stream, Transport.UDP, rtpPort + 1, rtpPort + 1, rtpPort + 101);
|
||||||
|
|
||||||
endTime = System.currentTimeMillis();
|
endTime = System.currentTimeMillis();
|
||||||
System.out.println("RTCP Component created in "
|
logger.info("RTCP Component created in "
|
||||||
+ (endTime - startTime) + " ms");
|
+ (endTime - startTime) + " ms");
|
||||||
|
|
||||||
return stream;
|
return stream;
|
||||||
|
|||||||
@ -53,17 +53,19 @@ public class TrickleIce
|
|||||||
//wait a bit so that the logger can stop dumping stuff:
|
//wait a bit so that the logger can stop dumping stuff:
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
|
|
||||||
System.err.println("=================== feed the following"
|
logger.info("=================== feed the following"
|
||||||
+" to the remote agent ===================");
|
+" to the remote agent ===================");
|
||||||
|
|
||||||
|
|
||||||
System.err.println(localSDP);
|
logger.info("\n" + localSDP);
|
||||||
|
|
||||||
System.err.println("======================================"
|
logger.info("======================================"
|
||||||
+ "========================================\n");
|
+ "========================================\n");
|
||||||
|
|
||||||
CandidatePrinter printer = new CandidatePrinter();
|
CandidatePrinter printer = new CandidatePrinter();
|
||||||
printer.agent = localAgent;
|
printer.agent = localAgent;
|
||||||
|
|
||||||
|
|
||||||
localAgent.startCandidateTrickle(printer);
|
localAgent.startCandidateTrickle(printer);
|
||||||
|
|
||||||
|
|
||||||
@ -77,15 +79,15 @@ public class TrickleIce
|
|||||||
allCandidates += component.getLocalCandidateCount();
|
allCandidates += component.getLocalCandidateCount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println("all candidates = " + allCandidates);
|
logger.info("all candidates = " + allCandidates);
|
||||||
|
|
||||||
String sdp = IceDistributed.readSDP();
|
/*String sdp = IceDistributed.readSDP();
|
||||||
|
|
||||||
startTime = System.currentTimeMillis();
|
startTime = System.currentTimeMillis();
|
||||||
SdpUtils.parseSDP(localAgent, sdp);
|
SdpUtils.parseSDP(localAgent, sdp);
|
||||||
|
|
||||||
localAgent.startConnectivityEstablishment();
|
localAgent.startConnectivityEstablishment();
|
||||||
|
*/
|
||||||
|
|
||||||
//Give processing enough time to finish. We'll System.exit() anyway
|
//Give processing enough time to finish. We'll System.exit() anyway
|
||||||
//as soon as localAgent enters a final state.
|
//as soon as localAgent enters a final state.
|
||||||
@ -121,20 +123,21 @@ public class TrickleIce
|
|||||||
|
|
||||||
for(Attribute attribute : update)
|
for(Attribute attribute : update)
|
||||||
{
|
{
|
||||||
System.err.print(attribute);
|
logger.info(attribute.toString().trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(iceCandidates == null)
|
if(iceCandidates == null)
|
||||||
{
|
{
|
||||||
try{Thread.sleep(1000);}catch(Exception e){};
|
try{Thread.sleep(1000);}catch(Exception e){};
|
||||||
|
|
||||||
System.err.println("ICE stats: time="
|
logger.info("ICE stats: time="
|
||||||
+ agent.getTotalHarvestingTime() + "ms");
|
+ agent.getTotalHarvestingTime() + "ms");
|
||||||
|
|
||||||
//print statistics
|
//print statistics
|
||||||
for (CandidateHarvester harvester : agent.getHarvesters())
|
for (CandidateHarvester harvester : agent.getHarvesters())
|
||||||
{
|
{
|
||||||
System.err.println(harvester.getHarvestStatistics());
|
logger.info(
|
||||||
|
harvester.getHarvestStatistics().toString().trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
60
test/test/signalling/Signalling.java
Normal file
60
test/test/signalling/Signalling.java
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* ice4j, the OpenSource Java Solution for NAT and Firewall Traversal.
|
||||||
|
* Maintained by the Jitsi community (https://jitsi.org).
|
||||||
|
*
|
||||||
|
* Distributable under LGPL license.
|
||||||
|
* See terms of license at gnu.org.
|
||||||
|
*/
|
||||||
|
package test.signalling;
|
||||||
|
|
||||||
|
import java.net.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple signalling utility that we use for ICE tests.
|
||||||
|
*
|
||||||
|
* @author Emil Ivov
|
||||||
|
*/
|
||||||
|
public class Signalling
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The socket where we send and receive signalling
|
||||||
|
*/
|
||||||
|
private Socket signallingSocket = null;
|
||||||
|
|
||||||
|
private SignallingCallback signallingCallback = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a signalling instance over the specified socket.
|
||||||
|
*
|
||||||
|
* @param socket the socket that this instance should use for signalling
|
||||||
|
*/
|
||||||
|
public Signalling(Socket socket, SignallingCallback signallingCallback)
|
||||||
|
{
|
||||||
|
this.signallingSocket = socket;
|
||||||
|
this.signallingCallback = signallingCallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a server signalling object. The method will block until a
|
||||||
|
* connection is actually received on
|
||||||
|
*
|
||||||
|
* @param socketAddress our bind address
|
||||||
|
* @param signallingCallback the callback that we will deliver signalling
|
||||||
|
* to.
|
||||||
|
*
|
||||||
|
* @return the newly created Signalling object
|
||||||
|
*
|
||||||
|
* @throws Throwable if anything goes wrong (which could happen with the
|
||||||
|
* socket stuff).
|
||||||
|
*/
|
||||||
|
public static Signalling createServerSignalling(
|
||||||
|
InetSocketAddress socketAddress,
|
||||||
|
SignallingCallback signallingCallback)
|
||||||
|
throws Throwable
|
||||||
|
{
|
||||||
|
ServerSocket serverSocket = new ServerSocket(socketAddress);
|
||||||
|
|
||||||
|
Signalling signalling = new Signalling(socketAddress, signallingCallback);
|
||||||
|
}
|
||||||
|
}
|
||||||
24
test/test/signalling/SignallingCallback.java
Normal file
24
test/test/signalling/SignallingCallback.java
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* ice4j, the OpenSource Java Solution for NAT and Firewall Traversal.
|
||||||
|
* Maintained by the Jitsi community (https://jitsi.org).
|
||||||
|
*
|
||||||
|
* Distributable under LGPL license.
|
||||||
|
* See terms of license at gnu.org.
|
||||||
|
*/
|
||||||
|
package test.signalling;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple signalling callback interface where we deliever newly received
|
||||||
|
* signalling from the {@link Signalling}
|
||||||
|
*
|
||||||
|
* @author Emil Ivov
|
||||||
|
*/
|
||||||
|
public interface SignallingCallback
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Processes the specified signalling string
|
||||||
|
*
|
||||||
|
* @param signalling the signalling string to process
|
||||||
|
*/
|
||||||
|
public void onSignalling(String signalling);
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user