[Freeswitch-svn] [commit] r3009 - in freeswitch/trunk/src/mod: codecs/mod_amr endpoints/mod_sofia

Freeswitch SVN anthm at freeswitch.org
Mon Oct 9 13:11:40 EDT 2006


Author: anthm
Date: Mon Oct  9 13:11:39 2006
New Revision: 3009

Modified:
   freeswitch/trunk/src/mod/codecs/mod_amr/Makefile
   freeswitch/trunk/src/mod/codecs/mod_amr/mod_amr.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c

Log:
update

Modified: freeswitch/trunk/src/mod/codecs/mod_amr/Makefile
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_amr/Makefile	(original)
+++ freeswitch/trunk/src/mod/codecs/mod_amr/Makefile	Mon Oct  9 13:11:39 2006
@@ -1,5 +1,5 @@
 CFLAGS += -I$(PREFIX)/include/amr
-LDFLAGS +=-lamrnb
+LDFLAGS +=-lamr
 
 all:	$(MODNAME).$(DYNAMIC_LIB_EXTEN)
 

Modified: freeswitch/trunk/src/mod/codecs/mod_amr/mod_amr.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_amr/mod_amr.c	(original)
+++ freeswitch/trunk/src/mod/codecs/mod_amr/mod_amr.c	Mon Oct  9 13:11:39 2006
@@ -88,13 +88,15 @@
 		AMR_BITRATE_1220
 	};
 
-#define AMR_Mode  7
+#define AMR_Mode 7
 
 static switch_status_t switch_amr_init(switch_codec_t *codec, switch_codec_flag_t flags,
 									  const switch_codec_settings_t *codec_settings) 
 {
 	struct amr_context *context = NULL;
 	int encoding, decoding;
+	int x, argc;
+	char *argv[10];
 
 	encoding = (flags & SWITCH_CODEC_FLAG_ENCODE);
 	decoding = (flags & SWITCH_CODEC_FLAG_DECODE);
@@ -103,12 +105,31 @@
 		return SWITCH_STATUS_FALSE;
 	} else {
 
+		if (codec->fmtp_in) {
+			argc = switch_separate_string(codec->fmtp_in, ';', argv, (sizeof(argv) / sizeof(argv[0])));
+			for(x = 0; x < argc; x++) {
+				char *data = argv[x];
+				char *arg;
+				while(*data && *data == ' ') {
+					data++;
+				}
+				if ((arg = strchr(data, '='))) {
+					*arg++ = '\0';
+					
+					printf("Codec arg %d [%s]=[%s]\n", x, data, arg);
+				}
+
+			}
+		}
+
+		codec->fmtp_out = "octet-align=0; mode-set=7";
+		
 		context->enc_mode = AMR_Mode; /* start in mode 7 */
 		context->encoder_state = NULL;
 		context->decoder_state = NULL;
 
 		if (encoding) {
-			context->encoder_state = Encoder_Interface_init(0);
+			context->encoder_state = Encoder_Interface_init(1);
 		}
 
 		if (decoding) {
@@ -152,9 +173,9 @@
 	if (!context) {
 		return SWITCH_STATUS_FALSE;
 	}
+	
+	*encoded_data_len = Encoder_Interface_Encode( context->encoder_state, context->enc_mode, (int16_t *)decoded_data, (int8_t *) encoded_data, 0);
 
-	*encoded_data_len = Encoder_Interface_Encode( context->encoder_state, context->enc_mode, (void *)decoded_data, encoded_data, 0 );
-
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -177,9 +198,8 @@
 	}
 
 	Decoder_Interface_Decode( context->decoder_state, (void *)encoded_data, (void *)decoded_data, 0 );
-
 	*decoded_data_len = codec->implementation->bytes_per_frame;
-
+	//printf("D %d/%d\n", encoded_data_len, *decoded_data_len);
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -187,8 +207,9 @@
 
 static const switch_codec_implementation_t amr_implementation = { 
 	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-	/*.ianacode */ 118, 
+	/*.ianacode */ 96, 
 	/*.iananame */ "AMR", 
+	/*.fmtp */ "octet-align=0",
 	/*.samples_per_second */ 8000, 
 	/*.bits_per_second */ 0, 
 	/*.microseconds_per_frame */ 20000, 

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	Mon Oct  9 13:11:39 2006
@@ -69,6 +69,7 @@
 #include <sofia-sip/sip_protos.h>
 #include <sofia-sip/auth_module.h>
 #include <sofia-sip/su_md5.h>
+#include <sofia-sip/su_log.h>
 
 static char reg_sql[] =
 "CREATE TABLE sip_registrations (\n"
@@ -1682,6 +1683,31 @@
 	/*.application_interface */ NULL
 };
 
+
+static void logger(void *logarg, char const *fmt, va_list ap)
+{
+	char *data;
+	int ret;
+
+	if (fmt) {
+#ifdef HAVE_VASPRINTF
+		ret = vasprintf(&data, fmt, ap);
+#else
+		data = (char *) malloc(2048);
+		vsnprintf(data, 2048, fmt, ap);
+#endif
+		if (ret == -1) {
+			return;
+		}
+	}
+	
+	if (data) {
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, (char*) "%s: %s", __FILE__, data);
+		free(data);
+	}
+}
+
+
 static switch_status_t sofia_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile,
 											  switch_core_session_t **new_session, switch_memory_pool_t *pool)
 {
@@ -3258,6 +3284,16 @@
 		goto done;
 	}
 
+	if ((settings = switch_xml_child(cfg, "global_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, "log-level")) {
+				su_log_set_level(NULL, atoi(val));
+			}
+		}
+	}
+
 	if ((profiles = switch_xml_child(cfg, "profiles"))) {
 		for (xprofile = switch_xml_child(profiles, "profile"); xprofile; xprofile = xprofile->next) {
 			if (!(settings = switch_xml_child(xprofile, "settings"))) {
@@ -3564,12 +3600,13 @@
 	}
 
 	su_init();
-
-
+	su_log_redirect(NULL, logger, NULL);
+	
 	switch_core_hash_init(&globals.profile_hash, module_pool);
 	switch_mutex_init(&globals.hash_mutex, SWITCH_MUTEX_NESTED, module_pool);
 
 	config_sofia(0);
+
 
 
 	/* connect my internal structure to the blank pointer passed to me */



More information about the Freeswitch-svn mailing list