Commit d2aba132 authored by jehan's avatar jehan

prepare stun server

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@87 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
parent a744f3de
......@@ -36,7 +36,7 @@ import javax.security.cert.CertificateException;
import org.apache.log4j.Logger;
import org.linphone.p2pproxy.api.P2pProxyException;
import org.linphone.p2pproxy.core.sipproxy.SipProxyRegistrarAdvertisement;
import org.linphone.p2pproxy.core.sipproxy.NetworkResourceAdvertisement;
import org.linphone.p2pproxy.core.sipproxy.superpeers.P2pUserRegistrationAdvertisement;
......@@ -207,7 +207,7 @@ public class JxtaNetworkManager {
// in this cast the AdvertisementTutorial
AdvertisementFactory.registerAdvertisementInstance(P2pUserProfileAdvertisement.getAdvertisementType(),new P2pUserProfileAdvertisement.Instantiator());
AdvertisementFactory.registerAdvertisementInstance(P2pUserRegistrationAdvertisement.getAdvertisementType(),new P2pUserRegistrationAdvertisement.Instantiator());
AdvertisementFactory.registerAdvertisementInstance(SipProxyRegistrarAdvertisement.getAdvertisementType(),new SipProxyRegistrarAdvertisement.Instantiator());
AdvertisementFactory.registerAdvertisementInstance(NetworkResourceAdvertisement.getAdvertisementType(),new NetworkResourceAdvertisement.Instantiator());
mRendezVousService = mNetworkPeerGroup.getRendezVousService();
mLog.info("Node PeerID ["+mNetworkPeerGroup.getPeerID()+"]");
......
......@@ -33,7 +33,7 @@ import org.linphone.p2pproxy.api.P2pProxyManagement;
import org.linphone.p2pproxy.core.media.rtprelay.MediaType;
import org.linphone.p2pproxy.core.media.rtprelay.RtpRelayServiceClient;
import org.linphone.p2pproxy.core.rdvautoconfig.PeerInfoServiceClient;
import org.linphone.p2pproxy.core.sipproxy.SipProxyRegistrarAdvertisement;
import org.linphone.p2pproxy.core.sipproxy.NetworkResourceAdvertisement;
public abstract class P2pProxyManagementImpl extends P2pProxyResourceManagementImpl implements ServiceProvider,P2pProxyManagement {
protected final Configurator mConfigurator;
......
......@@ -3,7 +3,8 @@ package org.linphone.p2pproxy.core;
import org.apache.log4j.Logger;
import org.linphone.p2pproxy.api.P2pProxyException;
import org.linphone.p2pproxy.api.P2pProxyResourceManagement;
import org.linphone.p2pproxy.core.sipproxy.SipProxyRegistrarAdvertisement;
import org.linphone.p2pproxy.core.sipproxy.NetworkResourceAdvertisement;
import org.linphone.p2pproxy.core.sipproxy.SipProxyRegistrar;
public class P2pProxyResourceManagementImpl implements P2pProxyResourceManagement {
protected final JxtaNetworkManager mJxtaNetworkManager;
......@@ -18,7 +19,7 @@ public class P2pProxyResourceManagementImpl implements P2pProxyResourceManagemen
//unknown domaine
return null;
}
SipProxyRegistrarAdvertisement lSipProxyRegistrarAdvertisement = (SipProxyRegistrarAdvertisement) (mJxtaNetworkManager.getAdvertisement(null, SipProxyRegistrarAdvertisement.NAME, true));
NetworkResourceAdvertisement lSipProxyRegistrarAdvertisement = (NetworkResourceAdvertisement) (mJxtaNetworkManager.getAdvertisement(null, SipProxyRegistrar.ADV_NAME, true));
return lSipProxyRegistrarAdvertisement.getAddress();
}catch (Exception e) {
throw new P2pProxyException(e);
......@@ -27,7 +28,7 @@ public class P2pProxyResourceManagementImpl implements P2pProxyResourceManagemen
}
public void revokeSipProxy(String aProxy) throws P2pProxyException {
try {
SipProxyRegistrarAdvertisement lSipProxyRegistrarAdvertisement = (SipProxyRegistrarAdvertisement) (mJxtaNetworkManager.getAdvertisement(null, SipProxyRegistrarAdvertisement.ADDRESS_TAG, true));
NetworkResourceAdvertisement lSipProxyRegistrarAdvertisement = (NetworkResourceAdvertisement) (mJxtaNetworkManager.getAdvertisement(null, NetworkResourceAdvertisement.ADDRESS_TAG, true));
mJxtaNetworkManager.getPeerGroup().getDiscoveryService().flushAdvertisement(lSipProxyRegistrarAdvertisement);
mLog.info(aProxy +"revoked");
} catch (Exception e) {
......
......@@ -37,6 +37,7 @@ import org.apache.log4j.Logger;
import org.linphone.p2pproxy.api.P2pProxyException;
import org.linphone.p2pproxy.core.Configurator;
import org.linphone.p2pproxy.core.GenericService;
import org.linphone.p2pproxy.core.GenericUdpSession;
import org.linphone.p2pproxy.core.JxtaNetworkManager;
import org.linphone.p2pproxy.core.ServiceProvider;
......@@ -51,6 +52,7 @@ public class RtpRelayService implements ServiceProvider{
//
private final RtpRelayServerConfig mConfig;
private final GenericService mGenericService;
private final GenericUdpSession mGenericUdpSession;
private class SocketHandlerFactory implements GenericService.ServiceSocketHandlerFactory {
public Runnable create(final Socket socket) {
......@@ -109,7 +111,9 @@ public class RtpRelayService implements ServiceProvider{
mGenericService = new GenericService(properties, jxtaNetworkManager,SRV_NAME ,new SocketHandlerFactory());
mConfig = aConfig;
mRtpRelayServer = new RtpRelayServer(mConfig.getAudioVideoPrivateSocketAddress());
mGenericUdpSession = new GenericUdpSession(mConfig.getAudioVideoPrivateSocketAddress());
mRtpRelayServer = new RtpRelayServer(mGenericUdpSession.getSocket());
mGenericUdpSession.addMessageHandler(mRtpRelayServer);
mLog.info("UdpRelayService created "+this);
}
......@@ -124,7 +128,7 @@ public class RtpRelayService implements ServiceProvider{
}
public void stop() {
mRtpRelayServer.close();
mGenericUdpSession.close();
mGenericService.stop();
}
......
......@@ -56,7 +56,7 @@ import net.jxta.id.IDFactory;
* </jxta:System>
* </pre>
*/
public class SipProxyRegistrarAdvertisement extends ExtendableAdvertisement implements Comparable, Cloneable, Serializable {
public class NetworkResourceAdvertisement extends ExtendableAdvertisement implements Comparable, Cloneable, Serializable {
/**
* Instantiator
*/
......@@ -68,7 +68,7 @@ public class SipProxyRegistrarAdvertisement extends ExtendableAdvertisement impl
* @return String the type of advertisement
*/
public String getAdvertisementType() {
return SipProxyRegistrarAdvertisement.getAdvertisementType();
return NetworkResourceAdvertisement.getAdvertisementType();
}
/**
......@@ -79,7 +79,7 @@ public class SipProxyRegistrarAdvertisement extends ExtendableAdvertisement impl
* could not be created.
*/
public Advertisement newInstance() {
return new SipProxyRegistrarAdvertisement();
return new NetworkResourceAdvertisement();
}
/**
......@@ -92,21 +92,22 @@ public class SipProxyRegistrarAdvertisement extends ExtendableAdvertisement impl
* could not be created.
*/
public Advertisement newInstance(net.jxta.document.Element root) {
return new SipProxyRegistrarAdvertisement(root);
return new NetworkResourceAdvertisement(root);
}
}
private ID mId ;;
private String mAddress;
private String mName;
public final static String ADDRESS_TAG = "address";
private final static String ID_TAG = "ID";
final static String NAME_TAG = "Name";
public final static String NAME = "p2p-proxy-proxyregistrar";
//public final static String NAME = "p2p-proxy-proxyregistrar";
private final static String[] mIndexs = {NAME_TAG};
private final static Logger mLog = Logger.getLogger(SipProxyRegistrarAdvertisement.class);
private final static Logger mLog = Logger.getLogger(NetworkResourceAdvertisement.class);
/**
*
*/
public SipProxyRegistrarAdvertisement(Element root) {
public NetworkResourceAdvertisement(Element root) {
TextElement doc = (TextElement) root;
......@@ -116,7 +117,7 @@ public class SipProxyRegistrarAdvertisement extends ExtendableAdvertisement impl
initialize(doc);
}
public SipProxyRegistrarAdvertisement() {
public NetworkResourceAdvertisement() {
// TODO Auto-generated constructor stub
}
......@@ -142,7 +143,7 @@ public class SipProxyRegistrarAdvertisement extends ExtendableAdvertisement impl
}
public String getName() {
return NAME;
return mName;
}
@Override
public ID getID() {
......@@ -154,7 +155,7 @@ public class SipProxyRegistrarAdvertisement extends ExtendableAdvertisement impl
return mIndexs;
}
public static String getAdvertisementType() {
return "jxta:" +NAME;
return "jxta:p2p-proxy-networkresource";
}
/* (non-Javadoc)
* @see net.jxta.document.Advertisement#toString()
......@@ -215,7 +216,7 @@ public class SipProxyRegistrarAdvertisement extends ExtendableAdvertisement impl
setAddress(elem.getTextValue());
return true;
} else if (elem.getName().equals(NAME_TAG)) {
//nop, name is static
setName(elem.getTextValue());
return true;
} else {
return false;
......@@ -241,6 +242,9 @@ public class SipProxyRegistrarAdvertisement extends ExtendableAdvertisement impl
public void setAddress(String anAddress) {
mAddress = anAddress;
}
public void setName(String aName) {
mName = aName;
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
......@@ -251,8 +255,8 @@ public class SipProxyRegistrarAdvertisement extends ExtendableAdvertisement impl
if (this == obj) {
return true;
}
if (obj instanceof SipProxyRegistrarAdvertisement) {
SipProxyRegistrarAdvertisement adv = (SipProxyRegistrarAdvertisement) obj;
if (obj instanceof NetworkResourceAdvertisement) {
NetworkResourceAdvertisement adv = (NetworkResourceAdvertisement) obj;
return getID().equals(adv.getID());
}
......
......@@ -56,7 +56,7 @@ public class SipProxyRegistrar implements SipProviderListener,SipProxyRegistrarM
private final static Logger mLog = Logger.getLogger(SipProxyRegistrar.class);
public final static String REGISTRAR_PORT="org.linphone.p2pproxy.SipListener.registrar.port";
public final static String REGISTRAR_PUBLIC_ADDRESS="org.linphone.p2pproxy.SipListener.registrar.public.address";
public final static String ADV_NAME = "p2p-proxy-proxyregistrar";
//
private final SipProvider mProvider;
private final JxtaNetworkManager mJxtaNetworkManager;
......@@ -68,7 +68,7 @@ public class SipProxyRegistrar implements SipProviderListener,SipProxyRegistrarM
private final P2pProxyAccountManagementMBean mP2pProxyAccountManagement;
private final Configurator mProperties;
private final SuperPeerProxy mSuperPeerProxy;
private final SipProxyRegistrarAdvertisement mProxyRegistrationAdvertisement;
private final NetworkResourceAdvertisement mProxyRegistrationAdvertisement;
//private long mNumberOfEstablishedCall;
private long mNumberOfRefusedRegistration;
......@@ -172,7 +172,7 @@ public class SipProxyRegistrar implements SipProviderListener,SipProxyRegistrarM
mProvider.addSipProviderListener(SipProvider.PROMISQUE,this);
mPool = Executors.newCachedThreadPool();
mSuperPeerProxy = new SuperPeerProxy(aJxtaNetworkManager, "sip:"+mProvider.getViaAddress()+":"+mProvider.getPort(),mRegistrationTab);
mProxyRegistrationAdvertisement = (SipProxyRegistrarAdvertisement) AdvertisementFactory.newAdvertisement(SipProxyRegistrarAdvertisement.getAdvertisementType());
mProxyRegistrationAdvertisement = (NetworkResourceAdvertisement) AdvertisementFactory.newAdvertisement(NetworkResourceAdvertisement.getAdvertisementType());
mProxyRegistrationAdvertisement.setID(IDFactory.newCodatID(mJxtaNetworkManager.getPeerGroup().getPeerGroupID(), mSuperPeerProxy.getSipProxyRegistrarAddress().toString().getBytes()));
mProxyRegistrationAdvertisement.setAddress(mSuperPeerProxy.getSipProxyRegistrarAddress());
mJxtaNetworkManager.getPeerGroup().getDiscoveryService().publish(mProxyRegistrationAdvertisement,60000,30000);
......
......@@ -41,7 +41,8 @@ import org.linphone.p2pproxy.core.P2pProxyAccountManagement;
import org.linphone.p2pproxy.core.P2pProxyAccountManagementMBean;
import org.linphone.p2pproxy.core.P2pProxyInstanceImpl;
import org.linphone.p2pproxy.core.P2pProxyMain;
import org.linphone.p2pproxy.core.sipproxy.SipProxyRegistrarAdvertisement;
import org.linphone.p2pproxy.core.sipproxy.NetworkResourceAdvertisement;
import org.linphone.p2pproxy.core.sipproxy.SipProxyRegistrar;
import org.linphone.p2pproxy.test.utils.DefaultCallListener;
import org.linphone.p2pproxy.test.utils.SipClient;
import org.zoolu.sip.address.NameAddress;
......@@ -108,7 +109,7 @@ public class P2pProxyTester extends TestCase {
public void testGetRegistrarAdress() {
try {
SipProxyRegistrarAdvertisement lSipProxyRegistrarAdvertisement = (SipProxyRegistrarAdvertisement) (((JxtaNetworkManager)mP2pProxyInstance.getOpaqueNetworkManager()).getAdvertisement(null, SipProxyRegistrarAdvertisement.NAME, true));
NetworkResourceAdvertisement lSipProxyRegistrarAdvertisement = (NetworkResourceAdvertisement) (((JxtaNetworkManager)mP2pProxyInstance.getOpaqueNetworkManager()).getAdvertisement(null,SipProxyRegistrar.ADV_NAME, true));
mLog.info("testGetRegistrarAdress ok ["+lSipProxyRegistrarAdvertisement.getAddress()+"]");
} catch (Exception e) {
mLog.error("testGetRegistrarAdress ko",e);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment