Search in sources :

Example 1 with UaConfig

use of org.pjsip.pjsua2.UaConfig in project vialer-android by VoIPGRID.

the class SipConfig method configureStunServer.

/**
 * Use a stun server if one has been configured.
 *
 * @param uaConfig
 */
private void configureStunServer(UaConfig uaConfig) {
    String[] stunHosts = mSipService.getResources().getStringArray(R.array.stun_hosts);
    if (stunHosts.length <= 0)
        return;
    StringVector stun = new StringVector();
    for (String stunHost : stunHosts) {
        mRemoteLogger.i("Configuring STUN server: " + stunHost);
        stun.add(stunHost);
    }
    uaConfig.setStunServer(stun);
}
Also used : StringVector(org.pjsip.pjsua2.StringVector)

Example 2 with UaConfig

use of org.pjsip.pjsua2.UaConfig in project vialer-android by VoIPGRID.

the class SipConfig method createEndpoint.

/**
 * Create the Endpoint and init/start the Endpoint.
 * @return
 * @throws LibraryInitFailedException
 */
private Endpoint createEndpoint() throws LibraryInitFailedException {
    mRemoteLogger.d("createEndpoint");
    Endpoint endpoint = new Endpoint();
    EpConfig endpointConfig = new EpConfig();
    // Set echo cancellation options for endpoint.
    MediaConfig mediaConfig = createMediaConfig(endpointConfig);
    endpointConfig.setMedConfig(mediaConfig);
    try {
        endpoint.libCreate();
    } catch (Exception e) {
        Log.e(TAG, "Unable to create the PJSIP library");
        mRemoteLogger.e("" + Log.getStackTraceString(e));
        e.printStackTrace();
        throw new LibraryInitFailedException();
    }
    if (BuildConfig.DEBUG || mSipService.getPreferences().remoteLoggingIsActive()) {
        setSipLogging(endpointConfig);
    }
    UaConfig uaConfig = endpointConfig.getUaConfig();
    uaConfig.setUserAgent(getUserAgentHeader(mSipService));
    configureStunServer(uaConfig);
    try {
        endpoint.libInit(endpointConfig);
    } catch (Exception e) {
        Log.e(TAG, "Unable to init the PJSIP library");
        mRemoteLogger.e("" + Log.getStackTraceString(e));
        e.printStackTrace();
        throw new LibraryInitFailedException();
    }
    TransportConfig transportConfig = createTransportConfig();
    try {
        mCurrentTransportId = endpoint.transportCreate(getTransportType(), transportConfig);
        endpoint.libStart();
    } catch (Exception exception) {
        Log.e(TAG, "Unable to start the PJSIP library");
        mRemoteLogger.e("" + Log.getStackTraceString(exception));
        throw new LibraryInitFailedException();
    }
    return endpoint;
}
Also used : EpConfig(org.pjsip.pjsua2.EpConfig) Endpoint(org.pjsip.pjsua2.Endpoint) UaConfig(org.pjsip.pjsua2.UaConfig) MediaConfig(org.pjsip.pjsua2.MediaConfig) TransportConfig(org.pjsip.pjsua2.TransportConfig)

Aggregations

Endpoint (org.pjsip.pjsua2.Endpoint)1 EpConfig (org.pjsip.pjsua2.EpConfig)1 MediaConfig (org.pjsip.pjsua2.MediaConfig)1 StringVector (org.pjsip.pjsua2.StringVector)1 TransportConfig (org.pjsip.pjsua2.TransportConfig)1 UaConfig (org.pjsip.pjsua2.UaConfig)1