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
This commit is contained in:
David M. Lee
2013-04-15 16:22:03 +00:00
parent c6cf12408e
commit 2450722f52
5 changed files with 206 additions and 46 deletions

View File

@@ -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);