[Freeswitch-svn] [commit] r4341 - in freeswitch/trunk/src: . mod/codecs/mod_g711

Freeswitch SVN anthm at freeswitch.org
Wed Feb 21 01:35:56 EST 2007


Author: anthm
Date: Wed Feb 21 01:35:55 2007
New Revision: 4341

Modified:
   freeswitch/trunk/src/mod/codecs/mod_g711/mod_g711.c
   freeswitch/trunk/src/switch_core.c
   freeswitch/trunk/src/switch_ivr.c

Log:
add 120ms to g711, fix errs in g711 alaw defs, tweak buffer in file playback and add kill to hupall

Modified: freeswitch/trunk/src/mod/codecs/mod_g711/mod_g711.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_g711/mod_g711.c	(original)
+++ freeswitch/trunk/src/mod/codecs/mod_g711/mod_g711.c	Wed Feb 21 01:35:55 2007
@@ -188,6 +188,26 @@
 /* Registration */
 
 
+static const switch_codec_implementation_t g711u_8k_120ms_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 0,
+	/*.iananame */ "PCMU",
+	/*.fmtp */ NULL,
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ 64000,
+	/*.microseconds_per_frame */ 120000,
+	/*.samples_per_frame */ 960,
+	/*.bytes_per_frame */ 1920,
+	/*.encoded_bytes_per_frame */ 960,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_g711u_init,
+	/*.encode */ switch_g711u_encode,
+	/*.decode */ switch_g711u_decode,
+	/*.destroy */ switch_g711u_destroy
+};
+
 static const switch_codec_implementation_t g711u_8k_60ms_implementation = {
 	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
 	/*.ianacode */ 0,
@@ -205,7 +225,8 @@
 	/*.init */ switch_g711u_init,
 	/*.encode */ switch_g711u_encode,
 	/*.decode */ switch_g711u_decode,
-	/*.destroy */ switch_g711u_destroy
+	/*.destroy */ switch_g711u_destroy,
+	/*.next*/ &g711u_8k_120ms_implementation
 };
 
 static const switch_codec_implementation_t g711u_8k_30ms_implementation = {
@@ -273,6 +294,25 @@
 
 
 
+static const switch_codec_implementation_t g711a_8k_120ms_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 8,
+	/*.iananame */ "PCMA",
+	/*.fmtp */ NULL,
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ 64000,
+	/*.microseconds_per_frame */ 120000,
+	/*.samples_per_frame */ 960,
+	/*.bytes_per_frame */ 1920,
+	/*.encoded_bytes_per_frame */ 960,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_g711a_init,
+	/*.encode */ switch_g711a_encode,
+	/*.decode */ switch_g711a_decode,
+	/*.destroy */ switch_g711a_destroy
+};
 
 static const switch_codec_implementation_t g711a_8k_60ms_implementation = {
 	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
@@ -288,10 +328,11 @@
 	/*.number_of_channels */ 1,
 	/*.pref_frames_per_packet */ 1,
 	/*.max_frames_per_packet */ 1,
-	/*.init */ switch_g711u_init,
-	/*.encode */ switch_g711u_encode,
-	/*.decode */ switch_g711u_decode,
-	/*.destroy */ switch_g711u_destroy,
+	/*.init */ switch_g711a_init,
+	/*.encode */ switch_g711a_encode,
+	/*.decode */ switch_g711a_decode,
+	/*.destroy */ switch_g711a_destroy,
+    /*.next*/ &g711a_8k_120ms_implementation
 };
 
 static const switch_codec_implementation_t g711a_8k_30ms_implementation = {
@@ -308,10 +349,10 @@
 	/*.number_of_channels */ 1,
 	/*.pref_frames_per_packet */ 1,
 	/*.max_frames_per_packet */ 1,
-	/*.init */ switch_g711u_init,
-	/*.encode */ switch_g711u_encode,
-	/*.decode */ switch_g711u_decode,
-	/*.destroy */ switch_g711u_destroy,
+	/*.init */ switch_g711a_init,
+	/*.encode */ switch_g711a_encode,
+	/*.decode */ switch_g711a_decode,
+	/*.destroy */ switch_g711a_destroy,
     /*.next*/ &g711a_8k_60ms_implementation
 };
 
@@ -350,10 +391,10 @@
 	/*.number_of_channels */ 1,
 	/*.pref_frames_per_packet */ 1,
 	/*.max_frames_per_packet */ 1,
-	/*.init */ switch_g711u_init,
-	/*.encode */ switch_g711u_encode,
-	/*.decode */ switch_g711u_decode,
-	/*.destroy */ switch_g711u_destroy,
+	/*.init */ switch_g711a_init,
+	/*.encode */ switch_g711a_encode,
+	/*.decode */ switch_g711a_decode,
+	/*.destroy */ switch_g711a_destroy,
     /*.next*/ &g711a_8k_20ms_implementation
 };
 

Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c	(original)
+++ freeswitch/trunk/src/switch_core.c	Wed Feb 21 01:35:55 2007
@@ -693,6 +693,7 @@
 			session = (switch_core_session_t *) val;
 			channel = switch_core_session_get_channel(session);
 			switch_channel_hangup(channel, cause);
+			switch_core_session_kill_channel(session, SWITCH_SIG_KILL);
 		}
 	}
 	switch_mutex_unlock(runtime.session_table_mutex);

Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c	(original)
+++ freeswitch/trunk/src/switch_ivr.c	Wed Feb 21 01:35:55 2007
@@ -1218,6 +1218,14 @@
 
 	if (!fh->audio_buffer) {
 		switch_buffer_create_dynamic(&fh->audio_buffer, FILE_BLOCKSIZE, FILE_BUFSIZE, 0);
+		if (!fh->audio_buffer) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup buffer failed\n");
+
+			switch_core_file_close(fh);
+			switch_core_session_reset(session);
+			
+			return SWITCH_STATUS_GENERR;
+		}
 	} 
 
 	if (asis) {
@@ -1334,7 +1342,10 @@
 			olen = asis ? framelen : ilen;
 			do_speed = 0;
 		} else {
-			olen = 32 * framelen;
+			olen = sizeof(abuf);
+			if (!asis) {
+				olen /= 2;
+			}
 			switch_core_file_read(fh, abuf, &olen);
 			switch_buffer_write(fh->audio_buffer, abuf, asis ? olen : olen * 2);
 			olen = switch_buffer_read(fh->audio_buffer, abuf, framelen);



More information about the Freeswitch-svn mailing list