提交 d77e574d authored 作者: Anthony Minessale's avatar Anthony Minessale

rearrange the furnature

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1846 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 03ac8289
......@@ -335,7 +335,15 @@ SWITCH_DECLARE (switch_status_t) switch_core_session_message_send(char *uuid_str
\param event the event to send
\return the status returned by the message handler
*/
SWITCH_DECLARE(switch_status_t) switch_core_session_event_send(char *uuid_str, switch_event_t *event);
SWITCH_DECLARE(switch_status_t) switch_core_session_event_send(char *uuid_str, switch_event_t **event);
/*!
\brief Send an event to a session translating it to it's native message format
\param session the session to receive the event
\param event the event to receive
\return the status returned by the handler
*/
SWITCH_DECLARE(switch_status_t) switch_core_session_receive_event(switch_core_session_t *session, switch_event_t **event);
/*!
\brief Retrieve private user data from a session
......@@ -433,7 +441,16 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_receive_message(switch_core_
\param event the event to queue
\return the status returned by the message handler
*/
SWITCH_DECLARE(switch_status_t) switch_core_session_queue_event(switch_core_session_t *session, switch_event_t *event);
SWITCH_DECLARE(switch_status_t) switch_core_session_queue_event(switch_core_session_t *session, switch_event_t **event);
/*!
\brief DE-Queue an event on a given session
\param session the session to de-queue the message on
\param event the de-queued event
\return the SWITCH_STATUS_SUCCESS if the event was de-queued
*/
SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_event(switch_core_session_t *session, switch_event_t **event);
/*!
\brief Read a frame from a session
......
......@@ -59,7 +59,7 @@ BEGIN_EXTERN_C
\return SWITCH_STATUS_SUCCESS to keep the collection moving.
*/
SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_callback(switch_core_session_t *session,
switch_dtmf_callback_function_t dtmf_callback,
switch_input_callback_function_t dtmf_callback,
void *buf,
unsigned int buflen);
......@@ -98,7 +98,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
switch_file_handle_t *fh,
char *file,
char *timer_name,
switch_dtmf_callback_function_t dtmf_callback,
switch_input_callback_function_t dtmf_callback,
void *buf,
unsigned int buflen);
......@@ -118,7 +118,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *session,
switch_file_handle_t *fh,
char *file,
switch_dtmf_callback_function_t dtmf_callback,
switch_input_callback_function_t dtmf_callback,
void *buf,
unsigned int buflen);
......@@ -127,7 +127,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text_handle(switch_core_session
switch_speech_handle_t *sh,
switch_codec_t *codec,
switch_timer_t *timer,
switch_dtmf_callback_function_t dtmf_callback,
switch_input_callback_function_t dtmf_callback,
char *text,
void *buf,
unsigned int buflen);
......@@ -150,7 +150,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *ses
char *voice_name,
char *timer_name,
uint32_t rate,
switch_dtmf_callback_function_t dtmf_callback,
switch_input_callback_function_t dtmf_callback,
char *text,
void *buf,
unsigned int buflen);
......@@ -169,7 +169,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *ses
SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_session_t *session,
switch_core_session_t *peer_session,
unsigned int timelimit,
switch_dtmf_callback_function_t dtmf_callback,
switch_input_callback_function_t dtmf_callback,
void *session_data,
void *peer_session_data);
......
......@@ -93,10 +93,10 @@ struct switch_io_event_hook_receive_message {
};
/*! \brief Node in which to store custom receive message callback hooks */
struct switch_io_event_hook_queue_event {
struct switch_io_event_hook_receive_event {
/*! the answer channel callback hook*/
switch_queue_event_hook_t queue_event;
struct switch_io_event_hook_queue_event *next;
switch_receive_event_hook_t receive_event;
struct switch_io_event_hook_receive_event *next;
};
/*! \brief Node in which to store custom read frame channel callback hooks */
......@@ -150,7 +150,7 @@ struct switch_io_event_hooks {
/*! a list of receive message hooks */
switch_io_event_hook_receive_message_t *receive_message;
/*! a list of queue message hooks */
switch_io_event_hook_queue_event_t *queue_event;
switch_io_event_hook_receive_event_t *receive_event;
/*! a list of read frame hooks */
switch_io_event_hook_read_frame_t *read_frame;
/*! a list of write frame hooks */
......@@ -186,7 +186,7 @@ struct switch_io_routines {
/*! receive a message from another session*/
switch_status_t (*receive_message)(switch_core_session_t *, switch_core_session_message_t *);
/*! queue a message for another session*/
switch_status_t (*queue_event)(switch_core_session_t *, switch_event_t *);
switch_status_t (*receive_event)(switch_core_session_t *, switch_event_t *);
};
/*! \brief Abstraction of an module endpoint interface
......
......@@ -573,6 +573,10 @@ typedef enum {
SWITCH_EVENT_ALL
} switch_event_types_t;
typedef enum {
SWITCH_INPUT_TYPE_DTMF,
SWITCH_INPUT_TYPE_EVENT
} switch_input_type_t;
typedef enum {
SWITCH_CAUSE_UNALLOCATED = 1,
......@@ -651,7 +655,7 @@ typedef struct switch_config switch_config_t;
typedef struct switch_io_event_hook_outgoing_channel switch_io_event_hook_outgoing_channel_t;
typedef struct switch_io_event_hook_answer_channel switch_io_event_hook_answer_channel_t;
typedef struct switch_io_event_hook_receive_message switch_io_event_hook_receive_message_t;
typedef struct switch_io_event_hook_queue_event switch_io_event_hook_queue_event_t;
typedef struct switch_io_event_hook_receive_event switch_io_event_hook_receive_event_t;
typedef struct switch_io_event_hook_read_frame switch_io_event_hook_read_frame_t;
typedef struct switch_io_event_hook_write_frame switch_io_event_hook_write_frame_t;
typedef struct switch_io_event_hook_kill_channel switch_io_event_hook_kill_channel_t;
......@@ -682,7 +686,7 @@ typedef switch_status_t (*switch_state_handler_t)(switch_core_session_t *);
typedef switch_status_t (*switch_outgoing_channel_hook_t)(switch_core_session_t *, switch_caller_profile_t *, switch_core_session_t *);
typedef switch_status_t (*switch_answer_channel_hook_t)(switch_core_session_t *);
typedef switch_status_t (*switch_receive_message_hook_t)(switch_core_session_t *, switch_core_session_message_t *);
typedef switch_status_t (*switch_queue_event_hook_t)(switch_core_session_t *, switch_event_t *);
typedef switch_status_t (*switch_receive_event_hook_t)(switch_core_session_t *, switch_event_t *);
typedef switch_status_t (*switch_read_frame_hook_t)(switch_core_session_t *, switch_frame_t **, int, switch_io_flag_t, int);
typedef switch_status_t (*switch_write_frame_hook_t)(switch_core_session_t *, switch_frame_t *, int, switch_io_flag_t, int);
typedef switch_status_t (*switch_kill_channel_hook_t)(switch_core_session_t *, int);
......@@ -692,7 +696,11 @@ typedef switch_status_t (*switch_send_dtmf_hook_t)(switch_core_session_t *, char
typedef struct switch_stream_handle switch_stream_handle_t;
typedef switch_status_t (*switch_stream_handle_write_function_t)(switch_stream_handle_t *handle, char *fmt, ...);
typedef switch_status_t (*switch_api_function_t)(char *in, switch_stream_handle_t *stream);
typedef switch_status_t (*switch_dtmf_callback_function_t)(switch_core_session_t *session, char *dtmf, void *buf, unsigned int buflen);
typedef switch_status_t (*switch_input_callback_function_t)(switch_core_session_t *session,
void *input,
switch_input_type_t input_type,
void *buf,
unsigned int buflen);
typedef int (*switch_core_db_callback_func_t)(void *pArg, int argc, char **argv, char **columnNames);
typedef switch_status_t (*switch_module_load_t) (switch_loadable_module_interface_t **, char *);
typedef switch_status_t (*switch_module_reload_t) (void);
......
......@@ -39,16 +39,23 @@ static const char modname[] = "mod_ivrtest";
dtmf handler function you can hook up to be executed when a digit is dialed during playback
if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
*/
static switch_status_t on_dtmf(switch_core_session_t *session, char *dtmf, void *buf, unsigned int buflen)
static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
switch (itype) {
case SWITCH_INPUT_TYPE_DTMF: {
char *dtmf = (char *) input;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
switch_copy_string((char *)buf, dtmf, buflen);
return SWITCH_STATUS_BREAK;
switch_copy_string((char *)buf, dtmf, buflen);
return SWITCH_STATUS_BREAK;
}
break;
default:
break;
}
return SWITCH_STATUS_SUCCESS;
}
static void disast_function(switch_core_session_t *session, char *data)
{
void *x = NULL;
......@@ -107,13 +114,22 @@ static void dirtest_function(switch_core_session_t *session, char *data)
}
static switch_status_t show_dtmf(switch_core_session_t *session, char *dtmf, void *buf, unsigned int buflen)
static switch_status_t show_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
switch_copy_string((char *)buf, dtmf, buflen);
return SWITCH_STATUS_SUCCESS;
switch (itype) {
case SWITCH_INPUT_TYPE_DTMF: {
char *dtmf = (char *) input;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
switch_copy_string((char *)buf, dtmf, buflen);
}
break;
default:
break;
}
return SWITCH_STATUS_SUCCESS;
}
static void tts_function(switch_core_session_t *session, char *data)
......
......@@ -37,12 +37,22 @@ static const char modname[] = "mod_playback";
dtmf handler function you can hook up to be executed when a digit is dialed during playback
if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
*/
static switch_status_t on_dtmf(switch_core_session_t *session, char *dtmf, void *buf, unsigned int buflen)
static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
if (*dtmf == '*') {
return SWITCH_STATUS_FALSE;
switch (itype) {
case SWITCH_INPUT_TYPE_DTMF: {
char *dtmf = (char *) input;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
if (*dtmf == '*') {
return SWITCH_STATUS_FALSE;
}
}
break;
default:
break;
}
return SWITCH_STATUS_SUCCESS;
......
......@@ -85,69 +85,75 @@ static uint32_t match_count(char *str, uint32_t max)
dtmf handler function you can hook up to be executed when a digit is dialed during playback
if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
*/
static switch_status_t on_dtmf(switch_core_session_t *session, char *dtmf, void *buf, unsigned int buflen)
{
static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
struct dtmf_buffer *dtb;
dtb = (struct dtmf_buffer *) buf;
{
switch (itype) {
case SWITCH_INPUT_TYPE_DTMF: {
char *dtmf = (char *) input;
struct dtmf_buffer *dtb;
dtb = (struct dtmf_buffer *) buf;
switch(*dtmf) {
case '#':
switch_set_flag(dtb, SFLAG_MAIN);
return SWITCH_STATUS_BREAK;
case '6':
dtb->index++;
return SWITCH_STATUS_BREAK;
case '4':
dtb->index--;
return SWITCH_STATUS_BREAK;
case '*':
if (switch_test_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE)) {
switch_clear_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE);
} else {
switch_set_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE);
}
break;
case '5':
switch_core_speech_text_param_tts(dtb->sh, "voice", "next");
switch_set_flag(dtb, SFLAG_INFO);
return SWITCH_STATUS_BREAK;
break;
case '9':
switch_core_speech_text_param_tts(dtb->sh, "voice", dtb->voice);
switch_set_flag(dtb, SFLAG_INFO);
return SWITCH_STATUS_BREAK;
break;
case '2':
if (dtb->speed < 260) {
dtb->speed += 30;
switch_core_speech_numeric_param_tts(dtb->sh, "speech/rate", dtb->speed);
switch(*dtmf) {
case '#':
switch_set_flag(dtb, SFLAG_MAIN);
return SWITCH_STATUS_BREAK;
case '6':
dtb->index++;
return SWITCH_STATUS_BREAK;
case '4':
dtb->index--;
return SWITCH_STATUS_BREAK;
case '*':
if (switch_test_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE)) {
switch_clear_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE);
} else {
switch_set_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE);
}
break;
case '5':
switch_core_speech_text_param_tts(dtb->sh, "voice", "next");
switch_set_flag(dtb, SFLAG_INFO);
return SWITCH_STATUS_BREAK;
}
break;
case '7':
dtb->speed = TTS_MEAN_SPEED;
switch_core_speech_numeric_param_tts(dtb->sh, "speech/rate", dtb->speed);
switch_set_flag(dtb, SFLAG_INFO);
return SWITCH_STATUS_BREAK;
case '8':
if (dtb->speed > 80) {
dtb->speed -= 30;
break;
case '9':
switch_core_speech_text_param_tts(dtb->sh, "voice", dtb->voice);
switch_set_flag(dtb, SFLAG_INFO);
return SWITCH_STATUS_BREAK;
break;
case '2':
if (dtb->speed < 260) {
dtb->speed += 30;
switch_core_speech_numeric_param_tts(dtb->sh, "speech/rate", dtb->speed);
switch_set_flag(dtb, SFLAG_INFO);
return SWITCH_STATUS_BREAK;
}
break;
case '7':
dtb->speed = TTS_MEAN_SPEED;
switch_core_speech_numeric_param_tts(dtb->sh, "speech/rate", dtb->speed);
switch_set_flag(dtb, SFLAG_INFO);
return SWITCH_STATUS_BREAK;
case '8':
if (dtb->speed > 80) {
dtb->speed -= 30;
switch_core_speech_numeric_param_tts(dtb->sh, "speech/rate", dtb->speed);
switch_set_flag(dtb, SFLAG_INFO);
return SWITCH_STATUS_BREAK;
}
break;
case '0':
switch_set_flag(dtb, SFLAG_INSTRUCT);
return SWITCH_STATUS_BREAK;
}
}
break;
default:
break;
case '0':
switch_set_flag(dtb, SFLAG_INSTRUCT);
return SWITCH_STATUS_BREAK;
}
return SWITCH_STATUS_SUCCESS;
}
static void rss_function(switch_core_session_t *session, char *data)
{
switch_channel_t *channel;
......
......@@ -1509,7 +1509,9 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", from);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "subject", subject);
switch_event_add_body(event, msg);
switch_event_fire(&event);
if (switch_core_session_queue_event(tech_pvt->session, &event) != SWITCH_STATUS_SUCCESS) {
switch_event_fire(&event);
}
}
break;
......
......@@ -239,6 +239,7 @@ static int on_msg(void *user_data, ikspak * pak)
stream.data = retbuf;
stream.end = stream.data;
stream.data_size = sizeof(retbuf);
stream.write_function = switch_console_stream_write;
switch_api_execute(cmd, arg, &stream);
return 0;
......
......@@ -307,7 +307,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_message_send(char *uuid_str,
return status;
}
SWITCH_DECLARE(switch_status_t) switch_core_session_event_send(char *uuid_str, switch_event_t *event)
SWITCH_DECLARE(switch_status_t) switch_core_session_event_send(char *uuid_str, switch_event_t **event)
{
switch_core_session_t *session = NULL;
switch_status_t status = SWITCH_STATUS_FALSE;
......@@ -1057,29 +1057,73 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_receive_message(switch_core_
return status;
}
SWITCH_DECLARE(switch_status_t) switch_core_session_queue_event(switch_core_session_t *session, switch_event_t *event)
SWITCH_DECLARE(switch_status_t) switch_core_session_receive_event(switch_core_session_t *session, switch_event_t **event)
{
switch_io_event_hook_queue_event_t *ptr;
switch_status_t status = SWITCH_STATUS_FALSE, istatus = SWITCH_STATUS_FALSE;;
switch_io_event_hook_receive_event_t *ptr;
switch_status_t status = SWITCH_STATUS_FALSE;
assert(session != NULL);
if (session->endpoint_interface->io_routines->queue_event) {
status = session->endpoint_interface->io_routines->queue_event(session, event);
if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
for (ptr = session->event_hooks.queue_event; ptr; ptr = ptr->next) {
if ((istatus = ptr->queue_event(session, event)) != SWITCH_STATUS_SUCCESS) {
break;
/* Acquire a read lock on the session or forget it the channel is dead */
if (switch_thread_rwlock_tryrdlock(session->rwlock) == SWITCH_STATUS_SUCCESS) {
if (switch_channel_get_state(session->channel) < CS_HANGUP) {
if (session->endpoint_interface->io_routines->receive_event) {
status = session->endpoint_interface->io_routines->receive_event(session, *event);
}
if (status == SWITCH_STATUS_SUCCESS) {
for (ptr = session->event_hooks.receive_event; ptr; ptr = ptr->next) {
if ((status = ptr->receive_event(session, *event)) != SWITCH_STATUS_SUCCESS) {
break;
}
}
}
}
if (status == SWITCH_STATUS_SUCCESS || status == SWITCH_STATUS_BREAK) {
if (!session->event_queue) {
switch_queue_create(&session->event_queue, SWITCH_EVENT_QUEUE_LEN, session->pool);
if (status == SWITCH_STATUS_BREAK) {
status = SWITCH_STATUS_SUCCESS;
}
if (status == SWITCH_STATUS_SUCCESS) {
switch_event_destroy(event);
}
switch_queue_push(session->event_queue, event);
}
switch_thread_rwlock_unlock(session->rwlock);
}
return status;
}
SWITCH_DECLARE(switch_status_t) switch_core_session_queue_event(switch_core_session_t *session, switch_event_t **event)
{
switch_status_t status = SWITCH_STATUS_SUCCESS;
assert(session != NULL);
if (!session->event_queue) {
switch_queue_create(&session->event_queue, SWITCH_EVENT_QUEUE_LEN, session->pool);
}
if ((status = (switch_status_t) switch_queue_push(session->event_queue, *event) == SWITCH_STATUS_SUCCESS)) {
*event = NULL;
}
return status;
}
SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_event(switch_core_session_t *session, switch_event_t **event)
{
switch_status_t status = SWITCH_STATUS_FALSE;
void *pop;
assert(session != NULL);
if (session->event_queue) {
if ((status = (switch_status_t) switch_queue_trypop(session->event_queue, &pop)) == SWITCH_STATUS_SUCCESS) {
*event = (switch_event_t *) pop;
}
}
......
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论