diff --git a/src/switch_ivr.c b/src/switch_ivr.c index 52a9e6a602..280a6e2155 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -1146,7 +1146,9 @@ SWITCH_DECLARE(void *) switch_ivr_digit_stream_parser_feed(switch_ivr_digit_stre } *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; diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c index 42f0f21b5e..c1c8a4282f 100644 --- a/src/switch_ivr_originate.c +++ b/src/switch_ivr_originate.c @@ -233,7 +233,7 @@ static int teletone_handler(teletone_generation_session_t * ts, teletone_tone_ma 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, diff --git a/src/switch_ivr_play_say.c b/src/switch_ivr_play_say.c index 4c2ceb3217..46e9f04e39 100644 --- a/src/switch_ivr_play_say.c +++ b/src/switch_ivr_play_say.c @@ -663,7 +663,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_gentones(switch_core_session_t *sessi 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 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess 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 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess if (!file) { - return SWITCH_STATUS_FALSE; + status = SWITCH_STATUS_FALSE; + goto end; } if (!prefix) { @@ -741,7 +744,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess 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 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess 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_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess switch_core_file_close(fh); switch_core_session_reset(session); - return SWITCH_STATUS_GENERR; + status = SWITCH_STATUS_GENERR; + goto end; } } @@ -831,7 +836,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess "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_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess 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 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess olen = asis ? framelen : ilen; do_speed = 0; } else { - olen = sizeof(abuf); + olen = FILE_STARTSAMPLES; if (!asis) { olen /= 2; } @@ -1085,6 +1092,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess switch_core_timer_destroy(&timer); } + + end: + free(abuf); + switch_core_session_reset(session); return status; } diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 9447f1bc78..170f88142e 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -171,6 +171,7 @@ struct switch_rtp { 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 @@ SWITCH_DECLARE(int) switch_rtp_write_manual(switch_rtp_t *rtp_session, 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 @@ SWITCH_DECLARE(int) switch_rtp_write_manual(switch_rtp_t *rtp_session, 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 @@ SWITCH_DECLARE(int) switch_rtp_write_manual(switch_rtp_t *rtp_session, 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 @@ SWITCH_DECLARE(int) switch_rtp_write_manual(switch_rtp_t *rtp_session, 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;