summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorDavid M. Lee <dlee@digium.com>2013-04-15 16:22:03 +0000
committerDavid M. Lee <dlee@digium.com>2013-04-15 16:22:03 +0000
commit2450722f52401b8537e9c0ffb1192f38b7dd146d (patch)
tree2a798888a6601082b150a2eada805b0b82aadaa4 /apps
parentc6cf12408edc133c229b323a9039e04f3c12c248 (diff)
DTMF events are now published on a channel's stasis_topic. AMI was
refactored to use these events rather than producing the events directly in channel.c. Finally, the code was added to app_stasis to produce DTMF events on the WebSocket. The AMI events are completely backward compatible, including sending events on transmitted DTMF, and sending DTMF start events. The Stasis-HTTP events are somewhat simplified. Since DTMF start and DTMF send events are generally less useful, Stasis-HTTP will only send events on received DTMF end. (closes issue ASTERISK-21282) (closes issue ASTERISK-21359) Review: https://reviewboard.asterisk.org/r/2439 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@385734 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps')
-rw-r--r--apps/app_stasis.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/apps/app_stasis.c b/apps/app_stasis.c
index 40269239d..62b35b49e 100644
--- a/apps/app_stasis.c
+++ b/apps/app_stasis.c
@@ -358,6 +358,43 @@ static int send_end_msg(struct app *app, struct ast_channel *chan)
return 0;
}
+static void dtmf_handler(struct app *app, struct ast_channel_blob *obj)
+{
+ RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref);
+ RAII_VAR(struct ast_json *, msg, NULL, ast_json_unref);
+ const char *direction;
+
+ /* To simplify events, we'll only generate on receive */
+ direction = ast_json_string_get(
+ ast_json_object_get(obj->blob, "direction"));
+
+ if (strcmp("Received", direction) != 0) {
+ return;
+ }
+
+ extra = ast_json_pack(
+ "{s: o}",
+ "digit", ast_json_ref(ast_json_object_get(obj->blob, "digit")));
+ if (!extra) {
+ return;
+ }
+
+ msg = app_event_create("dtmf-received", obj->snapshot, extra);
+ if (!msg) {
+ return;
+ }
+
+ app_send(app, msg);
+}
+
+static void blob_handler(struct app *app, struct ast_channel_blob *blob)
+{
+ /* To simplify events, we'll only generate on DTMF end */
+ if (strcmp(ast_channel_blob_json_type(blob), "dtmf_end") == 0) {
+ dtmf_handler(app, blob);
+ }
+}
+
static void sub_handler(void *data, struct stasis_subscription *sub,
struct stasis_topic *topic,
struct stasis_message *message)
@@ -373,6 +410,9 @@ static void sub_handler(void *data, struct stasis_subscription *sub,
return;
}
app_send(app, msg);
+ } else if (ast_channel_blob_type() == stasis_message_type(message)) {
+ struct ast_channel_blob *blob = stasis_message_data(message);
+ blob_handler(app, blob);
}
if (stasis_subscription_final_message(sub, message)) {
ao2_cleanup(data);