[Freeswitch-svn] [commit] r13147 - freeswitch/trunk/src/mod/endpoints/mod_loopback
FreeSWITCH SVN
anthm at freeswitch.org
Sat Apr 25 10:03:04 PDT 2009
Author: anthm
Date: Sat Apr 25 12:03:04 2009
New Revision: 13147
Log:
make mod_loopback render silence to prevent livelock
Modified:
freeswitch/trunk/src/mod/endpoints/mod_loopback/mod_loopback.c
Modified: freeswitch/trunk/src/mod/endpoints/mod_loopback/mod_loopback.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_loopback/mod_loopback.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_loopback/mod_loopback.c Sat Apr 25 12:03:04 2009
@@ -73,7 +73,7 @@
unsigned char write_databuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
switch_frame_t cng_frame;
- unsigned char cng_databuf[10];
+ unsigned char cng_databuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
switch_timer_t timer;
switch_caller_profile_t *caller_profile;
int32_t bowout_frame_count;
@@ -162,7 +162,7 @@
tech_pvt->cng_frame.data = tech_pvt->cng_databuf;
tech_pvt->cng_frame.buflen = sizeof(tech_pvt->cng_databuf);
- switch_set_flag((&tech_pvt->cng_frame), SFF_CNG);
+ //switch_set_flag((&tech_pvt->cng_frame), SFF_CNG);
tech_pvt->cng_frame.datalen = 2;
tech_pvt->bowout_frame_count = (tech_pvt->read_codec.implementation->actual_samples_per_second /
@@ -564,9 +564,34 @@
}
if (switch_test_flag(tech_pvt, TFLAG_CNG)) {
+ unsigned char data[SWITCH_RECOMMENDED_BUFFER_SIZE];
+ uint32_t flag = 0;
+ switch_status_t status;
+ uint32_t rate = tech_pvt->read_codec.implementation->actual_samples_per_second;
+
*frame = &tech_pvt->cng_frame;
tech_pvt->cng_frame.codec = &tech_pvt->read_codec;
- switch_set_flag((&tech_pvt->cng_frame), SFF_CNG);
+ tech_pvt->cng_frame.datalen = tech_pvt->read_codec.implementation->decoded_bytes_per_packet;
+ memset(tech_pvt->cng_frame.data, 0, tech_pvt->cng_frame.datalen);
+
+ if (strcasecmp(tech_pvt->read_codec.implementation->iananame, "L16")) {
+ status = switch_core_codec_encode(&tech_pvt->read_codec,
+ NULL,
+ data,
+ sizeof(data),
+ tech_pvt->read_codec.implementation->actual_samples_per_second,
+
+ tech_pvt->cng_frame.data,
+ &tech_pvt->cng_frame.datalen,
+ &rate,
+ &flag);
+ if (status != SWITCH_STATUS_SUCCESS) {
+ switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+ }
+
+ }
+
+ //switch_set_flag((&tech_pvt->cng_frame), SFF_CNG);
switch_clear_flag_locked(tech_pvt, TFLAG_CNG);
}
More information about the Freeswitch-svn
mailing list