adjust
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1255 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
1277a22e48
commit
92bba4dbe6
|
@ -496,7 +496,8 @@ typedef enum {
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
SWITCH_EVENT_CUSTOM - A custom event
|
SWITCH_EVENT_CUSTOM - A custom event
|
||||||
SWITCH_EVENT_CHANNEL_CREATE - A channel has changed state
|
SWITCH_EVENT_CHANNEL_CREATE - A channel has been created
|
||||||
|
SWITCH_EVENT_CHANNEL_DESTROY - A channel has been destroyed
|
||||||
SWITCH_EVENT_CHANNEL_STATE - A channel has changed state
|
SWITCH_EVENT_CHANNEL_STATE - A channel has changed state
|
||||||
SWITCH_EVENT_CHANNEL_ANSWER - A channel has been answered
|
SWITCH_EVENT_CHANNEL_ANSWER - A channel has been answered
|
||||||
SWITCH_EVENT_CHANNEL_HANGUP - A channel has been hungup
|
SWITCH_EVENT_CHANNEL_HANGUP - A channel has been hungup
|
||||||
|
@ -520,6 +521,7 @@ typedef enum {
|
||||||
typedef enum {
|
typedef enum {
|
||||||
SWITCH_EVENT_CUSTOM,
|
SWITCH_EVENT_CUSTOM,
|
||||||
SWITCH_EVENT_CHANNEL_CREATE,
|
SWITCH_EVENT_CHANNEL_CREATE,
|
||||||
|
SWITCH_EVENT_CHANNEL_DESTROY,
|
||||||
SWITCH_EVENT_CHANNEL_STATE,
|
SWITCH_EVENT_CHANNEL_STATE,
|
||||||
SWITCH_EVENT_CHANNEL_ANSWER,
|
SWITCH_EVENT_CHANNEL_ANSWER,
|
||||||
SWITCH_EVENT_CHANNEL_HANGUP,
|
SWITCH_EVENT_CHANNEL_HANGUP,
|
||||||
|
|
|
@ -483,6 +483,8 @@ SWITCH_DECLARE(switch_channel_state) switch_channel_set_state(switch_channel *ch
|
||||||
|
|
||||||
|
|
||||||
if (ok) {
|
if (ok) {
|
||||||
|
switch_event *event;
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s State Change %s -> %s\n", channel->name,
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s State Change %s -> %s\n", channel->name,
|
||||||
state_names[last_state], state_names[state]);
|
state_names[last_state], state_names[state]);
|
||||||
channel->state = state;
|
channel->state = state;
|
||||||
|
@ -491,6 +493,11 @@ SWITCH_DECLARE(switch_channel_state) switch_channel_set_state(switch_channel *ch
|
||||||
channel->hangup_cause = SWITCH_CAUSE_NORMAL_CLEARING;
|
channel->hangup_cause = SWITCH_CAUSE_NORMAL_CLEARING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_STATE) == SWITCH_STATUS_SUCCESS) {
|
||||||
|
switch_channel_event_set_data(channel, event);
|
||||||
|
switch_event_fire(&event);
|
||||||
|
}
|
||||||
|
|
||||||
if (state < CS_DONE) {
|
if (state < CS_DONE) {
|
||||||
switch_core_session_signal_state_change(channel->session);
|
switch_core_session_signal_state_change(channel->session);
|
||||||
}
|
}
|
||||||
|
@ -690,8 +697,15 @@ SWITCH_DECLARE(switch_channel_state) switch_channel_hangup(switch_channel *chann
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channel->state < CS_HANGUP) {
|
if (channel->state < CS_HANGUP) {
|
||||||
|
switch_event *event;
|
||||||
|
|
||||||
channel->state = CS_HANGUP;
|
channel->state = CS_HANGUP;
|
||||||
channel->hangup_cause = hangup_cause;
|
channel->hangup_cause = hangup_cause;
|
||||||
|
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_STATE) == SWITCH_STATUS_SUCCESS) {
|
||||||
|
switch_channel_event_set_data(channel, event);
|
||||||
|
switch_event_fire(&event);
|
||||||
|
}
|
||||||
|
|
||||||
switch_core_session_kill_channel(channel->session, SWITCH_SIG_KILL);
|
switch_core_session_kill_channel(channel->session, SWITCH_SIG_KILL);
|
||||||
switch_core_session_signal_state_change(channel->session);
|
switch_core_session_signal_state_change(channel->session);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1837,17 +1837,11 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *session)
|
||||||
switch_mutex_lock(session->mutex);
|
switch_mutex_lock(session->mutex);
|
||||||
|
|
||||||
while ((state = switch_channel_get_state(session->channel)) != CS_DONE) {
|
while ((state = switch_channel_get_state(session->channel)) != CS_DONE) {
|
||||||
switch_event *event;
|
|
||||||
|
|
||||||
if (state != laststate) {
|
if (state != laststate) {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
int proceed = 1;
|
int proceed = 1;
|
||||||
midstate = state;
|
midstate = state;
|
||||||
|
|
||||||
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_STATE) == SWITCH_STATUS_SUCCESS) {
|
|
||||||
switch_channel_event_set_data(session->channel, event);
|
|
||||||
switch_event_fire(&event);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case CS_NEW: /* Just created, Waiting for first instructions */
|
case CS_NEW: /* Just created, Waiting for first instructions */
|
||||||
|
@ -2095,6 +2089,12 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *session)
|
||||||
SWITCH_DECLARE(void) switch_core_session_destroy(switch_core_session **session)
|
SWITCH_DECLARE(void) switch_core_session_destroy(switch_core_session **session)
|
||||||
{
|
{
|
||||||
switch_memory_pool *pool;
|
switch_memory_pool *pool;
|
||||||
|
switch_event *event;
|
||||||
|
|
||||||
|
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_DESTROY) == SWITCH_STATUS_SUCCESS) {
|
||||||
|
switch_channel_event_set_data(session->channel, event);
|
||||||
|
switch_event_fire(&event);
|
||||||
|
}
|
||||||
|
|
||||||
pool = (*session)->pool;
|
pool = (*session)->pool;
|
||||||
*session = NULL;
|
*session = NULL;
|
||||||
|
@ -2336,6 +2336,11 @@ static void core_event_handler(switch_event *event)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (event->event_id) {
|
switch (event->event_id) {
|
||||||
|
|
||||||
|
case SWITCH_EVENT_CHANNEL_DESTROY:
|
||||||
|
snprintf(buf, sizeof(buf), "delete from channels where uuid='%s'", switch_event_get_header(event, "unique-id"));
|
||||||
|
sql = buf;
|
||||||
|
break;
|
||||||
case SWITCH_EVENT_CHANNEL_CREATE:
|
case SWITCH_EVENT_CHANNEL_CREATE:
|
||||||
snprintf(buf, sizeof(buf), "insert into channels (uuid,created,name,state) values('%s','%s','%s','%s')",
|
snprintf(buf, sizeof(buf), "insert into channels (uuid,created,name,state) values('%s','%s','%s','%s')",
|
||||||
switch_event_get_header(event, "unique-id"),
|
switch_event_get_header(event, "unique-id"),
|
||||||
|
@ -2360,8 +2365,7 @@ static void core_event_handler(switch_event *event)
|
||||||
|
|
||||||
switch(state_i) {
|
switch(state_i) {
|
||||||
case CS_HANGUP:
|
case CS_HANGUP:
|
||||||
snprintf(buf, sizeof(buf), "delete from channels where uuid='%s'", switch_event_get_header(event, "unique-id"));
|
case CS_DONE:
|
||||||
sql = buf;
|
|
||||||
break;
|
break;
|
||||||
case CS_RING:
|
case CS_RING:
|
||||||
snprintf(buf, sizeof(buf), "update channels set state='%s',cid_name='%s',cid_num='%s',ip_addr='%s',dest='%s'"
|
snprintf(buf, sizeof(buf), "update channels set state='%s',cid_name='%s',cid_num='%s',ip_addr='%s',dest='%s'"
|
||||||
|
@ -2440,6 +2444,7 @@ static void core_event_handler(switch_event *event)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL [%s]\n", sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,7 @@ also never put any new ones before EVENT_ALL
|
||||||
static char *EVENT_NAMES[] = {
|
static char *EVENT_NAMES[] = {
|
||||||
"CUSTOM",
|
"CUSTOM",
|
||||||
"CHANNEL_CREATE",
|
"CHANNEL_CREATE",
|
||||||
|
"CHANNEL_DESTROY",
|
||||||
"CHANNEL_STATE",
|
"CHANNEL_STATE",
|
||||||
"CHANNEL_ANSWER",
|
"CHANNEL_ANSWER",
|
||||||
"CHANNEL_HANGUP",
|
"CHANNEL_HANGUP",
|
||||||
|
|
Loading…
Reference in New Issue