From 83c94be443de47fb5d20e6f7beaa3c395d736590 Mon Sep 17 00:00:00 2001 From: Anatoly Y Date: Wed, 31 May 2017 09:29:22 +0000 Subject: [PATCH 1/4] Added Events --- mod_amd.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/mod_amd.c b/mod_amd.c index cccfad6..e08a295 100644 --- a/mod_amd.c +++ b/mod_amd.c @@ -145,7 +145,7 @@ typedef enum { } amd_vad_state_t; typedef struct { - const switch_core_session_t *session; + switch_core_session_t *session; switch_channel_t *channel; amd_vad_state_t state; uint32_t frame_ms; @@ -158,6 +158,23 @@ typedef struct { uint32_t in_greeting:1; } amd_vad_t; +static void amd_fire_event(const char *result, const char *cause, switch_core_session_t *fs_s) +{ + switch_event_t *event; + switch_event_t *event_copy; + + if ((switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, "amd")) != SWITCH_STATUS_SUCCESS) + return; + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "AMD-Result", result); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "AMD-Cause", cause); + if ((switch_event_dup(&event_copy, event)) != SWITCH_STATUS_SUCCESS) + return; + switch_core_session_queue_event(fs_s, &event); + switch_event_fire(&event_copy); + + return; +} + static amd_frame_classifier classify_frame(const switch_frame_t *f, const switch_codec_implementation_t *codec) { int16_t *audio = f->data; @@ -207,6 +224,7 @@ static switch_bool_t amd_handle_silence_frame(amd_vad_t *vad, const switch_frame switch_channel_set_variable(vad->channel, "amd_result", "MACHINE"); switch_channel_set_variable(vad->channel, "amd_cause", "INITIALSILENCE"); + amd_fire_event("MACHINE", "INITIALSILENCE", vad->session); return SWITCH_TRUE; } @@ -220,6 +238,7 @@ static switch_bool_t amd_handle_silence_frame(amd_vad_t *vad, const switch_frame switch_channel_set_variable(vad->channel, "amd_result", "HUMAN"); switch_channel_set_variable(vad->channel, "amd_cause", "HUMAN"); + amd_fire_event("HUMAN", "HUMAN", vad->session); return SWITCH_TRUE; } @@ -252,6 +271,7 @@ static switch_bool_t amd_handle_voiced_frame(amd_vad_t *vad, const switch_frame_ switch_channel_set_variable(vad->channel, "amd_result", "MACHINE"); switch_channel_set_variable(vad->channel, "amd_cause", "MAXWORDLENGTH"); + amd_fire_event("MACHINE", "MAXWORDLENGTH", vad->session); return SWITCH_TRUE; } @@ -265,6 +285,7 @@ static switch_bool_t amd_handle_voiced_frame(amd_vad_t *vad, const switch_frame_ switch_channel_set_variable(vad->channel, "amd_result", "MACHINE"); switch_channel_set_variable(vad->channel, "amd_cause", "MAXWORDS"); + amd_fire_event("MACHINE", "MAXWORDS", vad->session); return SWITCH_TRUE; } @@ -278,6 +299,7 @@ static switch_bool_t amd_handle_voiced_frame(amd_vad_t *vad, const switch_frame_ switch_channel_set_variable(vad->channel, "amd_result", "MACHINE"); switch_channel_set_variable(vad->channel, "amd_cause", "LONGGREETING"); + amd_fire_event("MACHINE", "LONGGREETING", vad->session); return SWITCH_TRUE; } From 645ebb27b1cad71972ba2e932cc34aa6d66f5ca7 Mon Sep 17 00:00:00 2001 From: Anatoly Y Date: Fri, 9 Jun 2017 09:41:00 +0000 Subject: [PATCH 2/4] Added Unique-ID field fot event --- mod_amd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mod_amd.c b/mod_amd.c index e08a295..cb515a5 100644 --- a/mod_amd.c +++ b/mod_amd.c @@ -167,6 +167,7 @@ static void amd_fire_event(const char *result, const char *cause, switch_core_se return; switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "AMD-Result", result); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "AMD-Cause", cause); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(fs_s)); if ((switch_event_dup(&event_copy, event)) != SWITCH_STATUS_SUCCESS) return; switch_core_session_queue_event(fs_s, &event); @@ -412,6 +413,7 @@ SWITCH_STANDARD_APP(amd_start_function) switch_channel_set_variable(channel, "amd_result", "NOTSURE"); switch_channel_set_variable(channel, "amd_cause", "TOOLONG"); + amd_fire_event("NOTSURE", "TOOLONG", vad.session); break; } } From fb55b4ba29c996e07321f3cfedd9962b9bf8d4d7 Mon Sep 17 00:00:00 2001 From: Anatoly Y Date: Fri, 3 Dec 2021 15:19:25 +0700 Subject: [PATCH 3/4] docs: Update README --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1a30b05..10147aa 100644 --- a/README.md +++ b/README.md @@ -18,14 +18,16 @@ To build this module, all you need to do is type `make`, but because it relies on `pkg-config` and FreeSWITCH, you need to point `pkg-config` to where FreeSWITCH is installed before building: -``` +```shell host$ export PKG_CONFIG_PATH=/usr/local/freeswitch/lib/pkgconfig/ host$ make ``` Sample Configuration -------------------- + Just put a file like this in your freeswitch installation, in **conf/autoload_configs/amd.conf.xml** + ```xml @@ -41,3 +43,9 @@ Just put a file like this in your freeswitch installation, in **conf/autoload_co ``` + +Events +------ + +The module fires the custom FreeSWITCH event (through the RabbitMQ transport) `amd` +with the significant fields `AMD-Result` and `AMD-Cause`. `Unique-ID` to recognize FreeSWITCH instance. From 2b3a0402a9763df9c083cd3e9a00e216d858e143 Mon Sep 17 00:00:00 2001 From: Anatoly Y Date: Fri, 3 Dec 2021 15:24:59 +0700 Subject: [PATCH 4/4] docs: Update README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 10147aa..6d7092c 100644 --- a/README.md +++ b/README.md @@ -47,5 +47,5 @@ Just put a file like this in your freeswitch installation, in **conf/autoload_co Events ------ -The module fires the custom FreeSWITCH event (through the RabbitMQ transport) `amd` -with the significant fields `AMD-Result` and `AMD-Cause`. `Unique-ID` to recognize FreeSWITCH instance. +The module fires the custom FreeSWITCH event `amd` with the significant fields `AMD-Result` and `AMD-Cause`. +`Unique-ID` to recognize FreeSWITCH instance.