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)
|
||||
{
|
||||
/* add Mapped address */
|
||||
/* add Mapped address and remove the XOR_MAPPED_ADDRESS one*/
|
||||
Attribute mappedAddressAttribute =
|
||||
AttributeFactory.createMappedAddressAttribute(
|
||||
evt.getRemoteAddress());
|
||||
|
||||
@ -9,6 +9,7 @@ package test;
|
||||
|
||||
import java.beans.*;
|
||||
import java.util.*;
|
||||
import java.util.logging.*;
|
||||
|
||||
import org.ice4j.*;
|
||||
import org.ice4j.ice.*;
|
||||
@ -24,6 +25,12 @@ import org.ice4j.security.*;
|
||||
*/
|
||||
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.
|
||||
@ -49,10 +56,10 @@ public class Ice
|
||||
{
|
||||
startTime = System.currentTimeMillis();
|
||||
|
||||
Agent localAgent = createAgent(9090);
|
||||
Agent localAgent = createAgent(9090, false);
|
||||
localAgent.setNominationStrategy(
|
||||
NominationStrategy.NOMINATE_HIGHEST_PRIO);
|
||||
Agent remotePeer = createAgent(6060);
|
||||
Agent remotePeer = createAgent(6060, false);
|
||||
|
||||
localAgent.addStateChangeListener(new IceProcessingListener());
|
||||
|
||||
@ -78,22 +85,22 @@ public class Ice
|
||||
stream.setRemotePassword(localAgent.getLocalPassword());
|
||||
}
|
||||
|
||||
System.out.println("Total candidate gathering time: "
|
||||
logger.info("Total candidate gathering time: "
|
||||
+ (endTime - startTime) + "ms");
|
||||
System.out.println("LocalAgent:\n" + localAgent);
|
||||
logger.info("LocalAgent:\n" + localAgent);
|
||||
|
||||
localAgent.startConnectivityEstablishment();
|
||||
|
||||
if (START_CONNECTIVITY_ESTABLISHMENT_OF_REMOTE_PEER)
|
||||
remotePeer.startConnectivityEstablishment();
|
||||
|
||||
System.out.println("Local audio clist:\n"
|
||||
logger.info("Local audio clist:\n"
|
||||
+ localAgent.getStream("audio").getCheckList());
|
||||
|
||||
IceMediaStream videoStream = localAgent.getStream("video");
|
||||
|
||||
if(videoStream != null)
|
||||
System.out.println("Local video clist:\n"
|
||||
logger.info("Local video clist:\n"
|
||||
+ videoStream.getCheckList());
|
||||
|
||||
//Give processing enough time to finish. We'll System.exit() anyway
|
||||
@ -120,11 +127,11 @@ public class Ice
|
||||
|
||||
Object iceProcessingState = evt.getNewValue();
|
||||
|
||||
System.out.println(
|
||||
logger.info(
|
||||
"Agent entered the " + iceProcessingState + " state.");
|
||||
if(iceProcessingState == IceProcessingState.COMPLETED)
|
||||
{
|
||||
System.out.println(
|
||||
logger.info(
|
||||
"Total ICE processing time: "
|
||||
+ (processingEndTime - startTime) + "ms");
|
||||
Agent agent = (Agent)evt.getSource();
|
||||
@ -133,26 +140,29 @@ public class Ice
|
||||
for(IceMediaStream stream : streams)
|
||||
{
|
||||
String streamName = stream.getName();
|
||||
System.out.println(
|
||||
logger.info(
|
||||
"Pairs selected for stream: " + streamName);
|
||||
List<Component> components = stream.getComponents();
|
||||
|
||||
for(Component cmp : components)
|
||||
{
|
||||
String cmpName = cmp.getName();
|
||||
System.out.println(cmpName + ": "
|
||||
logger.info(cmpName + ": "
|
||||
+ cmp.getSelectedPair());
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Printing the completed check lists:");
|
||||
logger.info("Printing the completed check lists:");
|
||||
for(IceMediaStream stream : streams)
|
||||
{
|
||||
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
|
||||
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
|
||||
|| iceProcessingState == IceProcessingState.FAILED)
|
||||
@ -164,6 +174,8 @@ public class Ice
|
||||
*/
|
||||
((Agent) evt.getSource()).free();
|
||||
|
||||
logger.info("Total ICE processing time: "
|
||||
+ (System.currentTimeMillis() - startTime));
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
@ -325,7 +337,7 @@ public class Ice
|
||||
long endTime = System.currentTimeMillis();
|
||||
long total = endTime - startTime;
|
||||
|
||||
System.out.println("Total harvesting time: " + total + "ms.");
|
||||
logger.info("Total harvesting time: " + total + "ms.");
|
||||
|
||||
return agent;
|
||||
}
|
||||
@ -361,16 +373,16 @@ public class Ice
|
||||
stream, Transport.UDP, rtpPort, rtpPort, rtpPort + 100);
|
||||
|
||||
long endTime = System.currentTimeMillis();
|
||||
System.out.println("RTP Component created in "
|
||||
+ (endTime - startTime) +" ms");
|
||||
logger.info("RTP Component created in "
|
||||
+ (endTime - startTime) + " ms");
|
||||
startTime = endTime;
|
||||
//rtcpComp
|
||||
agent.createComponent(
|
||||
stream, Transport.UDP, rtpPort + 1, rtpPort + 1, rtpPort + 101);
|
||||
|
||||
endTime = System.currentTimeMillis();
|
||||
System.out.println("RTCP Component created in "
|
||||
+ (endTime - startTime) +" ms");
|
||||
logger.info("RTCP Component created in "
|
||||
+ (endTime - startTime) + " ms");
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
@ -53,17 +53,19 @@ public class TrickleIce
|
||||
//wait a bit so that the logger can stop dumping stuff:
|
||||
Thread.sleep(500);
|
||||
|
||||
System.err.println("=================== feed the following"
|
||||
logger.info("=================== feed the following"
|
||||
+" to the remote agent ===================");
|
||||
|
||||
|
||||
System.err.println(localSDP);
|
||||
logger.info("\n" + localSDP);
|
||||
|
||||
System.err.println("======================================"
|
||||
logger.info("======================================"
|
||||
+ "========================================\n");
|
||||
|
||||
CandidatePrinter printer = new CandidatePrinter();
|
||||
printer.agent = localAgent;
|
||||
|
||||
|
||||
localAgent.startCandidateTrickle(printer);
|
||||
|
||||
|
||||
@ -77,15 +79,15 @@ public class TrickleIce
|
||||
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();
|
||||
SdpUtils.parseSDP(localAgent, sdp);
|
||||
|
||||
localAgent.startConnectivityEstablishment();
|
||||
|
||||
*/
|
||||
|
||||
//Give processing enough time to finish. We'll System.exit() anyway
|
||||
//as soon as localAgent enters a final state.
|
||||
@ -121,20 +123,21 @@ public class TrickleIce
|
||||
|
||||
for(Attribute attribute : update)
|
||||
{
|
||||
System.err.print(attribute);
|
||||
logger.info(attribute.toString().trim());
|
||||
}
|
||||
|
||||
if(iceCandidates == null)
|
||||
{
|
||||
try{Thread.sleep(1000);}catch(Exception e){};
|
||||
|
||||
System.err.println("ICE stats: time="
|
||||
logger.info("ICE stats: time="
|
||||
+ agent.getTotalHarvestingTime() + "ms");
|
||||
|
||||
//print statistics
|
||||
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