提交 50b68f2f authored 作者: Anthony Minessale's avatar Anthony Minessale

add some device-state mechinism to FS to allow tracking of device-specific…

add some device-state mechinism to FS to allow tracking of device-specific states where they may have more than one call from the same device
上级 31b6d601
......@@ -143,6 +143,8 @@ static const char *EVENT_NAMES[] = {
"CONFERENCE_DATA",
"CALL_SETUP_REQ",
"CALL_SETUP_RESULT",
"CALL_DETAIL",
"DEVICE_STATE",
"ALL"
};
......
......@@ -132,6 +132,8 @@ typedef enum {
ESL_EVENT_CONFERENCE_DATA,
ESL_EVENT_CALL_SETUP_REQ,
ESL_EVENT_CALL_SETUP_RESULT,
ESL_EVENT_CALL_DETAIL,
ESL_EVENT_DEVICE_STATE,
ESL_EVENT_ALL
} esl_event_types_t;
......
......@@ -659,7 +659,16 @@ SWITCH_DECLARE(void) switch_channel_state_thread_lock(switch_channel_t *channel)
SWITCH_DECLARE(void) switch_channel_state_thread_unlock(switch_channel_t *channel);
SWITCH_DECLARE(switch_status_t) switch_channel_state_thread_trylock(switch_channel_t *channel);
SWITCH_DECLARE(void) switch_channel_handle_cause(switch_channel_t *channel, switch_call_cause_t cause);
SWITCH_DECLARE(void) switch_channel_global_init(switch_memory_pool_t *pool);
SWITCH_DECLARE(void) switch_channel_global_uninit(void);
SWITCH_DECLARE(const char *) switch_channel_set_device_id(switch_channel_t *channel, const char *device_id);
SWITCH_DECLARE(void) switch_channel_clear_device_record(switch_channel_t *channel);
SWITCH_DECLARE(switch_device_record_t *) switch_channel_get_device_record(switch_channel_t *channel);
SWITCH_DECLARE(void) switch_channel_release_device_record(switch_device_record_t **dcdrp);
SWITCH_DECLARE(switch_status_t) switch_channel_bind_device_state_handler(switch_device_state_function_t function, void *user_data);
SWITCH_DECLARE(switch_status_t) switch_channel_unbind_device_state_handler(switch_device_state_function_t function);
SWITCH_DECLARE(const char *) switch_channel_device_state2str(switch_device_state_t device_state);
SWITCH_END_EXTERN_C
#endif
/* For Emacs:
......
......@@ -61,6 +61,11 @@ struct switch_app_log {
struct switch_app_log *next;
};
typedef struct switch_thread_data_s {
switch_thread_start_t func;
void *obj;
int alloc;
} switch_thread_data_t;
typedef struct switch_hold_record_s {
switch_time_t on;
......@@ -69,12 +74,42 @@ typedef struct switch_hold_record_s {
struct switch_hold_record_s *next;
} switch_hold_record_t;
typedef struct device_uuid_node_s {
char *uuid;
switch_xml_t xml_cdr;
switch_event_t *event;
switch_channel_callstate_t callstate;
switch_hold_record_t *hold_record;
switch_caller_profile_t *hup_profile;
struct switch_device_record_s *parent;
struct device_uuid_node_s *next;
} switch_device_node_t;
typedef struct switch_device_stats_s {
uint32_t total;
uint32_t offhook;
uint32_t active;
uint32_t held;
uint32_t hup;
} switch_device_stats_t;
typedef struct switch_device_record_s {
char *device_id;
char *uuid;
int refs;
switch_device_stats_t stats;
switch_device_state_t state;
switch_device_state_t last_state;
switch_time_t active_start;
switch_time_t active_stop;
struct device_uuid_node_s *uuid_list;
struct device_uuid_node_s *uuid_tail;
switch_mutex_t *mutex;
switch_memory_pool_t *pool;
} switch_device_record_t;
typedef struct switch_thread_data_s {
switch_thread_start_t func;
void *obj;
int alloc;
} switch_thread_data_t;
typedef void(*switch_device_state_function_t)(switch_core_session_t *session, switch_channel_callstate_t callstate, switch_device_record_t *drec);
#define MESSAGE_STAMP_FFL(_m) _m->_file = __FILE__; _m->_func = __SWITCH_FUNC__; _m->_line = __LINE__
......
......@@ -1109,9 +1109,19 @@ typedef enum {
CCS_EARLY,
CCS_ACTIVE,
CCS_HELD,
CCS_HANGUP
CCS_HANGUP,
CCS_UNHOLD
} switch_channel_callstate_t;
typedef enum {
SDS_DOWN,
SDS_ACTIVE,
SDS_ACTIVE_MULTI,
SDS_HELD,
SDS_HANGUP
} switch_device_state_t;
/*!
\enum switch_channel_state_t
\brief Channel States (these are the defaults, CS_SOFT_EXECUTE, CS_EXCHANGE_MEDIA, and CS_CONSUME_MEDIA are often overridden by specific apps)
......@@ -1277,6 +1287,8 @@ typedef enum {
CF_ZRTP_PASSTHRU,
CF_ZRTP_HASH,
CF_CHANNEL_SWAP,
CF_DEVICE_LEG,
CF_FINAL_DEVICE_LEG,
CF_PICKUP,
CF_CONFIRM_BLIND_TRANSFER,
CF_NO_PRESENCE,
......@@ -1727,6 +1739,8 @@ typedef enum {
SWITCH_EVENT_CONFERENCE_DATA,
SWITCH_EVENT_CALL_SETUP_REQ,
SWITCH_EVENT_CALL_SETUP_RESULT,
SWITCH_EVENT_CALL_DETAIL,
SWITCH_EVENT_DEVICE_STATE,
SWITCH_EVENT_ALL
} switch_event_types_t;
......
......@@ -157,6 +157,28 @@ SWITCH_STANDARD_API(skel_function)
return SWITCH_STATUS_SUCCESS;
}
static void mycb(switch_core_session_t *session, switch_channel_callstate_t callstate, switch_device_record_t *drec)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_CRIT,
"%s device: %s\nState: %s Dev State: %s/%s Total:%u Offhook:%u Active:%u Held:%u Hungup:%u Dur: %u %s\n",
switch_channel_get_name(channel),
drec->device_id,
switch_channel_callstate2str(callstate),
switch_channel_device_state2str(drec->last_state),
switch_channel_device_state2str(drec->state),
drec->stats.total,
drec->stats.offhook,
drec->stats.active,
drec->stats.held,
drec->stats.hup,
drec->active_stop ? (uint32_t)(drec->active_stop - drec->active_start) / 1000 : 0,
switch_channel_test_flag(channel, CF_FINAL_DEVICE_LEG) ? "FINAL LEG" : "");
}
/* Macro expands to: switch_status_t mod_skel_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool) */
SWITCH_MODULE_LOAD_FUNCTION(mod_skel_load)
{
......@@ -170,6 +192,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skel_load)
SWITCH_ADD_API(api_interface, "skel", "Skel API", skel_function, "syntax");
switch_channel_bind_device_state_handler(mycb, NULL);
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
......@@ -180,6 +204,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skel_load)
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skel_shutdown)
{
/* Cleanup dynamically allocated config settings */
switch_channel_unbind_device_state_handler(mycb);
switch_xml_config_cleanup(instructions);
return SWITCH_STATUS_SUCCESS;
}
......
......@@ -5850,7 +5850,7 @@ SWITCH_STANDARD_APP(sofia_sla_function)
{
private_object_t *tech_pvt;
switch_core_session_t *bargee_session;
switch_channel_t *channel = switch_core_session_get_channel(session);
if (zstr(data)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Usage: <uuid>\n");
return;
......@@ -5860,8 +5860,7 @@ SWITCH_STANDARD_APP(sofia_sla_function)
if (bargee_session == session) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "BARGE: %s (cannot barge on myself)\n", (char *) data);
} else {
switch_channel_t *channel;
if (switch_core_session_check_interface(bargee_session, sofia_endpoint_interface)) {
tech_pvt = switch_core_session_get_private(bargee_session);
sofia_clear_flag(tech_pvt, TFLAG_SLA_BARGING);
......@@ -5874,13 +5873,13 @@ SWITCH_STANDARD_APP(sofia_sla_function)
sofia_set_flag(tech_pvt, TFLAG_SLA_BARGING);
}
channel = switch_core_session_get_channel(session);
switch_channel_set_variable(channel, "sip_barging_uuid", (char *)data);
}
switch_core_session_rwunlock(bargee_session);
}
switch_channel_execute_on(channel, "execute_on_sip_barge");
switch_ivr_eavesdrop_session(session, data, NULL, ED_MUX_READ | ED_MUX_WRITE | ED_COPY_DISPLAY);
}
......
差异被折叠。
......@@ -1644,6 +1644,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
switch_console_init(runtime.memory_pool);
switch_event_init(runtime.memory_pool);
switch_channel_global_init(runtime.memory_pool);
if (switch_xml_init(runtime.memory_pool, err) != SWITCH_STATUS_SUCCESS) {
apr_terminate();
......@@ -2553,6 +2554,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_destroy(void)
switch_xml_destroy();
switch_core_session_uninit();
switch_console_shutdown();
switch_channel_global_uninit();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Closing Event Engine.\n");
switch_event_shutdown();
......
......@@ -577,6 +577,8 @@ SWITCH_DECLARE(void) switch_core_session_destroy_state(switch_core_session_t *se
STATE_MACRO(destroy, "DESTROY");
switch_channel_clear_device_record(session->channel);
return;
}
......
......@@ -198,6 +198,8 @@ static char *EVENT_NAMES[] = {
"CONFERENCE_DATA",
"CALL_SETUP_REQ",
"CALL_SETUP_RESULT",
"CALL_DETAIL",
"DEVICE_STATE",
"ALL"
};
......
......@@ -2689,6 +2689,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
}
if (local_var_event) {
const char *device_id = switch_event_get_header(local_var_event, "device_id");
switch_channel_set_profile_var(originate_status[i].peer_channel, "device_id", device_id);
}
if ((lc = switch_event_get_header(var_event, "local_var_clobber"))) {
local_clobber = switch_true(lc);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论