Freeswitch-trunk
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 2008
- 7 participants
- 386 discussions
Author: brian
Date: Fri Jan 4 20:03:57 2008
New Revision: 7084
Modified:
freeswitch/trunk/conf/sip_profiles/default.xml
Log:
turn this back on
Modified: freeswitch/trunk/conf/sip_profiles/default.xml
==============================================================================
--- freeswitch/trunk/conf/sip_profiles/default.xml (original)
+++ freeswitch/trunk/conf/sip_profiles/default.xml Fri Jan 4 20:03:57 2008
@@ -32,7 +32,7 @@
<!--<param name="dtmf-type" value="info"/>-->
<param name="record-template" value="$${base_dir}/recordings/${caller_id_number}.${strftime(%Y-%m-%d-%H-%M-%S)}.wav"/>
<!--enable to use presense and mwi -->
- <param name="manage-presence" value="false"/>
+ <param name="manage-presence" value="true"/>
<!-- This setting is for AAL2 bitpacking on G726 -->
<!-- <param name="bitpacking" value="aal2"/> -->
<!--max number of open dialogs in proceeding -->
1
0
[commit] r7083 - in freeswitch/trunk: conf/sip_profiles src src/include src/mod/endpoints/mod_sofia
by Freeswitch SVN 05 Jan '08
by Freeswitch SVN 05 Jan '08
05 Jan '08
Author: anthm
Date: Fri Jan 4 20:03:08 2008
New Revision: 7083
Modified:
freeswitch/trunk/conf/sip_profiles/default.xml
freeswitch/trunk/src/include/switch_ivr.h
freeswitch/trunk/src/include/switch_types.h
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
freeswitch/trunk/src/switch_core_state_machine.c
freeswitch/trunk/src/switch_ivr.c
freeswitch/trunk/src/switch_ivr_bridge.c
freeswitch/trunk/src/switch_ivr_originate.c
Log:
support crazy transfer crap
Modified: freeswitch/trunk/conf/sip_profiles/default.xml
==============================================================================
--- freeswitch/trunk/conf/sip_profiles/default.xml (original)
+++ freeswitch/trunk/conf/sip_profiles/default.xml Fri Jan 4 20:03:08 2008
@@ -32,7 +32,7 @@
<!--<param name="dtmf-type" value="info"/>-->
<param name="record-template" value="$${base_dir}/recordings/${caller_id_number}.${strftime(%Y-%m-%d-%H-%M-%S)}.wav"/>
<!--enable to use presense and mwi -->
- <param name="manage-presence" value="true"/>
+ <param name="manage-presence" value="false"/>
<!-- This setting is for AAL2 bitpacking on G726 -->
<!-- <param name="bitpacking" value="aal2"/> -->
<!--max number of open dialogs in proceeding -->
Modified: freeswitch/trunk/src/include/switch_ivr.h
==============================================================================
--- freeswitch/trunk/src/include/switch_ivr.h (original)
+++ freeswitch/trunk/src/include/switch_ivr.h Fri Jan 4 20:03:08 2008
@@ -727,6 +727,7 @@
SWITCH_DECLARE(void) switch_ivr_delay_echo(switch_core_session_t *session, uint32_t delay_ms);
SWITCH_DECLARE(void) switch_ivr_intercept_session(switch_core_session_t *session, const char *uuid);
SWITCH_DECLARE(void) switch_ivr_park_session(switch_core_session_t *session);
+SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t *session, switch_core_session_t *peer_session);
/** @} */
Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h (original)
+++ freeswitch/trunk/src/include/switch_types.h Fri Jan 4 20:03:08 2008
@@ -628,6 +628,7 @@
CF_VIDEO = (1 << 22) - Channel has video
CF_EVENT_LOCK = (1 << 23) - Don't parse events
CF_RESET = (1 << 24) - Tell extension parser to reset
+CF_ORIGINATING = (1 << 25) - Channel is originating
</pre>
*/
@@ -656,7 +657,8 @@
CF_UNICAST = (1 << 21),
CF_VIDEO = (1 << 22),
CF_EVENT_LOCK = (1 << 23),
- CF_RESET = (1 << 24)
+ CF_RESET = (1 << 24),
+ CF_ORIGINATING = (1 << 25)
} switch_channel_flag_t;
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Fri Jan 4 20:03:08 2008
@@ -1685,6 +1685,7 @@
switch_channel_set_variable(nchannel, "sip_destination_url", tech_pvt->dest);
caller_profile = switch_caller_profile_clone(nsession, outbound_profile);
+ caller_profile->destination_number = switch_core_strdup(caller_profile->pool, dest);
switch_channel_set_caller_profile(nchannel, caller_profile);
switch_channel_set_flag(nchannel, CF_OUTBOUND);
switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
Modified: freeswitch/trunk/src/switch_core_state_machine.c
==============================================================================
--- freeswitch/trunk/src/switch_core_state_machine.c (original)
+++ freeswitch/trunk/src/switch_core_state_machine.c Fri Jan 4 20:03:08 2008
@@ -132,7 +132,7 @@
char *expanded = NULL;
int nomedia = 0;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Execute %s(%s)\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Execute %s(%s)\n", switch_channel_get_name(session->channel),
extension->current_application->application_name, switch_str_nil(extension->current_application->application_data));
if ((application_interface = switch_loadable_module_get_application_interface(extension->current_application->application_name)) == 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Application %s\n", extension->current_application->application_name);
@@ -156,8 +156,9 @@
if ((expanded =
switch_channel_expand_variables(session->channel,
extension->current_application->application_data)) != extension->current_application->application_data) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Expanded String %s(%s)\n", extension->current_application->application_name,
- expanded);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Expanded String %s(%s)\n", switch_channel_get_name(session->channel),
+ extension->current_application->application_name, expanded);
+
}
if (switch_channel_get_variable(session->channel, "presence_id")) {
Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c (original)
+++ freeswitch/trunk/src/switch_ivr.c Fri Jan 4 20:03:08 2008
@@ -852,6 +852,8 @@
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
+ switch_channel_clear_flag(channel, CF_ORIGINATING);
+
/* clear all state handlers */
switch_channel_clear_state_handler(channel, NULL);
Modified: freeswitch/trunk/src/switch_ivr_bridge.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_bridge.c (original)
+++ freeswitch/trunk/src/switch_ivr_bridge.c Fri Jan 4 20:03:08 2008
@@ -596,7 +596,8 @@
switch_channel_answer(caller_channel);
}
- if (switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA)) {
+ if (switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA) ||
+ switch_channel_test_flag(peer_channel, CF_RING_READY)) {
switch_event_t *event;
switch_core_session_message_t msg = { 0 };
const switch_application_interface_t *application_interface;
@@ -627,7 +628,29 @@
}
}
-
+ if (!(switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA))) {
+ if ((status = switch_ivr_wait_for_answer(session, peer_session)) != SWITCH_STATUS_SUCCESS) {
+ switch_channel_state_t w_state = switch_channel_get_state(caller_channel);
+ switch_channel_hangup(peer_channel, SWITCH_CAUSE_ALLOTTED_TIMEOUT);
+ if (w_state < CS_HANGUP && w_state != CS_RING && w_state != CS_PARK && !switch_channel_test_flag(caller_channel, CF_TRANSFER) &&
+ w_state != CS_EXECUTE) {
+ const char *ext = switch_channel_get_variable(peer_channel, "original_destination_number");
+ if (!ext) {
+ ext = switch_channel_get_variable(peer_channel, "destination_number");
+ }
+
+ if (ext) {
+ switch_ivr_session_transfer(session, ext, NULL, NULL);
+ } else {
+ switch_channel_hangup(caller_channel, SWITCH_CAUSE_ALLOTTED_TIMEOUT);
+ }
+ }
+ switch_core_session_rwunlock(peer_session);
+ goto done;
+ }
+ }
+
+
msg.message_id = SWITCH_MESSAGE_INDICATE_BRIDGE;
msg.from = __FILE__;
msg.string_arg = switch_core_session_strdup(peer_session, switch_core_session_get_uuid(session));
@@ -707,8 +730,8 @@
SWITCH_DECLARE(switch_status_t) switch_ivr_uuid_bridge(const char *originator_uuid, const char *originatee_uuid)
{
- switch_core_session_t *originator_session, *originatee_session;
- switch_channel_t *originator_channel, *originatee_channel;
+ switch_core_session_t *originator_session, *originatee_session, *swap_session;
+ switch_channel_t *originator_channel, *originatee_channel, *swap_channel;
switch_status_t status = SWITCH_STATUS_FALSE;
switch_caller_profile_t *cp, *originator_cp, *originatee_cp;
@@ -717,6 +740,23 @@
originator_channel = switch_core_session_get_channel(originator_session);
originatee_channel = switch_core_session_get_channel(originatee_session);
+ if (!switch_channel_test_flag(originator_channel, CF_ANSWERED)) {
+ if (switch_channel_test_flag(originatee_channel, CF_ANSWERED)) {
+ swap_session = originator_session;
+ originator_session = originatee_session;
+ originatee_session = swap_session;
+
+ swap_channel = originator_channel;
+ originator_channel = originatee_channel;
+ originatee_channel = swap_channel;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "reversing order of channels so this will work!\n");
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Neither channel is answered, cannot bridge them.\n");
+ return SWITCH_STATUS_FALSE;
+ }
+ }
+
+
/* override transmit state for originator_channel to bridge to originatee_channel
* install pointer to originatee_session into originator_channel
* set CF_TRANSFER on both channels and change state to CS_TRANSMIT to
@@ -726,12 +766,13 @@
switch_channel_clear_state_handler(originator_channel, NULL);
switch_channel_clear_state_handler(originatee_channel, NULL);
- switch_channel_set_flag(originator_channel, CF_ORIGINATOR);
+ switch_channel_set_state_flag(originator_channel, CF_ORIGINATOR);
switch_channel_clear_flag(originatee_channel, CF_ORIGINATOR);
switch_channel_add_state_handler(originator_channel, &uuid_bridge_state_handlers);
switch_channel_add_state_handler(originatee_channel, &uuid_bridge_state_handlers);
switch_channel_set_variable(originator_channel, SWITCH_UUID_BRIDGE, switch_core_session_get_uuid(originatee_session));
+
switch_channel_set_variable(originator_channel, SWITCH_BRIDGE_CHANNEL_VARIABLE, switch_channel_get_name(originatee_channel));
switch_channel_set_variable(originator_channel, SWITCH_BRIDGE_UUID_VARIABLE, switch_core_session_get_uuid(originatee_session));
@@ -743,6 +784,16 @@
originator_cp = switch_channel_get_caller_profile(originator_channel);
originatee_cp = switch_channel_get_caller_profile(originatee_channel);
+
+
+ switch_channel_set_variable(originatee_channel, "original_destination_number", originatee_cp->destination_number);
+ switch_channel_set_variable(originatee_channel, "original_caller_id_name", originatee_cp->caller_id_name);
+ switch_channel_set_variable(originatee_channel, "original_caller_id_number", originatee_cp->caller_id_number);
+
+ switch_channel_set_variable(originator_channel, "original_destination_number", originator_cp->destination_number);
+ switch_channel_set_variable(originator_channel, "original_caller_id_name", originator_cp->caller_id_name);
+ switch_channel_set_variable(originator_channel, "original_caller_id_number", originator_cp->caller_id_number);
+
cp = switch_caller_profile_clone(originatee_session, originatee_cp);
cp->destination_number = switch_core_strdup(cp->pool, originator_cp->caller_id_number);
@@ -750,7 +801,7 @@
cp->caller_id_name = switch_core_strdup(cp->pool, originator_cp->caller_id_name);
switch_channel_set_caller_profile(originatee_channel, cp);
switch_channel_set_originator_caller_profile(originatee_channel, switch_caller_profile_clone(originatee_session, originator_cp));
-
+
cp = switch_caller_profile_clone(originator_session, originator_cp);
cp->destination_number = switch_core_strdup(cp->pool, originatee_cp->caller_id_number);
cp->caller_id_number = switch_core_strdup(cp->pool, originatee_cp->caller_id_number);
@@ -763,6 +814,9 @@
switch_channel_set_flag(originator_channel, CF_TRANSFER);
switch_channel_set_flag(originatee_channel, CF_TRANSFER);
+
+ switch_channel_clear_flag(originator_channel, CF_ORIGINATING);
+ switch_channel_clear_flag(originatee_channel, CF_ORIGINATING);
/* change the states and let the chips fall where they may */
switch_channel_set_state(originator_channel, CS_RESET);
Modified: freeswitch/trunk/src/switch_ivr_originate.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_originate.c (original)
+++ freeswitch/trunk/src/switch_ivr_originate.c Fri Jan 4 20:03:08 2008
@@ -165,13 +165,19 @@
*idx = IDX_NADA;
for (i = 0; i < len; i++) {
+ switch_channel_state_t state;
if (!peer_channels[i]) {
continue;
}
if (!*ring_ready && switch_channel_test_flag(peer_channels[i], CF_RING_READY)) {
*ring_ready = 1;
}
- if (switch_channel_get_state(peer_channels[i]) >= CS_HANGUP) {
+
+ state = switch_channel_get_state(peer_channels[i]);
+ if (state >= CS_HANGUP || state == CS_RESET || switch_channel_test_flag(peer_channels[i], CF_TRANSFER) ||
+ switch_channel_test_flag(peer_channels[i], CF_BRIDGED) ||
+ !switch_channel_test_flag(peer_channels[i], CF_ORIGINATING)
+ ) {
(*hups)++;
} else if ((switch_channel_test_flag(peer_channels[i], CF_ANSWERED) ||
(early_ok && len == 1 && switch_channel_test_flag(peer_channels[i], CF_EARLY_MEDIA))) &&
@@ -233,6 +239,284 @@
return 0;
}
+
+SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t *session, switch_core_session_t *peer_session)
+{
+ switch_channel_t *caller_channel;
+ switch_channel_t *peer_channel;
+ const char *ringback_data = NULL;
+ switch_frame_t write_frame = { 0 };
+ switch_codec_t write_codec = { 0 };
+ switch_codec_t *read_codec = NULL;
+ uint8_t pass = 0;
+ ringback_t ringback = { 0 };
+ switch_core_session_message_t *message = NULL;
+ switch_frame_t *read_frame = NULL;
+ switch_status_t status = SWITCH_STATUS_SUCCESS;
+ uint8_t abuf[1024];
+ int timelimit = 60;
+ const char *var;
+ switch_time_t start = 0;
+
+ caller_channel = switch_core_session_get_channel(session);
+ peer_channel = switch_core_session_get_channel(peer_session);
+
+ switch_assert(caller_channel && peer_channel);
+
+ if ((var = switch_channel_get_variable(caller_channel, "call_timeout"))) {
+ timelimit = atoi(var);
+ if (timelimit < 0) {
+ timelimit = 60;
+ }
+ }
+
+ timelimit *= 1000000;
+ start = switch_timestamp_now();
+
+ if ((switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA))) {
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ read_codec = switch_core_session_get_read_codec(session);
+
+ if (switch_channel_test_flag(caller_channel, CF_ANSWERED) || switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)) {
+ ringback_data = switch_channel_get_variable(caller_channel, "transfer_ringback");
+ }
+
+ if (!ringback_data) {
+ ringback_data = switch_channel_get_variable(caller_channel, "ringback");
+ }
+
+ switch_channel_set_variable(caller_channel, "originate_disposition", "failure");
+
+
+ if (ringback_data) {
+ char *tmp_data = NULL;
+ ringback_t ringback = { 0 };
+
+ switch_buffer_create_dynamic(&ringback.audio_buffer, 512, 1024, 0);
+ switch_buffer_set_loops(ringback.audio_buffer, -1);
+
+ if (switch_is_file_path(ringback_data)) {
+ char *ext;
+
+ if (strrchr(ringback_data, '.') || strstr(ringback_data, SWITCH_URL_SEPARATOR)) {
+ switch_core_session_set_read_codec(session, &write_codec);
+ } else {
+ ringback.asis++;
+ write_frame.codec = read_codec;
+ ext = read_codec->implementation->iananame;
+ tmp_data = switch_mprintf("%s.%s", ringback_data, ext);
+ ringback_data = tmp_data;
+ }
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Play Ringback File [%s]\n", ringback_data);
+
+ ringback.fhb.channels = read_codec->implementation->number_of_channels;
+ ringback.fhb.samplerate = read_codec->implementation->actual_samples_per_second;
+ if (switch_core_file_open(&ringback.fhb,
+ ringback_data,
+ read_codec->implementation->number_of_channels,
+ read_codec->implementation->actual_samples_per_second,
+ SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
+ switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Playing File\n");
+ switch_safe_free(tmp_data);
+ goto done;
+ }
+ ringback.fh = &ringback.fhb;
+
+
+ } else {
+ teletone_init_session(&ringback.ts, 0, teletone_handler, &ringback);
+ ringback.ts.rate = read_codec->implementation->actual_samples_per_second;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Play Ringback Tone [%s]\n", ringback_data);
+ //ringback.ts.debug = 1;
+ //ringback.ts.debug_stream = switch_core_get_console();
+ if (teletone_run(&ringback.ts, ringback_data)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Playing Tone\n");
+ teletone_destroy_session(&ringback.ts);
+ switch_buffer_destroy(&ringback.audio_buffer);
+ ringback_data = NULL;
+ }
+ }
+ switch_safe_free(tmp_data);
+
+ }
+
+
+ if (ringback_data && !switch_channel_test_flag(caller_channel, CF_ANSWERED) && !switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)) {
+ switch_channel_pre_answer(caller_channel);
+ }
+
+ if ((read_codec = switch_core_session_get_read_codec(session)) && (ringback_data || !switch_channel_test_flag(caller_channel, CF_BYPASS_MEDIA))) {
+ if (!(pass = (uint8_t) switch_test_flag(read_codec, SWITCH_CODEC_FLAG_PASSTHROUGH))) {
+ if (switch_core_codec_init(&write_codec,
+ "L16",
+ NULL,
+ read_codec->implementation->actual_samples_per_second,
+ read_codec->implementation->microseconds_per_frame / 1000,
+ 1, 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 Activation Success L16@%uhz 1 channel %dms\n",
+ read_codec->implementation->actual_samples_per_second, read_codec->implementation->microseconds_per_frame / 1000);
+ write_frame.data = abuf;
+ write_frame.buflen = sizeof(abuf);
+
+ write_frame.codec = &write_codec;
+ write_frame.datalen = read_codec->implementation->bytes_per_frame;
+ write_frame.samples = write_frame.datalen / 2;
+ memset(write_frame.data, 255, write_frame.datalen);
+
+ if (ringback_data) {
+ char *tmp_data = NULL;
+
+ switch_buffer_create_dynamic(&ringback.audio_buffer, 512, 1024, 0);
+ switch_buffer_set_loops(ringback.audio_buffer, -1);
+
+ if (switch_is_file_path(ringback_data)) {
+ char *ext;
+
+ if (strrchr(ringback_data, '.') || strstr(ringback_data, SWITCH_URL_SEPARATOR)) {
+ switch_core_session_set_read_codec(session, &write_codec);
+ } else {
+ ringback.asis++;
+ write_frame.codec = read_codec;
+ ext = read_codec->implementation->iananame;
+ tmp_data = switch_mprintf("%s.%s", ringback_data, ext);
+ ringback_data = tmp_data;
+ }
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Play Ringback File [%s]\n", ringback_data);
+
+ ringback.fhb.channels = read_codec->implementation->number_of_channels;
+ ringback.fhb.samplerate = read_codec->implementation->actual_samples_per_second;
+ if (switch_core_file_open(&ringback.fhb,
+ ringback_data,
+ read_codec->implementation->number_of_channels,
+ read_codec->implementation->actual_samples_per_second,
+ SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
+ switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Playing File\n");
+ switch_safe_free(tmp_data);
+ goto done;
+ }
+ ringback.fh = &ringback.fhb;
+
+
+ } else {
+ teletone_init_session(&ringback.ts, 0, teletone_handler, &ringback);
+ ringback.ts.rate = read_codec->implementation->actual_samples_per_second;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Play Ringback Tone [%s]\n", ringback_data);
+ //ringback.ts.debug = 1;
+ //ringback.ts.debug_stream = switch_core_get_console();
+ if (teletone_run(&ringback.ts, ringback_data)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Playing Tone\n");
+ teletone_destroy_session(&ringback.ts);
+ switch_buffer_destroy(&ringback.audio_buffer);
+ ringback_data = NULL;
+ }
+ }
+ switch_safe_free(tmp_data);
+ }
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec Error!\n");
+ switch_channel_hangup(caller_channel, SWITCH_CAUSE_NORMAL_TEMPORARY_FAILURE);
+ read_codec = NULL;
+ }
+ }
+ }
+
+ while (!(switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA))) {
+ int diff = (int)(switch_timestamp_now() - start);
+
+ if (diff > timelimit) {
+ status = SWITCH_STATUS_TIMEOUT;
+ goto done;
+ }
+
+ if (switch_core_session_dequeue_message(peer_session, &message) == SWITCH_STATUS_SUCCESS) {
+ switch_core_session_receive_message(session, message);
+
+ if (switch_test_flag(message, SCSMF_DYNAMIC)) {
+ switch_safe_free(message);
+ } else {
+ message = NULL;
+ }
+ }
+ status = switch_core_session_read_frame(session, &read_frame, 1000, 0);
+ if (!SWITCH_READ_ACCEPTABLE(status)) {
+ break;
+ }
+
+
+ if (read_frame && !pass) {
+ if (ringback.fh) {
+ uint8_t abuf[1024];
+ switch_size_t mlen, olen;
+ unsigned int pos = 0;
+
+ if (ringback.asis) {
+ mlen = write_frame.codec->implementation->encoded_bytes_per_frame;
+ } else {
+ mlen = write_frame.codec->implementation->samples_per_frame;
+ }
+
+ olen = mlen;
+ switch_core_file_read(ringback.fh, abuf, &olen);
+
+ if (olen == 0) {
+ olen = mlen;
+ ringback.fh->speed = 0;
+ switch_core_file_seek(ringback.fh, &pos, 0, SEEK_SET);
+ switch_core_file_read(ringback.fh, abuf, &olen);
+ if (olen == 0) {
+ break;
+ }
+ }
+ write_frame.data = abuf;
+ write_frame.datalen = (uint32_t) (ringback.asis ? olen : olen * 2);
+ } else if (ringback.audio_buffer) {
+ if ((write_frame.datalen = (uint32_t) switch_buffer_read_loop(ringback.audio_buffer,
+ write_frame.data,
+ write_frame.codec->implementation->bytes_per_frame)) <= 0) {
+ break;
+ }
+ }
+
+ if (switch_core_session_write_frame(session, &write_frame, 1000, 0) != SWITCH_STATUS_SUCCESS) {
+ break;
+ }
+ } else {
+ switch_yield(1000);
+ }
+ }
+
+ done:
+
+ if (ringback.fh) {
+ switch_core_file_close(ringback.fh);
+ ringback.fh = NULL;
+ } else if (ringback.audio_buffer) {
+ teletone_destroy_session(&ringback.ts);
+ switch_buffer_destroy(&ringback.audio_buffer);
+ }
+
+ if (!pass && write_codec.implementation) {
+ if (read_codec && !ringback.asis) {
+ switch_core_session_set_read_codec(session, read_codec);
+ switch_core_session_reset(session);
+ }
+ switch_core_codec_destroy(&write_codec);
+ }
+
+ return status;
+
+}
+
#define MAX_PEERS 128
SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *session,
switch_core_session_t **bleg,
@@ -608,8 +892,8 @@
peer_sessions[i] = new_session;
peer_channels[i] = switch_core_session_get_channel(new_session);
switch_assert(peer_channels[i] != NULL);
-
-
+ switch_channel_set_flag(peer_channels[i], CF_ORIGINATING);
+
if (var_event) {
switch_event_t *event;
switch_event_header_t *header;
@@ -888,6 +1172,14 @@
if (!peer_channels[i]) {
continue;
}
+
+ if (switch_channel_test_flag(peer_channels[i], CF_TRANSFER) || switch_channel_test_flag(peer_channels[i], CF_BRIDGED) ||
+ switch_channel_get_state(peer_channels[i]) == CS_RESET ||
+ !switch_channel_test_flag(peer_channels[i], CF_ORIGINATING)
+ ) {
+ continue;
+ }
+
if (i != idx) {
if (idx == IDX_CANCEL) {
if (to) {
@@ -916,6 +1208,7 @@
peer_channel = peer_channels[idx];
} else {
status = SWITCH_STATUS_FALSE;
+ peer_channel = NULL;
goto done;
}
@@ -968,6 +1261,10 @@
}
}
+ if (*cause == SWITCH_CAUSE_SUCCESS || *cause == SWITCH_CAUSE_UNALLOCATED) {
+ *cause = SWITCH_CAUSE_ORIGINATOR_CANCEL;
+ }
+
if (idx == IDX_CANCEL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"Originate Cancelled by originator termination Cause: %d [%s]\n", *cause, switch_channel_cause2str(*cause));
@@ -982,26 +1279,28 @@
switch_channel_set_variable(caller_channel, "originate_disposition", switch_channel_cause2str(*cause));
}
- if (!pass && write_codec.implementation) {
- switch_core_codec_destroy(&write_codec);
- }
-
if (ringback.fh) {
switch_core_file_close(ringback.fh);
ringback.fh = NULL;
+ } else if (ringback.audio_buffer) {
+ teletone_destroy_session(&ringback.ts);
+ switch_buffer_destroy(&ringback.audio_buffer);
+ }
+
+ if (!pass && write_codec.implementation) {
if (read_codec && !ringback.asis) {
switch_core_session_set_read_codec(session, read_codec);
switch_core_session_reset(session);
}
- } else if (ringback.audio_buffer) {
- teletone_destroy_session(&ringback.ts);
- switch_buffer_destroy(&ringback.audio_buffer);
+ switch_core_codec_destroy(&write_codec);
}
+
for (i = 0; i < and_argc; i++) {
if (!peer_channels[i]) {
continue;
}
+ switch_channel_clear_flag(peer_channels[i], CF_ORIGINATING);
if (status == SWITCH_STATUS_SUCCESS && bleg && *bleg && *bleg == peer_sessions[i]) {
continue;
}
1
0
Author: brian
Date: Fri Jan 4 13:24:00 2008
New Revision: 7082
Added:
freeswitch/trunk/scripts/scenario/
freeswitch/trunk/scripts/scenario/attended_transfer.button
freeswitch/trunk/scripts/scenario/blind_transfer.button
freeswitch/trunk/scripts/scenario/offhook.button
freeswitch/trunk/scripts/scenario/phones.cfg
freeswitch/trunk/scripts/scenario/runscenario.pl (contents, props changed)
Log:
These are used to run test scenarios against snom phones for automated testing
Added: freeswitch/trunk/scripts/scenario/attended_transfer.button
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/scenario/attended_transfer.button Fri Jan 4 13:24:00 2008
@@ -0,0 +1,14 @@
+Snom_300,key,CANCEL
+Snom_360,key,CANCEL
+Snom_370,key,CANCEL
+Snom_300,key,ONHOOK
+Snom_360,key,ONHOOK
+Snom_370,key,ONHOOK,1
+Snom_300,number,1006,1
+Snom_360,key,OFFHOOK, 1
+Snom_360,key,F_HOLD, 1
+Snom_360,number,1007,2
+Snom_370,key,OFFHOOK,1
+Snom_360,key,F_TRANSFER,2
+Snom_360,key,ONHOOK
+
Added: freeswitch/trunk/scripts/scenario/blind_transfer.button
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/scenario/blind_transfer.button Fri Jan 4 13:24:00 2008
@@ -0,0 +1,11 @@
+Snom_300,key,CANCEL
+Snom_360,key,CANCEL
+Snom_370,key,CANCEL
+Snom_300,key,ONHOOK
+Snom_360,key,ONHOOK
+Snom_370,key,ONHOOK,1
+Snom_300,number,1006,1
+Snom_360,key,OFFHOOK,1
+Snom_360,key,F_TRANSFER,1
+Snom_360,number,1007,2
+Snom_370,key,OFFHOOK,1
Added: freeswitch/trunk/scripts/scenario/offhook.button
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/scenario/offhook.button Fri Jan 4 13:24:00 2008
@@ -0,0 +1,8 @@
+Snom_300,key,OFFHOOK
+Snom_320,key,OFFHOOK
+Snom_360,key,OFFHOOK
+Snom_370,key,OFFHOOK
+Snom_300,key,ONHOOK
+Snom_320,key,ONHOOK
+Snom_360,key,ONHOOK
+Snom_370,key,ONHOOK
Added: freeswitch/trunk/scripts/scenario/phones.cfg
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/scenario/phones.cfg Fri Jan 4 13:24:00 2008
@@ -0,0 +1,4 @@
+Snom_300,10.0.1.241,1000
+Snom_320,10.0.1.242,1002
+Snom_360,10.0.1.243,1006
+Snom_370,10.0.1.244,1007
Added: freeswitch/trunk/scripts/scenario/runscenario.pl
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/scenario/runscenario.pl Fri Jan 4 13:24:00 2008
@@ -0,0 +1,59 @@
+#!/usr/bin/perl
+#
+# Scenario Test Execution.
+#
+use LWP::UserAgent;
+use Data::Dumper;
+
+$| =1;
+
+our $ua = LWP::UserAgent->new;
+my $phone = load_config();
+
+if(-f $ARGV[0]) {
+ run_scenario($ARGV[0]);
+} else {
+ print "No Scenario File?\n";
+ exit;
+}
+
+sub run_scenario($$) {
+ $file = shift;
+ open(SCENARIO,"<$file");
+ @commands = <SCENARIO>;
+ print Dumper $info;
+ foreach $command (@commands) {
+ chomp $command;
+ my($target, $type, $button, $delay) = split(",",$command);
+ &push_button($phone->{$target}, "$type", "$button", $delay);
+
+ }
+}
+
+sub push_button ($$$) {
+ $info = shift;
+ $type = shift;
+ $button = shift;
+ $delay = shift;
+
+ if($delay) {
+ sleep($delay);
+ } else {
+ $delay = 0;
+ }
+ print "$info->{name} -> $type => $button with delay $delay\n";
+
+ $request = HTTP::Request->new("GET", "http://$info->{ip}/command.htm?$type=$button");
+ $return = $ua->request($request);
+}
+
+sub load_config {
+ open(CFG,"<phones.cfg");
+ @phones = <CFG>;
+ foreach $line (@phones) {
+ chomp $line;
+ my($name,$ip,$extension) = split(",", $line);
+ $phone->{$name} = {name => $name, ip => $ip, extension => $extension}
+ }
+ return $phone;
+}
1
0
Author: anthm
Date: Fri Jan 4 11:43:50 2008
New Revision: 7081
Modified:
freeswitch/trunk/libs/sqlite/.update
freeswitch/trunk/libs/sqlite/src/sqliteInt.h
Log:
update
Modified: freeswitch/trunk/libs/sqlite/.update
==============================================================================
--- freeswitch/trunk/libs/sqlite/.update (original)
+++ freeswitch/trunk/libs/sqlite/.update Fri Jan 4 11:43:50 2008
@@ -1 +1 @@
-date
+Fri Jan 4 10:43:39 CST 2008
Modified: freeswitch/trunk/libs/sqlite/src/sqliteInt.h
==============================================================================
--- freeswitch/trunk/libs/sqlite/src/sqliteInt.h (original)
+++ freeswitch/trunk/libs/sqlite/src/sqliteInt.h Fri Jan 4 11:43:50 2008
@@ -15,7 +15,7 @@
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_
-
+#define _GNU_SOURCE
/*
** Extra interface definitions for those who need them
*/
@@ -285,14 +285,22 @@
#define ENTER_MALLOC 0
#define sqliteMalloc(x) zmalloc(x)//sqlite3Malloc(x,1)
#define sqliteMallocRaw(x) malloc(x)//sqlite3MallocRaw(x,1)
-#define sqliteRealloc(x,y) sqlite3Realloc(x,y)
-#define sqliteStrDup(x) sqlite3StrDup(x)
-#define sqliteStrNDup(x,y) sqlite3StrNDup(x,y)
+#define sqliteRealloc(x,y) realloc(x, y)//sqlite3Realloc(x,y)
+#define sqliteStrDup(x) strdup(x)//sqlite3StrDup(x)
+#define sqliteStrNDup(x,y) strndup(x, y)//sqlite3StrNDup(x,y)
#define sqliteReallocOrFree(x,y) sqlite3ReallocOrFree(x,y)
#endif
-#define sqliteFree(x) sqlite3FreeX(x)
+static inline void sane_free(void *x)
+{
+ if (x) {
+ free(x);
+ x = NULL;
+ }
+}
+
+#define sqliteFree(x) sane_free(x) //sqlite3FreeX(x)
#define sqliteAllocSize(x) sqlite3AllocSize(x)
1
0
04 Jan '08
Author: mikej
Date: Thu Jan 3 20:49:26 2008
New Revision: 7080
Modified:
freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c
Log:
check return from unlink.
Modified: freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c Thu Jan 3 20:49:26 2008
@@ -903,7 +903,9 @@
if ((*message_len = fh.sample_count / read_codec->implementation->actual_samples_per_second) < profile->min_record_len) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Message is less than minimum record length: %d, discarding it.\n",
profile->min_record_len);
- unlink(file_path);
+ if (unlink(file_path) != 0) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "failed to delete file [%s]\n", file_path);
+ }
goto record_file;
} else {
status = SWITCH_STATUS_SUCCESS;
1
0
[commit] r7079 - in freeswitch/trunk: conf/dialplan src src/include/private
by Freeswitch SVN 04 Jan '08
by Freeswitch SVN 04 Jan '08
04 Jan '08
Author: anthm
Date: Thu Jan 3 19:19:09 2008
New Revision: 7079
Modified:
freeswitch/trunk/conf/dialplan/default.xml
freeswitch/trunk/src/include/private/switch_core_pvt.h
freeswitch/trunk/src/switch_core_io.c
freeswitch/trunk/src/switch_core_session.c
Log:
add lock
Modified: freeswitch/trunk/conf/dialplan/default.xml
==============================================================================
--- freeswitch/trunk/conf/dialplan/default.xml (original)
+++ freeswitch/trunk/conf/dialplan/default.xml Thu Jan 3 19:19:09 2008
@@ -196,6 +196,7 @@
-->
<extension name="unpark">
<condition field="destination_number" expression="^5901$">
+ <action application="answer"/>
<action application="fifo" data="5900@$${domain} out nowait"/>
</condition>
</extension>
@@ -209,7 +210,7 @@
-->
<extension name="park">
<condition field="source" expression="mod_sofia" continue="on-true"/>
- <condition field="${sip_refer_to}" expression="park\+(.*)(a)(.*)>" continue="on-true">
+ <condition field="destination_number" expression="park\+(\d+)" continue="on-true">
<action application="fifo" data="$1@$${domain} in undef $${moh_uri}"/>
</condition>
</extension>
@@ -222,7 +223,7 @@
<condition field="destination_number" expression="^parking$" continue="on-true"/>
<condition field="${sip_to_params}" expression="fifo\=(\d+)">
<action application="answer"/>
- <action application="fifo" data="$1@$${domain} out undef"/>
+ <action application="fifo" data="$1@$${domain} out nowait"/>
</condition>
</extension>
Modified: freeswitch/trunk/src/include/private/switch_core_pvt.h
==============================================================================
--- freeswitch/trunk/src/include/private/switch_core_pvt.h (original)
+++ freeswitch/trunk/src/include/private/switch_core_pvt.h Thu Jan 3 19:19:09 2008
@@ -119,6 +119,7 @@
switch_audio_resampler_t *write_resampler;
switch_mutex_t *mutex;
+ switch_mutex_t *resample_mutex;
switch_thread_cond_t *cond;
switch_thread_rwlock_t *rwlock;
Modified: freeswitch/trunk/src/switch_core_io.c
==============================================================================
--- freeswitch/trunk/src/switch_core_io.c (original)
+++ freeswitch/trunk/src/switch_core_io.c Thu Jan 3 19:19:09 2008
@@ -191,11 +191,15 @@
switch (status) {
case SWITCH_STATUS_RESAMPLE:
if (!session->read_resampler) {
- if (switch_resample_create(&session->read_resampler,
- read_frame->codec->implementation->actual_samples_per_second,
- read_frame->codec->implementation->bytes_per_frame * 20,
- session->read_codec->implementation->actual_samples_per_second,
- session->read_codec->implementation->bytes_per_frame * 20, session->pool) != SWITCH_STATUS_SUCCESS) {
+ switch_mutex_lock(session->resample_mutex);
+ status = switch_resample_create(&session->read_resampler,
+ read_frame->codec->implementation->actual_samples_per_second,
+ read_frame->codec->implementation->bytes_per_frame * 20,
+ session->read_codec->implementation->actual_samples_per_second,
+ session->read_codec->implementation->bytes_per_frame * 20, session->pool);
+ switch_mutex_unlock(session->resample_mutex);
+
+ if (status != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to allocate resampler\n");
status = SWITCH_STATUS_FALSE;
goto done;
@@ -213,8 +217,10 @@
break;
case SWITCH_STATUS_NOOP:
if (session->read_resampler) {
+ switch_mutex_lock(session->resample_mutex);
switch_resample_destroy(&session->read_resampler);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Deactivating read resampler\n");
+ switch_mutex_unlock(session->resample_mutex);
}
status = SWITCH_STATUS_SUCCESS;
@@ -240,6 +246,7 @@
#if 0
if (session->read_resampler) {
short *data = read_frame->data;
+ switch_mutex_lock(session->resample_mutex);
session->read_resampler->from_len = switch_short_to_float(data, session->read_resampler->from, (int) read_frame->datalen / 2);
session->read_resampler->to_len =
@@ -249,6 +256,8 @@
read_frame->samples = session->read_resampler->to_len;
read_frame->datalen = session->read_resampler->to_len * 2;
read_frame->rate = session->read_resampler->to_rate;
+ switch_mutex_unlock(session->resample_mutex);
+
}
#endif
@@ -514,11 +523,13 @@
case SWITCH_STATUS_RESAMPLE:
write_frame = &session->raw_write_frame;
if (!session->write_resampler) {
+ switch_mutex_lock(session->resample_mutex);
status = switch_resample_create(&session->write_resampler,
frame->codec->implementation->actual_samples_per_second,
frame->codec->implementation->bytes_per_frame * 20,
session->write_codec->implementation->actual_samples_per_second,
session->write_codec->implementation->bytes_per_frame * 20, session->pool);
+ switch_mutex_unlock(session->resample_mutex);
if (status != SWITCH_STATUS_SUCCESS) {
goto done;
}
@@ -538,8 +549,10 @@
return SWITCH_STATUS_SUCCESS;
case SWITCH_STATUS_NOOP:
if (session->write_resampler) {
+ switch_mutex_lock(session->resample_mutex);
switch_resample_destroy(&session->write_resampler);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Deactivating write resampler\n");
+ switch_mutex_unlock(session->resample_mutex);
}
write_frame = frame;
status = SWITCH_STATUS_SUCCESS;
@@ -552,6 +565,8 @@
if (session->write_resampler) {
short *data = write_frame->data;
+
+ switch_mutex_lock(session->resample_mutex);
session->write_resampler->from_len = write_frame->datalen / 2;
switch_short_to_float(data, session->write_resampler->from, session->write_resampler->from_len);
@@ -568,6 +583,7 @@
write_frame->samples = session->write_resampler->to_len;
write_frame->datalen = write_frame->samples * 2;
write_frame->rate = session->write_resampler->to_rate;
+ switch_mutex_unlock(session->resample_mutex);
}
if (session->bugs) {
@@ -744,11 +760,14 @@
session->enc_write_frame.payload = session->write_codec->implementation->ianacode;
write_frame = &session->enc_write_frame;
if (!session->read_resampler) {
+ switch_mutex_lock(session->resample_mutex);
status = switch_resample_create(&session->read_resampler,
frame->codec->implementation->actual_samples_per_second,
frame->codec->implementation->bytes_per_frame * 20,
session->write_codec->implementation->actual_samples_per_second,
session->write_codec->implementation->bytes_per_frame * 20, session->pool);
+ switch_mutex_unlock(session->resample_mutex);
+
if (status != SWITCH_STATUS_SUCCESS) {
goto done;
}
@@ -766,8 +785,10 @@
break;
case SWITCH_STATUS_NOOP:
if (session->read_resampler) {
+ switch_mutex_lock(session->resample_mutex);
switch_resample_destroy(&session->read_resampler);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Deactivating read resampler\n");
+ switch_mutex_unlock(session->resample_mutex);
}
enc_frame->codec = session->write_codec;
enc_frame->samples = enc_frame->datalen / sizeof(int16_t);
@@ -788,7 +809,8 @@
if (session->read_resampler) {
short *data = write_frame->data;
-
+ switch_mutex_lock(session->resample_mutex);
+
session->read_resampler->from_len =
switch_short_to_float(data, session->read_resampler->from, (int) write_frame->datalen / 2);
session->read_resampler->to_len = (uint32_t)
@@ -799,6 +821,8 @@
write_frame->samples = session->read_resampler->to_len;
write_frame->datalen = session->read_resampler->to_len * 2;
write_frame->rate = session->read_resampler->to_rate;
+ switch_mutex_unlock(session->resample_mutex);
+
}
if (flag & SFF_CNG) {
switch_set_flag(write_frame, SFF_CNG);
Modified: freeswitch/trunk/src/switch_core_session.c
==============================================================================
--- freeswitch/trunk/src/switch_core_session.c (original)
+++ freeswitch/trunk/src/switch_core_session.c Thu Jan 3 19:19:09 2008
@@ -813,6 +813,7 @@
session->enc_read_frame.buflen = sizeof(session->enc_read_buf);
switch_mutex_init(&session->mutex, SWITCH_MUTEX_NESTED, session->pool);
+ switch_mutex_init(&session->resample_mutex, SWITCH_MUTEX_NESTED, session->pool);
switch_thread_rwlock_create(&session->bug_rwlock, session->pool);
switch_thread_cond_create(&session->cond, session->pool);
switch_thread_rwlock_create(&session->rwlock, session->pool);
1
0
[commit] r7078 - in freeswitch/trunk: conf conf/dialplan src/include src/mod/applications/mod_dptools src/mod/endpoints/mod_sofia
by Freeswitch SVN 03 Jan '08
by Freeswitch SVN 03 Jan '08
03 Jan '08
Author: anthm
Date: Thu Jan 3 18:42:15 2008
New Revision: 7078
Modified:
freeswitch/trunk/conf/dialplan/default.xml
freeswitch/trunk/conf/vars.xml
freeswitch/trunk/src/include/switch_types.h
freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
Log:
fix MODENDP-66
Modified: freeswitch/trunk/conf/dialplan/default.xml
==============================================================================
--- freeswitch/trunk/conf/dialplan/default.xml (original)
+++ freeswitch/trunk/conf/dialplan/default.xml Thu Jan 3 18:42:15 2008
@@ -2,6 +2,14 @@
<!-- http://wiki.freeswitch.org/wiki/Dialplan_XML -->
<include>
<context name="default">
+
+ <extension name="unloop">
+ <condition field="${unroll_loops}" expression="^true$" continue="on-true"/>
+ <condition field="${sip_looped_call}" expression="^true$">
+ <action application="deflect" data="${destination_number}"/>
+ </condition>
+ </extension>
+
<extension name="intercept">
<condition field="destination_number" expression="^886$">
<action application="answer"/>
@@ -35,8 +43,10 @@
<condition field="${numbering_plan}" expression="^$" break="never">
<action application="set_user" data="default@${domain}"/>
</condition>
- <condition>
+ <condition field="${call_debug}" expression="^true$" break="never">
<action application="info"/>
+ </condition>
+ <condition>
<action application="db" data="insert/spymap/${caller_id_number}/${uuid}"/>
<action application="db" data="insert/last_dial/${caller_id_number}/${destination_number}"/>
<action application="db" data="insert/last_dial/global/${uuid}"/>
Modified: freeswitch/trunk/conf/vars.xml
==============================================================================
--- freeswitch/trunk/conf/vars.xml (original)
+++ freeswitch/trunk/conf/vars.xml Thu Jan 3 18:42:15 2008
@@ -41,15 +41,14 @@
Used by: sofia.conf.xml dingaling.conf.xml
-->
<X-PRE-PROCESS cmd="set" data="external_sip_ip=stun:stun.fwdnet.net"/>
- <!-- server_name
- A public ip address or DNS name that is used when advertising conference
- presence or registering sip.
- Used by: conference.conf.xml
+ <!-- unroll-loops
+ Used to turn on sip loopback unrolling.
-->
+ <X-PRE-PROCESS cmd="set" data="unroll_loops=true"/>
<!-- outbound_caller_id and outbound_caller_name
The caller ID telephone number we should use when calling out.
Used by: conference.conf.xml
-->
<X-PRE-PROCESS cmd="set" data="outbound_caller_name=FreeSWITCH"/>
<X-PRE-PROCESS cmd="set" data="outbound_caller_id=8777423583"/>
-
+ <X-PRE-PROCESS cmd="set" data="call_debug=false"/>
Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h (original)
+++ freeswitch/trunk/src/include/switch_types.h Thu Jan 3 18:42:15 2008
@@ -431,6 +431,7 @@
SWITCH_MESSAGE_INDICATE_RESPOND - indicate reject
SWITCH_MESSAGE_INDICATE_BROADCAST - indicate media broadcast
SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT - indicate media broadcast
+ SWITCH_MESSAGE_INDICATE_DEFLECT - indicate deflect
</pre>
*/
typedef enum {
@@ -449,7 +450,8 @@
SWITCH_MESSAGE_INDICATE_REDIRECT,
SWITCH_MESSAGE_INDICATE_RESPOND,
SWITCH_MESSAGE_INDICATE_BROADCAST,
- SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT
+ SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT,
+ SWITCH_MESSAGE_INDICATE_DEFLECT
} switch_core_session_message_types_t;
Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Thu Jan 3 18:42:15 2008
@@ -428,6 +428,18 @@
}
+SWITCH_STANDARD_APP(deflect_function)
+{
+ switch_core_session_message_t msg = { 0 };
+
+ /* Tell the channel to respond the call */
+ msg.from = __FILE__;
+ msg.string_arg = data;
+ msg.message_id = SWITCH_MESSAGE_INDICATE_DEFLECT;
+ switch_core_session_receive_message(session, &msg);
+
+}
+
SWITCH_STANDARD_APP(set_function)
{
@@ -1398,8 +1410,9 @@
}
}
-
- switch_channel_hangup(caller_channel, cause);
+ if (!switch_channel_test_flag(caller_channel, CF_TRANSFER) && switch_channel_get_state(caller_channel) != CS_RING) {
+ switch_channel_hangup(caller_channel, cause);
+ }
return;
} else {
if (no_media_bridge) {
@@ -1632,6 +1645,7 @@
SWITCH_ADD_APP(app_interface, "ivr", "Run an ivr menu", "Run an ivr menu.", ivr_application_function, "<menu_name>", SAF_NONE);
SWITCH_ADD_APP(app_interface, "redirect", "Send session redirect", "Send a redirect message to a session.", redirect_function, "<redirect_data>", SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_APP(app_interface, "respond", "Send session respond", "Send a respond message to a session.", respond_function, "<respond_data>", SAF_SUPPORT_NOMEDIA);
+ SWITCH_ADD_APP(app_interface, "deflect", "Send call deflect", "Send a call deflect.", deflect_function, "<deflect_data>", SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_APP(app_interface, "reject", "Send session reject (depricated)", "Send a respond message to a session.", respond_function, "<respond_data>", SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_APP(app_interface, "queue_dtmf", "Queue dtmf to be sent", "Queue dtmf to be sent from a session", queue_dtmf_function, "<dtmf_data>", SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_APP(app_interface, "sched_hangup", SCHED_HANGUP_DESCR, SCHED_HANGUP_DESCR, sched_hangup_function, "[+]<time> [<cause>]", SAF_SUPPORT_NOMEDIA);
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Thu Jan 3 18:42:15 2008
@@ -914,6 +914,21 @@
nua_respond(tech_pvt->nh, SIP_302_MOVED_TEMPORARILY, SIPTAG_CONTACT_STR(msg->string_arg), TAG_END());
}
break;
+
+ case SWITCH_MESSAGE_INDICATE_DEFLECT:
+ {
+ char ref_to[128] = "";
+
+ if (!strstr(msg->string_arg, "sip:")) {
+ switch_snprintf(ref_to, sizeof(ref_to), "sip:%s@%s", msg->string_arg, tech_pvt->profile->sipip);
+ } else {
+ switch_set_string(ref_to, msg->string_arg);
+ }
+
+ nua_refer(tech_pvt->nh, SIPTAG_REFER_TO_STR(ref_to), SIPTAG_REFERRED_BY_STR(tech_pvt->contact_url), TAG_END());
+ }
+ break;
+
case SWITCH_MESSAGE_INDICATE_RESPOND:
if (msg->numeric_arg || msg->string_arg) {
int code = msg->numeric_arg;
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Thu Jan 3 18:42:15 2008
@@ -2241,7 +2241,7 @@
switch_event_t *v_event = NULL;
uint32_t sess_count = switch_core_session_count();
uint32_t sess_max = switch_core_session_limit(0);
- int is_auth = 0;
+ int is_auth = 0, calling_myself = 0;
su_addrinfo_t *my_addrinfo = msg_addrinfo(nua_current_request(nua));
if (sess_count >= sess_max) {
@@ -2261,12 +2261,19 @@
return;
}
+
+ get_addr(network_ip, sizeof(network_ip), &((struct sockaddr_in *) my_addrinfo->ai_addr)->sin_addr);
+
if ((profile->pflags & PFLAG_AUTH_CALLS) || sip->sip_proxy_authorization || sip->sip_authorization) {
- if (sofia_reg_handle_register(nua, profile, nh, sip, REG_INVITE, key, sizeof(key), &v_event)) {
- if (v_event) {
- switch_event_destroy(&v_event);
+ if (strcmp(network_ip, profile->sipip)) {
+ if (sofia_reg_handle_register(nua, profile, nh, sip, REG_INVITE, key, sizeof(key), &v_event)) {
+ if (v_event) {
+ switch_event_destroy(&v_event);
+ }
+ return;
}
- return;
+ } else {
+ calling_myself++;
}
is_auth++;
}
@@ -2288,13 +2295,16 @@
tech_pvt->key = switch_core_session_strdup(session, key);
}
- get_addr(network_ip, sizeof(network_ip), &((struct sockaddr_in *) my_addrinfo->ai_addr)->sin_addr);
-
channel = switch_core_session_get_channel(session);
+
if (is_auth) {
switch_channel_set_variable(channel, "sip_authorized", "true");
}
+ if (calling_myself) {
+ switch_channel_set_variable(channel, "sip_looped_call", "true");
+ }
+
if (v_event) {
switch_event_header_t *hp;
1
0
[commit] r7077 - in freeswitch/trunk: conf/autoload_configs src/mod/applications/mod_fifo src/mod/applications/mod_voicemail
by Freeswitch SVN 03 Jan '08
by Freeswitch SVN 03 Jan '08
03 Jan '08
Author: anthm
Date: Thu Jan 3 17:04:19 2008
New Revision: 7077
Modified:
freeswitch/trunk/conf/autoload_configs/voicemail.conf.xml
freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c
freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c
Log:
add min record len to voicemail
Modified: freeswitch/trunk/conf/autoload_configs/voicemail.conf.xml
==============================================================================
--- freeswitch/trunk/conf/autoload_configs/voicemail.conf.xml (original)
+++ freeswitch/trunk/conf/autoload_configs/voicemail.conf.xml Thu Jan 3 17:04:19 2008
@@ -7,6 +7,7 @@
<param name="terminator-key" value="#"/>
<param name="max-login-attempts" value="3"/>
<param name="digit-timeout" value="10000"/>
+ <param name="min-record-len" value="3"/>
<param name="max-record-len" value="300"/>
<param name="tone-spec" value="%(1000, 0, 640)"/>
<param name="callback-dialplan" value="XML"/>
Modified: freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c Thu Jan 3 17:04:19 2008
@@ -705,8 +705,10 @@
void *val, *pop;
fifo_node_t *node;
switch_memory_pool_t *pool = globals.pool;
- switch_mutex_lock(globals.mutex);
+ switch_mutex_t *mutex = globals.mutex;
+ switch_mutex_lock(mutex);
+
globals.running = 0;
/* Cleanup*/
for (hi = switch_hash_first(NULL, globals.fifo_hash); hi; hi = switch_hash_next(hi)) {
@@ -719,9 +721,8 @@
switch_core_hash_destroy(&node->consumer_hash);
}
switch_core_hash_destroy(&globals.fifo_hash);
- memset(&globals, 0, sizeof(globals));
- switch_mutex_unlock(globals.mutex);
-
+ memset(&globals, 0, sizeof(globals));
+ switch_mutex_unlock(mutex);
switch_core_destroy_memory_pool(&pool);
return SWITCH_STATUS_SUCCESS;
}
Modified: freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c Thu Jan 3 17:04:19 2008
@@ -96,6 +96,7 @@
char *date_fmt;
uint32_t digit_timeout;
uint32_t max_login_attempts;
+ uint32_t min_record_len;
uint32_t max_record_len;
switch_mutex_t *mutex;
uint32_t record_threshold;
@@ -289,7 +290,7 @@
char *record_copyright = "http://www.freeswitch.org";
switch_core_db_t *db;
- uint32_t timeout = 10000, max_login_attempts = 3, max_record_len = 300;
+ uint32_t timeout = 10000, max_login_attempts = 3, max_record_len = 300, min_record_len = 3;
db = NULL;
@@ -496,6 +497,16 @@
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "invalid attempts [%s] must be between 1 and 10 ms\n", val);
}
+ } else if (!strcasecmp(var, "min-record-len")) {
+ int tmp = 0;
+ if (!switch_strlen_zero(val)) {
+ tmp = atoi(val);
+ }
+ if (tmp > 0 && tmp < 10000) {
+ min_record_len = tmp;
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "invalid attempts [%s] must be between 1 and 10000s\n", val);
+ }
} else if (!strcasecmp(var, "max-record-len")) {
int tmp = 0;
if (!switch_strlen_zero(val)) {
@@ -578,6 +589,7 @@
profile->digit_timeout = timeout;
profile->max_login_attempts = max_login_attempts;
+ profile->min_record_len = min_record_len;
profile->max_record_len = max_record_len;
*profile->terminator_key = *terminator_key;
*profile->play_new_messages_key = *play_new_messages_key;
@@ -878,6 +890,7 @@
profile->record_file_key);
record_file:
+ *message_len = 0;
args.input_callback = cancel_on_dtmf;
TRY_CODE(switch_ivr_phrase_macro(session, macro_name, NULL, NULL, NULL));
TRY_CODE(switch_ivr_gentones(session, profile->tone_spec, 0, NULL));
@@ -887,9 +900,14 @@
fh.silence_hits = profile->record_silence_hits;
fh.samplerate = profile->record_sample_rate;
switch_ivr_record_file(session, &fh, file_path, &args, profile->max_record_len);
- *message_len = fh.sample_count / read_codec->implementation->actual_samples_per_second;
- status = SWITCH_STATUS_SUCCESS;
-
+ if ((*message_len = fh.sample_count / read_codec->implementation->actual_samples_per_second) < profile->min_record_len) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Message is less than minimum record length: %d, discarding it.\n",
+ profile->min_record_len);
+ unlink(file_path);
+ goto record_file;
+ } else {
+ status = SWITCH_STATUS_SUCCESS;
+ }
play_file:
memset(&fh, 0, sizeof(fh));
args.input_callback = control_playback;
1
0
Author: anthm
Date: Thu Jan 3 16:41:15 2008
New Revision: 7076
Modified:
freeswitch/trunk/src/switch_apr.c
freeswitch/trunk/src/switch_time.c
Log:
update
Modified: freeswitch/trunk/src/switch_apr.c
==============================================================================
--- freeswitch/trunk/src/switch_apr.c (original)
+++ freeswitch/trunk/src/switch_apr.c Thu Jan 3 16:41:15 2008
@@ -233,7 +233,7 @@
SWITCH_DECLARE(switch_time_t) switch_time_now(void)
{
-#ifdef HAVE_CLOCK_GETTIME
+#if defined(HAVE_CLOCK_GETTIME) && defined(SWITCH_USE_CLOCK_FUNCS)
struct timespec ts;
clock_gettime(CLOCK_REALTIME,&ts);
return ts.tv_sec * APR_USEC_PER_SEC + (ts.tv_nsec/1000);
Modified: freeswitch/trunk/src/switch_time.c
==============================================================================
--- freeswitch/trunk/src/switch_time.c (original)
+++ freeswitch/trunk/src/switch_time.c Thu Jan 3 16:41:15 2008
@@ -82,8 +82,8 @@
SWITCH_DECLARE(void) switch_sleep(switch_interval_time_t t)
{
-
-#if defined(HAVE_CLOCK_NANOSLEEP)
+
+#if defined(HAVE_CLOCK_NANOSLEEP) && defined(SWITCH_USE_CLOCK_FUNCS)
struct timespec ts;
ts.tv_sec = t / APR_USEC_PER_SEC;
ts.tv_nsec = (t % APR_USEC_PER_SEC) * 1000;
1
0
[commit] r7075 - in freeswitch/trunk: conf/autoload_configs conf/dialplan libs/libedit scripts/socket src src/include src/mod/applications/mod_commands src/mod/applications/mod_conference src/mod/applications/mod_fifo src/mod/endpoints/mod_sofia
by Freeswitch SVN 03 Jan '08
by Freeswitch SVN 03 Jan '08
03 Jan '08
Author: anthm
Date: Thu Jan 3 16:34:44 2008
New Revision: 7075
Modified:
freeswitch/trunk/conf/autoload_configs/conference.conf.xml
freeswitch/trunk/conf/dialplan/default.xml
freeswitch/trunk/libs/libedit/configure
freeswitch/trunk/scripts/socket/sock.pl
freeswitch/trunk/src/include/switch_ivr.h
freeswitch/trunk/src/include/switch_module_interfaces.h
freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
freeswitch/trunk/src/switch_core_io.c
freeswitch/trunk/src/switch_event.c
freeswitch/trunk/src/switch_ivr_async.c
freeswitch/trunk/src/switch_rtp.c
freeswitch/trunk/src/switch_time.c
Log:
cross t's and dot i's
Modified: freeswitch/trunk/conf/autoload_configs/conference.conf.xml
==============================================================================
--- freeswitch/trunk/conf/autoload_configs/conference.conf.xml (original)
+++ freeswitch/trunk/conf/autoload_configs/conference.conf.xml Thu Jan 3 16:34:44 2008
@@ -68,7 +68,7 @@
<!-- File to play when you're alone (music on hold)-->
<param name="moh-sound" value="$${moh_uri}"/>
<!-- File to play when you join the conference -->
- <!--<param name="enter-sound" value="welcome.wav"/>-->
+ <param name="enter-sound" value="tone_stream://%(1000,0,500)"/>
<!-- File to play when you leave the conference -->
<!--<param name="exit-sound" value="exit.wav"/>-->
<!-- File to play when you ae ejected from the conference -->
Modified: freeswitch/trunk/conf/dialplan/default.xml
==============================================================================
--- freeswitch/trunk/conf/dialplan/default.xml (original)
+++ freeswitch/trunk/conf/dialplan/default.xml Thu Jan 3 16:34:44 2008
@@ -98,6 +98,7 @@
</extension>
<extension name="extension-intercom">
+ <condition field="${sip_to_params}" expression="intercom\=true" continue="on-true"/>
<condition field="destination_number" expression="^8(10[01][0-9])$">
<action application="set" data="dialed_ext=$1"/>
<action application="export" data="sip_h_Call-Info=<sip:$${domain}>;answer-after=0"/>
@@ -166,7 +167,7 @@
</extension>
<extension name="rtp_multicast_page">
- <condition field="destination_number" expression="^pagegroup$">
+ <condition field="destination_number" expression="^pagegroup$|^7243">
<action application="esf_page_group"/>
</condition>
</extension>
@@ -215,6 +216,13 @@
</condition>
</extension>
+ <extension name="milliwatt">
+ <condition field="destination_number" expression="^9997$">
+ <action application="answer"/>
+ <action application="playback" data="tone_stream://%(10000,0,1004);loops=-1"/>
+ </condition>
+ </extension>
+
<extension name="tone_stream">
<condition field="destination_number" expression="^9998$">
<action application="answer"/>
Modified: freeswitch/trunk/libs/libedit/configure
==============================================================================
--- freeswitch/trunk/libs/libedit/configure (original)
+++ freeswitch/trunk/libs/libedit/configure Thu Jan 3 16:34:44 2008
@@ -420,7 +420,7 @@
# Identity of this package.
PACKAGE_NAME='libedit'
-PACKAGE_TARNAME='libedit-20071219'
+PACKAGE_TARNAME='libedit-20071230'
PACKAGE_VERSION='2.10'
PACKAGE_STRING='libedit 2.10'
PACKAGE_BUGREPORT=''
@@ -1816,7 +1816,7 @@
# Define the identity of the package.
- PACKAGE='libedit-20071219'
+ PACKAGE='libedit-20071230'
VERSION='2.10'
Modified: freeswitch/trunk/scripts/socket/sock.pl
==============================================================================
--- freeswitch/trunk/scripts/socket/sock.pl (original)
+++ freeswitch/trunk/scripts/socket/sock.pl Thu Jan 3 16:34:44 2008
@@ -22,7 +22,7 @@
$o = $fs->call_command("answer");
#to turn on events when in async mode
$o = $fs->raw_command("myevents");
-$o = $fs->call_command("playback", "/ram/swimp.raw");
+$o = $fs->call_command("echo");
#comment exit in async mode
@@ -38,6 +38,7 @@
}
if ($r->{event}->{'event-name'} !~ /execute/i) {
printf "wtf $data->{'unique-id'}\n";
+ print ".";
$o = $fs->call_command("break");
$o = $fs->call_command("hangup");
}
Modified: freeswitch/trunk/src/include/switch_ivr.h
==============================================================================
--- freeswitch/trunk/src/include/switch_ivr.h (original)
+++ freeswitch/trunk/src/include/switch_ivr.h Thu Jan 3 16:34:44 2008
@@ -205,7 +205,7 @@
*/
SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t *session, char *file, uint32_t limit, switch_file_handle_t *fh);
SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session_t *session, const char *uuid, switch_eavesdrop_flag_t flags);
-SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_t *session, char *file, uint32_t limit, const char *flags);
+SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_t *session, const char *file, uint32_t limit, const char *flags);
SWITCH_DECLARE(switch_status_t) switch_ivr_stop_displace_session(switch_core_session_t *session, const char *file);
/*!
Modified: freeswitch/trunk/src/include/switch_module_interfaces.h
==============================================================================
--- freeswitch/trunk/src/include/switch_module_interfaces.h (original)
+++ freeswitch/trunk/src/include/switch_module_interfaces.h Thu Jan 3 16:34:44 2008
@@ -195,6 +195,8 @@
switch_memory_pool_t *memory_pool;
/*! private data for loadable modules to store information */
void *private_info;
+ /*! remaining time from last call to _check()*/
+ switch_size_t diff;
};
typedef enum {
Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c Thu Jan 3 16:34:44 2008
@@ -2028,7 +2028,7 @@
}
switch_assert(buf);
- stream->write_function(stream, buf);
+ stream->raw_write_function(stream, (unsigned char *)buf, strlen(buf));
switch_event_destroy(&event);
free(buf);
} else {
Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Thu Jan 3 16:34:44 2008
@@ -558,7 +558,7 @@
conference_stop_file(conference, FILE_STOP_ASYNC);
}
if(conference->enter_sound) {
- conference_play_file(conference, conference->enter_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member->session), 0);
+ conference_play_file(conference, conference->enter_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member->session), 1);
}
}
@@ -808,7 +808,7 @@
/* Lead in time */
if (conference->fnode->leadin) {
conference->fnode->leadin--;
- } else {
+ } else if (!conference->fnode->done) {
file_sample_len = samples;
if (conference->fnode->type == NODE_TYPE_SPEECH) {
switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_BLOCKING;
@@ -837,7 +837,7 @@
/* Lead in time */
if (conference->async_fnode->leadin) {
conference->async_fnode->leadin--;
- } else {
+ } else if (!conference->async_fnode->done) {
file_sample_len = samples;
switch_core_file_read(&conference->async_fnode->fh, async_file_frame, &file_sample_len);
if (file_sample_len <= 0) {
Modified: freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c Thu Jan 3 16:34:44 2008
@@ -84,6 +84,7 @@
switch_hash_t *fifo_hash;
switch_mutex_t *mutex;
switch_memory_pool_t *pool;
+ int running;
} globals;
@@ -105,6 +106,10 @@
{
fifo_node_t *node;
+ if (!globals.running) {
+ return NULL;
+ }
+
node = switch_core_alloc(globals.pool, sizeof(*node));
node->name = switch_core_strdup(globals.pool, name);
@@ -122,6 +127,10 @@
{
switch_event_t *event;
+ if (!globals.running) {
+ return;
+ }
+
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", "%s", "park");
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", node->name);
@@ -139,7 +148,6 @@
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-state", "%s", node->waiting_count > 0 ? "CS_RING" : "CS_HANGUP");
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "unique-id", "%s", node->name);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "answer-state", "%s", node->waiting_count > 0 ? "early" : "terminated");
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "astate", "%s", node->waiting_count > 0 ? "early" : "terminated");
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-direction", "%s", "inbound");
switch_event_fire(&event);
}
@@ -151,6 +159,10 @@
char *to = switch_event_get_header(event, "to");
char *dup_to = NULL, *node_name;
fifo_node_t *node;
+
+ if (!globals.running) {
+ return;
+ }
if (!to || strncasecmp(to, "park+", 5)) {
return;
@@ -192,7 +204,9 @@
switch_time_t ts = switch_timestamp_now();
switch_size_t retsize;
-
+ if (!globals.running) {
+ return;
+ }
if (switch_strlen_zero(data)) {
@@ -577,6 +591,11 @@
const void *var;
int x = 0, verbose = 0;
+
+ if (!globals.running) {
+ return SWITCH_STATUS_FALSE;
+ }
+
if (!switch_strlen_zero(cmd)) {
data = strdup(cmd);
switch_assert(data);
@@ -672,6 +691,7 @@
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
SWITCH_ADD_APP(app_interface, "fifo", "Park with FIFO", FIFO_DESC, fifo_function, FIFO_USAGE, SAF_NONE);
SWITCH_ADD_API(commands_api_interface, "fifo", "Return data about a fifo", fifo_api_function, FIFO_API_SYNTAX);
+ globals.running = 1;
return SWITCH_STATUS_SUCCESS;
}
@@ -684,7 +704,10 @@
switch_hash_index_t *hi;
void *val, *pop;
fifo_node_t *node;
+ switch_memory_pool_t *pool = globals.pool;
switch_mutex_lock(globals.mutex);
+
+ globals.running = 0;
/* Cleanup*/
for (hi = switch_hash_first(NULL, globals.fifo_hash); hi; hi = switch_hash_next(hi)) {
switch_hash_this(hi, NULL, NULL, &val);
@@ -695,9 +718,11 @@
switch_core_hash_destroy(&node->caller_hash);
switch_core_hash_destroy(&node->consumer_hash);
}
- switch_mutex_unlock(globals.mutex);
switch_core_hash_destroy(&globals.fifo_hash);
- switch_core_destroy_memory_pool(&globals.pool);
+ memset(&globals, 0, sizeof(globals));
+ switch_mutex_unlock(globals.mutex);
+
+ switch_core_destroy_memory_pool(&pool);
return SWITCH_STATUS_SUCCESS;
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Thu Jan 3 16:34:44 2008
@@ -252,30 +252,11 @@
cause = switch_channel_get_cause(channel);
if (switch_test_flag(tech_pvt, TFLAG_SIP_HOLD) && cause != SWITCH_CAUSE_ATTENDED_TRANSFER) {
- const char *buuid;
- switch_core_session_t *bsession;
- switch_channel_t *bchannel;
- const char *lost_ext;
-
-
+
if (tech_pvt->max_missed_packets) {
switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_packets);
}
switch_channel_presence(tech_pvt->channel, "unknown", "unhold");
- if ((buuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
- if ((bsession = switch_core_session_locate(buuid))) {
- bchannel = switch_core_session_get_channel(bsession);
- if (switch_channel_test_flag(bchannel, CF_BROADCAST)) {
- if ((lost_ext = switch_channel_get_variable(bchannel, "left_hanging_extension"))) {
- switch_ivr_session_transfer(bsession, lost_ext, NULL, NULL);
- }
- switch_channel_clear_flag(bchannel, CF_BROADCAST);
- switch_channel_set_flag(bchannel, CF_BREAK);
- }
- switch_core_session_rwunlock(bsession);
- }
- }
-
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Thu Jan 3 16:34:44 2008
@@ -1382,25 +1382,38 @@
if (sendonly) {
if (!switch_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
const char *stream;
+
switch_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
switch_channel_presence(tech_pvt->channel, "unknown", "hold");
+
if (tech_pvt->max_missed_packets) {
switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_packets * 10);
}
+
if (!(stream = switch_channel_get_variable(tech_pvt->channel, SWITCH_HOLD_MUSIC_VARIABLE))) {
stream = tech_pvt->profile->hold_music;
}
+
if (stream) {
- switch_ivr_broadcast(switch_core_session_get_uuid(tech_pvt->session), stream, SMF_ECHO_BLEG | SMF_LOOP);
+ switch_ivr_displace_session(tech_pvt->session, stream, 0, "rl");
}
}
} else {
if (switch_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
- switch_channel_clear_flag_partner(tech_pvt->channel, CF_BROADCAST);
+ const char *stream;
+
if (tech_pvt->max_missed_packets) {
switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_packets);
}
- switch_channel_set_flag_partner(tech_pvt->channel, CF_BREAK);
+
+ if (!(stream = switch_channel_get_variable(tech_pvt->channel, SWITCH_HOLD_MUSIC_VARIABLE))) {
+ stream = tech_pvt->profile->hold_music;
+ }
+
+ if (stream) {
+ switch_ivr_stop_displace_session(tech_pvt->session, stream);
+ }
+
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
switch_channel_presence(tech_pvt->channel, "unknown", "unhold");
}
Modified: freeswitch/trunk/src/switch_core_io.c
==============================================================================
--- freeswitch/trunk/src/switch_core_io.c (original)
+++ freeswitch/trunk/src/switch_core_io.c Thu Jan 3 16:34:44 2008
@@ -94,7 +94,7 @@
{
switch_io_event_hook_read_frame_t *ptr;
switch_status_t status;
- int need_codec, perfect, do_bugs = 0, do_resample = 0;
+ int need_codec, perfect, do_bugs = 0, do_resample = 0, is_cng = 0;
unsigned int flag = 0;
top:
@@ -131,11 +131,14 @@
switch_assert(session != NULL);
switch_assert(*frame != NULL);
-
if (switch_test_flag(*frame, SFF_CNG)) {
status = SWITCH_STATUS_SUCCESS;
- goto done;
- }
+ if (!session->bugs) {
+ goto done;
+ }
+ is_cng = 1;
+
+ }
switch_assert((*frame)->codec != NULL);
if ((session->read_codec && (*frame)->codec && session->read_codec->implementation != (*frame)->codec->implementation)) {
@@ -163,16 +166,25 @@
if (status == SWITCH_STATUS_SUCCESS && need_codec) {
switch_frame_t *enc_frame, *read_frame = *frame;
- if (read_frame->codec) {
+ if (read_frame->codec || is_cng) {
session->raw_read_frame.datalen = session->raw_read_frame.buflen;
- status = switch_core_codec_decode(read_frame->codec,
- session->read_codec,
- read_frame->data,
- read_frame->datalen,
- session->read_codec->implementation->actual_samples_per_second,
- session->raw_read_frame.data, &session->raw_read_frame.datalen, &session->raw_read_frame.rate, &flag);
- if (do_resample && status == SWITCH_STATUS_SUCCESS) {
+ if (is_cng) {
+ memset(session->raw_read_frame.data, 255, read_frame->codec->implementation->bytes_per_frame);
+ session->raw_read_frame.datalen = read_frame->codec->implementation->bytes_per_frame;
+ session->raw_read_frame.samples = session->raw_read_frame.datalen / sizeof(int16_t);
+ read_frame = &session->raw_read_frame;
+ status = SWITCH_STATUS_SUCCESS;
+ } else {
+ status = switch_core_codec_decode(read_frame->codec,
+ session->read_codec,
+ read_frame->data,
+ read_frame->datalen,
+ session->read_codec->implementation->actual_samples_per_second,
+ session->raw_read_frame.data, &session->raw_read_frame.datalen, &session->raw_read_frame.rate, &flag);
+ }
+
+ if (do_resample && ((status == SWITCH_STATUS_SUCCESS) || is_cng)) {
status = SWITCH_STATUS_RESAMPLE;
}
Modified: freeswitch/trunk/src/switch_event.c
==============================================================================
--- freeswitch/trunk/src/switch_event.c (original)
+++ freeswitch/trunk/src/switch_event.c Thu Jan 3 16:34:44 2008
@@ -506,6 +506,9 @@
} else {
event->headers = hp->next;
}
+ if (hp == event->last_header || !hp->next) {
+ event->last_header = lp;
+ }
FREE(hp->name);
FREE(hp->value);
memset(hp, 0, sizeof(*hp));
Modified: freeswitch/trunk/src/switch_ivr_async.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_async.c (original)
+++ freeswitch/trunk/src/switch_ivr_async.c Thu Jan 3 16:34:44 2008
@@ -98,9 +98,10 @@
typedef struct {
switch_file_handle_t fh;
int mux;
+ int loop;
} displace_helper_t;
-static switch_bool_t displace_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
+static switch_bool_t write_displace_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
{
displace_helper_t *dh = (displace_helper_t *) user_data;
uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE];
@@ -154,7 +155,12 @@
}
if (st != SWITCH_STATUS_SUCCESS || len == 0) {
- return SWITCH_FALSE;
+ if (dh->loop) {
+ uint32_t pos = 0;
+ switch_core_file_seek(&dh->fh, &pos, 0, SEEK_SET);
+ } else {
+ return SWITCH_FALSE;
+ }
}
switch_core_media_bug_set_write_replace_frame(bug, rframe);
@@ -168,6 +174,80 @@
return SWITCH_TRUE;
}
+
+
+static switch_bool_t read_displace_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
+{
+ displace_helper_t *dh = (displace_helper_t *) user_data;
+ uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE];
+ switch_frame_t frame = { 0 };
+
+ frame.data = data;
+ frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
+
+ switch (type) {
+ case SWITCH_ABC_TYPE_INIT:
+ break;
+ case SWITCH_ABC_TYPE_CLOSE:
+ if (dh) {
+ switch_core_file_close(&dh->fh);
+ }
+ break;
+ case SWITCH_ABC_TYPE_WRITE_REPLACE:
+ {
+ switch_frame_t *rframe = switch_core_media_bug_get_write_replace_frame(bug);
+ if (dh && !dh->mux) {
+ memset(rframe->data, 255, rframe->datalen);
+ }
+ switch_core_media_bug_set_write_replace_frame(bug, rframe);
+ }
+ break;
+ case SWITCH_ABC_TYPE_READ_REPLACE:
+ if (dh) {
+ switch_frame_t *rframe = NULL;
+ switch_size_t len;
+ switch_status_t st;
+ rframe = switch_core_media_bug_get_read_replace_frame(bug);
+ len = rframe->samples;
+
+ if (dh->mux) {
+ int16_t buf[1024];
+ int16_t *fp = rframe->data;
+ uint32_t x;
+
+ st = switch_core_file_read(&dh->fh, buf, &len);
+
+ for(x = 0; x < (uint32_t) len; x++) {
+ int32_t mixed = fp[x] + buf[x];
+ switch_normalize_to_16bit(mixed);
+ fp[x] = (int16_t) mixed;
+ }
+ } else {
+ st = switch_core_file_read(&dh->fh, rframe->data, &len);
+ rframe->samples = (uint32_t) len;
+ rframe->datalen = rframe->samples * 2;
+ }
+
+ if (st != SWITCH_STATUS_SUCCESS || len == 0) {
+ if (dh->loop) {
+ uint32_t pos = 0;
+ switch_core_file_seek(&dh->fh, &pos, 0, SEEK_SET);
+ } else {
+ return SWITCH_FALSE;
+ }
+ }
+
+ switch_core_media_bug_set_read_replace_frame(bug, rframe);
+ }
+ break;
+ case SWITCH_ABC_TYPE_WRITE:
+ default:
+ break;
+ }
+
+ return SWITCH_TRUE;
+}
+
SWITCH_DECLARE(switch_status_t) switch_ivr_stop_displace_session(switch_core_session_t *session, const char *file)
{
switch_media_bug_t *bug;
@@ -184,7 +264,7 @@
}
-SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_t *session, char *file, uint32_t limit, const char *flags)
+SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_t *session, const char *file, uint32_t limit, const char *flags)
{
switch_channel_t *channel;
switch_codec_t *read_codec;
@@ -206,15 +286,13 @@
return SWITCH_STATUS_MEMERR;
}
-
-
+
read_codec = switch_core_session_get_read_codec(session);
switch_assert(read_codec != NULL);
dh->fh.channels = read_codec->implementation->number_of_channels;
dh->fh.samplerate = read_codec->implementation->actual_samples_per_second;
-
-
+
if (switch_core_file_open(&dh->fh,
file,
read_codec->implementation->number_of_channels,
@@ -236,7 +314,17 @@
dh->mux++;
}
- if ((status = switch_core_media_bug_add(session, displace_callback, dh, to, SMBF_WRITE_REPLACE | SMBF_READ_REPLACE, &bug)) != SWITCH_STATUS_SUCCESS) {
+ if (flags && strchr(flags, 'l')) {
+ dh->loop++;
+ }
+
+ if (flags && strchr(flags, 'r')) {
+ status = switch_core_media_bug_add(session, read_displace_callback, dh, to, SMBF_WRITE_REPLACE | SMBF_READ_REPLACE, &bug);
+ } else {
+ status = switch_core_media_bug_add(session, write_displace_callback, dh, to, SMBF_WRITE_REPLACE | SMBF_READ_REPLACE, &bug);
+ }
+
+ if (status != SWITCH_STATUS_SUCCESS) {
switch_core_file_close(&dh->fh);
return status;
}
@@ -1600,105 +1688,108 @@
switch_core_session_t *other_session = NULL;
const char *other_uuid = NULL;
char *app = "playback";
+ char *cause = NULL;
+ char *mypath;
+ char *p;
switch_assert(path);
- if ((session = switch_core_session_locate(uuid))) {
- char *cause = NULL;
- char *mypath;
- char *p;
+ if (!(session = switch_core_session_locate(uuid))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "uuid [%s] does not match an existing session.\n", switch_str_nil(uuid));
+ return SWITCH_STATUS_FALSE;
+ }
- master = session;
+ master = session;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
+ channel = switch_core_session_get_channel(session);
+ switch_assert(channel != NULL);
- if ((switch_channel_test_flag(channel, CF_EVENT_PARSE))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Channel [%s] already broadcasting...broadcast aborted\n",
- switch_channel_get_name(channel));
- switch_core_session_rwunlock(session);
- return SWITCH_STATUS_FALSE;
- }
+ if ((switch_channel_test_flag(channel, CF_EVENT_PARSE))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Channel [%s] already broadcasting...broadcast aborted\n",
+ switch_channel_get_name(channel));
+ switch_core_session_rwunlock(session);
+ return SWITCH_STATUS_FALSE;
+ }
- mypath = strdup(path);
+ mypath = strdup(path);
- if ((nomedia = switch_channel_test_flag(channel, CF_BYPASS_MEDIA))) {
- switch_ivr_media(uuid, SMF_REBRIDGE);
- }
+ if ((nomedia = switch_channel_test_flag(channel, CF_BYPASS_MEDIA))) {
+ switch_ivr_media(uuid, SMF_REBRIDGE);
+ }
- if ((p = strchr(mypath, ':')) && *(p+1) == ':') {
- app = mypath;
- *p++ = '\0';
- *p++ = '\0';
- path = p;
- }
-
- if ((cause = strchr(app, '!'))) {
- *cause++ = '\0';
- if (!cause) {
- cause = "normal_clearing";
- }
+ if ((p = strchr(mypath, ':')) && *(p+1) == ':') {
+ app = mypath;
+ *p++ = '\0';
+ *p++ = '\0';
+ path = p;
+ }
+
+ if ((cause = strchr(app, '!'))) {
+ *cause++ = '\0';
+ if (!cause) {
+ cause = "normal_clearing";
}
+ }
- if ((flags & SMF_ECHO_BLEG) && (other_uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE))
- && (other_session = switch_core_session_locate(other_uuid))) {
- if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "execute");
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "%s", app);
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-arg", "%s", path);
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "lead-frames", "%d", 5);
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
- if ((flags & SMF_LOOP)) {
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "loops", "%d", -1);
- }
-
- switch_core_session_queue_private_event(other_session, &event);
+ if ((flags & SMF_ECHO_BLEG) && (other_uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
+ && (other_session = switch_core_session_locate(other_uuid))) {
+ if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "execute");
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "%s", app);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-arg", "%s", path);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "lead-frames", "%d", 5);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
+ if ((flags & SMF_LOOP)) {
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "loops", "%d", -1);
}
-
- switch_core_session_rwunlock(other_session);
- master = other_session;
- other_session = NULL;
+
+ switch_core_session_queue_private_event(other_session, &event);
}
-
- if ((flags & SMF_ECHO_ALEG)) {
- if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "execute");
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "%s", app);
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-arg", "%s", path);
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "lead-frames", "%d", 5);
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
- if ((flags & SMF_LOOP)) {
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "loops", "%d", -1);
- }
- switch_core_session_queue_private_event(session, &event);
+
+ switch_core_session_rwunlock(other_session);
+ master = other_session;
+ other_session = NULL;
+ }
+
+ if ((flags & SMF_ECHO_ALEG)) {
+ if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "execute");
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "%s", app);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-arg", "%s", path);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "lead-frames", "%d", 5);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
+ if ((flags & SMF_LOOP)) {
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "loops", "%d", -1);
}
- master = session;
+ switch_core_session_queue_private_event(session, &event);
}
+ master = session;
+ }
- if (nomedia) {
- if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "nomedia");
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "nomedia-uuid", "%s", uuid);
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
- switch_core_session_queue_private_event(master, &event);
- }
+ if (nomedia) {
+ if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "nomedia");
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "nomedia-uuid", "%s", uuid);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
+ switch_core_session_queue_private_event(master, &event);
}
+ }
- if (cause) {
- if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "execute");
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "hangup");
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-arg", "%s", cause);
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
- switch_core_session_queue_private_event(session, &event);
- }
+ if (cause) {
+ if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "execute");
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "hangup");
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-arg", "%s", cause);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
+ switch_core_session_queue_private_event(session, &event);
}
-
- switch_core_session_rwunlock(session);
- switch_safe_free(mypath);
}
+ switch_core_session_rwunlock(session);
+ switch_safe_free(mypath);
+
+
return SWITCH_STATUS_SUCCESS;
Modified: freeswitch/trunk/src/switch_rtp.c
==============================================================================
--- freeswitch/trunk/src/switch_rtp.c (original)
+++ freeswitch/trunk/src/switch_rtp.c Thu Jan 3 16:34:44 2008
@@ -1101,12 +1101,8 @@
break;
do_continue:
-
- if (rtp_session->ms_per_packet) {
- switch_yield((rtp_session->ms_per_packet / 1000) * 750);
- } else {
- switch_yield(1000);
- }
+
+ switch_yield(1000);
}
*payload_type = (switch_payload_t) rtp_session->recv_msg.header.pt;
Modified: freeswitch/trunk/src/switch_time.c
==============================================================================
--- freeswitch/trunk/src/switch_time.c (original)
+++ freeswitch/trunk/src/switch_time.c Thu Jan 3 16:34:44 2008
@@ -187,7 +187,7 @@
{
timer_private_t *private_info = timer->private_info;
switch_status_t status = SWITCH_STATUS_SUCCESS;
- switch_size_t diff;
+
if (globals.RUNNING != 1 || !private_info->ready) {
return SWITCH_STATUS_SUCCESS;
@@ -196,12 +196,12 @@
check_roll();
if (TIMER_MATRIX[timer->interval].tick < private_info->reference) {
- diff = private_info->reference - TIMER_MATRIX[timer->interval].tick;
+ timer->diff = private_info->reference - TIMER_MATRIX[timer->interval].tick;
} else {
- diff = 0;
+ timer->diff = 0;
}
- if (diff) {
+ if (timer->diff) {
status = SWITCH_STATUS_FALSE;
} else {
timer_step(timer);
1
0