mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-13 12:40:17 +00:00
opts
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6867 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
b181a75419
commit
73f501852c
@ -1146,7 +1146,9 @@ SWITCH_DECLARE(void *) switch_ivr_digit_stream_parser_feed(switch_ivr_digit_stre
|
|||||||
}
|
}
|
||||||
*dst = digit;
|
*dst = digit;
|
||||||
} else {
|
} 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++)) = digit;
|
||||||
*(stream->digits + len) = '\0';
|
*(stream->digits + len) = '\0';
|
||||||
stream->last_digit_time = switch_time_now() / 1000;
|
stream->last_digit_time = switch_time_now() / 1000;
|
||||||
|
@ -233,7 +233,7 @@ static int teletone_handler(teletone_generation_session_t * ts, teletone_tone_ma
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAX_PEERS 256
|
#define MAX_PEERS 128
|
||||||
SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *session,
|
SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *session,
|
||||||
switch_core_session_t **bleg,
|
switch_core_session_t **bleg,
|
||||||
switch_call_cause_t *cause,
|
switch_call_cause_t *cause,
|
||||||
|
@ -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_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;
|
switch_channel_t *channel;
|
||||||
int16_t abuf[FILE_STARTSAMPLES];
|
int16_t *abuf;
|
||||||
char dtmf[128];
|
char dtmf[128];
|
||||||
uint32_t interval = 0, samples = 0, framelen, sample_start = 0;
|
uint32_t interval = 0, samples = 0, framelen, sample_start = 0;
|
||||||
uint32_t ilen = 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 *timer_name;
|
||||||
const char *prebuf;
|
const char *prebuf;
|
||||||
|
|
||||||
|
switch_zmalloc(abuf, FILE_STARTSAMPLES);
|
||||||
|
|
||||||
channel = switch_core_session_get_channel(session);
|
channel = switch_core_session_get_channel(session);
|
||||||
switch_assert(channel != NULL);
|
switch_assert(channel != NULL);
|
||||||
|
|
||||||
@ -694,7 +696,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
|
|||||||
|
|
||||||
|
|
||||||
if (!file) {
|
if (!file) {
|
||||||
return SWITCH_STATUS_FALSE;
|
status = SWITCH_STATUS_FALSE;
|
||||||
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!prefix) {
|
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,
|
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_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_core_session_reset(session);
|
switch_core_session_reset(session);
|
||||||
return SWITCH_STATUS_NOTFOUND;
|
status = SWITCH_STATUS_NOTFOUND;
|
||||||
|
goto end;
|
||||||
}
|
}
|
||||||
if (switch_test_flag(fh, SWITCH_FILE_NATIVE)) {
|
if (switch_test_flag(fh, SWITCH_FILE_NATIVE)) {
|
||||||
asis = 1;
|
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.data = abuf;
|
||||||
write_frame.buflen = sizeof(abuf);
|
write_frame.buflen = FILE_STARTSAMPLES;
|
||||||
|
|
||||||
if (sample_start > 0) {
|
if (sample_start > 0) {
|
||||||
uint32_t pos = 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_file_close(fh);
|
||||||
switch_core_session_reset(session);
|
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);
|
"Raw Codec Activation Failed %s@%uhz %u channels %dms\n", codec_name, fh->samplerate, fh->channels, interval);
|
||||||
switch_core_file_close(fh);
|
switch_core_file_close(fh);
|
||||||
switch_core_session_reset(session);
|
switch_core_session_reset(session);
|
||||||
return SWITCH_STATUS_GENERR;
|
status = SWITCH_STATUS_GENERR;
|
||||||
|
goto end;
|
||||||
}
|
}
|
||||||
samples = codec.implementation->samples_per_frame;
|
samples = codec.implementation->samples_per_frame;
|
||||||
framelen = codec.implementation->bytes_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_codec_destroy(&codec);
|
||||||
switch_core_file_close(fh);
|
switch_core_file_close(fh);
|
||||||
switch_core_session_reset(session);
|
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);
|
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;
|
olen = asis ? framelen : ilen;
|
||||||
do_speed = 0;
|
do_speed = 0;
|
||||||
} else {
|
} else {
|
||||||
olen = sizeof(abuf);
|
olen = FILE_STARTSAMPLES;
|
||||||
if (!asis) {
|
if (!asis) {
|
||||||
olen /= 2;
|
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);
|
switch_core_timer_destroy(&timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
end:
|
||||||
|
free(abuf);
|
||||||
|
|
||||||
switch_core_session_reset(session);
|
switch_core_session_reset(session);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -171,6 +171,7 @@ struct switch_rtp {
|
|||||||
stfu_instance_t *jb;
|
stfu_instance_t *jb;
|
||||||
uint32_t max_missed_packets;
|
uint32_t max_missed_packets;
|
||||||
uint32_t missed_count;
|
uint32_t missed_count;
|
||||||
|
rtp_msg_t write_msg;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int global_init = 0;
|
static int global_init = 0;
|
||||||
@ -1645,7 +1646,6 @@ SWITCH_DECLARE(int) switch_rtp_write_manual(switch_rtp_t *rtp_session,
|
|||||||
uint32_t datalen,
|
uint32_t datalen,
|
||||||
uint8_t m, switch_payload_t payload, uint32_t ts, uint16_t mseq, uint32_t ssrc, switch_frame_flag_t *flags)
|
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;
|
switch_size_t bytes;
|
||||||
|
|
||||||
if (!switch_rtp_ready(rtp_session)) {
|
if (!switch_rtp_ready(rtp_session)) {
|
||||||
@ -1660,13 +1660,13 @@ SWITCH_DECLARE(int) switch_rtp_write_manual(switch_rtp_t *rtp_session,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
send_msg = rtp_session->send_msg;
|
rtp_session->write_msg = rtp_session->send_msg;
|
||||||
send_msg.header.seq = htons(mseq);
|
rtp_session->write_msg.header.seq = htons(mseq);
|
||||||
send_msg.header.ts = htonl(ts);
|
rtp_session->write_msg.header.ts = htonl(ts);
|
||||||
send_msg.header.ssrc = htonl(ssrc);
|
rtp_session->write_msg.header.ssrc = htonl(ssrc);
|
||||||
send_msg.header.pt = payload;
|
rtp_session->write_msg.header.pt = payload;
|
||||||
send_msg.header.m = m ? 1 : 0;
|
rtp_session->write_msg.header.m = m ? 1 : 0;
|
||||||
memcpy(send_msg.body, data, datalen);
|
memcpy(rtp_session->write_msg.body, data, datalen);
|
||||||
|
|
||||||
bytes = rtp_header_len + 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;
|
int sbytes = (int) bytes;
|
||||||
err_status_t stat;
|
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) {
|
if (stat) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error: srtp protection failed with code %d\n", 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;
|
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 -1;
|
||||||
}
|
}
|
||||||
return (int) bytes;
|
return (int) bytes;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user