mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-14 21:38:34 +00:00
improve voicemail
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6399 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
1 parent
5dfde04160
commit
f64d7e43ce
13 files changed
+1323
-89
No files matched your search
+34
-11
@@ -348,6 +348,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
|
||||
const char *vval;
|
||||
time_t start = 0;
|
||||
uint32_t org_silence_hits = 0;
|
||||
switch_audio_resampler_t *resampler = NULL;
|
||||
int16_t resamp_out[2048];
|
||||
|
||||
if (!fh) {
|
||||
fh = &lfh;
|
||||
@@ -360,13 +362,27 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
|
||||
assert(read_codec != NULL);
|
||||
|
||||
fh->channels = read_codec->implementation->number_of_channels;
|
||||
fh->samplerate = read_codec->implementation->actual_samples_per_second;
|
||||
|
||||
if (fh->samplerate) {
|
||||
if (fh->samplerate != read_codec->implementation->actual_samples_per_second) {
|
||||
if (switch_resample_create(&resampler,
|
||||
read_codec->implementation->actual_samples_per_second,
|
||||
read_codec->implementation->actual_samples_per_second * 20,
|
||||
fh->samplerate,
|
||||
fh->samplerate * 20,
|
||||
switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unable to create resampler!\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fh->samplerate = read_codec->implementation->actual_samples_per_second;
|
||||
}
|
||||
|
||||
if (switch_core_file_open(fh,
|
||||
file,
|
||||
read_codec->implementation->number_of_channels,
|
||||
read_codec->implementation->actual_samples_per_second,
|
||||
fh->channels,
|
||||
fh->samplerate,
|
||||
SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
switch_core_session_reset(session);
|
||||
@@ -539,7 +555,17 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
|
||||
|
||||
if (!switch_test_flag(fh, SWITCH_FILE_PAUSE)) {
|
||||
len = (switch_size_t) read_frame->datalen / 2;
|
||||
if (switch_core_file_write(fh, read_frame->data, &len) != SWITCH_STATUS_SUCCESS) {
|
||||
int16_t *data = read_frame->data;
|
||||
|
||||
if (resampler) {
|
||||
resampler->from_len = switch_short_to_float(read_frame->data, resampler->from, (int) len);
|
||||
resampler->to_len = switch_resample_process(resampler, resampler->from, resampler->from_len, resampler->to, resampler->to_size, 0);
|
||||
switch_float_to_short(resampler->to, resamp_out, read_frame->datalen);
|
||||
len = resampler->to_len;
|
||||
data = resamp_out;
|
||||
}
|
||||
|
||||
if (switch_core_file_write(fh, data, &len) != SWITCH_STATUS_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -609,28 +635,25 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_gentones(switch_core_session_t *sessi
|
||||
}
|
||||
|
||||
for(;;) {
|
||||
switch_status_t status = switch_core_session_read_frame(session, &read_frame, 1000, 0);
|
||||
|
||||
switch_status_t status;
|
||||
|
||||
if (!switch_channel_ready(channel)) {
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (switch_channel_test_flag(channel, CF_BREAK)) {
|
||||
switch_channel_clear_flag(channel, CF_BREAK);
|
||||
status = SWITCH_STATUS_BREAK;
|
||||
break;
|
||||
}
|
||||
|
||||
status = switch_core_session_read_frame(session, &read_frame, 1000, 0);
|
||||
|
||||
if (!SWITCH_READ_ACCEPTABLE(status)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (read_frame->datalen < 2 || switch_test_flag(read_frame, SFF_CNG)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (args && (args->read_frame_callback)) {
|
||||
if (args->read_frame_callback(session, read_frame, args->user_data) != SWITCH_STATUS_SUCCESS) {
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user