mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-08 20:43:51 +00:00
Merge branch 'master' of ssh://git.freeswitch.org:222/freeswitch
This commit is contained in:
commit
7dc92c47e1
22 files changed
+488
-66
No files matched your search
@@ -144,7 +144,8 @@ typedef enum {
|
||||
MFLAG_MOD = (1 << 16),
|
||||
MFLAG_INDICATE_MUTE = (1 << 17),
|
||||
MFLAG_INDICATE_UNMUTE = (1 << 18),
|
||||
MFLAG_NOMOH = (1 << 19)
|
||||
MFLAG_NOMOH = (1 << 19),
|
||||
MFLAG_VIDEO_BRIDGE = (1 << 20)
|
||||
} member_flag_t;
|
||||
|
||||
typedef enum {
|
||||
@@ -161,7 +162,8 @@ typedef enum {
|
||||
CFLAG_OUTCALL = (1 << 10),
|
||||
CFLAG_INHASH = (1 << 11),
|
||||
CFLAG_EXIT_SOUND = (1 << 12),
|
||||
CFLAG_ENTER_SOUND = (1 << 13)
|
||||
CFLAG_ENTER_SOUND = (1 << 13),
|
||||
CFLAG_VIDEO_BRIDGE = (1 << 14)
|
||||
} conf_flag_t;
|
||||
|
||||
typedef enum {
|
||||
@@ -437,6 +439,7 @@ static switch_status_t chat_send(const char *proto, const char *from, const char
|
||||
const char *body, const char *type, const char *hint);
|
||||
|
||||
static void launch_conference_record_thread(conference_obj_t *conference, char *path);
|
||||
static void launch_conference_video_bridge_thread(conference_member_t *member_a, conference_member_t *member_b);
|
||||
|
||||
typedef switch_status_t (*conf_api_args_cmd_t) (conference_obj_t *, switch_stream_handle_t *, int, char **);
|
||||
typedef switch_status_t (*conf_api_member_cmd_t) (conference_member_t *, switch_stream_handle_t *, void *);
|
||||
@@ -951,6 +954,56 @@ static switch_status_t conference_del_member(conference_obj_t *conference, confe
|
||||
return status;
|
||||
}
|
||||
|
||||
struct vid_helper {
|
||||
conference_member_t *member_a;
|
||||
conference_member_t *member_b;
|
||||
int up;
|
||||
};
|
||||
|
||||
/* Thread bridging video between two members, there will be two threads if video briding is used */
|
||||
static void *SWITCH_THREAD_FUNC conference_video_bridge_thread_run(switch_thread_t *thread, void *obj)
|
||||
{
|
||||
struct vid_helper *vh = obj;
|
||||
switch_channel_t *channel_a = switch_core_session_get_channel(vh->member_a->session);
|
||||
switch_channel_t *channel_b = switch_core_session_get_channel(vh->member_b->session);
|
||||
switch_status_t status;
|
||||
switch_frame_t *read_frame;
|
||||
|
||||
/* Acquire locks for both sessions so the helper object and member structures don't get destroyed before we exit */
|
||||
if (switch_core_session_read_lock(vh->member_a->session) != SWITCH_STATUS_SUCCESS) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (switch_core_session_read_lock(vh->member_b->session) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_core_session_rwunlock(vh->member_a->session);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
vh->up = 1;
|
||||
while (switch_test_flag(vh->member_a, MFLAG_RUNNING) && switch_test_flag(vh->member_b, MFLAG_RUNNING) &&
|
||||
switch_channel_ready(channel_a) && switch_channel_ready(channel_b)) {
|
||||
status = switch_core_session_read_video_frame(vh->member_a->session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
|
||||
if (!SWITCH_READ_ACCEPTABLE(status)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!switch_test_flag(read_frame, SFF_CNG)) {
|
||||
if (switch_core_session_write_video_frame(vh->member_b->session, read_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch_core_session_rwunlock(vh->member_a->session);
|
||||
switch_core_session_rwunlock(vh->member_b->session);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s video thread ended.\n", switch_channel_get_name(channel_a));
|
||||
|
||||
vh->up = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* Main video monitor thread (1 per distinct conference room) */
|
||||
static void *SWITCH_THREAD_FUNC conference_video_thread_run(switch_thread_t *thread, void *obj)
|
||||
{
|
||||
@@ -1103,6 +1156,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v
|
||||
int has_file_data = 0, members_with_video = 0;
|
||||
uint32_t conf_energy = 0;
|
||||
int nomoh = 0;
|
||||
conference_member_t *video_bridge_members[2] = { 0 };
|
||||
|
||||
/* Sync the conference to a single timing source */
|
||||
if (switch_core_timer_next(&timer) != SWITCH_STATUS_SUCCESS) {
|
||||
@@ -1128,6 +1182,14 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v
|
||||
if (switch_test_flag(imember, MFLAG_NOMOH)) {
|
||||
nomoh++;
|
||||
}
|
||||
|
||||
if (switch_test_flag(imember, MFLAG_VIDEO_BRIDGE)) {
|
||||
if (!video_bridge_members[0]) {
|
||||
video_bridge_members[0] = imember;
|
||||
} else {
|
||||
video_bridge_members[1] = imember;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch_clear_flag_locked(imember, MFLAG_HAS_AUDIO);
|
||||
@@ -1187,7 +1249,11 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v
|
||||
|
||||
|
||||
if (members_with_video && conference->video_running != 1) {
|
||||
launch_conference_video_thread(conference);
|
||||
if (!switch_test_flag(conference, CFLAG_VIDEO_BRIDGE)) {
|
||||
launch_conference_video_thread(conference);
|
||||
} else if (video_bridge_members[0] && video_bridge_members[1]){
|
||||
launch_conference_video_bridge_thread(video_bridge_members[0], video_bridge_members[1]);
|
||||
}
|
||||
}
|
||||
|
||||
/* If a file or speech event is being played */
|
||||
@@ -1498,13 +1564,15 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v
|
||||
if (!switch_test_flag(imember, MFLAG_NOCHANNEL)) {
|
||||
channel = switch_core_session_get_channel(imember->session);
|
||||
|
||||
/* add this little bit to preserve the bridge cause code in case of an early media call that */
|
||||
/* never answers */
|
||||
if (switch_test_flag(conference, CFLAG_ANSWERED)) {
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
|
||||
} else {
|
||||
/* put actual cause code from outbound channel hangup here */
|
||||
switch_channel_hangup(channel, conference->bridge_hangup_cause);
|
||||
if (!switch_false(switch_channel_get_variable(channel, "hangup_after_conference"))) {
|
||||
/* add this little bit to preserve the bridge cause code in case of an early media call that */
|
||||
/* never answers */
|
||||
if (switch_test_flag(conference, CFLAG_ANSWERED)) {
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
|
||||
} else {
|
||||
/* put actual cause code from outbound channel hangup here */
|
||||
switch_channel_hangup(channel, conference->bridge_hangup_cause);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5448,6 +5516,8 @@ static void set_mflags(const char *flags, member_flag_t *f)
|
||||
*f |= MFLAG_ENDCONF;
|
||||
} else if (!strcasecmp(argv[i], "mintwo")) {
|
||||
*f |= MFLAG_MINTWO;
|
||||
} else if (!strcasecmp(argv[i], "video-bridge")) {
|
||||
*f |= MFLAG_VIDEO_BRIDGE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5480,6 +5550,8 @@ static void set_cflags(const char *flags, uint32_t *f)
|
||||
*f |= CFLAG_VID_FLOOR;
|
||||
} else if (!strcasecmp(argv[i], "waste-bandwidth")) {
|
||||
*f |= CFLAG_WASTE_BANDWIDTH;
|
||||
} else if (!strcasecmp(argv[i], "video-bridge")) {
|
||||
*f |= CFLAG_VIDEO_BRIDGE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6227,20 +6299,44 @@ static void launch_conference_thread(conference_obj_t *conference)
|
||||
switch_thread_create(&thread, thd_attr, conference_thread_run, conference, conference->pool);
|
||||
}
|
||||
|
||||
|
||||
/* Create a video thread for the conference and launch it */
|
||||
static void launch_conference_video_thread(conference_obj_t *conference)
|
||||
static switch_thread_t *launch_thread_detached(switch_thread_start_t func, switch_memory_pool_t *pool, void *data)
|
||||
{
|
||||
switch_thread_t *thread;
|
||||
switch_threadattr_t *thd_attr = NULL;
|
||||
|
||||
switch_threadattr_create(&thd_attr, conference->pool);
|
||||
switch_threadattr_create(&thd_attr, pool);
|
||||
switch_threadattr_detach_set(thd_attr, 1);
|
||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
switch_thread_create(&thread, thd_attr, conference_video_thread_run, conference, conference->pool);
|
||||
switch_thread_create(&thread, thd_attr, func, data, pool);
|
||||
|
||||
return thread;
|
||||
}
|
||||
|
||||
/* Create a video thread for the conference and launch it */
|
||||
static void launch_conference_video_thread(conference_obj_t *conference)
|
||||
{
|
||||
launch_thread_detached(conference_video_thread_run, conference->pool, conference);
|
||||
conference->video_running = 1;
|
||||
}
|
||||
|
||||
/* Create a video thread for the conference and launch it */
|
||||
static void launch_conference_video_bridge_thread(conference_member_t *member_a, conference_member_t *member_b)
|
||||
{
|
||||
switch_memory_pool_t *pool = member_a->conference->pool;
|
||||
struct vid_helper *vh = switch_core_alloc(pool, 2 * sizeof *vh);
|
||||
|
||||
vh[0].member_a = member_a;
|
||||
vh[0].member_b = member_b;
|
||||
|
||||
vh[1].member_a = member_b;
|
||||
vh[1].member_b = member_a;
|
||||
|
||||
launch_thread_detached(conference_video_bridge_thread_run, pool, &vh[0]);
|
||||
launch_thread_detached(conference_video_bridge_thread_run, pool, &vh[1]);
|
||||
|
||||
member_a->conference->video_running = 1;
|
||||
}
|
||||
|
||||
static void launch_conference_record_thread(conference_obj_t *conference, char *path)
|
||||
{
|
||||
switch_thread_t *thread;
|
||||
|
||||
@@ -31,7 +31,7 @@ CREATE TABLE `lcr` (
|
||||
`trail_strip` int(11) NOT NULL,
|
||||
`prefix` varchar(16) NOT NULL,
|
||||
`suffix` varchar(16) NOT NULL,
|
||||
`lcr_profile` varchar(32) default NULL,
|
||||
`lcr_profile` int(11) NOT NULL default 0,
|
||||
`date_start` datetime NOT NULL DEFAULT '1970-01-01',
|
||||
`date_end` datetime NOT NULL DEFAULT '2030-12-31',
|
||||
`quality` float(10,6) NOT NULL,
|
||||
|
||||
@@ -252,7 +252,7 @@ SWITCH_STANDARD_APP(soundtouch_start_function)
|
||||
char *argv[6];
|
||||
int argc;
|
||||
char *lbuf = NULL;
|
||||
int x;
|
||||
int x, n;
|
||||
|
||||
if ((bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_soundtouch_"))) {
|
||||
if (!zstr(data) && !strcasecmp(data, "stop")) {
|
||||
@@ -275,26 +275,38 @@ SWITCH_STANDARD_APP(soundtouch_start_function)
|
||||
sth->tempo = 1;
|
||||
sth->hook_dtmf = false;
|
||||
sth->send_not_recv = false;
|
||||
n = 0;
|
||||
for (x = 0; x < argc; x++) {
|
||||
if (!strncasecmp(argv[x], "send_leg", 8)) {
|
||||
sth->send_not_recv = true;
|
||||
} else if (!strncasecmp(argv[x], "hook_dtmf", 9)) {
|
||||
sth->hook_dtmf = true;
|
||||
n++;
|
||||
} else if (strchr(argv[x], 'p')) {
|
||||
sth->pitch = normalize_soundtouch_value('p',atof(argv[x]));
|
||||
sth->pitch = normalize_soundtouch_value('p', atof(argv[x]));
|
||||
n++;
|
||||
} else if (strchr(argv[x], 'r')) {
|
||||
sth->rate = normalize_soundtouch_value('r',atof(argv[x]));
|
||||
sth->rate = normalize_soundtouch_value('r', atof(argv[x]));
|
||||
n++;
|
||||
} else if (strchr(argv[x], 'o')) {
|
||||
sth->pitch = normalize_soundtouch_value('p', compute_pitch_from_octaves(atof(argv[x])) );
|
||||
n++;
|
||||
} else if (strchr(argv[x], 's')) {
|
||||
/*12.0f taken from soundtouch conversion to octaves*/
|
||||
sth->pitch = normalize_soundtouch_value('p', compute_pitch_from_octaves(atof(argv[x]) / 12.0f) );
|
||||
n++;
|
||||
} else if (strchr(argv[x], 't')) {
|
||||
sth->tempo = normalize_soundtouch_value('t',atof(argv[x]));
|
||||
sth->tempo = normalize_soundtouch_value('t', atof(argv[x]));
|
||||
n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (n < 1) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Cannot run, no pitch set\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
sth->session = session;
|
||||
|
||||
@@ -308,9 +320,134 @@ SWITCH_STANDARD_APP(soundtouch_start_function)
|
||||
|
||||
}
|
||||
|
||||
/* API Interface Function */
|
||||
#define SOUNDTOUCH_API_SYNTAX "<uuid> [start|stop] [send_leg] [hook_dtmf] [-]<X>s [-]<X>o <X>p <X>r <X>t"
|
||||
SWITCH_STANDARD_API(soundtouch_api_function)
|
||||
{
|
||||
switch_core_session_t *rsession = NULL;
|
||||
switch_channel_t *channel = NULL;
|
||||
switch_media_bug_t *bug;
|
||||
switch_status_t status;
|
||||
struct soundtouch_helper *sth;
|
||||
char *mycmd = NULL;
|
||||
int argc = 0;
|
||||
char *argv[10] = { 0 };
|
||||
char *uuid = NULL;
|
||||
char *action = NULL;
|
||||
char *lbuf = NULL;
|
||||
int x, n;
|
||||
|
||||
if (zstr(cmd)) {
|
||||
goto usage;
|
||||
}
|
||||
|
||||
if (!(mycmd = strdup(cmd))) {
|
||||
goto usage;
|
||||
}
|
||||
|
||||
if ((argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) < 2) {
|
||||
goto usage;
|
||||
}
|
||||
|
||||
uuid = argv[0];
|
||||
action = argv[1];
|
||||
|
||||
if (!(rsession = switch_core_session_locate(uuid))) {
|
||||
stream->write_function(stream, "-ERR Cannot locate session!\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
channel = switch_core_session_get_channel(rsession);
|
||||
|
||||
if ((bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_soundtouch_"))) {
|
||||
if (!zstr(action) && !strcasecmp(action, "stop")) {
|
||||
switch_channel_set_private(channel, "_soundtouch_", NULL);
|
||||
switch_core_media_bug_remove(rsession, &bug);
|
||||
stream->write_function(stream, "+OK Success\n");
|
||||
} else {
|
||||
stream->write_function(stream, "-ERR Cannot run 2 at once on the same channel!\n");
|
||||
}
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!zstr(action) && strcasecmp(action, "start")) {
|
||||
goto usage;
|
||||
}
|
||||
|
||||
if (argc < 3) {
|
||||
goto usage;
|
||||
}
|
||||
|
||||
sth = (struct soundtouch_helper *) switch_core_session_alloc(rsession, sizeof(*sth));
|
||||
assert(sth != NULL);
|
||||
|
||||
|
||||
sth->pitch = 1;
|
||||
sth->rate = 1;
|
||||
sth->tempo = 1;
|
||||
sth->hook_dtmf = false;
|
||||
sth->send_not_recv = false;
|
||||
n = 0;
|
||||
for (x = 2; x < argc; x++) {
|
||||
if (!strncasecmp(argv[x], "send_leg", 8)) {
|
||||
sth->send_not_recv = true;
|
||||
} else if (!strncasecmp(argv[x], "hook_dtmf", 9)) {
|
||||
sth->hook_dtmf = true;
|
||||
n++;
|
||||
} else if (strchr(argv[x], 'p')) {
|
||||
sth->pitch = normalize_soundtouch_value('p', atof(argv[x]));
|
||||
n++;
|
||||
} else if (strchr(argv[x], 'r')) {
|
||||
sth->rate = normalize_soundtouch_value('r', atof(argv[x]));
|
||||
n++;
|
||||
} else if (strchr(argv[x], 'o')) {
|
||||
sth->pitch = normalize_soundtouch_value('p', compute_pitch_from_octaves(atof(argv[x])) );
|
||||
n++;
|
||||
} else if (strchr(argv[x], 's')) {
|
||||
/*12.0f taken from soundtouch conversion to octaves*/
|
||||
sth->pitch = normalize_soundtouch_value('p', compute_pitch_from_octaves(atof(argv[x]) / 12.0f) );
|
||||
n++;
|
||||
} else if (strchr(argv[x], 't')) {
|
||||
sth->tempo = normalize_soundtouch_value('t', atof(argv[x]));
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
if (n < 1) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rsession), SWITCH_LOG_WARNING, "Cannot run, no pitch set\n");
|
||||
goto usage;
|
||||
}
|
||||
|
||||
sth->session = rsession;
|
||||
|
||||
if ((status = switch_core_media_bug_add(rsession, "soundtouch", NULL, soundtouch_callback, sth, 0,
|
||||
sth->send_not_recv ? SMBF_WRITE_REPLACE : SMBF_READ_REPLACE, &bug)) != SWITCH_STATUS_SUCCESS) {
|
||||
stream->write_function(stream, "-ERR Failure!\n");
|
||||
goto done;
|
||||
} else {
|
||||
switch_channel_set_private(channel, "_soundtouch_", bug);
|
||||
stream->write_function(stream, "+OK Success\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
||||
usage:
|
||||
stream->write_function(stream, "-USAGE: %s\n", SOUNDTOUCH_API_SYNTAX);
|
||||
|
||||
done:
|
||||
if (rsession) {
|
||||
switch_core_session_rwunlock(rsession);
|
||||
}
|
||||
|
||||
switch_safe_free(mycmd);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_soundtouch_load)
|
||||
{
|
||||
switch_application_interface_t *app_interface;
|
||||
switch_api_interface_t *api_interface;
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
@@ -318,6 +455,10 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_soundtouch_load)
|
||||
SWITCH_ADD_APP(app_interface, "soundtouch", "Alter the audio stream", "Alter the audio stream pitch/rate/tempo",
|
||||
soundtouch_start_function, "[send_leg] [hook_dtmf] [-]<X>s [-]<X>o <X>p <X>r <X>t", SAF_NONE);
|
||||
|
||||
SWITCH_ADD_API(api_interface, "soundtouch", "soundtouch", soundtouch_api_function, SOUNDTOUCH_API_SYNTAX);
|
||||
|
||||
switch_console_set_complete("add soundtouch ::console::list_uuid ::[start:stop");
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -997,13 +997,25 @@ static pvt_t *pvt_init(switch_core_session_t *session, mod_spandsp_fax_applicati
|
||||
}
|
||||
|
||||
if ((tmp = switch_channel_get_variable(channel, "fax_ident"))) {
|
||||
pvt->ident = switch_core_session_strdup(session, tmp);
|
||||
char *data = NULL;
|
||||
|
||||
data = strdup(tmp);
|
||||
switch_url_decode(data);
|
||||
pvt->ident = switch_core_session_strdup(session, data);
|
||||
|
||||
switch_safe_free(data);
|
||||
} else {
|
||||
pvt->ident = switch_core_session_strdup(session, globals.ident);
|
||||
}
|
||||
|
||||
if ((tmp = switch_channel_get_variable(channel, "fax_header"))) {
|
||||
pvt->header = switch_core_session_strdup(session, tmp);
|
||||
char *data = NULL;
|
||||
|
||||
data = strdup(tmp);
|
||||
switch_url_decode(data);
|
||||
pvt->header = switch_core_session_strdup(session, data);
|
||||
|
||||
switch_safe_free(data);
|
||||
} else {
|
||||
pvt->header = switch_core_session_strdup(session, globals.header);
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ static void check_timeouts(void)
|
||||
switch_hash_this(i_hi, &i_var, NULL, &i_val);
|
||||
i_ext = (char *) i_var;
|
||||
token = (valet_token_t *) i_val;
|
||||
if (token->timeout > 0 && token->timeout < now) {
|
||||
if (token->timeout > 0 && (token->timeout < now || token->timeout == 1)) {
|
||||
switch_core_hash_delete(lot->hash, i_ext);
|
||||
switch_safe_free(token);
|
||||
goto top;
|
||||
@@ -164,7 +164,7 @@ SWITCH_STANDARD_APP(valet_parking_function)
|
||||
char dtmf_buf[128] = "";
|
||||
int is_auto = 0, play_announce = 1;
|
||||
const char *var;
|
||||
valet_token_t *token;
|
||||
valet_token_t *token = NULL;
|
||||
|
||||
if ((var = switch_channel_get_variable(channel, "valet_announce_slot"))) {
|
||||
play_announce = switch_true(var);
|
||||
@@ -279,6 +279,7 @@ SWITCH_STANDARD_APP(valet_parking_function)
|
||||
if (!zstr(var)) {
|
||||
if (!strcmp(var, token->uuid)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Valet ticket %s accepted.\n", var);
|
||||
token->timeout = 0;
|
||||
switch_channel_set_variable(channel, "valet_ticket", NULL);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid token %s\n", token->uuid);
|
||||
@@ -319,7 +320,6 @@ SWITCH_STANDARD_APP(valet_parking_function)
|
||||
}
|
||||
|
||||
switch_zmalloc(token, sizeof(*token));
|
||||
token->timeout = switch_epoch_time_now(NULL) + 10;
|
||||
switch_set_string(token->uuid, switch_core_session_get_uuid(session));
|
||||
switch_core_hash_insert(lot->hash, ext, token);
|
||||
|
||||
@@ -335,15 +335,15 @@ SWITCH_STANDARD_APP(valet_parking_function)
|
||||
switch_core_session_t *b_session;
|
||||
|
||||
if ((b_session = switch_core_session_locate(uuid))) {
|
||||
token->timeout = switch_epoch_time_now(NULL) + 10;
|
||||
if (play_announce) {
|
||||
switch_ivr_phrase_macro(session, "valet_announce_ext", tmp, NULL, NULL);
|
||||
}
|
||||
|
||||
switch_ivr_session_transfer(b_session, dest, "inline", NULL);
|
||||
switch_mutex_unlock(lot->mutex);
|
||||
switch_core_session_rwunlock(b_session);
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
|
||||
return;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -388,6 +388,13 @@ SWITCH_STANDARD_APP(valet_parking_function)
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Usage: %s\n", VALET_APP_SYNTAX);
|
||||
}
|
||||
|
||||
end:
|
||||
|
||||
if (token) {
|
||||
token->timeout = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_API(valet_info_function)
|
||||
|
||||
@@ -741,13 +741,6 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
|
||||
}
|
||||
}
|
||||
|
||||
if ((val = switch_channel_get_variable(channel, SOFIA_SESSION_TIMEOUT))) {
|
||||
int v_session_timeout = atoi(val);
|
||||
if (v_session_timeout >= 0) {
|
||||
session_timeout = v_session_timeout;
|
||||
}
|
||||
}
|
||||
|
||||
if (sofia_test_flag(tech_pvt, TFLAG_NAT) ||
|
||||
(val = switch_channel_get_variable(channel, "sip-force-contact")) ||
|
||||
((val = switch_channel_get_variable(channel, "sip_sticky_contact")) && switch_true(val))) {
|
||||
@@ -756,6 +749,13 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
|
||||
switch_channel_set_variable(channel, "sip_nat_detected", "true");
|
||||
}
|
||||
|
||||
if ((val = switch_channel_get_variable(channel, SOFIA_SESSION_TIMEOUT))) {
|
||||
int v_session_timeout = atoi(val);
|
||||
if (v_session_timeout >= 0) {
|
||||
session_timeout = v_session_timeout;
|
||||
}
|
||||
}
|
||||
|
||||
if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) {
|
||||
char *extra_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_RESPONSE_HEADER_PREFIX);
|
||||
char *cid = NULL;
|
||||
@@ -780,19 +780,27 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
|
||||
}
|
||||
}
|
||||
|
||||
if ((tech_pvt->session_timeout = session_timeout)) {
|
||||
tech_pvt->session_refresher = switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND ? nua_local_refresher : nua_remote_refresher;
|
||||
} else {
|
||||
tech_pvt->session_refresher = nua_no_refresher;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (sofia_use_soa(tech_pvt)) {
|
||||
nua_respond(tech_pvt->nh, SIP_200_OK,
|
||||
NUTAG_AUTOANSWER(0),
|
||||
TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
|
||||
TAG_IF(sticky, NUTAG_PROXY(tech_pvt->record_route)),
|
||||
TAG_IF(cid, SIPTAG_HEADER_STR(cid)),
|
||||
NUTAG_SESSION_TIMER(session_timeout),
|
||||
NUTAG_SESSION_REFRESHER(session_timeout ? nua_local_refresher : nua_no_refresher),
|
||||
NUTAG_SESSION_TIMER(tech_pvt->session_timeout),
|
||||
NUTAG_SESSION_REFRESHER(tech_pvt->session_refresher),
|
||||
SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
|
||||
SIPTAG_CALL_INFO_STR(switch_channel_get_variable(tech_pvt->channel, SOFIA_SIP_HEADER_PREFIX "call_info")),
|
||||
SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
|
||||
SOATAG_REUSE_REJECTED(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1),
|
||||
TAG_IF(is_proxy, SOATAG_RTP_SELECT(1)),
|
||||
TAG_IF(is_proxy, SOATAG_RTP_SELECT(1)),
|
||||
TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
|
||||
TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
|
||||
SIPTAG_HEADER_STR("X-FS-Support: " FREESWITCH_SUPPORT)), TAG_END());
|
||||
@@ -803,8 +811,8 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
|
||||
TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
|
||||
TAG_IF(sticky, NUTAG_PROXY(tech_pvt->record_route)),
|
||||
TAG_IF(cid, SIPTAG_HEADER_STR(cid)),
|
||||
NUTAG_SESSION_TIMER(session_timeout),
|
||||
NUTAG_SESSION_REFRESHER(session_timeout ? nua_local_refresher : nua_no_refresher),
|
||||
NUTAG_SESSION_TIMER(tech_pvt->session_timeout),
|
||||
NUTAG_SESSION_REFRESHER(tech_pvt->session_refresher),
|
||||
SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
|
||||
SIPTAG_CALL_INFO_STR(switch_channel_get_variable(tech_pvt->channel, SOFIA_SIP_HEADER_PREFIX "call_info")),
|
||||
SIPTAG_CONTENT_TYPE_STR("application/sdp"),
|
||||
@@ -2001,6 +2009,8 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
snprintf(message, sizeof(message), "P-Asserted-Identity: \"%s\" <%s>", name, number);
|
||||
sofia_set_flag_locked(tech_pvt, TFLAG_UPDATING_DISPLAY);
|
||||
nua_update(tech_pvt->nh,
|
||||
NUTAG_SESSION_TIMER(tech_pvt->session_timeout),
|
||||
NUTAG_SESSION_REFRESHER(tech_pvt->session_refresher),
|
||||
TAG_IF(!zstr(tech_pvt->route_uri), NUTAG_PROXY(tech_pvt->route_uri)),
|
||||
TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)),
|
||||
TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_END());
|
||||
@@ -2009,17 +2019,21 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
|
||||
sofia_set_flag_locked(tech_pvt, TFLAG_UPDATING_DISPLAY);
|
||||
nua_update(tech_pvt->nh,
|
||||
NUTAG_SESSION_TIMER(tech_pvt->session_timeout),
|
||||
NUTAG_SESSION_REFRESHER(tech_pvt->session_refresher),
|
||||
TAG_IF(!zstr(tech_pvt->route_uri), NUTAG_PROXY(tech_pvt->route_uri)),
|
||||
TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)),
|
||||
TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_END());
|
||||
} else if ((ua && (switch_stristr("cisco/spa50", ua) || switch_stristr("cisco/spa525", ua)))) {
|
||||
snprintf(message, sizeof(message), "P-Asserted-Identity: \"%s\" <sip:%s@%s>", name, number, tech_pvt->profile->sipip);
|
||||
snprintf(message, sizeof(message), "P-Asserted-Identity: \"%s\" <sip:%s@%s>", name, number, tech_pvt->profile->sipip);
|
||||
|
||||
sofia_set_flag_locked(tech_pvt, TFLAG_UPDATING_DISPLAY);
|
||||
nua_update(tech_pvt->nh,
|
||||
TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)),
|
||||
TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_END());
|
||||
}
|
||||
sofia_set_flag_locked(tech_pvt, TFLAG_UPDATING_DISPLAY);
|
||||
nua_update(tech_pvt->nh,
|
||||
NUTAG_SESSION_TIMER(tech_pvt->session_timeout),
|
||||
NUTAG_SESSION_REFRESHER(tech_pvt->session_refresher),
|
||||
TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)),
|
||||
TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_END());
|
||||
}
|
||||
|
||||
tech_pvt->last_sent_callee_id_name = switch_core_session_strdup(tech_pvt->session, name);
|
||||
tech_pvt->last_sent_callee_id_number = switch_core_session_strdup(tech_pvt->session, number);
|
||||
@@ -2071,6 +2085,8 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
} else if (ua && switch_stristr("polycom", ua)) {
|
||||
snprintf(message, sizeof(message), "P-Asserted-Identity: \"%s\" <%s>", msg->string_arg, tech_pvt->caller_profile->destination_number);
|
||||
nua_update(tech_pvt->nh,
|
||||
NUTAG_SESSION_TIMER(tech_pvt->session_timeout),
|
||||
NUTAG_SESSION_REFRESHER(tech_pvt->session_refresher),
|
||||
TAG_IF(!zstr(tech_pvt->route_uri), NUTAG_PROXY(tech_pvt->route_uri)),
|
||||
TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)),
|
||||
TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_END());
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#define HAVE_APR
|
||||
#include <switch.h>
|
||||
#include <switch_version.h>
|
||||
#define SOFIA_NAT_SESSION_TIMEOUT 1800
|
||||
#define SOFIA_NAT_SESSION_TIMEOUT 90
|
||||
#define SOFIA_MAX_ACL 100
|
||||
#ifdef _MSC_VER
|
||||
#define HAVE_FUNCTION 1
|
||||
@@ -767,6 +767,8 @@ struct private_object {
|
||||
sofia_cid_type_t cid_type;
|
||||
switch_payload_t payload_space;
|
||||
switch_payload_t ianacodes[SWITCH_MAX_CODECS];
|
||||
uint32_t session_timeout;
|
||||
enum nua_session_refresher session_refresher;
|
||||
};
|
||||
|
||||
struct callback_t {
|
||||
|
||||
@@ -7454,6 +7454,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
|
||||
|
||||
if (sofia_glue_check_nat(profile, tech_pvt->remote_ip)) {
|
||||
tech_pvt->user_via = sofia_glue_create_external_via(session, profile, tech_pvt->transport);
|
||||
nua_set_hparams(tech_pvt->nh, SIPTAG_VIA_STR(tech_pvt->user_via), TAG_END());
|
||||
}
|
||||
|
||||
if (sip->sip_contact && sip->sip_contact->m_url) {
|
||||
|
||||
@@ -2366,6 +2366,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
||||
extra_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_HEADER_PREFIX);
|
||||
|
||||
session_timeout = tech_pvt->profile->session_timeout;
|
||||
|
||||
if ((val = switch_channel_get_variable(channel, SOFIA_SESSION_TIMEOUT))) {
|
||||
int v_session_timeout = atoi(val);
|
||||
if (v_session_timeout >= 0) {
|
||||
@@ -2420,10 +2421,12 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
||||
sofia_clear_flag(tech_pvt, TFLAG_ENABLE_SOA);
|
||||
}
|
||||
|
||||
if (sofia_test_flag(tech_pvt, TFLAG_RECOVERED)) {
|
||||
session_timeout = 0;
|
||||
if ((tech_pvt->session_timeout = session_timeout)) {
|
||||
tech_pvt->session_refresher = switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND ? nua_local_refresher : nua_remote_refresher;
|
||||
} else {
|
||||
tech_pvt->session_refresher = nua_no_refresher;
|
||||
}
|
||||
|
||||
|
||||
if (sofia_use_soa(tech_pvt)) {
|
||||
nua_invite(tech_pvt->nh,
|
||||
NUTAG_AUTOANSWER(0),
|
||||
@@ -2431,8 +2434,8 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
||||
//TAG_IF(!zstr(tech_pvt->local_sdp_str), NUTAG_AUTOACK(1)),
|
||||
// The code above is breaking things...... grrr WE need this because we handle our own acks and there are 3pcc cases in there too
|
||||
NUTAG_AUTOACK(0),
|
||||
NUTAG_SESSION_TIMER(session_timeout),
|
||||
NUTAG_SESSION_REFRESHER(session_timeout ? nua_local_refresher : nua_no_refresher),
|
||||
NUTAG_SESSION_TIMER(tech_pvt->session_timeout),
|
||||
NUTAG_SESSION_REFRESHER(tech_pvt->session_refresher),
|
||||
TAG_IF(sofia_test_flag(tech_pvt, TFLAG_RECOVERED), NUTAG_INVITE_TIMER(UINT_MAX)),
|
||||
TAG_IF(invite_full_from, SIPTAG_FROM_STR(invite_full_from)),
|
||||
TAG_IF(invite_full_to, SIPTAG_TO_STR(invite_full_to)),
|
||||
@@ -2465,8 +2468,8 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
||||
nua_invite(tech_pvt->nh,
|
||||
NUTAG_AUTOANSWER(0),
|
||||
NUTAG_AUTOACK(0),
|
||||
NUTAG_SESSION_TIMER(session_timeout),
|
||||
TAG_IF(session_timeout, NUTAG_SESSION_REFRESHER(nua_remote_refresher)),
|
||||
NUTAG_SESSION_TIMER(tech_pvt->session_timeout),
|
||||
NUTAG_SESSION_REFRESHER(tech_pvt->session_refresher),
|
||||
TAG_IF(sofia_test_flag(tech_pvt, TFLAG_RECOVERED), NUTAG_INVITE_TIMER(UINT_MAX)),
|
||||
TAG_IF(invite_full_from, SIPTAG_FROM_STR(invite_full_from)),
|
||||
TAG_IF(invite_full_to, SIPTAG_TO_STR(invite_full_to)),
|
||||
@@ -4820,6 +4823,12 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
|
||||
}
|
||||
}
|
||||
|
||||
if (!best_te && (sofia_test_pflag(tech_pvt->profile, PFLAG_LIBERAL_DTMF) || sofia_test_flag(tech_pvt, TFLAG_LIBERAL_DTMF))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
|
||||
"No 2833 in SDP. Liberal DTMF mode adding %d as telephone-event.", tech_pvt->profile->te);
|
||||
best_te = tech_pvt->profile->te;
|
||||
}
|
||||
|
||||
if (best_te) {
|
||||
if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
|
||||
te = tech_pvt->te = (switch_payload_t) best_te;
|
||||
@@ -4836,9 +4845,9 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Disable 2833 dtmf\n");
|
||||
switch_channel_set_variable(tech_pvt->channel, "dtmf_type", "none");
|
||||
tech_pvt->dtmf_type = DTMF_NONE;
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "No 2833 in SDP. Disable 2833 dtmf and switch to INFO\n");
|
||||
switch_channel_set_variable(tech_pvt->channel, "dtmf_type", "info");
|
||||
tech_pvt->dtmf_type = DTMF_INFO;
|
||||
te = tech_pvt->recv_te = 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user