[Freeswitch-trunk] [commit] r6867 - freeswitch/trunk/src

Freeswitch SVN anthm at freeswitch.org
Tue Dec 18 12:33:29 EST 2007


Author: anthm
Date: Tue Dec 18 12:33:29 2007
New Revision: 6867

Modified:
   freeswitch/trunk/src/switch_ivr.c
   freeswitch/trunk/src/switch_ivr_originate.c
   freeswitch/trunk/src/switch_ivr_play_say.c
   freeswitch/trunk/src/switch_rtp.c

Log:
opts

Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c	(original)
+++ freeswitch/trunk/src/switch_ivr.c	Tue Dec 18 12:33:29 2007
@@ -1146,7 +1146,9 @@
 					}
 					*dst = digit;
 				} else {
-					stream->digits = realloc(stream->digits, len + 2);
+					char *tmp = realloc(stream->digits, len + 2);
+					switch_assert(tmp);
+					stream->digits = tmp;
 					*(stream->digits + (len++)) = digit;
 					*(stream->digits + len) = '\0';
 					stream->last_digit_time = switch_time_now() / 1000;

Modified: freeswitch/trunk/src/switch_ivr_originate.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_originate.c	(original)
+++ freeswitch/trunk/src/switch_ivr_originate.c	Tue Dec 18 12:33:29 2007
@@ -233,7 +233,7 @@
 	return 0;
 }
 
-#define MAX_PEERS 256
+#define MAX_PEERS 128
 SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *session,
 													 switch_core_session_t **bleg,
 													 switch_call_cause_t *cause,

Modified: freeswitch/trunk/src/switch_ivr_play_say.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_play_say.c	(original)
+++ freeswitch/trunk/src/switch_ivr_play_say.c	Tue Dec 18 12:33:29 2007
@@ -663,7 +663,7 @@
 SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *session, switch_file_handle_t *fh, const char *file, switch_input_args_t *args)
 {
 	switch_channel_t *channel;
-	int16_t abuf[FILE_STARTSAMPLES];
+	int16_t *abuf;
 	char dtmf[128];
 	uint32_t interval = 0, samples = 0, framelen, sample_start = 0;
 	uint32_t ilen = 0;
@@ -686,6 +686,8 @@
 	const char *timer_name;
 	const char *prebuf;
 
+	switch_zmalloc(abuf, FILE_STARTSAMPLES);
+
 	channel = switch_core_session_get_channel(session);
 	switch_assert(channel != NULL);
 
@@ -694,7 +696,8 @@
 
 
 	if (!file) {
-		return SWITCH_STATUS_FALSE;
+		status = SWITCH_STATUS_FALSE;
+		goto end;
 	}
 
 	if (!prefix) {
@@ -741,7 +744,8 @@
 							  read_codec->implementation->actual_samples_per_second,
 							  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
 		switch_core_session_reset(session);
-		return SWITCH_STATUS_NOTFOUND;
+		status = SWITCH_STATUS_NOTFOUND;
+		goto end;
 	}
 	if (switch_test_flag(fh, SWITCH_FILE_NATIVE)) {
 		asis = 1;
@@ -749,7 +753,7 @@
 
 
 	write_frame.data = abuf;
-	write_frame.buflen = sizeof(abuf);
+	write_frame.buflen = FILE_STARTSAMPLES;
 
 	if (sample_start > 0) {
 		uint32_t pos = 0;
@@ -806,7 +810,8 @@
 			switch_core_file_close(fh);
 			switch_core_session_reset(session);
 
-			return SWITCH_STATUS_GENERR;
+			status = SWITCH_STATUS_GENERR;
+			goto end;
 		}
 	}
 
@@ -831,7 +836,8 @@
 							  "Raw Codec Activation Failed %s@%uhz %u channels %dms\n", codec_name, fh->samplerate, fh->channels, interval);
 			switch_core_file_close(fh);
 			switch_core_session_reset(session);
-			return SWITCH_STATUS_GENERR;
+			status = SWITCH_STATUS_GENERR;
+			goto end;
 		}
 		samples = codec.implementation->samples_per_frame;
 		framelen = codec.implementation->bytes_per_frame;
@@ -847,7 +853,8 @@
 			switch_core_codec_destroy(&codec);
 			switch_core_file_close(fh);
 			switch_core_session_reset(session);
-			return SWITCH_STATUS_GENERR;
+			status = SWITCH_STATUS_GENERR;
+			goto end;
 		}
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer success %u bytes per %d ms!\n", len, interval);
 	}
@@ -926,7 +933,7 @@
 			olen = asis ? framelen : ilen;
 			do_speed = 0;
 		} else {
-			olen = sizeof(abuf);
+			olen = FILE_STARTSAMPLES;
 			if (!asis) {
 				olen /= 2;
 			}
@@ -1085,6 +1092,10 @@
 		switch_core_timer_destroy(&timer);
 	}
 
+
+ end:
+	free(abuf);
+
 	switch_core_session_reset(session);
 	return status;
 }

Modified: freeswitch/trunk/src/switch_rtp.c
==============================================================================
--- freeswitch/trunk/src/switch_rtp.c	(original)
+++ freeswitch/trunk/src/switch_rtp.c	Tue Dec 18 12:33:29 2007
@@ -171,6 +171,7 @@
 	stfu_instance_t *jb;
 	uint32_t max_missed_packets;
 	uint32_t missed_count;
+	rtp_msg_t write_msg;
 };
 
 static int global_init = 0;
@@ -1645,7 +1646,6 @@
 											uint32_t datalen,
 											uint8_t m, switch_payload_t payload, uint32_t ts, uint16_t mseq, uint32_t ssrc, switch_frame_flag_t *flags)
 {
-	rtp_msg_t send_msg = { {0} };
 	switch_size_t bytes;
 
 	if (!switch_rtp_ready(rtp_session)) {
@@ -1660,13 +1660,13 @@
 		return -1;
 	}
 
-	send_msg = rtp_session->send_msg;
-	send_msg.header.seq = htons(mseq);
-	send_msg.header.ts = htonl(ts);
-	send_msg.header.ssrc = htonl(ssrc);
-	send_msg.header.pt = payload;
-	send_msg.header.m = m ? 1 : 0;
-	memcpy(send_msg.body, data, datalen);
+	rtp_session->write_msg = rtp_session->send_msg;
+	rtp_session->write_msg.header.seq = htons(mseq);
+	rtp_session->write_msg.header.ts = htonl(ts);
+	rtp_session->write_msg.header.ssrc = htonl(ssrc);
+	rtp_session->write_msg.header.pt = payload;
+	rtp_session->write_msg.header.m = m ? 1 : 0;
+	memcpy(rtp_session->write_msg.body, data, datalen);
 
 	bytes = rtp_header_len + datalen;
 
@@ -1675,7 +1675,7 @@
 		int sbytes = (int) bytes;
 		err_status_t stat;
 
-		stat = srtp_protect(rtp_session->send_ctx, &send_msg.header, &sbytes);
+		stat = srtp_protect(rtp_session->send_ctx, &rtp_session->write_msg.header, &sbytes);
 		if (stat) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error: srtp protection failed with code %d\n", stat);
 		}
@@ -1683,7 +1683,7 @@
 		bytes = sbytes;
 	}
 
-	if (switch_socket_sendto(rtp_session->sock, rtp_session->remote_addr, 0, (void *) &send_msg, &bytes) != SWITCH_STATUS_SUCCESS) {
+	if (switch_socket_sendto(rtp_session->sock, rtp_session->remote_addr, 0, (void *) &rtp_session->write_msg, &bytes) != SWITCH_STATUS_SUCCESS) {
 		return -1;
 	}
 	return (int) bytes;



More information about the Freeswitch-trunk mailing list