Changeset 151:39c0ce77b49c in mediastreamer2


Ignore:
Timestamp:
Nov 3, 2008 4:11:21 PM (5 years ago)
Author:
jehan <jehan@…>
Branch:
default
Message:

add stun client to UserInstance? tester

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@154 3f6dc0c8-ddfe-455d-9043-3cd528dc4637

Location:
p2pproxy
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • p2pproxy/src/org/linphone/p2pproxy/core/P2pProxyMain.java

    r110 r151  
    477477   }  
    478478} 
     479 
    479480public static String[] lookupSipProxiesUri(String aDomaine) { 
    480481           try { 
     
    486487        } 
    487488 
     489public static String[] lookupMediaServerAddress(String aDomaine) { 
     490   try { 
     491      isReady(); 
     492      return mP2pProxyManagement.getMediaServerList(); 
     493   } catch (Exception e) { 
     494      return null; 
     495   }  
     496} 
     497 
    488498public static int getState() { 
    489499   try { 
  • p2pproxy/src/org/linphone/p2pproxy/core/stun/StunClient.java

    r92 r151  
    5252   private int SO_TIME_OUT = 300; 
    5353    
     54   public StunClient(String[] aStunServerList) { 
     55      List<InetSocketAddress> lAddressList = new ArrayList<InetSocketAddress>(); 
     56      for (String lStunInstance:aStunServerList) { 
     57         URI lUri = URI.create(lStunInstance); 
     58         InetSocketAddress lInetSocketAddress = new InetSocketAddress(lUri.getHost(),lUri.getPort()); 
     59         lAddressList.add(lInetSocketAddress); 
     60      } 
     61      mStunServerList = lAddressList; 
     62   } 
    5463   StunClient(List<InetSocketAddress> aStunServerList) { 
    5564      mStunServerList = aStunServerList; 
  • p2pproxy/test-src/org/linphone/p2pproxy/test/utils/UserInstance.java

    r126 r151  
    3232import org.linphone.p2pproxy.api.P2pProxyResourceManagement; 
    3333import org.linphone.p2pproxy.core.P2pProxyMain; 
     34import org.linphone.p2pproxy.core.stun.StunClient; 
    3435import org.linphone.p2pproxy.launcher.P2pProxylauncherConstants; 
    3536import org.zoolu.net.SocketAddress; 
     
    4243private final SipProvider mProvider; 
    4344private final SipClient mSipClient; 
     45private  StunClient mStunClient; 
    4446private final int REGISTRATION_PERIOD=60; 
    4547private final static Logger mLog = Logger.getLogger(UserInstance.class); 
     
    8082    mProvider=new SipProvider(null,lSipPort); 
    8183        mSipClient = new SipClient(mProvider,userName,30000); 
     84         
    8285         class RegistrarTimerTask extends  TimerTask { 
    8386                @Override 
     
    103106                        mProvider.setOutboundProxy(new SocketAddress(lProxyUri.getRawSchemeSpecificPart())); 
    104107                        mLog.info("use outband proxy ["+mProvider.getOutboundProxy()+"]"); 
     108                        //3 setup stun client 
     109                         
     110                        String [] lMediaServer = P2pProxyMain.lookupMediaServerAddress(P2pProxyResourceManagement.DOMAINE); 
     111                        mStunClient =  new StunClient(lMediaServer); 
    105112                        mSipClient.register(REGISTRATION_PERIOD,userName); 
    106113                        mIsRegistered = true; 
     
    113120                 
    114121        }; 
    115         mTimer.schedule(new  RegistrarTimerTask(), REGISTRATION_PERIOD-REGISTRATION_PERIOD/10); 
     122        mTimer.schedule(new  RegistrarTimerTask(), 0); 
    116123        mSipClient.listen(); 
    117124        } catch (Exception e) { 
     
    124131public static void main(String[] args) throws P2pProxyException { 
    125132        String lFrom=null, lTo=null, lPreferedProxyUri=null; 
    126         int lDuration = 10, lLoop=0; 
     133        int lDuration = 10000, lLoop=0; 
    127134        for (int i=0; i < args.length; i=i+2) {   
    128135                   String argument = args[i]; 
     
    158165           System.exit(1); 
    159166   } 
    160    if (lTo == null) { 
     167   if (lLoop != 0 && lTo == null) { 
    161168           System.out.println("missing -to "); 
    162169           usage(); 
Note: See TracChangeset for help on using the changeset viewer.