Search in sources :

Example 1 with SipProfile

use of android.net.sip.SipProfile in project XobotOS by xamarin.

the class SipSessionGroup method reset.

synchronized void reset(String localIp) throws SipException, IOException {
    mLocalIp = localIp;
    if (localIp == null)
        return;
    SipProfile myself = mLocalProfile;
    SipFactory sipFactory = SipFactory.getInstance();
    Properties properties = new Properties();
    properties.setProperty("javax.sip.STACK_NAME", getStackName());
    properties.setProperty("gov.nist.javax.sip.THREAD_POOL_SIZE", THREAD_POOL_SIZE);
    String outboundProxy = myself.getProxyAddress();
    if (!TextUtils.isEmpty(outboundProxy)) {
        Log.v(TAG, "outboundProxy is " + outboundProxy);
        properties.setProperty("javax.sip.OUTBOUND_PROXY", outboundProxy + ":" + myself.getPort() + "/" + myself.getProtocol());
    }
    SipStack stack = mSipStack = sipFactory.createSipStack(properties);
    try {
        SipProvider provider = stack.createSipProvider(stack.createListeningPoint(localIp, allocateLocalPort(), myself.getProtocol()));
        provider.addSipListener(this);
        mSipHelper = new SipHelper(stack, provider);
    } catch (InvalidArgumentException e) {
        throw new IOException(e.getMessage());
    } catch (TooManyListenersException e) {
        // must never happen
        throw new SipException("SipSessionGroup constructor", e);
    }
    Log.d(TAG, " start stack for " + myself.getUriString());
    stack.start();
    mCallReceiverSession = null;
    mSessionMap.clear();
    resetExternalAddress();
}
Also used : TooManyListenersException(java.util.TooManyListenersException) InvalidArgumentException(javax.sip.InvalidArgumentException) SipProfile(android.net.sip.SipProfile) SipFactory(javax.sip.SipFactory) SipStack(javax.sip.SipStack) IOException(java.io.IOException) Properties(java.util.Properties) SipException(javax.sip.SipException) SipProvider(javax.sip.SipProvider)

Example 2 with SipProfile

use of android.net.sip.SipProfile in project XobotOS by xamarin.

the class SipSessionGroup method createPeerProfile.

private static SipProfile createPeerProfile(HeaderAddress header) throws SipException {
    try {
        Address address = header.getAddress();
        SipURI uri = (SipURI) address.getURI();
        String username = uri.getUser();
        if (username == null)
            username = ANONYMOUS;
        int port = uri.getPort();
        SipProfile.Builder builder = new SipProfile.Builder(username, uri.getHost()).setDisplayName(address.getDisplayName());
        if (port > 0)
            builder.setPort(port);
        return builder.build();
    } catch (IllegalArgumentException e) {
        throw new SipException("createPeerProfile()", e);
    } catch (ParseException e) {
        throw new SipException("createPeerProfile()", e);
    }
}
Also used : HeaderAddress(javax.sip.header.HeaderAddress) Address(javax.sip.address.Address) SipProfile(android.net.sip.SipProfile) ParseException(java.text.ParseException) SipURI(javax.sip.address.SipURI) SipException(javax.sip.SipException) ListeningPoint(javax.sip.ListeningPoint)

Aggregations

SipProfile (android.net.sip.SipProfile)2 SipException (javax.sip.SipException)2 IOException (java.io.IOException)1 ParseException (java.text.ParseException)1 Properties (java.util.Properties)1 TooManyListenersException (java.util.TooManyListenersException)1 InvalidArgumentException (javax.sip.InvalidArgumentException)1 ListeningPoint (javax.sip.ListeningPoint)1 SipFactory (javax.sip.SipFactory)1 SipProvider (javax.sip.SipProvider)1 SipStack (javax.sip.SipStack)1 Address (javax.sip.address.Address)1 SipURI (javax.sip.address.SipURI)1 HeaderAddress (javax.sip.header.HeaderAddress)1