mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-15 13:14:03 +00:00
add record_fill_cng var
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16964 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
b2c281035c
commit
cf521109d2
@ -364,7 +364,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
|
|||||||
time_t start = 0;
|
time_t start = 0;
|
||||||
uint32_t org_silence_hits = 0;
|
uint32_t org_silence_hits = 0;
|
||||||
int asis = 0;
|
int asis = 0;
|
||||||
int waste_resources = 0;
|
int waste_resources = 0, fill_cng = 0;
|
||||||
switch_codec_implementation_t read_impl = { 0 };
|
switch_codec_implementation_t read_impl = { 0 };
|
||||||
switch_frame_t write_frame = { 0 };
|
switch_frame_t write_frame = { 0 };
|
||||||
unsigned char write_buf[SWITCH_RECOMMENDED_BUFFER_SIZE] = { 0 };
|
unsigned char write_buf[SWITCH_RECOMMENDED_BUFFER_SIZE] = { 0 };
|
||||||
@ -416,6 +416,18 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ((vval = switch_channel_get_variable(channel, "record_fill_cng"))) {
|
||||||
|
|
||||||
|
if (switch_true(vval)) {
|
||||||
|
fill_cng = 1400;
|
||||||
|
} else {
|
||||||
|
if ((fill_cng = atoi(vval)) < 0) {
|
||||||
|
fill_cng = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ((vval = switch_channel_get_variable(channel, "record_waste_resources"))) {
|
if ((vval = switch_channel_get_variable(channel, "record_waste_resources"))) {
|
||||||
|
|
||||||
if (switch_true(vval)) {
|
if (switch_true(vval)) {
|
||||||
@ -425,7 +437,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
|
|||||||
waste_resources = 0;
|
waste_resources = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (fill_cng || waste_resources) {
|
||||||
if (switch_core_codec_init(&write_codec,
|
if (switch_core_codec_init(&write_codec,
|
||||||
"L16",
|
"L16",
|
||||||
NULL,
|
NULL,
|
||||||
@ -665,6 +680,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fill_cng || waste_resources) {
|
||||||
|
switch_generate_sln_silence((int16_t *) write_frame.data, write_frame.samples, waste_resources);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!switch_test_flag(fh, SWITCH_FILE_PAUSE) && !switch_test_flag(read_frame, SFF_CNG)) {
|
if (!switch_test_flag(fh, SWITCH_FILE_PAUSE) && !switch_test_flag(read_frame, SFF_CNG)) {
|
||||||
int16_t *data = read_frame->data;
|
int16_t *data = read_frame->data;
|
||||||
len = (switch_size_t) asis ? read_frame->datalen : read_frame->datalen / 2;
|
len = (switch_size_t) asis ? read_frame->datalen : read_frame->datalen / 2;
|
||||||
@ -672,10 +692,14 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
|
|||||||
if (switch_core_file_write(fh, data, &len) != SWITCH_STATUS_SUCCESS) {
|
if (switch_core_file_write(fh, data, &len) != SWITCH_STATUS_SUCCESS) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} else if (switch_test_flag(read_frame, SFF_CNG)) {
|
||||||
|
len = write_frame.datalen;
|
||||||
|
if (switch_core_file_write(fh, write_frame.data, &len) != SWITCH_STATUS_SUCCESS) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (waste_resources) {
|
if (waste_resources) {
|
||||||
switch_generate_sln_silence((int16_t *) write_frame.data, write_frame.samples, waste_resources);
|
|
||||||
if (switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) {
|
if (switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user