mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-18 18:58:22 +00:00
Refactor operations to access the stasis cache instead of objects directly when retrieving information.
(closes issue ASTERISK-21883) Review: https://reviewboard.asterisk.org/r/2645/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@393831 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -35,6 +35,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||
#include "asterisk/astobj2.h"
|
||||
#include "asterisk/json.h"
|
||||
#include "asterisk/pbx.h"
|
||||
#include "asterisk/bridging.h"
|
||||
#include "asterisk/translate.h"
|
||||
#include "asterisk/stasis.h"
|
||||
#include "asterisk/stasis_channels.h"
|
||||
|
||||
@@ -121,13 +123,21 @@ static int channel_snapshot_cmp_cb(void *obj, void *arg, int flags)
|
||||
static void channel_snapshot_dtor(void *obj)
|
||||
{
|
||||
struct ast_channel_snapshot *snapshot = obj;
|
||||
|
||||
ast_string_field_free_memory(snapshot);
|
||||
ao2_cleanup(snapshot->manager_vars);
|
||||
ao2_cleanup(snapshot->channel_vars);
|
||||
}
|
||||
|
||||
struct ast_channel_snapshot *ast_channel_snapshot_create(struct ast_channel *chan)
|
||||
{
|
||||
RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
|
||||
RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
|
||||
char nativeformats[256];
|
||||
struct ast_str *write_transpath = ast_str_alloca(256);
|
||||
struct ast_str *read_transpath = ast_str_alloca(256);
|
||||
struct ast_party_id effective_connected_id;
|
||||
struct ast_callid *callid;
|
||||
|
||||
/* no snapshots for dummy channels */
|
||||
if (!ast_channel_tech(chan)) {
|
||||
@@ -140,6 +150,7 @@ struct ast_channel_snapshot *ast_channel_snapshot_create(struct ast_channel *cha
|
||||
}
|
||||
|
||||
ast_string_field_set(snapshot, name, ast_channel_name(chan));
|
||||
ast_string_field_set(snapshot, type, ast_channel_tech(chan)->type);
|
||||
ast_string_field_set(snapshot, accountcode, ast_channel_accountcode(chan));
|
||||
ast_string_field_set(snapshot, peeraccount, ast_channel_peeraccount(chan));
|
||||
ast_string_field_set(snapshot, userfield, ast_channel_userfield(chan));
|
||||
@@ -180,16 +191,42 @@ struct ast_channel_snapshot *ast_channel_snapshot_create(struct ast_channel *cha
|
||||
S_COR(ast_channel_connected(chan)->id.number.valid, ast_channel_connected(chan)->id.number.str, ""));
|
||||
ast_string_field_set(snapshot, language, ast_channel_language(chan));
|
||||
|
||||
if ((bridge = ast_channel_get_bridge(chan))) {
|
||||
ast_string_field_set(snapshot, bridgeid, bridge->uniqueid);
|
||||
}
|
||||
|
||||
ast_string_field_set(snapshot, nativeformats, ast_getformatname_multiple(nativeformats, sizeof(nativeformats),
|
||||
ast_channel_nativeformats(chan)));
|
||||
ast_string_field_set(snapshot, readformat, ast_getformatname(ast_channel_readformat(chan)));
|
||||
ast_string_field_set(snapshot, writeformat, ast_getformatname(ast_channel_writeformat(chan)));
|
||||
ast_string_field_set(snapshot, writetrans, ast_translate_path_to_str(ast_channel_writetrans(chan), &write_transpath));
|
||||
ast_string_field_set(snapshot, readtrans, ast_translate_path_to_str(ast_channel_readtrans(chan), &read_transpath));
|
||||
|
||||
effective_connected_id = ast_channel_connected_effective_id(chan);
|
||||
ast_string_field_set(snapshot, effective_name,
|
||||
S_COR(effective_connected_id.name.valid, effective_connected_id.name.str, ""));
|
||||
ast_string_field_set(snapshot, effective_number,
|
||||
S_COR(effective_connected_id.number.valid, effective_connected_id.number.str, ""));
|
||||
|
||||
if ((callid = ast_channel_callid(chan))) {
|
||||
ast_callid_strnprint(snapshot->callid, sizeof(snapshot->callid), callid);
|
||||
ast_callid_unref(callid);
|
||||
}
|
||||
|
||||
snapshot->creationtime = ast_channel_creationtime(chan);
|
||||
snapshot->hanguptime = *(ast_channel_whentohangup(chan));
|
||||
snapshot->state = ast_channel_state(chan);
|
||||
snapshot->priority = ast_channel_priority(chan);
|
||||
snapshot->amaflags = ast_channel_amaflags(chan);
|
||||
snapshot->hangupcause = ast_channel_hangupcause(chan);
|
||||
ast_copy_flags(&snapshot->flags, ast_channel_flags(chan), 0xFFFFFFFF);
|
||||
snapshot->caller_pres = ast_party_id_presentation(&ast_channel_caller(chan)->id);
|
||||
snapshot->callgroup = ast_channel_callgroup(chan);
|
||||
snapshot->pickupgroup = ast_channel_pickupgroup(chan);
|
||||
ast_set_flag(&snapshot->softhangup_flags, ast_channel_softhangup_internal_flag(chan));
|
||||
|
||||
snapshot->manager_vars = ast_channel_get_manager_vars(chan);
|
||||
snapshot->channel_vars = ast_channel_get_vars(chan);
|
||||
|
||||
ao2_ref(snapshot, +1);
|
||||
return snapshot;
|
||||
|
Reference in New Issue
Block a user