Adds support for generations

This commit is contained in:
emcho 2010-09-28 11:26:00 +00:00
parent 5f4c05d699
commit a10d5e6687
3 changed files with 57 additions and 7 deletions

View File

@ -201,7 +201,16 @@ public class Agent
private TerminationThread terminationThread; private TerminationThread terminationThread;
/** /**
* Initializes an empty <tt>Agent</tt> 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 <tt>Agent</tt> with no streams, and no address
*/ */
public Agent() public Agent()
{ {
@ -1435,4 +1444,28 @@ public class Agent
setState(terminationState); 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;
}
} }

View File

@ -294,4 +294,20 @@ public class StunCandidateHarvester
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
} }
/**
* Returns a <tt>String</tt> representation of this harvester containing its
* type and server address.
*
* @return a <tt>String</tt> 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;
}
} }

View File

@ -279,8 +279,9 @@ public class Ice
new TransportAddress(hostname, port, Transport.UDP), new TransportAddress(hostname, port, Transport.UDP),
longTermCredential)); longTermCredential));
//STREAMS
createStream(rtpPort, "audio", agent); createStream(rtpPort, "audio", agent);
// createStream(rtpPort + 2, "video", agent); createStream(rtpPort + 2, "video", agent);
return agent; return agent;
} }
@ -320,12 +321,12 @@ public class Ice
+ (endTime - startTime) +" ms"); + (endTime - startTime) +" ms");
startTime = endTime; startTime = endTime;
//rtcpComp //rtcpComp
// agent.createComponent( agent.createComponent(
// 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 " System.out.println("RTCP Component created in "
// + (endTime - startTime) +" ms"); + (endTime - startTime) +" ms");
return stream; return stream;
} }