void ast_channel_callid_set(struct ast_channel *chan, struct ast_callid *callid) { char call_identifier_from[AST_CALLID_BUFFER_LENGTH]; char call_identifier_to[AST_CALLID_BUFFER_LENGTH]; call_identifier_from[0] = '\0'; ast_callid_strnprint(call_identifier_to, sizeof(call_identifier_to), callid); if (chan->callid) { ast_callid_strnprint(call_identifier_from, sizeof(call_identifier_from), chan->callid); ast_debug(3, "Channel Call ID changing from %s to %s\n", call_identifier_from, call_identifier_to); /* unbind if already set */ ast_callid_unref(chan->callid); } chan->callid = ast_callid_ref(callid); ast_test_suite_event_notify("CallIDChange", "State: CallIDChange\r\n" "Channel: %s\r\n" "CallID: %s\r\n" "PriorCallID: %s", ast_channel_name(chan), call_identifier_to, call_identifier_from); ast_channel_publish_snapshot(chan); }
static void mixmonitor_free(struct mixmonitor *mixmonitor) { if (mixmonitor) { if (mixmonitor->mixmonitor_ds) { ast_mutex_destroy(&mixmonitor->mixmonitor_ds->lock); ast_cond_destroy(&mixmonitor->mixmonitor_ds->destruction_condition); ast_free(mixmonitor->filename_write); ast_free(mixmonitor->filename_read); ast_free(mixmonitor->mixmonitor_ds); ast_free(mixmonitor->name); ast_free(mixmonitor->post_process); } if (mixmonitor->callid) { ast_callid_unref(mixmonitor->callid); } ast_free(mixmonitor); } }
/*! \brief Part of PBX interface */ static struct ast_channel *local_request(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, int *cause) { struct local_pvt *p; struct ast_channel *chan; struct ast_callid *callid; /* Allocate a new private structure and then Asterisk channels */ p = local_alloc(data, cap); if (!p) { return NULL; } callid = ast_read_threadstorage_callid(); chan = ast_unreal_new_channels(&p->base, &local_tech, AST_STATE_DOWN, AST_STATE_RING, p->exten, p->context, assignedids, requestor, callid); if (chan) { ao2_link(locals, p); } if (callid) { ast_callid_unref(callid); } ao2_ref(p, -1); /* kill the ref from the alloc */ return chan; }
void ast_channel_callid_cleanup(struct ast_channel *chan) { if (chan->callid) { chan->callid = ast_callid_unref(chan->callid); } }
struct ast_channel_snapshot *ast_channel_snapshot_create(struct ast_channel *chan) { struct ast_channel_snapshot *snapshot; struct ast_bridge *bridge; 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)) { return NULL; } snapshot = ao2_alloc(sizeof(*snapshot), channel_snapshot_dtor); if (!snapshot || ast_string_field_init(snapshot, 1024)) { ao2_cleanup(snapshot); return NULL; } 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)); ast_string_field_set(snapshot, uniqueid, ast_channel_uniqueid(chan)); ast_string_field_set(snapshot, linkedid, ast_channel_linkedid(chan)); ast_string_field_set(snapshot, hangupsource, ast_channel_hangupsource(chan)); if (ast_channel_appl(chan)) { ast_string_field_set(snapshot, appl, ast_channel_appl(chan)); } if (ast_channel_data(chan)) { ast_string_field_set(snapshot, data, ast_channel_data(chan)); } ast_string_field_set(snapshot, context, ast_channel_context(chan)); ast_string_field_set(snapshot, exten, ast_channel_exten(chan)); ast_string_field_set(snapshot, caller_name, S_COR(ast_channel_caller(chan)->id.name.valid, ast_channel_caller(chan)->id.name.str, "")); ast_string_field_set(snapshot, caller_number, S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, "")); ast_string_field_set(snapshot, caller_dnid, S_OR(ast_channel_dialed(chan)->number.str, "")); ast_string_field_set(snapshot, caller_subaddr, S_COR(ast_channel_caller(chan)->id.subaddress.valid, ast_channel_caller(chan)->id.subaddress.str, "")); ast_string_field_set(snapshot, dialed_subaddr, S_COR(ast_channel_dialed(chan)->subaddress.valid, ast_channel_dialed(chan)->subaddress.str, "")); ast_string_field_set(snapshot, caller_ani, S_COR(ast_channel_caller(chan)->ani.number.valid, ast_channel_caller(chan)->ani.number.str, "")); ast_string_field_set(snapshot, caller_rdnis, S_COR(ast_channel_redirecting(chan)->from.number.valid, ast_channel_redirecting(chan)->from.number.str, "")); ast_string_field_set(snapshot, caller_dnid, S_OR(ast_channel_dialed(chan)->number.str, "")); ast_string_field_set(snapshot, connected_name, S_COR(ast_channel_connected(chan)->id.name.valid, ast_channel_connected(chan)->id.name.str, "")); ast_string_field_set(snapshot, connected_number, 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); ao2_cleanup(bridge); } 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); snapshot->tech_properties = ast_channel_tech(chan)->properties; return snapshot; }