[Freeswitch-svn] [commit] r2264 - freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip

Freeswitch SVN anthm at freeswitch.org
Fri Aug 11 16:10:30 EDT 2006


Author: anthm
Date: Fri Aug 11 16:10:29 2006
New Revision: 2264

Modified:
   freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip/mod_pjsip.c

Log:
add more config options to control debug and rtp-ip

Modified: freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip/mod_pjsip.c
==============================================================================
--- freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip/mod_pjsip.c	(original)
+++ freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip/mod_pjsip.c	Fri Aug 11 16:10:29 2006
@@ -74,10 +74,11 @@
 
 	pj_sockaddr_in sip_addr;
 	char *sip_ip;
+	char *rtp_ip;
 	int sip_port;
 
 	/* */
-	char name[128];
+	char *name;
 	char local_addr[128];
 	char *dialplan;
 	char *codec_string;
@@ -89,6 +90,7 @@
 
 	int flags;
 	switch_hash_t *call_hash;
+	switch_memory_pool_t *pool;
 };
 
 typedef enum {
@@ -1603,7 +1605,7 @@
 	media->desc.port_count = 1;
 	media->desc.transport = pj_str( "RTP/AVP" );
 
-	strncpy( tech_pvt->local_sdp_audio_addr, profile->local_addr, 
+	strncpy( tech_pvt->local_sdp_audio_addr, profile->rtp_ip, 
 			 sizeof(tech_pvt->local_sdp_audio_addr) );
 
 	/* codec rtpmap list */
@@ -1768,33 +1770,52 @@
 static switch_status_t config_pjsip( void )
 {
 	char *cfgname = MOD_PJSIP_CFG;
-	switch_xml_t config, xml, xmlprofile, param;
+	switch_xml_t config, xml, xmlprofile, settings, param;
 	switch_status_t result = SWITCH_STATUS_SUCCESS;
 
+
 	if( !( xml = switch_xml_open_cfg( cfgname, &config, NULL ) )) {
                 switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not open config %s\n", cfgname );
                 return SWITCH_STATUS_TERM;
 	}
 
+
+	if ((settings = switch_xml_child( config, "settings" ))) {
+		for (param = switch_xml_child(settings, "param"); param; param = param->next) {
+            char *var = (char *) switch_xml_attr_soft(param, "name");
+            char *val = (char *) switch_xml_attr_soft(param, "value");
+			
+			if (!strcasecmp(var, "debug")) {
+				pj_log_set_level(atoi(val));
+			}
+		}
+	}
+
 	for( xmlprofile = switch_xml_child( config, "profile" ); xmlprofile; xmlprofile = xmlprofile->next )
 	{
 		struct pjsip_profile *profile;
 		char *profile_name = (char *) switch_xml_attr_soft( xmlprofile, "name" );
+		switch_memory_pool_t *pool = NULL;
 
 		if( !profile_name ) {
 			profile_name = "noname";
 		}
+		
+		if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n");
+			result = SWITCH_STATUS_TERM;
+			goto out;
+		}
 
-		if( !(profile = switch_core_alloc( module_pool, sizeof(struct pjsip_profile))) ) {
-	                switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, 
-									   "Failed to allocate new profile %s\n", profile_name );
-        	        result = SWITCH_STATUS_TERM;
+		if( !(profile = switch_core_alloc( pool, sizeof(struct pjsip_profile))) ) {
+			switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to allocate new profile %s\n", profile_name );
+			result = SWITCH_STATUS_TERM;
 			goto out;
 		}
-		memset( profile, 0, sizeof( struct pjsip_profile ) );
+		
+		profile->pool = pool;
+		profile->name = switch_core_strdup(pool, profile_name);
 
-		switch_copy_string( profile->name, profile_name, sizeof( profile->name ) );
-
 		profile->sip_addr.sin_family = PJ_AF_INET;
 		profile->sip_addr.sin_port = pj_htons( DEFAULT_PORT );
 
@@ -1806,7 +1827,9 @@
 			if ( !strcmp( var, "max-calls" ) ) {
 				profile->max_calls = atoi( val );
 			}
-			else if ( !strcmp( var, "ip" ) ) {
+			else if ( !strcmp( var, "rtp-ip" ) ) {
+				profile->rtp_ip = switch_core_strdup(profile->pool, val);
+			} else if ( !strcmp( var, "ip" ) ) {
 				pj_str_t tmp;
 
 				if( !pj_inet_aton( pj_cstr( &tmp, val ), &profile->sip_addr.sin_addr ) ) {
@@ -2003,7 +2026,7 @@
 	}
 
 	pj_log_set_log_func(log_func);
-	pj_log_set_level(4);
+	pj_log_set_level(0);
 
 	/* next: pjlib_util */
 	status = pjlib_util_init();



More information about the Freeswitch-svn mailing list