org.lastbamboo.common.ice
Class IceAgentImpl

java.lang.Object
  extended by org.lastbamboo.common.ice.IceAgentImpl
All Implemented Interfaces:
IceAgent, IceOfferAnswer, org.lastbamboo.common.offer.answer.OfferAnswer

public class IceAgentImpl
extends Object
implements IceAgent

Implementation of an ICE agent. An agent can contain multiple media streams and manages the top level of an ICE exchange.


Constructor Summary
IceAgentImpl(IceMediaStreamFactory mediaStreamFactory, boolean controlling, org.lastbamboo.common.offer.answer.OfferAnswerListener offerAnswerListener, UdpSocketFactory udpSocketFactory, UdpSocketFactory unreliableUdpSocketFactory, org.lastbamboo.common.offer.answer.IceMediaStreamDesc iceMediaStreamDesc)
          Creates a new ICE agent for an answerer.
 
Method Summary
 long calculateDelay(int Ta_i)
          Calculates the delay in milliseconds to use before initiating a new transaction for a given media stream.
 void checkValidPairsForAllComponents(IceMediaStream mediaStream)
          Notifies the listener that the media stream may have valid pairs for all components of a given media stream, possibly requiring changing states of other streams, as specified in part 2 of ICE section 7.1.2.2.3.
 void close()
           
 void closeTcp()
           
 void closeUdp()
           
 Collection<? extends IceCandidate> gatherCandidates()
          Gathers candidates for this specific offer/answer implementation.
 byte[] generateAnswer()
           
 byte[] generateOffer()
           
 IceState getIceState()
          Accessor for the overall state of ICE processing.
 Collection<IceMediaStream> getMediaStreams()
          Accessor for all the media streams for the agent.
 Queue<IceCandidatePair> getNominatedPairs()
          Accessor for the nominated pairs.
 InetAddress getPublicAdress()
           
 IceTieBreaker getTieBreaker()
          Accessor for the role conflict tie-breaker for this agent.
 boolean isClosed()
          Whether or not the check list is closed.
 boolean isControlling()
          Returns whether or not this agent is the controlling agent.
 void onNominatedPair(IceCandidatePair pair, IceMediaStream mediaStream)
          Indicates a pair has been nominated.
 void onNoMorePairs()
          Called when there are no more pairs to process.
 void onUnfreezeCheckLists(IceMediaStream mediaStream)
          Tells the listener to unfreeze any other check lists.
 void onValidPairs(IceMediaStream mediaStream)
          Tells the agent to consider the valid pairs for this media stream for nomination.
 void processAnswer(org.littleshoot.mina.common.ByteBuffer answer)
           
 void processOffer(org.littleshoot.mina.common.ByteBuffer offer)
           
 void recomputePairPriorities()
          Recomputes the priorities of pairs in checklists.
 void setControlling(boolean controlling)
          Sets whether or not this agent is the controlling agent.
 void useRelay()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IceAgentImpl

public IceAgentImpl(IceMediaStreamFactory mediaStreamFactory,
                    boolean controlling,
                    org.lastbamboo.common.offer.answer.OfferAnswerListener offerAnswerListener,
                    UdpSocketFactory udpSocketFactory,
                    UdpSocketFactory unreliableUdpSocketFactory,
                    org.lastbamboo.common.offer.answer.IceMediaStreamDesc iceMediaStreamDesc)
             throws IceUdpConnectException
Creates a new ICE agent for an answerer. Passes the offer in the constructor.

Parameters:
mediaStreamFactory - Factory for creating the media streams we're using ICE to establish.
controlling - Whether or not agent will start out as controlling.
Throws:
IceUdpConnectException - If there's an error connecting the ICE UDP peer.
Method Detail

checkValidPairsForAllComponents

public void checkValidPairsForAllComponents(IceMediaStream mediaStream)
Description copied from interface: IceAgent
Notifies the listener that the media stream may have valid pairs for all components of a given media stream, possibly requiring changing states of other streams, as specified in part 2 of ICE section 7.1.2.2.3. "Updating Pair States".

Specified by:
checkValidPairsForAllComponents in interface IceAgent
Parameters:
mediaStream - The media stream.

onUnfreezeCheckLists

public void onUnfreezeCheckLists(IceMediaStream mediaStream)
Description copied from interface: IceAgent
Tells the listener to unfreeze any other check lists.

Specified by:
onUnfreezeCheckLists in interface IceAgent
Parameters:
mediaStream - The media stream initiating the unfreeze operation.

calculateDelay

public long calculateDelay(int Ta_i)
Description copied from interface: IceAgent
Calculates the delay in milliseconds to use before initiating a new transaction for a given media stream. The agent handles this because the number of outstanding media streams is taken into account when calculating the delay, and only the agent has that information.

Specified by:
calculateDelay in interface IceAgent
Parameters:
Ta_i - The transaction delay for the specific media stream.
Returns:
The transaction delay to use based on a formula taking into account the number of active media streams.

isControlling

public boolean isControlling()
Description copied from interface: IceAgent
Returns whether or not this agent is the controlling agent.

Specified by:
isControlling in interface IceAgent
Returns:
true if this agent is the controlling agent, otherwise false.

setControlling

public void setControlling(boolean controlling)
Description copied from interface: IceAgent
Sets whether or not this agent is the controlling agent.

Specified by:
setControlling in interface IceAgent
Parameters:
controlling - Whether or not this agent is the controlling agent.

recomputePairPriorities

public void recomputePairPriorities()
Description copied from interface: IceAgent
Recomputes the priorities of pairs in checklists. This can happen, for example, if our role has changed from controlling to controlled or vice versa.

Specified by:
recomputePairPriorities in interface IceAgent

getTieBreaker

public IceTieBreaker getTieBreaker()
Description copied from interface: IceAgent
Accessor for the role conflict tie-breaker for this agent.

Specified by:
getTieBreaker in interface IceAgent
Returns:
The role conflict tie-breaker for this agent.

generateAnswer

public byte[] generateAnswer()
Specified by:
generateAnswer in interface org.lastbamboo.common.offer.answer.OfferAnswer

generateOffer

public byte[] generateOffer()
Specified by:
generateOffer in interface org.lastbamboo.common.offer.answer.OfferAnswer

processOffer

public void processOffer(org.littleshoot.mina.common.ByteBuffer offer)
Specified by:
processOffer in interface org.lastbamboo.common.offer.answer.OfferAnswer

processAnswer

public void processAnswer(org.littleshoot.mina.common.ByteBuffer answer)
Specified by:
processAnswer in interface org.lastbamboo.common.offer.answer.OfferAnswer

getMediaStreams

public Collection<IceMediaStream> getMediaStreams()
Description copied from interface: IceAgent
Accessor for all the media streams for the agent.

Specified by:
getMediaStreams in interface IceAgent
Returns:
The media streams for the agent.

onNominatedPair

public void onNominatedPair(IceCandidatePair pair,
                            IceMediaStream mediaStream)
Description copied from interface: IceAgent
Indicates a pair has been nominated. The agent needs to update checks and pair states accordingly and likely to begin transmitting media.

Specified by:
onNominatedPair in interface IceAgent
Parameters:
pair - The nominated pair.
mediaStream - The ICE media stream the pair is a part of.

getIceState

public IceState getIceState()
Description copied from interface: IceAgent
Accessor for the overall state of ICE processing.

Specified by:
getIceState in interface IceAgent
Returns:
The overall state of ICE processing for all media streams.

getNominatedPairs

public Queue<IceCandidatePair> getNominatedPairs()
Description copied from interface: IceAgent
Accessor for the nominated pairs. TODO: We only currently support the single media stream. This method would have to change for multiple streams.

Specified by:
getNominatedPairs in interface IceAgent
Returns:
The Queue of nominated IceCandidatePairs.

onValidPairs

public void onValidPairs(IceMediaStream mediaStream)
Description copied from interface: IceAgent
Tells the agent to consider the valid pairs for this media stream for nomination.

Specified by:
onValidPairs in interface IceAgent
Parameters:
mediaStream - The media stream the pair is valid for.

close

public void close()
Specified by:
close in interface org.lastbamboo.common.offer.answer.OfferAnswer

onNoMorePairs

public void onNoMorePairs()
Description copied from interface: IceAgent
Called when there are no more pairs to process.

Specified by:
onNoMorePairs in interface IceAgent

closeTcp

public void closeTcp()
Specified by:
closeTcp in interface org.lastbamboo.common.offer.answer.OfferAnswer

closeUdp

public void closeUdp()
Specified by:
closeUdp in interface org.lastbamboo.common.offer.answer.OfferAnswer

gatherCandidates

public Collection<? extends IceCandidate> gatherCandidates()
Description copied from interface: IceOfferAnswer
Gathers candidates for this specific offer/answer implementation.

Specified by:
gatherCandidates in interface IceOfferAnswer
Returns:
The collection of IceCandidates.

getPublicAdress

public InetAddress getPublicAdress()

useRelay

public void useRelay()
Specified by:
useRelay in interface org.lastbamboo.common.offer.answer.OfferAnswer

isClosed

public boolean isClosed()
Description copied from interface: IceAgent
Whether or not the check list is closed.

Specified by:
isClosed in interface IceAgent
Returns:
Whether or not the check list is closed.


Copyright © 2013 LittleShoot. All Rights Reserved.