summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorTerry Wilson <twilson@digium.com>2012-02-20 23:43:27 +0000
committerTerry Wilson <twilson@digium.com>2012-02-20 23:43:27 +0000
commit57f42bd74f78d5022631b2ba2269892f8a3a384a (patch)
tree3283ec4ac88c5b3c267f4490b410e5331911f2bb /main
parent25e5eb3b96e6d9bcbb2fc02fbd879ae21104c1f5 (diff)
ast_channel opaquification of pointers and integral types
Review: https://reviewboard.asterisk.org/r/1753/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@356042 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r--main/abstract_jb.c8
-rw-r--r--main/app.c32
-rw-r--r--main/audiohook.c60
-rw-r--r--main/bridging.c2
-rw-r--r--main/ccss.c4
-rw-r--r--main/cdr.c16
-rw-r--r--main/cel.c4
-rw-r--r--main/channel.c873
-rw-r--r--main/channel_internal_api.c404
-rw-r--r--main/cli.c50
-rw-r--r--main/devicestate.c2
-rw-r--r--main/dial.c6
-rw-r--r--main/features.c200
-rw-r--r--main/file.c75
-rw-r--r--main/framehook.c20
-rw-r--r--main/image.c8
-rw-r--r--main/manager.c30
-rw-r--r--main/message.c2
-rw-r--r--main/pbx.c172
-rw-r--r--main/rtp_engine.c48
-rw-r--r--main/udptl.c12
21 files changed, 1198 insertions, 830 deletions
diff --git a/main/abstract_jb.c b/main/abstract_jb.c
index 3ae3e0331..c35b1d8aa 100644
--- a/main/abstract_jb.c
+++ b/main/abstract_jb.c
@@ -160,14 +160,14 @@ int ast_jb_do_usecheck(struct ast_channel *c0, struct ast_channel *c1)
struct ast_jb *jb1 = &c1->jb;
struct ast_jb_conf *conf0 = &jb0->conf;
struct ast_jb_conf *conf1 = &jb1->conf;
- int c0_wants_jitter = c0->tech->properties & AST_CHAN_TP_WANTSJITTER;
- int c0_creates_jitter = c0->tech->properties & AST_CHAN_TP_CREATESJITTER;
+ int c0_wants_jitter = ast_channel_tech(c0)->properties & AST_CHAN_TP_WANTSJITTER;
+ int c0_creates_jitter = ast_channel_tech(c0)->properties & AST_CHAN_TP_CREATESJITTER;
int c0_jb_enabled = ast_test_flag(conf0, AST_JB_ENABLED);
int c0_force_jb = ast_test_flag(conf0, AST_JB_FORCED);
int c0_jb_timebase_initialized = ast_test_flag(jb0, JB_TIMEBASE_INITIALIZED);
int c0_jb_created = ast_test_flag(jb0, JB_CREATED);
- int c1_wants_jitter = c1->tech->properties & AST_CHAN_TP_WANTSJITTER;
- int c1_creates_jitter = c1->tech->properties & AST_CHAN_TP_CREATESJITTER;
+ int c1_wants_jitter = ast_channel_tech(c1)->properties & AST_CHAN_TP_WANTSJITTER;
+ int c1_creates_jitter = ast_channel_tech(c1)->properties & AST_CHAN_TP_CREATESJITTER;
int c1_jb_enabled = ast_test_flag(conf1, AST_JB_ENABLED);
int c1_force_jb = ast_test_flag(conf1, AST_JB_FORCED);
int c1_jb_timebase_initialized = ast_test_flag(jb1, JB_TIMEBASE_INITIALIZED);
diff --git a/main/app.c b/main/app.c
index d7c148581..821c2fbfb 100644
--- a/main/app.c
+++ b/main/app.c
@@ -122,14 +122,14 @@ int ast_app_dtget(struct ast_channel *chan, const char *context, char *collect,
}
if (!timeout) {
- if (chan->pbx && chan->pbx->dtimeoutms) {
- timeout = chan->pbx->dtimeoutms;
+ if (ast_channel_pbx(chan) && ast_channel_pbx(chan)->dtimeoutms) {
+ timeout = ast_channel_pbx(chan)->dtimeoutms;
} else {
timeout = 5000;
}
}
- if ((ts = ast_get_indication_tone(chan->zone, "dial"))) {
+ if ((ts = ast_get_indication_tone(ast_channel_zone(chan), "dial"))) {
res = ast_playtones_start(chan, 0, ts->data, 0);
ts = ast_tone_zone_sound_unref(ts);
} else {
@@ -193,8 +193,8 @@ enum ast_getdata_result ast_app_getdata(struct ast_channel *c, const char *promp
}
if (ast_strlen_zero(filename)) {
/* set timeouts for the last prompt */
- fto = c->pbx ? c->pbx->rtimeoutms : 6000;
- to = c->pbx ? c->pbx->dtimeoutms : 2000;
+ fto = ast_channel_pbx(c) ? ast_channel_pbx(c)->rtimeoutms : 6000;
+ to = ast_channel_pbx(c) ? ast_channel_pbx(c)->dtimeoutms : 2000;
if (timeout > 0) {
fto = to = timeout;
@@ -207,7 +207,7 @@ enum ast_getdata_result ast_app_getdata(struct ast_channel *c, const char *promp
* get rid of the long timeout between
* prompts, and make it 50ms */
fto = 50;
- to = c->pbx ? c->pbx->dtimeoutms : 2000;
+ to = ast_channel_pbx(c) ? ast_channel_pbx(c)->dtimeoutms : 2000;
}
res = ast_readstring(c, s, maxlen, to, fto, "#");
if (res == AST_GETDATA_EMPTY_END_TERMINATED) {
@@ -599,7 +599,7 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file,
strcat(breaks, restart);
}
}
- if (chan->_state != AST_STATE_UP) {
+ if (ast_channel_state(chan) != AST_STATE_UP) {
res = ast_answer(chan);
}
@@ -617,7 +617,7 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file,
res = ast_streamfile(chan, file, ast_channel_language(chan));
if (!res) {
if (pause_restart_point) {
- ast_seekstream(chan->stream, pause_restart_point, SEEK_SET);
+ ast_seekstream(ast_channel_stream(chan), pause_restart_point, SEEK_SET);
pause_restart_point = 0;
}
else if (end || offset < 0) {
@@ -626,12 +626,12 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file,
}
ast_verb(3, "ControlPlayback seek to offset %ld from end\n", offset);
- ast_seekstream(chan->stream, offset, SEEK_END);
+ ast_seekstream(ast_channel_stream(chan), offset, SEEK_END);
end = NULL;
offset = 0;
} else if (offset) {
ast_verb(3, "ControlPlayback seek to offset %ld\n", offset);
- ast_seekstream(chan->stream, offset, SEEK_SET);
+ ast_seekstream(ast_channel_stream(chan), offset, SEEK_SET);
offset = 0;
}
res = ast_waitstream_fr(chan, breaks, fwd, rev, skipms);
@@ -649,7 +649,7 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file,
}
if (suspend && strchr(suspend, res)) {
- pause_restart_point = ast_tellstream(chan->stream);
+ pause_restart_point = ast_tellstream(ast_channel_stream(chan));
for (;;) {
ast_stopstream(chan);
if (!(res = ast_waitfordigit(chan, 1000))) {
@@ -677,8 +677,8 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file,
if (pause_restart_point) {
offset = pause_restart_point;
} else {
- if (chan->stream) {
- offset = ast_tellstream(chan->stream);
+ if (ast_channel_stream(chan)) {
+ offset = ast_tellstream(ast_channel_stream(chan));
} else {
offset = -8; /* indicate end of file */
}
@@ -689,7 +689,7 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file,
}
/* If we are returning a digit cast it as char */
- if (res > 0 || chan->stream) {
+ if (res > 0 || ast_channel_stream(chan)) {
res = (char)res;
}
@@ -1692,7 +1692,7 @@ static int ivr_dispatch(struct ast_channel *chan, struct ast_ivr_option *option,
}
return res;
case AST_ACTION_WAITOPTION:
- if (!(res = ast_waitfordigit(chan, chan->pbx ? chan->pbx->rtimeoutms : 10000))) {
+ if (!(res = ast_waitfordigit(chan, ast_channel_pbx(chan) ? ast_channel_pbx(chan)->rtimeoutms : 10000))) {
return 't';
}
return res;
@@ -1750,7 +1750,7 @@ static int read_newoption(struct ast_channel *chan, struct ast_ivr_menu *menu, c
int res = 0;
int ms;
while (option_matchmore(menu, exten)) {
- ms = chan->pbx ? chan->pbx->dtimeoutms : 5000;
+ ms = ast_channel_pbx(chan) ? ast_channel_pbx(chan)->dtimeoutms : 5000;
if (strlen(exten) >= maxexten - 1) {
break;
}
diff --git a/main/audiohook.c b/main/audiohook.c
index 83fec318f..da80f0aea 100644
--- a/main/audiohook.c
+++ b/main/audiohook.c
@@ -434,30 +434,32 @@ int ast_audiohook_attach(struct ast_channel *chan, struct ast_audiohook *audioho
{
ast_channel_lock(chan);
- if (!chan->audiohooks) {
+ if (!ast_channel_audiohooks(chan)) {
+ struct ast_audiohook_list *ahlist;
/* Whoops... allocate a new structure */
- if (!(chan->audiohooks = ast_calloc(1, sizeof(*chan->audiohooks)))) {
+ if (!(ahlist = ast_calloc(1, sizeof(*ahlist)))) {
ast_channel_unlock(chan);
return -1;
}
- AST_LIST_HEAD_INIT_NOLOCK(&chan->audiohooks->spy_list);
- AST_LIST_HEAD_INIT_NOLOCK(&chan->audiohooks->whisper_list);
- AST_LIST_HEAD_INIT_NOLOCK(&chan->audiohooks->manipulate_list);
+ ast_channel_audiohooks_set(chan, ahlist);
+ AST_LIST_HEAD_INIT_NOLOCK(&ast_channel_audiohooks(chan)->spy_list);
+ AST_LIST_HEAD_INIT_NOLOCK(&ast_channel_audiohooks(chan)->whisper_list);
+ AST_LIST_HEAD_INIT_NOLOCK(&ast_channel_audiohooks(chan)->manipulate_list);
/* This sample rate will adjust as necessary when writing to the list. */
- chan->audiohooks->list_internal_samp_rate = 8000;
+ ast_channel_audiohooks(chan)->list_internal_samp_rate = 8000;
}
/* Drop into respective list */
if (audiohook->type == AST_AUDIOHOOK_TYPE_SPY)
- AST_LIST_INSERT_TAIL(&chan->audiohooks->spy_list, audiohook, list);
+ AST_LIST_INSERT_TAIL(&ast_channel_audiohooks(chan)->spy_list, audiohook, list);
else if (audiohook->type == AST_AUDIOHOOK_TYPE_WHISPER)
- AST_LIST_INSERT_TAIL(&chan->audiohooks->whisper_list, audiohook, list);
+ AST_LIST_INSERT_TAIL(&ast_channel_audiohooks(chan)->whisper_list, audiohook, list);
else if (audiohook->type == AST_AUDIOHOOK_TYPE_MANIPULATE)
- AST_LIST_INSERT_TAIL(&chan->audiohooks->manipulate_list, audiohook, list);
+ AST_LIST_INSERT_TAIL(&ast_channel_audiohooks(chan)->manipulate_list, audiohook, list);
- audiohook_set_internal_rate(audiohook, chan->audiohooks->list_internal_samp_rate, 1);
- audiohook_list_set_samplerate_compatibility(chan->audiohooks);
+ audiohook_set_internal_rate(audiohook, ast_channel_audiohooks(chan)->list_internal_samp_rate, 1);
+ audiohook_list_set_samplerate_compatibility(ast_channel_audiohooks(chan));
/* Change status over to running since it is now attached */
ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_RUNNING);
@@ -573,7 +575,7 @@ void ast_audiohook_move_by_source(struct ast_channel *old_chan, struct ast_chann
struct ast_audiohook *audiohook;
enum ast_audiohook_status oldstatus;
- if (!old_chan->audiohooks || !(audiohook = find_audiohook_by_source(old_chan->audiohooks, source))) {
+ if (!ast_channel_audiohooks(old_chan) || !(audiohook = find_audiohook_by_source(ast_channel_audiohooks(old_chan), source))) {
return;
}
@@ -604,12 +606,12 @@ int ast_audiohook_detach_source(struct ast_channel *chan, const char *source)
ast_channel_lock(chan);
/* Ensure the channel has audiohooks on it */
- if (!chan->audiohooks) {
+ if (!ast_channel_audiohooks(chan)) {
ast_channel_unlock(chan);
return -1;
}
- audiohook = find_audiohook_by_source(chan->audiohooks, source);
+ audiohook = find_audiohook_by_source(ast_channel_audiohooks(chan), source);
ast_channel_unlock(chan);
@@ -633,19 +635,19 @@ int ast_audiohook_remove(struct ast_channel *chan, struct ast_audiohook *audioho
{
ast_channel_lock(chan);
- if (!chan->audiohooks) {
+ if (!ast_channel_audiohooks(chan)) {
ast_channel_unlock(chan);
return -1;
}
if (audiohook->type == AST_AUDIOHOOK_TYPE_SPY)
- AST_LIST_REMOVE(&chan->audiohooks->spy_list, audiohook, list);
+ AST_LIST_REMOVE(&ast_channel_audiohooks(chan)->spy_list, audiohook, list);
else if (audiohook->type == AST_AUDIOHOOK_TYPE_WHISPER)
- AST_LIST_REMOVE(&chan->audiohooks->whisper_list, audiohook, list);
+ AST_LIST_REMOVE(&ast_channel_audiohooks(chan)->whisper_list, audiohook, list);
else if (audiohook->type == AST_AUDIOHOOK_TYPE_MANIPULATE)
- AST_LIST_REMOVE(&chan->audiohooks->manipulate_list, audiohook, list);
+ AST_LIST_REMOVE(&ast_channel_audiohooks(chan)->manipulate_list, audiohook, list);
- audiohook_list_set_samplerate_compatibility(chan->audiohooks);
+ audiohook_list_set_samplerate_compatibility(ast_channel_audiohooks(chan));
ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_DONE);
ast_channel_unlock(chan);
@@ -939,26 +941,26 @@ int ast_channel_audiohook_count_by_source(struct ast_channel *chan, const char *
int count = 0;
struct ast_audiohook *ah = NULL;
- if (!chan->audiohooks)
+ if (!ast_channel_audiohooks(chan))
return -1;
switch (type) {
case AST_AUDIOHOOK_TYPE_SPY:
- AST_LIST_TRAVERSE(&chan->audiohooks->spy_list, ah, list) {
+ AST_LIST_TRAVERSE(&ast_channel_audiohooks(chan)->spy_list, ah, list) {
if (!strcmp(ah->source, source)) {
count++;
}
}
break;
case AST_AUDIOHOOK_TYPE_WHISPER:
- AST_LIST_TRAVERSE(&chan->audiohooks->whisper_list, ah, list) {
+ AST_LIST_TRAVERSE(&ast_channel_audiohooks(chan)->whisper_list, ah, list) {
if (!strcmp(ah->source, source)) {
count++;
}
}
break;
case AST_AUDIOHOOK_TYPE_MANIPULATE:
- AST_LIST_TRAVERSE(&chan->audiohooks->manipulate_list, ah, list) {
+ AST_LIST_TRAVERSE(&ast_channel_audiohooks(chan)->manipulate_list, ah, list) {
if (!strcmp(ah->source, source)) {
count++;
}
@@ -977,24 +979,24 @@ int ast_channel_audiohook_count_by_source_running(struct ast_channel *chan, cons
{
int count = 0;
struct ast_audiohook *ah = NULL;
- if (!chan->audiohooks)
+ if (!ast_channel_audiohooks(chan))
return -1;
switch (type) {
case AST_AUDIOHOOK_TYPE_SPY:
- AST_LIST_TRAVERSE(&chan->audiohooks->spy_list, ah, list) {
+ AST_LIST_TRAVERSE(&ast_channel_audiohooks(chan)->spy_list, ah, list) {
if ((!strcmp(ah->source, source)) && (ah->status == AST_AUDIOHOOK_STATUS_RUNNING))
count++;
}
break;
case AST_AUDIOHOOK_TYPE_WHISPER:
- AST_LIST_TRAVERSE(&chan->audiohooks->whisper_list, ah, list) {
+ AST_LIST_TRAVERSE(&ast_channel_audiohooks(chan)->whisper_list, ah, list) {
if ((!strcmp(ah->source, source)) && (ah->status == AST_AUDIOHOOK_STATUS_RUNNING))
count++;
}
break;
case AST_AUDIOHOOK_TYPE_MANIPULATE:
- AST_LIST_TRAVERSE(&chan->audiohooks->manipulate_list, ah, list) {
+ AST_LIST_TRAVERSE(&ast_channel_audiohooks(chan)->manipulate_list, ah, list) {
if ((!strcmp(ah->source, source)) && (ah->status == AST_AUDIOHOOK_STATUS_RUNNING))
count++;
}
@@ -1207,12 +1209,12 @@ int ast_audiohook_set_mute(struct ast_channel *chan, const char *source, enum as
ast_channel_lock(chan);
/* Ensure the channel has audiohooks on it */
- if (!chan->audiohooks) {
+ if (!ast_channel_audiohooks(chan)) {
ast_channel_unlock(chan);
return -1;
}
- audiohook = find_audiohook_by_source(chan->audiohooks, source);
+ audiohook = find_audiohook_by_source(ast_channel_audiohooks(chan), source);
if (audiohook) {
if (clear) {
diff --git a/main/bridging.c b/main/bridging.c
index b97150f04..8fecd53b7 100644
--- a/main/bridging.c
+++ b/main/bridging.c
@@ -1531,7 +1531,7 @@ void ast_bridge_update_talker_src_video_mode(struct ast_bridge *bridge, struct a
{
struct ast_bridge_video_talker_src_data *data;
/* If the channel doesn't support video, we don't care about it */
- if (!ast_format_cap_has_type(chan->nativeformats, AST_FORMAT_TYPE_VIDEO)) {
+ if (!ast_format_cap_has_type(ast_channel_nativeformats(chan), AST_FORMAT_TYPE_VIDEO)) {
return;
}
diff --git a/main/ccss.c b/main/ccss.c
index e0925ab0a..b1ec63a89 100644
--- a/main/ccss.c
+++ b/main/ccss.c
@@ -2686,7 +2686,7 @@ static void *generic_recall(void *data)
ast_channel_exten_set(chan, generic_pvt->exten);
ast_channel_context_set(chan, generic_pvt->context);
- chan->priority = 1;
+ ast_channel_priority_set(chan, 1);
pbx_builtin_setvar_helper(chan, "CC_EXTEN", generic_pvt->exten);
pbx_builtin_setvar_helper(chan, "CC_CONTEXT", generic_pvt->context);
@@ -4045,7 +4045,7 @@ void ast_cc_call_failed(struct ast_channel *incoming, struct ast_channel *outgoi
struct cc_control_payload payload;
struct ast_cc_config_params *cc_params;
- if (outgoing->hangupcause != AST_CAUSE_BUSY && outgoing->hangupcause != AST_CAUSE_CONGESTION) {
+ if (ast_channel_hangupcause(outgoing) != AST_CAUSE_BUSY && ast_channel_hangupcause(outgoing) != AST_CAUSE_CONGESTION) {
/* It doesn't make sense to try to offer CCBS to the caller if the reason for ast_call
* failing is something other than busy or congestion
*/
diff --git a/main/cdr.c b/main/cdr.c
index 0c50a13d8..af6885308 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -930,8 +930,8 @@ int ast_cdr_init(struct ast_cdr *cdr, struct ast_channel *c)
set_one_cid(cdr, c);
cdr_seq_inc(cdr);
- cdr->disposition = (c->_state == AST_STATE_UP) ? AST_CDR_ANSWERED : AST_CDR_NOANSWER;
- cdr->amaflags = c->amaflags ? c->amaflags : ast_default_amaflags;
+ cdr->disposition = (ast_channel_state(c) == AST_STATE_UP) ? AST_CDR_ANSWERED : AST_CDR_NOANSWER;
+ cdr->amaflags = ast_channel_amaflags(c) ? ast_channel_amaflags(c) : ast_default_amaflags;
ast_copy_string(cdr->accountcode, ast_channel_accountcode(c), sizeof(cdr->accountcode));
ast_copy_string(cdr->peeraccount, ast_channel_peeraccount(c), sizeof(cdr->peeraccount));
/* Destination information */
@@ -1019,7 +1019,7 @@ char *ast_cdr_flags2str(int flag)
int ast_cdr_setaccount(struct ast_channel *chan, const char *account)
{
- struct ast_cdr *cdr = chan->cdr;
+ struct ast_cdr *cdr = ast_channel_cdr(chan);
const char *old_acct = "";
if (!ast_strlen_zero(ast_channel_accountcode(chan))) {
@@ -1045,7 +1045,7 @@ int ast_cdr_setaccount(struct ast_channel *chan, const char *account)
int ast_cdr_setpeeraccount(struct ast_channel *chan, const char *account)
{
- struct ast_cdr *cdr = chan->cdr;
+ struct ast_cdr *cdr = ast_channel_cdr(chan);
const char *old_acct = "";
if (!ast_strlen_zero(ast_channel_peeraccount(chan))) {
@@ -1074,7 +1074,7 @@ int ast_cdr_setamaflags(struct ast_channel *chan, const char *flag)
struct ast_cdr *cdr;
int newflag = ast_cdr_amaflags2int(flag);
if (newflag) {
- for (cdr = chan->cdr; cdr; cdr = cdr->next) {
+ for (cdr = ast_channel_cdr(chan); cdr; cdr = cdr->next) {
if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
cdr->amaflags = newflag;
}
@@ -1086,7 +1086,7 @@ int ast_cdr_setamaflags(struct ast_channel *chan, const char *flag)
int ast_cdr_setuserfield(struct ast_channel *chan, const char *userfield)
{
- struct ast_cdr *cdr = chan->cdr;
+ struct ast_cdr *cdr = ast_channel_cdr(chan);
for ( ; cdr ; cdr = cdr->next) {
if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED))
@@ -1098,7 +1098,7 @@ int ast_cdr_setuserfield(struct ast_channel *chan, const char *userfield)
int ast_cdr_appenduserfield(struct ast_channel *chan, const char *userfield)
{
- struct ast_cdr *cdr = chan->cdr;
+ struct ast_cdr *cdr = ast_channel_cdr(chan);
for ( ; cdr ; cdr = cdr->next) {
int len = strlen(cdr->userfield);
@@ -1112,7 +1112,7 @@ int ast_cdr_appenduserfield(struct ast_channel *chan, const char *userfield)
int ast_cdr_update(struct ast_channel *c)
{
- struct ast_cdr *cdr = c->cdr;
+ struct ast_cdr *cdr = ast_channel_cdr(c);
for ( ; cdr ; cdr = cdr->next) {
if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
diff --git a/main/cel.c b/main/cel.c
index feb67ed24..fdf1bf0f1 100644
--- a/main/cel.c
+++ b/main/cel.c
@@ -477,7 +477,7 @@ struct ast_channel *ast_cel_fabricate_channel_from_event(const struct ast_event
ast_channel_appl_set(tchan, ast_strdup(record.application_name));
ast_channel_data_set(tchan, ast_strdup(record.application_data));
- tchan->amaflags = record.amaflag;
+ ast_channel_amaflags_set(tchan, record.amaflag);
return tchan;
}
@@ -566,7 +566,7 @@ int ast_cel_report_event(struct ast_channel *chan, enum ast_cel_event_type event
AST_EVENT_IE_CEL_CHANNAME, AST_EVENT_IE_PLTYPE_STR, ast_channel_name(chan),
AST_EVENT_IE_CEL_APPNAME, AST_EVENT_IE_PLTYPE_STR, S_OR(ast_channel_appl(chan), ""),
AST_EVENT_IE_CEL_APPDATA, AST_EVENT_IE_PLTYPE_STR, S_OR(ast_channel_data(chan), ""),
- AST_EVENT_IE_CEL_AMAFLAGS, AST_EVENT_IE_PLTYPE_UINT, chan->amaflags,
+ AST_EVENT_IE_CEL_AMAFLAGS, AST_EVENT_IE_PLTYPE_UINT, ast_channel_amaflags(chan),
AST_EVENT_IE_CEL_ACCTCODE, AST_EVENT_IE_PLTYPE_STR, ast_channel_accountcode(chan),
AST_EVENT_IE_CEL_PEERACCT, AST_EVENT_IE_PLTYPE_STR, ast_channel_peeraccount(chan),
AST_EVENT_IE_CEL_UNIQUEID, AST_EVENT_IE_PLTYPE_STR, ast_channel_uniqueid(chan),
diff --git a/main/channel.c b/main/channel.c
index bd560f50c..a7cca1cad 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -431,7 +431,7 @@ static int kill_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
static int kill_hangup(struct ast_channel *chan)
{
- chan->tech_pvt = NULL;
+ ast_channel_tech_pvt_set(chan, NULL);
return 0;
}
@@ -531,7 +531,7 @@ static int ast_channel_trace_data_update(struct ast_channel *chan, struct ast_ch
/* save the current location and store it in the trace list */
ast_copy_string(trace->context, ast_channel_context(chan), sizeof(trace->context));
ast_copy_string(trace->exten, ast_channel_exten(chan), sizeof(trace->exten));
- trace->priority = chan->priority;
+ trace->priority = ast_channel_priority(chan);
AST_LIST_INSERT_HEAD(&traced->trace, trace, entry);
}
return 0;
@@ -920,6 +920,9 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
int flags;
struct varshead *headp;
char *tech = "", *tech2 = NULL;
+ struct ast_format_cap *nativeformats;
+ struct ast_sched_context *schedctx;
+ struct ast_timer *timer;
/* If shutting down, don't allocate any new channels */
if (shutting_down) {
@@ -940,17 +943,18 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
/* Channel structure allocation failure. */
return NULL;
}
- if (!(tmp->nativeformats = ast_format_cap_alloc())) {
+ if (!(nativeformats = ast_format_cap_alloc())) {
ao2_ref(tmp, -1);
/* format capabilities structure allocation failure */
return NULL;
}
+ ast_channel_nativeformats_set(tmp, nativeformats);
/*
* Init file descriptors to unopened state so
* the destructor can know not to close them.
*/
- tmp->timingfd = -1;
+ ast_channel_timingfd_set(tmp, -1);
for (x = 0; x < ARRAY_LEN(tmp->alertpipe); ++x) {
tmp->alertpipe[x] = -1;
}
@@ -958,13 +962,14 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
tmp->fds[x] = -1;
}
#ifdef HAVE_EPOLL
- tmp->epfd = epoll_create(25);
+ ast_channel_epfd(tmp) = epoll_create(25);
#endif
- if (!(tmp->sched = ast_sched_context_create())) {
+ if (!(schedctx = ast_sched_context_create())) {
ast_log(LOG_WARNING, "Channel allocation failed: Unable to create schedule context\n");
return ast_channel_unref(tmp);
}
+ ast_channel_sched_set(tmp, schedctx);
ast_party_dialed_init(&tmp->dialed);
ast_party_caller_init(&tmp->caller);
@@ -986,11 +991,12 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
}
}
- if ((tmp->timer = ast_timer_open())) {
- if (strcmp(ast_timer_get_name(tmp->timer), "timerfd")) {
+ if ((timer = ast_timer_open())) {
+ ast_channel_timer_set(tmp, timer);
+ if (strcmp(ast_timer_get_name(ast_channel_timer(tmp)), "timerfd")) {
needqueue = 0;
}
- tmp->timingfd = ast_timer_fd(tmp->timer);
+ ast_channel_timingfd_set(tmp, ast_timer_fd(ast_channel_timer(tmp)));
}
if (needqueue) {
@@ -1025,15 +1031,15 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
/* Always watch the alertpipe */
ast_channel_set_fd(tmp, AST_ALERT_FD, tmp->alertpipe[0]);
/* And timing pipe */
- ast_channel_set_fd(tmp, AST_TIMING_FD, tmp->timingfd);
+ ast_channel_set_fd(tmp, AST_TIMING_FD, ast_channel_timingfd(tmp));
/* Initial state */
- tmp->_state = state;
+ ast_channel_state_set(tmp, state);
- tmp->streamid = -1;
+ ast_channel_streamid_set(tmp, -1);
- tmp->fin = global_fin;
- tmp->fout = global_fout;
+ ast_channel_fin_set(tmp, global_fin);
+ ast_channel_fout_set(tmp, global_fout);
if (ast_strlen_zero(ast_config_AST_SYSTEM_NAME)) {
ast_channel_uniqueid_build(tmp, "%li.%d", (long) time(NULL),
@@ -1078,10 +1084,11 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
/* Reminder for the future: under what conditions do we NOT want to track cdrs on channels? */
/* These 4 variables need to be set up for the cdr_init() to work right */
- if (amaflag)
- tmp->amaflags = amaflag;
- else
- tmp->amaflags = ast_default_amaflags;
+ if (amaflag) {
+ ast_channel_amaflags_set(tmp, amaflag);
+ } else {
+ ast_channel_amaflags_set(tmp, ast_default_amaflags);
+ }
if (!ast_strlen_zero(acctcode))
ast_channel_accountcode_set(tmp, acctcode);
@@ -1090,11 +1097,11 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
ast_channel_context_set(tmp, S_OR(context, "default"));
ast_channel_exten_set(tmp, S_OR(exten, "s"));
- tmp->priority = 1;
+ ast_channel_priority_set(tmp, -1);
- tmp->cdr = ast_cdr_alloc();
- ast_cdr_init(tmp->cdr, tmp);
- ast_cdr_start(tmp->cdr);
+ ast_channel_cdr_set(tmp, ast_cdr_alloc());
+ ast_cdr_init(ast_channel_cdr(tmp), tmp);
+ ast_cdr_start(ast_channel_cdr(tmp));
ast_cel_report_event(tmp, AST_CEL_CHANNEL_START, NULL, NULL, NULL);
@@ -1107,7 +1114,7 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
ast_channel_language_set(tmp, defaultlanguage);
- tmp->tech = &null_tech;
+ ast_channel_tech_set(tmp, &null_tech);
ao2_link(channels, tmp);
@@ -1304,8 +1311,8 @@ static int __ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, in
ast_log(LOG_WARNING, "Unable to write to alert pipe on %s (qlen = %d): %s!\n",
ast_channel_name(chan), queued_frames, strerror(errno));
}
- } else if (chan->timingfd > -1) {
- ast_timer_enable_continuous(chan->timer);
+ } else if (ast_channel_timingfd(chan) > -1) {
+ ast_timer_enable_continuous(ast_channel_timer(chan));
} else if (ast_test_flag(chan, AST_FLAG_BLOCKING)) {
pthread_kill(chan->blocker, SIGURG);
}
@@ -1354,7 +1361,7 @@ int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
if (!ast_channel_trylock(chan)) {
chan->_softhangup |= AST_SOFTHANGUP_DEV;
if (cause < 0)
- f.data.uint32 = chan->hangupcause;
+ f.data.uint32 = ast_channel_hangupcause(chan);
manager_event(EVENT_FLAG_CALL, "HangupRequest",
"Channel: %s\r\n"
@@ -1629,7 +1636,7 @@ int ast_safe_sleep_conditional(struct ast_channel *chan, int ms, int (*cond)(voi
AST_LIST_HEAD_INIT_NOLOCK(&deferred_frames);
/* If no other generator is present, start silencegen while waiting */
- if (ast_opt_transmit_silence && !chan->generatordata) {
+ if (ast_opt_transmit_silence && !ast_channel_generatordata(chan)) {
silgen = ast_channel_start_silence_generator(chan);
}
@@ -2201,13 +2208,13 @@ static void ast_channel_destructor(void *obj)
ast_channel_lock(chan);
ast_channel_unlock(chan);
- if (chan->tech_pvt) {
+ if (ast_channel_tech_pvt(chan)) {
ast_log(LOG_WARNING, "Channel '%s' may not have been hung up properly\n", ast_channel_name(chan));
- ast_free(chan->tech_pvt);
+ ast_free(ast_channel_tech_pvt(chan));
}
- if (chan->sched) {
- ast_sched_context_destroy(chan->sched);
+ if (ast_channel_sched(chan)) {
+ ast_sched_context_destroy(ast_channel_sched(chan));
}
if (ast_channel_name(chan)) {
@@ -2223,19 +2230,19 @@ static void ast_channel_destructor(void *obj)
}
/* Stop monitoring */
- if (chan->monitor)
- chan->monitor->stop( chan, 0 );
+ if (ast_channel_monitor(chan))
+ ast_channel_monitor(chan)->stop( chan, 0 );
/* If there is native format music-on-hold state, free it */
- if (chan->music_state)
+ if (ast_channel_music_state(chan))
ast_moh_cleanup(chan);
/* Free translators */
- if (chan->readtrans)
- ast_translator_free_path(chan->readtrans);
- if (chan->writetrans)
- ast_translator_free_path(chan->writetrans);
- if (chan->pbx)
+ if (ast_channel_readtrans(chan))
+ ast_translator_free_path(ast_channel_readtrans(chan));
+ if (ast_channel_writetrans(chan))
+ ast_translator_free_path(ast_channel_writetrans(chan));
+ if (ast_channel_pbx(chan))
ast_log(LOG_WARNING, "PBX may not have been terminated properly on '%s'\n", ast_channel_name(chan));
ast_party_dialed_free(&chan->dialed);
@@ -2248,15 +2255,15 @@ static void ast_channel_destructor(void *obj)
close(fd);
if ((fd = chan->alertpipe[1]) > -1)
close(fd);
- if (chan->timer) {
- ast_timer_close(chan->timer);
+ if (ast_channel_timer(chan)) {
+ ast_timer_close(ast_channel_timer(chan));
}
#ifdef HAVE_EPOLL
for (i = 0; i < AST_MAX_FDS; i++) {
if (chan->epfd_data[i])
free(chan->epfd_data[i]);
}
- close(chan->epfd);
+ close(ast_channel_epfd(chan));
#endif
while ((f = AST_LIST_REMOVE_HEAD(&chan->readq, frame_list)))
ast_frfree(f);
@@ -2272,13 +2279,13 @@ static void ast_channel_destructor(void *obj)
/* Destroy the jitterbuffer */
ast_jb_destroy(chan);
- if (chan->cdr) {
- ast_cdr_discard(chan->cdr);
- chan->cdr = NULL;
+ if (ast_channel_cdr(chan)) {
+ ast_cdr_discard(ast_channel_cdr(chan));
+ ast_channel_cdr_set(chan, NULL);
}
- if (chan->zone) {
- chan->zone = ast_tone_zone_unref(chan->zone);
+ if (ast_channel_zone(chan)) {
+ ast_channel_zone_set(chan, ast_tone_zone_unref(ast_channel_zone(chan)));
}
ast_string_field_free_memory(chan);
@@ -2294,7 +2301,7 @@ static void ast_channel_destructor(void *obj)
ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, device_name);
}
- chan->nativeformats = ast_format_cap_destroy(chan->nativeformats);
+ ast_channel_nativeformats_set(chan, ast_format_cap_destroy(ast_channel_nativeformats(chan)));
}
/*! \brief Free a dummy channel structure */
@@ -2316,9 +2323,9 @@ static void ast_dummy_channel_destructor(void *obj)
while ((vardata = AST_LIST_REMOVE_HEAD(headp, entries)))
ast_var_delete(vardata);
- if (chan->cdr) {
- ast_cdr_discard(chan->cdr);
- chan->cdr = NULL;
+ if (ast_channel_cdr(chan)) {
+ ast_cdr_discard(ast_channel_cdr(chan));
+ ast_channel_cdr_set(chan, NULL);
}
ast_string_field_free_memory(chan);
@@ -2399,7 +2406,7 @@ void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
struct ast_epoll_data *aed = NULL;
if (chan->fds[which] > -1) {
- epoll_ctl(chan->epfd, EPOLL_CTL_DEL, chan->fds[which], &ev);
+ epoll_ctl(ast_channel_epfd(chan), EPOLL_CTL_DEL, chan->fds[which], &ev);
aed = chan->epfd_data[which];
}
@@ -2414,7 +2421,7 @@ void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
ev.events = EPOLLIN | EPOLLPRI | EPOLLERR | EPOLLHUP;
ev.data.ptr = aed;
- epoll_ctl(chan->epfd, EPOLL_CTL_ADD, fd, &ev);
+ epoll_ctl(ast_channel_epfd(chan), EPOLL_CTL_ADD, fd, &ev);
} else if (aed) {
/* We don't have to keep around this epoll data structure now */
free(aed);
@@ -2432,7 +2439,7 @@ void ast_poll_channel_add(struct ast_channel *chan0, struct ast_channel *chan1)
struct epoll_event ev;
int i = 0;
- if (chan0->epfd == -1)
+ if (ast_channel_epfd(chan0) == -1)
return;
/* Iterate through the file descriptors on chan1, adding them to chan0 */
@@ -2441,7 +2448,7 @@ void ast_poll_channel_add(struct ast_channel *chan0, struct ast_channel *chan1)
continue;
ev.events = EPOLLIN | EPOLLPRI | EPOLLERR | EPOLLHUP;
ev.data.ptr = chan1->epfd_data[i];
- epoll_ctl(chan0->epfd, EPOLL_CTL_ADD, chan1->fds[i], &ev);
+ epoll_ctl(ast_channel_epfd(chan0), EPOLL_CTL_ADD, chan1->fds[i], &ev);
}
#endif
@@ -2455,13 +2462,13 @@ void ast_poll_channel_del(struct ast_channel *chan0, struct ast_channel *chan1)
struct epoll_event ev;
int i = 0;
- if (chan0->epfd == -1)
+ if (ast_channel_epfd(chan0) == -1)
return;
for (i = 0; i < AST_MAX_FDS; i++) {
if (chan1->fds[i] == -1)
continue;
- epoll_ctl(chan0->epfd, EPOLL_CTL_DEL, chan1->fds[i], &ev);
+ epoll_ctl(ast_channel_epfd(chan0), EPOLL_CTL_DEL, chan1->fds[i], &ev);
}
#endif
@@ -2527,18 +2534,18 @@ int ast_softhangup(struct ast_channel *chan, int cause)
static void free_translation(struct ast_channel *clonechan)
{
- if (clonechan->writetrans)
- ast_translator_free_path(clonechan->writetrans);
- if (clonechan->readtrans)
- ast_translator_free_path(clonechan->readtrans);
- clonechan->writetrans = NULL;
- clonechan->readtrans = NULL;
- if (ast_format_cap_is_empty(clonechan->nativeformats)) {
+ if (ast_channel_writetrans(clonechan))
+ ast_translator_free_path(ast_channel_writetrans(clonechan));
+ if (ast_channel_readtrans(clonechan))
+ ast_translator_free_path(ast_channel_readtrans(clonechan));
+ ast_channel_writetrans_set(clonechan, NULL);
+ ast_channel_readtrans_set(clonechan, NULL);
+ if (ast_format_cap_is_empty(ast_channel_nativeformats(clonechan))) {
ast_format_clear(&clonechan->rawwriteformat);
ast_format_clear(&clonechan->rawreadformat);
} else {
struct ast_format tmpfmt;
- ast_best_codec(clonechan->nativeformats, &tmpfmt);
+ ast_best_codec(ast_channel_nativeformats(clonechan), &tmpfmt);
ast_format_copy(&clonechan->rawwriteformat, &tmpfmt);
ast_format_copy(&clonechan->rawreadformat, &tmpfmt);
}
@@ -2564,9 +2571,9 @@ void ast_set_hangupsource(struct ast_channel *chan, const char *source, int forc
static void destroy_hooks(struct ast_channel *chan)
{
- if (chan->audiohooks) {
- ast_audiohook_detach_list(chan->audiohooks);
- chan->audiohooks = NULL;
+ if (ast_channel_audiohooks(chan)) {
+ ast_audiohook_detach_list(ast_channel_audiohooks(chan));
+ ast_channel_audiohooks_set(chan, NULL);
}
ast_framehook_list_destroy(chan);
@@ -2590,7 +2597,7 @@ int ast_hangup(struct ast_channel *chan)
* prevent __ast_channel_masquerade() from setting up a
* masquerade with a dead channel.
*/
- while (chan->masq) {
+ while (ast_channel_masq(chan)) {
ast_channel_unlock(chan);
if (ast_do_masquerade(chan)) {
ast_log(LOG_WARNING, "Failed to perform masquerade\n");
@@ -2602,7 +2609,7 @@ int ast_hangup(struct ast_channel *chan)
ast_channel_lock(chan);
}
- if (chan->masqr) {
+ if (ast_channel_masqr(chan)) {
/*
* This channel is one which will be masqueraded into something.
* Mark it as a zombie already so ast_do_masquerade() will know
@@ -2626,29 +2633,29 @@ int ast_hangup(struct ast_channel *chan)
free_translation(chan);
/* Close audio stream */
- if (chan->stream) {
- ast_closestream(chan->stream);
- chan->stream = NULL;
+ if (ast_channel_stream(chan)) {
+ ast_closestream(ast_channel_stream(chan));
+ ast_channel_stream_set(chan, NULL);
}
/* Close video stream */
- if (chan->vstream) {
- ast_closestream(chan->vstream);
- chan->vstream = NULL;
+ if (ast_channel_vstream(chan)) {
+ ast_closestream(ast_channel_vstream(chan));
+ ast_channel_vstream_set(chan, NULL);
}
- if (chan->sched) {
- ast_sched_context_destroy(chan->sched);
- chan->sched = NULL;
+ if (ast_channel_sched(chan)) {
+ ast_sched_context_destroy(ast_channel_sched(chan));
+ ast_channel_sched_set(chan, NULL);
}
- if (chan->generatordata) { /* Clear any tone stuff remaining */
- if (chan->generator && chan->generator->release) {
- chan->generator->release(chan, chan->generatordata);
+ if (ast_channel_generatordata(chan)) { /* Clear any tone stuff remaining */
+ if (ast_channel_generator(chan) && ast_channel_generator(chan)->release) {
+ ast_channel_generator(chan)->release(chan, ast_channel_generatordata(chan));
}
}
- chan->generatordata = NULL;
- chan->generator = NULL;
+ ast_channel_generatordata_set(chan, NULL);
+ ast_channel_generator_set(chan, NULL);
- snprintf(extra_str, sizeof(extra_str), "%d,%s,%s", chan->hangupcause, ast_channel_hangupsource(chan), S_OR(pbx_builtin_getvar_helper(chan, "DIALSTATUS"), ""));
+ snprintf(extra_str, sizeof(extra_str), "%d,%s,%s", ast_channel_hangupcause(chan), ast_channel_hangupsource(chan), S_OR(pbx_builtin_getvar_helper(chan, "DIALSTATUS"), ""));
ast_cel_report_event(chan, AST_CEL_HANGUP, NULL, extra_str, NULL);
if (ast_test_flag(chan, AST_FLAG_BLOCKING)) {
@@ -2660,8 +2667,8 @@ int ast_hangup(struct ast_channel *chan)
if (!was_zombie) {
ast_debug(1, "Hanging up channel '%s'\n", ast_channel_name(chan));
- if (chan->tech->hangup) {
- chan->tech->hangup(chan);
+ if (ast_channel_tech(chan)->hangup) {
+ ast_channel_tech(chan)->hangup(chan);
}
} else {
ast_debug(1, "Hanging up zombie '%s'\n", ast_channel_name(chan));
@@ -2685,17 +2692,17 @@ int ast_hangup(struct ast_channel *chan)
S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, "<unknown>"),
S_COR(chan->connected.id.number.valid, chan->connected.id.number.str, "<unknown>"),
S_COR(chan->connected.id.name.valid, chan->connected.id.name.str, "<unknown>"),
- chan->hangupcause,
- ast_cause2str(chan->hangupcause)
+ ast_channel_hangupcause(chan),
+ ast_cause2str(ast_channel_hangupcause(chan))
);
- if (chan->cdr && !ast_test_flag(chan->cdr, AST_CDR_FLAG_BRIDGED) &&
- !ast_test_flag(chan->cdr, AST_CDR_FLAG_POST_DISABLED) &&
- (chan->cdr->disposition != AST_CDR_NULL || ast_test_flag(chan->cdr, AST_CDR_FLAG_DIALED))) {
+ if (ast_channel_cdr(chan) && !ast_test_flag(ast_channel_cdr(chan), AST_CDR_FLAG_BRIDGED) &&
+ !ast_test_flag(ast_channel_cdr(chan), AST_CDR_FLAG_POST_DISABLED) &&
+ (ast_channel_cdr(chan)->disposition != AST_CDR_NULL || ast_test_flag(ast_channel_cdr(chan), AST_CDR_FLAG_DIALED))) {
ast_channel_lock(chan);
- ast_cdr_end(chan->cdr);
- ast_cdr_detach(chan->cdr);
- chan->cdr = NULL;
+ ast_cdr_end(ast_channel_cdr(chan));
+ ast_cdr_detach(ast_channel_cdr(chan));
+ ast_channel_cdr_set(chan, NULL);
ast_channel_unlock(chan);
}
@@ -2724,16 +2731,16 @@ int ast_raw_answer(struct ast_channel *chan, int cdr_answer)
ast_channel_unlock(chan);
- switch (chan->_state) {
+ switch (ast_channel_state(chan)) {
case AST_STATE_RINGING:
case AST_STATE_RING:
ast_channel_lock(chan);
- if (chan->tech->answer) {
- res = chan->tech->answer(chan);
+ if (ast_channel_tech(chan)->answer) {
+ res = ast_channel_tech(chan)->answer(chan);
}
ast_setstate(chan, AST_STATE_UP);
if (cdr_answer) {
- ast_cdr_answer(chan->cdr);
+ ast_cdr_answer(ast_channel_cdr(chan));
}
ast_cel_report_event(chan, AST_CEL_ANSWER, NULL, NULL, NULL);
ast_channel_unlock(chan);
@@ -2744,7 +2751,7 @@ int ast_raw_answer(struct ast_channel *chan, int cdr_answer)
* is essentially a no-op, so it is safe.
*/
if (cdr_answer) {
- ast_cdr_answer(chan->cdr);
+ ast_cdr_answer(ast_channel_cdr(chan));
}
break;
default:
@@ -2761,7 +2768,7 @@ int __ast_answer(struct ast_channel *chan, unsigned int delay, int cdr_answer)
int res = 0;
enum ast_channel_state old_state;
- old_state = chan->_state;
+ old_state = ast_channel_state(chan);
if ((res = ast_raw_answer(chan, cdr_answer))) {
return res;
}
@@ -2865,11 +2872,11 @@ int ast_answer(struct ast_channel *chan)
void ast_deactivate_generator(struct ast_channel *chan)
{
ast_channel_lock(chan);
- if (chan->generatordata) {
- if (chan->generator && chan->generator->release)
- chan->generator->release(chan, chan->generatordata);
- chan->generatordata = NULL;
- chan->generator = NULL;
+ if (ast_channel_generatordata(chan)) {
+ if (ast_channel_generator(chan) && ast_channel_generator(chan)->release)
+ ast_channel_generator(chan)->release(chan, ast_channel_generatordata(chan));
+ ast_channel_generatordata_set(chan, NULL);
+ ast_channel_generator_set(chan, NULL);
ast_channel_set_fd(chan, AST_GENERATOR_FD, -1);
ast_clear_flag(chan, AST_FLAG_WRITE_INT);
ast_settimeout(chan, 0, NULL, NULL);
@@ -2880,8 +2887,8 @@ void ast_deactivate_generator(struct ast_channel *chan)
static void generator_write_format_change(struct ast_channel *chan)
{
ast_channel_lock(chan);
- if (chan->generator && chan->generator->write_format_change) {
- chan->generator->write_format_change(chan, chan->generatordata);
+ if (ast_channel_generator(chan) && ast_channel_generator(chan)->write_format_change) {
+ ast_channel_generator(chan)->write_format_change(chan, ast_channel_generatordata(chan));
}
ast_channel_unlock(chan);
}
@@ -2895,10 +2902,10 @@ static int generator_force(const void *data)
struct ast_channel *chan = (struct ast_channel *)data;
ast_channel_lock(chan);
- tmp = chan->generatordata;
- chan->generatordata = NULL;
- if (chan->generator)
- generate = chan->generator->generate;
+ tmp = ast_channel_generatordata(chan);
+ ast_channel_generatordata_set(chan, NULL);
+ if (ast_channel_generator(chan))
+ generate = ast_channel_generator(chan)->generate;
ast_channel_unlock(chan);
if (!tmp || !generate)
@@ -2906,7 +2913,7 @@ static int generator_force(const void *data)
res = generate(chan, tmp, 0, ast_format_rate(&chan->writeformat) / 50);
- chan->generatordata = tmp;
+ ast_channel_generatordata_set(chan, tmp);
if (res) {
ast_debug(1, "Auto-deactivating generator\n");
@@ -2919,19 +2926,21 @@ static int generator_force(const void *data)
int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
{
int res = 0;
+ void *generatordata;
ast_channel_lock(chan);
- if (chan->generatordata) {
- if (chan->generator && chan->generator->release)
- chan->generator->release(chan, chan->generatordata);
- chan->generatordata = NULL;
+ if (ast_channel_generatordata(chan)) {
+ if (ast_channel_generator(chan) && ast_channel_generator(chan)->release)
+ ast_channel_generator(chan)->release(chan, ast_channel_generatordata(chan));
+ ast_channel_generatordata_set(chan, NULL);
}
- if (gen->alloc && !(chan->generatordata = gen->alloc(chan, params))) {
+ if (gen->alloc && !(generatordata = gen->alloc(chan, params))) {
res = -1;
}
if (!res) {
ast_settimeout(chan, 50, generator_force, chan);
- chan->generator = gen;
+ ast_channel_generatordata_set(chan, generatordata);
+ ast_channel_generator_set(chan, gen);
}
ast_channel_unlock(chan);
@@ -2983,7 +2992,7 @@ struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds,
/* Perform any pending masquerades */
for (x = 0; x < n; x++) {
- if (c[x]->masq && ast_do_masquerade(c[x])) {
+ if (ast_channel_masq(c[x]) && ast_do_masquerade(c[x])) {
ast_log(LOG_WARNING, "Masquerade failed\n");
*ms = -1;
return NULL;
@@ -3088,7 +3097,7 @@ struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds,
ast_set_flag(winner, AST_FLAG_EXCEPTION);
else
ast_clear_flag(winner, AST_FLAG_EXCEPTION);
- winner->fdno = fdmap[x].fdno;
+ ast_channel_fdno_set(winner, fdmap[x].fdno);
} else { /* this is an fd */
if (outfd)
*outfd = pfds[x].fd;
@@ -3117,7 +3126,7 @@ static struct ast_channel *ast_waitfor_nandfds_simple(struct ast_channel *chan,
/* See if this channel needs to be masqueraded */
- if (chan->masq && ast_do_masquerade(chan)) {
+ if (ast_channel_masq(chan) && ast_do_masquerade(chan)) {
ast_log(LOG_WARNING, "Failed to perform masquerade on %s\n", ast_channel_name(chan));
*ms = -1;
return NULL;
@@ -3146,7 +3155,7 @@ static struct ast_channel *ast_waitfor_nandfds_simple(struct ast_channel *chan,
start = ast_tvnow();
/* We don't have to add any file descriptors... they are already added, we just have to wait! */
- res = epoll_wait(chan->epfd, ev, 1, rms);
+ res = epoll_wait(ast_channel_epfd(chan), ev, 1, rms);
/* Stop blocking */
ast_clear_flag(chan, AST_FLAG_BLOCKING);
@@ -3174,7 +3183,7 @@ static struct ast_channel *ast_waitfor_nandfds_simple(struct ast_channel *chan,
/* See what events are pending */
aed = ev[0].data.ptr;
- chan->fdno = aed->which;
+ ast_channel_fdno_set(chan, aed->which);
if (ev[0].events & EPOLLPRI)
ast_set_flag(chan, AST_FLAG_EXCEPTION);
else
@@ -3199,7 +3208,7 @@ static struct ast_channel *ast_waitfor_nandfds_complex(struct ast_channel **c, i
struct ast_channel *winner = NULL;
for (i = 0; i < n; i++) {
- if (c[i]->masq && ast_do_masquerade(c[i])) {
+ if (ast_channel_masq(c[i]) && ast_do_masquerade(c[i])) {
ast_log(LOG_WARNING, "Masquerade failed\n");
*ms = -1;
return NULL;
@@ -3231,7 +3240,7 @@ static struct ast_channel *ast_waitfor_nandfds_complex(struct ast_channel **c, i
if (*ms > 0)
start = ast_tvnow();
- res = epoll_wait(c[0]->epfd, ev, 25, rms);
+ res = epoll_wait(ast_channel_epfd(c[0]), ev, 25, rms);
for (i = 0; i < n; i++)
ast_clear_flag(c[i], AST_FLAG_BLOCKING);
@@ -3269,7 +3278,7 @@ static struct ast_channel *ast_waitfor_nandfds_complex(struct ast_channel **c, i
ast_set_flag(winner, AST_FLAG_EXCEPTION);
else
ast_clear_flag(winner, AST_FLAG_EXCEPTION);
- winner->fdno = aed->which;
+ ast_channel_fdno_set(winner, aed->which);
}
if (*ms > 0) {
@@ -3291,7 +3300,7 @@ struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds,
*exception = 0;
/* If no epoll file descriptor is available resort to classic nandfds */
- if (!n || nfds || c[0]->epfd == -1)
+ if (!n || nfds || ast_channel_epfd(c[0]) == -1)
return ast_waitfor_nandfds_classic(c, n, fds, nfds, exception, outfd, ms);
else if (!nfds && n == 1)
return ast_waitfor_nandfds_simple(c[0], ms);
@@ -3328,7 +3337,7 @@ int ast_settimeout(struct ast_channel *c, unsigned int rate, int (*func)(const v
ast_channel_lock(c);
- if (c->timingfd == -1) {
+ if (ast_channel_timingfd(c) == -1) {
ast_channel_unlock(c);
return -1;
}
@@ -3338,16 +3347,16 @@ int ast_settimeout(struct ast_channel *c, unsigned int rate, int (*func)(const v
data = NULL;
}
- if (rate && rate > (max_rate = ast_timer_get_max_rate(c->timer))) {
+ if (rate && rate > (max_rate = ast_timer_get_max_rate(ast_channel_timer(c)))) {
real_rate = max_rate;
}
ast_debug(1, "Scheduling timer at (%u requested / %u actual) timer ticks per second\n", rate, real_rate);
- res = ast_timer_set_rate(c->timer, real_rate);
+ res = ast_timer_set_rate(ast_channel_timer(c), real_rate);
c->timingfunc = func;
- c->timingdata = data;
+ ast_channel_timingdata_set(c, data);
ast_channel_unlock(c);
@@ -3453,9 +3462,9 @@ static void send_dtmf_event(struct ast_channel *chan, const char *direction, con
static void ast_read_generator_actions(struct ast_channel *chan, struct ast_frame *f)
{
- if (chan->generator && chan->generator->generate && chan->generatordata && !ast_internal_timing_enabled(chan)) {
- void *tmp = chan->generatordata;
- int (*generate)(struct ast_channel *chan, void *tmp, int datalen, int samples) = chan->generator->generate;
+ if (ast_channel_generator(chan) && ast_channel_generator(chan)->generate && ast_channel_generatordata(chan) && !ast_internal_timing_enabled(chan)) {
+ void *tmp = ast_channel_generatordata(chan);
+ int (*generate)(struct ast_channel *chan, void *tmp, int datalen, int samples) = ast_channel_generator(chan)->generate;
int res;
int samples;
@@ -3464,7 +3473,7 @@ static void ast_read_generator_actions(struct ast_channel *chan, struct ast_fram
ast_settimeout(chan, 0, NULL, NULL);
}
- chan->generatordata = NULL; /* reset, to let writes go through */
+ ast_channel_generatordata_set(chan, NULL); /* reset, to let writes go through */
if (ast_format_cmp(&f->subclass.format, &chan->writeformat) == AST_FORMAT_CMP_NOT_EQUAL) {
float factor;
@@ -3485,14 +3494,14 @@ static void ast_read_generator_actions(struct ast_channel *chan, struct ast_fram
ast_channel_unlock(chan);
res = generate(chan, tmp, f->datalen, samples);
ast_channel_lock(chan);
- chan->generatordata = tmp;
+ ast_channel_generatordata_set(chan, tmp);
if (res) {
ast_debug(1, "Auto-deactivating generator\n");
ast_deactivate_generator(chan);
}
} else if (f->frametype == AST_FRAME_CNG) {
- if (chan->generator && !chan->timingfunc && (chan->timingfd > -1)) {
+ if (ast_channel_generator(chan) && !chan->timingfunc && (ast_channel_timingfd(chan) > -1)) {
ast_debug(1, "Generator got CNG, switching to timed mode\n");
ast_settimeout(chan, 50, generator_force, chan);
}
@@ -3568,7 +3577,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
* point at the end (there are only two exceptions to this).
*/
- if (chan->masq) {
+ if (ast_channel_masq(chan)) {
if (ast_do_masquerade(chan))
ast_log(LOG_WARNING, "Failed to perform masquerade\n");
else
@@ -3581,7 +3590,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
/* Stop if we're a zombie or need a soft hangup */
if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) {
- if (chan->generator)
+ if (ast_channel_generator(chan))
ast_deactivate_generator(chan);
/*
@@ -3612,7 +3621,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
*
* One of the potential problems is blocking on a dead channel.
*/
- if (chan->fdno == -1) {
+ if (ast_channel_fdno(chan) == -1) {
ast_log(LOG_ERROR,
"ast_read() on chan '%s' called with no recorded file descriptor.\n",
ast_channel_name(chan));
@@ -3620,7 +3629,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
#endif
}
- prestate = chan->_state;
+ prestate = ast_channel_state(chan);
/* Read and ignore anything on the alertpipe, but read only
one sizeof(blah) per frame that we send from it */
@@ -3642,27 +3651,27 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
}
}
- if (chan->timingfd > -1 && chan->fdno == AST_TIMING_FD) {
+ if (ast_channel_timingfd(chan) > -1 && ast_channel_fdno(chan) == AST_TIMING_FD) {
enum ast_timer_event res;
ast_clear_flag(chan, AST_FLAG_EXCEPTION);
- res = ast_timer_get_event(chan->timer);
+ res = ast_timer_get_event(ast_channel_timer(chan));
switch (res) {
case AST_TIMING_EVENT_EXPIRED:
- ast_timer_ack(chan->timer, 1);
+ ast_timer_ack(ast_channel_timer(chan), 1);
if (chan->timingfunc) {
/* save a copy of func/data before unlocking the channel */
int (*func)(const void *) = chan->timingfunc;
- void *data = chan->timingdata;
- chan->fdno = -1;
+ void *data = ast_channel_timingdata(chan);
+ ast_channel_fdno_set(chan, -1);
ast_channel_unlock(chan);
func(data);
} else {
- ast_timer_set_rate(chan->timer, 0);
- chan->fdno = -1;
+ ast_timer_set_rate(ast_channel_timer(chan), 0);
+ ast_channel_fdno_set(chan, -1);
ast_channel_unlock(chan);
}
@@ -3672,23 +3681,23 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
case AST_TIMING_EVENT_CONTINUOUS:
if (AST_LIST_EMPTY(&chan->readq) ||
!AST_LIST_NEXT(AST_LIST_FIRST(&chan->readq), frame_list)) {
- ast_timer_disable_continuous(chan->timer);
+ ast_timer_disable_continuous(ast_channel_timer(chan));
}
break;
}
- } else if (chan->fds[AST_GENERATOR_FD] > -1 && chan->fdno == AST_GENERATOR_FD) {
+ } else if (chan->fds[AST_GENERATOR_FD] > -1 && ast_channel_fdno(chan) == AST_GENERATOR_FD) {
/* if the AST_GENERATOR_FD is set, call the generator with args
* set to -1 so it can do whatever it needs to.
*/
- void *tmp = chan->generatordata;
- chan->generatordata = NULL; /* reset to let ast_write get through */
- chan->generator->generate(chan, tmp, -1, -1);
- chan->generatordata = tmp;
+ void *tmp = ast_channel_generatordata(chan);
+ ast_channel_generatordata_set(chan, NULL); /* reset to let ast_write get through */
+ ast_channel_generator(chan)->generate(chan, tmp, -1, -1);
+ ast_channel_generatordata_set(chan, tmp);
f = &ast_null_frame;
- chan->fdno = -1;
+ ast_channel_fdno_set(chan, -1);
goto done;
- } else if (chan->fds[AST_JITTERBUFFER_FD] > -1 && chan->fdno == AST_JITTERBUFFER_FD) {
+ } else if (chan->fds[AST_JITTERBUFFER_FD] > -1 && ast_channel_fdno(chan) == AST_JITTERBUFFER_FD) {
ast_clear_flag(chan, AST_FLAG_EXCEPTION);
}
@@ -3742,29 +3751,29 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
} else {
chan->blocker = pthread_self();
if (ast_test_flag(chan, AST_FLAG_EXCEPTION)) {
- if (chan->tech->exception)
- f = chan->tech->exception(chan);
+ if (ast_channel_tech(chan)->exception)
+ f = ast_channel_tech(chan)->exception(chan);
else {
ast_log(LOG_WARNING, "Exception flag set on '%s', but no exception handler\n", ast_channel_name(chan));
f = &ast_null_frame;
}
/* Clear the exception flag */
ast_clear_flag(chan, AST_FLAG_EXCEPTION);
- } else if (chan->tech && chan->tech->read)
- f = chan->tech->read(chan);
+ } else if (ast_channel_tech(chan) && ast_channel_tech(chan)->read)
+ f = ast_channel_tech(chan)->read(chan);
else
ast_log(LOG_WARNING, "No read routine on channel %s\n", ast_channel_name(chan));
}
/* Perform the framehook read event here. After the frame enters the framehook list
* there is no telling what will happen, <insert mad scientist laugh here>!!! */
- f = ast_framehook_list_read_event(chan->framehooks, f);
+ f = ast_framehook_list_read_event(ast_channel_framehooks(chan), f);
/*
* Reset the recorded file descriptor that triggered this read so that we can
* easily detect when ast_read() is called without properly using ast_waitfor().
*/
- chan->fdno = -1;
+ ast_channel_fdno_set(chan, -1);
if (f) {
struct ast_frame *readq_tail = AST_LIST_LAST(&chan->readq);
@@ -3839,23 +3848,23 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
/* There was no begin, turn this into a begin and send the end later */
f->frametype = AST_FRAME_DTMF_BEGIN;
ast_set_flag(chan, AST_FLAG_EMULATE_DTMF);
- chan->emulate_dtmf_digit = f->subclass.integer;
+ ast_channel_emulate_dtmf_digit_set(chan, f->subclass.integer);
chan->dtmf_tv = ast_tvnow();
if (f->len) {
if (f->len > AST_MIN_DTMF_DURATION)
- chan->emulate_dtmf_duration = f->len;
+ ast_channel_emulate_dtmf_duration_set(chan, f->len);
else
- chan->emulate_dtmf_duration = AST_MIN_DTMF_DURATION;
+ ast_channel_emulate_dtmf_duration_set(chan, AST_MIN_DTMF_DURATION);
} else
- chan->emulate_dtmf_duration = AST_DEFAULT_EMULATE_DTMF_DURATION;
- ast_log(LOG_DTMF, "DTMF begin emulation of '%c' with duration %u queued on %s\n", f->subclass.integer, chan->emulate_dtmf_duration, ast_channel_name(chan));
+ ast_channel_emulate_dtmf_duration_set(chan, AST_DEFAULT_EMULATE_DTMF_DURATION);
+ ast_log(LOG_DTMF, "DTMF begin emulation of '%c' with duration %u queued on %s\n", f->subclass.integer, ast_channel_emulate_dtmf_duration(chan), ast_channel_name(chan));
}
- if (chan->audiohooks) {
+ if (ast_channel_audiohooks(chan)) {
struct ast_frame *old_frame = f;
/*!
* \todo XXX It is possible to write a digit to the audiohook twice
* if the digit was originally read while the channel was in autoservice. */
- f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f);
+ f = ast_audiohook_write_list(chan, ast_channel_audiohooks(chan), AST_AUDIOHOOK_DIRECTION_READ, f);
if (old_frame != f)
ast_frfree(old_frame);
}
@@ -3886,8 +3895,8 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
if (f->len < AST_MIN_DTMF_DURATION && !ast_test_flag(chan, AST_FLAG_END_DTMF_ONLY)) {
ast_log(LOG_DTMF, "DTMF end '%c' has duration %ld but want minimum %d, emulating on %s\n", f->subclass.integer, f->len, AST_MIN_DTMF_DURATION, ast_channel_name(chan));
ast_set_flag(chan, AST_FLAG_EMULATE_DTMF);
- chan->emulate_dtmf_digit = f->subclass.integer;
- chan->emulate_dtmf_duration = AST_MIN_DTMF_DURATION - f->len;
+ ast_channel_emulate_dtmf_digit_set(chan, f->subclass.integer);
+ ast_channel_emulate_dtmf_duration_set(chan, AST_MIN_DTMF_DURATION - f->len);
ast_frfree(f);
f = &ast_null_frame;
} else {
@@ -3897,9 +3906,9 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
}
chan->dtmf_tv = now;
}
- if (chan->audiohooks) {
+ if (ast_channel_audiohooks(chan)) {
struct ast_frame *old_frame = f;
- f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f);
+ f = ast_audiohook_write_list(chan, ast_channel_audiohooks(chan), AST_AUDIOHOOK_DIRECTION_READ, f);
if (old_frame != f)
ast_frfree(old_frame);
}
@@ -3927,23 +3936,23 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
* between DTMF digits. */
if (ast_test_flag(chan, AST_FLAG_EMULATE_DTMF)) {
struct timeval now = ast_tvnow();
- if (!chan->emulate_dtmf_duration) {
+ if (!ast_channel_emulate_dtmf_duration(chan)) {
ast_clear_flag(chan, AST_FLAG_EMULATE_DTMF);
- chan->emulate_dtmf_digit = 0;
- } else if (ast_tvdiff_ms(now, chan->dtmf_tv) >= chan->emulate_dtmf_duration) {
- chan->emulate_dtmf_duration = 0;
+ ast_channel_emulate_dtmf_digit_set(chan, 0);
+ } else if (ast_tvdiff_ms(now, chan->dtmf_tv) >= ast_channel_emulate_dtmf_duration(chan)) {
+ ast_channel_emulate_dtmf_duration_set(chan, 0);
ast_frfree(f);
f = &chan->dtmff;
f->frametype = AST_FRAME_DTMF_END;
- f->subclass.integer = chan->emulate_dtmf_digit;
+ f->subclass.integer = ast_channel_emulate_dtmf_digit(chan);
f->len = ast_tvdiff_ms(now, chan->dtmf_tv);
chan->dtmf_tv = now;
ast_clear_flag(chan, AST_FLAG_EMULATE_DTMF);
- chan->emulate_dtmf_digit = 0;
+ ast_channel_emulate_dtmf_digit_set(chan, 0);
ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass.integer, ast_channel_name(chan));
- if (chan->audiohooks) {
+ if (ast_channel_audiohooks(chan)) {
struct ast_frame *old_frame = f;
- f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f);
+ f = ast_audiohook_write_list(chan, ast_channel_audiohooks(chan), AST_AUDIOHOOK_DIRECTION_READ, f);
if (old_frame != f) {
ast_frfree(old_frame);
}
@@ -3956,9 +3965,9 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
* is reached , because we want to make sure we pass at least one
* voice frame through before starting the next digit, to ensure a gap
* between DTMF digits. */
- if (ast_test_flag(chan, AST_FLAG_EMULATE_DTMF) && !chan->emulate_dtmf_duration) {
+ if (ast_test_flag(chan, AST_FLAG_EMULATE_DTMF) && !ast_channel_emulate_dtmf_duration(chan)) {
ast_clear_flag(chan, AST_FLAG_EMULATE_DTMF);
- chan->emulate_dtmf_digit = 0;
+ ast_channel_emulate_dtmf_digit_set(chan, 0);
}
if (dropaudio || ast_test_flag(chan, AST_FLAG_IN_DTMF)) {
@@ -3970,17 +3979,17 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
if (ast_test_flag(chan, AST_FLAG_EMULATE_DTMF) && !ast_test_flag(chan, AST_FLAG_IN_DTMF)) {
struct timeval now = ast_tvnow();
- if (ast_tvdiff_ms(now, chan->dtmf_tv) >= chan->emulate_dtmf_duration) {
- chan->emulate_dtmf_duration = 0;
+ if (ast_tvdiff_ms(now, chan->dtmf_tv) >= ast_channel_emulate_dtmf_duration(chan)) {
+ ast_channel_emulate_dtmf_duration_set(chan, 0);
ast_frfree(f);
f = &chan->dtmff;
f->frametype = AST_FRAME_DTMF_END;
- f->subclass.integer = chan->emulate_dtmf_digit;
+ f->subclass.integer = ast_channel_emulate_dtmf_digit(chan);
f->len = ast_tvdiff_ms(now, chan->dtmf_tv);
chan->dtmf_tv = now;
- if (chan->audiohooks) {
+ if (ast_channel_audiohooks(chan)) {
struct ast_frame *old_frame = f;
- f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f);
+ f = ast_audiohook_write_list(chan, ast_channel_audiohooks(chan), AST_AUDIOHOOK_DIRECTION_READ, f);
if (old_frame != f)
ast_frfree(old_frame);
}
@@ -3990,48 +3999,50 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
ast_frfree(f);
f = &ast_null_frame;
}
- } else if ((f->frametype == AST_FRAME_VOICE) && !ast_format_cap_iscompatible(chan->nativeformats, &f->subclass.format)) {
+ } else if ((f->frametype == AST_FRAME_VOICE) && !ast_format_cap_iscompatible(ast_channel_nativeformats(chan), &f->subclass.format)) {
/* This frame is not one of the current native formats -- drop it on the floor */
char to[200];
ast_log(LOG_NOTICE, "Dropping incompatible voice frame on %s of format %s since our native format has changed to %s\n",
- ast_channel_name(chan), ast_getformatname(&f->subclass.format), ast_getformatname_multiple(to, sizeof(to), chan->nativeformats));
+ ast_channel_name(chan), ast_getformatname(&f->subclass.format), ast_getformatname_multiple(to, sizeof(to), ast_channel_nativeformats(chan)));
ast_frfree(f);
f = &ast_null_frame;
} else if ((f->frametype == AST_FRAME_VOICE)) {
/* Send frame to audiohooks if present */
- if (chan->audiohooks) {
+ if (ast_channel_audiohooks(chan)) {
struct ast_frame *old_frame = f;
- f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f);
+ f = ast_audiohook_write_list(chan, ast_channel_audiohooks(chan), AST_AUDIOHOOK_DIRECTION_READ, f);
if (old_frame != f)
ast_frfree(old_frame);
}
- if (chan->monitor && chan->monitor->read_stream ) {
+ if (ast_channel_monitor(chan) && ast_channel_monitor(chan)->read_stream ) {
/* XXX what does this do ? */
#ifndef MONITOR_CONSTANT_DELAY
- int jump = chan->outsmpl - chan->insmpl - 4 * f->samples;
+ int jump = ast_channel_outsmpl(chan) - ast_channel_insmpl(chan) - 4 * f->samples;
if (jump >= 0) {
- jump = calc_monitor_jump((chan->outsmpl - chan->insmpl), ast_format_rate(&f->subclass.format), ast_format_rate(&chan->monitor->read_stream->fmt->format));
- if (ast_seekstream(chan->monitor->read_stream, jump, SEEK_FORCECUR) == -1)
+ jump = calc_monitor_jump((ast_channel_outsmpl(chan) - ast_channel_insmpl(chan)), ast_format_rate(&f->subclass.format), ast_format_rate(&ast_channel_monitor(chan)->read_stream->fmt->format));
+ if (ast_seekstream(ast_channel_monitor(chan)->read_stream, jump, SEEK_FORCECUR) == -1) {
ast_log(LOG_WARNING, "Failed to perform seek in monitoring read stream, synchronization between the files may be broken\n");
- chan->insmpl += (chan->outsmpl - chan->insmpl) + f->samples;
- } else
- chan->insmpl+= f->samples;
+ }
+ ast_channel_insmpl_set(chan, ast_channel_insmpl(chan) + (ast_channel_outsmpl(chan) - ast_channel_insmpl(chan)) + f->samples);
+ } else {
+ ast_channel_insmpl_set(chan, ast_channel_insmpl(chan) + f->samples);
+ }
#else
- int jump = calc_monitor_jump((chan->outsmpl - chan->insmpl), ast_format_rate(f->subclass.codec), ast_format_rate(chan->monitor->read_stream->fmt->format));
+ int jump = calc_monitor_jump((ast_channel_outsmpl(chan) - ast_channel_insmpl(chan)), ast_format_rate(f->subclass.codec), ast_format_rate(ast_channel_monitor(chan)->read_stream->fmt->format));
if (jump - MONITOR_DELAY >= 0) {
- if (ast_seekstream(chan->monitor->read_stream, jump - f->samples, SEEK_FORCECUR) == -1)
+ if (ast_seekstream(ast_channel_monitor(chan)->read_stream, jump - f->samples, SEEK_FORCECUR) == -1)
ast_log(LOG_WARNING, "Failed to perform seek in monitoring read stream, synchronization between the files may be broken\n");
- chan->insmpl += chan->outsmpl - chan->insmpl;
+ ast_channel_insmpl(chan) += ast_channel_outsmpl(chan) - ast_channel_insmpl(chan);
} else
- chan->insmpl += f->samples;
+ ast_channel_insmpl(chan) += f->samples;
#endif
- if (chan->monitor->state == AST_MONITOR_RUNNING) {
- if (ast_writestream(chan->monitor->read_stream, f) < 0)
+ if (ast_channel_monitor(chan)->state == AST_MONITOR_RUNNING) {
+ if (ast_writestream(ast_channel_monitor(chan)->read_stream, f) < 0)
ast_log(LOG_WARNING, "Failed to write data to channel monitor read stream\n");
}
}
- if (chan->readtrans && (f = ast_translate(chan->readtrans, f, 1)) == NULL) {
+ if (ast_channel_readtrans(chan) && (f = ast_translate(ast_channel_readtrans(chan), f, 1)) == NULL) {
f = &ast_null_frame;
}
@@ -4067,25 +4078,25 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
chan->_softhangup |= AST_SOFTHANGUP_DEV;
}
if (cause)
- chan->hangupcause = cause;
- if (chan->generator)
+ ast_channel_hangupcause_set(chan, cause);
+ if (ast_channel_generator(chan))
ast_deactivate_generator(chan);
/* We no longer End the CDR here */
}
/* High bit prints debugging */
- if (chan->fin & DEBUGCHAN_FLAG)
+ if (ast_channel_fin(chan) & DEBUGCHAN_FLAG)
ast_frame_dump(ast_channel_name(chan), f, "<<");
- chan->fin = FRAMECOUNT_INC(chan->fin);
+ ast_channel_fin_set(chan, FRAMECOUNT_INC(ast_channel_fin(chan)));
done:
- if (chan->music_state && chan->generator && chan->generator->digit && f && f->frametype == AST_FRAME_DTMF_END)
- chan->generator->digit(chan, f->subclass.integer);
+ if (ast_channel_music_state(chan) && ast_channel_generator(chan) && ast_channel_generator(chan)->digit && f && f->frametype == AST_FRAME_DTMF_END)
+ ast_channel_generator(chan)->digit(chan, f->subclass.integer);
- if (chan->audiohooks && ast_audiohook_write_list_empty(chan->audiohooks)) {
+ if (ast_channel_audiohooks(chan) && ast_audiohook_write_list_empty(ast_channel_audiohooks(chan))) {
/* The list gets recreated if audiohooks are added again later */
- ast_audiohook_detach_list(chan->audiohooks);
- chan->audiohooks = NULL;
+ ast_audiohook_detach_list(ast_channel_audiohooks(chan));
+ ast_channel_audiohooks_set(chan, NULL);
}
ast_channel_unlock(chan);
return f;
@@ -4093,7 +4104,7 @@ done:
int ast_internal_timing_enabled(struct ast_channel *chan)
{
- return (ast_opt_internal_timing && chan->timingfd > -1);
+ return (ast_opt_internal_timing && ast_channel_timingfd(chan) > -1);
}
struct ast_frame *ast_read(struct ast_channel *chan)
@@ -4180,7 +4191,7 @@ int ast_indicate_data(struct ast_channel *chan, int _condition,
goto indicate_cleanup;
}
- if (!ast_framehook_list_is_empty(chan->framehooks)) {
+ if (!ast_framehook_list_is_empty(ast_channel_framehooks(chan))) {
/* Do framehooks now, do it, go, go now */
struct ast_frame frame = {
.frametype = AST_FRAME_CONTROL,
@@ -4193,7 +4204,7 @@ int ast_indicate_data(struct ast_channel *chan, int _condition,
awesome_frame = ast_frdup(&frame);
/* who knows what we will get back! the anticipation is killing me. */
- if (!(awesome_frame = ast_framehook_list_write_event(chan->framehooks, awesome_frame))
+ if (!(awesome_frame = ast_framehook_list_write_event(ast_channel_framehooks(chan), awesome_frame))
|| awesome_frame->frametype != AST_FRAME_CONTROL) {
res = 0;
@@ -4238,15 +4249,15 @@ int ast_indicate_data(struct ast_channel *chan, int _condition,
if (is_visible_indication(condition)) {
/* A new visible indication is requested. */
- chan->visible_indication = condition;
+ ast_channel_visible_indication_set(chan, condition);
} else if (condition == AST_CONTROL_UNHOLD || _condition < 0) {
/* Visible indication is cleared/stopped. */
- chan->visible_indication = 0;
+ ast_channel_visible_indication_set(chan, 0);
}
- if (chan->tech->indicate) {
+ if (ast_channel_tech(chan)->indicate) {
/* See if the channel driver can handle this condition. */
- res = chan->tech->indicate(chan, condition, data, datalen);
+ res = ast_channel_tech(chan)->indicate(chan, condition, data, datalen);
} else {
res = -1;
}
@@ -4286,7 +4297,7 @@ int ast_indicate_data(struct ast_channel *chan, int _condition,
* has some meaning.*/
goto indicate_cleanup;
case AST_CONTROL_RINGING:
- ts = ast_get_indication_tone(chan->zone, "ring");
+ ts = ast_get_indication_tone(ast_channel_zone(chan), "ring");
/* It is common practice for channel drivers to return -1 if trying
* to indicate ringing on a channel which is up. The idea is to let the
* core generate the ringing inband. However, we don't want the
@@ -4294,16 +4305,16 @@ int ast_indicate_data(struct ast_channel *chan, int _condition,
* to print nor do we want ast_indicate_data to return an "error" for this
* condition
*/
- if (chan->_state == AST_STATE_UP) {
+ if (ast_channel_state(chan) == AST_STATE_UP) {
res = 0;
}
break;
case AST_CONTROL_BUSY:
- ts = ast_get_indication_tone(chan->zone, "busy");
+ ts = ast_get_indication_tone(ast_channel_zone(chan), "busy");
break;
case AST_CONTROL_INCOMPLETE:
case AST_CONTROL_CONGESTION:
- ts = ast_get_indication_tone(chan->zone, "congestion");
+ ts = ast_get_indication_tone(ast_channel_zone(chan), "congestion");
break;
case AST_CONTROL_PROGRESS:
case AST_CONTROL_PROCEEDING:
@@ -4412,7 +4423,7 @@ int ast_sendtext(struct ast_channel *chan, const char *text)
}
CHECK_BLOCKING(chan);
- if (chan->tech->write_text && (ast_format_cap_has_type(chan->nativeformats, AST_FORMAT_TYPE_TEXT))) {
+ if (ast_channel_tech(chan)->write_text && (ast_format_cap_has_type(ast_channel_nativeformats(chan), AST_FORMAT_TYPE_TEXT))) {
struct ast_frame f;
f.frametype = AST_FRAME_TEXT;
@@ -4424,9 +4435,9 @@ int ast_sendtext(struct ast_channel *chan, const char *text)
f.seqno = 0;
ast_format_set(&f.subclass.format, AST_FORMAT_T140, 0);
- res = chan->tech->write_text(chan, &f);
- } else if (chan->tech->send_text) {
- res = chan->tech->send_text(chan, text);
+ res = ast_channel_tech(chan)->write_text(chan, &f);
+ } else if (ast_channel_tech(chan)->send_text) {
+ res = ast_channel_tech(chan)->send_text(chan, text);
}
ast_clear_flag(chan, AST_FLAG_BLOCKING);
ast_channel_unlock(chan);
@@ -4456,10 +4467,10 @@ int ast_senddigit_begin(struct ast_channel *chan, char digit)
"941+1477" /* # */
};
- if (!chan->tech->send_digit_begin)
+ if (!ast_channel_tech(chan)->send_digit_begin)
return 0;
- if (!chan->tech->send_digit_begin(chan, digit))
+ if (!ast_channel_tech(chan)->send_digit_begin(chan, digit))
return 0;
if (digit >= '0' && digit <='9')
@@ -4482,10 +4493,10 @@ int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duratio
{
int res = -1;
- if (chan->tech->send_digit_end)
- res = chan->tech->send_digit_end(chan, digit, duration);
+ if (ast_channel_tech(chan)->send_digit_end)
+ res = ast_channel_tech(chan)->send_digit_end(chan, digit, duration);
- if (res && chan->generator)
+ if (res && ast_channel_generator(chan))
ast_playtones_stop(chan);
return 0;
@@ -4493,7 +4504,7 @@ int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duratio
int ast_senddigit(struct ast_channel *chan, char digit, unsigned int duration)
{
- if (chan->tech->send_digit_begin) {
+ if (ast_channel_tech(chan)->send_digit_begin) {
ast_senddigit_begin(chan, digit);
ast_safe_sleep(chan, (duration >= AST_DEFAULT_EMULATE_DTMF_DURATION ? duration : AST_DEFAULT_EMULATE_DTMF_DURATION));
}
@@ -4507,7 +4518,7 @@ int ast_prod(struct ast_channel *chan)
char nothing[128];
/* Send an empty audio frame to get things moving */
- if (chan->_state != AST_STATE_UP) {
+ if (ast_channel_state(chan) != AST_STATE_UP) {
ast_debug(1, "Prodding channel '%s'\n", ast_channel_name(chan));
ast_format_copy(&a.subclass.format, &chan->rawwriteformat);
a.data.ptr = nothing + AST_FRIENDLY_OFFSET;
@@ -4521,7 +4532,7 @@ int ast_prod(struct ast_channel *chan)
int ast_write_video(struct ast_channel *chan, struct ast_frame *fr)
{
int res;
- if (!chan->tech->write_video)
+ if (!ast_channel_tech(chan)->write_video)
return 0;
res = ast_write(chan, fr);
if (!res)
@@ -4653,7 +4664,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
goto done;
/* Handle any pending masquerades */
- if (chan->masq) {
+ if (ast_channel_masq(chan)) {
ast_channel_unlock(chan);
if (ast_do_masquerade(chan)) {
ast_log(LOG_WARNING, "Failed to perform masquerade\n");
@@ -4661,19 +4672,19 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
}
ast_channel_lock(chan);
}
- if (chan->masqr) {
+ if (ast_channel_masqr(chan)) {
res = 0; /* XXX explain, why 0 ? */
goto done;
}
/* Perform the framehook write event here. After the frame enters the framehook list
* there is no telling what will happen, how awesome is that!!! */
- if (!(fr = ast_framehook_list_write_event(chan->framehooks, fr))) {
+ if (!(fr = ast_framehook_list_write_event(ast_channel_framehooks(chan), fr))) {
res = 0;
goto done;
}
- if (chan->generatordata && (!fr->src || strcasecmp(fr->src, "ast_prod"))) {
+ if (ast_channel_generatordata(chan) && (!fr->src || strcasecmp(fr->src, "ast_prod"))) {
if (ast_test_flag(chan, AST_FLAG_WRITE_INT)) {
ast_deactivate_generator(chan);
} else {
@@ -4688,26 +4699,26 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
CHECK_BLOCKING(chan);
} else if (fr->frametype == AST_FRAME_CONTROL && fr->subclass.integer == AST_CONTROL_UNHOLD) {
/* This is a side case where Echo is basically being called and the person put themselves on hold and took themselves off hold */
- res = (chan->tech->indicate == NULL) ? 0 :
- chan->tech->indicate(chan, fr->subclass.integer, fr->data.ptr, fr->datalen);
+ res = (ast_channel_tech(chan)->indicate == NULL) ? 0 :
+ ast_channel_tech(chan)->indicate(chan, fr->subclass.integer, fr->data.ptr, fr->datalen);
}
res = 0; /* XXX explain, why 0 ? */
goto done;
}
}
/* High bit prints debugging */
- if (chan->fout & DEBUGCHAN_FLAG)
+ if (ast_channel_fout(chan) & DEBUGCHAN_FLAG)
ast_frame_dump(ast_channel_name(chan), fr, ">>");
CHECK_BLOCKING(chan);
switch (fr->frametype) {
case AST_FRAME_CONTROL:
- res = (chan->tech->indicate == NULL) ? 0 :
- chan->tech->indicate(chan, fr->subclass.integer, fr->data.ptr, fr->datalen);
+ res = (ast_channel_tech(chan)->indicate == NULL) ? 0 :
+ ast_channel_tech(chan)->indicate(chan, fr->subclass.integer, fr->data.ptr, fr->datalen);
break;
case AST_FRAME_DTMF_BEGIN:
- if (chan->audiohooks) {
+ if (ast_channel_audiohooks(chan)) {
struct ast_frame *old_frame = fr;
- fr = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_WRITE, fr);
+ fr = ast_audiohook_write_list(chan, ast_channel_audiohooks(chan), AST_AUDIOHOOK_DIRECTION_WRITE, fr);
if (old_frame != fr)
f = fr;
}
@@ -4719,10 +4730,10 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
CHECK_BLOCKING(chan);
break;
case AST_FRAME_DTMF_END:
- if (chan->audiohooks) {
+ if (ast_channel_audiohooks(chan)) {
struct ast_frame *new_frame = fr;
- new_frame = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_WRITE, fr);
+ new_frame = ast_audiohook_write_list(chan, ast_channel_audiohooks(chan), AST_AUDIOHOOK_DIRECTION_WRITE, fr);
if (new_frame != fr) {
ast_frfree(new_frame);
}
@@ -4736,28 +4747,28 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
break;
case AST_FRAME_TEXT:
if (fr->subclass.integer == AST_FORMAT_T140) {
- res = (chan->tech->write_text == NULL) ? 0 :
- chan->tech->write_text(chan, fr);
+ res = (ast_channel_tech(chan)->write_text == NULL) ? 0 :
+ ast_channel_tech(chan)->write_text(chan, fr);
} else {
- res = (chan->tech->send_text == NULL) ? 0 :
- chan->tech->send_text(chan, (char *) fr->data.ptr);
+ res = (ast_channel_tech(chan)->send_text == NULL) ? 0 :
+ ast_channel_tech(chan)->send_text(chan, (char *) fr->data.ptr);
}
break;
case AST_FRAME_HTML:
- res = (chan->tech->send_html == NULL) ? 0 :
- chan->tech->send_html(chan, fr->subclass.integer, (char *) fr->data.ptr, fr->datalen);
+ res = (ast_channel_tech(chan)->send_html == NULL) ? 0 :
+ ast_channel_tech(chan)->send_html(chan, fr->subclass.integer, (char *) fr->data.ptr, fr->datalen);
break;
case AST_FRAME_VIDEO:
/* XXX Handle translation of video codecs one day XXX */
- res = (chan->tech->write_video == NULL) ? 0 :
- chan->tech->write_video(chan, fr);
+ res = (ast_channel_tech(chan)->write_video == NULL) ? 0 :
+ ast_channel_tech(chan)->write_video(chan, fr);
break;
case AST_FRAME_MODEM:
- res = (chan->tech->write == NULL) ? 0 :
- chan->tech->write(chan, fr);
+ res = (ast_channel_tech(chan)->write == NULL) ? 0 :
+ ast_channel_tech(chan)->write(chan, fr);
break;
case AST_FRAME_VOICE:
- if (chan->tech->write == NULL)
+ if (ast_channel_tech(chan)->write == NULL)
break; /*! \todo XXX should return 0 maybe ? */
if (ast_opt_generic_plc && fr->subclass.format.id == AST_FORMAT_SLINEAR) {
@@ -4774,16 +4785,16 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
* eliminate user impact and help identify the problem areas
* JIRA issues related to this :-
* ASTERISK-14384, ASTERISK-17502, ASTERISK-17541, ASTERISK-18063, ASTERISK-18325, ASTERISK-18422*/
- if ((!ast_format_cap_iscompatible(chan->nativeformats, &fr->subclass.format)) &&
+ if ((!ast_format_cap_iscompatible(ast_channel_nativeformats(chan), &fr->subclass.format)) &&
(ast_format_cmp(&chan->writeformat, &fr->subclass.format) != AST_FORMAT_CMP_EQUAL)) {
char nf[512];
ast_log(LOG_WARNING, "Codec mismatch on channel %s setting write format to %s from %s native formats %s\n",
ast_channel_name(chan), ast_getformatname(&fr->subclass.format), ast_getformatname(&chan->writeformat),
- ast_getformatname_multiple(nf, sizeof(nf), chan->nativeformats));
+ ast_getformatname_multiple(nf, sizeof(nf), ast_channel_nativeformats(chan)));
ast_set_write_format_by_id(chan, fr->subclass.format.id);
}
- f = (chan->writetrans) ? ast_translate(chan->writetrans, fr, 0) : fr;
+ f = (ast_channel_writetrans(chan)) ? ast_translate(ast_channel_writetrans(chan), fr, 0) : fr;
}
if (!f) {
@@ -4791,7 +4802,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
break;
}
- if (chan->audiohooks) {
+ if (ast_channel_audiohooks(chan)) {
struct ast_frame *prev = NULL, *new_frame, *cur, *dup;
int freeoldlist = 0;
@@ -4803,7 +4814,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
* an item in a list of frames, create a new list adding each cur frame back to it
* regardless if the cur frame changes or not. */
for (cur = f; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
- new_frame = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_WRITE, cur);
+ new_frame = ast_audiohook_write_list(chan, ast_channel_audiohooks(chan), AST_AUDIOHOOK_DIRECTION_WRITE, cur);
/* if this frame is different than cur, preserve the end of the list,
* free the old frames, and set cur to be the new frame */
@@ -4840,33 +4851,35 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
/* the translator on chan->writetrans may have returned multiple frames
from the single frame we passed in; if so, feed each one of them to the
monitor */
- if (chan->monitor && chan->monitor->write_stream) {
+ if (ast_channel_monitor(chan) && ast_channel_monitor(chan)->write_stream) {
struct ast_frame *cur;
for (cur = f; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
/* XXX must explain this code */
#ifndef MONITOR_CONSTANT_DELAY
- int jump = chan->insmpl - chan->outsmpl - 4 * cur->samples;
+ int jump = ast_channel_insmpl(chan) - ast_channel_outsmpl(chan) - 4 * cur->samples;
if (jump >= 0) {
- jump = calc_monitor_jump((chan->insmpl - chan->outsmpl), ast_format_rate(&f->subclass.format), ast_format_rate(&chan->monitor->read_stream->fmt->format));
- if (ast_seekstream(chan->monitor->write_stream, jump, SEEK_FORCECUR) == -1)
+ jump = calc_monitor_jump((ast_channel_insmpl(chan) - ast_channel_outsmpl(chan)), ast_format_rate(&f->subclass.format), ast_format_rate(&ast_channel_monitor(chan)->read_stream->fmt->format));
+ if (ast_seekstream(ast_channel_monitor(chan)->write_stream, jump, SEEK_FORCECUR) == -1) {
ast_log(LOG_WARNING, "Failed to perform seek in monitoring write stream, synchronization between the files may be broken\n");
- chan->outsmpl += (chan->insmpl - chan->outsmpl) + cur->samples;
+ }
+ ast_channel_outsmpl_set(chan, ast_channel_outsmpl(chan) + (ast_channel_insmpl(chan) - ast_channel_outsmpl(chan)) + cur->samples);
} else {
- chan->outsmpl += cur->samples;
+ ast_channel_outsmpl_set(chan, ast_channel_outsmpl(chan) + cur->samples);
}
#else
- int jump = calc_monitor_jump((chan->insmpl - chan->outsmpl), ast_format_rate(f->subclass.codec), ast_format_rate(chan->monitor->read_stream->fmt->format));
+ int jump = calc_monitor_jump((ast_channel_insmpl(chan) - ast_channel_outsmpl(chan)), ast_format_rate(f->subclass.codec), ast_format_rate(ast_channel_monitor(chan)->read_stream->fmt->format));
if (jump - MONITOR_DELAY >= 0) {
- if (ast_seekstream(chan->monitor->write_stream, jump - cur->samples, SEEK_FORCECUR) == -1)
+ if (ast_seekstream(ast_channel_monitor(chan)->write_stream, jump - cur->samples, SEEK_FORCECUR) == -1) {
ast_log(LOG_WARNING, "Failed to perform seek in monitoring write stream, synchronization between the files may be broken\n");
- chan->outsmpl += chan->insmpl - chan->outsmpl;
+ }
+ ast_channel_outsmpl_set(chan, ast_channel_outsmpl(chan) + ast_channel_insmpl(chan) - ast_channel_outsmpl(chan));
} else {
- chan->outsmpl += cur->samples;
+ ast_channel_outsmpl_set(chan, ast_channel_outsmpl(chan) + cur->samples);
}
#endif
- if (chan->monitor->state == AST_MONITOR_RUNNING) {
- if (ast_writestream(chan->monitor->write_stream, cur) < 0)
+ if (ast_channel_monitor(chan)->state == AST_MONITOR_RUNNING) {
+ if (ast_writestream(ast_channel_monitor(chan)->write_stream, cur) < 0)
ast_log(LOG_WARNING, "Failed to write data to channel monitor write stream\n");
}
}
@@ -4884,14 +4897,14 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
next = AST_LIST_NEXT(cur, frame_list);
AST_LIST_NEXT(cur, frame_list) = NULL;
if (!skip) {
- if ((res = chan->tech->write(chan, cur)) < 0) {
+ if ((res = ast_channel_tech(chan)->write(chan, cur)) < 0) {
chan->_softhangup |= AST_SOFTHANGUP_DEV;
skip = 1;
} else if (next) {
/* don't do this for the last frame in the list,
as the code outside the loop will do it once
*/
- chan->fout = FRAMECOUNT_INC(chan->fout);
+ ast_channel_fout_set(chan, FRAMECOUNT_INC(ast_channel_fout(chan)));
}
}
ast_frfree(cur);
@@ -4901,7 +4914,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
/* reset f so the code below doesn't attempt to free it */
f = NULL;
} else {
- res = chan->tech->write(chan, f);
+ res = ast_channel_tech(chan)->write(chan, f);
}
break;
case AST_FRAME_NULL:
@@ -4913,7 +4926,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
/* At this point, fr is the incoming frame and f is NULL. Channels do
* not expect to get NULL as a frame pointer and will segfault. Hence,
* we output the original frame passed in. */
- res = chan->tech->write(chan, fr);
+ res = ast_channel_tech(chan)->write(chan, fr);
break;
}
@@ -4925,13 +4938,13 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
if (res < 0) {
chan->_softhangup |= AST_SOFTHANGUP_DEV;
} else {
- chan->fout = FRAMECOUNT_INC(chan->fout);
+ ast_channel_fout_set(chan, FRAMECOUNT_INC(ast_channel_fout(chan)));
}
done:
- if (chan->audiohooks && ast_audiohook_write_list_empty(chan->audiohooks)) {
+ if (ast_channel_audiohooks(chan) && ast_audiohook_write_list_empty(ast_channel_audiohooks(chan))) {
/* The list gets recreated if audiohooks are added again later */
- ast_audiohook_detach_list(chan->audiohooks);
- chan->audiohooks = NULL;
+ ast_audiohook_detach_list(ast_channel_audiohooks(chan));
+ ast_channel_audiohooks_set(chan, NULL);
}
ast_channel_unlock(chan);
return res;
@@ -4944,7 +4957,7 @@ static int set_format(struct ast_channel *chan,
struct ast_trans_pvt **trans,
const int direction)
{
- struct ast_format_cap *cap_native = chan->nativeformats;
+ struct ast_format_cap *cap_native = ast_channel_nativeformats(chan);
struct ast_format best_set_fmt;
struct ast_format best_native_fmt;
int res;
@@ -4960,7 +4973,7 @@ static int set_format(struct ast_channel *chan,
ast_channel_lock(chan);
ast_format_copy(format, &best_set_fmt);
ast_format_copy(rawformat, &best_set_fmt);
- ast_format_cap_set(chan->nativeformats, &best_set_fmt);
+ ast_format_cap_set(ast_channel_nativeformats(chan), &best_set_fmt);
ast_channel_unlock(chan);
if (*trans) {
@@ -4969,7 +4982,7 @@ static int set_format(struct ast_channel *chan,
*trans = NULL;
/* If there is a generator on the channel, it needs to know about this
* change if it is the write format. */
- if (direction && chan->generatordata) {
+ if (direction && ast_channel_generatordata(chan)) {
generator_write_format_change(chan);
}
return 0;
@@ -5039,7 +5052,7 @@ static int set_format(struct ast_channel *chan,
/* If there is a generator on the channel, it needs to know about this
* change if it is the write format. */
- if (direction && chan->generatordata) {
+ if (direction && ast_channel_generatordata(chan)) {
generator_write_format_change(chan);
}
return res;
@@ -5048,6 +5061,7 @@ static int set_format(struct ast_channel *chan,
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
{
struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
+ struct ast_trans_pvt *trans = NULL;
int res;
if (!cap) {
return -1;
@@ -5058,9 +5072,10 @@ int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
cap,
&chan->rawreadformat,
&chan->readformat,
- &chan->readtrans,
+ &trans,
0);
+ ast_channel_readtrans_set(chan, trans);
ast_format_cap_destroy(cap);
return res;
}
@@ -5069,6 +5084,7 @@ int ast_set_read_format_by_id(struct ast_channel *chan, enum ast_format_id id)
{
struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
struct ast_format tmp_format;
+ struct ast_trans_pvt *trans = NULL;
int res;
if (!cap) {
return -1;
@@ -5079,26 +5095,32 @@ int ast_set_read_format_by_id(struct ast_channel *chan, enum ast_format_id id)
cap,
&chan->rawreadformat,
&chan->readformat,
- &chan->readtrans,
+ &trans,
0);
+ ast_channel_readtrans_set(chan, trans);
ast_format_cap_destroy(cap);
return res;
}
int ast_set_read_format_from_cap(struct ast_channel *chan, struct ast_format_cap *cap)
{
- return set_format(chan,
+ struct ast_trans_pvt *trans = NULL;
+ int res;
+ res = set_format(chan,
cap,
&chan->rawreadformat,
&chan->readformat,
- &chan->readtrans,
+ &trans,
0);
+ ast_channel_readtrans_set(chan, trans);
+ return res;
}
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
{
struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
+ struct ast_trans_pvt *trans = NULL;
int res;
if (!cap) {
return -1;
@@ -5109,9 +5131,10 @@ int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
cap,
&chan->rawwriteformat,
&chan->writeformat,
- &chan->writetrans,
+ &trans,
1);
+ ast_channel_writetrans_set(chan, trans);
ast_format_cap_destroy(cap);
return res;
}
@@ -5120,6 +5143,7 @@ int ast_set_write_format_by_id(struct ast_channel *chan, enum ast_format_id id)
{
struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
struct ast_format tmp_format;
+ struct ast_trans_pvt *trans = NULL;
int res;
if (!cap) {
return -1;
@@ -5130,21 +5154,26 @@ int ast_set_write_format_by_id(struct ast_channel *chan, enum ast_format_id id)
cap,
&chan->rawwriteformat,
&chan->writeformat,
- &chan->writetrans,
+ &trans,
1);
+ ast_channel_writetrans_set(chan, trans);
ast_format_cap_destroy(cap);
return res;
}
int ast_set_write_format_from_cap(struct ast_channel *chan, struct ast_format_cap *cap)
{
- return set_format(chan,
+ struct ast_trans_pvt *trans = NULL;
+ int res;
+ res = set_format(chan,
cap,
&chan->rawwriteformat,
&chan->writeformat,
- &chan->writetrans,
+ &trans,
1);
+ ast_channel_writetrans_set(chan, trans);
+ return res;
}
const char *ast_channel_reason2str(int reason)
@@ -5267,7 +5296,7 @@ struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_chan
}
ast_channel_lock_both(orig, new_chan);
- ast_copy_flags(new_chan->cdr, orig->cdr, AST_CDR_FLAG_ORIGINATED);
+ ast_copy_flags(ast_channel_cdr(new_chan), ast_channel_cdr(orig), AST_CDR_FLAG_ORIGINATED);
ast_channel_accountcode_set(new_chan, ast_channel_accountcode(orig));
ast_party_connected_line_copy(&new_chan->connected, &orig->connected);
ast_party_redirecting_copy(&new_chan->redirecting, &orig->redirecting);
@@ -5338,7 +5367,7 @@ struct ast_channel *__ast_request_and_dial(const char *type, struct ast_format_c
}
}
- ast_set_flag(chan->cdr, AST_CDR_FLAG_ORIGINATED);
+ ast_set_flag(ast_channel_cdr(chan), AST_CDR_FLAG_ORIGINATED);
ast_party_connected_line_set_init(&connected, &chan->connected);
if (cid_num) {
connected.id.number.valid = 1;
@@ -5356,7 +5385,7 @@ struct ast_channel *__ast_request_and_dial(const char *type, struct ast_format_c
ast_log(LOG_NOTICE, "Unable to call channel %s/%s\n", type, addr);
} else {
res = 1; /* mark success in case chan->_state is already AST_STATE_UP */
- while (timeout && chan->_state != AST_STATE_UP) {
+ while (timeout && ast_channel_state(chan) != AST_STATE_UP) {
struct ast_frame *f;
res = ast_waitfor(chan, timeout);
if (res == 0) { /* timeout, treat it like ringing */
@@ -5387,25 +5416,25 @@ struct ast_channel *__ast_request_and_dial(const char *type, struct ast_format_c
break;
case AST_CONTROL_BUSY:
- ast_cdr_busy(chan->cdr);
+ ast_cdr_busy(ast_channel_cdr(chan));
*outstate = f->subclass.integer;
timeout = 0;
break;
case AST_CONTROL_INCOMPLETE:
- ast_cdr_failed(chan->cdr);
+ ast_cdr_failed(ast_channel_cdr(chan));
*outstate = AST_CONTROL_CONGESTION;
timeout = 0;
break;
case AST_CONTROL_CONGESTION:
- ast_cdr_failed(chan->cdr);
+ ast_cdr_failed(ast_channel_cdr(chan));
*outstate = f->subclass.integer;
timeout = 0;
break;
case AST_CONTROL_ANSWER:
- ast_cdr_answer(chan->cdr);
+ ast_cdr_answer(ast_channel_cdr(chan));
*outstate = f->subclass.integer;
timeout = 0; /* trick to force exit from the while() */
break;
@@ -5440,30 +5469,32 @@ struct ast_channel *__ast_request_and_dial(const char *type, struct ast_format_c
if (!ast_strlen_zero(oh->exten))
ast_channel_exten_set(chan, oh->exten);
if (oh->priority)
- chan->priority = oh->priority;
+ ast_channel_priority_set(chan, oh->priority);
}
- if (chan->_state == AST_STATE_UP)
+ if (ast_channel_state(chan) == AST_STATE_UP)
*outstate = AST_CONTROL_ANSWER;
if (res <= 0) {
+ struct ast_cdr *chancdr;
ast_channel_lock(chan);
if (AST_CONTROL_RINGING == last_subclass) {
- chan->hangupcause = AST_CAUSE_NO_ANSWER;
+ ast_channel_hangupcause_set(chan, AST_CAUSE_NO_ANSWER);
}
- if (!chan->cdr && (chan->cdr = ast_cdr_alloc())) {
- ast_cdr_init(chan->cdr, chan);
+ if (!ast_channel_cdr(chan) && (chancdr = ast_cdr_alloc())) {
+ ast_channel_cdr_set(chan, chancdr);
+ ast_cdr_init(ast_channel_cdr(chan), chan);
}
- if (chan->cdr) {
+ if (ast_channel_cdr(chan)) {
char tmp[256];
snprintf(tmp, sizeof(tmp), "%s/%s", type, addr);
- ast_cdr_setapp(chan->cdr, "Dial", tmp);
+ ast_cdr_setapp(ast_channel_cdr(chan), "Dial", tmp);
ast_cdr_update(chan);
- ast_cdr_start(chan->cdr);
- ast_cdr_end(chan->cdr);
+ ast_cdr_start(ast_channel_cdr(chan));
+ ast_cdr_end(ast_channel_cdr(chan));
/* If the cause wasn't handled properly */
- if (ast_cdr_disposition(chan->cdr, chan->hangupcause)) {
- ast_cdr_failed(chan->cdr);
+ if (ast_cdr_disposition(ast_channel_cdr(chan), ast_channel_hangupcause(chan))) {
+ ast_cdr_failed(ast_channel_cdr(chan));
}
}
ast_channel_unlock(chan);
@@ -5608,11 +5639,11 @@ int ast_call(struct ast_channel *chan, const char *addr, int timeout)
/* Stop if we're a zombie or need a soft hangup */
ast_channel_lock(chan);
if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) {
- if (chan->cdr) {
- ast_set_flag(chan->cdr, AST_CDR_FLAG_DIALED);
+ if (ast_channel_cdr(chan)) {
+ ast_set_flag(ast_channel_cdr(chan), AST_CDR_FLAG_DIALED);
}
- if (chan->tech->call)
- res = chan->tech->call(chan, addr, timeout);
+ if (ast_channel_tech(chan)->call)
+ res = ast_channel_tech(chan)->call(chan, addr, timeout);
ast_set_flag(chan, AST_FLAG_OUTGOING);
}
ast_channel_unlock(chan);
@@ -5633,8 +5664,8 @@ int ast_transfer(struct ast_channel *chan, char *dest)
/* Stop if we're a zombie or need a soft hangup */
ast_channel_lock(chan);
if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) {
- if (chan->tech->transfer) {
- res = chan->tech->transfer(chan, dest);
+ if (ast_channel_tech(chan)->transfer) {
+ res = ast_channel_tech(chan)->transfer(chan, dest);
if (!res)
res = 1;
} else
@@ -5694,7 +5725,7 @@ int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, in
return -1;
for (;;) {
int d;
- if (c->stream) {
+ if (ast_channel_stream(c)) {
d = ast_waitstream_full(c, AST_DIGIT_ANY, audiofd, ctrlfd);
ast_stopstream(c);
if (!silgen && ast_opt_transmit_silence)
@@ -5742,13 +5773,13 @@ int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, in
int ast_channel_supports_html(struct ast_channel *chan)
{
- return (chan->tech->send_html) ? 1 : 0;
+ return (ast_channel_tech(chan)->send_html) ? 1 : 0;
}
int ast_channel_sendhtml(struct ast_channel *chan, int subclass, const char *data, int datalen)
{
- if (chan->tech->send_html)
- return chan->tech->send_html(chan, subclass, data, datalen);
+ if (ast_channel_tech(chan)->send_html)
+ return ast_channel_tech(chan)->send_html(chan, subclass, data, datalen);
return -1;
}
@@ -5760,14 +5791,14 @@ int ast_channel_sendurl(struct ast_channel *chan, const char *url)
/*! \brief Set up translation from one channel to another */
static int ast_channel_make_compatible_helper(struct ast_channel *from, struct ast_channel *to)
{
- struct ast_format_cap *src_cap = from->nativeformats; /* shallow copy, do not destroy */
- struct ast_format_cap *dst_cap = to->nativeformats; /* shallow copy, do not destroy */
+ struct ast_format_cap *src_cap = ast_channel_nativeformats(from); /* shallow copy, do not destroy */
+ struct ast_format_cap *dst_cap = ast_channel_nativeformats(to); /* shallow copy, do not destroy */
struct ast_format best_src_fmt;
struct ast_format best_dst_fmt;
int use_slin;
/* See if the channel driver can natively make these two channels compatible */
- if (from->tech->bridge && from->tech->bridge == to->tech->bridge &&
+ if (ast_channel_tech(from)->bridge && ast_channel_tech(from)->bridge == ast_channel_tech(to)->bridge &&
!ast_channel_setoption(from, AST_OPTION_MAKE_COMPATIBLE, to, sizeof(struct ast_channel *), 0)) {
return 0;
}
@@ -5870,8 +5901,8 @@ static int __ast_channel_masquerade(struct ast_channel *original, struct ast_cha
&& (clonechan->_bridge->_bridge != clonechan)) {
final_clone = clonechan->_bridge;
}
- if (final_clone->tech->get_base_channel
- && (base = final_clone->tech->get_base_channel(final_clone))) {
+ if (ast_channel_tech(final_clone)->get_base_channel
+ && (base = ast_channel_tech(final_clone)->get_base_channel(final_clone))) {
final_clone = base;
}
@@ -5925,9 +5956,9 @@ static int __ast_channel_masquerade(struct ast_channel *original, struct ast_cha
ast_debug(1, "Planning to masquerade channel %s into the structure of %s\n",
ast_channel_name(clonechan), ast_channel_name(original));
- if (!original->masqr && !original->masq && !clonechan->masq && !clonechan->masqr) {
- original->masq = clonechan;
- clonechan->masqr = original;
+ if (!ast_channel_masqr(original) && !ast_channel_masq(original) && !ast_channel_masq(clonechan) && !ast_channel_masqr(clonechan)) {
+ ast_channel_masq_set(original, clonechan);
+ ast_channel_masqr_set(clonechan, original);
if (xfer_ds) {
ast_channel_datastore_add(original, xfer_ds);
}
@@ -5935,19 +5966,19 @@ static int __ast_channel_masquerade(struct ast_channel *original, struct ast_cha
ast_queue_frame(clonechan, &ast_null_frame);
ast_debug(1, "Done planning to masquerade channel %s into the structure of %s\n", ast_channel_name(clonechan), ast_channel_name(original));
res = 0;
- } else if (original->masq) {
+ } else if (ast_channel_masq(original)) {
ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
- ast_channel_name(original->masq), ast_channel_name(original));
- } else if (original->masqr) {
+ ast_channel_name(ast_channel_masq(original)), ast_channel_name(original));
+ } else if (ast_channel_masqr(original)) {
/* not yet as a previously planned masq hasn't yet happened */
ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
- ast_channel_name(original), ast_channel_name(original->masqr));
- } else if (clonechan->masq) {
+ ast_channel_name(original), ast_channel_name(ast_channel_masqr(original)));
+ } else if (ast_channel_masq(clonechan)) {
ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
- ast_channel_name(clonechan->masq), ast_channel_name(clonechan));
+ ast_channel_name(ast_channel_masq(clonechan)), ast_channel_name(clonechan));
} else { /* (clonechan->masqr) */
ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
- ast_channel_name(clonechan), ast_channel_name(clonechan->masqr));
+ ast_channel_name(clonechan), ast_channel_name(ast_channel_masqr(clonechan)));
}
ast_channel_unlock(clonechan);
@@ -6447,7 +6478,7 @@ int ast_do_masquerade(struct ast_channel *original)
* verifies whether or not the masquerade has already been
* completed by another thread.
*/
- while ((clonechan = original->masq) && ast_channel_trylock(clonechan)) {
+ while ((clonechan = ast_channel_masq(original)) && ast_channel_trylock(clonechan)) {
/*
* A masq is needed but we could not get the clonechan lock
* immediately. Since this function already holds the global
@@ -6489,21 +6520,21 @@ int ast_do_masquerade(struct ast_channel *original)
}
/* clear the masquerade channels */
- original->masq = NULL;
- clonechan->masqr = NULL;
+ ast_channel_masq_set(original, NULL);
+ ast_channel_masqr_set(clonechan, NULL);
/* unlink from channels container as name (which is the hash value) will change */
ao2_unlink(channels, original);
ao2_unlink(channels, clonechan);
ast_debug(4, "Actually Masquerading %s(%d) into the structure of %s(%d)\n",
- ast_channel_name(clonechan), clonechan->_state, ast_channel_name(original), original->_state);
+ ast_channel_name(clonechan), ast_channel_state(clonechan), ast_channel_name(original), ast_channel_state(original));
/*
* Stop any visible indiction on the original channel so we can
* transfer it to the clonechan taking the original's place.
*/
- visible_indication = original->visible_indication;
+ visible_indication = ast_channel_visible_indication(original);
ast_indicate(original, -1);
chans[0] = clonechan;
@@ -6513,7 +6544,7 @@ int ast_do_masquerade(struct ast_channel *original)
"CloneState: %s\r\n"
"Original: %s\r\n"
"OriginalState: %s\r\n",
- ast_channel_name(clonechan), ast_state2str(clonechan->_state), ast_channel_name(original), ast_state2str(original->_state));
+ ast_channel_name(clonechan), ast_state2str(ast_channel_state(clonechan)), ast_channel_name(original), ast_state2str(ast_channel_state(original)));
/* Having remembered the original read/write formats, we turn off any translation on either
one */
@@ -6537,18 +6568,18 @@ int ast_do_masquerade(struct ast_channel *original)
ast_channel_set_linkgroup(original, clonechan);
/* Swap the technologies */
- t = original->tech;
- original->tech = clonechan->tech;
- clonechan->tech = t;
+ t = ast_channel_tech(original);
+ ast_channel_tech_set(original, ast_channel_tech(clonechan));
+ ast_channel_tech_set(clonechan, t);
/* Swap the cdrs */
- cdr = original->cdr;
- original->cdr = clonechan->cdr;
- clonechan->cdr = cdr;
+ cdr = ast_channel_cdr(original);
+ ast_channel_cdr_set(original, ast_channel_cdr(clonechan));
+ ast_channel_cdr_set(clonechan, cdr);
- t_pvt = original->tech_pvt;
- original->tech_pvt = clonechan->tech_pvt;
- clonechan->tech_pvt = t_pvt;
+ t_pvt = ast_channel_tech_pvt(original);
+ ast_channel_tech_pvt_set(original, ast_channel_tech_pvt(clonechan));
+ ast_channel_tech_pvt_set(clonechan, t_pvt);
/* Swap the alertpipes */
for (i = 0; i < 2; i++) {
@@ -6602,16 +6633,16 @@ int ast_do_masquerade(struct ast_channel *original)
call ast_setstate since the event manager doesn't really consider
these separate. We do this early so that the clone has the proper
state of the original channel. */
- origstate = original->_state;
- original->_state = clonechan->_state;
- clonechan->_state = origstate;
+ origstate = ast_channel_state(original);
+ ast_channel_state_set(original, ast_channel_state(clonechan));
+ ast_channel_state_set(clonechan, origstate);
- if (clonechan->tech->fixup && clonechan->tech->fixup(original, clonechan)) {
+ if (ast_channel_tech(clonechan)->fixup && ast_channel_tech(clonechan)->fixup(original, clonechan)) {
ast_log(LOG_WARNING, "Fixup failed on channel %s, strange things may happen.\n", ast_channel_name(clonechan));
}
/* Start by disconnecting the original's physical side */
- if (clonechan->tech->hangup && clonechan->tech->hangup(clonechan)) {
+ if (ast_channel_tech(clonechan)->hangup && ast_channel_tech(clonechan)->hangup(clonechan)) {
ast_log(LOG_WARNING, "Hangup failed! Strange things may happen!\n");
res = -1;
goto done;
@@ -6621,16 +6652,16 @@ int ast_do_masquerade(struct ast_channel *original)
* We just hung up the physical side of the channel. Set the
* new zombie to use the kill channel driver for safety.
*/
- clonechan->tech = &ast_kill_tech;
+ ast_channel_tech_set(clonechan, &ast_kill_tech);
/* Mangle the name of the clone channel */
snprintf(zombn, sizeof(zombn), "%s<ZOMBIE>", orig); /* quick, hide the brains! */
__ast_change_name_nolink(clonechan, zombn);
/* Update the type. */
- t_pvt = original->monitor;
- original->monitor = clonechan->monitor;
- clonechan->monitor = t_pvt;
+ t_pvt = ast_channel_monitor(original);
+ ast_channel_monitor_set(original, ast_channel_monitor(clonechan));
+ ast_channel_monitor_set(clonechan, t_pvt);
/* Keep the same language. */
ast_channel_language_set(original, ast_channel_language(clonechan));
@@ -6660,14 +6691,14 @@ int ast_do_masquerade(struct ast_channel *original)
clone_variables(original, clonechan);
/* Presense of ADSI capable CPE follows clone */
- original->adsicpe = clonechan->adsicpe;
+ ast_channel_adsicpe_set(original, ast_channel_adsicpe(clonechan));
/* Bridge remains the same */
/* CDR fields remain the same */
/* XXX What about blocking, softhangup, blocker, and lock and blockproc? XXX */
/* Application and data remain the same */
/* Clone exception becomes real one, as with fdno */
ast_set_flag(original, ast_test_flag(clonechan, AST_FLAG_EXCEPTION | AST_FLAG_OUTGOING));
- original->fdno = clonechan->fdno;
+ ast_channel_fdno_set(original, ast_channel_fdno(clonechan));
/* Schedule context remains the same */
/* Stream stuff stays the same */
/* Keep the original state. The fixup code will need to work with it most likely */
@@ -6695,10 +6726,10 @@ int ast_do_masquerade(struct ast_channel *original)
report_new_callerid(original);
/* Restore original timing file descriptor */
- ast_channel_set_fd(original, AST_TIMING_FD, original->timingfd);
+ ast_channel_set_fd(original, AST_TIMING_FD, ast_channel_timingfd(original));
/* Our native formats are different now */
- ast_format_cap_copy(original->nativeformats, clonechan->nativeformats);
+ ast_format_cap_copy(ast_channel_nativeformats(original), ast_channel_nativeformats(clonechan));
/* Context, extension, priority, app data, jump table, remain the same */
/* pvt switches. pbx stays the same, as does next */
@@ -6725,16 +6756,16 @@ int ast_do_masquerade(struct ast_channel *original)
/* Okay. Last thing is to let the channel driver know about all this mess, so he
can fix up everything as best as possible */
- if (original->tech->fixup) {
- if (original->tech->fixup(clonechan, original)) {
+ if (ast_channel_tech(original)->fixup) {
+ if (ast_channel_tech(original)->fixup(clonechan, original)) {
ast_log(LOG_WARNING, "Channel for type '%s' could not fixup channel %s\n",
- original->tech->type, ast_channel_name(original));
+ ast_channel_tech(original)->type, ast_channel_name(original));
res = -1;
goto done;
}
} else
ast_log(LOG_WARNING, "Channel type '%s' does not have a fixup routine (for %s)! Bad things may happen.\n",
- original->tech->type, ast_channel_name(original));
+ ast_channel_tech(original)->type, ast_channel_name(original));
/*
* If an indication is currently playing, maintain it on the channel
@@ -6761,8 +6792,8 @@ int ast_do_masquerade(struct ast_channel *original)
"Cause-txt: %s\r\n",
ast_channel_name(clonechan),
ast_channel_uniqueid(clonechan),
- clonechan->hangupcause,
- ast_cause2str(clonechan->hangupcause)
+ ast_channel_hangupcause(clonechan),
+ ast_cause2str(ast_channel_hangupcause(clonechan))
);
clonechan = ast_channel_release(clonechan);
} else {
@@ -6774,7 +6805,7 @@ int ast_do_masquerade(struct ast_channel *original)
/* Signal any blocker */
if (ast_test_flag(original, AST_FLAG_BLOCKING))
pthread_kill(original->blocker, SIGURG);
- ast_debug(1, "Done Masquerading %s (%d)\n", ast_channel_name(original), original->_state);
+ ast_debug(1, "Done Masquerading %s (%d)\n", ast_channel_name(original), ast_channel_state(original));
if ((bridged = ast_bridged_channel(original))) {
ast_channel_lock(bridged);
@@ -6831,8 +6862,8 @@ void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char
ast_free(chan->caller.ani.number.str);
chan->caller.ani.number.str = ast_strdup(cid_ani);
}
- if (chan->cdr) {
- ast_cdr_setcid(chan->cdr, chan);
+ if (ast_channel_cdr(chan)) {
+ ast_cdr_setcid(ast_channel_cdr(chan), chan);
}
report_new_callerid(chan);
@@ -6874,15 +6905,15 @@ void ast_channel_set_caller_event(struct ast_channel *chan, const struct ast_par
/* The caller id name or number changed. */
report_new_callerid(chan);
}
- if (chan->cdr) {
- ast_cdr_setcid(chan->cdr, chan);
+ if (ast_channel_cdr(chan)) {
+ ast_cdr_setcid(ast_channel_cdr(chan), chan);
}
ast_channel_unlock(chan);
}
int ast_setstate(struct ast_channel *chan, enum ast_channel_state state)
{
- int oldstate = chan->_state;
+ int oldstate = ast_channel_state(chan);
char name[AST_CHANNEL_NAME], *dashptr;
if (oldstate == state)
@@ -6893,7 +6924,7 @@ int ast_setstate(struct ast_channel *chan, enum ast_channel_state state)
*dashptr = '\0';
}
- chan->_state = state;
+ ast_channel_state_set(chan, state);
/* We have to pass AST_DEVICE_UNKNOWN here because it is entirely possible that the channel driver
* for this channel is using the callback method for device state. If we pass in an actual state here
@@ -6910,7 +6941,7 @@ int ast_setstate(struct ast_channel *chan, enum ast_channel_state state)
"ConnectedLineNum: %s\r\n"
"ConnectedLineName: %s\r\n"
"Uniqueid: %s\r\n",
- ast_channel_name(chan), chan->_state, ast_state2str(chan->_state),
+ ast_channel_name(chan), ast_channel_state(chan), ast_state2str(ast_channel_state(chan)),
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, ""),
S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, ""),
S_COR(chan->connected.id.number.valid, chan->connected.id.number.str, ""),
@@ -6925,8 +6956,8 @@ struct ast_channel *ast_bridged_channel(struct ast_channel *chan)
{
struct ast_channel *bridged;
bridged = chan->_bridge;
- if (bridged && bridged->tech->bridged_channel)
- bridged = bridged->tech->bridged_channel(chan, bridged);
+ if (bridged && ast_channel_tech(bridged)->bridged_channel)
+ bridged = ast_channel_tech(bridged)->bridged_channel(chan, bridged);
return bridged;
}
@@ -6982,8 +7013,8 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct
int jb_in_use;
int to;
- o0nativeformats = ast_format_cap_dup(c0->nativeformats);
- o1nativeformats = ast_format_cap_dup(c1->nativeformats);
+ o0nativeformats = ast_format_cap_dup(ast_channel_nativeformats(c0));
+ o1nativeformats = ast_format_cap_dup(ast_channel_nativeformats(c1));
if (!o0nativeformats || !o1nativeformats) {
ast_format_cap_destroy(o0nativeformats); /* NULL safe */
@@ -6993,8 +7024,8 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct
cs[0] = c0;
cs[1] = c1;
- pvt0 = c0->tech_pvt;
- pvt1 = c1->tech_pvt;
+ pvt0 = ast_channel_tech_pvt(c0);
+ pvt1 = ast_channel_tech_pvt(c1);
watch_c0_dtmf = config->flags & AST_BRIDGE_DTMF_CHANNEL_0;
watch_c1_dtmf = config->flags & AST_BRIDGE_DTMF_CHANNEL_1;
@@ -7015,9 +7046,9 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct
for (;;) {
struct ast_channel *who, *other;
- if ((c0->tech_pvt != pvt0) || (c1->tech_pvt != pvt1) ||
- (!ast_format_cap_identical(o0nativeformats, c0->nativeformats)) ||
- (!ast_format_cap_identical(o1nativeformats, c1->nativeformats))) {
+ if ((ast_channel_tech_pvt(c0) != pvt0) || (ast_channel_tech_pvt(c1) != pvt1) ||
+ (!ast_format_cap_identical(o0nativeformats, ast_channel_nativeformats(c0))) ||
+ (!ast_format_cap_identical(o1nativeformats, ast_channel_nativeformats(c1)))) {
/* Check for Masquerade, codec changes, etc */
res = AST_BRIDGE_RETRY;
break;
@@ -7178,10 +7209,10 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct
int ast_channel_early_bridge(struct ast_channel *c0, struct ast_channel *c1)
{
/* Make sure we can early bridge, if not error out */
- if (!c0->tech->early_bridge || (c1 && (!c1->tech->early_bridge || c0->tech->early_bridge != c1->tech->early_bridge)))
+ if (!ast_channel_tech(c0)->early_bridge || (c1 && (!ast_channel_tech(c1)->early_bridge || ast_channel_tech(c0)->early_bridge != ast_channel_tech(c1)->early_bridge)))
return -1;
- return c0->tech->early_bridge(c0, c1);
+ return ast_channel_tech(c0)->early_bridge(c0, c1);
}
/*! \brief Send manager event for bridge link and unlink events.
@@ -7219,8 +7250,8 @@ static void update_bridge_vars(struct ast_channel *c0, struct ast_channel *c1)
ast_channel_lock(c1);
c1_name = ast_strdupa(ast_channel_name(c1));
- if (c1->tech->get_pvt_uniqueid) {
- c1_pvtid = ast_strdupa(c1->tech->get_pvt_uniqueid(c1));
+ if (ast_channel_tech(c1)->get_pvt_uniqueid) {
+ c1_pvtid = ast_strdupa(ast_channel_tech(c1)->get_pvt_uniqueid(c1));
}
ast_channel_unlock(c1);
@@ -7232,8 +7263,8 @@ static void update_bridge_vars(struct ast_channel *c0, struct ast_channel *c1)
pbx_builtin_setvar_helper(c0, "BRIDGEPVTCALLID", c1_pvtid);
}
c0_name = ast_strdupa(ast_channel_name(c0));
- if (c0->tech->get_pvt_uniqueid) {
- c0_pvtid = ast_strdupa(c0->tech->get_pvt_uniqueid(c0));
+ if (ast_channel_tech(c0)->get_pvt_uniqueid) {
+ c0_pvtid = ast_strdupa(ast_channel_tech(c0)->get_pvt_uniqueid(c0));
}
ast_channel_unlock(c0);
@@ -7303,8 +7334,8 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
ast_test_flag(c1, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c1))
return -1;
- o0nativeformats = ast_format_cap_dup(c0->nativeformats);
- o1nativeformats = ast_format_cap_dup(c1->nativeformats);
+ o0nativeformats = ast_format_cap_dup(ast_channel_nativeformats(c0));
+ o1nativeformats = ast_format_cap_dup(ast_channel_nativeformats(c1));
if (!o0nativeformats || !o1nativeformats) {
ast_format_cap_destroy(o0nativeformats);
ast_format_cap_destroy(o1nativeformats);
@@ -7354,9 +7385,9 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
config->nexteventts.tv_usec = 0;
}
- if (!c0->tech->send_digit_begin)
+ if (!ast_channel_tech(c0)->send_digit_begin)
ast_set_flag(c1, AST_FLAG_END_DTMF_ONLY);
- if (!c1->tech->send_digit_begin)
+ if (!ast_channel_tech(c1)->send_digit_begin)
ast_set_flag(c0, AST_FLAG_END_DTMF_ONLY);
manager_bridge_event(1, 1, c0, c1);
@@ -7446,19 +7477,19 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
bridge_play_sounds(c0, c1);
- if (c0->tech->bridge &&
+ if (ast_channel_tech(c0)->bridge &&
/* if < 1 ms remains use generic bridging for accurate timing */
(!config->timelimit || to > 1000 || to == 0) &&
- (c0->tech->bridge == c1->tech->bridge) &&
- !c0->monitor && !c1->monitor &&
- !c0->audiohooks && !c1->audiohooks &&
- ast_framehook_list_is_empty(c0->framehooks) && ast_framehook_list_is_empty(c1->framehooks) &&
- !c0->masq && !c0->masqr && !c1->masq && !c1->masqr) {
+ (ast_channel_tech(c0)->bridge == ast_channel_tech(c1)->bridge) &&
+ !ast_channel_monitor(c0) && !ast_channel_monitor(c1) &&
+ !ast_channel_audiohooks(c0) && !ast_channel_audiohooks(c1) &&
+ ast_framehook_list_is_empty(ast_channel_framehooks(c0)) && ast_framehook_list_is_empty(ast_channel_framehooks(c1)) &&
+ !ast_channel_masq(c0) && !ast_channel_masqr(c0) && !ast_channel_masq(c1) && !ast_channel_masqr(c1)) {
int timeoutms = to - 1000 > 0 ? to - 1000 : to;
/* Looks like they share a bridge method and nothing else is in the way */
ast_set_flag(c0, AST_FLAG_NBRIDGE);
ast_set_flag(c1, AST_FLAG_NBRIDGE);
- if ((res = c0->tech->bridge(c0, c1, config->flags, fo, rc, timeoutms)) == AST_BRIDGE_COMPLETE) {
+ if ((res = ast_channel_tech(c0)->bridge(c0, c1, config->flags, fo, rc, timeoutms)) == AST_BRIDGE_COMPLETE) {
manager_bridge_event(0, 1, c0, c1);
ast_debug(1, "Returning from native bridge, channels: %s, %s\n", ast_channel_name(c0), ast_channel_name(c1));
@@ -7494,9 +7525,9 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
if (((ast_format_cmp(&c1->readformat, &c0->writeformat) == AST_FORMAT_CMP_NOT_EQUAL) ||
(ast_format_cmp(&c0->readformat, &c1->writeformat) == AST_FORMAT_CMP_NOT_EQUAL) ||
- !ast_format_cap_identical(c0->nativeformats, o0nativeformats) ||
- !ast_format_cap_identical(c1->nativeformats, o1nativeformats)) &&
- !(c0->generator || c1->generator)) {
+ !ast_format_cap_identical(ast_channel_nativeformats(c0), o0nativeformats) ||
+ !ast_format_cap_identical(ast_channel_nativeformats(c1), o1nativeformats)) &&
+ !(ast_channel_generator(c0) || ast_channel_generator(c1))) {
if (ast_channel_make_compatible(c0, c1)) {
ast_log(LOG_WARNING, "Can't make %s and %s compatible\n", ast_channel_name(c0), ast_channel_name(c1));
manager_bridge_event(0, 1, c0, c1);
@@ -7505,8 +7536,8 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
return AST_BRIDGE_FAILED;
}
- ast_format_cap_copy(o0nativeformats, c0->nativeformats);
- ast_format_cap_copy(o1nativeformats, c1->nativeformats);
+ ast_format_cap_copy(o0nativeformats, ast_channel_nativeformats(c0));
+ ast_format_cap_copy(o1nativeformats, ast_channel_nativeformats(c1));
}
update_bridge_vars(c0, c1);
@@ -7544,7 +7575,7 @@ int ast_channel_setoption(struct ast_channel *chan, int option, void *data, int
int res;
ast_channel_lock(chan);
- if (!chan->tech->setoption) {
+ if (!ast_channel_tech(chan)->setoption) {
errno = ENOSYS;
ast_channel_unlock(chan);
return -1;
@@ -7553,7 +7584,7 @@ int ast_channel_setoption(struct ast_channel *chan, int option, void *data, int
if (block)
ast_log(LOG_ERROR, "XXX Blocking not implemented yet XXX\n");
- res = chan->tech->setoption(chan, option, data, datalen);
+ res = ast_channel_tech(chan)->setoption(chan, option, data, datalen);
ast_channel_unlock(chan);
return res;
@@ -7564,7 +7595,7 @@ int ast_channel_queryoption(struct ast_channel *chan, int option, void *data, in
int res;
ast_channel_lock(chan);
- if (!chan->tech->queryoption) {
+ if (!ast_channel_tech(chan)->queryoption) {
errno = ENOSYS;
ast_channel_unlock(chan);
return -1;
@@ -7573,7 +7604,7 @@ int ast_channel_queryoption(struct ast_channel *chan, int option, void *data, in
if (block)
ast_log(LOG_ERROR, "XXX Blocking not implemented yet XXX\n");
- res = chan->tech->queryoption(chan, option, data, datalen);
+ res = ast_channel_tech(chan)->queryoption(chan, option, data, datalen);
ast_channel_unlock(chan);
return res;
@@ -7721,7 +7752,7 @@ int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, i
return res;
/* Give us some wiggle room */
- while (chan->generatordata && ast_waitfor(chan, 100) >= 0) {
+ while (ast_channel_generatordata(chan) && ast_waitfor(chan, 100) >= 0) {
struct ast_frame *f = ast_read(chan);
if (f)
ast_frfree(f);
diff --git a/main/channel_internal_api.c b/main/channel_internal_api.c
index 6fc116a31..5a2061952 100644
--- a/main/channel_internal_api.c
+++ b/main/channel_internal_api.c
@@ -1,30 +1,30 @@
/*
- * Asterisk -- An open source telephony toolkit.
+ *Asterisk -- An open source telephony toolkit.
*
- * Copyright (C) 2012, Digium, Inc.
+ *Copyright (C) 2012, Digium, Inc.
*
- * Mark Spencer <markster@digium.com>
+ *Mark Spencer <markster@digium.com>
*
- * See http://www.asterisk.org for more information about
- * the Asterisk project. Please do not directly contact
- * any of the maintainers of this project for assistance;
- * the project provides a web site, mailing lists and IRC
- * channels for your use.
+ *See http://www.asterisk.org for more information about
+ *the Asterisk project. Please do not directly contact
+ *any of the maintainers of this project for assistance;
+ *the project provides a web site, mailing lists and IRC
+ *channels for your use.
*
- * This program is free software, distributed under the terms of
- * the GNU General Public License Version 2. See the LICENSE file
- * at the top of the source tree.
+ *This program is free software, distributed under the terms of
+ *the GNU General Public License Version 2. See the LICENSE file
+ *at the top of the source tree.
*/
/*! \file
*
- * \brief Channel Accessor API
+ *\brief Channel Accessor API
*
- * This file is intended to be the only file that ever accesses the
- * internals of an ast_channel. All other files should use the
- * accessor functions defined here.
+ *This file is intended to be the only file that ever accesses the
+ *internals of an ast_channel. All other files should use the
+ *accessor functions defined here.
*
- * \author Terry Wilson
+ *\author Terry Wilson
*/
#include "asterisk.h"
@@ -67,14 +67,14 @@ AST_DATA_STRUCTURE(ast_callerid, DATA_EXPORT_CALLERID);
MEMBER(ast_channel, __do_not_use_parkinglot, AST_DATA_STRING) \
MEMBER(ast_channel, __do_not_use_hangupsource, AST_DATA_STRING) \
MEMBER(ast_channel, __do_not_use_dialcontext, AST_DATA_STRING) \
- MEMBER(ast_channel, rings, AST_DATA_INTEGER) \
- MEMBER(ast_channel, priority, AST_DATA_INTEGER) \
- MEMBER(ast_channel, macropriority, AST_DATA_INTEGER) \
- MEMBER(ast_channel, adsicpe, AST_DATA_INTEGER) \
- MEMBER(ast_channel, fin, AST_DATA_UNSIGNED_INTEGER) \
- MEMBER(ast_channel, fout, AST_DATA_UNSIGNED_INTEGER) \
- MEMBER(ast_channel, emulate_dtmf_duration, AST_DATA_UNSIGNED_INTEGER) \
- MEMBER(ast_channel, visible_indication, AST_DATA_INTEGER) \
+ MEMBER(ast_channel, __do_not_use_rings, AST_DATA_INTEGER) \
+ MEMBER(ast_channel, __do_not_use_priority, AST_DATA_INTEGER) \
+ MEMBER(ast_channel, __do_not_use_macropriority, AST_DATA_INTEGER) \
+ MEMBER(ast_channel, __do_not_use_adsicpe, AST_DATA_INTEGER) \
+ MEMBER(ast_channel, __do_not_use_fin, AST_DATA_UNSIGNED_INTEGER) \
+ MEMBER(ast_channel, __do_not_use_fout, AST_DATA_UNSIGNED_INTEGER) \
+ MEMBER(ast_channel, __do_not_use_emulate_dtmf_duration, AST_DATA_UNSIGNED_INTEGER) \
+ MEMBER(ast_channel, __do_not_use_visible_indication, AST_DATA_INTEGER) \
MEMBER(ast_channel, __do_not_use_context, AST_DATA_STRING) \
MEMBER(ast_channel, __do_not_use_exten, AST_DATA_STRING) \
MEMBER(ast_channel, __do_not_use_macrocontext, AST_DATA_STRING) \
@@ -142,39 +142,39 @@ int ast_channel_data_add_structure(struct ast_data *tree,
ast_data_add_codec(tree, "writeformat", &chan->writeformat);
ast_data_add_codec(tree, "rawreadformat", &chan->rawreadformat);
ast_data_add_codec(tree, "rawwriteformat", &chan->rawwriteformat);
- ast_data_add_codecs(tree, "nativeformats", chan->nativeformats);
+ ast_data_add_codecs(tree, "nativeformats", ast_channel_nativeformats(chan));
/* state */
enum_node = ast_data_add_node(tree, "state");
if (!enum_node) {
return -1;
}
- ast_data_add_str(enum_node, "text", ast_state2str(chan->_state));
- ast_data_add_int(enum_node, "value", chan->_state);
+ ast_data_add_str(enum_node, "text", ast_state2str(ast_channel_state(chan)));
+ ast_data_add_int(enum_node, "value", ast_channel_state(chan));
/* hangupcause */
enum_node = ast_data_add_node(tree, "hangupcause");
if (!enum_node) {
return -1;
}
- ast_data_add_str(enum_node, "text", ast_cause2str(chan->hangupcause));
- ast_data_add_int(enum_node, "value", chan->hangupcause);
+ ast_data_add_str(enum_node, "text", ast_cause2str(ast_channel_hangupcause(chan)));
+ ast_data_add_int(enum_node, "value", ast_channel_hangupcause(chan));
/* amaflags */
enum_node = ast_data_add_node(tree, "amaflags");
if (!enum_node) {
return -1;
}
- ast_data_add_str(enum_node, "text", ast_cdr_flags2str(chan->amaflags));
- ast_data_add_int(enum_node, "value", chan->amaflags);
+ ast_data_add_str(enum_node, "text", ast_cdr_flags2str(ast_channel_amaflags(chan)));
+ ast_data_add_int(enum_node, "value", ast_channel_amaflags(chan));
/* transfercapability */
enum_node = ast_data_add_node(tree, "transfercapability");
if (!enum_node) {
return -1;
}
- ast_data_add_str(enum_node, "text", ast_transfercapability2str(chan->transfercapability));
- ast_data_add_int(enum_node, "value", chan->transfercapability);
+ ast_data_add_str(enum_node, "text", ast_transfercapability2str(ast_channel_transfercapability(chan)));
+ ast_data_add_int(enum_node, "value", ast_channel_transfercapability(chan));
/* _softphangup */
data_softhangup = ast_data_add_node(tree, "softhangup");
@@ -218,12 +218,12 @@ int ast_channel_data_add_structure(struct ast_data *tree,
#endif
/* tone zone */
- if (chan->zone) {
+ if (ast_channel_zone(chan)) {
data_zones = ast_data_add_node(tree, "zone");
if (!data_zones) {
return -1;
}
- ast_tone_zone_data_add_structure(data_zones, chan->zone);
+ ast_tone_zone_data_add_structure(data_zones, ast_channel_zone(chan));
}
/* insert cdr */
@@ -232,7 +232,7 @@ int ast_channel_data_add_structure(struct ast_data *tree,
return -1;
}
- ast_cdr_data_add_structure(data_cdr, chan->cdr, 1);
+ ast_cdr_data_add_structure(data_cdr, ast_channel_cdr(chan), 1);
return 0;
}
@@ -352,3 +352,335 @@ void ast_channel_macroexten_set(struct ast_channel *chan, const char *value)
{
ast_copy_string(chan->__do_not_use_macroexten, value, sizeof(chan->__do_not_use_macroexten));
}
+
+
+char ast_channel_emulate_dtmf_digit(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_emulate_dtmf_digit;
+}
+void ast_channel_emulate_dtmf_digit_set(struct ast_channel *chan, char value)
+{
+ chan->__do_not_use_emulate_dtmf_digit = value;
+}
+int ast_channel_amaflags(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_amaflags;
+}
+void ast_channel_amaflags_set(struct ast_channel *chan, int value)
+{
+ chan->__do_not_use_amaflags = value;
+}
+#ifdef HAVE_EPOLL
+int ast_channel_epfd(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_epfd;
+}
+void ast_channel_epfd_set(struct ast_channel *chan, int value)
+{
+ chan->__do_not_use_epfd = value;
+}
+#endif
+int ast_channel_fdno(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_fdno;
+}
+void ast_channel_fdno_set(struct ast_channel *chan, int value)
+{
+ chan->__do_not_use_fdno = value;
+}
+int ast_channel_hangupcause(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_hangupcause;
+}
+void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
+{
+ chan->__do_not_use_hangupcause = value;
+}
+int ast_channel_macropriority(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_macropriority;
+}
+void ast_channel_macropriority_set(struct ast_channel *chan, int value)
+{
+ chan->__do_not_use_macropriority = value;
+}
+int ast_channel_priority(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_priority;
+}
+void ast_channel_priority_set(struct ast_channel *chan, int value)
+{
+ chan->__do_not_use_priority = value;
+}
+int ast_channel_rings(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_rings;
+}
+void ast_channel_rings_set(struct ast_channel *chan, int value)
+{
+ chan->__do_not_use_rings = value;
+}
+int ast_channel_streamid(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_streamid;
+}
+void ast_channel_streamid_set(struct ast_channel *chan, int value)
+{
+ chan->__do_not_use_streamid = value;
+}
+int ast_channel_timingfd(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_timingfd;
+}
+void ast_channel_timingfd_set(struct ast_channel *chan, int value)
+{
+ chan->__do_not_use_timingfd = value;
+}
+int ast_channel_visible_indication(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_visible_indication;
+}
+void ast_channel_visible_indication_set(struct ast_channel *chan, int value)
+{
+ chan->__do_not_use_visible_indication = value;
+}
+int ast_channel_vstreamid(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_vstreamid;
+}
+void ast_channel_vstreamid_set(struct ast_channel *chan, int value)
+{
+ chan->__do_not_use_vstreamid = value;
+}
+unsigned short ast_channel_transfercapability(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_transfercapability;
+}
+void ast_channel_transfercapability_set(struct ast_channel *chan, unsigned short value)
+{
+ chan->__do_not_use_transfercapability = value;
+}
+unsigned int ast_channel_emulate_dtmf_duration(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_emulate_dtmf_duration;
+}
+void ast_channel_emulate_dtmf_duration_set(struct ast_channel *chan, unsigned int value)
+{
+ chan->__do_not_use_emulate_dtmf_duration = value;
+}
+unsigned int ast_channel_fin(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_fin;
+}
+void ast_channel_fin_set(struct ast_channel *chan, unsigned int value)
+{
+ chan->__do_not_use_fin = value;
+}
+unsigned int ast_channel_fout(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_fout;
+}
+void ast_channel_fout_set(struct ast_channel *chan, unsigned int value)
+{
+ chan->__do_not_use_fout = value;
+}
+unsigned long ast_channel_insmpl(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_insmpl;
+}
+void ast_channel_insmpl_set(struct ast_channel *chan, unsigned long value)
+{
+ chan->__do_not_use_insmpl = value;
+}
+unsigned long ast_channel_outsmpl(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_outsmpl;
+}
+void ast_channel_outsmpl_set(struct ast_channel *chan, unsigned long value)
+{
+ chan->__do_not_use_outsmpl = value;
+}
+void *ast_channel_generatordata(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_generatordata;
+}
+void ast_channel_generatordata_set(struct ast_channel *chan, void *value)
+{
+ chan->__do_not_use_generatordata = value;
+}
+void *ast_channel_music_state(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_music_state;
+}
+void ast_channel_music_state_set(struct ast_channel *chan, void *value)
+{
+ chan->__do_not_use_music_state = value;
+}
+void *ast_channel_tech_pvt(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_tech_pvt;
+}
+void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)
+{
+ chan->__do_not_use_tech_pvt = value;
+}
+void *ast_channel_timingdata(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_timingdata;
+}
+void ast_channel_timingdata_set(struct ast_channel *chan, void *value)
+{
+ chan->__do_not_use_timingdata = value;
+}
+struct ast_audiohook_list *ast_channel_audiohooks(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_audiohooks;
+}
+void ast_channel_audiohooks_set(struct ast_channel *chan, struct ast_audiohook_list *value)
+{
+ chan->__do_not_use_audiohooks = value;
+}
+struct ast_cdr *ast_channel_cdr(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_cdr;
+}
+void ast_channel_cdr_set(struct ast_channel *chan, struct ast_cdr *value)
+{
+ chan->__do_not_use_cdr = value;
+}
+struct ast_channel *ast_channel_masq(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_masq;
+}
+void ast_channel_masq_set(struct ast_channel *chan, struct ast_channel *value)
+{
+ chan->__do_not_use_masq = value;
+}
+struct ast_channel *ast_channel_masqr(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_masqr;
+}
+void ast_channel_masqr_set(struct ast_channel *chan, struct ast_channel *value)
+{
+ chan->__do_not_use_masqr = value;
+}
+struct ast_channel_monitor *ast_channel_monitor(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_monitor;
+}
+void ast_channel_monitor_set(struct ast_channel *chan, struct ast_channel_monitor *value)
+{
+ chan->__do_not_use_monitor = value;
+}
+struct ast_filestream *ast_channel_stream(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_stream;
+}
+void ast_channel_stream_set(struct ast_channel *chan, struct ast_filestream *value)
+{
+ chan->__do_not_use_stream = value;
+}
+struct ast_filestream *ast_channel_vstream(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_vstream;
+}
+void ast_channel_vstream_set(struct ast_channel *chan, struct ast_filestream *value)
+{
+ chan->__do_not_use_vstream = value;
+}
+struct ast_format_cap *ast_channel_nativeformats(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_nativeformats;
+}
+void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value)
+{
+ chan->__do_not_use_nativeformats = value;
+}
+struct ast_framehook_list *ast_channel_framehooks(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_framehooks;
+}
+void ast_channel_framehooks_set(struct ast_channel *chan, struct ast_framehook_list *value)
+{
+ chan->__do_not_use_framehooks = value;
+}
+struct ast_generator *ast_channel_generator(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_generator;
+}
+void ast_channel_generator_set(struct ast_channel *chan, struct ast_generator *value)
+{
+ chan->__do_not_use_generator = value;
+}
+struct ast_pbx *ast_channel_pbx(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_pbx;
+}
+void ast_channel_pbx_set(struct ast_channel *chan, struct ast_pbx *value)
+{
+ chan->__do_not_use_pbx = value;
+}
+struct ast_sched_context *ast_channel_sched(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_sched;
+}
+void ast_channel_sched_set(struct ast_channel *chan, struct ast_sched_context *value)
+{
+ chan->__do_not_use_sched = value;
+}
+struct ast_timer *ast_channel_timer(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_timer;
+}
+void ast_channel_timer_set(struct ast_channel *chan, struct ast_timer *value)
+{
+ chan->__do_not_use_timer = value;
+}
+struct ast_tone_zone *ast_channel_zone(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_zone;
+}
+void ast_channel_zone_set(struct ast_channel *chan, struct ast_tone_zone *value)
+{
+ chan->__do_not_use_zone = value;
+}
+struct ast_trans_pvt *ast_channel_readtrans(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_readtrans;
+}
+void ast_channel_readtrans_set(struct ast_channel *chan, struct ast_trans_pvt *value)
+{
+ chan->__do_not_use_readtrans = value;
+}
+struct ast_trans_pvt *ast_channel_writetrans(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_writetrans;
+}
+void ast_channel_writetrans_set(struct ast_channel *chan, struct ast_trans_pvt *value)
+{
+ chan->__do_not_use_writetrans = value;
+}
+const struct ast_channel_tech *ast_channel_tech(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_tech;
+}
+void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value)
+{
+ chan->__do_not_use_tech = value;
+}
+enum ast_channel_adsicpe ast_channel_adsicpe(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_adsicpe;
+}
+void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value)
+{
+ chan->__do_not_use_adsicpe = value;
+}
+enum ast_channel_state ast_channel_state(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_state;
+}
+void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state value)
+{
+ chan->__do_not_use_state = value;
+}
diff --git a/main/cli.c b/main/cli.c
index dd4ccf9b9..c6355835b 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -902,8 +902,8 @@ static char *handle_chanlist(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
bc = ast_bridged_channel(c);
if (!count) {
- if ((concise || verbose) && c->cdr && !ast_tvzero(c->cdr->start)) {
- int duration = (int)(ast_tvdiff_ms(ast_tvnow(), c->cdr->start) / 1000);
+ if ((concise || verbose) && ast_channel_cdr(c) && !ast_tvzero(ast_channel_cdr(c)->start)) {
+ int duration = (int)(ast_tvdiff_ms(ast_tvnow(), ast_channel_cdr(c)->start) / 1000);
if (verbose) {
int durh = duration / 3600;
int durm = (duration % 3600) / 60;
@@ -914,18 +914,18 @@ static char *handle_chanlist(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
}
}
if (concise) {
- ast_cli(a->fd, CONCISE_FORMAT_STRING, ast_channel_name(c), ast_channel_context(c), ast_channel_exten(c), c->priority, ast_state2str(c->_state),
+ ast_cli(a->fd, CONCISE_FORMAT_STRING, ast_channel_name(c), ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), ast_state2str(ast_channel_state(c)),
ast_channel_appl(c) ? ast_channel_appl(c) : "(None)",
S_OR(ast_channel_data(c), ""), /* XXX different from verbose ? */
S_COR(c->caller.id.number.valid, c->caller.id.number.str, ""),
S_OR(ast_channel_accountcode(c), ""),
S_OR(ast_channel_peeraccount(c), ""),
- c->amaflags,
+ ast_channel_amaflags(c),
durbuf,
bc ? ast_channel_name(bc) : "(None)",
ast_channel_uniqueid(c));
} else if (verbose) {
- ast_cli(a->fd, VERBOSE_FORMAT_STRING, ast_channel_name(c), ast_channel_context(c), ast_channel_exten(c), c->priority, ast_state2str(c->_state),
+ ast_cli(a->fd, VERBOSE_FORMAT_STRING, ast_channel_name(c), ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), ast_state2str(ast_channel_state(c)),
ast_channel_appl(c) ? ast_channel_appl(c) : "(None)",
ast_channel_data(c) ? S_OR(ast_channel_data(c), "(Empty)" ): "(None)",
S_COR(c->caller.id.number.valid, c->caller.id.number.str, ""),
@@ -938,10 +938,10 @@ static char *handle_chanlist(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
char appdata[40] = "(None)";
if (!ast_strlen_zero(ast_channel_context(c)) && !ast_strlen_zero(ast_channel_exten(c)))
- snprintf(locbuf, sizeof(locbuf), "%s@%s:%d", ast_channel_exten(c), ast_channel_context(c), c->priority);
+ snprintf(locbuf, sizeof(locbuf), "%s@%s:%d", ast_channel_exten(c), ast_channel_context(c), ast_channel_priority(c));
if (ast_channel_appl(c))
snprintf(appdata, sizeof(appdata), "%s(%s)", ast_channel_appl(c), S_OR(ast_channel_data(c), ""));
- ast_cli(a->fd, FORMAT_STRING, ast_channel_name(c), locbuf, ast_state2str(c->_state), appdata);
+ ast_cli(a->fd, FORMAT_STRING, ast_channel_name(c), locbuf, ast_state2str(ast_channel_state(c)), appdata);
}
}
ast_channel_unlock(c);
@@ -1280,13 +1280,13 @@ static int channel_set_debug(void *obj, void *arg, void *data, int flags)
ast_channel_lock(chan);
- if (!(chan->fin & DEBUGCHAN_FLAG) || !(chan->fout & DEBUGCHAN_FLAG)) {
+ if (!(ast_channel_fin(chan) & DEBUGCHAN_FLAG) || !(ast_channel_fout(chan) & DEBUGCHAN_FLAG)) {
if (args->is_off) {
- chan->fin &= ~DEBUGCHAN_FLAG;
- chan->fout &= ~DEBUGCHAN_FLAG;
+ ast_channel_fin_set(chan, ast_channel_fin(chan) & ~DEBUGCHAN_FLAG);
+ ast_channel_fout_set(chan, ast_channel_fout(chan) & ~DEBUGCHAN_FLAG);
} else {
- chan->fin |= DEBUGCHAN_FLAG;
- chan->fout |= DEBUGCHAN_FLAG;
+ ast_channel_fin_set(chan, ast_channel_fin(chan) | DEBUGCHAN_FLAG);
+ ast_channel_fout_set(chan, ast_channel_fout(chan) | DEBUGCHAN_FLAG);
}
ast_cli(args->fd, "Debugging %s on channel %s\n", args->is_off ? "disabled" : "enabled",
ast_channel_name(chan));
@@ -1430,8 +1430,8 @@ static char *handle_showchan(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
ast_channel_lock(c);
- if (c->cdr) {
- elapsed_seconds = now.tv_sec - c->cdr->start.tv_sec;
+ if (ast_channel_cdr(c)) {
+ elapsed_seconds = now.tv_sec - ast_channel_cdr(c)->start.tv_sec;
hour = elapsed_seconds / 3600;
min = (elapsed_seconds % 3600) / 60;
sec = elapsed_seconds % 60;
@@ -1475,27 +1475,27 @@ static char *handle_showchan(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
" Application: %s\n"
" Data: %s\n"
" Blocking in: %s\n",
- ast_channel_name(c), c->tech->type, ast_channel_uniqueid(c), ast_channel_linkedid(c),
+ ast_channel_name(c), ast_channel_tech(c)->type, ast_channel_uniqueid(c), ast_channel_linkedid(c),
S_COR(c->caller.id.number.valid, c->caller.id.number.str, "(N/A)"),
S_COR(c->caller.id.name.valid, c->caller.id.name.str, "(N/A)"),
S_COR(c->connected.id.number.valid, c->connected.id.number.str, "(N/A)"),
S_COR(c->connected.id.name.valid, c->connected.id.name.str, "(N/A)"),
S_OR(c->dialed.number.str, "(N/A)"),
ast_channel_language(c),
- ast_state2str(c->_state), c->_state, c->rings,
- ast_getformatname_multiple(nf, sizeof(nf), c->nativeformats),
+ ast_state2str(ast_channel_state(c)), ast_channel_state(c), ast_channel_rings(c),
+ ast_getformatname_multiple(nf, sizeof(nf), ast_channel_nativeformats(c)),
ast_getformatname(&c->writeformat),
ast_getformatname(&c->readformat),
- c->writetrans ? "Yes" : "No",
- ast_translate_path_to_str(c->writetrans, &write_transpath),
- c->readtrans ? "Yes" : "No",
- ast_translate_path_to_str(c->readtrans, &read_transpath),
+ ast_channel_writetrans(c) ? "Yes" : "No",
+ ast_translate_path_to_str(ast_channel_writetrans(c), &write_transpath),
+ ast_channel_readtrans(c) ? "Yes" : "No",
+ ast_translate_path_to_str(ast_channel_readtrans(c), &read_transpath),
c->fds[0],
- c->fin & ~DEBUGCHAN_FLAG, (c->fin & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
- c->fout & ~DEBUGCHAN_FLAG, (c->fout & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
+ ast_channel_fin(c) & ~DEBUGCHAN_FLAG, (ast_channel_fin(c) & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
+ ast_channel_fout(c) & ~DEBUGCHAN_FLAG, (ast_channel_fout(c) & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
(long)c->whentohangup.tv_sec,
cdrtime, c->_bridge ? ast_channel_name(c->_bridge) : "<none>", ast_bridged_channel(c) ? ast_channel_name(ast_bridged_channel(c)) : "<none>",
- ast_channel_context(c), ast_channel_exten(c), c->priority, c->callgroup, c->pickupgroup, (ast_channel_appl(c) ? ast_channel_appl(c) : "(N/A)" ),
+ ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), c->callgroup, c->pickupgroup, (ast_channel_appl(c) ? ast_channel_appl(c) : "(N/A)" ),
(ast_channel_data(c) ? S_OR(ast_channel_data(c), "(Empty)") : "(None)"),
(ast_test_flag(c, AST_FLAG_BLOCKING) ? ast_channel_blockproc(c) : "(Not Blocking)"));
@@ -1503,7 +1503,7 @@ static char *handle_showchan(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
ast_str_append(&output, 0, " Variables:\n%s\n", ast_str_buffer(obuf));
}
- if (c->cdr && ast_cdr_serialize_variables(c->cdr, &obuf, '=', '\n', 1)) {
+ if (ast_channel_cdr(c) && ast_cdr_serialize_variables(ast_channel_cdr(c), &obuf, '=', '\n', 1)) {
ast_str_append(&output, 0, " CDR Variables:\n%s\n", ast_str_buffer(obuf));
}
diff --git a/main/devicestate.c b/main/devicestate.c
index ab5225bea..1002e3810 100644
--- a/main/devicestate.c
+++ b/main/devicestate.c
@@ -274,7 +274,7 @@ enum ast_device_state ast_parse_device_state(const char *device)
return AST_DEVICE_UNKNOWN;
}
- res = (chan->_state == AST_STATE_RINGING) ? AST_DEVICE_RINGING : AST_DEVICE_INUSE;
+ res = (ast_channel_state(chan) == AST_STATE_RINGING) ? AST_DEVICE_RINGING : AST_DEVICE_INUSE;
chan = ast_channel_unref(chan);
diff --git a/main/dial.c b/main/dial.c
index 528aa18bc..3455ca329 100644
--- a/main/dial.c
+++ b/main/dial.c
@@ -255,7 +255,7 @@ static int begin_dial_channel(struct ast_dial_channel *channel, struct ast_chann
ast_copy_string(numsubst, channel->device, sizeof(numsubst));
if (chan) {
- cap_request = chan->nativeformats;
+ cap_request = ast_channel_nativeformats(chan);
} else {
cap_all_audio = ast_format_cap_alloc_nolock();
ast_format_cap_add_all_by_type(cap_all_audio, AST_FORMAT_TYPE_AUDIO);
@@ -291,8 +291,8 @@ static int begin_dial_channel(struct ast_dial_channel *channel, struct ast_chann
if (ast_strlen_zero(ast_channel_musicclass(channel->owner)))
ast_channel_musicclass_set(channel->owner, ast_channel_musicclass(chan));
- channel->owner->adsicpe = chan->adsicpe;
- channel->owner->transfercapability = chan->transfercapability;
+ ast_channel_adsicpe_set(channel->owner, ast_channel_adsicpe(chan));
+ ast_channel_transfercapability_set(channel->owner, ast_channel_transfercapability(chan));
}
/* Attempt to actually call this device */
diff --git a/main/features.c b/main/features.c
index bf5282ca8..d3c98a474 100644
--- a/main/features.c
+++ b/main/features.c
@@ -672,18 +672,18 @@ static void set_kill_chan_tech(struct ast_channel *chan)
ast_channel_lock(chan);
/* Hangup the channel's physical side */
- if (chan->tech->hangup) {
- chan->tech->hangup(chan);
+ if (ast_channel_tech(chan)->hangup) {
+ ast_channel_tech(chan)->hangup(chan);
}
- if (chan->tech_pvt) {
+ if (ast_channel_tech_pvt(chan)) {
ast_log(LOG_WARNING, "Channel '%s' may not have been hung up properly\n",
ast_channel_name(chan));
- ast_free(chan->tech_pvt);
- chan->tech_pvt = NULL;
+ ast_free(ast_channel_tech_pvt(chan));
+ ast_channel_tech_pvt_set(chan, NULL);
}
/* Install the kill technology and wake up anyone waiting on it. */
- chan->tech = &ast_kill_tech;
+ ast_channel_tech_set(chan, &ast_kill_tech);
for (idx = 0; idx < AST_MAX_FDS; ++idx) {
switch (idx) {
case AST_ALERT_FD:
@@ -839,7 +839,7 @@ static void set_c_e_p(struct ast_channel *chan, const char *context, const char
{
ast_channel_context_set(chan, context);
ast_channel_exten_set(chan, ext);
- chan->priority = pri;
+ ast_channel_priority_set(chan, pri);
}
/*!
@@ -890,7 +890,7 @@ static void check_goto_on_transfer(struct ast_channel *chan)
}
}
ast_parseable_goto(xferchan, goto_on_transfer);
- xferchan->_state = AST_STATE_UP;
+ ast_channel_state_set(xferchan, AST_STATE_UP);
ast_clear_flag(xferchan, AST_FLAGS_ALL);
ast_channel_clear_softhangup(xferchan, AST_SOFTHANGUP_ALL);
@@ -1431,7 +1431,7 @@ static int park_call_full(struct ast_channel *chan, struct ast_channel *peer, st
* the same name we can be tricky and just grab the bridged
* channel from the other side of the local.
*/
- if (!strcasecmp(peer->tech->type, "Local")) {
+ if (!strcasecmp(ast_channel_tech(peer)->type, "Local")) {
struct ast_channel *tmpchan, *base_peer;
char other_side[AST_CHANNEL_NAME];
char *c;
@@ -1472,7 +1472,7 @@ static int park_call_full(struct ast_channel *chan, struct ast_channel *peer, st
S_OR(args->return_ext, S_OR(ast_channel_macroexten(chan), ast_channel_exten(chan))),
sizeof(pu->exten));
pu->priority = args->return_pri ? args->return_pri :
- (chan->macropriority ? chan->macropriority : chan->priority);
+ (ast_channel_macropriority(chan) ? ast_channel_macropriority(chan) : ast_channel_priority(chan));
/*
* If parking a channel directly, don't quite yet get parking
@@ -1636,7 +1636,7 @@ static int masq_park_call(struct ast_channel *rchan, struct ast_channel *peer, s
/* Make a new, channel that we'll use to masquerade in the real one */
chan = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, ast_channel_accountcode(rchan), ast_channel_exten(rchan),
- ast_channel_context(rchan), ast_channel_linkedid(rchan), rchan->amaflags, "Parked/%s", ast_channel_name(rchan));
+ ast_channel_context(rchan), ast_channel_linkedid(rchan), ast_channel_amaflags(rchan), "Parked/%s", ast_channel_name(rchan));
if (!chan) {
ast_log(LOG_WARNING, "Unable to create parked channel\n");
if (!ast_test_flag(args, AST_PARK_OPT_SILENCE)) {
@@ -1687,12 +1687,12 @@ static int masq_park_call(struct ast_channel *rchan, struct ast_channel *peer, s
}
/* Setup the extensions and such */
- set_c_e_p(chan, ast_channel_context(rchan), ast_channel_exten(rchan), rchan->priority);
+ set_c_e_p(chan, ast_channel_context(rchan), ast_channel_exten(rchan), ast_channel_priority(rchan));
/* Setup the macro extension and such */
ast_channel_macrocontext_set(chan, ast_channel_macrocontext(rchan));
ast_channel_macroexten_set(chan, ast_channel_macroexten(rchan));
- chan->macropriority = rchan->macropriority;
+ ast_channel_macropriority_set(chan, ast_channel_macropriority(rchan));
/* Manually do the masquerade to make sure it is complete. */
ast_do_masquerade(chan);
@@ -1896,7 +1896,7 @@ static int builtin_parkcall(struct ast_channel *chan, struct ast_channel *peer,
*/
/* Answer if call is not up */
- if (chan->_state != AST_STATE_UP) {
+ if (ast_channel_state(chan) != AST_STATE_UP) {
/*
* XXX Why are we doing this? Both of the channels should be up
* since you cannot do DTMF features unless you are bridged.
@@ -2034,12 +2034,12 @@ static int builtin_automonitor(struct ast_channel *chan, struct ast_channel *pee
}
}
- if (callee_chan->monitor) {
+ if (ast_channel_monitor(callee_chan)) {
ast_verb(4, "User hit '%s' to stop recording call.\n", code);
if (!ast_strlen_zero(automon_message_stop)) {
play_message_in_bridged_call(caller_chan, callee_chan, automon_message_stop);
}
- callee_chan->monitor->stop(callee_chan, 1);
+ ast_channel_monitor(callee_chan)->stop(callee_chan, 1);
return AST_FEATURE_RETURN_SUCCESS;
}
@@ -2312,32 +2312,32 @@ static int builtin_blindtransfer(struct ast_channel *chan, struct ast_channel *p
pbx_builtin_setvar_helper(transferee, "BLINDTRANSFER", ast_channel_name(transferer));
finishup(transferee);
ast_channel_lock(transferer);
- if (!transferer->cdr) { /* this code should never get called (in a perfect world) */
- transferer->cdr = ast_cdr_alloc();
- if (transferer->cdr) {
- ast_cdr_init(transferer->cdr, transferer); /* initialize our channel's cdr */
- ast_cdr_start(transferer->cdr);
+ if (!ast_channel_cdr(transferer)) { /* this code should never get called (in a perfect world) */
+ ast_channel_cdr_set(transferer, ast_cdr_alloc());
+ if (ast_channel_cdr(transferer)) {
+ ast_cdr_init(ast_channel_cdr(transferer), transferer); /* initialize our channel's cdr */
+ ast_cdr_start(ast_channel_cdr(transferer));
}
}
ast_channel_unlock(transferer);
- if (transferer->cdr) {
- struct ast_cdr *swap = transferer->cdr;
+ if (ast_channel_cdr(transferer)) {
+ struct ast_cdr *swap = ast_channel_cdr(transferer);
ast_debug(1,
"transferer=%s; transferee=%s; lastapp=%s; lastdata=%s; chan=%s; dstchan=%s\n",
- ast_channel_name(transferer), ast_channel_name(transferee), transferer->cdr->lastapp,
- transferer->cdr->lastdata, transferer->cdr->channel,
- transferer->cdr->dstchannel);
+ ast_channel_name(transferer), ast_channel_name(transferee), ast_channel_cdr(transferer)->lastapp,
+ ast_channel_cdr(transferer)->lastdata, ast_channel_cdr(transferer)->channel,
+ ast_channel_cdr(transferer)->dstchannel);
ast_debug(1, "TRANSFEREE; lastapp=%s; lastdata=%s, chan=%s; dstchan=%s\n",
- transferee->cdr->lastapp, transferee->cdr->lastdata, transferee->cdr->channel,
- transferee->cdr->dstchannel);
+ ast_channel_cdr(transferee)->lastapp, ast_channel_cdr(transferee)->lastdata, ast_channel_cdr(transferee)->channel,
+ ast_channel_cdr(transferee)->dstchannel);
ast_debug(1, "transferer_real_context=%s; xferto=%s\n",
transferer_real_context, xferto);
/* swap cdrs-- it will save us some time & work */
- transferer->cdr = transferee->cdr;
- transferee->cdr = swap;
+ ast_channel_cdr_set(transferer, ast_channel_cdr(transferee));
+ ast_channel_cdr_set(transferee, swap);
}
- if (!transferee->pbx) {
+ if (!ast_channel_pbx(transferee)) {
/* Doh! Use our handy async_goto functions */
ast_debug(1, "About to ast_async_goto %s.\n", ast_channel_name(transferee));
if (ast_async_goto(transferee, transferer_real_context, xferto, 1)) {
@@ -2532,7 +2532,7 @@ static int builtin_atxfer(struct ast_channel *chan, struct ast_channel *peer, st
/* Dial party C */
newchan = feature_request_and_dial(transferer, transferer_name_orig, transferer,
- transferee, "Local", transferer->nativeformats, xferto,
+ transferee, "Local", ast_channel_nativeformats(transferer), xferto,
atxfernoanswertimeout, &outstate, ast_channel_language(transferer));
ast_debug(2, "Dial party C result: newchan:%d, outstate:%d\n", !!newchan, outstate);
@@ -2639,7 +2639,7 @@ static int builtin_atxfer(struct ast_channel *chan, struct ast_channel *peer, st
transferer_tech, transferer_name);
newchan = feature_request_and_dial(transferer, transferer_name_orig,
transferee, transferee, transferer_tech,
- transferee->nativeformats, transferer_name,
+ ast_channel_nativeformats(transferee), transferer_name,
atxfernoanswertimeout, &outstate, ast_channel_language(transferer));
ast_debug(2, "Dial party B result: newchan:%d, outstate:%d\n",
!!newchan, outstate);
@@ -2668,7 +2668,7 @@ static int builtin_atxfer(struct ast_channel *chan, struct ast_channel *peer, st
ast_debug(1, "We're retrying to call %s/%s\n", "Local", xferto);
newchan = feature_request_and_dial(transferer, transferer_name_orig,
transferer, transferee, "Local",
- transferee->nativeformats, xferto,
+ ast_channel_nativeformats(transferee), xferto,
atxfernoanswertimeout, &outstate, ast_channel_language(transferer));
ast_debug(2, "Redial party C result: newchan:%d, outstate:%d\n",
!!newchan, outstate);
@@ -2718,21 +2718,21 @@ static int builtin_atxfer(struct ast_channel *chan, struct ast_channel *peer, st
}
/* Give party A a momentary ringback tone during transfer. */
- xferchan->visible_indication = AST_CONTROL_RINGING;
+ ast_channel_visible_indication_set(xferchan, AST_CONTROL_RINGING);
/* Make formats okay */
xferchan->readformat = transferee->readformat;
xferchan->writeformat = transferee->writeformat;
ast_channel_masquerade(xferchan, transferee);
- ast_explicit_goto(xferchan, ast_channel_context(transferee), ast_channel_exten(transferee), transferee->priority);
- xferchan->_state = AST_STATE_UP;
+ ast_explicit_goto(xferchan, ast_channel_context(transferee), ast_channel_exten(transferee), ast_channel_priority(transferee));
+ ast_channel_state_set(xferchan, AST_STATE_UP);
ast_clear_flag(xferchan, AST_FLAGS_ALL);
/* Do the masquerade manually to make sure that is is completed. */
ast_do_masquerade(xferchan);
- newchan->_state = AST_STATE_UP;
+ ast_channel_state_set(newchan, AST_STATE_UP);
ast_clear_flag(newchan, AST_FLAGS_ALL);
tobj = ast_calloc(1, sizeof(*tobj));
if (!tobj) {
@@ -3454,7 +3454,7 @@ static struct ast_channel *feature_request_and_dial(struct ast_channel *caller,
if (ast_call(chan, addr, timeout)) {
ast_log(LOG_NOTICE, "Unable to call channel %s/%s\n", type, addr);
- switch (chan->hangupcause) {
+ switch (ast_channel_hangupcause(chan)) {
case AST_CAUSE_BUSY:
state = AST_CONTROL_BUSY;
break;
@@ -3489,7 +3489,7 @@ static struct ast_channel *feature_request_and_dial(struct ast_channel *caller,
ast_poll_channel_add(caller, chan);
transferee_hungup = 0;
- while (!ast_check_hangup(transferee) && (chan->_state != AST_STATE_UP)) {
+ while (!ast_check_hangup(transferee) && (ast_channel_state(chan) != AST_STATE_UP)) {
int num_chans = 0;
monitor_chans[num_chans++] = transferee;
@@ -3557,7 +3557,7 @@ static struct ast_channel *feature_request_and_dial(struct ast_channel *caller,
}
f = ast_read(chan);
if (f == NULL) { /*doh! where'd he go?*/
- switch (chan->hangupcause) {
+ switch (ast_channel_hangupcause(chan)) {
case AST_CAUSE_BUSY:
state = AST_CONTROL_BUSY;
break;
@@ -3678,7 +3678,7 @@ static struct ast_channel *feature_request_and_dial(struct ast_channel *caller,
done:
ast_indicate(caller, -1);
- if (chan && (ready || chan->_state == AST_STATE_UP)) {
+ if (chan && (ready || ast_channel_state(chan) == AST_STATE_UP)) {
state = AST_CONTROL_ANSWER;
} else if (chan) {
ast_hangup(chan);
@@ -3699,15 +3699,15 @@ void ast_channel_log(char *title, struct ast_channel *chan) /* for debug, this i
{
ast_log(LOG_NOTICE, "______ %s (%lx)______\n", title, (unsigned long) chan);
ast_log(LOG_NOTICE, "CHAN: name: %s; appl: %s; data: %s; contxt: %s; exten: %s; pri: %d;\n",
- ast_channel_name(chan), ast_channel_appl(chan), ast_channel_data(chan), ast_channel_context(chan), ast_channel_exten(chan), chan->priority);
+ ast_channel_name(chan), ast_channel_appl(chan), ast_channel_data(chan), ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan));
ast_log(LOG_NOTICE, "CHAN: acctcode: %s; dialcontext: %s; amaflags: %x; maccontxt: %s; macexten: %s; macpri: %d;\n",
- ast_channel_accountcode(chan), ast_channel_dialcontext(chan), chan->amaflags, ast_channel_macrocontext(chan), ast_channel_macroexten(chan), chan->macropriority);
+ ast_channel_accountcode(chan), ast_channel_dialcontext(chan), ast_channel_amaflags(chan), ast_channel_macrocontext(chan), ast_channel_macroexten(chan), ast_channel_macropriority(chan));
ast_log(LOG_NOTICE, "CHAN: masq: %p; masqr: %p; _bridge: %p; uniqueID: %s; linkedID:%s\n",
- chan->masq, chan->masqr,
+ ast_channel_masq(chan), ast_channel_masqr(chan),
chan->_bridge, ast_channel_uniqueid(chan), ast_channel_linkedid(chan));
- if (chan->masqr) {
+ if (ast_channel_masqr(chan)) {
ast_log(LOG_NOTICE, "CHAN: masquerading as: %s; cdr: %p;\n",
- ast_channel_name(chan->masqr), chan->masqr->cdr);
+ ast_channel_name(ast_channel_masqr(chan)), ast_channel_cdr(ast_channel_masqr(chan)));
}
if (chan->_bridge) {
ast_log(LOG_NOTICE, "CHAN: Bridged to %s\n", ast_channel_name(chan->_bridge));
@@ -3867,8 +3867,8 @@ int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, struct a
int we_disabled_peer_cdr = 0;
struct ast_option_header *aoh;
struct ast_cdr *bridge_cdr = NULL;
- struct ast_cdr *chan_cdr = chan->cdr; /* the proper chan cdr, if there are forked cdrs */
- struct ast_cdr *peer_cdr = peer->cdr; /* the proper chan cdr, if there are forked cdrs */
+ struct ast_cdr *chan_cdr = ast_channel_cdr(chan); /* the proper chan cdr, if there are forked cdrs */
+ struct ast_cdr *peer_cdr = ast_channel_cdr(peer); /* the proper chan cdr, if there are forked cdrs */
struct ast_cdr *new_chan_cdr = NULL; /* the proper chan cdr, if there are forked cdrs */
struct ast_cdr *new_peer_cdr = NULL; /* the proper chan cdr, if there are forked cdrs */
struct ast_silence_generator *silgen = NULL;
@@ -3883,7 +3883,7 @@ int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, struct a
/* This is an interesting case. One example is if a ringing channel gets redirected to
* an extension that picks up a parked call. This will make sure that the call taken
* out of parking gets told that the channel it just got bridged to is still ringing. */
- if (chan->_state == AST_STATE_RINGING && peer->visible_indication != AST_CONTROL_RINGING) {
+ if (ast_channel_state(chan) == AST_STATE_RINGING && ast_channel_visible_indication(peer) != AST_CONTROL_RINGING) {
ast_indicate(peer, AST_CONTROL_RINGING);
}
@@ -3907,7 +3907,7 @@ int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, struct a
set_config_flags(chan, config);
/* Answer if need be */
- if (chan->_state != AST_STATE_UP) {
+ if (ast_channel_state(chan) != AST_STATE_UP) {
if (ast_raw_answer(chan, 1)) {
return -1;
}
@@ -3922,19 +3922,19 @@ int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, struct a
ast_channel_set_linkgroup(chan,peer);
/* copy the userfield from the B-leg to A-leg if applicable */
- if (chan->cdr && peer->cdr && !ast_strlen_zero(peer->cdr->userfield)) {
+ if (ast_channel_cdr(chan) && ast_channel_cdr(peer) && !ast_strlen_zero(ast_channel_cdr(peer)->userfield)) {
char tmp[256];
ast_channel_lock(chan);
- if (!ast_strlen_zero(chan->cdr->userfield)) {
- snprintf(tmp, sizeof(tmp), "%s;%s", chan->cdr->userfield, peer->cdr->userfield);
+ if (!ast_strlen_zero(ast_channel_cdr(chan)->userfield)) {
+ snprintf(tmp, sizeof(tmp), "%s;%s", ast_channel_cdr(chan)->userfield, ast_channel_cdr(peer)->userfield);
ast_cdr_appenduserfield(chan, tmp);
} else {
- ast_cdr_setuserfield(chan, peer->cdr->userfield);
+ ast_cdr_setuserfield(chan, ast_channel_cdr(peer)->userfield);
}
ast_channel_unlock(chan);
/* Don't delete the CDR; just disable it. */
- ast_set_flag(peer->cdr, AST_CDR_FLAG_POST_DISABLED);
+ ast_set_flag(ast_channel_cdr(peer), AST_CDR_FLAG_POST_DISABLED);
we_disabled_peer_cdr = 1;
}
ast_copy_string(orig_channame,ast_channel_name(chan),sizeof(orig_channame));
@@ -3965,8 +3965,8 @@ int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, struct a
ast_copy_string(bridge_cdr->lastapp, S_OR(ast_channel_appl(chan), ""), sizeof(bridge_cdr->lastapp));
ast_copy_string(bridge_cdr->lastdata, S_OR(ast_channel_data(chan), ""), sizeof(bridge_cdr->lastdata));
ast_cdr_setcid(bridge_cdr, chan);
- bridge_cdr->disposition = (chan->_state == AST_STATE_UP) ? AST_CDR_ANSWERED : AST_CDR_NULL;
- bridge_cdr->amaflags = chan->amaflags ? chan->amaflags : ast_default_amaflags;
+ bridge_cdr->disposition = (ast_channel_state(chan) == AST_STATE_UP) ? AST_CDR_ANSWERED : AST_CDR_NULL;
+ bridge_cdr->amaflags = ast_channel_amaflags(chan) ? ast_channel_amaflags(chan) : ast_default_amaflags;
ast_copy_string(bridge_cdr->accountcode, ast_channel_accountcode(chan), sizeof(bridge_cdr->accountcode));
/* Destination information */
ast_copy_string(bridge_cdr->dst, ast_channel_exten(chan), sizeof(bridge_cdr->dst));
@@ -4341,41 +4341,41 @@ before_you_go:
dialplan code operate on it */
ast_channel_lock(chan);
if (bridge_cdr) {
- swapper = chan->cdr;
+ swapper = ast_channel_cdr(chan);
ast_copy_string(savelastapp, bridge_cdr->lastapp, sizeof(bridge_cdr->lastapp));
ast_copy_string(savelastdata, bridge_cdr->lastdata, sizeof(bridge_cdr->lastdata));
- chan->cdr = bridge_cdr;
+ ast_channel_cdr_set(chan, bridge_cdr);
}
ast_copy_string(save_context, ast_channel_context(chan), sizeof(save_context));
ast_copy_string(save_exten, ast_channel_exten(chan), sizeof(save_exten));
- save_prio = chan->priority;
+ save_prio = ast_channel_priority(chan);
if (h_context != ast_channel_context(chan)) {
ast_channel_context_set(chan, h_context);
}
ast_channel_exten_set(chan, "h");
- chan->priority = 1;
+ ast_channel_priority_set(chan, 1);
ast_channel_unlock(chan);
while ((spawn_error = ast_spawn_extension(chan, ast_channel_context(chan), ast_channel_exten(chan),
- chan->priority,
+ ast_channel_priority(chan),
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL),
&found, 1)) == 0) {
- chan->priority++;
+ ast_channel_priority_set(chan, ast_channel_priority(chan) + 1);
}
if (found && spawn_error) {
/* Something bad happened, or a hangup has been requested. */
- ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", ast_channel_context(chan), ast_channel_exten(chan), chan->priority, ast_channel_name(chan));
- ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", ast_channel_context(chan), ast_channel_exten(chan), chan->priority, ast_channel_name(chan));
+ ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan), ast_channel_name(chan));
+ ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan), ast_channel_name(chan));
}
/* swap it back */
ast_channel_lock(chan);
ast_channel_context_set(chan, save_context);
ast_channel_exten_set(chan, save_exten);
- chan->priority = save_prio;
+ ast_channel_priority_set(chan, save_prio);
if (bridge_cdr) {
- if (chan->cdr == bridge_cdr) {
- chan->cdr = swapper;
+ if (ast_channel_cdr(chan) == bridge_cdr) {
+ ast_channel_cdr_set(chan, swapper);
} else {
bridge_cdr = NULL;
}
@@ -4393,7 +4393,7 @@ before_you_go:
}
/* obey the NoCDR() wishes. -- move the DISABLED flag to the bridge CDR if it was set on the channel during the bridge... */
- new_chan_cdr = pick_unlocked_cdr(chan->cdr); /* the proper chan cdr, if there are forked cdrs */
+ new_chan_cdr = pick_unlocked_cdr(ast_channel_cdr(chan)); /* the proper chan cdr, if there are forked cdrs */
if (bridge_cdr && new_chan_cdr && ast_test_flag(new_chan_cdr, AST_CDR_FLAG_POST_DISABLED))
ast_set_flag(bridge_cdr, AST_CDR_FLAG_POST_DISABLED);
@@ -4436,7 +4436,7 @@ before_you_go:
ast_channel_lock(chan_ptr);
if (!ast_bridged_channel(chan_ptr)) {
struct ast_cdr *cur;
- for (cur = chan_ptr->cdr; cur; cur = cur->next) {
+ for (cur = ast_channel_cdr(chan_ptr); cur; cur = cur->next) {
if (cur == chan_cdr) {
break;
}
@@ -4451,13 +4451,13 @@ before_you_go:
/* new channel */
ast_cdr_specialized_reset(new_chan_cdr, 0);
} else {
- ast_cdr_specialized_reset(chan->cdr, 0); /* nothing changed, reset the chan cdr */
+ ast_cdr_specialized_reset(ast_channel_cdr(chan), 0); /* nothing changed, reset the chan cdr */
}
}
{
struct ast_channel *chan_ptr = NULL;
- new_peer_cdr = pick_unlocked_cdr(peer->cdr); /* the proper chan cdr, if there are forked cdrs */
+ new_peer_cdr = pick_unlocked_cdr(ast_channel_cdr(peer)); /* the proper chan cdr, if there are forked cdrs */
if (new_chan_cdr && ast_test_flag(new_chan_cdr, AST_CDR_FLAG_POST_DISABLED) && new_peer_cdr && !ast_test_flag(new_peer_cdr, AST_CDR_FLAG_POST_DISABLED))
ast_set_flag(new_peer_cdr, AST_CDR_FLAG_POST_DISABLED); /* DISABLED is viral-- it will propagate across a bridge */
if (strcasecmp(orig_peername, ast_channel_name(peer)) != 0) {
@@ -4466,7 +4466,7 @@ before_you_go:
ast_channel_lock(chan_ptr);
if (!ast_bridged_channel(chan_ptr)) {
struct ast_cdr *cur;
- for (cur = chan_ptr->cdr; cur; cur = cur->next) {
+ for (cur = ast_channel_cdr(chan_ptr); cur; cur = cur->next) {
if (cur == peer_cdr) {
break;
}
@@ -4484,9 +4484,9 @@ before_you_go:
}
} else {
if (we_disabled_peer_cdr) {
- ast_clear_flag(peer->cdr, AST_CDR_FLAG_POST_DISABLED);
+ ast_clear_flag(ast_channel_cdr(peer), AST_CDR_FLAG_POST_DISABLED);
}
- ast_cdr_specialized_reset(peer->cdr, 0); /* nothing changed, reset the peer cdr */
+ ast_cdr_specialized_reset(ast_channel_cdr(peer), 0); /* nothing changed, reset the peer cdr */
}
}
@@ -4687,7 +4687,7 @@ static int manage_parked_call(struct parkeduser *pu, const struct pollfd *pfds,
ast_verb(2, "Timeout for %s parked on %d (%s). Returning to %s,%s,%d\n",
ast_channel_name(pu->chan), pu->parkingnum, pu->parkinglot->name, ast_channel_context(pu->chan),
- ast_channel_exten(pu->chan), pu->chan->priority);
+ ast_channel_exten(pu->chan), ast_channel_priority(pu->chan));
/* Start up the PBX, or hang them up */
if (ast_pbx_start(chan)) {
@@ -4729,7 +4729,7 @@ static int manage_parked_call(struct parkeduser *pu, const struct pollfd *pfds,
} else {
ast_clear_flag(chan, AST_FLAG_EXCEPTION);
}
- chan->fdno = x;
+ ast_channel_fdno_set(chan, x);
/* See if they need servicing */
f = ast_read(pu->chan);
@@ -4755,7 +4755,7 @@ static int manage_parked_call(struct parkeduser *pu, const struct pollfd *pfds,
ast_frfree(f);
if (pu->hold_method == AST_CONTROL_HOLD
&& pu->moh_trys < 3
- && !chan->generatordata) {
+ && !ast_channel_generatordata(chan)) {
ast_debug(1,
"MOH on parked call stopped by outside source. Restarting on channel %s.\n",
ast_channel_name(chan));
@@ -4936,7 +4936,7 @@ static int park_call_exec(struct ast_channel *chan, const char *data)
struct park_app_args app_args;
/* Answer if call is not up */
- if (chan->_state != AST_STATE_UP) {
+ if (ast_channel_state(chan) != AST_STATE_UP) {
if (ast_answer(chan)) {
return -1;
}
@@ -4978,9 +4978,9 @@ static int park_call_exec(struct ast_channel *chan, const char *data)
* this call should return.
*/
ast_copy_string(orig_exten, ast_channel_exten(chan), sizeof(orig_exten));
- orig_priority = chan->priority;
+ orig_priority = ast_channel_priority(chan);
ast_channel_exten_set(chan, "s");
- chan->priority = 1;
+ ast_channel_priority_set(chan, 1);
/* Park the call */
if (!ast_strlen_zero(app_args.pl_name)) {
@@ -5010,7 +5010,7 @@ static int park_call_exec(struct ast_channel *chan, const char *data)
if (res) {
/* Park failed, try to continue in the dialplan. */
ast_channel_exten_set(chan, orig_exten);
- chan->priority = orig_priority;
+ ast_channel_priority_set(chan, orig_priority);
res = 0;
} else {
/* Park succeeded. */
@@ -5061,7 +5061,7 @@ static int parked_call_exec(struct ast_channel *chan, const char *data)
parkinglot = find_parkinglot(pl_name);
if (!parkinglot) {
/* It helps to answer the channel if not already up. :) */
- if (chan->_state != AST_STATE_UP) {
+ if (ast_channel_state(chan) != AST_STATE_UP) {
ast_answer(chan);
}
if (ast_stream_and_wait(chan, "pbx-invalidpark", "")) {
@@ -5078,7 +5078,7 @@ static int parked_call_exec(struct ast_channel *chan, const char *data)
AST_LIST_LOCK(&parkinglot->parkings);
AST_LIST_TRAVERSE_SAFE_BEGIN(&parkinglot->parkings, pu, list) {
if ((ast_strlen_zero(app_args.pl_space) || pu->parkingnum == park)
- && !pu->notquiteyet && !pu->chan->pbx) {
+ && !pu->notquiteyet && !ast_channel_pbx(pu->chan)) {
/* The parking space has a call and can be picked up now. */
AST_LIST_REMOVE_CURRENT(list);
break;
@@ -5171,7 +5171,7 @@ static int parked_call_exec(struct ast_channel *chan, const char *data)
}
/* JK02: it helps to answer the channel if not already up */
- if (chan->_state != AST_STATE_UP) {
+ if (ast_channel_state(chan) != AST_STATE_UP) {
ast_answer(chan);
}
@@ -5216,7 +5216,7 @@ static int parked_call_exec(struct ast_channel *chan, const char *data)
ast_verb(3, "Channel %s connected to parked call %d\n", ast_channel_name(chan), park);
pbx_builtin_setvar_helper(chan, "PARKEDCHANNEL", ast_channel_name(peer));
- ast_cdr_setdestchan(chan->cdr, ast_channel_name(peer));
+ ast_cdr_setdestchan(ast_channel_cdr(chan), ast_channel_name(peer));
memset(&config, 0, sizeof(struct ast_bridge_config));
/* Get datastore for peer and apply it's features to the callee side of the bridge config */
@@ -5266,7 +5266,7 @@ static int parked_call_exec(struct ast_channel *chan, const char *data)
res = ast_bridge_call(chan, peer, &config);
pbx_builtin_setvar_helper(chan, "PARKEDCHANNEL", ast_channel_name(peer));
- ast_cdr_setdestchan(chan->cdr, ast_channel_name(peer));
+ ast_cdr_setdestchan(ast_channel_cdr(chan), ast_channel_name(peer));
/* Simulate the PBX hanging up */
ast_hangup(peer);
@@ -6811,7 +6811,7 @@ static void do_bridge_masquerade(struct ast_channel *chan, struct ast_channel *t
{
ast_moh_stop(chan);
ast_channel_lock_both(chan, tmpchan);
- ast_setstate(tmpchan, chan->_state);
+ ast_setstate(tmpchan, ast_channel_state(chan));
tmpchan->readformat = chan->readformat;
tmpchan->writeformat = chan->writeformat;
ast_channel_unlock(chan);
@@ -6823,7 +6823,7 @@ static void do_bridge_masquerade(struct ast_channel *chan, struct ast_channel *t
ast_do_masquerade(tmpchan);
/* when returning from bridge, the channel will continue at the next priority */
- ast_explicit_goto(tmpchan, ast_channel_context(chan), ast_channel_exten(chan), chan->priority + 1);
+ ast_explicit_goto(tmpchan, ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan) + 1);
}
/*!
@@ -6867,7 +6867,7 @@ static int action_bridge(struct mansession *s, const struct message *m)
}
/* Answer the channels if needed */
- if (chana->_state != AST_STATE_UP)
+ if (ast_channel_state(chana) != AST_STATE_UP)
ast_answer(chana);
/* create the placeholder channels and grab the other channels */
@@ -6894,7 +6894,7 @@ static int action_bridge(struct mansession *s, const struct message *m)
}
/* Answer the channels if needed */
- if (chanb->_state != AST_STATE_UP)
+ if (ast_channel_state(chanb) != AST_STATE_UP)
ast_answer(chanb);
/* create the placeholder channels and grab the other channels */
@@ -7196,16 +7196,16 @@ static const struct ast_datastore_info pickup_active = {
int ast_can_pickup(struct ast_channel *chan)
{
- if (!chan->pbx && !chan->masq && !ast_test_flag(chan, AST_FLAG_ZOMBIE)
- && (chan->_state == AST_STATE_RINGING
- || chan->_state == AST_STATE_RING
+ if (!ast_channel_pbx(chan) && !ast_channel_masq(chan) && !ast_test_flag(chan, AST_FLAG_ZOMBIE)
+ && (ast_channel_state(chan) == AST_STATE_RINGING
+ || ast_channel_state(chan) == AST_STATE_RING
/*
* Check the down state as well because some SIP devices do not
* give 180 ringing when they can just give 183 session progress
* instead. Issue 14005. (Some ISDN switches as well for that
* matter.)
*/
- || chan->_state == AST_STATE_DOWN)
+ || ast_channel_state(chan) == AST_STATE_DOWN)
&& !ast_channel_datastore_find(chan, &pickup_active, NULL)) {
return 1;
}
@@ -7557,7 +7557,7 @@ static int bridge_exec(struct ast_channel *chan, const char *data)
}
/* answer the channel if needed */
- if (current_dest_chan->_state != AST_STATE_UP) {
+ if (ast_channel_state(current_dest_chan) != AST_STATE_UP) {
ast_answer(current_dest_chan);
}
@@ -7637,7 +7637,7 @@ static int bridge_exec(struct ast_channel *chan, const char *data)
if (!ast_check_hangup(final_dest_chan) && !ast_test_flag(&opts, OPT_CALLEE_KILL)) {
ast_debug(1, "starting new PBX in %s,%s,%d for chan %s\n",
ast_channel_context(final_dest_chan), ast_channel_exten(final_dest_chan),
- final_dest_chan->priority, ast_channel_name(final_dest_chan));
+ ast_channel_priority(final_dest_chan), ast_channel_name(final_dest_chan));
if (ast_pbx_start(final_dest_chan) != AST_PBX_SUCCESS) {
ast_log(LOG_WARNING, "FAILED continuing PBX on dest chan %s\n", ast_channel_name(final_dest_chan));
@@ -7919,14 +7919,14 @@ static struct ast_channel *create_test_channel(const struct ast_channel_tech *fa
}
/* normally this is done in the channel driver */
- ast_format_cap_add(test_channel1->nativeformats, ast_format_set(&tmp_fmt, AST_FORMAT_GSM, 0));
+ ast_format_cap_add(ast_channel_nativeformats(test_channel1), ast_format_set(&tmp_fmt, AST_FORMAT_GSM, 0));
ast_format_set(&test_channel1->writeformat, AST_FORMAT_GSM, 0);
ast_format_set(&test_channel1->rawwriteformat, AST_FORMAT_GSM, 0);
ast_format_set(&test_channel1->readformat, AST_FORMAT_GSM, 0);
ast_format_set(&test_channel1->rawreadformat, AST_FORMAT_GSM, 0);
- test_channel1->tech = fake_tech;
+ ast_channel_tech_set(test_channel1, fake_tech);
return test_channel1;
}
diff --git a/main/file.c b/main/file.c
index 3befcaedf..5341e8f18 100644
--- a/main/file.c
+++ b/main/file.c
@@ -128,16 +128,16 @@ int ast_stopstream(struct ast_channel *tmp)
ast_channel_lock(tmp);
/* Stop a running stream if there is one */
- if (tmp->stream) {
- ast_closestream(tmp->stream);
- tmp->stream = NULL;
+ if (ast_channel_stream(tmp)) {
+ ast_closestream(ast_channel_stream(tmp));
+ ast_channel_stream_set(tmp, NULL);
if (tmp->oldwriteformat.id && ast_set_write_format(tmp, &tmp->oldwriteformat))
ast_log(LOG_WARNING, "Unable to restore format back to %s\n", ast_getformatname(&tmp->oldwriteformat));
}
/* Stop the video stream too */
- if (tmp->vstream != NULL) {
- ast_closestream(tmp->vstream);
- tmp->vstream = NULL;
+ if (ast_channel_vstream(tmp) != NULL) {
+ ast_closestream(ast_channel_vstream(tmp));
+ ast_channel_vstream_set(tmp, NULL);
}
ast_channel_unlock(tmp);
@@ -300,13 +300,13 @@ static void filestream_close(struct ast_filestream *f)
switch (format_type)
{
case AST_FORMAT_TYPE_AUDIO:
- f->owner->stream = NULL;
- AST_SCHED_DEL(f->owner->sched, f->owner->streamid);
+ ast_channel_stream_set(f->owner, NULL);
+ AST_SCHED_DEL_ACCESSOR(ast_channel_sched(f->owner), f->owner, ast_channel_streamid, ast_channel_streamid_set);
ast_settimeout(f->owner, 0, NULL, NULL);
break;
case AST_FORMAT_TYPE_VIDEO:
- f->owner->vstream = NULL;
- AST_SCHED_DEL(f->owner->sched, f->owner->vstreamid);
+ ast_channel_vstream_set(f->owner, NULL);
+ AST_SCHED_DEL_ACCESSOR(ast_channel_sched(f->owner), f->owner, ast_channel_vstreamid, ast_channel_vstreamid_set);
break;
default:
ast_log(AST_LOG_WARNING, "Unable to schedule deletion of filestream with unsupported type %s\n", f->fmt->name);
@@ -498,13 +498,13 @@ static int filehelper(const char *filename, const void *arg2, const char *fmt, c
s->trans = NULL;
s->filename = NULL;
if (AST_FORMAT_GET_TYPE(s->fmt->format.id) == AST_FORMAT_TYPE_AUDIO) {
- if (chan->stream)
- ast_closestream(chan->stream);
- chan->stream = s;
+ if (ast_channel_stream(chan))
+ ast_closestream(ast_channel_stream(chan));
+ ast_channel_stream_set(chan, s);
} else {
- if (chan->vstream)
- ast_closestream(chan->vstream);
- chan->vstream = s;
+ if (ast_channel_vstream(chan))
+ ast_closestream(ast_channel_vstream(chan));
+ ast_channel_vstream_set(chan, s);
}
ast_free(fn);
break;
@@ -679,7 +679,7 @@ struct ast_filestream *ast_openstream_full(struct ast_channel *chan, const char
if (!asis) {
/* do this first, otherwise we detect the wrong writeformat */
ast_stopstream(chan);
- if (chan->generator)
+ if (ast_channel_generator(chan))
ast_deactivate_generator(chan);
}
if (preflang == NULL)
@@ -712,7 +712,7 @@ struct ast_filestream *ast_openstream_full(struct ast_channel *chan, const char
}
res = filehelper(buf, chan, NULL, ACTION_OPEN);
if (res >= 0)
- return chan->stream;
+ return ast_channel_stream(chan);
return NULL;
}
@@ -736,7 +736,7 @@ struct ast_filestream *ast_openvstream(struct ast_channel *chan, const char *fil
return NULL;
/* is the channel capable of video without translation ?*/
- if (!ast_format_cap_has_type(chan->nativeformats, AST_FORMAT_TYPE_VIDEO)) {
+ if (!ast_format_cap_has_type(ast_channel_nativeformats(chan), AST_FORMAT_TYPE_VIDEO)) {
return NULL;
}
if (!(tmp_cap = ast_format_cap_alloc_nolock())) {
@@ -753,7 +753,7 @@ struct ast_filestream *ast_openvstream(struct ast_channel *chan, const char *fil
while (!ast_format_cap_iter_next(tmp_cap, &tmp_fmt)) {
fmt = ast_getformatname(&tmp_fmt);
if ((AST_FORMAT_GET_TYPE(tmp_fmt.id) != AST_FORMAT_TYPE_VIDEO) ||
- !ast_format_cap_iscompatible(chan->nativeformats, &tmp_fmt)) {
+ !ast_format_cap_iscompatible(ast_channel_nativeformats(chan), &tmp_fmt)) {
continue;
}
@@ -761,7 +761,7 @@ struct ast_filestream *ast_openvstream(struct ast_channel *chan, const char *fil
if (fd >= 0) {
ast_format_cap_iter_end(tmp_cap);
tmp_cap = ast_format_cap_destroy(tmp_cap);
- return chan->vstream;
+ return ast_channel_vstream(chan);
}
ast_log(LOG_WARNING, "File %s has video but couldn't be opened\n", filename);
}
@@ -838,7 +838,7 @@ static enum fsread_res ast_readaudio_callback(struct ast_filestream *s)
}
if (whennext != s->lasttimeout) {
- if (s->owner->timingfd > -1) {
+ if (ast_channel_timingfd(s->owner) > -1) {
float samp_rate = (float) ast_format_rate(&s->fmt->format);
unsigned int rate;
@@ -846,8 +846,7 @@ static enum fsread_res ast_readaudio_callback(struct ast_filestream *s)
ast_settimeout(s->owner, rate, ast_fsread_audio, s);
} else {
- s->owner->streamid = ast_sched_add(s->owner->sched,
- whennext / (ast_format_rate(&s->fmt->format) / 1000), ast_fsread_audio, s);
+ ast_channel_streamid_set(s->owner, ast_sched_add(ast_channel_sched(s->owner), whennext / (ast_format_rate(&s->fmt->format) / 1000), ast_fsread_audio, s));
}
s->lasttimeout = whennext;
return FSREAD_SUCCESS_NOSCHED;
@@ -855,7 +854,7 @@ static enum fsread_res ast_readaudio_callback(struct ast_filestream *s)
return FSREAD_SUCCESS_SCHED;
return_failure:
- s->owner->streamid = -1;
+ ast_channel_streamid_set(s->owner, -1);
ast_settimeout(s->owner, 0, NULL, NULL);
return FSREAD_FAILURE;
}
@@ -887,7 +886,7 @@ static enum fsread_res ast_readvideo_callback(struct ast_filestream *s)
ast_log(LOG_WARNING, "Failed to write frame\n");
ast_frfree(fr);
}
- s->owner->vstreamid = -1;
+ ast_channel_vstreamid_set(s->owner, -1);
return FSREAD_FAILURE;
}
@@ -897,9 +896,7 @@ static enum fsread_res ast_readvideo_callback(struct ast_filestream *s)
}
if (whennext != s->lasttimeout) {
- s->owner->vstreamid = ast_sched_add(s->owner->sched,
- whennext / (ast_format_rate(&s->fmt->format) / 1000),
- ast_fsread_video, s);
+ ast_channel_vstreamid_set(s->owner, ast_sched_add(ast_channel_sched(s->owner), whennext / (ast_format_rate(&s->fmt->format) / 1000), ast_fsread_video, s));
s->lasttimeout = whennext;
return FSREAD_SUCCESS_NOSCHED;
}
@@ -1018,7 +1015,7 @@ int ast_streamfile(struct ast_channel *chan, const char *filename, const char *p
fs = ast_openstream(chan, filename, preflang);
if (!fs) {
- ast_log(LOG_WARNING, "Unable to open %s (format %s): %s\n", filename, ast_getformatname_multiple(fmt, sizeof(fmt), chan->nativeformats), strerror(errno));
+ ast_log(LOG_WARNING, "Unable to open %s (format %s): %s\n", filename, ast_getformatname_multiple(fmt, sizeof(fmt), ast_channel_nativeformats(chan)), strerror(errno));
return -1;
}
@@ -1260,7 +1257,7 @@ static int waitstream_core(struct ast_channel *c, const char *breakon,
if (ast_test_flag(c, AST_FLAG_MASQ_NOSTREAM))
orig_chan_name = ast_strdupa(ast_channel_name(c));
- while (c->stream) {
+ while (ast_channel_stream(c)) {
int res;
int ms;
@@ -1270,7 +1267,7 @@ static int waitstream_core(struct ast_channel *c, const char *breakon,
break;
}
- ms = ast_sched_wait(c->sched);
+ ms = ast_sched_wait(ast_channel_sched(c));
if (ms < 0 && !c->timingfunc) {
ast_stopstream(c);
@@ -1324,15 +1321,15 @@ static int waitstream_core(struct ast_channel *c, const char *breakon,
res = fr->subclass.integer;
if (strchr(forward, res)) {
int eoftest;
- ast_stream_fastforward(c->stream, skip_ms);
- eoftest = fgetc(c->stream->f);
- if (feof(c->stream->f)) {
- ast_stream_rewind(c->stream, skip_ms);
+ ast_stream_fastforward(ast_channel_stream(c), skip_ms);
+ eoftest = fgetc(ast_channel_stream(c)->f);
+ if (feof(ast_channel_stream(c)->f)) {
+ ast_stream_rewind(ast_channel_stream(c), skip_ms);
} else {
- ungetc(eoftest, c->stream->f);
+ ungetc(eoftest, ast_channel_stream(c)->f);
}
} else if (strchr(reverse, res)) {
- ast_stream_rewind(c->stream, skip_ms);
+ ast_stream_rewind(ast_channel_stream(c), skip_ms);
} else if (strchr(breakon, res)) {
ast_frfree(fr);
ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
@@ -1379,7 +1376,7 @@ static int waitstream_core(struct ast_channel *c, const char *breakon,
}
ast_frfree(fr);
}
- ast_sched_runq(c->sched);
+ ast_sched_runq(ast_channel_sched(c));
}
ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
diff --git a/main/framehook.c b/main/framehook.c
index 2d5fd5a47..14f619866 100644
--- a/main/framehook.c
+++ b/main/framehook.c
@@ -90,6 +90,7 @@ static struct ast_frame *framehook_list_push_event(struct ast_framehook_list *fr
int ast_framehook_attach(struct ast_channel *chan, struct ast_framehook_interface *i)
{
struct ast_framehook *framehook;
+ struct ast_framehook_list *fh_list;
struct ast_frame *frame;
if (i->version != AST_FRAMEHOOK_INTERFACE_VERSION) {
ast_log(LOG_ERROR, "Version '%hu' of framehook interface not what we compiled against (%hu)\n",
@@ -103,13 +104,14 @@ int ast_framehook_attach(struct ast_channel *chan, struct ast_framehook_interfac
framehook->chan = chan;
/* create the framehook list if it didn't already exist */
- if (!chan->framehooks && !(chan->framehooks = ast_calloc(1, sizeof(*chan->framehooks)))) {
+ if (!ast_channel_framehooks(chan) && !(fh_list = ast_calloc(1, sizeof(*ast_channel_framehooks(chan))))) {
ast_free(framehook);
return -1;
}
- framehook->id = ++chan->framehooks->id_count;
- AST_LIST_INSERT_TAIL(&chan->framehooks->list, framehook, list);
+ ast_channel_framehooks_set(chan, fh_list);
+ framehook->id = ++ast_channel_framehooks(chan)->id_count;
+ AST_LIST_INSERT_TAIL(&ast_channel_framehooks(chan)->list, framehook, list);
/* Tell the event callback we're live and rocking */
frame = framehook->i.event_cb(framehook->chan, NULL, AST_FRAMEHOOK_EVENT_ATTACHED, framehook->i.data);
@@ -128,11 +130,11 @@ int ast_framehook_detach(struct ast_channel *chan, int id)
struct ast_framehook *framehook;
int res = -1;
- if (!chan->framehooks) {
+ if (!ast_channel_framehooks(chan)) {
return res;
}
- AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->framehooks->list, framehook, list) {
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&ast_channel_framehooks(chan)->list, framehook, list) {
if (framehook->id == id) {
/* we mark for detachment rather than doing explicitly here because
* it needs to be safe for this function to be called within the
@@ -152,16 +154,16 @@ int ast_framehook_list_destroy(struct ast_channel *chan)
{
struct ast_framehook *framehook;
- if (!chan->framehooks) {
+ if (!ast_channel_framehooks(chan)) {
return 0;
}
- AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->framehooks->list, framehook, list) {
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&ast_channel_framehooks(chan)->list, framehook, list) {
AST_LIST_REMOVE_CURRENT(list);
framehook_detach_and_destroy(framehook);
}
AST_LIST_TRAVERSE_SAFE_END;
- ast_free(chan->framehooks);
- chan->framehooks = NULL;
+ ast_free(ast_channel_framehooks(chan));
+ ast_channel_framehooks_set(chan, NULL);
return 0;
}
diff --git a/main/image.c b/main/image.c
index 0e956b0c9..35e8d6d5c 100644
--- a/main/image.c
+++ b/main/image.c
@@ -64,9 +64,9 @@ void ast_image_unregister(struct ast_imager *img)
int ast_supports_images(struct ast_channel *chan)
{
- if (!chan || !chan->tech)
+ if (!chan || !ast_channel_tech(chan))
return 0;
- if (!chan->tech->send_image)
+ if (!ast_channel_tech(chan)->send_image)
return 0;
return 1;
}
@@ -157,10 +157,10 @@ int ast_send_image(struct ast_channel *chan, const char *filename)
{
struct ast_frame *f;
int res = -1;
- if (chan->tech->send_image) {
+ if (ast_channel_tech(chan)->send_image) {
f = ast_read_image(filename, ast_channel_language(chan), NULL);
if (f) {
- res = chan->tech->send_image(chan, f);
+ res = ast_channel_tech(chan)->send_image(chan, f);
ast_frfree(f);
}
}
diff --git a/main/manager.c b/main/manager.c
index c538a29f0..8fa1041c4 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -3157,8 +3157,8 @@ static int action_hangup(struct mansession *s, const struct message *m)
ast_channel_lock(c);
if (causecode > 0) {
ast_debug(1, "Setting hangupcause of channel %s to %d (is %d now)\n",
- ast_channel_name(c), causecode, c->hangupcause);
- c->hangupcause = causecode;
+ ast_channel_name(c), causecode, ast_channel_hangupcause(c));
+ ast_channel_hangupcause_set(c, causecode);
}
ast_softhangup_nolock(c, AST_SOFTHANGUP_EXPLICIT);
ast_channel_unlock(c);
@@ -3326,9 +3326,9 @@ static int action_status(struct mansession *s, const struct message *m)
} else {
bridge[0] = '\0';
}
- if (c->pbx) {
- if (c->cdr) {
- elapsed_seconds = now.tv_sec - c->cdr->start.tv_sec;
+ if (ast_channel_pbx(c)) {
+ if (ast_channel_cdr(c)) {
+ elapsed_seconds = now.tv_sec - ast_channel_cdr(c)->start.tv_sec;
}
astman_append(s,
"Event: Status\r\n"
@@ -3356,9 +3356,9 @@ static int action_status(struct mansession *s, const struct message *m)
S_COR(c->connected.id.number.valid, c->connected.id.number.str, "<unknown>"),
S_COR(c->connected.id.name.valid, c->connected.id.name.str, "<unknown>"),
ast_channel_accountcode(c),
- c->_state,
- ast_state2str(c->_state), ast_channel_context(c),
- ast_channel_exten(c), c->priority, (long)elapsed_seconds, bridge, ast_channel_uniqueid(c), ast_str_buffer(str), idText);
+ ast_channel_state(c),
+ ast_state2str(ast_channel_state(c)), ast_channel_context(c),
+ ast_channel_exten(c), ast_channel_priority(c), (long)elapsed_seconds, bridge, ast_channel_uniqueid(c), ast_str_buffer(str), idText);
} else {
astman_append(s,
"Event: Status\r\n"
@@ -3381,7 +3381,7 @@ static int action_status(struct mansession *s, const struct message *m)
S_COR(c->connected.id.number.valid, c->connected.id.number.str, "<unknown>"),
S_COR(c->connected.id.name.valid, c->connected.id.name.str, "<unknown>"),
ast_channel_accountcode(c),
- ast_state2str(c->_state), bridge, ast_channel_uniqueid(c),
+ ast_state2str(ast_channel_state(c)), bridge, ast_channel_uniqueid(c),
ast_str_buffer(str), idText);
}
@@ -3500,7 +3500,7 @@ static int action_redirect(struct mansession *s, const struct message *m)
return 0;
}
- if (chan->pbx) {
+ if (ast_channel_pbx(chan)) {
ast_channel_lock(chan);
ast_set_flag(chan, AST_FLAG_BRIDGE_HANGUP_DONT); /* don't let the after-bridge code run the h-exten */
ast_channel_unlock(chan);
@@ -3510,7 +3510,7 @@ static int action_redirect(struct mansession *s, const struct message *m)
if (!res) {
if (!ast_strlen_zero(name2)) {
if (chan2) {
- if (chan2->pbx) {
+ if (ast_channel_pbx(chan2)) {
ast_channel_lock(chan2);
ast_set_flag(chan2, AST_FLAG_BRIDGE_HANGUP_DONT); /* don't let the after-bridge code run the h-exten */
ast_channel_unlock(chan2);
@@ -4577,8 +4577,8 @@ static int action_coreshowchannels(struct mansession *s, const struct message *m
ast_channel_lock(c);
bc = ast_bridged_channel(c);
- if (c->cdr && !ast_tvzero(c->cdr->start)) {
- duration = (int)(ast_tvdiff_ms(ast_tvnow(), c->cdr->start) / 1000);
+ if (ast_channel_cdr(c) && !ast_tvzero(ast_channel_cdr(c)->start)) {
+ duration = (int)(ast_tvdiff_ms(ast_tvnow(), ast_channel_cdr(c)->start) / 1000);
durh = duration / 3600;
durm = (duration % 3600) / 60;
durs = duration % 60;
@@ -4605,8 +4605,8 @@ static int action_coreshowchannels(struct mansession *s, const struct message *m
"AccountCode: %s\r\n"
"BridgedChannel: %s\r\n"
"BridgedUniqueID: %s\r\n"
- "\r\n", idText, ast_channel_name(c), ast_channel_uniqueid(c), ast_channel_context(c), ast_channel_exten(c), c->priority, c->_state,
- ast_state2str(c->_state), ast_channel_appl(c) ? ast_channel_appl(c) : "", ast_channel_data(c) ? S_OR(ast_channel_data(c), "") : "",
+ "\r\n", idText, ast_channel_name(c), ast_channel_uniqueid(c), ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), ast_channel_state(c),
+ ast_state2str(ast_channel_state(c)), ast_channel_appl(c) ? ast_channel_appl(c) : "", ast_channel_data(c) ? S_OR(ast_channel_data(c), "") : "",
S_COR(c->caller.id.number.valid, c->caller.id.number.str, ""),
S_COR(c->caller.id.name.valid, c->caller.id.name.str, ""),
S_COR(c->connected.id.number.valid, c->connected.id.number.str, ""),
diff --git a/main/message.c b/main/message.c
index c4d2c4372..1e575f2e2 100644
--- a/main/message.c
+++ b/main/message.c
@@ -616,7 +616,7 @@ static struct ast_channel *create_msg_q_chan(void)
ast_channel_unlink(chan);
- chan->tech = &msg_chan_tech_hack;
+ ast_channel_tech_set(chan, &msg_chan_tech_hack);
if (!(ds = ast_datastore_alloc(&msg_datastore, NULL))) {
ast_hangup(chan);
diff --git a/main/pbx.c b/main/pbx.c
index 436dc87da..626d6e8aa 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -1529,8 +1529,8 @@ int pbx_exec(struct ast_channel *c, /*!< Channel */
const char *saved_c_appl;
const char *saved_c_data;
- if (c->cdr && !ast_check_hangup(c))
- ast_cdr_setapp(c->cdr, app->name, data);
+ if (ast_channel_cdr(c) && !ast_check_hangup(c))
+ ast_cdr_setapp(ast_channel_cdr(c), app->name, data);
/* save channel values */
saved_c_appl= ast_channel_appl(c);
@@ -3314,14 +3314,14 @@ const char *ast_str_retrieve_variable(struct ast_str **str, ssize_t maxlen, stru
} else if (!strcmp(var, "CONTEXT")) {
s = ast_channel_context(c);
} else if (!strcmp(var, "PRIORITY")) {
- ast_str_set(str, maxlen, "%d", c->priority);
+ ast_str_set(str, maxlen, "%d", ast_channel_priority(c));
s = ast_str_buffer(*str);
} else if (!strcmp(var, "CHANNEL")) {
s = ast_channel_name(c);
} else if (!strcmp(var, "UNIQUEID")) {
s = ast_channel_uniqueid(c);
} else if (!strcmp(var, "HANGUPCAUSE")) {
- ast_str_set(str, maxlen, "%d", c->hangupcause);
+ ast_str_set(str, maxlen, "%d", ast_channel_hangupcause(c));
s = ast_str_buffer(*str);
}
}
@@ -3438,7 +3438,7 @@ static int raise_exception(struct ast_channel *chan, const char *reason, int pri
ast_string_field_set(exception, reason, reason);
ast_string_field_set(exception, context, ast_channel_context(chan));
ast_string_field_set(exception, exten, ast_channel_exten(chan));
- exception->priority = chan->priority;
+ exception->priority = ast_channel_priority(chan);
set_ext_pri(chan, "e", priority);
return 0;
}
@@ -4363,7 +4363,7 @@ static int pbx_extension_helper(struct ast_channel *c, struct ast_context *con,
ast_channel_context_set(c, context);
if (ast_channel_exten(c) != exten)
ast_channel_exten_set(c, exten);
- c->priority = priority;
+ ast_channel_priority_set(c, priority);
pbx_substitute_variables(passdata, sizeof(passdata), c, e);
#ifdef CHANNEL_TRACE
ast_channel_trace_update(c);
@@ -4386,7 +4386,7 @@ static int pbx_extension_helper(struct ast_channel *c, struct ast_context *con,
"Application: %s\r\n"
"AppData: %s\r\n"
"Uniqueid: %s\r\n",
- ast_channel_name(c), ast_channel_context(c), ast_channel_exten(c), c->priority, app->name, passdata, ast_channel_uniqueid(c));
+ ast_channel_name(c), ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), app->name, passdata, ast_channel_uniqueid(c));
return pbx_exec(c, app, passdata); /* 0 on success, -1 on failure */
}
} else if (q.swo) { /* not found here, but in another switch */
@@ -5058,7 +5058,7 @@ static void set_ext_pri(struct ast_channel *c, const char *exten, int pri)
{
ast_channel_lock(c);
ast_channel_exten_set(c, exten);
- c->priority = pri;
+ ast_channel_priority_set(c, pri);
ast_channel_unlock(c);
}
@@ -5090,7 +5090,7 @@ static int collect_digits(struct ast_channel *c, int waittime, char *buf, int bu
buf[pos++] = digit;
buf[pos] = '\0';
}
- waittime = c->pbx->dtimeoutms;
+ waittime = ast_channel_pbx(c)->dtimeoutms;
}
}
return 0;
@@ -5103,25 +5103,28 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
int res = 0;
int autoloopflag;
int error = 0; /* set an error conditions */
+ struct ast_pbx *pbx;
/* A little initial setup here */
- if (c->pbx) {
+ if (ast_channel_pbx(c)) {
ast_log(LOG_WARNING, "%s already has PBX structure??\n", ast_channel_name(c));
/* XXX and now what ? */
- ast_free(c->pbx);
+ ast_free(ast_channel_pbx(c));
}
- if (!(c->pbx = ast_calloc(1, sizeof(*c->pbx))))
+ if (!(pbx = ast_calloc(1, sizeof(*pbx)))) {
return -1;
+ }
+ ast_channel_pbx_set(c, pbx);
/* Set reasonable defaults */
- c->pbx->rtimeoutms = 10000;
- c->pbx->dtimeoutms = 5000;
+ ast_channel_pbx(c)->rtimeoutms = 10000;
+ ast_channel_pbx(c)->dtimeoutms = 5000;
autoloopflag = ast_test_flag(c, AST_FLAG_IN_AUTOLOOP); /* save value to restore at the end */
ast_set_flag(c, AST_FLAG_IN_AUTOLOOP);
if (ast_strlen_zero(ast_channel_exten(c))) {
/* If not successful fall back to 's' - but only if there is no given exten */
- ast_verb(2, "Starting %s at %s,%s,%d failed so falling back to exten 's'\n", ast_channel_name(c), ast_channel_context(c), ast_channel_exten(c), c->priority);
+ ast_verb(2, "Starting %s at %s,%s,%d failed so falling back to exten 's'\n", ast_channel_name(c), ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c));
/* XXX the original code used the existing priority in the call to
* ast_exists_extension(), and reset it to 1 afterwards.
* I believe the correct thing is to set it to 1 immediately.
@@ -5130,7 +5133,7 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
}
ast_channel_lock(c);
- if (c->cdr) {
+ if (ast_channel_cdr(c)) {
/* allow CDR variables that have been collected after channel was created to be visible during call */
ast_cdr_update(c);
}
@@ -5143,11 +5146,11 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
int timeout = 0;
/* loop on priorities in this context/exten */
- while (!(res = ast_spawn_extension(c, ast_channel_context(c), ast_channel_exten(c), c->priority,
+ while (!(res = ast_spawn_extension(c, ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c),
S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL),
&found, 1))) {
if (!ast_check_hangup(c)) {
- ++c->priority;
+ ast_channel_priority_set(c, ast_channel_priority(c) + 1);
continue;
}
@@ -5178,7 +5181,7 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
break;
}
ast_debug(1, "Extension %s, priority %d returned normally even though call was hung up\n",
- ast_channel_exten(c), c->priority);
+ ast_channel_exten(c), ast_channel_priority(c));
error = 1;
break;
} /* end while - from here on we can use 'break' to go out */
@@ -5190,8 +5193,8 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
dst_exten[pos++] = digit = res;
dst_exten[pos] = '\0';
} else if (res == AST_PBX_INCOMPLETE) {
- ast_debug(1, "Spawn extension (%s,%s,%d) exited INCOMPLETE on '%s'\n", ast_channel_context(c), ast_channel_exten(c), c->priority, ast_channel_name(c));
- ast_verb(2, "Spawn extension (%s, %s, %d) exited INCOMPLETE on '%s'\n", ast_channel_context(c), ast_channel_exten(c), c->priority, ast_channel_name(c));
+ ast_debug(1, "Spawn extension (%s,%s,%d) exited INCOMPLETE on '%s'\n", ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), ast_channel_name(c));
+ ast_verb(2, "Spawn extension (%s, %s, %d) exited INCOMPLETE on '%s'\n", ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), ast_channel_name(c));
/* Don't cycle on incomplete - this will happen if the only extension that matches is our "incomplete" extension */
if (!ast_matchmore_extension(c, ast_channel_context(c), ast_channel_exten(c), 1,
@@ -5203,15 +5206,15 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
pos = strlen(dst_exten);
}
} else {
- ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", ast_channel_context(c), ast_channel_exten(c), c->priority, ast_channel_name(c));
- ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", ast_channel_context(c), ast_channel_exten(c), c->priority, ast_channel_name(c));
+ ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), ast_channel_name(c));
+ ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), ast_channel_name(c));
if ((res == AST_PBX_ERROR)
&& ast_exists_extension(c, ast_channel_context(c), "e", 1,
S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL))) {
/* if we are already on the 'e' exten, don't jump to it again */
if (!strcmp(ast_channel_exten(c), "e")) {
- ast_verb(2, "Spawn extension (%s, %s, %d) exited ERROR while already on 'e' exten on '%s'\n", ast_channel_context(c), ast_channel_exten(c), c->priority, ast_channel_name(c));
+ ast_verb(2, "Spawn extension (%s, %s, %d) exited ERROR while already on 'e' exten on '%s'\n", ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), ast_channel_name(c));
error = 1;
} else {
raise_exception(c, "ERROR", 1);
@@ -5242,7 +5245,7 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
/* Call timed out with no special extension to jump to. */
}
ast_channel_lock(c);
- if (c->cdr) {
+ if (ast_channel_cdr(c)) {
ast_cdr_update(c);
}
ast_channel_unlock(c);
@@ -5286,9 +5289,9 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
} else { /* keypress received, get more digits for a full extension */
int waittime = 0;
if (digit)
- waittime = c->pbx->dtimeoutms;
+ waittime = ast_channel_pbx(c)->dtimeoutms;
else if (!autofallthrough)
- waittime = c->pbx->rtimeoutms;
+ waittime = ast_channel_pbx(c)->rtimeoutms;
if (!waittime) {
const char *status = pbx_builtin_getvar_helper(c, "DIALSTATUS");
if (!status)
@@ -5350,7 +5353,7 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
}
}
ast_channel_lock(c);
- if (c->cdr) {
+ if (ast_channel_cdr(c)) {
ast_verb(2, "CDR updated on %s\n",ast_channel_name(c));
ast_cdr_update(c);
}
@@ -5371,24 +5374,24 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
&& ast_exists_extension(c, ast_channel_context(c), "h", 1,
S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL))) {
set_ext_pri(c, "h", 1);
- if (c->cdr && ast_opt_end_cdr_before_h_exten) {
- ast_cdr_end(c->cdr);
+ if (ast_channel_cdr(c) && ast_opt_end_cdr_before_h_exten) {
+ ast_cdr_end(ast_channel_cdr(c));
}
- while ((res = ast_spawn_extension(c, ast_channel_context(c), ast_channel_exten(c), c->priority,
+ while ((res = ast_spawn_extension(c, ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c),
S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL),
&found, 1)) == 0) {
- c->priority++;
+ ast_channel_priority_set(c, ast_channel_priority(c) + 1);
}
if (found && res) {
/* Something bad happened, or a hangup has been requested. */
- ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", ast_channel_context(c), ast_channel_exten(c), c->priority, ast_channel_name(c));
- ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", ast_channel_context(c), ast_channel_exten(c), c->priority, ast_channel_name(c));
+ ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), ast_channel_name(c));
+ ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), ast_channel_name(c));
}
}
ast_set2_flag(c, autoloopflag, AST_FLAG_IN_AUTOLOOP);
ast_clear_flag(c, AST_FLAG_BRIDGE_HANGUP_RUN); /* from one round to the next, make sure this gets cleared */
- pbx_destroy(c->pbx);
- c->pbx = NULL;
+ pbx_destroy(ast_channel_pbx(c));
+ ast_channel_pbx_set(c, NULL);
if (!args || !args->no_hangup_chan) {
ast_hangup(c);
@@ -8297,10 +8300,11 @@ int ast_explicit_goto(struct ast_channel *chan, const char *context, const char
if (!ast_strlen_zero(exten))
ast_channel_exten_set(chan, exten);
if (priority > -1) {
- chan->priority = priority;
+ ast_channel_priority_set(chan, priority);
/* see flag description in channel.h for explanation */
- if (ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP))
- chan->priority--;
+ if (ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP)) {
+ ast_channel_priority_set(chan, ast_channel_priority(chan) - 1);
+ }
}
ast_channel_unlock(chan);
@@ -8326,7 +8330,7 @@ int ast_async_goto(struct ast_channel *chan, const char *context, const char *ex
} tmpvars = { 0, };
ast_channel_lock(chan);
- if (chan->pbx) { /* This channel is currently in the PBX */
+ if (ast_channel_pbx(chan)) { /* This channel is currently in the PBX */
ast_explicit_goto(chan, context, exten, priority + 1);
ast_softhangup_nolock(chan, AST_SOFTHANGUP_ASYNCGOTO);
ast_channel_unlock(chan);
@@ -8341,11 +8345,11 @@ int ast_async_goto(struct ast_channel *chan, const char *context, const char *ex
tmpvars.context = ast_strdupa(ast_channel_context(chan));
tmpvars.linkedid = ast_strdupa(ast_channel_linkedid(chan));
tmpvars.name = ast_strdupa(ast_channel_name(chan));
- tmpvars.amaflags = chan->amaflags;
- tmpvars.state = chan->_state;
+ tmpvars.amaflags = ast_channel_amaflags(chan);
+ tmpvars.state = ast_channel_state(chan);
ast_format_copy(&tmpvars.writeformat, &chan->writeformat);
ast_format_copy(&tmpvars.readformat, &chan->readformat);
- tmpvars.cdr = chan->cdr ? ast_cdr_dup(chan->cdr) : NULL;
+ tmpvars.cdr = ast_channel_cdr(chan) ? ast_cdr_dup(ast_channel_cdr(chan)) : NULL;
ast_channel_unlock(chan);
@@ -8358,8 +8362,8 @@ int ast_async_goto(struct ast_channel *chan, const char *context, const char *ex
/* copy the cdr info over */
if (tmpvars.cdr) {
- ast_cdr_discard(tmpchan->cdr);
- tmpchan->cdr = tmpvars.cdr;
+ ast_cdr_discard(ast_channel_cdr(tmpchan));
+ ast_channel_cdr_set(tmpchan, tmpvars.cdr);
tmpvars.cdr = NULL;
}
@@ -8856,7 +8860,7 @@ static void *async_wait(void *data)
struct ast_frame *f;
struct ast_app *app;
- while (timeout && (chan->_state != AST_STATE_UP)) {
+ while (timeout && (ast_channel_state(chan) != AST_STATE_UP)) {
res = ast_waitfor(chan, timeout);
if (res < 1)
break;
@@ -8874,7 +8878,7 @@ static void *async_wait(void *data)
}
ast_frfree(f);
}
- if (chan->_state == AST_STATE_UP) {
+ if (ast_channel_state(chan) == AST_STATE_UP) {
if (!ast_strlen_zero(as->app)) {
app = pbx_findapp(as->app);
if (app) {
@@ -8888,7 +8892,7 @@ static void *async_wait(void *data)
if (!ast_strlen_zero(as->exten))
ast_channel_exten_set(chan, as->exten);
if (as->priority > 0)
- chan->priority = as->priority;
+ ast_channel_priority_set(chan, as->priority);
/* Run the PBX */
if (ast_pbx_run(chan)) {
ast_log(LOG_ERROR, "Failed to start PBX on %s\n", ast_channel_name(chan));
@@ -8916,20 +8920,20 @@ static int ast_pbx_outgoing_cdr_failed(void)
if (!chan)
return -1; /* failure */
- chan->cdr = ast_cdr_alloc();
- if (!chan->cdr) {
+ ast_channel_cdr_set(chan, ast_cdr_alloc());
+ if (!ast_channel_cdr(chan)) {
/* allocation of the cdr failed */
chan = ast_channel_unref(chan); /* free the channel */
return -1; /* return failure */
}
/* allocation of the cdr was successful */
- ast_cdr_init(chan->cdr, chan); /* initialize our channel's cdr */
- ast_cdr_start(chan->cdr); /* record the start and stop time */
- ast_cdr_end(chan->cdr);
- ast_cdr_failed(chan->cdr); /* set the status to failed */
- ast_cdr_detach(chan->cdr); /* post and free the record */
- chan->cdr = NULL;
+ ast_cdr_init(ast_channel_cdr(chan), chan); /* initialize our channel's cdr */
+ ast_cdr_start(ast_channel_cdr(chan)); /* record the start and stop time */
+ ast_cdr_end(ast_channel_cdr(chan));
+ ast_cdr_failed(ast_channel_cdr(chan)); /* set the status to failed */
+ ast_cdr_detach(ast_channel_cdr(chan)); /* post and free the record */
+ ast_channel_cdr_set(chan, NULL);
chan = ast_channel_unref(chan); /* free the channel */
return 0; /* success */
@@ -8959,7 +8963,7 @@ int ast_pbx_outgoing_exten(const char *type, struct ast_format_cap *cap, const c
ast_channel_lock(chan);
}
if (chan) {
- if (chan->_state == AST_STATE_UP) {
+ if (ast_channel_state(chan) == AST_STATE_UP) {
res = 0;
ast_verb(4, "Channel %s was answered.\n", ast_channel_name(chan));
@@ -8989,11 +8993,11 @@ int ast_pbx_outgoing_exten(const char *type, struct ast_format_cap *cap, const c
} else {
ast_verb(4, "Channel %s was never answered.\n", ast_channel_name(chan));
- if (chan->cdr) { /* update the cdr */
+ if (ast_channel_cdr(chan)) { /* update the cdr */
/* here we update the status of the call, which sould be busy.
* if that fails then we set the status to failed */
- if (ast_cdr_disposition(chan->cdr, chan->hangupcause))
- ast_cdr_failed(chan->cdr);
+ if (ast_cdr_disposition(ast_channel_cdr(chan), ast_channel_hangupcause(chan)))
+ ast_cdr_failed(ast_channel_cdr(chan));
}
if (channel) {
@@ -9127,7 +9131,7 @@ int ast_pbx_outgoing_app(const char *type, struct ast_format_cap *cap, const cha
ast_set_variables(chan, vars);
if (account)
ast_cdr_setaccount(chan, account);
- if (chan->_state == AST_STATE_UP) {
+ if (ast_channel_state(chan) == AST_STATE_UP) {
res = 0;
ast_verb(4, "Channel %s was answered.\n", ast_channel_name(chan));
tmp = ast_calloc(1, sizeof(*tmp));
@@ -9163,11 +9167,11 @@ int ast_pbx_outgoing_app(const char *type, struct ast_format_cap *cap, const cha
}
} else {
ast_verb(4, "Channel %s was never answered.\n", ast_channel_name(chan));
- if (chan->cdr) { /* update the cdr */
+ if (ast_channel_cdr(chan)) { /* update the cdr */
/* here we update the status of the call, which sould be busy.
* if that fails then we set the status to failed */
- if (ast_cdr_disposition(chan->cdr, chan->hangupcause))
- ast_cdr_failed(chan->cdr);
+ if (ast_cdr_disposition(ast_channel_cdr(chan), ast_channel_hangupcause(chan)))
+ ast_cdr_failed(ast_channel_cdr(chan));
}
ast_hangup(chan);
}
@@ -9499,9 +9503,9 @@ static int pbx_builtin_busy(struct ast_channel *chan, const char *data)
ast_indicate(chan, AST_CONTROL_BUSY);
/* Don't change state of an UP channel, just indicate
busy in audio */
- if (chan->_state != AST_STATE_UP) {
+ if (ast_channel_state(chan) != AST_STATE_UP) {
ast_setstate(chan, AST_STATE_BUSY);
- ast_cdr_busy(chan->cdr);
+ ast_cdr_busy(ast_channel_cdr(chan));
}
wait_for_hangup(chan, data);
return -1;
@@ -9515,9 +9519,9 @@ static int pbx_builtin_congestion(struct ast_channel *chan, const char *data)
ast_indicate(chan, AST_CONTROL_CONGESTION);
/* Don't change state of an UP channel, just indicate
congestion in audio */
- if (chan->_state != AST_STATE_UP) {
+ if (ast_channel_state(chan) != AST_STATE_UP) {
ast_setstate(chan, AST_STATE_BUSY);
- ast_cdr_congestion(chan->cdr);
+ ast_cdr_congestion(ast_channel_cdr(chan));
}
wait_for_hangup(chan, data);
return -1;
@@ -9544,7 +9548,7 @@ static int pbx_builtin_answer(struct ast_channel *chan, const char *data)
AST_STANDARD_APP_ARGS(args, parse);
- if (!ast_strlen_zero(args.delay) && (chan->_state != AST_STATE_UP))
+ if (!ast_strlen_zero(args.delay) && (ast_channel_state(chan) != AST_STATE_UP))
delay = atoi(data);
if (delay < 0) {
@@ -9571,7 +9575,7 @@ static int pbx_builtin_incomplete(struct ast_channel *chan, const char *data)
/* If the channel is hungup, stop waiting */
if (ast_check_hangup(chan)) {
return -1;
- } else if (chan->_state != AST_STATE_UP && answer) {
+ } else if (ast_channel_state(chan) != AST_STATE_UP && answer) {
__ast_answer(chan, 0, 1);
}
@@ -9600,7 +9604,7 @@ static int pbx_builtin_resetcdr(struct ast_channel *chan, const char *data)
ast_app_parse_options(resetcdr_opts, &flags, NULL, args);
}
- ast_cdr_reset(chan->cdr, &flags);
+ ast_cdr_reset(ast_channel_cdr(chan), &flags);
return 0;
}
@@ -9629,21 +9633,21 @@ static int pbx_builtin_hangup(struct ast_channel *chan, const char *data)
char *endptr;
if ((cause = ast_str2cause(data)) > -1) {
- chan->hangupcause = cause;
+ ast_channel_hangupcause_set(chan, cause);
return -1;
}
cause = strtol((const char *) data, &endptr, 10);
if (cause != 0 || (data != endptr)) {
- chan->hangupcause = cause;
+ ast_channel_hangupcause_set(chan, cause);
return -1;
}
ast_log(LOG_WARNING, "Invalid cause given to Hangup(): \"%s\"\n", (char *) data);
}
- if (!chan->hangupcause) {
- chan->hangupcause = AST_CAUSE_NORMAL_CLEARING;
+ if (!ast_channel_hangupcause(chan)) {
+ ast_channel_hangupcause_set(chan, AST_CAUSE_NORMAL_CLEARING);
}
return -1;
@@ -9827,7 +9831,7 @@ static int pbx_builtin_waitexten(struct ast_channel *chan, const char *data)
} else if (ast_test_flag(&flags, WAITEXTEN_MOH)) {
ast_indicate_data(chan, AST_CONTROL_HOLD, S_OR(opts[0], NULL), strlen(opts[0]));
} else if (ast_test_flag(&flags, WAITEXTEN_DIALTONE)) {
- struct ast_tone_zone_sound *ts = ast_get_indication_tone(chan->zone, "dial");
+ struct ast_tone_zone_sound *ts = ast_get_indication_tone(ast_channel_zone(chan), "dial");
if (ts) {
ast_playtones_start(chan, 0, ts->data, 0);
ts = ast_tone_zone_sound_unref(ts);
@@ -9838,8 +9842,8 @@ static int pbx_builtin_waitexten(struct ast_channel *chan, const char *data)
/* Wait for "n" seconds */
if (!ast_app_parse_timelen(args.timeout, &ms, TIMELEN_SECONDS) && ms > 0) {
/* Yay! */
- } else if (chan->pbx) {
- ms = chan->pbx->rtimeoutms;
+ } else if (ast_channel_pbx(chan)) {
+ ms = ast_channel_pbx(chan)->rtimeoutms;
} else {
ms = 10000;
}
@@ -9849,7 +9853,7 @@ static int pbx_builtin_waitexten(struct ast_channel *chan, const char *data)
if (ast_check_hangup(chan)) {
/* Call is hungup for some reason. */
res = -1;
- } else if (ast_exists_extension(chan, ast_channel_context(chan), ast_channel_exten(chan), chan->priority + 1,
+ } else if (ast_exists_extension(chan, ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan) + 1,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
ast_verb(3, "Timeout on %s, continuing...\n", ast_channel_name(chan));
} else if (ast_exists_extension(chan, ast_channel_context(chan), "t", 1,
@@ -9923,7 +9927,7 @@ static int pbx_builtin_background(struct ast_channel *chan, const char *data)
}
/* Answer if need be */
- if (chan->_state != AST_STATE_UP) {
+ if (ast_channel_state(chan) != AST_STATE_UP) {
if (ast_test_flag(&flags, BACKGROUND_SKIP)) {
goto done;
} else if (!ast_test_flag(&flags, BACKGROUND_NOANSWER)) {
@@ -9983,7 +9987,7 @@ static int pbx_builtin_background(struct ast_channel *chan, const char *data)
snprintf(buf, sizeof(buf), "%c", res);
ast_channel_exten_set(chan, buf);
ast_channel_context_set(chan, args.context);
- chan->priority = 0;
+ ast_channel_priority_set(chan, 0);
res = 0;
}
done:
@@ -9998,7 +10002,7 @@ static int pbx_builtin_goto(struct ast_channel *chan, const char *data)
{
int res = ast_parseable_goto(chan, data);
if (!res)
- ast_verb(3, "Goto (%s,%s,%d)\n", ast_channel_context(chan), ast_channel_exten(chan), chan->priority + 1);
+ ast_verb(3, "Goto (%s,%s,%d)\n", ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan) + 1);
return res;
}
@@ -10223,7 +10227,7 @@ int pbx_builtin_setvar_multiple(struct ast_channel *chan, const char *vdata)
} else if (!chan) {
ast_log(LOG_WARNING, "MSet: ignoring entry '%s' with no '='\n", pair.name);
} else {
- ast_log(LOG_WARNING, "MSet: ignoring entry '%s' with no '=' (in %s@%s:%d\n", pair.name, ast_channel_exten(chan), ast_channel_context(chan), chan->priority);
+ ast_log(LOG_WARNING, "MSet: ignoring entry '%s' with no '=' (in %s@%s:%d\n", pair.name, ast_channel_exten(chan), ast_channel_context(chan), ast_channel_priority(chan));
}
}
@@ -10756,7 +10760,7 @@ static int pbx_parseable_goto(struct ast_channel *chan, const char *goto_string,
/* At this point we have a priority and maybe an extension and a context */
if (mode)
- ipri = chan->priority + (ipri * mode);
+ ipri = ast_channel_priority(chan) + (ipri * mode);
if (async)
ast_async_goto(chan, context, exten, ipri);
diff --git a/main/rtp_engine.c b/main/rtp_engine.c
index 3e2e39ba8..518ac140c 100644
--- a/main/rtp_engine.c
+++ b/main/rtp_engine.c
@@ -843,17 +843,17 @@ static enum ast_bridge_result local_bridge_loop(struct ast_channel *c0, struct a
break;
}
/* Check if anything changed */
- if ((c0->tech_pvt != pvt0) ||
- (c1->tech_pvt != pvt1) ||
- (c0->masq || c0->masqr || c1->masq || c1->masqr) ||
- (c0->monitor || c0->audiohooks || c1->monitor || c1->audiohooks) ||
- (!ast_framehook_list_is_empty(c0->framehooks) || !ast_framehook_list_is_empty(c1->framehooks))) {
+ if ((ast_channel_tech_pvt(c0) != pvt0) ||
+ (ast_channel_tech_pvt(c1) != pvt1) ||
+ (ast_channel_masq(c0) || ast_channel_masqr(c0) || ast_channel_masq(c1) || ast_channel_masqr(c1)) ||
+ (ast_channel_monitor(c0) || ast_channel_audiohooks(c0) || ast_channel_monitor(c1) || ast_channel_audiohooks(c1)) ||
+ (!ast_framehook_list_is_empty(ast_channel_framehooks(c0)) || !ast_framehook_list_is_empty(ast_channel_framehooks(c1)))) {
ast_debug(1, "rtp-engine-local-bridge: Oooh, something is weird, backing out\n");
/* If a masquerade needs to happen we have to try to read in a frame so that it actually happens. Without this we risk being called again and going into a loop */
- if ((c0->masq || c0->masqr) && (fr = ast_read(c0))) {
+ if ((ast_channel_masq(c0) || ast_channel_masqr(c0)) && (fr = ast_read(c0))) {
ast_frfree(fr);
}
- if ((c1->masq || c1->masqr) && (fr = ast_read(c1))) {
+ if ((ast_channel_masq(c1) || ast_channel_masqr(c1)) && (fr = ast_read(c1))) {
ast_frfree(fr);
}
res = AST_BRIDGE_RETRY;
@@ -1041,11 +1041,11 @@ static enum ast_bridge_result remote_bridge_loop(struct ast_channel *c0,
cs[2] = NULL;
for (;;) {
/* Check if anything changed */
- if ((c0->tech_pvt != pvt0) ||
- (c1->tech_pvt != pvt1) ||
- (c0->masq || c0->masqr || c1->masq || c1->masqr) ||
- (c0->monitor || c0->audiohooks || c1->monitor || c1->audiohooks) ||
- (!ast_framehook_list_is_empty(c0->framehooks) || !ast_framehook_list_is_empty(c1->framehooks))) {
+ if ((ast_channel_tech_pvt(c0) != pvt0) ||
+ (ast_channel_tech_pvt(c1) != pvt1) ||
+ (ast_channel_masq(c0) || ast_channel_masqr(c0) || ast_channel_masq(c1) || ast_channel_masqr(c1)) ||
+ (ast_channel_monitor(c0) || ast_channel_audiohooks(c0) || ast_channel_monitor(c1) || ast_channel_audiohooks(c1)) ||
+ (!ast_framehook_list_is_empty(ast_channel_framehooks(c0)) || !ast_framehook_list_is_empty(ast_channel_framehooks(c1)))) {
ast_debug(1, "Oooh, something is weird, backing out\n");
res = AST_BRIDGE_RETRY;
break;
@@ -1187,14 +1187,14 @@ static enum ast_bridge_result remote_bridge_loop(struct ast_channel *c0,
ast_rtp_instance_get_remote_address(instance1, &t1);
ast_sockaddr_copy(&ac1, &t1);
/* Update codec information */
- if (glue0->get_codec && c0->tech_pvt) {
+ if (glue0->get_codec && ast_channel_tech_pvt(c0)) {
ast_format_cap_remove_all(cap0);
ast_format_cap_remove_all(oldcap0);
glue0->get_codec(c0, cap0);
ast_format_cap_append(oldcap0, cap0);
}
- if (glue1->get_codec && c1->tech_pvt) {
+ if (glue1->get_codec && ast_channel_tech_pvt(c1)) {
ast_format_cap_remove_all(cap1);
ast_format_cap_remove_all(oldcap1);
glue0->get_codec(c1, cap1);
@@ -1243,18 +1243,18 @@ static enum ast_bridge_result remote_bridge_loop(struct ast_channel *c0,
if (ast_test_flag(c0, AST_FLAG_ZOMBIE)) {
ast_debug(1, "Channel '%s' Zombie cleardown from bridge\n", ast_channel_name(c0));
- } else if (c0->tech_pvt != pvt0) {
+ } else if (ast_channel_tech_pvt(c0) != pvt0) {
ast_debug(1, "Channel c0->'%s' pvt changed, in bridge with c1->'%s'\n", ast_channel_name(c0), ast_channel_name(c1));
- } else if (glue0 != ast_rtp_instance_get_glue(c0->tech->type)) {
+ } else if (glue0 != ast_rtp_instance_get_glue(ast_channel_tech(c0)->type)) {
ast_debug(1, "Channel c0->'%s' technology changed, in bridge with c1->'%s'\n", ast_channel_name(c0), ast_channel_name(c1));
} else if (glue0->update_peer(c0, NULL, NULL, NULL, 0, 0)) {
ast_log(LOG_WARNING, "Channel '%s' failed to break RTP bridge\n", ast_channel_name(c0));
}
if (ast_test_flag(c1, AST_FLAG_ZOMBIE)) {
ast_debug(1, "Channel '%s' Zombie cleardown from bridge\n", ast_channel_name(c1));
- } else if (c1->tech_pvt != pvt1) {
+ } else if (ast_channel_tech_pvt(c1) != pvt1) {
ast_debug(1, "Channel c1->'%s' pvt changed, in bridge with c0->'%s'\n", ast_channel_name(c1), ast_channel_name(c0));
- } else if (glue1 != ast_rtp_instance_get_glue(c1->tech->type)) {
+ } else if (glue1 != ast_rtp_instance_get_glue(ast_channel_tech(c1)->type)) {
ast_debug(1, "Channel c1->'%s' technology changed, in bridge with c0->'%s'\n", ast_channel_name(c1), ast_channel_name(c0));
} else if (glue1->update_peer(c1, NULL, NULL, NULL, 0, 0)) {
ast_log(LOG_WARNING, "Channel '%s' failed to break RTP bridge\n", ast_channel_name(c1));
@@ -1318,7 +1318,7 @@ enum ast_bridge_result ast_rtp_instance_bridge(struct ast_channel *c0, struct as
}
/* Grab glue that binds each channel to something using the RTP engine */
- if (!(glue0 = ast_rtp_instance_get_glue(c0->tech->type)) || !(glue1 = ast_rtp_instance_get_glue(c1->tech->type))) {
+ if (!(glue0 = ast_rtp_instance_get_glue(ast_channel_tech(c0)->type)) || !(glue1 = ast_rtp_instance_get_glue(ast_channel_tech(c1)->type))) {
ast_debug(1, "Can't find native functions for channel '%s'\n", glue0 ? ast_channel_name(c1) : ast_channel_name(c0));
goto done;
}
@@ -1397,12 +1397,12 @@ enum ast_bridge_result ast_rtp_instance_bridge(struct ast_channel *c0, struct as
/* Depending on the end result for bridging either do a local bridge or remote bridge */
if (audio_glue0_res == AST_RTP_GLUE_RESULT_LOCAL || audio_glue1_res == AST_RTP_GLUE_RESULT_LOCAL) {
ast_verb(3, "Locally bridging %s and %s\n", ast_channel_name(c0), ast_channel_name(c1));
- res = local_bridge_loop(c0, c1, instance0, instance1, timeoutms, flags, fo, rc, c0->tech_pvt, c1->tech_pvt);
+ res = local_bridge_loop(c0, c1, instance0, instance1, timeoutms, flags, fo, rc, ast_channel_tech_pvt(c0), ast_channel_tech_pvt(c1));
} else {
ast_verb(3, "Remotely bridging %s and %s\n", ast_channel_name(c0), ast_channel_name(c1));
res = remote_bridge_loop(c0, c1, instance0, instance1, vinstance0, vinstance1,
tinstance0, tinstance1, glue0, glue1, cap0, cap1, timeoutms, flags,
- fo, rc, c0->tech_pvt, c1->tech_pvt);
+ fo, rc, ast_channel_tech_pvt(c0), ast_channel_tech_pvt(c1));
}
instance0->glue = NULL;
@@ -1460,7 +1460,7 @@ void ast_rtp_instance_early_bridge_make_compatible(struct ast_channel *c0, struc
}
/* Grab glue that binds each channel to something using the RTP engine */
- if (!(glue0 = ast_rtp_instance_get_glue(c0->tech->type)) || !(glue1 = ast_rtp_instance_get_glue(c1->tech->type))) {
+ if (!(glue0 = ast_rtp_instance_get_glue(ast_channel_tech(c0)->type)) || !(glue1 = ast_rtp_instance_get_glue(ast_channel_tech(c1)->type))) {
ast_debug(1, "Can't find native functions for channel '%s'\n", glue0 ? ast_channel_name(c1) : ast_channel_name(c0));
goto done;
}
@@ -1561,7 +1561,7 @@ int ast_rtp_instance_early_bridge(struct ast_channel *c0, struct ast_channel *c1
}
/* Grab glue that binds each channel to something using the RTP engine */
- if (!(glue0 = ast_rtp_instance_get_glue(c0->tech->type)) || !(glue1 = ast_rtp_instance_get_glue(c1->tech->type))) {
+ if (!(glue0 = ast_rtp_instance_get_glue(ast_channel_tech(c0)->type)) || !(glue1 = ast_rtp_instance_get_glue(ast_channel_tech(c1)->type))) {
ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", glue0 ? ast_channel_name(c1) : ast_channel_name(c0));
goto done;
}
@@ -1735,7 +1735,7 @@ int ast_rtp_instance_make_compatible(struct ast_channel *chan, struct ast_rtp_in
ast_channel_lock(peer);
- if (!(glue = ast_rtp_instance_get_glue(peer->tech->type))) {
+ if (!(glue = ast_rtp_instance_get_glue(ast_channel_tech(peer)->type))) {
ast_channel_unlock(peer);
return -1;
}
diff --git a/main/udptl.c b/main/udptl.c
index be5fff10d..6502cbc54 100644
--- a/main/udptl.c
+++ b/main/udptl.c
@@ -1125,7 +1125,7 @@ static struct ast_udptl_protocol *get_proto(struct ast_channel *chan)
AST_RWLIST_RDLOCK(&protos);
AST_RWLIST_TRAVERSE(&protos, cur, list) {
- if (cur->type == chan->tech->type)
+ if (cur->type == ast_channel_tech(chan)->type)
break;
}
AST_RWLIST_UNLOCK(&protos);
@@ -1170,8 +1170,8 @@ int ast_udptl_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
ast_channel_unlock(c1);
return -1;
}
- pvt0 = c0->tech_pvt;
- pvt1 = c1->tech_pvt;
+ pvt0 = ast_channel_tech_pvt(c0);
+ pvt1 = ast_channel_tech_pvt(c1);
p0 = pr0->get_udptl_info(c0);
p1 = pr1->get_udptl_info(c1);
if (!p0 || !p1) {
@@ -1200,9 +1200,9 @@ int ast_udptl_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
cs[1] = c1;
cs[2] = NULL;
for (;;) {
- if ((c0->tech_pvt != pvt0) ||
- (c1->tech_pvt != pvt1) ||
- (c0->masq || c0->masqr || c1->masq || c1->masqr)) {
+ if ((ast_channel_tech_pvt(c0) != pvt0) ||
+ (ast_channel_tech_pvt(c1) != pvt1) ||
+ (ast_channel_masq(c0) || ast_channel_masqr(c0) || ast_channel_masq(c1) || ast_channel_masqr(c1))) {
ast_debug(1, "Oooh, something is weird, backing out\n");
/* Tell it to try again later */
return -3;