freeswitch-branches
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
January 2009
- 5 participants
- 136 discussions
[Freeswitch-branches] [commit] r11433 - freeswitch/branches/1.0/src/mod/endpoints/mod_sofia
by FreeSWITCH SVN 22 Jan '09
by FreeSWITCH SVN 22 Jan '09
22 Jan '09
Author: mikej
Date: Thu Jan 22 17:19:52 2009
New Revision: 11433
Log:
mod_sofia: fix codec change race condition (r:11143)
Modified:
freeswitch/branches/1.0/src/mod/endpoints/mod_sofia/mod_sofia.c
freeswitch/branches/1.0/src/mod/endpoints/mod_sofia/mod_sofia.h
freeswitch/branches/1.0/src/mod/endpoints/mod_sofia/sofia_glue.c
Modified: freeswitch/branches/1.0/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/branches/1.0/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/branches/1.0/src/mod/endpoints/mod_sofia/mod_sofia.c Thu Jan 22 17:19:52 2009
@@ -709,14 +709,14 @@
}
if (tech_pvt->check_frames++ < MAX_CODEC_CHECK_FRAMES) {
- if (!tech_pvt->read_codec.implementation->encoded_bytes_per_packet) {
+ if (!tech_pvt->read_impl.encoded_bytes_per_packet) {
tech_pvt->check_frames = MAX_CODEC_CHECK_FRAMES;
goto skip;
}
- if (tech_pvt->last_ts && tech_pvt->read_frame.datalen != tech_pvt->read_codec.implementation->encoded_bytes_per_packet) {
+ if (tech_pvt->last_ts && tech_pvt->read_frame.datalen != tech_pvt->read_impl.encoded_bytes_per_packet) {
switch_size_t codec_ms = (int)(tech_pvt->read_frame.timestamp -
- tech_pvt->last_ts) / (tech_pvt->read_codec.implementation->samples_per_second / 1000);
+ tech_pvt->last_ts) / (tech_pvt->read_impl.samples_per_second / 1000);
if ((codec_ms % 10) != 0) {
tech_pvt->check_frames = MAX_CODEC_CHECK_FRAMES;
@@ -768,8 +768,8 @@
}
if (rtp_timeout_sec) {
- tech_pvt->max_missed_packets = (tech_pvt->read_codec.implementation->samples_per_second * rtp_timeout_sec) /
- tech_pvt->read_codec.implementation->samples_per_packet;
+ tech_pvt->max_missed_packets = (tech_pvt->read_impl.samples_per_second * rtp_timeout_sec) /
+ tech_pvt->read_impl.samples_per_packet;
switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_packets);
if (!rtp_hold_timeout_sec) {
@@ -778,13 +778,13 @@
}
if (rtp_hold_timeout_sec) {
- tech_pvt->max_missed_hold_packets = (tech_pvt->read_codec.implementation->samples_per_second * rtp_hold_timeout_sec) /
- tech_pvt->read_codec.implementation->samples_per_packet;
+ tech_pvt->max_missed_hold_packets = (tech_pvt->read_impl.samples_per_second * rtp_hold_timeout_sec) /
+ tech_pvt->read_impl.samples_per_packet;
}
if (switch_rtp_change_interval(tech_pvt->rtp_session,
tech_pvt->codec_ms * 1000,
- tech_pvt->read_codec.implementation->samples_per_packet
+ tech_pvt->read_impl.samples_per_packet
) != SWITCH_STATUS_SUCCESS) {
switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
@@ -806,10 +806,10 @@
}
skip:
- if ((bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_packet)) {
+ if ((bytes = tech_pvt->read_impl.encoded_bytes_per_packet)) {
frames = (tech_pvt->read_frame.datalen / bytes);
}
- tech_pvt->read_frame.samples = (int) (frames * tech_pvt->read_codec.implementation->samples_per_packet);
+ tech_pvt->read_frame.samples = (int) (frames * tech_pvt->read_impl.samples_per_packet);
if (tech_pvt->read_frame.datalen == 0) {
continue;
@@ -872,13 +872,13 @@
switch_set_flag_locked(tech_pvt, TFLAG_WRITING);
if (!switch_test_flag(frame, SFF_CNG) && !switch_test_flag(frame, SFF_PROXY_PACKET)) {
- if (tech_pvt->read_codec.implementation->encoded_bytes_per_packet) {
- bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_packet;
+ if (tech_pvt->read_impl.encoded_bytes_per_packet) {
+ bytes = tech_pvt->read_impl.encoded_bytes_per_packet;
frames = ((int) frame->datalen / bytes);
} else
frames = 1;
- samples = frames * tech_pvt->read_codec.implementation->samples_per_packet;
+ samples = frames * tech_pvt->read_impl.samples_per_packet;
}
tech_pvt->timestamp_send += samples;
Modified: freeswitch/branches/1.0/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/branches/1.0/src/mod/endpoints/mod_sofia/mod_sofia.h (original)
+++ freeswitch/branches/1.0/src/mod/endpoints/mod_sofia/mod_sofia.h Thu Jan 22 17:19:52 2009
@@ -553,6 +553,8 @@
uint32_t last_codec_ms;
nua_event_t want_event;
switch_rtp_bug_flag_t rtp_bugs;
+ switch_codec_implementation_t read_impl;
+ switch_codec_implementation_t write_impl;
};
struct callback_t {
Modified: freeswitch/branches/1.0/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/branches/1.0/src/mod/endpoints/mod_sofia/sofia_glue.c (original)
+++ freeswitch/branches/1.0/src/mod/endpoints/mod_sofia/sofia_glue.c Thu Jan 22 17:19:52 2009
@@ -1654,9 +1654,13 @@
switch_goto_status(SWITCH_STATUS_FALSE, end);
}
+ tech_pvt->read_impl = *tech_pvt->read_codec.implementation;
+ tech_pvt->write_impl = *tech_pvt->write_codec.implementation;
+
+
if (switch_rtp_ready(tech_pvt->rtp_session)) {
switch_assert(tech_pvt->read_codec.implementation);
- switch_rtp_set_default_samples_per_interval(tech_pvt->rtp_session, tech_pvt->read_codec.implementation->samples_per_packet);
+ switch_rtp_set_default_samples_per_interval(tech_pvt->rtp_session, tech_pvt->read_impl.samples_per_packet);
}
tech_pvt->read_frame.rate = tech_pvt->rm_rate;
@@ -1669,7 +1673,7 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set Codec %s %s/%ld %d ms %d samples\n",
switch_channel_get_name(tech_pvt->channel), tech_pvt->iananame, tech_pvt->rm_rate, tech_pvt->codec_ms,
- tech_pvt->read_codec.implementation->samples_per_packet);
+ tech_pvt->read_impl.samples_per_packet);
tech_pvt->read_frame.codec = &tech_pvt->read_codec;
tech_pvt->write_codec.agreed_pt = tech_pvt->agreed_pt;
@@ -1832,8 +1836,8 @@
goto end;
}
- bw = tech_pvt->read_codec.implementation->bits_per_second;
- ms = tech_pvt->read_codec.implementation->microseconds_per_packet;
+ bw = tech_pvt->read_impl.bits_per_second;
+ ms = tech_pvt->read_impl.microseconds_per_packet;
if (myflags) {
flags = myflags;
@@ -1892,7 +1896,7 @@
tech_pvt->local_sdp_audio_ip,
tech_pvt->local_sdp_audio_port,
tech_pvt->remote_sdp_audio_ip,
- tech_pvt->remote_sdp_audio_port, tech_pvt->agreed_pt, tech_pvt->read_codec.implementation->microseconds_per_packet / 1000);
+ tech_pvt->remote_sdp_audio_port, tech_pvt->agreed_pt, tech_pvt->read_impl.microseconds_per_packet / 1000);
}
switch_snprintf(tmp, sizeof(tmp), "%d", tech_pvt->local_sdp_audio_port);
@@ -1934,7 +1938,7 @@
tech_pvt->local_sdp_audio_ip,
tech_pvt->local_sdp_audio_port,
tech_pvt->remote_sdp_audio_ip,
- tech_pvt->remote_sdp_audio_port, tech_pvt->agreed_pt, tech_pvt->read_codec.implementation->microseconds_per_packet / 1000);
+ tech_pvt->remote_sdp_audio_port, tech_pvt->agreed_pt, tech_pvt->read_impl.microseconds_per_packet / 1000);
} else {
timer_name = tech_pvt->profile->timer_name;
@@ -1949,7 +1953,7 @@
tech_pvt->remote_sdp_audio_ip,
tech_pvt->remote_sdp_audio_port,
tech_pvt->agreed_pt,
- tech_pvt->read_codec.implementation->samples_per_packet,
+ tech_pvt->read_impl.samples_per_packet,
tech_pvt->codec_ms * 1000,
(switch_rtp_flag_t) flags, timer_name, &err, switch_core_session_get_pool(tech_pvt->session));
@@ -1982,7 +1986,7 @@
}
}
- stun_ping = (ival * tech_pvt->read_codec.implementation->samples_per_second) / tech_pvt->read_codec.implementation->samples_per_packet;
+ stun_ping = (ival * tech_pvt->read_impl.samples_per_second) / tech_pvt->read_impl.samples_per_packet;
}
tech_pvt->ssrc = switch_rtp_get_ssrc(tech_pvt->rtp_session);
@@ -2012,7 +2016,7 @@
} else {
int qlen;
- qlen = len / (tech_pvt->read_codec.implementation->microseconds_per_packet / 1000);
+ qlen = len / (tech_pvt->read_impl.microseconds_per_packet / 1000);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Setting Jitterbuffer to %dms (%d frames)\n", len, qlen);
switch_rtp_activate_jitter_buffer(tech_pvt->rtp_session, qlen);
@@ -2034,8 +2038,8 @@
}
if (rtp_timeout_sec) {
- tech_pvt->max_missed_packets = (tech_pvt->read_codec.implementation->samples_per_second * rtp_timeout_sec) /
- tech_pvt->read_codec.implementation->samples_per_packet;
+ tech_pvt->max_missed_packets = (tech_pvt->read_impl.samples_per_second * rtp_timeout_sec) /
+ tech_pvt->read_impl.samples_per_packet;
switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_packets);
if (!rtp_hold_timeout_sec) {
@@ -2044,8 +2048,8 @@
}
if (rtp_hold_timeout_sec) {
- tech_pvt->max_missed_hold_packets = (tech_pvt->read_codec.implementation->samples_per_second * rtp_hold_timeout_sec) /
- tech_pvt->read_codec.implementation->samples_per_packet;
+ tech_pvt->max_missed_hold_packets = (tech_pvt->read_impl.samples_per_second * rtp_hold_timeout_sec) /
+ tech_pvt->read_impl.samples_per_packet;
}
if (tech_pvt->te) {
1
0
22 Jan '09
Author: mikej
Date: Thu Jan 22 17:17:38 2009
New Revision: 11432
Log:
Modified:
freeswitch/branches/1.0/src/switch_core_io.c
Modified: freeswitch/branches/1.0/src/switch_core_io.c
==============================================================================
--- freeswitch/branches/1.0/src/switch_core_io.c (original)
+++ freeswitch/branches/1.0/src/switch_core_io.c Thu Jan 22 17:17:38 2009
@@ -805,7 +805,8 @@
}
if (session->write_codec) {
- if (write_frame->codec->implementation->decoded_bytes_per_packet == session->write_codec->implementation->decoded_bytes_per_packet) {
+ if (!ptime_mismatch &&
+ write_frame->codec->implementation->decoded_bytes_per_packet == session->write_codec->implementation->decoded_bytes_per_packet) {
perfect = TRUE;
} else {
if (!session->raw_write_buffer) {
1
0
[Freeswitch-branches] [commit] r11431 - freeswitch/branches/1.0/scripts/contrib/mrene/mod_limit
by FreeSWITCH SVN 22 Jan '09
by FreeSWITCH SVN 22 Jan '09
22 Jan '09
Author: mikej
Date: Thu Jan 22 17:15:46 2009
New Revision: 11431
Log:
Removed:
freeswitch/branches/1.0/scripts/contrib/mrene/mod_limit/
1
0
[Freeswitch-branches] [commit] r11430 - in freeswitch/branches/1.0/src: . mod/formats/mod_local_stream mod/languages/mod_managed mod/languages/mod_managed/managed
by FreeSWITCH SVN 22 Jan '09
by FreeSWITCH SVN 22 Jan '09
22 Jan '09
Author: mikej
Date: Thu Jan 22 17:14:07 2009
New Revision: 11430
Log:
core: fix double close of file handles and add recording of native files (r:11108-11113)
Modified:
freeswitch/branches/1.0/src/mod/formats/mod_local_stream/mod_local_stream.c
freeswitch/branches/1.0/src/mod/languages/mod_managed/freeswitch_wrap.cxx
freeswitch/branches/1.0/src/mod/languages/mod_managed/managed/swig.cs
freeswitch/branches/1.0/src/switch_core_file.c
freeswitch/branches/1.0/src/switch_ivr_play_say.c
Modified: freeswitch/branches/1.0/src/mod/formats/mod_local_stream/mod_local_stream.c
==============================================================================
--- freeswitch/branches/1.0/src/mod/formats/mod_local_stream/mod_local_stream.c (original)
+++ freeswitch/branches/1.0/src/mod/formats/mod_local_stream/mod_local_stream.c Thu Jan 22 17:14:07 2009
@@ -251,7 +251,7 @@
done:
- if (fh.file_interface) {
+ if (switch_test_flag((&fh), SWITCH_FILE_OPEN)) {
switch_core_file_close(&fh);
}
Modified: freeswitch/branches/1.0/src/mod/languages/mod_managed/freeswitch_wrap.cxx
==============================================================================
--- freeswitch/branches/1.0/src/mod/languages/mod_managed/freeswitch_wrap.cxx (original)
+++ freeswitch/branches/1.0/src/mod/languages/mod_managed/freeswitch_wrap.cxx Thu Jan 22 17:14:07 2009
@@ -1510,6 +1510,17 @@
}
+SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_DEFAULT_FILE_BUFFER_LEN_get() {
+ int jresult ;
+ int result;
+
+ result = (int) 65536;
+
+ jresult = result;
+ return jresult;
+}
+
+
SWIGEXPORT void SWIGSTDCALL CSharp_switch_dtmf_t_digit_set(void * jarg1, char jarg2) {
switch_dtmf_t *arg1 = (switch_dtmf_t *) 0 ;
char arg2 ;
@@ -6143,13 +6154,15 @@
}
-SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_reset(void * jarg1, int jarg2) {
+SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_reset(void * jarg1, int jarg2, int jarg3) {
switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
switch_bool_t arg2 ;
+ switch_bool_t arg3 ;
arg1 = (switch_core_session_t *)jarg1;
arg2 = (switch_bool_t)jarg2;
- switch_core_session_reset(arg1,arg2);
+ arg3 = (switch_bool_t)jarg3;
+ switch_core_session_reset(arg1,arg2,arg3);
}
@@ -13093,6 +13106,81 @@
}
+SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_pre_buffer_set(void * jarg1, void * jarg2) {
+ switch_file_handle *arg1 = (switch_file_handle *) 0 ;
+ switch_buffer_t *arg2 = (switch_buffer_t *) 0 ;
+
+ arg1 = (switch_file_handle *)jarg1;
+ arg2 = (switch_buffer_t *)jarg2;
+ if (arg1) (arg1)->pre_buffer = arg2;
+
+}
+
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_switch_file_handle_pre_buffer_get(void * jarg1) {
+ void * jresult ;
+ switch_file_handle *arg1 = (switch_file_handle *) 0 ;
+ switch_buffer_t *result = 0 ;
+
+ arg1 = (switch_file_handle *)jarg1;
+ result = (switch_buffer_t *) ((arg1)->pre_buffer);
+ jresult = (void *)result;
+ return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_pre_buffer_data_set(void * jarg1, void * jarg2) {
+ switch_file_handle *arg1 = (switch_file_handle *) 0 ;
+ unsigned char *arg2 = (unsigned char *) 0 ;
+
+ arg1 = (switch_file_handle *)jarg1;
+ arg2 = (unsigned char *)jarg2;
+ if (arg1) (arg1)->pre_buffer_data = arg2;
+
+}
+
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_switch_file_handle_pre_buffer_data_get(void * jarg1) {
+ void * jresult ;
+ switch_file_handle *arg1 = (switch_file_handle *) 0 ;
+ unsigned char *result = 0 ;
+
+ arg1 = (switch_file_handle *)jarg1;
+ result = (unsigned char *) ((arg1)->pre_buffer_data);
+ jresult = (void *)result;
+ return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_pre_buffer_datalen_set(void * jarg1, void * jarg2) {
+ switch_file_handle *arg1 = (switch_file_handle *) 0 ;
+ switch_size_t arg2 ;
+ switch_size_t *argp2 ;
+
+ arg1 = (switch_file_handle *)jarg1;
+ argp2 = (switch_size_t *)jarg2;
+ if (!argp2) {
+ SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_size_t", 0);
+ return ;
+ }
+ arg2 = *argp2;
+ if (arg1) (arg1)->pre_buffer_datalen = arg2;
+
+}
+
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_switch_file_handle_pre_buffer_datalen_get(void * jarg1) {
+ void * jresult ;
+ switch_file_handle *arg1 = (switch_file_handle *) 0 ;
+ switch_size_t result;
+
+ arg1 = (switch_file_handle *)jarg1;
+ result = ((arg1)->pre_buffer_datalen);
+ jresult = new switch_size_t((switch_size_t &)result);
+ return jresult;
+}
+
+
SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_file_set(void * jarg1, char * jarg2) {
switch_file_handle *arg1 = (switch_file_handle *) 0 ;
char *arg2 = (char *) 0 ;
@@ -18377,6 +18465,26 @@
}
+SWIGEXPORT void SWIGSTDCALL CSharp_switch_channel_event_set_basic_data(void * jarg1, void * jarg2) {
+ switch_channel_t *arg1 = (switch_channel_t *) 0 ;
+ switch_event_t *arg2 = (switch_event_t *) 0 ;
+
+ arg1 = (switch_channel_t *)jarg1;
+ arg2 = (switch_event_t *)jarg2;
+ switch_channel_event_set_basic_data(arg1,arg2);
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_switch_channel_event_set_extended_data(void * jarg1, void * jarg2) {
+ switch_channel_t *arg1 = (switch_channel_t *) 0 ;
+ switch_event_t *arg2 = (switch_event_t *) 0 ;
+
+ arg1 = (switch_channel_t *)jarg1;
+ arg2 = (switch_event_t *)jarg2;
+ switch_channel_event_set_extended_data(arg1,arg2);
+}
+
+
SWIGEXPORT char * SWIGSTDCALL CSharp_switch_channel_expand_variables(void * jarg1, char * jarg2) {
char * jresult ;
switch_channel_t *arg1 = (switch_channel_t *) 0 ;
Modified: freeswitch/branches/1.0/src/mod/languages/mod_managed/managed/swig.cs
==============================================================================
--- freeswitch/branches/1.0/src/mod/languages/mod_managed/managed/swig.cs (original)
+++ freeswitch/branches/1.0/src/mod/languages/mod_managed/managed/swig.cs Thu Jan 22 17:14:07 2009
@@ -1344,8 +1344,8 @@
return ret;
}
- public static void switch_core_session_reset(SWIGTYPE_p_switch_core_session session, switch_bool_t flush_dtmf) {
- freeswitchPINVOKE.switch_core_session_reset(SWIGTYPE_p_switch_core_session.getCPtr(session), (int)flush_dtmf);
+ public static void switch_core_session_reset(SWIGTYPE_p_switch_core_session session, switch_bool_t flush_dtmf, switch_bool_t reset_read_codec) {
+ freeswitchPINVOKE.switch_core_session_reset(SWIGTYPE_p_switch_core_session.getCPtr(session), (int)flush_dtmf, (int)reset_read_codec);
}
public static switch_status_t switch_core_session_write_frame(SWIGTYPE_p_switch_core_session session, switch_frame frame, uint flags, int stream_id) {
@@ -2581,6 +2581,14 @@
freeswitchPINVOKE.switch_channel_event_set_data(SWIGTYPE_p_switch_channel.getCPtr(channel), switch_event.getCPtr(arg1));
}
+ public static void switch_channel_event_set_basic_data(SWIGTYPE_p_switch_channel channel, switch_event arg1) {
+ freeswitchPINVOKE.switch_channel_event_set_basic_data(SWIGTYPE_p_switch_channel.getCPtr(channel), switch_event.getCPtr(arg1));
+ }
+
+ public static void switch_channel_event_set_extended_data(SWIGTYPE_p_switch_channel channel, switch_event arg1) {
+ freeswitchPINVOKE.switch_channel_event_set_extended_data(SWIGTYPE_p_switch_channel.getCPtr(channel), switch_event.getCPtr(arg1));
+ }
+
public static string switch_channel_expand_variables(SWIGTYPE_p_switch_channel channel, string arg1) {
string ret = freeswitchPINVOKE.switch_channel_expand_variables(SWIGTYPE_p_switch_channel.getCPtr(channel), arg1);
return ret;
@@ -4109,6 +4117,7 @@
public static readonly string SWITCH_SPEECH_KEY = freeswitchPINVOKE.SWITCH_SPEECH_KEY_get();
public static readonly string SWITCH_UUID_BRIDGE = freeswitchPINVOKE.SWITCH_UUID_BRIDGE_get();
public static readonly int SWITCH_BITS_PER_BYTE = freeswitchPINVOKE.SWITCH_BITS_PER_BYTE_get();
+ public static readonly int SWITCH_DEFAULT_FILE_BUFFER_LEN = freeswitchPINVOKE.SWITCH_DEFAULT_FILE_BUFFER_LEN_get();
public static readonly int SWITCH_MAX_STACKS = freeswitchPINVOKE.SWITCH_MAX_STACKS_get();
public static readonly int SWITCH_THREAD_STACKSIZE = freeswitchPINVOKE.SWITCH_THREAD_STACKSIZE_get();
public static readonly int SWITCH_SYSTEM_THREAD_STACKSIZE = freeswitchPINVOKE.SWITCH_SYSTEM_THREAD_STACKSIZE_get();
@@ -4690,6 +4699,9 @@
[DllImport("mod_managed", EntryPoint="CSharp_SWITCH_BITS_PER_BYTE_get")]
public static extern int SWITCH_BITS_PER_BYTE_get();
+ [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_DEFAULT_FILE_BUFFER_LEN_get")]
+ public static extern int SWITCH_DEFAULT_FILE_BUFFER_LEN_get();
+
[DllImport("mod_managed", EntryPoint="CSharp_switch_dtmf_t_digit_set")]
public static extern void switch_dtmf_t_digit_set(HandleRef jarg1, char jarg2);
@@ -5798,7 +5810,7 @@
public static extern int switch_core_session_write_video_frame(HandleRef jarg1, HandleRef jarg2, uint jarg3, int jarg4);
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_reset")]
- public static extern void switch_core_session_reset(HandleRef jarg1, int jarg2);
+ public static extern void switch_core_session_reset(HandleRef jarg1, int jarg2, int jarg3);
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_write_frame")]
public static extern int switch_core_session_write_frame(HandleRef jarg1, HandleRef jarg2, uint jarg3, int jarg4);
@@ -7438,6 +7450,24 @@
[DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_dbuflen_get")]
public static extern IntPtr switch_file_handle_dbuflen_get(HandleRef jarg1);
+ [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_pre_buffer_set")]
+ public static extern void switch_file_handle_pre_buffer_set(HandleRef jarg1, HandleRef jarg2);
+
+ [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_pre_buffer_get")]
+ public static extern IntPtr switch_file_handle_pre_buffer_get(HandleRef jarg1);
+
+ [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_pre_buffer_data_set")]
+ public static extern void switch_file_handle_pre_buffer_data_set(HandleRef jarg1, HandleRef jarg2);
+
+ [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_pre_buffer_data_get")]
+ public static extern IntPtr switch_file_handle_pre_buffer_data_get(HandleRef jarg1);
+
+ [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_pre_buffer_datalen_set")]
+ public static extern void switch_file_handle_pre_buffer_datalen_set(HandleRef jarg1, HandleRef jarg2);
+
+ [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_pre_buffer_datalen_get")]
+ public static extern IntPtr switch_file_handle_pre_buffer_datalen_get(HandleRef jarg1);
+
[DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_file_set")]
public static extern void switch_file_handle_file_set(HandleRef jarg1, string jarg2);
@@ -8743,6 +8773,12 @@
[DllImport("mod_managed", EntryPoint="CSharp_switch_channel_event_set_data")]
public static extern void switch_channel_event_set_data(HandleRef jarg1, HandleRef jarg2);
+ [DllImport("mod_managed", EntryPoint="CSharp_switch_channel_event_set_basic_data")]
+ public static extern void switch_channel_event_set_basic_data(HandleRef jarg1, HandleRef jarg2);
+
+ [DllImport("mod_managed", EntryPoint="CSharp_switch_channel_event_set_extended_data")]
+ public static extern void switch_channel_event_set_extended_data(HandleRef jarg1, HandleRef jarg2);
+
[DllImport("mod_managed", EntryPoint="CSharp_switch_channel_expand_variables")]
public static extern string switch_channel_expand_variables(HandleRef jarg1, string jarg2);
@@ -19956,7 +19992,9 @@
SWITCH_FILE_NATIVE = (1 << 9),
SWITCH_FILE_SEEK = (1 << 10),
SWITCH_FILE_OPEN = (1 << 11),
- SWITCH_FILE_CALLBACK = (1 << 12)
+ SWITCH_FILE_CALLBACK = (1 << 12),
+ SWITCH_FILE_DONE = (1 << 13),
+ SWITCH_FILE_BUFFER_DONE = (1 << 14)
}
}
@@ -20304,6 +20342,40 @@
}
}
+ public SWIGTYPE_p_switch_buffer pre_buffer {
+ set {
+ freeswitchPINVOKE.switch_file_handle_pre_buffer_set(swigCPtr, SWIGTYPE_p_switch_buffer.getCPtr(value));
+ }
+ get {
+ IntPtr cPtr = freeswitchPINVOKE.switch_file_handle_pre_buffer_get(swigCPtr);
+ SWIGTYPE_p_switch_buffer ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_buffer(cPtr, false);
+ return ret;
+ }
+ }
+
+ public SWIGTYPE_p_unsigned_char pre_buffer_data {
+ set {
+ freeswitchPINVOKE.switch_file_handle_pre_buffer_data_set(swigCPtr, SWIGTYPE_p_unsigned_char.getCPtr(value));
+ }
+ get {
+ IntPtr cPtr = freeswitchPINVOKE.switch_file_handle_pre_buffer_data_get(swigCPtr);
+ SWIGTYPE_p_unsigned_char ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_unsigned_char(cPtr, false);
+ return ret;
+ }
+ }
+
+ public SWIGTYPE_p_switch_size_t pre_buffer_datalen {
+ set {
+ freeswitchPINVOKE.switch_file_handle_pre_buffer_datalen_set(swigCPtr, SWIGTYPE_p_switch_size_t.getCPtr(value));
+ if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve();
+ }
+ get {
+ SWIGTYPE_p_switch_size_t ret = new SWIGTYPE_p_switch_size_t(freeswitchPINVOKE.switch_file_handle_pre_buffer_datalen_get(swigCPtr), true);
+ if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
+ }
+
public string file {
set {
freeswitchPINVOKE.switch_file_handle_file_set(swigCPtr, value);
Modified: freeswitch/branches/1.0/src/switch_core_file.c
==============================================================================
--- freeswitch/branches/1.0/src/switch_core_file.c (original)
+++ freeswitch/branches/1.0/src/switch_core_file.c Thu Jan 22 17:14:07 2009
@@ -132,7 +132,7 @@
{
switch_status_t status = SWITCH_STATUS_FALSE;
switch_size_t want, got, orig_len = *len;
-
+
switch_assert(fh != NULL);
switch_assert(fh->file_interface != NULL);
@@ -155,19 +155,21 @@
if (fh->pre_buffer) {
switch_size_t rlen;
+ int asis = switch_test_flag(fh, SWITCH_FILE_NATIVE);
+
if (!switch_test_flag(fh, SWITCH_FILE_BUFFER_DONE)) {
if (!switch_buffer_inuse(fh->pre_buffer)) {
- rlen = fh->pre_buffer_datalen / 2;
+ rlen = asis ? fh->pre_buffer_datalen : fh->pre_buffer_datalen / 2;
if ((status = fh->file_interface->file_read(fh, fh->pre_buffer_data, &rlen)) != SWITCH_STATUS_SUCCESS || !rlen) {
switch_set_flag(fh, SWITCH_FILE_BUFFER_DONE);
} else {
- switch_buffer_write(fh->pre_buffer, fh->pre_buffer_data, rlen * 2);
+ switch_buffer_write(fh->pre_buffer, fh->pre_buffer_data, asis ? rlen : rlen * 2);
}
}
}
- rlen = switch_buffer_read(fh->pre_buffer, data, *len * 2);
- *len = rlen / 2;
+ rlen = switch_buffer_read(fh->pre_buffer, data, asis ? *len : *len * 2);
+ *len = asis ? rlen : rlen / 2;
if (*len == 0) {
switch_set_flag(fh, SWITCH_FILE_DONE);
@@ -278,13 +280,14 @@
if (fh->pre_buffer) {
switch_size_t rlen, blen;
switch_status_t status = SWITCH_STATUS_SUCCESS;
+ int asis = switch_test_flag(fh, SWITCH_FILE_NATIVE);
- switch_buffer_write(fh->pre_buffer, data, *len * 2);
+ switch_buffer_write(fh->pre_buffer, data, asis ? *len : *len * 2);
rlen = switch_buffer_inuse(fh->pre_buffer);
if (rlen >= fh->pre_buffer_datalen) {
blen = switch_buffer_read(fh->pre_buffer, fh->pre_buffer_data, fh->pre_buffer_datalen);
- blen /= 2;
+ if (!asis) blen /= 2;
if ((status = fh->file_interface->file_write(fh, fh->pre_buffer_data, &blen)) != SWITCH_STATUS_SUCCESS) {
*len = 0;
}
@@ -346,6 +349,10 @@
switch_assert(fh != NULL);
switch_assert(fh->file_interface != NULL);
+ if (!switch_test_flag(fh, SWITCH_FILE_OPEN)) {
+ return SWITCH_STATUS_FALSE;
+ }
+
switch_clear_flag(fh, SWITCH_FILE_OPEN);
status = fh->file_interface->file_close(fh);
@@ -356,9 +363,11 @@
if (fh->pre_buffer) {
if (switch_test_flag(fh, SWITCH_FILE_FLAG_WRITE)) {
switch_size_t rlen, blen;
+ int asis = switch_test_flag(fh, SWITCH_FILE_NATIVE);
+
while((rlen = switch_buffer_inuse(fh->pre_buffer))) {
blen = switch_buffer_read(fh->pre_buffer, fh->pre_buffer_data, fh->pre_buffer_datalen);
- blen /= 2;
+ if (asis) blen /= 2;
if (fh->file_interface->file_write(fh, fh->pre_buffer_data, &blen) != SWITCH_STATUS_SUCCESS) {
break;
}
Modified: freeswitch/branches/1.0/src/switch_ivr_play_say.c
==============================================================================
--- freeswitch/branches/1.0/src/switch_ivr_play_say.c (original)
+++ freeswitch/branches/1.0/src/switch_ivr_play_say.c Thu Jan 22 17:14:07 2009
@@ -384,6 +384,7 @@
const char *vval;
time_t start = 0;
uint32_t org_silence_hits = 0;
+ int asis = 0;
switch_assert(read_codec != NULL);
@@ -396,6 +397,30 @@
fh->channels = read_codec->implementation->number_of_channels;
fh->native_rate = read_codec->implementation->actual_samples_per_second;
+
+
+ if (!strstr(file, SWITCH_URL_SEPARATOR)) {
+ char *ext;
+ const char *prefix;
+
+ prefix = switch_channel_get_variable(channel, "sound_prefix");
+ if (!prefix) {
+ prefix = SWITCH_GLOBAL_dirs.base_dir;
+ }
+
+ if (!switch_is_file_path(file)) {
+ file = switch_core_session_sprintf(session, "%s%s%s", prefix, SWITCH_PATH_SEPARATOR, file);
+ }
+ if ((ext = strrchr(file, '.'))) {
+ ext++;
+ } else {
+ ext = read_codec->implementation->iananame;
+ file = switch_core_session_sprintf(session, "%s.%s", file, ext);
+ asis = 1;
+ }
+ }
+
+
if (switch_core_file_open(fh,
file,
fh->channels,
@@ -406,6 +431,10 @@
return SWITCH_STATUS_GENERR;
}
+ if (switch_test_flag(fh, SWITCH_FILE_NATIVE)) {
+ asis = 1;
+ }
+
switch_channel_pre_answer(channel);
if ((p = switch_channel_get_variable(channel, "RECORD_TITLE"))) {
@@ -444,37 +473,43 @@
switch_channel_set_variable(channel, "RECORD_DATE", NULL);
}
- codec_name = "L16";
- if (switch_core_codec_init(&codec,
- codec_name,
- NULL,
- read_codec->implementation->actual_samples_per_second,
- read_codec->implementation->microseconds_per_packet / 1000,
- read_codec->implementation->number_of_channels,
- SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
- switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activated\n");
- switch_core_session_set_read_codec(session, &codec);
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
- "Raw Codec Activation Failed %s@%uhz %u channels %dms\n", codec_name, fh->samplerate,
- fh->channels, read_codec->implementation->microseconds_per_packet / 1000);
- switch_core_file_close(fh);
- switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
- return SWITCH_STATUS_GENERR;
+ if (!asis) {
+ codec_name = "L16";
+ if (switch_core_codec_init(&codec,
+ codec_name,
+ NULL,
+ read_codec->implementation->actual_samples_per_second,
+ read_codec->implementation->microseconds_per_packet / 1000,
+ read_codec->implementation->number_of_channels,
+ SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
+ switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activated\n");
+ switch_core_session_set_read_codec(session, &codec);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "Raw Codec Activation Failed %s@%uhz %u channels %dms\n", codec_name, fh->samplerate,
+ fh->channels, read_codec->implementation->microseconds_per_packet / 1000);
+ switch_core_file_close(fh);
+ switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
+ return SWITCH_STATUS_GENERR;
+ }
}
if (limit) {
start = switch_timestamp(NULL);
}
-
+
if (fh->thresh) {
- if (fh->silence_hits) {
- fh->silence_hits = fh->samplerate * fh->silence_hits / read_codec->implementation->samples_per_packet;
+ if (asis) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Can't detect silence on a native recording.\n");
} else {
- fh->silence_hits = fh->samplerate * 3 / read_codec->implementation->samples_per_packet;
+ if (fh->silence_hits) {
+ fh->silence_hits = fh->samplerate * fh->silence_hits / read_codec->implementation->samples_per_packet;
+ } else {
+ fh->silence_hits = fh->samplerate * 3 / read_codec->implementation->samples_per_packet;
+ }
+ org_silence_hits = fh->silence_hits;
}
- org_silence_hits = fh->silence_hits;
}
for (;;) {
@@ -543,7 +578,7 @@
}
}
- if (fh->thresh) {
+ if (!asis && fh->thresh) {
int16_t *fdata = (int16_t *) read_frame->data;
uint32_t samples = read_frame->datalen / sizeof(*fdata);
uint32_t score, count = 0, j = 0;
@@ -571,8 +606,8 @@
if (!switch_test_flag(fh, SWITCH_FILE_PAUSE) && !switch_test_flag(read_frame, SFF_CNG)) {
int16_t *data = read_frame->data;
- len = (switch_size_t) read_frame->datalen / 2;
-
+ len = (switch_size_t) asis ? read_frame->datalen : read_frame->datalen / 2;
+
if (switch_core_file_write(fh, data, &len) != SWITCH_STATUS_SUCCESS) {
break;
}
1
0
[Freeswitch-branches] [commit] r11427 - freeswitch/branches/1.0/src/mod/endpoints/mod_sofia
by FreeSWITCH SVN 22 Jan '09
by FreeSWITCH SVN 22 Jan '09
22 Jan '09
Author: mikej
Date: Thu Jan 22 17:06:17 2009
New Revision: 11427
Log:
mod_sofia: fix notify event wasn't allowing content-length 0 (r:11106/MODENDP-167)
Modified:
freeswitch/branches/1.0/src/mod/endpoints/mod_sofia/mod_sofia.c
Modified: freeswitch/branches/1.0/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/branches/1.0/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/branches/1.0/src/mod/endpoints/mod_sofia/mod_sofia.c Thu Jan 22 17:06:17 2009
@@ -2675,12 +2675,12 @@
if (call_id) {
sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,'%q','%q','%q' "
- "from sip_registrations where call_id='%q'", ct, es, body, call_id
+ "from sip_registrations where call_id='%q'", ct, es, switch_str_nil(body), call_id
);
} else {
sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,'%q','%q','%q' "
"from sip_registrations where sip_user='%s' and sip_host='%q'",
- ct, es, body, user, host
+ ct, es, switch_str_nil(body), switch_str_nil(user), switch_str_nil(host)
);
}
1
0
22 Jan '09
Author: mikej
Date: Thu Jan 22 17:01:56 2009
New Revision: 11426
Log:
core: fix codec and media handling issues (r:11104)
Modified:
freeswitch/branches/1.0/src/include/switch_core.h
freeswitch/branches/1.0/src/include/switch_module_interfaces.h
freeswitch/branches/1.0/src/include/switch_types.h
freeswitch/branches/1.0/src/mod/applications/mod_conference/mod_conference.c
freeswitch/branches/1.0/src/mod/applications/mod_rss/mod_rss.c
freeswitch/branches/1.0/src/mod/endpoints/mod_loopback/mod_loopback.c
freeswitch/branches/1.0/src/mod/endpoints/mod_sofia/sofia_glue.c
freeswitch/branches/1.0/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c
freeswitch/branches/1.0/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
freeswitch/branches/1.0/src/mod/formats/mod_local_stream/mod_local_stream.c
freeswitch/branches/1.0/src/switch_core.c
freeswitch/branches/1.0/src/switch_core_file.c
freeswitch/branches/1.0/src/switch_core_io.c
freeswitch/branches/1.0/src/switch_core_session.c
freeswitch/branches/1.0/src/switch_core_state_machine.c
freeswitch/branches/1.0/src/switch_ivr.c
freeswitch/branches/1.0/src/switch_ivr_async.c
freeswitch/branches/1.0/src/switch_ivr_bridge.c
freeswitch/branches/1.0/src/switch_ivr_originate.c
freeswitch/branches/1.0/src/switch_ivr_play_say.c
Modified: freeswitch/branches/1.0/src/include/switch_core.h
==============================================================================
--- freeswitch/branches/1.0/src/include/switch_core.h (original)
+++ freeswitch/branches/1.0/src/include/switch_core.h Thu Jan 22 17:01:56 2009
@@ -330,7 +330,7 @@
\return success if it is safe to read from the session
*/
#ifdef SWITCH_DEBUG_RWLOCKS
-#define switch_core_session_read_lock(session) switch_core_session_perform_read_lock_hangup(session, __FILE__, __SWITCH_FUNC__, __LINE__)
+#define switch_core_session_read_lock_hangup(session) switch_core_session_perform_read_lock_hangup(session, __FILE__, __SWITCH_FUNC__, __LINE__)
#else
SWITCH_DECLARE(switch_status_t) switch_core_session_read_lock_hangup(_In_ switch_core_session_t *session);
#endif
@@ -901,7 +901,7 @@
\param session the session to reset
\param flush_dtmf flush all queued dtmf events too
*/
-SWITCH_DECLARE(void) switch_core_session_reset(_In_ switch_core_session_t *session, switch_bool_t flush_dtmf);
+SWITCH_DECLARE(void) switch_core_session_reset(_In_ switch_core_session_t *session, switch_bool_t flush_dtmf, switch_bool_t reset_read_codec);
/*!
\brief Write a frame to a session
Modified: freeswitch/branches/1.0/src/include/switch_module_interfaces.h
==============================================================================
--- freeswitch/branches/1.0/src/include/switch_module_interfaces.h (original)
+++ freeswitch/branches/1.0/src/include/switch_module_interfaces.h Thu Jan 22 17:01:56 2009
@@ -320,6 +320,9 @@
switch_buffer_t *buffer;
switch_byte_t *dbuf;
switch_size_t dbuflen;
+ switch_buffer_t *pre_buffer;
+ unsigned char *pre_buffer_data;
+ switch_size_t pre_buffer_datalen;
const char *file;
const char *func;
int line;
Modified: freeswitch/branches/1.0/src/include/switch_types.h
==============================================================================
--- freeswitch/branches/1.0/src/include/switch_types.h (original)
+++ freeswitch/branches/1.0/src/include/switch_types.h Thu Jan 22 17:01:56 2009
@@ -166,7 +166,9 @@
#define SWITCH_SPEECH_KEY "speech"
#define SWITCH_UUID_BRIDGE "uuid_bridge"
#define SWITCH_BITS_PER_BYTE 8
- typedef uint8_t switch_byte_t;
+#define SWITCH_DEFAULT_FILE_BUFFER_LEN 65536
+
+typedef uint8_t switch_byte_t;
typedef struct {
char digit;
@@ -1061,7 +1063,9 @@
SWITCH_FILE_NATIVE = (1 << 9),
SWITCH_FILE_SEEK = (1 << 10),
SWITCH_FILE_OPEN = (1 << 11),
- SWITCH_FILE_CALLBACK = (1 << 12)
+ SWITCH_FILE_CALLBACK = (1 << 12),
+ SWITCH_FILE_DONE = (1 << 13),
+ SWITCH_FILE_BUFFER_DONE = (1 << 14)
} switch_file_flag_enum_t;
typedef uint32_t switch_file_flag_t;
Modified: freeswitch/branches/1.0/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/branches/1.0/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/branches/1.0/src/mod/applications/mod_conference/mod_conference.c Thu Jan 22 17:01:56 2009
@@ -1,4 +1,4 @@
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005/2006, Anthony Minessale II <anthmct(a)yahoo.com>
*
@@ -139,7 +139,8 @@
MFLAG_FLUSH_BUFFER = (1 << 8),
MFLAG_ENDCONF = (1 << 9),
MFLAG_HAS_AUDIO = (1 << 10),
- MFLAG_TALKING = (1 << 11)
+ MFLAG_TALKING = (1 << 11),
+ MFLAG_RESTART = (1 << 12)
} member_flag_t;
typedef enum {
@@ -337,6 +338,7 @@
} api_command_t;
/* Function Prototypes */
+static int setup_media(conference_member_t *member, conference_obj_t *conference);
static uint32_t next_member_id(void);
static conference_relationship_t *member_get_relationship(conference_member_t *member, conference_member_t *other_member);
static conference_member_t *conference_member_get(conference_obj_t *conference, uint32_t id);
@@ -1758,18 +1760,43 @@
/* NB. this starts the input thread after some initial setup for the call leg */
static void conference_loop_output(conference_member_t *member)
{
- switch_channel_t *channel = switch_core_session_get_channel(member->session);
+ switch_channel_t *channel;
switch_frame_t write_frame = { 0 };
- uint8_t *data;
+ uint8_t *data = NULL;
switch_timer_t timer = { 0 };
- switch_codec_t *read_codec = switch_core_session_get_read_codec(member->session);
- uint32_t interval = read_codec->implementation->microseconds_per_packet / 1000;
- uint32_t samples = switch_samples_per_packet(member->conference->rate, interval);
- uint32_t csamples = samples;
- uint32_t tsamples = member->orig_read_codec->implementation->samples_per_packet;
- uint32_t flush_len = 0;
- uint32_t low_count = 0, bytes = samples * 2;
- call_list_t *call_list = NULL, *cp = NULL;
+ switch_codec_t *read_codec;
+ uint32_t interval;
+ uint32_t samples;
+ uint32_t csamples;
+ uint32_t tsamples;
+ uint32_t flush_len;
+ uint32_t low_count, bytes;
+ call_list_t *call_list, *cp;
+ int restarting = -1;
+
+ top:
+
+ restarting++;
+
+ if (switch_test_flag(member, MFLAG_RESTART)) {
+ switch_clear_flag(member, MFLAG_RESTART);
+ switch_set_flag_locked(member, MFLAG_FLUSH_BUFFER);
+ switch_core_timer_destroy(&timer);
+ }
+
+ channel = switch_core_session_get_channel(member->session);
+ read_codec = switch_core_session_get_read_codec(member->session);
+ interval = read_codec->implementation->microseconds_per_packet / 1000;
+ samples = switch_samples_per_packet(member->conference->rate, interval);
+ csamples = samples;
+ tsamples = member->orig_read_codec->implementation->samples_per_packet;
+ flush_len = 0;
+ low_count = 0;
+ bytes = samples * 2;
+ call_list = NULL;
+ cp = NULL;
+
+
switch_assert(member->conference != NULL);
@@ -1783,62 +1810,72 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Setup timer %s success interval: %u samples: %u\n",
member->conference->timer_name, interval, tsamples);
- write_frame.data = data = switch_core_session_alloc(member->session, SWITCH_RECOMMENDED_BUFFER_SIZE);
- write_frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
+ if (!restarting) {
+ write_frame.data = data = switch_core_session_alloc(member->session, SWITCH_RECOMMENDED_BUFFER_SIZE);
+ write_frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
+ }
+
write_frame.codec = &member->write_codec;
if (!switch_test_flag(member->conference, CFLAG_ANSWERED)) {
switch_channel_answer(channel);
}
- /* Start the input thread */
- launch_conference_loop_input(member, switch_core_session_get_pool(member->session));
-
- /* build a digit stream object */
- if (member->conference->dtmf_parser != NULL
- && switch_ivr_digit_stream_new(member->conference->dtmf_parser, &member->digit_stream) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Danger Will Robinson, there is no digit parser stream object\n");
- }
-
- if ((call_list = switch_channel_get_private(channel, "_conference_autocall_list_"))) {
- const char *cid_name = switch_channel_get_variable(channel, "conference_auto_outcall_caller_id_name");
- const char *cid_num = switch_channel_get_variable(channel, "conference_auto_outcall_caller_id_number");
- const char *toval = switch_channel_get_variable(channel, "conference_auto_outcall_timeout");
- const char *flags = switch_channel_get_variable(channel, "conference_auto_outcall_flags");
- const char *ann = switch_channel_get_variable(channel, "conference_auto_outcall_announce");
- const char *prefix = switch_channel_get_variable(channel, "conference_auto_outcall_prefix");
- int to = 60;
+ if (!restarting) {
+ /* Start the input thread */
+ launch_conference_loop_input(member, switch_core_session_get_pool(member->session));
- if (ann) {
- member->conference->special_announce = switch_core_strdup(member->conference->pool, ann);
+ /* build a digit stream object */
+ if (member->conference->dtmf_parser != NULL
+ && switch_ivr_digit_stream_new(member->conference->dtmf_parser, &member->digit_stream) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Danger Will Robinson, there is no digit parser stream object\n");
}
- switch_channel_set_private(channel, "_conference_autocall_list_", NULL);
+ if ((call_list = switch_channel_get_private(channel, "_conference_autocall_list_"))) {
+ const char *cid_name = switch_channel_get_variable(channel, "conference_auto_outcall_caller_id_name");
+ const char *cid_num = switch_channel_get_variable(channel, "conference_auto_outcall_caller_id_number");
+ const char *toval = switch_channel_get_variable(channel, "conference_auto_outcall_timeout");
+ const char *flags = switch_channel_get_variable(channel, "conference_auto_outcall_flags");
+ const char *ann = switch_channel_get_variable(channel, "conference_auto_outcall_announce");
+ const char *prefix = switch_channel_get_variable(channel, "conference_auto_outcall_prefix");
+ int to = 60;
+
+ if (ann) {
+ member->conference->special_announce = switch_core_strdup(member->conference->pool, ann);
+ }
+
+ switch_channel_set_private(channel, "_conference_autocall_list_", NULL);
- if (toval) {
- to = atoi(toval);
- if (to < 10 || to > 500) {
- to = 60;
+ if (toval) {
+ to = atoi(toval);
+ if (to < 10 || to > 500) {
+ to = 60;
+ }
}
- }
- for (cp = call_list; cp; cp = cp->next) {
- int argc;
- char *argv[512] = { 0 };
- char *cpstr = strdup(cp->string);
- int x = 0;
+ for (cp = call_list; cp; cp = cp->next) {
+ int argc;
+ char *argv[512] = { 0 };
+ char *cpstr = strdup(cp->string);
+ int x = 0;
- switch_assert(cpstr);
- argc = switch_separate_string(cpstr, ',', argv, (sizeof(argv) / sizeof(argv[0])));
- for (x = 0; x < argc; x++) {
- char *dial_str = switch_mprintf("%s%s", switch_str_nil(prefix), argv[x]);
- switch_assert(dial_str);
- conference_outcall_bg(member->conference, NULL, NULL, dial_str, to, switch_str_nil(flags), cid_name, cid_num);
- switch_safe_free(dial_str);
+ switch_assert(cpstr);
+ argc = switch_separate_string(cpstr, ',', argv, (sizeof(argv) / sizeof(argv[0])));
+ for (x = 0; x < argc; x++) {
+ char *dial_str = switch_mprintf("%s%s", switch_str_nil(prefix), argv[x]);
+ switch_assert(dial_str);
+ conference_outcall_bg(member->conference, NULL, NULL, dial_str, to, switch_str_nil(flags), cid_name, cid_num);
+ switch_safe_free(dial_str);
+ }
+ switch_safe_free(cpstr);
}
- switch_safe_free(cpstr);
}
}
+
+ if (restarting) {
+ switch_channel_clear_flag(channel, CF_SERVICE);
+ }
+
/* Fair WARNING, If you expect the caller to hear anything or for digit handling to be processed, */
/* you better not block this thread loop for more than the duration of member->conference->timer_name! */
while (switch_test_flag(member, MFLAG_RUNNING) && switch_test_flag(member, MFLAG_ITHREAD)
@@ -1852,6 +1889,10 @@
switch_size_t file_sample_len = csamples;
switch_size_t file_data_len = file_sample_len * 2;
+ if (switch_test_flag(member, MFLAG_RESTART)) {
+ goto top;
+ }
+
switch_mutex_lock(member->flag_mutex);
if (switch_core_session_dequeue_event(member->session, &event) == SWITCH_STATUS_SUCCESS) {
@@ -2145,6 +2186,8 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Joining Conference\n");
goto end;
}
+
+ fh.pre_buffer_datalen = SWITCH_DEFAULT_FILE_BUFFER_LEN;
if (switch_core_file_open(&fh,
rec->path, (uint8_t) 1, conference->rate, SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT,
@@ -2371,6 +2414,7 @@
fnode->leadin = leadin;
/* Open the file */
+ fnode->fh.pre_buffer_datalen = SWITCH_DEFAULT_FILE_BUFFER_LEN;
if (switch_core_file_open(&fnode->fh, file, (uint8_t) 1, conference->rate, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, pool) !=
SWITCH_STATUS_SUCCESS) {
switch_core_destroy_memory_pool(&pool);
@@ -2465,6 +2509,7 @@
fnode->type = NODE_TYPE_FILE;
fnode->leadin = leadin;
/* Open the file */
+ fnode->fh.pre_buffer_datalen = SWITCH_DEFAULT_FILE_BUFFER_LEN;
if (switch_core_file_open(&fnode->fh,
file, (uint8_t) 1, member->conference->rate, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
pool) != SWITCH_STATUS_SUCCESS) {
@@ -3631,9 +3676,21 @@
switch_mutex_lock(member->flag_mutex);
conference_del_member(conference, member);
conference_add_member(new_conference, member);
+
+ if (conference->rate != new_conference->rate) {
+ if(setup_media(member, new_conference)) {
+ switch_clear_flag_locked(member, MFLAG_RUNNING);
+ } else {
+ switch_channel_set_flag(channel, CF_SERVICE);
+ switch_set_flag(member, MFLAG_RESTART);
+ }
+ }
+
switch_mutex_unlock(new_conference->mutex);
switch_mutex_unlock(member->flag_mutex);
- stream->write_function(stream, "OK Members sent to conference %s.\n", argv[2]);
+
+
+ stream->write_function(stream, "OK Member '%d' sent to conference %s.\n", member->id, argv[2]);
/* tell them what happened */
if (test_eflag(conference, EFLAG_TRANSFER) &&
@@ -4349,6 +4406,111 @@
switch_channel_set_private(channel, "_conference_autocall_list_", call_list);
}
+
+static int setup_media(conference_member_t *member, conference_obj_t *conference)
+{
+ switch_codec_t *read_codec;
+
+
+ switch_core_session_reset(member->session, SWITCH_TRUE, SWITCH_FALSE);
+
+ if (member->read_codec.implementation) {
+ switch_core_codec_destroy(&member->read_codec);
+ }
+
+ if (member->read_resampler) {
+ switch_resample_destroy(&member->read_resampler);
+ }
+
+ read_codec = switch_core_session_get_read_codec(member->session);
+ member->orig_read_codec = read_codec;
+ member->native_rate = read_codec->implementation->samples_per_second;
+
+ /* Setup a Signed Linear codec for reading audio. */
+ if (switch_core_codec_init(&member->read_codec,
+ "L16",
+ NULL, read_codec->implementation->actual_samples_per_second, read_codec->implementation->microseconds_per_packet / 1000,
+ 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, member->pool) == SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ "Raw Codec Activation Success L16@%uhz 1 channel %dms\n",
+ read_codec->implementation->actual_samples_per_second, read_codec->implementation->microseconds_per_packet / 1000);
+
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n",
+ read_codec->implementation->actual_samples_per_second, read_codec->implementation->microseconds_per_packet / 1000);
+
+ goto done;
+ }
+
+ if (!member->frame_size) {
+ member->frame_size = SWITCH_RECOMMENDED_BUFFER_SIZE;
+ member->frame = switch_core_alloc(member->pool, member->frame_size);
+ member->mux_frame = switch_core_alloc(member->pool, member->frame_size);
+ }
+
+ if (read_codec->implementation->actual_samples_per_second != conference->rate) {
+ if (switch_resample_create(&member->read_resampler,
+ read_codec->implementation->actual_samples_per_second,
+ member->frame_size, conference->rate, member->frame_size, member->pool) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unable to create resampler!\n");
+ goto done;
+ }
+
+
+ member->resample_out = switch_core_alloc(member->pool, member->frame_size);
+ member->resample_out_len = member->frame_size;
+
+ /* Setup an audio buffer for the resampled audio */
+ if (switch_buffer_create_dynamic(&member->resample_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX)
+ != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n");
+ goto done;
+ }
+ }
+
+
+ /* Setup a Signed Linear codec for writing audio. */
+ if (switch_core_codec_init(&member->write_codec,
+ "L16",
+ NULL,
+ conference->rate,
+ read_codec->implementation->microseconds_per_packet / 1000,
+ 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, member->pool) == SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ "Raw Codec Activation Success L16@%uhz 1 channel %dms\n",
+ conference->rate, read_codec->implementation->microseconds_per_packet / 1000);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n",
+ conference->rate, read_codec->implementation->microseconds_per_packet / 1000);
+ goto codec_done2;
+ }
+
+ /* Setup an audio buffer for the incoming audio */
+ if (switch_buffer_create_dynamic(&member->audio_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n");
+ goto codec_done1;
+ }
+
+ /* Setup an audio buffer for the outgoing audio */
+ if (switch_buffer_create_dynamic(&member->mux_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n");
+ goto codec_done1;
+ }
+
+ return 0;
+
+ codec_done1:
+ switch_core_codec_destroy(&member->read_codec);
+ codec_done2:
+ switch_core_codec_destroy(&member->write_codec);
+ done:
+
+ return -1;
+
+
+}
+
+
/* Application interface function that is called from the dialplan to join the channel to a conference */
SWITCH_STANDARD_APP(conference_function)
{
@@ -4632,84 +4794,16 @@
switch_set_flag(conference, CFLAG_ANSWERED);
}
- member.orig_read_codec = read_codec;
- member.native_rate = read_codec->implementation->samples_per_second;
+ member.session = session;
member.pool = switch_core_session_get_pool(session);
- /* Setup a Signed Linear codec for reading audio. */
- if (switch_core_codec_init(&member.read_codec,
- "L16",
- NULL, read_codec->implementation->actual_samples_per_second, read_codec->implementation->microseconds_per_packet / 1000,
- 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, member.pool) == SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- "Raw Codec Activation Success L16@%uhz 1 channel %dms\n",
- read_codec->implementation->actual_samples_per_second, read_codec->implementation->microseconds_per_packet / 1000);
-
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n",
- read_codec->implementation->actual_samples_per_second, read_codec->implementation->microseconds_per_packet / 1000);
-
+ if (setup_media(&member, conference)) {
flags = 0;
goto done;
}
- member.frame_size = SWITCH_RECOMMENDED_BUFFER_SIZE;
- member.frame = switch_core_alloc(member.pool, member.frame_size);
- member.mux_frame = switch_core_alloc(member.pool, member.frame_size);
-
- if (read_codec->implementation->actual_samples_per_second != conference->rate) {
- if (switch_resample_create(&member.read_resampler,
- read_codec->implementation->actual_samples_per_second,
- member.frame_size, conference->rate, member.frame_size, member.pool) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unable to create resampler!\n");
- goto done;
- }
-
-
- member.resample_out = switch_core_alloc(member.pool, member.frame_size);
- member.resample_out_len = member.frame_size;
-
- /* Setup an audio buffer for the resampled audio */
- if (switch_buffer_create_dynamic(&member.resample_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX)
- != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n");
- goto done;
- }
- }
-
-
- /* Setup a Signed Linear codec for writing audio. */
- if (switch_core_codec_init(&member.write_codec,
- "L16",
- NULL,
- conference->rate,
- read_codec->implementation->microseconds_per_packet / 1000,
- 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, member.pool) == SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- "Raw Codec Activation Success L16@%uhz 1 channel %dms\n",
- conference->rate, read_codec->implementation->microseconds_per_packet / 1000);
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n",
- conference->rate, read_codec->implementation->microseconds_per_packet / 1000);
- flags = 0;
- goto codec_done2;
- }
-
- /* Setup an audio buffer for the incoming audio */
- if (switch_buffer_create_dynamic(&member.audio_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n");
- goto codec_done1;
- }
-
- /* Setup an audio buffer for the outgoing audio */
- if (switch_buffer_create_dynamic(&member.mux_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n");
- goto codec_done1;
- }
-
/* Prepare MUTEXS */
member.id = next_member_id();
- member.session = session;
switch_mutex_init(&member.flag_mutex, SWITCH_MUTEX_NESTED, member.pool);
switch_mutex_init(&member.audio_in_mutex, SWITCH_MUTEX_NESTED, member.pool);
switch_mutex_init(&member.audio_out_mutex, SWITCH_MUTEX_NESTED, member.pool);
@@ -4724,7 +4818,8 @@
/* Add the caller to the conference */
if (conference_add_member(conference, &member) != SWITCH_STATUS_SUCCESS) {
- goto codec_done1;
+ switch_core_codec_destroy(&member.read_codec);
+ goto done;
}
msg.from = __FILE__;
@@ -4747,12 +4842,14 @@
/* Put the original codec back */
switch_core_session_set_read_codec(member.session, NULL);
- /* Clean Up. codec_done(X): is for error situations after the codecs were setup and done: is for situations before */
- codec_done1:
- switch_core_codec_destroy(&member.read_codec);
- codec_done2:
- switch_core_codec_destroy(&member.write_codec);
+ /* Clean Up. */
+
done:
+
+ if (member.read_resampler) {
+ switch_resample_destroy(&member.read_resampler);
+ }
+
switch_event_destroy(¶ms);
switch_buffer_destroy(&member.resample_buffer);
switch_buffer_destroy(&member.audio_buffer);
@@ -4796,7 +4893,7 @@
}
}
- switch_core_session_reset(session, SWITCH_TRUE);
+ switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
/* release the readlock */
if (rl) {
Modified: freeswitch/branches/1.0/src/mod/applications/mod_rss/mod_rss.c
==============================================================================
--- freeswitch/branches/1.0/src/mod/applications/mod_rss/mod_rss.c (original)
+++ freeswitch/branches/1.0/src/mod/applications/mod_rss/mod_rss.c Thu Jan 22 17:01:56 2009
@@ -619,7 +619,7 @@
}
switch_xml_free(xml);
- switch_core_session_reset(session, SWITCH_TRUE);
+ switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
}
Modified: freeswitch/branches/1.0/src/mod/endpoints/mod_loopback/mod_loopback.c
==============================================================================
--- freeswitch/branches/1.0/src/mod/endpoints/mod_loopback/mod_loopback.c (original)
+++ freeswitch/branches/1.0/src/mod/endpoints/mod_loopback/mod_loopback.c Thu Jan 22 17:01:56 2009
@@ -264,7 +264,10 @@
}
if (tech_pvt->other_session) {
- switch_core_session_read_lock(tech_pvt->other_session);
+ if (switch_core_session_read_lock(tech_pvt->other_session) != SWITCH_STATUS_SUCCESS) {
+ switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+ goto end;
+ }
} else {
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
goto end;
Modified: freeswitch/branches/1.0/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/branches/1.0/src/mod/endpoints/mod_sofia/sofia_glue.c (original)
+++ freeswitch/branches/1.0/src/mod/endpoints/mod_sofia/sofia_glue.c Thu Jan 22 17:01:56 2009
@@ -1623,7 +1623,7 @@
resetting = 1;
switch_core_codec_destroy(&tech_pvt->read_codec);
switch_core_codec_destroy(&tech_pvt->write_codec);
- switch_core_session_reset(tech_pvt->session, SWITCH_TRUE);
+ switch_core_session_reset(tech_pvt->session, SWITCH_TRUE, SWITCH_TRUE);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Already using %s\n", tech_pvt->read_codec.implementation->iananame);
switch_goto_status(SWITCH_STATUS_SUCCESS, end);
Modified: freeswitch/branches/1.0/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c
==============================================================================
--- freeswitch/branches/1.0/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c (original)
+++ freeswitch/branches/1.0/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c Thu Jan 22 17:01:56 2009
@@ -1202,7 +1202,9 @@
if ((session = listener->session)) {
channel = switch_core_session_get_channel(session);
- switch_core_session_read_lock(session);
+ if (switch_core_session_read_lock(session) != SWITCH_STATUS_SUCCESS) {
+ goto done;
+ }
}
if (switch_strlen_zero(listener->remote_ip)) {
Modified: freeswitch/branches/1.0/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
==============================================================================
--- freeswitch/branches/1.0/src/mod/event_handlers/mod_event_socket/mod_event_socket.c (original)
+++ freeswitch/branches/1.0/src/mod/event_handlers/mod_event_socket/mod_event_socket.c Thu Jan 22 17:01:56 2009
@@ -1770,7 +1770,9 @@
if ((session = listener->session)) {
channel = switch_core_session_get_channel(session);
- switch_core_session_read_lock(session);
+ if (switch_core_session_read_lock(session) != SWITCH_STATUS_SUCCESS) {
+ goto done;
+ }
}
if (prefs.acl_count && listener->sa && !switch_strlen_zero(listener->remote_ip)) {
Modified: freeswitch/branches/1.0/src/mod/formats/mod_local_stream/mod_local_stream.c
==============================================================================
--- freeswitch/branches/1.0/src/mod/formats/mod_local_stream/mod_local_stream.c (original)
+++ freeswitch/branches/1.0/src/mod/formats/mod_local_stream/mod_local_stream.c Thu Jan 22 17:01:56 2009
@@ -183,6 +183,7 @@
fname = path_buf;
fh.prebuf = source->prebuf;
+ fh.pre_buffer_datalen = 65536;
if (switch_core_file_open(&fh,
(char *) fname,
Modified: freeswitch/branches/1.0/src/switch_core.c
==============================================================================
--- freeswitch/branches/1.0/src/switch_core.c (original)
+++ freeswitch/branches/1.0/src/switch_core.c Thu Jan 22 17:01:56 2009
@@ -277,7 +277,10 @@
switch_assert(thread != NULL);
switch_assert(session != NULL);
- switch_core_session_read_lock(session);
+ if (switch_core_session_read_lock(session) != SWITCH_STATUS_SUCCESS) {
+ return NULL;
+ }
+
channel = switch_core_session_get_channel(session);
switch_channel_set_flag(channel, CF_SERVICE);
Modified: freeswitch/branches/1.0/src/switch_core_file.c
==============================================================================
--- freeswitch/branches/1.0/src/switch_core_file.c (original)
+++ freeswitch/branches/1.0/src/switch_core_file.c Thu Jan 22 17:01:56 2009
@@ -117,6 +117,12 @@
}
}
+ if (fh->pre_buffer_datalen) {
+ //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Prebuffering %d bytes\n", (int)fh->pre_buffer_datalen);
+ switch_buffer_create_dynamic(&fh->pre_buffer, fh->pre_buffer_datalen, fh->pre_buffer_datalen / 2, 0);
+ fh->pre_buffer_data = switch_core_alloc(fh->memory_pool, fh->pre_buffer_datalen);
+ }
+
switch_set_flag(fh, SWITCH_FILE_OPEN);
return status;
@@ -124,26 +130,61 @@
SWITCH_DECLARE(switch_status_t) switch_core_file_read(switch_file_handle_t *fh, void *data, switch_size_t *len)
{
- switch_status_t status;
+ switch_status_t status = SWITCH_STATUS_FALSE;
switch_size_t want, got, orig_len = *len;
switch_assert(fh != NULL);
switch_assert(fh->file_interface != NULL);
+ top:
+
if (fh->buffer && switch_buffer_inuse(fh->buffer) >= *len * 2) {
*len = switch_buffer_read(fh->buffer, data, orig_len * 2) / 2;
return SWITCH_STATUS_SUCCESS;
}
-
+
+ if (switch_test_flag(fh, SWITCH_FILE_DONE)) {
+ switch_clear_flag(fh, SWITCH_FILE_DONE);
+ *len = 0;
+ return SWITCH_STATUS_FALSE;
+ }
+
want = *len;
more:
- if ((status = fh->file_interface->file_read(fh, data, len)) != SWITCH_STATUS_SUCCESS || !*len) {
- *len = 0;
- goto done;
+ if (fh->pre_buffer) {
+ switch_size_t rlen;
+ if (!switch_test_flag(fh, SWITCH_FILE_BUFFER_DONE)) {
+ if (!switch_buffer_inuse(fh->pre_buffer)) {
+ rlen = fh->pre_buffer_datalen / 2;
+ if ((status = fh->file_interface->file_read(fh, fh->pre_buffer_data, &rlen)) != SWITCH_STATUS_SUCCESS || !rlen) {
+ switch_set_flag(fh, SWITCH_FILE_BUFFER_DONE);
+ } else {
+ switch_buffer_write(fh->pre_buffer, fh->pre_buffer_data, rlen * 2);
+ }
+ }
+ }
+
+ rlen = switch_buffer_read(fh->pre_buffer, data, *len * 2);
+ *len = rlen / 2;
+
+ if (*len == 0) {
+ switch_set_flag(fh, SWITCH_FILE_DONE);
+ goto top;
+ } else {
+ status = SWITCH_STATUS_SUCCESS;
+ }
+
+ } else {
+
+ if ((status = fh->file_interface->file_read(fh, data, len)) != SWITCH_STATUS_SUCCESS || !*len) {
+ switch_set_flag(fh, SWITCH_FILE_DONE);
+ goto top;
+ }
}
+
got = *len;
if (!switch_test_flag(fh, SWITCH_FILE_NATIVE) && fh->native_rate != fh->samplerate) {
@@ -187,8 +228,6 @@
}
- done:
-
return status;
}
@@ -235,7 +274,26 @@
return SWITCH_STATUS_SUCCESS;
}
- return fh->file_interface->file_write(fh, data, len);
+
+ if (fh->pre_buffer) {
+ switch_size_t rlen, blen;
+ switch_status_t status = SWITCH_STATUS_SUCCESS;
+
+ switch_buffer_write(fh->pre_buffer, data, *len * 2);
+
+ rlen = switch_buffer_inuse(fh->pre_buffer);
+ if (rlen >= fh->pre_buffer_datalen) {
+ blen = switch_buffer_read(fh->pre_buffer, fh->pre_buffer_data, fh->pre_buffer_datalen);
+ blen /= 2;
+ if ((status = fh->file_interface->file_write(fh, fh->pre_buffer_data, &blen)) != SWITCH_STATUS_SUCCESS) {
+ *len = 0;
+ }
+ }
+
+ return status;
+ } else {
+ return fh->file_interface->file_write(fh, data, len);
+ }
}
SWITCH_DECLARE(switch_status_t) switch_core_file_seek(switch_file_handle_t *fh, unsigned int *cur_pos, int64_t samples, int whence)
@@ -295,6 +353,21 @@
switch_buffer_destroy(&fh->buffer);
}
+ if (fh->pre_buffer) {
+ if (switch_test_flag(fh, SWITCH_FILE_FLAG_WRITE)) {
+ switch_size_t rlen, blen;
+ while((rlen = switch_buffer_inuse(fh->pre_buffer))) {
+ blen = switch_buffer_read(fh->pre_buffer, fh->pre_buffer_data, fh->pre_buffer_datalen);
+ blen /= 2;
+ if (fh->file_interface->file_write(fh, fh->pre_buffer_data, &blen) != SWITCH_STATUS_SUCCESS) {
+ break;
+ }
+ }
+ }
+
+ switch_buffer_destroy(&fh->pre_buffer);
+ }
+
switch_resample_destroy(&fh->resampler);
UNPROTECT_INTERFACE(fh->file_interface);
Modified: freeswitch/branches/1.0/src/switch_core_io.c
==============================================================================
--- freeswitch/branches/1.0/src/switch_core_io.c (original)
+++ freeswitch/branches/1.0/src/switch_core_io.c Thu Jan 22 17:01:56 2009
@@ -805,7 +805,7 @@
}
if (session->write_codec) {
- if (write_frame->datalen == session->write_codec->implementation->decoded_bytes_per_packet) {
+ if (write_frame->codec->implementation->decoded_bytes_per_packet == session->write_codec->implementation->decoded_bytes_per_packet) {
perfect = TRUE;
} else {
if (!session->raw_write_buffer) {
@@ -828,6 +828,12 @@
}
if (perfect) {
+
+ if (write_frame->datalen < session->write_codec->implementation->decoded_bytes_per_packet) {
+ memset(write_frame->data, 255, session->write_codec->implementation->decoded_bytes_per_packet - write_frame->datalen);
+ write_frame->datalen = session->write_codec->implementation->decoded_bytes_per_packet;
+ }
+
enc_frame = write_frame;
session->enc_write_frame.datalen = session->enc_write_frame.buflen;
Modified: freeswitch/branches/1.0/src/switch_core_session.c
==============================================================================
--- freeswitch/branches/1.0/src/switch_core_session.c (original)
+++ freeswitch/branches/1.0/src/switch_core_session.c Thu Jan 22 17:01:56 2009
@@ -110,11 +110,12 @@
switch_hash_this(hi, NULL, NULL, &val);
if (val) {
session = (switch_core_session_t *) val;
- switch_core_session_read_lock(session);
- if (session->endpoint_interface == endpoint_interface) {
- switch_channel_hangup(switch_core_session_get_channel(session), cause);
+ if (switch_core_session_read_lock(session) == SWITCH_STATUS_SUCCESS) {
+ if (session->endpoint_interface == endpoint_interface) {
+ switch_channel_hangup(switch_core_session_get_channel(session), cause);
+ }
+ switch_core_session_rwunlock(session);
}
- switch_core_session_rwunlock(session);
}
}
switch_mutex_unlock(runtime.throttle_mutex);
@@ -132,9 +133,10 @@
switch_hash_this(hi, NULL, NULL, &val);
if (val) {
session = (switch_core_session_t *) val;
- switch_core_session_read_lock(session);
- switch_channel_hangup(switch_core_session_get_channel(session), cause);
- switch_core_session_rwunlock(session);
+ if (switch_core_session_read_lock(session) == SWITCH_STATUS_SUCCESS) {
+ switch_channel_hangup(switch_core_session_get_channel(session), cause);
+ switch_core_session_rwunlock(session);
+ }
}
}
switch_mutex_unlock(runtime.throttle_mutex);
@@ -744,13 +746,14 @@
return x;
}
-SWITCH_DECLARE(void) switch_core_session_reset(switch_core_session_t *session, switch_bool_t flush_dtmf)
+SWITCH_DECLARE(void) switch_core_session_reset(switch_core_session_t *session, switch_bool_t flush_dtmf, switch_bool_t reset_read_codec)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_size_t has;
-
- switch_core_session_set_read_codec(session, NULL);
+ if (reset_read_codec) {
+ switch_core_session_set_read_codec(session, NULL);
+ }
/* clear resamplers */
switch_mutex_lock(session->resample_mutex);
@@ -824,7 +827,7 @@
switch_channel_get_name((*session)->channel), switch_channel_state_name(switch_channel_get_state((*session)->channel)));
- switch_core_session_reset(*session, TRUE);
+ switch_core_session_reset(*session, TRUE, SWITCH_TRUE);
switch_core_media_bug_remove_all(*session);
switch_ivr_deactivate_unicast(*session);
Modified: freeswitch/branches/1.0/src/switch_core_state_machine.c
==============================================================================
--- freeswitch/branches/1.0/src/switch_core_state_machine.c (original)
+++ freeswitch/branches/1.0/src/switch_core_state_machine.c Thu Jan 22 17:01:56 2009
@@ -185,7 +185,7 @@
{
switch_assert(session != NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Standard PARK\n", switch_channel_get_name(session->channel));
- switch_core_session_reset(session, SWITCH_TRUE);
+ switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
switch_ivr_park(session, NULL);
}
Modified: freeswitch/branches/1.0/src/switch_ivr.c
==============================================================================
--- freeswitch/branches/1.0/src/switch_ivr.c (original)
+++ freeswitch/branches/1.0/src/switch_ivr.c Thu Jan 22 17:01:56 2009
@@ -1163,7 +1163,7 @@
max_forwards = switch_core_session_sprintf(session, "%d", forwardval);
switch_channel_set_variable(channel, SWITCH_MAX_FORWARDS_VARIABLE, max_forwards);
- switch_core_session_reset(session, SWITCH_TRUE);
+ switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
switch_channel_clear_flag(channel, CF_ORIGINATING);
/* clear all state handlers */
Modified: freeswitch/branches/1.0/src/switch_ivr_async.c
==============================================================================
--- freeswitch/branches/1.0/src/switch_ivr_async.c (original)
+++ freeswitch/branches/1.0/src/switch_ivr_async.c Thu Jan 22 17:01:56 2009
@@ -371,7 +371,7 @@
read_codec->implementation->actual_samples_per_second,
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
- switch_core_session_reset(session, SWITCH_TRUE);
+ switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
return SWITCH_STATUS_GENERR;
}
@@ -794,7 +794,7 @@
switch_core_session_rwunlock(tsession);
status = SWITCH_STATUS_SUCCESS;
- switch_core_session_reset(session, SWITCH_TRUE);
+ switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
}
return status;
@@ -842,6 +842,7 @@
fh->channels = channels;
fh->samplerate = read_codec->implementation->actual_samples_per_second;
+ fh->pre_buffer_datalen = SWITCH_DEFAULT_FILE_BUFFER_LEN;
if (switch_core_file_open(fh,
file,
@@ -850,7 +851,7 @@
SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening %s\n", file);
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
- switch_core_session_reset(session, SWITCH_TRUE);
+ switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
return SWITCH_STATUS_GENERR;
}
@@ -1678,7 +1679,11 @@
switch_thread_cond_create(&sth->cond, sth->pool);
switch_mutex_init(&sth->mutex, SWITCH_MUTEX_NESTED, sth->pool);
- switch_core_session_read_lock(sth->session);
+ if (switch_core_session_read_lock(sth->session) != SWITCH_STATUS_SUCCESS) {
+ sth->ready = 0;
+ return NULL;
+ }
+
switch_mutex_lock(sth->mutex);
sth->ready = 1;
Modified: freeswitch/branches/1.0/src/switch_ivr_bridge.c
==============================================================================
--- freeswitch/branches/1.0/src/switch_ivr_bridge.c (original)
+++ freeswitch/branches/1.0/src/switch_ivr_bridge.c Thu Jan 22 17:01:56 2009
@@ -430,7 +430,7 @@
end:
- switch_core_session_reset(session_a, SWITCH_TRUE);
+ switch_core_session_reset(session_a, SWITCH_TRUE, SWITCH_TRUE);
switch_channel_set_variable(chan_a, SWITCH_BRIDGE_VARIABLE, NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "BRIDGE THREAD DONE [%s]\n", switch_channel_get_name(chan_a));
if (!inner_bridge) {
@@ -451,7 +451,7 @@
switch_channel_set_private(channel, "_bridge_", NULL);
if (bd->session == session && *bd->b_uuid) {
audio_bridge_thread(NULL, (void *) bd);
- switch_core_session_reset(session, SWITCH_TRUE);
+ switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
} else {
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
}
@@ -581,7 +581,7 @@
switch_channel_wait_for_state(channel, other_channel, CS_SOFT_EXECUTE);
- switch_core_session_reset(session, SWITCH_TRUE);
+ switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
ready_a = switch_channel_ready(channel);
Modified: freeswitch/branches/1.0/src/switch_ivr_originate.c
==============================================================================
--- freeswitch/branches/1.0/src/switch_ivr_originate.c (original)
+++ freeswitch/branches/1.0/src/switch_ivr_originate.c Thu Jan 22 17:01:56 2009
@@ -501,9 +501,9 @@
}
olen = mlen;
- if (ringback.fh->resampler && ringback.fh->resampler->rfactor > 1) {
- olen = (switch_size_t) (olen * ringback.fh->resampler->rfactor);
- }
+ //if (ringback.fh->resampler && ringback.fh->resampler->rfactor > 1) {
+ //olen = (switch_size_t) (olen * ringback.fh->resampler->rfactor);
+ //}
switch_core_file_read(ringback.fh, write_frame.data, &olen);
if (olen == 0) {
@@ -547,7 +547,7 @@
switch_buffer_destroy(&ringback.audio_buffer);
}
- switch_core_session_reset(session, SWITCH_TRUE);
+ switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
if (write_codec.implementation) {
switch_core_codec_destroy(&write_codec);
@@ -1128,7 +1128,10 @@
continue;
}
- switch_core_session_read_lock(new_session);
+ if (switch_core_session_read_lock(new_session) != SWITCH_STATUS_SUCCESS) {
+ status = SWITCH_STATUS_FALSE;
+ goto done;
+ }
pool = NULL;
caller_profiles[i] = new_profile;
@@ -1473,9 +1476,10 @@
}
olen = mlen;
- if (ringback.fh->resampler && ringback.fh->resampler->rfactor > 1) {
- olen = (switch_size_t) (olen * ringback.fh->resampler->rfactor);
- }
+
+ //if (ringback.fh->resampler && ringback.fh->resampler->rfactor > 1) {
+ //olen = (switch_size_t) (olen * ringback.fh->resampler->rfactor);
+ //}
switch_core_file_read(ringback.fh, write_frame.data, &olen);
@@ -1527,7 +1531,7 @@
if (session && (ringback_data || !(switch_channel_test_flag(caller_channel, CF_PROXY_MODE) &&
switch_channel_test_flag(caller_channel, CF_PROXY_MEDIA)))) {
- switch_core_session_reset(session, SWITCH_FALSE);
+ switch_core_session_reset(session, SWITCH_FALSE, SWITCH_TRUE);
}
for (i = 0; i < and_argc; i++) {
@@ -1716,7 +1720,7 @@
}
if (session) {
- switch_core_session_reset(session, SWITCH_FALSE);
+ switch_core_session_reset(session, SWITCH_FALSE, SWITCH_TRUE);
}
if (write_codec.implementation) {
Modified: freeswitch/branches/1.0/src/switch_ivr_play_say.c
==============================================================================
--- freeswitch/branches/1.0/src/switch_ivr_play_say.c (original)
+++ freeswitch/branches/1.0/src/switch_ivr_play_say.c Thu Jan 22 17:01:56 2009
@@ -402,7 +402,7 @@
read_codec->implementation->actual_samples_per_second,
SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
- switch_core_session_reset(session, SWITCH_TRUE);
+ switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
return SWITCH_STATUS_GENERR;
}
@@ -460,7 +460,7 @@
"Raw Codec Activation Failed %s@%uhz %u channels %dms\n", codec_name, fh->samplerate,
fh->channels, read_codec->implementation->microseconds_per_packet / 1000);
switch_core_file_close(fh);
- switch_core_session_reset(session, SWITCH_TRUE);
+ switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
return SWITCH_STATUS_GENERR;
}
@@ -580,7 +580,7 @@
}
switch_core_file_close(fh);
- switch_core_session_reset(session, SWITCH_TRUE);
+ switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
return status;
}
@@ -853,7 +853,7 @@
read_codec->implementation->number_of_channels,
read_codec->implementation->actual_samples_per_second,
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
- switch_core_session_reset(session, SWITCH_TRUE);
+ switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
status = SWITCH_STATUS_NOTFOUND;
goto end;
}
@@ -910,7 +910,7 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Setup buffer failed\n");
switch_core_file_close(fh);
- switch_core_session_reset(session, SWITCH_TRUE);
+ switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
status = SWITCH_STATUS_GENERR;
goto end;
@@ -937,7 +937,7 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"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, SWITCH_TRUE);
+ switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
status = SWITCH_STATUS_GENERR;
goto end;
}
@@ -953,7 +953,7 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Setup timer failed!\n");
switch_core_codec_destroy(&codec);
switch_core_file_close(fh);
- switch_core_session_reset(session, SWITCH_TRUE);
+ switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
status = SWITCH_STATUS_GENERR;
goto end;
}
@@ -1238,7 +1238,7 @@
end:
switch_safe_free(abuf);
- switch_core_session_reset(session, SWITCH_FALSE);
+ switch_core_session_reset(session, SWITCH_FALSE, SWITCH_TRUE);
return status;
}
@@ -1275,7 +1275,7 @@
read_codec->implementation->number_of_channels,
read_codec->implementation->actual_samples_per_second,
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
- switch_core_session_reset(session, SWITCH_TRUE);
+ switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
return SWITCH_STATUS_NOTFOUND;
}
switch_zmalloc(abuf, SWITCH_RECOMMENDED_BUFFER_SIZE);
@@ -1362,7 +1362,7 @@
}
}
- switch_core_session_reset(session, SWITCH_FALSE);
+ switch_core_session_reset(session, SWITCH_FALSE, SWITCH_TRUE);
switch_core_codec_destroy(&raw_codec);
end:
@@ -1835,7 +1835,7 @@
timer_name = switch_channel_get_variable(channel, "timer_name");
- switch_core_session_reset(session, SWITCH_FALSE);
+ switch_core_session_reset(session, SWITCH_FALSE, SWITCH_TRUE);
read_codec = switch_core_session_get_read_codec(session);
rate = read_codec->implementation->actual_samples_per_second;
@@ -1846,7 +1846,7 @@
if (switch_core_speech_open(sh, tts_name, voice_name, (uint32_t) rate, interval,
&flags, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module!\n");
- switch_core_session_reset(session, SWITCH_TRUE);
+ switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
if (cache_obj) {
switch_channel_set_private(channel, SWITCH_CACHE_SPEECH_HANDLES_OBJ_NAME, NULL);
}
@@ -1872,7 +1872,7 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed %s@%uhz 1 channel %dms\n", codec_name, rate, interval);
flags = 0;
switch_core_speech_close(sh, &flags);
- switch_core_session_reset(session, SWITCH_TRUE);
+ switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
if (cache_obj) {
switch_channel_set_private(channel, SWITCH_CACHE_SPEECH_HANDLES_OBJ_NAME, NULL);
}
@@ -1889,7 +1889,7 @@
switch_core_codec_destroy(write_frame.codec);
flags = 0;
switch_core_speech_close(sh, &flags);
- switch_core_session_reset(session, SWITCH_TRUE);
+ switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
if (cache_obj) {
switch_channel_set_private(channel, SWITCH_CACHE_SPEECH_HANDLES_OBJ_NAME, NULL);
}
@@ -1918,7 +1918,7 @@
}
}
- switch_core_session_reset(session, SWITCH_FALSE);
+ switch_core_session_reset(session, SWITCH_FALSE, SWITCH_TRUE);
return status;
}
1
0
[Freeswitch-branches] [commit] r11424 - freeswitch/branches/1.0/src/mod/endpoints/mod_sofia
by FreeSWITCH SVN 22 Jan '09
by FreeSWITCH SVN 22 Jan '09
22 Jan '09
Author: mikej
Date: Thu Jan 22 16:58:28 2009
New Revision: 11424
Log:
mod_sofia: add support in sdp for a=maxptime (r:11103)
Modified:
freeswitch/branches/1.0/src/mod/endpoints/mod_sofia/sofia_glue.c
Modified: freeswitch/branches/1.0/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/branches/1.0/src/mod/endpoints/mod_sofia/sofia_glue.c (original)
+++ freeswitch/branches/1.0/src/mod/endpoints/mod_sofia/sofia_glue.c Thu Jan 22 16:58:28 2009
@@ -2252,7 +2252,7 @@
sdp_media_t *m;
sdp_attribute_t *attr;
int first = 0, last = 0;
- int ptime = 0, dptime = 0;
+ int ptime = 0, dptime = 0, maxptime = 0, dmaxptime = 0;
int sendonly = 0;
int greedy = 0, x = 0, skip = 0, mine = 0;
switch_channel_t *channel = switch_core_session_get_channel(session);
@@ -2302,6 +2302,8 @@
sendonly = 0;
} else if (!strcasecmp(attr->a_name, "ptime")) {
dptime = atoi(attr->a_value);
+ } else if (!strcasecmp(attr->a_name, "maxptime")) {
+ dmaxptime = atoi(attr->a_value);
}
}
@@ -2314,6 +2316,7 @@
sdp_connection_t *connection;
ptime = dptime;
+ maxptime = dmaxptime;
if (m->m_proto == sdp_proto_srtp) {
got_savp++;
@@ -2360,6 +2363,8 @@
for (attr = m->m_attributes; attr; attr = attr->a_next) {
if (!strcasecmp(attr->a_name, "ptime") && attr->a_value) {
ptime = atoi(attr->a_value);
+ } else if (!strcasecmp(attr->a_name, "maxptime") && attr->a_value) {
+ maxptime = atoi(attr->a_value);
} else if (!got_crypto && !strcasecmp(attr->a_name, "crypto") && !switch_strlen_zero(attr->a_value)) {
int crypto_tag;
@@ -2498,6 +2503,10 @@
first = 0;
last = tech_pvt->num_codecs;
}
+
+ if (maxptime && (!ptime || ptime > maxptime)) {
+ ptime = maxptime;
+ }
for (i = first; i < last && i < tech_pvt->num_codecs; i++) {
const switch_codec_implementation_t *imp = tech_pvt->codecs[i];
@@ -2515,7 +2524,8 @@
}
if (match) {
- if ((ptime && ptime * 1000 != imp->microseconds_per_packet) || map->rm_rate != codec_rate) {
+ if ((ptime && ptime * 1000 != imp->microseconds_per_packet) ||
+ map->rm_rate != codec_rate) {
near_rate = map->rm_rate;
near_match = imp;
match = 0;
@@ -2545,9 +2555,14 @@
mimp = near_match;
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Substituting codec %s@%ui@%uh\n",
- mimp->iananame, mimp->microseconds_per_packet / 1000, mimp->samples_per_second);
- match = 1;
+ if (!maxptime || mimp->microseconds_per_packet / 1000 <= maxptime) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Substituting codec %s@%ui@%uh\n",
+ mimp->iananame, mimp->microseconds_per_packet / 1000, mimp->samples_per_second);
+ match = 1;
+ } else {
+ mimp = NULL;
+ match = 0;
+ }
}
if (!match && greedy) {
1
0
[Freeswitch-branches] [commit] r11423 - freeswitch/branches/1.0/conf/dialplan
by FreeSWITCH SVN 22 Jan '09
by FreeSWITCH SVN 22 Jan '09
22 Jan '09
Author: mikej
Date: Thu Jan 22 16:53:11 2009
New Revision: 11423
Log:
Modified:
freeswitch/branches/1.0/conf/dialplan/public.xml
Modified: freeswitch/branches/1.0/conf/dialplan/public.xml
==============================================================================
--- freeswitch/branches/1.0/conf/dialplan/public.xml (original)
+++ freeswitch/branches/1.0/conf/dialplan/public.xml Thu Jan 22 16:53:11 2009
@@ -31,7 +31,7 @@
</extension>
<extension name="call_debug" continue="true">
- <condition field="$${call_debug}" expression="^true$" break="never">
+ <condition field="${call_debug}" expression="^true$" break="never">
<action application="info"/>
</condition>
</extension>
1
0
22 Jan '09
Author: mikej
Date: Thu Jan 22 16:51:26 2009
New Revision: 11422
Log:
core: fix buffering issues (r:11101,11145)
Modified:
freeswitch/branches/1.0/src/switch_core_file.c
Modified: freeswitch/branches/1.0/src/switch_core_file.c
==============================================================================
--- freeswitch/branches/1.0/src/switch_core_file.c (original)
+++ freeswitch/branches/1.0/src/switch_core_file.c Thu Jan 22 16:51:26 2009
@@ -161,11 +161,12 @@
if (fh->resampler->to_len < want || fh->resampler->to_len > orig_len) {
if (!fh->buffer) {
- switch_buffer_create_dynamic(&fh->buffer, fh->resampler->to_len * 4, fh->resampler->to_len * 8, fh->resampler->to_len * 32);
+ int factor = fh->resampler->to_len * fh->samplerate / 1000;
+ switch_buffer_create_dynamic(&fh->buffer, factor, factor, 0);
switch_assert(fh->buffer);
}
if (!fh->dbuf) {
- fh->dbuflen = fh->resampler->to_len * 8;
+ fh->dbuflen = want * 2;
fh->dbuf = switch_core_alloc(fh->memory_pool, fh->dbuflen);
}
switch_assert(fh->resampler->to_len <= fh->dbuflen);
@@ -174,7 +175,7 @@
switch_buffer_write(fh->buffer, fh->dbuf, fh->resampler->to_len * 2);
if (switch_buffer_inuse(fh->buffer) < want * 2) {
- *len = want - fh->resampler->to_len;
+ *len = want;
goto more;
}
*len = switch_buffer_read(fh->buffer, data, orig_len * 2) / 2;
1
0
[Freeswitch-branches] [commit] r11420 - freeswitch/branches/1.0/src/mod/endpoints/mod_sofia
by FreeSWITCH SVN 22 Jan '09
by FreeSWITCH SVN 22 Jan '09
22 Jan '09
Author: mikej
Date: Thu Jan 22 16:36:07 2009
New Revision: 11420
Log:
Modified:
freeswitch/branches/1.0/src/mod/endpoints/mod_sofia/sofia_glue.c
Modified: freeswitch/branches/1.0/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/branches/1.0/src/mod/endpoints/mod_sofia/sofia_glue.c (original)
+++ freeswitch/branches/1.0/src/mod/endpoints/mod_sofia/sofia_glue.c Thu Jan 22 16:36:07 2009
@@ -2351,8 +2351,8 @@
switch_channel_set_variable(tech_pvt->channel, "has_t38", "true");
switch_channel_set_private(tech_pvt->channel, "t38_options", t38_options);
- switch_channel_set_flag(tech_pvt->channel, CF_PROXY_MEDIA);
- switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA);
+ //switch_channel_set_flag(tech_pvt->channel, CF_PROXY_MEDIA);
+ //switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA);
} else if (m->m_type == sdp_media_audio && m->m_port && !got_audio) {
sdp_rtpmap_t *map;
1
0