FS-10015: [freeswitch-core] Add variable to allow firing of text events #resolve

This commit is contained in:
Anthony Minessale 2017-02-06 16:37:59 -06:00
parent db89f45e0d
commit 9dba32410f
7 changed files with 33 additions and 10 deletions

View File

@ -147,7 +147,7 @@ static const char *EVENT_NAMES[] = {
"CALL_SETUP_RESULT",
"CALL_DETAIL",
"DEVICE_STATE",
"REAL_TIME_TEXT",
"TEXT",
"ALL"
};

View File

@ -137,7 +137,7 @@ typedef enum {
ESL_EVENT_CALL_SETUP_RESULT,
ESL_EVENT_CALL_DETAIL,
ESL_EVENT_DEVICE_STATE,
ESL_EVENT_REAL_TIME_TEXT,
ESL_EVENT_TEXT,
ESL_EVENT_ALL
} esl_event_types_t;

View File

@ -1537,6 +1537,7 @@ typedef enum {
CF_TEXT_IDLE,
CF_TEXT_LINE_BASED,
CF_QUEUE_TEXT_EVENTS,
CF_FIRE_TEXT_EVENTS,
CF_MSRP,
CF_MSRPS,
CF_WANT_MSRP,
@ -2058,7 +2059,7 @@ typedef enum {
SWITCH_EVENT_CALL_SETUP_RESULT,
SWITCH_EVENT_CALL_DETAIL,
SWITCH_EVENT_DEVICE_STATE,
SWITCH_EVENT_REAL_TIME_TEXT,
SWITCH_EVENT_TEXT,
SWITCH_EVENT_ALL
} switch_event_types_t;

View File

@ -2644,6 +2644,7 @@ SWITCH_DECLARE(void) switch_channel_event_set_extended_data(switch_channel_t *ch
event->event_id == SWITCH_EVENT_MEDIA_BUG_STOP ||
event->event_id == SWITCH_EVENT_CHANNEL_HOLD ||
event->event_id == SWITCH_EVENT_CHANNEL_UNHOLD ||
event->event_id == SWITCH_EVENT_TEXT ||
event->event_id == SWITCH_EVENT_CUSTOM) {
/* Index Variables */

View File

@ -6461,6 +6461,10 @@ static void *SWITCH_THREAD_FUNC text_helper_thread(switch_thread_t *thread, void
return NULL;
}
if (switch_channel_var_true(session->channel, "fire_text_events")) {
switch_channel_set_flag(session->channel, CF_FIRE_TEXT_EVENTS);
}
cr_frame.data = CR;
cr_frame.datalen = 3;
@ -14206,9 +14210,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_text_frame(switch_core_
switch_core_media_bug_prune(session);
}
}
if (status == SWITCH_STATUS_SUCCESS || status == SWITCH_STATUS_BREAK) {
if (switch_channel_test_flag(session->channel, CF_QUEUE_TEXT_EVENTS) && (*frame)->datalen && !switch_test_flag((*frame), SFF_CNG)) {
if ((switch_channel_test_flag(session->channel, CF_QUEUE_TEXT_EVENTS) || switch_channel_test_flag(session->channel, CF_FIRE_TEXT_EVENTS)) &&
(*frame)->datalen && !switch_test_flag((*frame), SFF_CNG)) {
int ok = 1;
switch_event_t *event;
void *data = (*frame)->data;
@ -14234,11 +14239,27 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_text_frame(switch_core_
if (ok) {
if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_extended_data(session->channel, event);
if (switch_event_create(&event, SWITCH_EVENT_TEXT) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(session->channel, event);
switch_event_add_body(event, "%s", (char *)data);
switch_core_session_queue_event(session, &event);
if (switch_channel_test_flag(session->channel, CF_QUEUE_TEXT_EVENTS)) {
switch_event_t *q_event = NULL;
if (switch_channel_test_flag(session->channel, CF_FIRE_TEXT_EVENTS)) {
switch_event_dup(&q_event, event);
} else {
q_event = event;
event = NULL;
}
switch_core_session_queue_event(session, &q_event);
}
if (switch_channel_test_flag(session->channel, CF_FIRE_TEXT_EVENTS)) {
switch_event_fire(&event);
}
}
if (session->text_line_buffer) {
switch_buffer_zero(session->text_line_buffer);

View File

@ -219,7 +219,7 @@ static char *EVENT_NAMES[] = {
"CALL_SETUP_RESULT",
"CALL_DETAIL",
"DEVICE_STATE",
"REAL_TIME_TEXT",
"TEXT",
"ALL"
};

View File

@ -1543,7 +1543,7 @@ static switch_bool_t text_callback(switch_media_bug_t *bug, void *user_data, swi
switch_core_session_t *session = switch_core_media_bug_get_session(bug);
//switch_channel_t *channel = switch_core_session_get_channel(session);
if (switch_event_create(&event, SWITCH_EVENT_REAL_TIME_TEXT) == SWITCH_STATUS_SUCCESS) {
if (switch_event_create(&event, SWITCH_EVENT_TEXT) == SWITCH_STATUS_SUCCESS) {
switch_event_add_body(event, text, SWITCH_VA_NONE);
if (switch_true(switch_core_get_variable("fire_text_events"))) {