コード例 #1
0
ファイル: phapi.c プロジェクト: gabrieldelsaint/UIM
MY_DLLEXPORT OWPL_RESULT
owplInit(	const int asyncCallbackMode,
			const int udpPort, 
			const int tcpPort, 
			const int tlsPort, 
			const char* szBindToAddr,
			const int bUserSequentialPorts)
{
	int i;

	phcb = (phCallbacks_t * ) malloc(sizeof(phCallbacks_t));
	memset(phcb, 0, sizeof(phCallbacks_t));

	phcfg.asyncmode = asyncCallbackMode;

	ph_avcodec_init();
	ph_calls_init();

	if (udpPort > 0) {
		snprintf(phcfg.sipport, sizeof(phcfg.sipport), "%d", udpPort);
	}

	if (phcfg.use_tunnel)
	{
		i = ph_tunnel_init();
		if (i)
		{
			return i;
		}
	}

#ifdef FORCE_VAD
/* HACK for test */
#ifdef EMBED
	phcfg.vad = VAD_VALID_MASK | (500 & VAD_THRESHOLD_MASK);
#else
	phcfg.vad = VAD_VALID_MASK | (1000 & VAD_THRESHOLD_MASK);
#endif
#endif

#ifdef FORCE_CNG
  /* HACK for test */
  phcfg.cng = 1;
#endif

	ph_media_init(phcfg.use_tunnel, phcfg.plugin_path);

	i = eXosip_init(0, 0, atoi(phcfg.sipport), phTunnel);

	if (i)
	{
		return OWPL_RESULT_FAILURE;
	}

	{
		/* <UOLFONE> */
		/*
		const char * ua  = WENGOPHONE_UA;
		eXosip_set_user_agent(ua);
		*/
		if (phcfg.user_agent[0])
		{
			eXosip_set_user_agent(phcfg.user_agent);
		}
		else
		{
			const char * ua  = UOLFONECLIENT_UA;
			eXosip_set_user_agent(ua);
		}
		/* <UOLFONE> */
	}

	ph_nat_init();

/* This should be done in the setter of phcfg.proxy
	if (phcfg.force_proxy)
	{
		eXosip_force_proxy(phcfg.proxy);
	}
*/

	{
		char contact[512];

		eXosip_guess_contact_uri(phcfg.identity, contact, sizeof(contact), 1);
		eXosip_set_answer_contact(contact);
	}

	ph_vlines_init();

	ph_payloads_init();

	if (!phcfg.audio_dev || phcfg.audio_dev[0] == '\0')
	{
		// Set default audio device if no one has been set before
		owplAudioSetConfigString(0);
	}

	/* register callbacks? */
	eXosip_set_mode(EVENT_MODE);

	if (!phcfg.asyncmode)
	{
		phWaitTimeout = 1;
	}
	else 
	{
		phWaitTimeout = 500;
	}

	if (phcfg.asyncmode)
	{
		osip_thread_create(20000, ph_api_thread, 0);
	}

	ph_media_stop_mutex = g_mutex_new();

	phIsInitialized = 1;

	DEBUGTRACE("PhInit finished\n");

	return OWPL_RESULT_SUCCESS;
}
コード例 #2
0
OWPL_RESULT
owplInit
(
	const int asyncCallbackMode,
	short udpPort,
	short tcpPort,
	short tlsPort,
	const char* szBindToAddr,
	const int bUserSequentialPorts
)
{
	int return_code;
	short useUdp = (udpPort == -1 ? 0 : 1);
	short useTcp = (tcpPort == -1 ? 0 : 1);
	short useTls = (tlsPort == -1 ? 0 : 1);
	const char* ptime;

	return_code = owplAdapterInitialize();
	if (return_code != 0)
	{
		owplLogError("owplAdapterInitialize failed");
		return OWPL_RESULT_FAILURE;
	}
	return_code = owplAdapterNortelInitialize("nortel");
	if (return_code != 0)
	{
		owplLogError("owplAdapterNortelInitialize failed");
		return OWPL_RESULT_FAILURE;
	}

	phcb = (phCallbacks_t * ) malloc(sizeof(phCallbacks_t));
	memset(phcb, 0, sizeof(phCallbacks_t));

	phcfg.asyncmode = asyncCallbackMode;

	return_code = owplInitOwsl(useUdp, useTcp, useTls);
	if (return_code != 0)
	{
		owplLogError("owplInitOwsl failed");
		return OWPL_RESULT_FAILURE;
	}

	osip_trace_initialize_func(OSIP_INFO3, owplOsipLogFunction);

	return_code = eXosip_init(0, 0, udpPort, tcpPort, tlsPort);
	if (return_code != 0)
	{
		owplLogError("eXosip_init failed");
		return OWPL_RESULT_FAILURE;
	}

	{

		const char version[] = stringize(VOXOXVERSION);//VOXOX - CJC - 2009.06.27 
		// VOXOX CHANGE by ASV 06-27-2009: modified the code to be compatible with GCC
		char ua[50] = "VoxOx "; // We need to define he size to make sure strcat has enough space to copy version in ua
		strcat(ua, version);//VOXOX - CJC - 2009.06.27 
		// VOXOX CHANGE by ASV - end
		eXosip_set_user_agent(ua);
	}

	ph_avcodec_init();
	ph_calls_init();

#ifdef FORCE_VAD
/* HACK for test */
#ifdef EMBED
	phcfg.vad = VAD_VALID_MASK | (500 & VAD_THRESHOLD_MASK);
#else
	phcfg.vad = VAD_VALID_MASK | (1000 & VAD_THRESHOLD_MASK);
#endif
#endif

#ifdef FORCE_CNG
  /* HACK for test */
  phcfg.cng = 1;
#endif

	ph_media_init(phcfg.plugin_path);

	ph_vlines_init();

	ph_payloads_init();

	if (!phcfg.audio_dev || phcfg.audio_dev[0] == '\0')
	{
		// Set default audio device if no one has been set before
		owplAudioSetConfigString(0);
	}
#if 0	
	ptime = getenv("EXOSIP_FORCE_PTIME");
	if (!ptime || !*ptime)
	{
		putenv("EXOSIP_FORCE_PTIME=20");
	}
#endif	
	/* register callbacks? */
	eXosip_set_mode(EVENT_MODE);

	if (!phcfg.asyncmode)
	{
		phWaitTimeout = 1;
	}
	else 
	{
		phWaitTimeout = 500;
	}

	if (phcfg.asyncmode)
	{
		osip_thread_create(20000, ph_api_thread, 0);
	}

	pthread_mutex_init(&ph_media_stop_mutex, NULL);

	phIsInitialized = 1;

	owplLogDebug("owplInit finished");

	return OWPL_RESULT_SUCCESS;
}