mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-22 05:38:14 +00:00
extract legacy proxy to package sipproxy
git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@21 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
This commit is contained in:
parent
74c12a5761
commit
adfc060fce
6 changed files with 60 additions and 18 deletions
|
|
@ -46,7 +46,7 @@ public class MessageDispatcher implements PipeMsgListener {
|
|||
}
|
||||
}
|
||||
}
|
||||
synchronized void addPipeMsgListener(PipeMsgListener aPipeMsgListener) {
|
||||
public synchronized void addPipeMsgListener(PipeMsgListener aPipeMsgListener) {
|
||||
mPipeMsgListenerList.add(aPipeMsgListener);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import org.apache.log4j.Logger;
|
|||
import org.linphone.p2pproxy.api.P2pProxyException;
|
||||
import org.linphone.p2pproxy.core.Configurator;
|
||||
|
||||
import org.linphone.p2pproxy.core.NetworkResources;
|
||||
import org.linphone.p2pproxy.core.sipproxy.NetworkResources;
|
||||
import org.linphone.p2pproxy.core.sipproxy.SdpProcessor;
|
||||
import org.linphone.p2pproxy.core.sipproxy.SipProxyRegistrar;
|
||||
import org.linphone.p2pproxy.core.sipproxy.SipProxyRegistrar.Registration;
|
||||
|
|
@ -164,20 +164,20 @@ public class SdpProcessorImpl implements SdpProcessor {
|
|||
|
||||
String lMLineName = lMediaDescriptor.getMedia().getMedia();
|
||||
RtpSessionImpl lRtpSession = null;
|
||||
if (lRegistration.NetResources.hasRtpSession(lMLineName) == false) {
|
||||
if (((NetworkResources) lRegistration.NetResources).hasRtpSession(lMLineName) == false) {
|
||||
// first time, just create
|
||||
int lPortStart = Integer.parseInt(mProperties.getProperty(SipProxyRegistrar.UDP_MEDIA_RELAY_PORT_START, "15000"));
|
||||
lRtpSession = new RtpSessionImpl (lPortStart,lMLineName);
|
||||
lRegistration.NetResources.putRtpSession(lMLineName, lRtpSession);
|
||||
((NetworkResources) lRegistration.NetResources).putRtpSession(lMLineName, lRtpSession);
|
||||
} else {
|
||||
lRtpSession = lRegistration.NetResources.getRtpSession(lMLineName);
|
||||
lRtpSession = ((NetworkResources) lRegistration.NetResources).getRtpSession(lMLineName);
|
||||
}
|
||||
if (aRemotePipe != null) {
|
||||
lRtpSession.setRemotePipe(aRemotePipe);
|
||||
}
|
||||
|
||||
}
|
||||
return lRegistration.NetResources;
|
||||
return (NetworkResources) lRegistration.NetResources;
|
||||
}catch (Exception e) {
|
||||
throw new P2pProxyException(e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ package org.linphone.p2pproxy.core.sipproxy;
|
|||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import net.jxta.discovery.DiscoveryService;
|
||||
import net.jxta.document.Advertisement;
|
||||
import net.jxta.endpoint.MessageElement;
|
||||
import net.jxta.endpoint.StringMessageElement;
|
||||
|
|
@ -37,6 +38,7 @@ import org.linphone.p2pproxy.api.P2pProxyUserNotFoundException;
|
|||
import org.linphone.p2pproxy.core.JxtaNetworkManager;
|
||||
import org.linphone.p2pproxy.core.P2pProxyAdvertisementNotFoundException;
|
||||
import org.linphone.p2pproxy.core.media.rtprelay.SdpProcessorImpl;
|
||||
import org.linphone.p2pproxy.core.sipproxy.SipProxyRegistrar.Registration;
|
||||
import org.zoolu.sip.address.NameAddress;
|
||||
import org.zoolu.sip.address.SipURL;
|
||||
import org.zoolu.sip.header.MultipleHeader;
|
||||
|
|
@ -46,7 +48,7 @@ import org.zoolu.sip.message.MessageFactory;
|
|||
import org.zoolu.sip.provider.SipProvider;
|
||||
import org.zoolu.sip.transaction.TransactionServer;
|
||||
|
||||
public class JxtaSipProxy implements SipProxy, PipeMsgListener {
|
||||
public class JxtaSipProxy implements SipProxy, PipeMsgListener,RegistrationHandler {
|
||||
private final JxtaNetworkManager mJxtaNetworkManager;
|
||||
private final Map<String,SipProxyRegistrar.Registration> mRegistrationTab;
|
||||
private final SdpProcessor mSdpProcessor;
|
||||
|
|
@ -211,5 +213,20 @@ public class JxtaSipProxy implements SipProxy, PipeMsgListener {
|
|||
mProvider.sendMessage(lSipMessage);
|
||||
//
|
||||
}
|
||||
public void updateRegistration(Registration aRegistration, Message aRegistrationMessage) throws P2pProxyException {
|
||||
try {
|
||||
if (aRegistration.NetResources == null) {
|
||||
// new registration, create pipe
|
||||
NetworkResources lRegistration = new NetworkResources(aRegistration.From,mJxtaNetworkManager);
|
||||
aRegistration.NetResources = lRegistration;
|
||||
lRegistration.addPipeMsgListener(this);
|
||||
}
|
||||
|
||||
((NetworkResources) aRegistration.NetResources).publish(aRegistration.Expiration);
|
||||
} catch (Exception e) {
|
||||
throw new P2pProxyException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ 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;
|
||||
package org.linphone.p2pproxy.core.sipproxy;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
|
@ -26,6 +26,8 @@ import java.util.Map;
|
|||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.linphone.p2pproxy.core.JxtaNetworkManager;
|
||||
import org.linphone.p2pproxy.core.MessageDispatcher;
|
||||
import org.linphone.p2pproxy.core.media.jxtaudpproxy.RtpSessionImpl;
|
||||
|
||||
import net.jxta.discovery.DiscoveryService;
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
p2pproxy Copyright (C) 2007 Jehan Monnier ()
|
||||
|
||||
RegistrationHandler.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.sipproxy;
|
||||
|
||||
|
||||
import org.linphone.p2pproxy.api.P2pProxyException;
|
||||
import org.linphone.p2pproxy.core.sipproxy.SipProxyRegistrar.Registration;
|
||||
import org.zoolu.sip.message.Message;
|
||||
|
||||
public interface RegistrationHandler {
|
||||
public void updateRegistration(Registration aRegistration, Message aRegistrationMessage) throws P2pProxyException;
|
||||
}
|
||||
|
|
@ -46,7 +46,6 @@ import org.linphone.p2pproxy.api.P2pProxyUserNotFoundException;
|
|||
|
||||
import org.linphone.p2pproxy.core.Configurator;
|
||||
import org.linphone.p2pproxy.core.JxtaNetworkManager;
|
||||
import org.linphone.p2pproxy.core.NetworkResources;
|
||||
import org.linphone.p2pproxy.core.P2pProxyAccountManagementMBean;
|
||||
import org.linphone.p2pproxy.core.P2pProxyAdvertisementNotFoundException;
|
||||
import org.linphone.p2pproxy.core.media.rtprelay.MediaType;
|
||||
|
|
@ -93,7 +92,8 @@ public class SipProxyRegistrar implements SipProviderListener,SipProxyRegistrarM
|
|||
public static class Registration {
|
||||
long RegistrationDate;
|
||||
long Expiration;
|
||||
public NetworkResources NetResources;
|
||||
//implementation specific context
|
||||
public Object NetResources;
|
||||
public Map<MediaType,InetSocketAddress> RtpRelays = new HashMap<MediaType,InetSocketAddress>() ;
|
||||
String Contact;
|
||||
final String From;
|
||||
|
|
@ -274,19 +274,13 @@ public class SipProxyRegistrar implements SipProviderListener,SipProxyRegistrarM
|
|||
}
|
||||
private void updateRegistration(Registration aRegistration, Message aRegistrationMessage) throws IOException {
|
||||
aRegistration.RegistrationDate = System.currentTimeMillis();
|
||||
// default registration periode
|
||||
// default registration period
|
||||
aRegistration.Expiration = 3600000;
|
||||
if (aRegistrationMessage.getExpiresHeader() != null ) {
|
||||
aRegistration.Expiration = aRegistrationMessage.getExpiresHeader().getDeltaSeconds()*1000;
|
||||
}
|
||||
|
||||
if (aRegistration.NetResources == null) {
|
||||
// new registration, create pipe
|
||||
aRegistration.NetResources = new NetworkResources(aRegistration.From,mJxtaNetworkManager);
|
||||
aRegistration.NetResources.addPipeMsgListener(this);
|
||||
}
|
||||
|
||||
aRegistration.NetResources.publish(aRegistration.Expiration);
|
||||
//TODO handle registration
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue