diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/json.c | 8 | ||||
-rw-r--r-- | main/manager_channels.c | 4 | ||||
-rw-r--r-- | main/stasis_channels.c | 31 |
3 files changed, 35 insertions, 8 deletions
diff --git a/main/json.c b/main/json.c index 07d2c5e95..2aa53875b 100644 --- a/main/json.c +++ b/main/json.c @@ -519,16 +519,12 @@ struct ast_json *ast_json_dialplan_cep(const char *context, const char *exten, i "priority", priority != -1 ? ast_json_integer_create(priority) : ast_json_null()); } -struct ast_json *ast_json_timeval(const struct timeval *tv, const char *zone) +struct ast_json *ast_json_timeval(const struct timeval tv, const char *zone) { char buf[AST_ISO8601_LEN]; struct ast_tm tm = {}; - if (tv == NULL) { - return NULL; - } - - ast_localtime(tv, &tm, zone); + ast_localtime(&tv, &tm, zone); ast_strftime(buf, sizeof(buf),AST_ISO8601_FORMAT, &tm); diff --git a/main/manager_channels.c b/main/manager_channels.c index 03cf71fd8..004467e3b 100644 --- a/main/manager_channels.c +++ b/main/manager_channels.c @@ -665,7 +665,7 @@ static void channel_dtmf_begin(struct ast_channel_blob *obj) const char *direction = ast_json_string_get(ast_json_object_get(obj->blob, "direction")); - channel_event_string = manager_build_channel_state_string(obj->snapshot); + channel_event_string = ast_manager_build_channel_state_string(obj->snapshot); if (!channel_event_string) { return; @@ -706,7 +706,7 @@ static void channel_dtmf_end(struct ast_channel_blob *obj) long duration_ms = ast_json_integer_get(ast_json_object_get(obj->blob, "duration_ms")); - channel_event_string = manager_build_channel_state_string(obj->snapshot); + channel_event_string = ast_manager_build_channel_state_string(obj->snapshot); if (!channel_event_string) { return; diff --git a/main/stasis_channels.c b/main/stasis_channels.c index 363ceb7e4..b40f13572 100644 --- a/main/stasis_channels.c +++ b/main/stasis_channels.c @@ -458,6 +458,37 @@ void ast_channel_publish_varset(struct ast_channel *chan, const char *name, cons publish_message_for_channel_topics(msg, chan); } +struct ast_json *ast_channel_snapshot_to_json(const struct ast_channel_snapshot *snapshot) +{ + RAII_VAR(struct ast_json *, json_chan, NULL, ast_json_unref); + + if (snapshot == NULL) { + return NULL; + } + + json_chan = ast_json_pack("{ s: s, s: s, s: s, s: s, s: s, s: s, s: s," + " s: s, s: s, s: s, s: s, s: o, s: o, s: o," + " s: o" + "}", + "name", snapshot->name, + "state", ast_state2str(snapshot->state), + "accountcode", snapshot->accountcode, + "peeraccount", snapshot->peeraccount, + "userfield", snapshot->userfield, + "uniqueid", snapshot->uniqueid, + "linkedid", snapshot->linkedid, + "parkinglot", snapshot->parkinglot, + "hangupsource", snapshot->hangupsource, + "appl", snapshot->appl, + "data", snapshot->data, + "dialplan", ast_json_dialplan_cep(snapshot->context, snapshot->exten, snapshot->priority), + "caller", ast_json_name_number(snapshot->caller_name, snapshot->caller_number), + "connected", ast_json_name_number(snapshot->connected_name, snapshot->connected_number), + "creationtime", ast_json_timeval(snapshot->creationtime, NULL)); + + return ast_json_ref(json_chan); +} + void ast_stasis_channels_shutdown(void) { ao2_cleanup(channel_snapshot_type); |