xmas presence 2009

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16053 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale
2009-12-24 05:44:23 +00:00
parent f2b9cbf23e
commit 88a21f40f2
7 changed files with 644 additions and 246 deletions

View File

@@ -467,6 +467,7 @@ SWITCH_DECLARE(void) switch_channel_presence(switch_channel_t *channel, const ch
{
switch_event_t *event;
switch_event_types_t type = SWITCH_EVENT_PRESENCE_IN;
const char *call_info = NULL;
if (!status) {
type = SWITCH_EVENT_PRESENCE_OUT;
@@ -480,6 +481,8 @@ SWITCH_DECLARE(void) switch_channel_presence(switch_channel_t *channel, const ch
return;
}
call_info = switch_channel_get_variable(channel, "presence_call_info");
if (switch_event_create(&event, type) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(channel, event);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", __FILE__);
@@ -494,6 +497,29 @@ SWITCH_DECLARE(void) switch_channel_presence(switch_channel_t *channel, const ch
}
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
if (call_info) {
char *call_info_state = "active";
if (!switch_channel_up(channel)) {
call_info_state = "idle";
} else if (!strcasecmp(status, "hold")) {
call_info_state = "held";
} else if (!switch_channel_test_flag(channel, CF_ANSWERED)) {
if (channel->direction == SWITCH_CALL_DIRECTION_OUTBOUND) {
call_info_state = "progressing";
} else {
call_info_state = "alerting";
}
}
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "presence-call-info-state", call_info_state);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "presence-call-info", call_info);
}
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "presence-call-direction",
channel->direction == SWITCH_CALL_DIRECTION_OUTBOUND ? "outbound" : "inbound");
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", channel->event_count++);
switch_event_fire(&event);
}
@@ -2191,6 +2217,8 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_chan
free(stream.data);
}
switch_channel_presence(channel, "unknown", "answered", NULL);
switch_channel_audio_sync(channel);
return SWITCH_STATUS_SUCCESS;