From a10d5e668765cd4f98b4e22ed60de02ad2231f8c Mon Sep 17 00:00:00 2001 From: emcho Date: Tue, 28 Sep 2010 11:26:00 +0000 Subject: [PATCH] Adds support for generations --- src/org/ice4j/ice/Agent.java | 35 ++++++++++++++++++- .../ice/harvest/StunCandidateHarvester.java | 16 +++++++++ test/test/Ice.java | 13 +++---- 3 files changed, 57 insertions(+), 7 deletions(-) diff --git a/src/org/ice4j/ice/Agent.java b/src/org/ice4j/ice/Agent.java index 2bd821b..485b81e 100644 --- a/src/org/ice4j/ice/Agent.java +++ b/src/org/ice4j/ice/Agent.java @@ -201,7 +201,16 @@ public class Agent private TerminationThread terminationThread; /** - * Initializes an empty Agent with no streams, and no address. + * Some protocols, such as XMPP, need to be able to distinguish the separate + * ICE sessions that occur as a result of ICE restarts, which is why we need + * to keep track of generations. A generation is an index, starting at 0, + * that enables the parties to keep track of updates to the candidate + * throughout the life of the session. + */ + private int generation = 0; + + /** + * Creates an empty Agent with no streams, and no address */ public Agent() { @@ -1435,4 +1444,28 @@ public class Agent setState(terminationState); } + + /** + * Returns the current generation of this ICE Agent. A generation is an + * index, starting at 0, that enables the parties to keep track of updates + * to the candidate throughout the life of the session. + * + * @return the current generation of this ICE Agent + */ + public int getGeneration() + { + return generation; + } + + /** + * Specifies the current generation of this ICE Agent. A generation is an + * index, starting at 0, that enables the parties to keep track of updates + * to the candidate throughout the life of the session. + * + * @param generation the current generation of this ICE Agent + */ + public void setGeneration(int generation) + { + this.generation = generation; + } } diff --git a/src/org/ice4j/ice/harvest/StunCandidateHarvester.java b/src/org/ice4j/ice/harvest/StunCandidateHarvester.java index d220fd4..d07be01 100644 --- a/src/org/ice4j/ice/harvest/StunCandidateHarvester.java +++ b/src/org/ice4j/ice/harvest/StunCandidateHarvester.java @@ -294,4 +294,20 @@ public class StunCandidateHarvester Thread.currentThread().interrupt(); } } + + /** + * Returns a String representation of this harvester containing its + * type and server address. + * + * @return a String representation of this harvester containing its + * type and server address. + */ + @Override + public String toString() + { + String proto = (this instanceof TurnCandidateHarvester) + ? "TURN" + : "STUN"; + return proto + " harvester for srvr: " + this.stunServer; + } } diff --git a/test/test/Ice.java b/test/test/Ice.java index 1c638cb..a4cd617 100644 --- a/test/test/Ice.java +++ b/test/test/Ice.java @@ -279,8 +279,9 @@ public class Ice new TransportAddress(hostname, port, Transport.UDP), longTermCredential)); + //STREAMS createStream(rtpPort, "audio", agent); -// createStream(rtpPort + 2, "video", agent); + createStream(rtpPort + 2, "video", agent); return agent; } @@ -320,12 +321,12 @@ public class Ice + (endTime - startTime) +" ms"); startTime = endTime; //rtcpComp -// agent.createComponent( -// stream, Transport.UDP, rtpPort + 1, rtpPort + 1, rtpPort + 101); + agent.createComponent( + stream, Transport.UDP, rtpPort + 1, rtpPort + 1, rtpPort + 101); -// endTime = System.currentTimeMillis(); -// System.out.println("RTCP Component created in " -// + (endTime - startTime) +" ms"); + endTime = System.currentTimeMillis(); + System.out.println("RTCP Component created in " + + (endTime - startTime) +" ms"); return stream; }