[ice4j] r160 committed - Starts work on supporting triggered checks and peer-reflexive candidat...

ice4j at googlecode.com ice4j at googlecode.com
Thu Apr 29 00:43:50 CEST 2010


Revision: 160
Author: emcho at sip-communicator.org
Date: Wed Apr 28 15:31:18 2010
Log: Starts work on supporting triggered checks and peer-reflexive  
candidate discovery
http://code.google.com/p/ice4j/source/detail?r=160

Modified:
  /trunk/src/org/ice4j/ice/Agent.java
  /trunk/src/org/ice4j/ice/FoundationsRegistry.java
  /trunk/src/org/ice4j/ice/checks/ConnectivityCheckServer.java
  /trunk/test/test/Ice.java

=======================================
--- /trunk/src/org/ice4j/ice/Agent.java	Wed Apr 28 15:30:53 2010
+++ /trunk/src/org/ice4j/ice/Agent.java	Wed Apr 28 15:31:18 2010
@@ -30,7 +30,7 @@
   * @author Emil Ivov
   */
  public class Agent
-    implements RemoteAddressHandler
+    implements IncomingCheckProcessor
  {
      /**
       * Our class logger.
@@ -90,8 +90,13 @@
       * addresses in here are actually peer-reflexive or not, and schedule
       * the necessary triggered checks.
       */
-    private final List<RemoteCandidate> preDiscoveredRemoteCandidatesQueue
-        = new Vector<RemoteCandidate>();
+    private final List<CandidatePair> preDiscoveredPairsQueue
+        = new Vector<CandidatePair>();
+
+    /**
+     * The lock that we use while starting connectivity establishment.
+     */
+    private final Object startLock = new Object();

      /**
       * The user fragment that we should use for the ice-ufrag attribute.
@@ -289,7 +294,7 @@
       */
      public void startConnectivityEstablishment()
      {
-        synchronized(this)
+        synchronized(startLock)
          {
              initCheckLists();

@@ -327,11 +332,7 @@
       */
      public boolean isStarted()
      {
-        synchronized(this)
-        {
-            return iceStarted;
-        }
-
+        return iceStarted;
      }

      /**
@@ -665,9 +666,9 @@
      {
          Collection<IceMediaStream> streamsCollection =  
mediaStreams.values();

-        for( IceMediaStream cmp : streamsCollection)
-        {
-            LocalCandidate cnd = cmp.findLocalCandidate(localAddress);
+        for( IceMediaStream stream : streamsCollection)
+        {
+            LocalCandidate cnd = stream.findLocalCandidate(localAddress);

              if(cnd != null)
                  return cnd;
@@ -692,29 +693,50 @@
       * we decide to send a check to <tt>remoteAddress</tt>.
       *
       */
-    public void handleRemoteAddress(TransportAddress remoteAddress,
-                                    TransportAddress localAddress,
-                                    long             priority,
-                                    String           remoteUFrag)
-    {
-        this.createMediaStream(null).createComponent(null).
-
-        if(iceStarted)
-        {
-            /*
-            if remoteAddress is not known
-            {
-                create peer reflexive candidate
-            }
-
-            schedule triggered check
-            */
-        }
-        else
-        {
-            RemoteCandidate remoteCand = new RemoteCandidate(
-                remoteAddres, );
-        }
+    public void incomingCheckReceived(TransportAddress remoteAddress,
+                                      TransportAddress localAddress,
+                                      long             priority,
+                                      String           remoteUFrag)
+    {
+        LocalCandidate localCandidate = findLocalCandidate(localAddress);
+        Component parentComponent = localCandidate.getParentComponent();
+
+        RemoteCandidate remoteCandidate = new RemoteCandidate(
+            remoteAddress, parentComponent,
+            CandidateType.PEER_REFLEXIVE_CANDIDATE,
+             
foundationsRegistry.obtainFoundationForPeerReflexiveCandidate(),
+            priority);
+
+        CandidatePair triggeredPair
+            = new CandidatePair(localCandidate, remoteCandidate);
+
+        synchronized(startLock)
+        {
+            if(isStarted())
+            {
+                //we are started, which means we have the remote candidates
+                //so it's now safe to go and see whether this is a new PR  
cand.
+                triggerCheck(triggeredPair);
+            }
+            else
+            {
+                //we are not started yet so we'd better wait until we get  
the
+                //remote candidates incase we are holding to a new PR one.
+                this.preDiscoveredPairsQueue.add(triggeredPair);
+            }
+        }
+    }
+
+    /**
+     * Either queues a triggered check for <tt>triggeredPair</tt> or, in  
case
+     * there's already a pair with the specified remote and local  
addresses,
+     * puts it in the queue instead.
+     *
+     * @param triggeredPair the pair containing the local and remote  
candidate
+     * that we'd need to trigger a check for.
+     */
+    private void triggerCheck(CandidatePair triggeredPair)
+    {

      }
  }
=======================================
--- /trunk/src/org/ice4j/ice/FoundationsRegistry.java	Wed Jan 27 10:17:20  
2010
+++ /trunk/src/org/ice4j/ice/FoundationsRegistry.java	Wed Apr 28 15:31:18  
2010
@@ -22,6 +22,12 @@
       */
      private int lastAssignedFoundation = 0;

+    /**
+     * The foundation number that was last assigned to a PEER-REFLEXIVE
+     * <tt>RemoteCandidate</tt>
+     */
+    private int lastAssignedRemoteFoundation = 10000;
+
      /**
       * Contains mappings between a type+baseIP+server+transport
       * <tt>String</tt>s and the foundation that has been assigned to them.
@@ -30,8 +36,8 @@

      /**
       * Assigns to <tt>candidate</tt> the foundation that corresponds to its
-     * bas type and transport properties or a new one if no foundation has  
been
-     * generated yet for the specific combination.
+     * base, type and transport properties or a new one if no foundation  
has
+     * been generated yet for the specific combination.
       *
       * @param candidate the <tt>Candidate</tt> that we'd like to assign a
       * foundation to.
@@ -78,6 +84,18 @@

          candidate.setFoundation(foundationValue);
      }
+
+    /**
+     * Returns an (as far as you care) random foundation that could be  
assigned
+     * to a learned PEER-REFLEXIVE candidate.
+     *
+     * @return  a foundation <tt>String</tt> that could be assigned to a
+     * learned PEER-REFLEXIVE candidate.
+     */
+    public String obtainFoundationForPeerReflexiveCandidate()
+    {
+        return Integer.toString(lastAssignedRemoteFoundation++);
+    }

      /**
       * Returns the number of foundation <tt>String</tt>s that are currently
=======================================
--- /trunk/src/org/ice4j/ice/checks/ConnectivityCheckServer.java	Wed Apr 28  
15:30:42 2010
+++ /trunk/src/org/ice4j/ice/checks/ConnectivityCheckServer.java	Wed Apr 28  
15:31:18 2010
@@ -34,10 +34,10 @@
      private final Agent parentAgent;

      /**
-     * The {@link RemoteAddressHandler} that we should notify when we  
notice
+     * The {@link IncomingCheckProcessor} that we should notify when we  
notice
       * new remote transport addresses.
       */
-    private final RemoteAddressHandler addressHandler;
+    private final IncomingCheckProcessor addressHandler;

      /**
       * The stun stack that we will use for connectivity checks.
@@ -53,7 +53,7 @@
       * @param addressHandler the handler that
       */
      public ConnectivityCheckServer(Agent                parentAgent,
-                                   RemoteAddressHandler addressHandler)
+                                   IncomingCheckProcessor addressHandler)
      {
          this.parentAgent = parentAgent;
          this.addressHandler = addressHandler;
@@ -102,7 +102,7 @@
          long priority = priorityAttr.getPriority();

          //tell our address handler we saw a new remote address;
-        addressHandler.handleRemoteAddress(evt.getRemoteAddress(),
+        addressHandler.incomingCheckReceived(evt.getRemoteAddress(),
                                           evt.getLocalAddress(),
                                           priority, remoteUfrag);

=======================================
--- /trunk/test/test/Ice.java	Mon Apr 26 14:33:01 2010
+++ /trunk/test/test/Ice.java	Wed Apr 28 15:31:18 2010
@@ -51,7 +51,7 @@
                          + (endTime - startTime) + "ms");
          System.out.println("LocalAgent:\n" + localAgent);

-        localAgent.startChecks();
+        localAgent.startConnectivityEstablishment();

          System.out.println("Local audio clist:\n"
                          + localAgent.getStream("audio").getCheckList());

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe at sip-communicator.dev.java.net
For additional commands, e-mail: commits-help at sip-communicator.dev.java.net





More information about the commits mailing list