mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-25 12:10:18 +00:00
fix a bunch of stuff
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7854 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
dc5c28e1f9
commit
74a3d8ab95
@ -459,9 +459,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_nomedia(const char *uuid, switch_medi
|
|||||||
/*!
|
/*!
|
||||||
\brief Signal the session with a protocol specific hold message.
|
\brief Signal the session with a protocol specific hold message.
|
||||||
\param uuid the uuid of the session to hold
|
\param uuid the uuid of the session to hold
|
||||||
|
\param message optional message
|
||||||
\return SWITCH_STATUS_SUCCESS if all is well
|
\return SWITCH_STATUS_SUCCESS if all is well
|
||||||
*/
|
*/
|
||||||
SWITCH_DECLARE(switch_status_t) switch_ivr_hold_uuid(const char *uuid);
|
SWITCH_DECLARE(switch_status_t) switch_ivr_hold_uuid(const char *uuid, const char *message);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Signal the session with a protocol specific unhold message.
|
\brief Signal the session with a protocol specific unhold message.
|
||||||
@ -473,9 +474,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_unhold_uuid(const char *uuid);
|
|||||||
/*!
|
/*!
|
||||||
\brief Signal the session with a protocol specific hold message.
|
\brief Signal the session with a protocol specific hold message.
|
||||||
\param session the session to hold
|
\param session the session to hold
|
||||||
|
\param message optional message
|
||||||
\return SWITCH_STATUS_SUCCESS if all is well
|
\return SWITCH_STATUS_SUCCESS if all is well
|
||||||
*/
|
*/
|
||||||
SWITCH_DECLARE(switch_status_t) switch_ivr_hold(switch_core_session_t *session);
|
SWITCH_DECLARE(switch_status_t) switch_ivr_hold(switch_core_session_t *session, const char *message);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Signal the session with a protocol specific unhold message.
|
\brief Signal the session with a protocol specific unhold message.
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#define SWITCH_PLATFORM_H
|
#define SWITCH_PLATFORM_H
|
||||||
|
|
||||||
SWITCH_BEGIN_EXTERN_C
|
SWITCH_BEGIN_EXTERN_C
|
||||||
|
#define SWITCH_USE_CLOCK_FUNCS
|
||||||
#ifdef __ICC
|
#ifdef __ICC
|
||||||
#pragma warning (disable:810 869 981 279 1469 188)
|
#pragma warning (disable:810 869 981 279 1469 188)
|
||||||
#endif
|
#endif
|
||||||
|
@ -504,7 +504,8 @@ typedef enum {
|
|||||||
SWITCH_MESSAGE_INDICATE_BROADCAST,
|
SWITCH_MESSAGE_INDICATE_BROADCAST,
|
||||||
SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT,
|
SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT,
|
||||||
SWITCH_MESSAGE_INDICATE_DEFLECT,
|
SWITCH_MESSAGE_INDICATE_DEFLECT,
|
||||||
SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ
|
SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ,
|
||||||
|
SWITCH_MESSAGE_INDICATE_DISPLAY
|
||||||
} switch_core_session_message_types_t;
|
} switch_core_session_message_types_t;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1081,7 +1081,7 @@ SWITCH_STANDARD_API(sched_broadcast_function)
|
|||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define HOLD_SYNTAX "<uuid>"
|
#define HOLD_SYNTAX "<uuid> [<display>]"
|
||||||
SWITCH_STANDARD_API(uuid_hold_function)
|
SWITCH_STANDARD_API(uuid_hold_function)
|
||||||
{
|
{
|
||||||
char *mycmd = NULL, *argv[4] = { 0 };
|
char *mycmd = NULL, *argv[4] = { 0 };
|
||||||
@ -1102,7 +1102,49 @@ SWITCH_STANDARD_API(uuid_hold_function)
|
|||||||
if (!strcasecmp(argv[0], "off")) {
|
if (!strcasecmp(argv[0], "off")) {
|
||||||
status = switch_ivr_unhold_uuid(argv[1]);
|
status = switch_ivr_unhold_uuid(argv[1]);
|
||||||
} else {
|
} else {
|
||||||
status = switch_ivr_hold_uuid(argv[0]);
|
status = switch_ivr_hold_uuid(argv[0], argv[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status == SWITCH_STATUS_SUCCESS) {
|
||||||
|
stream->write_function(stream, "+OK Success\n");
|
||||||
|
} else {
|
||||||
|
stream->write_function(stream, "-ERR Operation Failed\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_safe_free(mycmd);
|
||||||
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define DISPLAY_SYNTAX "<uuid> <display>"
|
||||||
|
SWITCH_STANDARD_API(uuid_display_function)
|
||||||
|
{
|
||||||
|
char *mycmd = NULL, *argv[2] = { 0 };
|
||||||
|
int argc = 0;
|
||||||
|
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||||
|
|
||||||
|
if (session) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) {
|
||||||
|
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (switch_strlen_zero(cmd) || argc < 2 || switch_strlen_zero(argv[0]) || switch_strlen_zero(argv[1])) {
|
||||||
|
stream->write_function(stream, "-USAGE: %s\n", HOLD_SYNTAX);
|
||||||
|
} else {
|
||||||
|
switch_core_session_message_t msg = { 0 };
|
||||||
|
switch_core_session_t *lsession = NULL;
|
||||||
|
|
||||||
|
msg.message_id = SWITCH_MESSAGE_INDICATE_DISPLAY;
|
||||||
|
msg.string_arg = argv[1];
|
||||||
|
msg.from = __FILE__;
|
||||||
|
|
||||||
|
if ((lsession = switch_core_session_locate(argv[0]))) {
|
||||||
|
status = switch_core_session_receive_message(lsession, &msg);
|
||||||
|
switch_core_session_rwunlock(lsession);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2152,6 +2194,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
|
|||||||
SWITCH_ADD_API(commands_api_interface, "uuid_broadcast", "broadcast", uuid_broadcast_function, BROADCAST_SYNTAX);
|
SWITCH_ADD_API(commands_api_interface, "uuid_broadcast", "broadcast", uuid_broadcast_function, BROADCAST_SYNTAX);
|
||||||
SWITCH_ADD_API(commands_api_interface, "hold", "hold (depricated)", uuid_hold_function, HOLD_SYNTAX);
|
SWITCH_ADD_API(commands_api_interface, "hold", "hold (depricated)", uuid_hold_function, HOLD_SYNTAX);
|
||||||
SWITCH_ADD_API(commands_api_interface, "uuid_hold", "hold", uuid_hold_function, HOLD_SYNTAX);
|
SWITCH_ADD_API(commands_api_interface, "uuid_hold", "hold", uuid_hold_function, HOLD_SYNTAX);
|
||||||
|
SWITCH_ADD_API(commands_api_interface, "uuid_display", "change display", uuid_display_function, DISPLAY_SYNTAX);
|
||||||
SWITCH_ADD_API(commands_api_interface, "media", "media (depricated)", uuid_media_function, MEDIA_SYNTAX);
|
SWITCH_ADD_API(commands_api_interface, "media", "media (depricated)", uuid_media_function, MEDIA_SYNTAX);
|
||||||
SWITCH_ADD_API(commands_api_interface, "uuid_media", "media", uuid_media_function, MEDIA_SYNTAX);
|
SWITCH_ADD_API(commands_api_interface, "uuid_media", "media", uuid_media_function, MEDIA_SYNTAX);
|
||||||
SWITCH_ADD_API(commands_api_interface, "fsctl", "control messages", ctl_function, CTL_SYNTAX);
|
SWITCH_ADD_API(commands_api_interface, "fsctl", "control messages", ctl_function, CTL_SYNTAX);
|
||||||
|
@ -374,6 +374,17 @@ SWITCH_STANDARD_APP(redirect_function)
|
|||||||
switch_core_session_receive_message(session, &msg);
|
switch_core_session_receive_message(session, &msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SWITCH_STANDARD_APP(display_function)
|
||||||
|
{
|
||||||
|
switch_core_session_message_t msg = { 0 };
|
||||||
|
|
||||||
|
/* Tell the channel to redirect */
|
||||||
|
msg.from = __FILE__;
|
||||||
|
msg.string_arg = data;
|
||||||
|
msg.message_id = SWITCH_MESSAGE_INDICATE_DISPLAY;
|
||||||
|
switch_core_session_receive_message(session, &msg);
|
||||||
|
}
|
||||||
|
|
||||||
SWITCH_STANDARD_APP(respond_function)
|
SWITCH_STANDARD_APP(respond_function)
|
||||||
{
|
{
|
||||||
switch_core_session_message_t msg = { 0 };
|
switch_core_session_message_t msg = { 0 };
|
||||||
@ -1588,6 +1599,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load)
|
|||||||
SWITCH_ADD_APP(app_interface, "detect_speech", "Detect speech", "Detect speech on a channel.", detect_speech_function, DETECT_SPEECH_SYNTAX, SAF_NONE);
|
SWITCH_ADD_APP(app_interface, "detect_speech", "Detect speech", "Detect speech on a channel.", detect_speech_function, DETECT_SPEECH_SYNTAX, SAF_NONE);
|
||||||
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, "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, "redirect", "Send session redirect", "Send a redirect message to a session.", redirect_function, "<redirect_data>", SAF_SUPPORT_NOMEDIA);
|
||||||
|
SWITCH_ADD_APP(app_interface, "send_display", "Send session a new display", "Send session a new display.", display_function, "<text>", 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, "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, "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, "reject", "Send session reject (depricated)", "Send a respond message to a session.", respond_function, "<respond_data>", SAF_SUPPORT_NOMEDIA);
|
||||||
|
@ -572,10 +572,6 @@ SWITCH_STANDARD_DIALPLAN(enum_dialplan_hunt)
|
|||||||
free_results(&results);
|
free_results(&results);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extension) {
|
|
||||||
switch_channel_set_state(channel, CS_EXECUTE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return extension;
|
return extension;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -284,10 +284,6 @@ SWITCH_STANDARD_DIALPLAN(asterisk_dialplan_hunt)
|
|||||||
|
|
||||||
switch_config_close_file(&cfg);
|
switch_config_close_file(&cfg);
|
||||||
|
|
||||||
if (extension) {
|
|
||||||
switch_channel_set_state(channel, CS_EXECUTE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return extension;
|
return extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,11 +138,6 @@ SWITCH_STANDARD_DIALPLAN(directory_dialplan_hunt)
|
|||||||
|
|
||||||
switch_core_directory_close(&dh);
|
switch_core_directory_close(&dh);
|
||||||
|
|
||||||
|
|
||||||
if (extension) {
|
|
||||||
switch_channel_set_state(channel, CS_EXECUTE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return extension;
|
return extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,10 +274,6 @@ SWITCH_STANDARD_DIALPLAN(dialplan_hunt)
|
|||||||
switch_xml_free(xml);
|
switch_xml_free(xml);
|
||||||
xml = NULL;
|
xml = NULL;
|
||||||
|
|
||||||
if (extension) {
|
|
||||||
switch_channel_set_state(channel, CS_EXECUTE);
|
|
||||||
}
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
switch_xml_free(xml);
|
switch_xml_free(xml);
|
||||||
return extension;
|
return extension;
|
||||||
|
@ -100,12 +100,14 @@ static switch_status_t sofia_on_init(switch_core_session_t *session)
|
|||||||
|
|
||||||
if (sofia_glue_do_invite(session) != SWITCH_STATUS_SUCCESS) {
|
if (sofia_glue_do_invite(session) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||||
|
assert( switch_channel_get_state(channel) != CS_INIT);
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move Channel's State Machine to RING */
|
/* Move Channel's State Machine to RING */
|
||||||
switch_channel_set_state(channel, CS_RING);
|
switch_channel_set_state(channel, CS_RING);
|
||||||
|
assert( switch_channel_get_state(channel) != CS_INIT);
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -538,6 +540,7 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
|
|||||||
tech_pvt->read_frame.flags = SFF_NONE;
|
tech_pvt->read_frame.flags = SFF_NONE;
|
||||||
|
|
||||||
status = switch_rtp_zerocopy_read_frame(tech_pvt->rtp_session, &tech_pvt->read_frame);
|
status = switch_rtp_zerocopy_read_frame(tech_pvt->rtp_session, &tech_pvt->read_frame);
|
||||||
|
|
||||||
if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
|
if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
|
||||||
if (status == SWITCH_STATUS_TIMEOUT) {
|
if (status == SWITCH_STATUS_TIMEOUT) {
|
||||||
switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_MEDIA_TIMEOUT);
|
switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_MEDIA_TIMEOUT);
|
||||||
@ -552,7 +555,7 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
|
|||||||
switch_rtp_dequeue_dtmf(tech_pvt->rtp_session, &dtmf);
|
switch_rtp_dequeue_dtmf(tech_pvt->rtp_session, &dtmf);
|
||||||
switch_channel_queue_dtmf(channel, &dtmf);
|
switch_channel_queue_dtmf(channel, &dtmf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tech_pvt->read_frame.datalen > 0) {
|
if (tech_pvt->read_frame.datalen > 0) {
|
||||||
size_t bytes = 0;
|
size_t bytes = 0;
|
||||||
int frames = 1;
|
int frames = 1;
|
||||||
@ -844,10 +847,25 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SWITCH_MESSAGE_INDICATE_DISPLAY:
|
||||||
|
{
|
||||||
|
if (!switch_strlen_zero(msg->string_arg)) {
|
||||||
|
char message[256] = "";
|
||||||
|
snprintf(message, sizeof(message), "From:\r\nTo: \"%s\"\r\n", msg->string_arg);
|
||||||
|
nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"), SIPTAG_PAYLOAD_STR(message), TAG_END());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case SWITCH_MESSAGE_INDICATE_HOLD:
|
case SWITCH_MESSAGE_INDICATE_HOLD:
|
||||||
{
|
{
|
||||||
switch_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
|
switch_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
|
||||||
sofia_glue_do_invite(session);
|
sofia_glue_do_invite(session);
|
||||||
|
if (!switch_strlen_zero(msg->string_arg)) {
|
||||||
|
char message[256] = "";
|
||||||
|
snprintf(message, sizeof(message), "From:\r\nTo: \"%s\"\r\n", msg->string_arg);
|
||||||
|
nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"), SIPTAG_PAYLOAD_STR(message), TAG_END());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1083,20 +1083,20 @@ SWITCH_DECLARE(void) switch_channel_event_set_data(switch_channel_t *channel, sw
|
|||||||
}
|
}
|
||||||
x = 0;
|
x = 0;
|
||||||
/* Index Variables */
|
/* Index Variables */
|
||||||
for (hi = channel->variables->headers; hi; hi = hi->next) {
|
if (channel->variables) {
|
||||||
char buf[1024];
|
for (hi = channel->variables->headers; hi; hi = hi->next) {
|
||||||
char *vvar = NULL, *vval = NULL;
|
char buf[1024];
|
||||||
|
char *vvar = NULL, *vval = NULL;
|
||||||
|
|
||||||
vvar = (char *) hi->name;
|
vvar = (char *) hi->name;
|
||||||
vval = (char *) hi->value;
|
vval = (char *) hi->value;
|
||||||
x++;
|
x++;
|
||||||
|
|
||||||
switch_assert(vvar && vval);
|
|
||||||
switch_snprintf(buf, sizeof(buf), "variable_%s", vvar);
|
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, buf, "%s", vval);
|
|
||||||
|
|
||||||
|
switch_assert(vvar && vval);
|
||||||
|
switch_snprintf(buf, sizeof(buf), "variable_%s", vvar);
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, buf, "%s", vval);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_mutex_unlock(channel->profile_mutex);
|
switch_mutex_unlock(channel->profile_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,6 +93,7 @@ static void switch_core_standard_on_ring(switch_core_session_t *session)
|
|||||||
|
|
||||||
if ((extension = dialplan_interface->hunt_function(session, dparg, NULL)) != 0) {
|
if ((extension = dialplan_interface->hunt_function(session, dparg, NULL)) != 0) {
|
||||||
switch_channel_set_caller_extension(session->channel, extension);
|
switch_channel_set_caller_extension(session->channel, extension);
|
||||||
|
switch_channel_set_state(session->channel, CS_EXECUTE);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -112,12 +113,14 @@ static void switch_core_standard_on_ring(switch_core_session_t *session)
|
|||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "No Route, Aborting\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "No Route, Aborting\n");
|
||||||
switch_channel_hangup(session->channel, SWITCH_CAUSE_NO_ROUTE_DESTINATION);
|
switch_channel_hangup(session->channel, SWITCH_CAUSE_NO_ROUTE_DESTINATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
|
||||||
if (expanded && dpstr && expanded != dpstr) {
|
if (expanded && dpstr && expanded != dpstr) {
|
||||||
free(expanded);
|
free(expanded);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void switch_core_standard_on_execute(switch_core_session_t *session)
|
static void switch_core_standard_on_execute(switch_core_session_t *session)
|
||||||
@ -294,7 +297,7 @@ void switch_core_state_machine_init(switch_memory_pool_t *pool)
|
|||||||
#define STATE_MACRO(__STATE, __STATE_STR) do { \
|
#define STATE_MACRO(__STATE, __STATE_STR) do { \
|
||||||
midstate = state; \
|
midstate = state; \
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) State %s\n", switch_channel_get_name(session->channel), __STATE_STR); \
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) State %s\n", switch_channel_get_name(session->channel), __STATE_STR); \
|
||||||
if (!driver_state_handler->on_##__STATE || (driver_state_handler->on_##__STATE(session) == SWITCH_STATUS_SUCCESS \
|
if (!driver_state_handler->on_##__STATE || ( driver_state_handler->on_##__STATE(session) == SWITCH_STATUS_SUCCESS \
|
||||||
&& midstate == switch_channel_get_state(session->channel))) { \
|
&& midstate == switch_channel_get_state(session->channel))) { \
|
||||||
while (do_extra_handlers && (application_state_handler = switch_channel_get_state_handler(session->channel, index++)) != 0) { \
|
while (do_extra_handlers && (application_state_handler = switch_channel_get_state_handler(session->channel, index++)) != 0) { \
|
||||||
if (!application_state_handler || !application_state_handler->on_##__STATE \
|
if (!application_state_handler || !application_state_handler->on_##__STATE \
|
||||||
@ -325,6 +328,7 @@ void switch_core_state_machine_init(switch_memory_pool_t *pool)
|
|||||||
switch_core_standard_on_##__STATE(session); \
|
switch_core_standard_on_##__STATE(session); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) State end %s %s %s\n", switch_channel_get_name(session->channel), __STATE_STR, switch_channel_state_name(midstate), switch_channel_state_name(switch_channel_get_state(session->channel))); \
|
||||||
} while (silly)
|
} while (silly)
|
||||||
|
|
||||||
SWITCH_DECLARE(void) switch_core_session_run(switch_core_session_t *session)
|
SWITCH_DECLARE(void) switch_core_session_run(switch_core_session_t *session)
|
||||||
@ -430,9 +434,14 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session_t *session)
|
|||||||
}
|
}
|
||||||
goto done;
|
goto done;
|
||||||
case CS_INIT: /* Basic setup tasks */
|
case CS_INIT: /* Basic setup tasks */
|
||||||
switch_core_session_signal_lock(session);
|
assert(driver_state_handler->on_init);
|
||||||
STATE_MACRO(init, "INIT");
|
//switch_core_session_signal_lock(session);
|
||||||
switch_core_session_signal_unlock(session);
|
if (0) STATE_MACRO(init, "INIT");
|
||||||
|
//switch_core_session_signal_unlock(session);
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) State INIT\n", switch_channel_get_name(session->channel));
|
||||||
|
driver_state_handler->on_init(session);
|
||||||
|
assert( switch_channel_get_state(session->channel) != CS_INIT);
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) State INIT-END\n", switch_channel_get_name(session->channel));
|
||||||
break;
|
break;
|
||||||
case CS_RING: /* Look for a dialplan and find something to do */
|
case CS_RING: /* Look for a dialplan and find something to do */
|
||||||
switch_core_session_signal_lock(session);
|
switch_core_session_signal_lock(session);
|
||||||
@ -480,6 +489,8 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session_t *session)
|
|||||||
if (endstate == CS_NEW) {
|
if (endstate == CS_NEW) {
|
||||||
switch_yield(1000);
|
switch_yield(1000);
|
||||||
} else {
|
} else {
|
||||||
|
assert( switch_channel_get_state(session->channel) != CS_INIT);
|
||||||
|
assert( switch_channel_get_running_state(session->channel) != CS_INIT);
|
||||||
switch_thread_cond_wait(session->cond, session->mutex);
|
switch_thread_cond_wait(session->cond, session->mutex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -678,7 +678,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_ivr_hold(switch_core_session_t *session)
|
SWITCH_DECLARE(switch_status_t) switch_ivr_hold(switch_core_session_t *session, const char *message)
|
||||||
{
|
{
|
||||||
switch_core_session_message_t msg = { 0 };
|
switch_core_session_message_t msg = { 0 };
|
||||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||||
@ -686,6 +686,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_hold(switch_core_session_t *session)
|
|||||||
const char *other_uuid;
|
const char *other_uuid;
|
||||||
|
|
||||||
msg.message_id = SWITCH_MESSAGE_INDICATE_HOLD;
|
msg.message_id = SWITCH_MESSAGE_INDICATE_HOLD;
|
||||||
|
msg.string_arg = message;
|
||||||
msg.from = __FILE__;
|
msg.from = __FILE__;
|
||||||
|
|
||||||
switch_channel_set_flag(channel, CF_HOLD);
|
switch_channel_set_flag(channel, CF_HOLD);
|
||||||
@ -693,7 +694,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_hold(switch_core_session_t *session)
|
|||||||
|
|
||||||
switch_core_session_receive_message(session, &msg);
|
switch_core_session_receive_message(session, &msg);
|
||||||
|
|
||||||
|
|
||||||
if ((stream = switch_channel_get_variable(channel, SWITCH_HOLD_MUSIC_VARIABLE))) {
|
if ((stream = switch_channel_get_variable(channel, SWITCH_HOLD_MUSIC_VARIABLE))) {
|
||||||
if ((other_uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
|
if ((other_uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
|
||||||
switch_ivr_broadcast(other_uuid, stream, SMF_ECHO_ALEG | SMF_LOOP);
|
switch_ivr_broadcast(other_uuid, stream, SMF_ECHO_ALEG | SMF_LOOP);
|
||||||
@ -704,12 +704,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_hold(switch_core_session_t *session)
|
|||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_ivr_hold_uuid(const char *uuid)
|
SWITCH_DECLARE(switch_status_t) switch_ivr_hold_uuid(const char *uuid, const char *message)
|
||||||
{
|
{
|
||||||
switch_core_session_t *session;
|
switch_core_session_t *session;
|
||||||
|
|
||||||
if ((session = switch_core_session_locate(uuid))) {
|
if ((session = switch_core_session_locate(uuid))) {
|
||||||
switch_ivr_hold(session);
|
switch_ivr_hold(session, message);
|
||||||
switch_core_session_rwunlock(session);
|
switch_core_session_rwunlock(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
static const switch_state_handler_table_t originate_state_handlers;
|
static const switch_state_handler_table_t originate_state_handlers;
|
||||||
|
|
||||||
static switch_status_t originate_on_hold(switch_core_session_t *session)
|
static switch_status_t originate_on_hold_transmit(switch_core_session_t *session)
|
||||||
{
|
{
|
||||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||||
|
|
||||||
@ -42,7 +42,6 @@ static switch_status_t originate_on_hold(switch_core_session_t *session)
|
|||||||
switch_ivr_sleep(session, 10);
|
switch_ivr_sleep(session, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* clear this handler so it only works once (next time (a.k.a. Transfer) we will do the real ring and hold states) */
|
|
||||||
switch_channel_clear_state_handler(channel, &originate_state_handlers);
|
switch_channel_clear_state_handler(channel, &originate_state_handlers);
|
||||||
|
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
@ -64,8 +63,8 @@ static const switch_state_handler_table_t originate_state_handlers = {
|
|||||||
/*.on_execute */ NULL,
|
/*.on_execute */ NULL,
|
||||||
/*.on_hangup */ NULL,
|
/*.on_hangup */ NULL,
|
||||||
/*.on_loopback */ NULL,
|
/*.on_loopback */ NULL,
|
||||||
/*.on_transmit */ NULL,
|
/*.on_transmit */ originate_on_hold_transmit,
|
||||||
/*.on_hold */ originate_on_hold
|
/*.on_hold */ originate_on_hold_transmit
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -113,6 +112,7 @@ static void *SWITCH_THREAD_FUNC collect_thread_run(switch_thread_t * thread, voi
|
|||||||
goto wbreak;
|
goto wbreak;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch_channel_set_state(channel, CS_TRANSMIT);
|
||||||
switch_core_session_exec(collect->session, application_interface, app_data);
|
switch_core_session_exec(collect->session, application_interface, app_data);
|
||||||
|
|
||||||
if (switch_channel_get_state(channel) < CS_HANGUP) {
|
if (switch_channel_get_state(channel) < CS_HANGUP) {
|
||||||
|
@ -1057,8 +1057,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
|
|||||||
while (switch_channel_ready(channel) && switch_channel_test_flag(channel, CF_HOLD)) {
|
while (switch_channel_ready(channel) && switch_channel_test_flag(channel, CF_HOLD)) {
|
||||||
switch_yield(10000);
|
switch_yield(10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
tstatus = switch_core_session_read_frame(session, &read_frame, -1, 0);
|
tstatus = switch_core_session_read_frame(session, &read_frame, -1, 0);
|
||||||
|
|
||||||
if (!SWITCH_READ_ACCEPTABLE(tstatus)) {
|
if (!SWITCH_READ_ACCEPTABLE(tstatus)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -879,14 +879,12 @@ SWITCH_DECLARE(void) switch_rtp_destroy(switch_rtp_t **rtp_session)
|
|||||||
void *pop;
|
void *pop;
|
||||||
switch_socket_t *sock;
|
switch_socket_t *sock;
|
||||||
|
|
||||||
|
|
||||||
switch_mutex_lock((*rtp_session)->flag_mutex);
|
|
||||||
|
|
||||||
if (!rtp_session || !*rtp_session || !(*rtp_session)->ready) {
|
if (!rtp_session || !*rtp_session || !(*rtp_session)->ready) {
|
||||||
switch_mutex_unlock((*rtp_session)->flag_mutex);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch_mutex_lock((*rtp_session)->flag_mutex);
|
||||||
|
|
||||||
READ_INC((*rtp_session));
|
READ_INC((*rtp_session));
|
||||||
WRITE_INC((*rtp_session));
|
WRITE_INC((*rtp_session));
|
||||||
|
|
||||||
@ -1122,7 +1120,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
|
|||||||
|
|
||||||
bytes = sizeof(rtp_msg_t);
|
bytes = sizeof(rtp_msg_t);
|
||||||
status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock, 0, (void *) &rtp_session->recv_msg, &bytes);
|
status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock, 0, (void *) &rtp_session->recv_msg, &bytes);
|
||||||
|
|
||||||
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_BREAK)) {
|
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_BREAK)) {
|
||||||
switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_BREAK);
|
switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_BREAK);
|
||||||
bytes = 0;
|
bytes = 0;
|
||||||
@ -1293,7 +1291,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
|
|||||||
|
|
||||||
if (rtp_session->timer.interval) {
|
if (rtp_session->timer.interval) {
|
||||||
check = (uint8_t) (switch_core_timer_check(&rtp_session->timer) == SWITCH_STATUS_SUCCESS);
|
check = (uint8_t) (switch_core_timer_check(&rtp_session->timer) == SWITCH_STATUS_SUCCESS);
|
||||||
|
|
||||||
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_AUTO_CNG) &&
|
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_AUTO_CNG) &&
|
||||||
rtp_session->timer.samplecount >= (rtp_session->last_write_samplecount + (rtp_session->samples_per_interval * 50))) {
|
rtp_session->timer.samplecount >= (rtp_session->last_write_samplecount + (rtp_session->samples_per_interval * 50))) {
|
||||||
uint8_t data[10] = { 0 };
|
uint8_t data[10] = { 0 };
|
||||||
|
@ -58,7 +58,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(softtimer_shutdown);
|
|||||||
SWITCH_MODULE_RUNTIME_FUNCTION(softtimer_runtime);
|
SWITCH_MODULE_RUNTIME_FUNCTION(softtimer_runtime);
|
||||||
SWITCH_MODULE_DEFINITION(CORE_SOFTTIMER_MODULE, softtimer_load, softtimer_shutdown, softtimer_runtime);
|
SWITCH_MODULE_DEFINITION(CORE_SOFTTIMER_MODULE, softtimer_load, softtimer_shutdown, softtimer_runtime);
|
||||||
|
|
||||||
#define MAX_ELEMENTS 360
|
#define MAX_ELEMENTS 3600
|
||||||
#define IDLE_SPEED 100
|
#define IDLE_SPEED 100
|
||||||
#define STEP_MS 1
|
#define STEP_MS 1
|
||||||
#define STEP_MIC 1000
|
#define STEP_MIC 1000
|
||||||
@ -202,7 +202,7 @@ static switch_status_t timer_step(switch_timer_t *timer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
timer->samplecount = (uint32_t) samples;
|
timer->samplecount = (uint32_t) samples;
|
||||||
private_info->reference++;
|
private_info->reference = TIMER_MATRIX[timer->interval].tick + 1;
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -217,7 +217,7 @@ static switch_status_t timer_next(switch_timer_t *timer)
|
|||||||
check_roll();
|
check_roll();
|
||||||
switch_yield(1000);
|
switch_yield(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (globals.RUNNING == 1) {
|
if (globals.RUNNING == 1) {
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -230,7 +230,6 @@ static switch_status_t timer_check(switch_timer_t *timer)
|
|||||||
timer_private_t *private_info = timer->private_info;
|
timer_private_t *private_info = timer->private_info;
|
||||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||||
|
|
||||||
|
|
||||||
if (globals.RUNNING != 1 || !private_info->ready) {
|
if (globals.RUNNING != 1 || !private_info->ready) {
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -340,20 +339,25 @@ SWITCH_MODULE_RUNTIME_FUNCTION(softtimer_runtime)
|
|||||||
tick = 0;
|
tick = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (x = 1; x <= MAX_ELEMENTS; x++) {
|
for (x = 0; x <= MAX_ELEMENTS; x++) {
|
||||||
int i = x * 10;
|
int i = x, index;
|
||||||
int index = (current_ms % i == 0) ? i : 0;
|
|
||||||
|
if (i == 0) {
|
||||||
|
i = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
index = (current_ms % i == 0) ? i : 0;
|
||||||
|
|
||||||
if (TIMER_MATRIX[index].count) {
|
if (TIMER_MATRIX[index].count) {
|
||||||
TIMER_MATRIX[index].tick++;
|
TIMER_MATRIX[index].tick++;
|
||||||
if (TIMER_MATRIX[index].tick == MAX_TICK) {
|
if (TIMER_MATRIX[x].tick == MAX_TICK) {
|
||||||
TIMER_MATRIX[index].tick = 0;
|
TIMER_MATRIX[x].tick = 0;
|
||||||
TIMER_MATRIX[index].roll++;
|
TIMER_MATRIX[x].roll++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_ms == MAX_ELEMENTS) {
|
if (current_ms == MAX_ELEMENTS) {
|
||||||
current_ms = 0;
|
current_ms = 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user