Commit 6d157983 authored by jehan's avatar jehan

test stun client

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@95 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
parent d611a2da
......@@ -22,8 +22,8 @@ package org.linphone.p2pproxy.api;
import org.zoolu.sip.provider.SipProvider;
public interface P2pProxyInstance {
public static int BASE_HTTP = 9700;
public static int BASE_TCP = 30700;
public static int BASE_HTTP = 30700;
public static int BASE_TCP = 9701;
public enum Mode {relay, edge, auto,seeding_server};
/**
......
......@@ -102,11 +102,12 @@ public class P2pProxyInstanceImpl implements P2pProxyInstance {
lNetworkConfigurator.load();
}
// set sedding host
lNetworkConfigurator.addSeedRendezvous(new URI("http://"+getPublicHostAddress()+":"+BASE_HTTP));
lNetworkConfigurator.addSeedRelay(new URI("http://"+getPublicHostAddress()+":"+BASE_HTTP));
lNetworkConfigurator.addSeedRendezvous(new URI("tcp://"+getPublicHostAddress()+":"+BASE_TCP));
lNetworkConfigurator.addSeedRelay(new URI("tcp://"+getPublicHostAddress()+":"+BASE_TCP));
// set listening ports
lNetworkConfigurator.setHttpInterfaceAddress(getPrivateHostAddress());
lNetworkConfigurator.setHttpPort(BASE_HTTP + mIndex);
// lNetworkConfigurator.setTcpInterfaceAddress(getPrivateHostAddress());
// lNetworkConfigurator.setHttpInterfaceAddress(getPrivateHostAddress());
// lNetworkConfigurator.setHttpPort(BASE_HTTP + mIndex);
lNetworkConfigurator.setTcpPort(BASE_TCP + mIndex);
switch (mMode) {
......@@ -244,7 +245,7 @@ public class P2pProxyInstanceImpl implements P2pProxyInstance {
aNetworkConfigurator.setMode(JxtaNetworkManager.SUPER_PEER_MODE);
if (isSeeding == true) {
mJxtaNetworkManager = new JxtaNetworkManager(aProperties,aNetworkConfigurator,60000,JxtaNetworkManager.Mode.seeding_server);
mServiceProvider = new SeedingPeerServiceManager(aProperties, mJxtaNetworkManager,false);
mServiceProvider = new SeedingPeerServiceManager(aProperties, mJxtaNetworkManager,true);
mP2pProxyManagement = null;
} else {
mJxtaNetworkManager = new JxtaNetworkManager(aProperties,aNetworkConfigurator,60000,JxtaNetworkManager.Mode.relay);
......
......@@ -136,7 +136,11 @@ public class P2pProxyMain implements P2pProxyMainMBean {
lsipPort = Integer.parseInt(args[i + 1]);
System.out.println("sipPort detected[" + lsipPort + "]");
mConfigurator.setProperty(SipProxyRegistrar.REGISTRAR_PORT, Integer.toString(lsipPort));
} else if (argument.equals("-relay")) {
} else if (argument.equals("-media")) {
lMediaPort = Integer.parseInt(args[i + 1]);
System.out.println("media detected[" + lsipPort + "]");
mConfigurator.setProperty(SipProxyRegistrar.REGISTRAR_PORT, Integer.toString(lMediaPort));
} else if (argument.equals("-relay")) {
lMode = JxtaNetworkManager.Mode.relay;
mConfigurator.setProperty(JxtaNetworkManager.MODE, lMode.name());
System.out.println("relay mode detected");
......
......@@ -6,21 +6,18 @@
package org.linphone.p2pproxy.core;
import java.net.InetSocketAddress;
import java.net.SocketException;
import java.net.URI;
import java.net.UnknownHostException;
import org.apache.log4j.Logger;
import org.linphone.p2pproxy.api.P2pProxyException;
import org.linphone.p2pproxy.core.media.rtprelay.RtpRelayService;
import org.linphone.p2pproxy.core.media.rtprelay.RtpRelayServerConfig;
import org.linphone.p2pproxy.core.media.MediaResourceService;
import org.linphone.p2pproxy.core.rdvautoconfig.PeerInfoProviderService;
public class SeedingPeerServiceManager extends P2pProxyResourceManagementImpl implements ServiceProvider {
protected final Configurator mConfigurator;
private final PeerInfoProviderService mPeerInfoProviderService;
private RtpRelayService mUdpRelayService = null;
private MediaResourceService mStunUdpRelayService = null;
private final static Logger mLog = Logger.getLogger(SeedingPeerServiceManager.class);
SeedingPeerServiceManager(Configurator aConfigurator, JxtaNetworkManager aJxtaNetworkManager,boolean enableUdpRelay) throws SocketException, UnknownHostException {
......@@ -28,26 +25,22 @@ public class SeedingPeerServiceManager extends P2pProxyResourceManagementImpl im
mConfigurator = aConfigurator;
mPeerInfoProviderService = new PeerInfoProviderService(aConfigurator, aJxtaNetworkManager);
if (enableUdpRelay == true) {
URI lAudioVideoPublicUri = URI.create(aConfigurator.getProperty(RtpRelayService.AUDIO_VIDEO_PUBLIC_URI,RtpRelayService.getDefaultAudioVideoPublicUri()));
int lAudioVideoLocalPort = Integer.valueOf(aConfigurator.getProperty(RtpRelayService.AUDIO_VIDEO_LOCAL_PORT,String.valueOf(lAudioVideoPublicUri.getPort())));
RtpRelayServerConfig lConfig = new RtpRelayServerConfig(new InetSocketAddress(lAudioVideoPublicUri.getHost(),lAudioVideoPublicUri.getPort())
,new InetSocketAddress(lAudioVideoLocalPort));
mUdpRelayService = new RtpRelayService(lConfig,aConfigurator,aJxtaNetworkManager);
mStunUdpRelayService = new MediaResourceService(aConfigurator,aJxtaNetworkManager);
}
}
public void start(long aTimeout) throws P2pProxyException {
mPeerInfoProviderService.start(aTimeout);
if (mUdpRelayService != null) {
mUdpRelayService.start(aTimeout);
if (mStunUdpRelayService != null) {
mStunUdpRelayService.start(aTimeout);
}
mLog.info("SeedingPeerServiceManager started");
}
public void stop() {
mPeerInfoProviderService.stop();
if (mUdpRelayService != null) {
mUdpRelayService.stop();
if (mStunUdpRelayService != null) {
mStunUdpRelayService.stop();
}
mLog.info("SeedingPeerServiceManager stopped");
}
......
/*
p2pproxy Copyright (C) 2007 Jehan Monnier ()
MediaResourceService.java - .
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.p2pproxy.core.media;
import java.net.InetSocketAddress;
import java.net.SocketException;
import java.net.URI;
import java.net.UnknownHostException;
import net.jxta.document.AdvertisementFactory;
import net.jxta.id.IDFactory;
import org.apache.log4j.Logger;
import org.linphone.p2pproxy.api.P2pProxyException;
import org.linphone.p2pproxy.core.Configurator;
import org.linphone.p2pproxy.core.GenericUdpSession;
import org.linphone.p2pproxy.core.JxtaNetworkManager;
import org.linphone.p2pproxy.core.ServiceProvider;
import org.linphone.p2pproxy.core.media.rtprelay.RtpRelayServer;
import org.linphone.p2pproxy.core.media.rtprelay.RtpRelayServerConfig;
import org.linphone.p2pproxy.core.media.rtprelay.RtpRelayService;
import org.linphone.p2pproxy.core.sipproxy.NetworkResourceAdvertisement;
import org.linphone.p2pproxy.core.stun.StunServer;
public class MediaResourceService implements ServiceProvider {
private final static Logger mLog = Logger.getLogger(MediaResourceService.class);
private GenericUdpSession mUdpSessionForStunRtp;
private RtpRelayServer mRtpRelayServer;
private StunServer mSturServer;
private RtpRelayServerConfig mConfig;
private final JxtaNetworkManager mJxtaNetworkManager;
private NetworkResourceAdvertisement mStunRtpServerAdvertisement;
public final static String ADV_NAME = "p2p-proxy-stunrtp";
public MediaResourceService(Configurator aConfigurator, JxtaNetworkManager aJxtaNetworkManager) throws SocketException, UnknownHostException {
URI lAudioVideoPublicUri = URI.create(aConfigurator.getProperty(RtpRelayService.AUDIO_VIDEO_PUBLIC_URI,RtpRelayService.getDefaultAudioVideoPublicUri()));
int lAudioVideoLocalPort = Integer.valueOf(aConfigurator.getProperty(RtpRelayService.AUDIO_VIDEO_LOCAL_PORT,String.valueOf(lAudioVideoPublicUri.getPort())));
mConfig = new RtpRelayServerConfig(new InetSocketAddress(lAudioVideoPublicUri.getHost(),lAudioVideoPublicUri.getPort())
,new InetSocketAddress(lAudioVideoLocalPort));
mUdpSessionForStunRtp = new GenericUdpSession(new InetSocketAddress(lAudioVideoLocalPort));
mRtpRelayServer = new RtpRelayServer(mUdpSessionForStunRtp.getSocket(),1000,1000);
mUdpSessionForStunRtp.addMessageHandler(mRtpRelayServer);
mSturServer = new StunServer(mUdpSessionForStunRtp.getSocket());
mUdpSessionForStunRtp.addMessageHandler(mSturServer);
mJxtaNetworkManager = aJxtaNetworkManager;
}
public void start(long timeOut) throws P2pProxyException {
try {
mStunRtpServerAdvertisement = (NetworkResourceAdvertisement) AdvertisementFactory.newAdvertisement(NetworkResourceAdvertisement.getAdvertisementType());
mStunRtpServerAdvertisement.setAddress("udp://"+mConfig.getAudioVideoPublicSocketAddress().getAddress().getHostAddress()+":"+mConfig.getAudioVideoPublicSocketAddress().getPort());
mStunRtpServerAdvertisement.setID(IDFactory.newCodatID(mJxtaNetworkManager.getPeerGroup().getPeerGroupID(), mStunRtpServerAdvertisement.getAddress().toString().getBytes()));
mStunRtpServerAdvertisement.setName(ADV_NAME);
mJxtaNetworkManager.getPeerGroup().getDiscoveryService().publish(mStunRtpServerAdvertisement,60000,30000);
mLog.info(mStunRtpServerAdvertisement + "published");
} catch (Exception e) {
throw new P2pProxyException(e);
}
}
public void stop() {
try {
mJxtaNetworkManager.getPeerGroup().getDiscoveryService().flushAdvertisement(mStunRtpServerAdvertisement);
mUdpSessionForStunRtp.close();
} catch (Exception e) {
mLog.error("cannot stop MediaResourceService",e);
}
}
}
......@@ -200,6 +200,10 @@ public class RtpRelayServer implements GenericUdpSession.MessageHandler {
public void onMessage(DatagramPacket aMessage) {
try {
if (mLog.isInfoEnabled()) mLog.info("new incoming message from ["+aMessage.getSocketAddress()+"]");
if (isRtpRtcpPacket(aMessage) == false) {
if (mLog.isInfoEnabled()) mLog.info("not rtp/rtcp packet skip");
return;
}
long lSsrc = getSsrc(aMessage);
if (isSessionIdPresent(aMessage)) {
String lSessionId = getSessionId(aMessage);
......@@ -323,5 +327,8 @@ public class RtpRelayServer implements GenericUdpSession.MessageHandler {
public int getRoutingtableSize() {
return mRoutingTable.getSize();
}
boolean isRtpRtcpPacket(DatagramPacket aMessage) {
return (aMessage.getData()[0] >> 6) != 0;
}
}
......@@ -175,6 +175,7 @@ public class SipProxyRegistrar implements SipProviderListener,SipProxyRegistrarM
mProxyRegistrationAdvertisement = (NetworkResourceAdvertisement) AdvertisementFactory.newAdvertisement(NetworkResourceAdvertisement.getAdvertisementType());
mProxyRegistrationAdvertisement.setID(IDFactory.newCodatID(mJxtaNetworkManager.getPeerGroup().getPeerGroupID(), mSuperPeerProxy.getSipProxyRegistrarAddress().toString().getBytes()));
mProxyRegistrationAdvertisement.setAddress(mSuperPeerProxy.getSipProxyRegistrarAddress());
mProxyRegistrationAdvertisement.setName(ADV_NAME);
mJxtaNetworkManager.getPeerGroup().getDiscoveryService().publish(mProxyRegistrationAdvertisement,60000,30000);
mLog.info(mProxyRegistrationAdvertisement + "published");
}
......
......@@ -36,7 +36,7 @@ public class AddressInfo {
private InetSocketAddress mPublicAddress;
private Mode mMode = Mode.unknown;
AddressInfo(InetSocketAddress aPrivateAddress) {
public AddressInfo(InetSocketAddress aPrivateAddress) {
mPrivateAddress = aPrivateAddress;
}
public Mode getMode() {
......@@ -54,4 +54,14 @@ public class AddressInfo {
public void setPublicAddress(InetSocketAddress aPublicAddress) {
mPublicAddress = aPublicAddress;
}
public boolean isNated() {
if (mPublicAddress != null) {
return mPublicAddress.equals(mPrivateAddress);
} else {
return false;
}
}
public String toString() {
return "private ["+mPrivateAddress+"] public ["+mPublicAddress+"] mode ["+mMode+"]";
}
}
......@@ -29,16 +29,13 @@ import java.net.URI;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import org.linphone.p2pproxy.api.P2pProxyException;
import org.linphone.p2pproxy.core.JxtaNetworkManager;
import org.linphone.p2pproxy.core.P2pProxyAdvertisementNotFoundException;
import org.linphone.p2pproxy.core.media.MediaResourceService;
import org.linphone.p2pproxy.core.sipproxy.NetworkResourceAdvertisement;
import org.linphone.p2pproxy.test.StunServerTester;
import de.javawi.jstun.attribute.ChangeRequest;
import de.javawi.jstun.attribute.ChangedAddress;
import de.javawi.jstun.attribute.ErrorCode;
import de.javawi.jstun.attribute.MappedAddress;
import de.javawi.jstun.attribute.MessageAttribute;
......@@ -51,13 +48,13 @@ public class StunClient {
private static Logger mLog = Logger.getLogger(StunClient.class);
private List<InetSocketAddress> mStunServerList;
JxtaNetworkManager mJxtaNetworkManager;
private DiscoveryInfo mDiscoveryInfo;
private int SO_TIME_OUT = 300;
StunClient(List<InetSocketAddress> aStunServerList) {
mStunServerList = aStunServerList;
}
StunClient(JxtaNetworkManager aJxtaNetworkManager) throws P2pProxyException {
public StunClient(JxtaNetworkManager aJxtaNetworkManager) throws P2pProxyException {
//need to acquire stun server address()
mJxtaNetworkManager = aJxtaNetworkManager;
try {
......@@ -67,7 +64,7 @@ public class StunClient {
}
}
private List<InetSocketAddress> acquireStunServerAddress() throws P2pProxyAdvertisementNotFoundException, InterruptedException, IOException {
List<NetworkResourceAdvertisement> lStunServerAdv = (List<NetworkResourceAdvertisement>) mJxtaNetworkManager.getAdvertisementList(null, StunServer.ADV_NAME, true);
List<NetworkResourceAdvertisement> lStunServerAdv = (List<NetworkResourceAdvertisement>) mJxtaNetworkManager.getAdvertisementList(null, MediaResourceService.ADV_NAME, true);
List<InetSocketAddress> lSocketAddressList = new ArrayList<InetSocketAddress>(lStunServerAdv.size());
for (NetworkResourceAdvertisement lNetworkResourceAdvertisement: lStunServerAdv) {
URI lServerUri = URI.create(lNetworkResourceAdvertisement.getAddress());
......@@ -77,17 +74,28 @@ public class StunClient {
}
public AddressInfo computeAddressInfo(DatagramSocket lLocalSocket) throws P2pProxyException {
//1 bind request
AddressInfo lAddressInfo = new AddressInfo((InetSocketAddress) lLocalSocket.getLocalSocketAddress());
try {
//1 bind request
bindRequest(lLocalSocket,lLocalSocket, mStunServerList.get(0));
//open new socket
DiscoveryInfo lDiscoveryInfo = new DiscoveryInfo((InetSocketAddress) lLocalSocket.getLocalSocketAddress());
//1 bind request
bindRequest(lDiscoveryInfo,lLocalSocket,lLocalSocket, mStunServerList.get(0));
//2 bind request
if (mStunServerList.size() > 1) {
//open new socket
DatagramSocket lDatagramSocket = new DatagramSocket();
bindRequest(lDiscoveryInfo,lLocalSocket,lDatagramSocket, mStunServerList.get(1));
lDatagramSocket.close();
}
//analyse
lAddressInfo.setPublicAddress(lDiscoveryInfo.getPublicSocketAddress());
} catch (Exception e) {
throw new P2pProxyException(e);
}
return null;
return lAddressInfo;
}
private void bindRequest(DatagramSocket aLocalSocket, DatagramSocket aResponseSocket,InetSocketAddress aStunAddress) throws UtilityException, SocketException, UnknownHostException, IOException, MessageAttributeParsingException, MessageHeaderParsingException, P2pProxyException {
private void bindRequest(DiscoveryInfo aDiscoveryInfo,DatagramSocket aLocalSocket, DatagramSocket aResponseSocket,InetSocketAddress aStunAddress) throws UtilityException, SocketException, UnknownHostException, IOException, MessageAttributeParsingException, MessageHeaderParsingException, P2pProxyException {
int timeSinceFirstTransmission = 0;
int lSoTimeOut = SO_TIME_OUT;
while (true) {
......@@ -117,7 +125,7 @@ public class StunClient {
MappedAddress lMappedAddress = (MappedAddress) receiveMH.getMessageAttribute(MessageAttribute.MessageAttributeType.MappedAddress);
ErrorCode ec = (ErrorCode) receiveMH.getMessageAttribute(MessageAttribute.MessageAttributeType.ErrorCode);
if (ec != null) {
mDiscoveryInfo.setError(ec.getResponseCode(), ec.getReason());
aDiscoveryInfo.setError(ec.getResponseCode(), ec.getReason());
throw new P2pProxyException("Message header contains an Errorcode message attribute. ["+ec+"]");
}
if ((lMappedAddress == null)) {
......@@ -125,9 +133,9 @@ public class StunClient {
} else {
if (aLocalSocket.getLocalSocketAddress().equals(aResponseSocket.getLocalSocketAddress())) {
mDiscoveryInfo.setPublicSocketAddress(new InetSocketAddress(lMappedAddress.getAddress().getInetAddress(),lMappedAddress.getPort()));
aDiscoveryInfo.setPublicSocketAddress(new InetSocketAddress(lMappedAddress.getAddress().getInetAddress(),lMappedAddress.getPort()));
} else {
mDiscoveryInfo.setFullCone();
aDiscoveryInfo.setFullCone();
}
}
return;
......@@ -143,9 +151,9 @@ public class StunClient {
// node is not capable of udp communication
if (mLog.isInfoEnabled()) mLog.info("Socket timeout while receiving the response. Maximum retry limit exceed. Give up.");
if (aLocalSocket.getLocalSocketAddress().equals(aResponseSocket.getLocalSocketAddress())) {
mDiscoveryInfo.setBlockedUDP();
aDiscoveryInfo.setBlockedUDP();
} else {
mDiscoveryInfo.setSymmetric();
aDiscoveryInfo.setSymmetric();
}
if (mLog.isInfoEnabled()) mLog.info("Node is not capable of UDP communication.");
return ;
......
......@@ -50,7 +50,7 @@ import de.javawi.jstun.util.Address;
public class StunServer implements GenericUdpSession.MessageHandler {
private static Logger mLog = Logger.getLogger(StunServer.class);
private final DatagramSocket mSocket;
public final static String ADV_NAME = "p2p-proxy-stunserver";
public StunServer(DatagramSocket mListeningSocket) throws SocketException {
mSocket = mListeningSocket;
}
......
......@@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.p2pproxy.test;
import java.net.DatagramSocket;
import java.util.Enumeration;
import java.util.List;
import java.util.concurrent.Semaphore;
......@@ -43,6 +44,8 @@ import org.linphone.p2pproxy.core.P2pProxyInstanceImpl;
import org.linphone.p2pproxy.core.P2pProxyMain;
import org.linphone.p2pproxy.core.sipproxy.NetworkResourceAdvertisement;
import org.linphone.p2pproxy.core.sipproxy.SipProxyRegistrar;
import org.linphone.p2pproxy.core.stun.AddressInfo;
import org.linphone.p2pproxy.core.stun.StunClient;
import org.linphone.p2pproxy.test.utils.DefaultCallListener;
import org.linphone.p2pproxy.test.utils.SipClient;
import org.zoolu.sip.address.NameAddress;
......@@ -107,6 +110,25 @@ public class P2pProxyTester extends TestCase {
protected void tearDown() throws Exception {
}
public void testStunClient() {
try {
// if (mP2pProxyInstance2 == null) {
// try {
// setupJxta2();
// } catch (Exception e) {
// mLog.error("cannot start peer2");
// }
// }
DatagramSocket lDatagramSocket = new DatagramSocket();
StunClient lStunClient = new StunClient((JxtaNetworkManager)mP2pProxyInstance.getOpaqueNetworkManager());
AddressInfo lAddressInfo = lStunClient.computeAddressInfo(lDatagramSocket);
mLog.info("AddressInfo ["+lAddressInfo+"]");
}catch (Exception e) {
mLog.error("testStunClient ko",e);
Assert.fail(e.getMessage());
}
}
public void testGetRegistrarAdress() {
try {
NetworkResourceAdvertisement lSipProxyRegistrarAdvertisement = (NetworkResourceAdvertisement) (((JxtaNetworkManager)mP2pProxyInstance.getOpaqueNetworkManager()).getAdvertisement(null,SipProxyRegistrar.ADV_NAME, true));
......@@ -394,12 +416,13 @@ public class P2pProxyTester extends TestCase {
private void setupJxta() throws Exception {
mP2pProxyInstance = new P2pProxyInstanceImpl();
mP2pProxyInstance.setMode(Mode.relay);
mP2pProxyInstance.setIndex(0);
mP2pProxyInstance.setMode(Mode.seeding_server);
mP2pProxyInstance.setIndex(1);
mP2pProxyInstance.setProperty(JxtaNetworkManager.ADV_DISCOVERY_TIMEOUT, String.valueOf(RDV_DISCOVERY_TIMEOUT));
mP2pProxyInstance.start();
while (mP2pProxyInstance.isStarted() == false) Thread.sleep(500);
}
private void call(String aCaller,String aCallee) throws Exception {
call(aCaller,aCallee,false);
}
......
......@@ -23,6 +23,7 @@ public class RtpRelayServerTester extends TestCase{
static private int RTP_SERVER_PORT = 16000;
private static GenericUdpSession mGenericUdpSession;
static StunServer mSturServer = null;
private final int SO_TIMEOUT=100;
@Before
public void setUp() throws Exception {
......@@ -74,27 +75,27 @@ public class RtpRelayServerTester extends TestCase{
//1 send rtcp app A
DatagramSocket lRtcpSocketA = new DatagramSocket(new InetSocketAddress("localhost", 0));
DatagramPacket lRtcpaPacket = new DatagramPacket(lRtcpA,lRtcpA.length,InetAddress.getByName("localhost"), RTP_SERVER_PORT);
lRtcpSocketA.setSoTimeout(100);
lRtcpSocketA.setSoTimeout(SO_TIMEOUT);
lRtcpSocketA.send(lRtcpaPacket);
//2 send rtcp app B
DatagramSocket lRtcpSocketB = new DatagramSocket(new InetSocketAddress("localhost", 0));
DatagramPacket lRtcpbPacket = new DatagramPacket(lRtcpB,lRtcpB.length,InetAddress.getByName("localhost"), RTP_SERVER_PORT);
lRtcpSocketB.setSoTimeout(100);
lRtcpSocketB.setSoTimeout(SO_TIMEOUT);
lRtcpSocketB.send(lRtcpbPacket);
//3 send rtp A
DatagramSocket lRtpSocketA = new DatagramSocket(new InetSocketAddress("localhost", 0));
DatagramPacket lRtpaPacket = new DatagramPacket(lRtpA,lRtpA.length,InetAddress.getByName("localhost"), RTP_SERVER_PORT);
lRtpSocketA.setSoTimeout(100);
lRtpSocketA.setSoTimeout(SO_TIMEOUT);
lRtpSocketA.send(lRtpaPacket);
//4 send rtp B
DatagramSocket lRtpSocketB = new DatagramSocket(new InetSocketAddress("localhost", 0));
DatagramPacket lRtpblPacket = new DatagramPacket(lRtpB,lRtpB.length,InetAddress.getByName("localhost"), RTP_SERVER_PORT);
lRtpSocketB.send(lRtpblPacket);
lRtpSocketB.setSoTimeout(100);
lRtpSocketB.setSoTimeout(SO_TIMEOUT);
......@@ -112,7 +113,7 @@ public class RtpRelayServerTester extends TestCase{
//check RTP A->B
DatagramPacket lReceivedRtpbPacket = new DatagramPacket(new byte[1500],1500);
lRtpSocketA.setSoTimeout(100);
lRtpSocketA.setSoTimeout(SO_TIMEOUT);
lRtpSocketA.send(lRtpaPacket);
try {
lRtpSocketB.receive(lReceivedRtpbPacket);
......
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