From 57f42bd74f78d5022631b2ba2269892f8a3a384a Mon Sep 17 00:00:00 2001 From: Terry Wilson Date: Mon, 20 Feb 2012 23:43:27 +0000 Subject: 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 --- res/res_adsi.c | 22 ++++++++-------- res/res_agi.c | 36 +++++++++++++------------- res/res_calendar.c | 6 ++--- res/res_fax.c | 8 +++--- res/res_monitor.c | 70 ++++++++++++++++++++++++++------------------------ res/res_musiconhold.c | 64 ++++++++++++++++++++++----------------------- res/res_rtp_asterisk.c | 2 +- res/snmp/agent.c | 34 ++++++++++++------------ 8 files changed, 122 insertions(+), 120 deletions(-) (limited to 'res') diff --git a/res/res_adsi.c b/res/res_adsi.c index 327ab130d..0987b494a 100644 --- a/res/res_adsi.c +++ b/res/res_adsi.c @@ -211,7 +211,7 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms char ack[3]; struct ast_frame *f; - if (chan->adsicpe == AST_ADSI_UNAVAILABLE) { + if (ast_channel_adsicpe(chan) == AST_ADSI_UNAVAILABLE) { /* Don't bother if we know they don't support ADSI */ errno = ENOSYS; return -1; @@ -219,7 +219,7 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms while (retries < maxretries) { struct ast_format tmpfmt; - if (!(chan->adsicpe & ADSI_FLAG_DATAMODE)) { + if (!(ast_channel_adsicpe(chan) & ADSI_FLAG_DATAMODE)) { /* Generate CAS (no SAS) */ ast_format_set(&tmpfmt, AST_FORMAT_ULAW, 0); ast_gen_cas(buf, 0, 680, &tmpfmt); @@ -235,8 +235,8 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms if (((res = ast_waitfor(chan, waittime)) < 1)) { /* Didn't get back DTMF A in time */ ast_debug(1, "No ADSI CPE detected (%d)\n", res); - if (!chan->adsicpe) { - chan->adsicpe = AST_ADSI_UNAVAILABLE; + if (!ast_channel_adsicpe(chan)) { + ast_channel_adsicpe_set(chan, AST_ADSI_UNAVAILABLE); } errno = ENOSYS; return -1; @@ -249,8 +249,8 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms if (f->frametype == AST_FRAME_DTMF) { if (f->subclass.integer == 'A') { /* Okay, this is an ADSI CPE. Note this for future reference, too */ - if (!chan->adsicpe) { - chan->adsicpe = AST_ADSI_AVAILABLE; + if (!ast_channel_adsicpe(chan)) { + ast_channel_adsicpe_set(chan, AST_ADSI_AVAILABLE); } break; } else { @@ -259,8 +259,8 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms } else { ast_log(LOG_WARNING, "Unknown ADSI response '%c'\n", f->subclass.integer); } - if (!chan->adsicpe) { - chan->adsicpe = AST_ADSI_UNAVAILABLE; + if (!ast_channel_adsicpe(chan)) { + ast_channel_adsicpe_set(chan, AST_ADSI_UNAVAILABLE); } errno = ENOSYS; ast_frfree(f); @@ -367,7 +367,7 @@ int AST_OPTIONAL_API_NAME(ast_adsi_end_download)(struct ast_channel *chan) int AST_OPTIONAL_API_NAME(ast_adsi_transmit_message_full)(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype, int dowait) { unsigned char *msgs[5] = { NULL, NULL, NULL, NULL, NULL }; - int msglens[5], msgtypes[5], newdatamode = (chan->adsicpe & ADSI_FLAG_DATAMODE), res, x, waitforswitch = 0; + int msglens[5], msgtypes[5], newdatamode = (ast_channel_adsicpe(chan) & ADSI_FLAG_DATAMODE), res, x, waitforswitch = 0; struct ast_format writeformat; struct ast_format readformat; @@ -424,7 +424,7 @@ int AST_OPTIONAL_API_NAME(ast_adsi_transmit_message_full)(struct ast_channel *ch } if (!res) { - chan->adsicpe = (chan->adsicpe & ~ADSI_FLAG_DATAMODE) | newdatamode; + ast_channel_adsicpe_set(chan, (ast_channel_adsicpe(chan) & ~ADSI_FLAG_DATAMODE) | newdatamode); } if (writeformat.id) { @@ -787,7 +787,7 @@ int AST_OPTIONAL_API_NAME(ast_adsi_voice_mode)(unsigned char *buf, int when) int AST_OPTIONAL_API_NAME(ast_adsi_available)(struct ast_channel *chan) { - int cpe = chan->adsicpe & 0xff; + int cpe = ast_channel_adsicpe(chan) & 0xff; if ((cpe == AST_ADSI_AVAILABLE) || (cpe == AST_ADSI_UNKNOWN)) { return 1; diff --git a/res/res_agi.c b/res/res_agi.c index 444029161..b8c39f929 100644 --- a/res/res_agi.c +++ b/res/res_agi.c @@ -1726,7 +1726,7 @@ static void setup_env(struct ast_channel *chan, char *request, int fd, int enhan ast_agi_send(fd, chan, "agi_request: %s\n", request); ast_agi_send(fd, chan, "agi_channel: %s\n", ast_channel_name(chan)); ast_agi_send(fd, chan, "agi_language: %s\n", ast_channel_language(chan)); - ast_agi_send(fd, chan, "agi_type: %s\n", chan->tech->type); + ast_agi_send(fd, chan, "agi_type: %s\n", ast_channel_tech(chan)->type); ast_agi_send(fd, chan, "agi_uniqueid: %s\n", ast_channel_uniqueid(chan)); ast_agi_send(fd, chan, "agi_version: %s\n", ast_get_version()); @@ -1747,7 +1747,7 @@ static void setup_env(struct ast_channel *chan, char *request, int fd, int enhan /* Context information */ ast_agi_send(fd, chan, "agi_context: %s\n", ast_channel_context(chan)); ast_agi_send(fd, chan, "agi_extension: %s\n", ast_channel_exten(chan)); - ast_agi_send(fd, chan, "agi_priority: %d\n", chan->priority); + ast_agi_send(fd, chan, "agi_priority: %d\n", ast_channel_priority(chan)); ast_agi_send(fd, chan, "agi_enhanced: %s\n", enhanced ? "1.0" : "0.0"); /* User information */ @@ -1768,7 +1768,7 @@ static int handle_answer(struct ast_channel *chan, AGI *agi, int argc, const cha int res = 0; /* Answer the channel */ - if (chan->_state != AST_STATE_UP) + if (ast_channel_state(chan) != AST_STATE_UP) res = ast_answer(chan); ast_agi_send(agi->fd, chan, "200 result=%d\n", res); @@ -1975,7 +1975,7 @@ static int handle_streamfile(struct ast_channel *chan, AGI *agi, int argc, const res = ast_waitstream_full(chan, argv[3], agi->audio, agi->ctrl); /* this is to check for if ast_waitstream closed the stream, we probably are at * the end of the stream, return that amount, else check for the amount */ - sample_offset = (chan->stream) ? ast_tellstream(fs) : max_length; + sample_offset = (ast_channel_stream(chan)) ? ast_tellstream(fs) : max_length; ast_stopstream(chan); if (res == 1) { /* Stop this command, don't print a result line, as there is a new command */ @@ -2002,9 +2002,9 @@ static int handle_getoption(struct ast_channel *chan, AGI *agi, int argc, const if ( argc == 5 ) timeout = atoi(argv[4]); - else if (chan->pbx->dtimeoutms) { + else if (ast_channel_pbx(chan)->dtimeoutms) { /* by default dtimeout is set to 5sec */ - timeout = chan->pbx->dtimeoutms; /* in msec */ + timeout = ast_channel_pbx(chan)->dtimeoutms; /* in msec */ } if (!(fs = ast_openstream(chan, argv[2], ast_channel_language(chan)))) { @@ -2031,7 +2031,7 @@ static int handle_getoption(struct ast_channel *chan, AGI *agi, int argc, const res = ast_waitstream_full(chan, argv[3], agi->audio, agi->ctrl); /* this is to check for if ast_waitstream closed the stream, we probably are at * the end of the stream, return that amount, else check for the amount */ - sample_offset = (chan->stream)?ast_tellstream(fs):max_length; + sample_offset = (ast_channel_stream(chan))?ast_tellstream(fs):max_length; ast_stopstream(chan); if (res == 1) { /* Stop this command, don't print a result line, as there is a new command */ @@ -2331,7 +2331,7 @@ static int handle_recordfile(struct ast_channel *chan, AGI *agi, int argc, const /* Request a video update */ ast_indicate(chan, AST_CONTROL_VIDUPDATE); - chan->stream = fs; + ast_channel_stream_set(chan, fs); ast_applystream(chan,fs); /* really should have checks */ ast_seekstream(fs, sample_offset, SEEK_SET); @@ -2542,12 +2542,12 @@ static int handle_channelstatus(struct ast_channel *chan, AGI *agi, int argc, co struct ast_channel *c; if (argc == 2) { /* no argument: supply info on the current channel */ - ast_agi_send(agi->fd, chan, "200 result=%d\n", chan->_state); + ast_agi_send(agi->fd, chan, "200 result=%d\n", ast_channel_state(chan)); return RESULT_SUCCESS; } else if (argc == 3) { /* one argument: look for info on the specified channel */ if ((c = ast_channel_get_by_name(argv[2]))) { - ast_agi_send(agi->fd, chan, "200 result=%d\n", c->_state); + ast_agi_send(agi->fd, chan, "200 result=%d\n", ast_channel_state(c)); c = ast_channel_unref(c); return RESULT_SUCCESS; } @@ -2955,10 +2955,10 @@ static int handle_speechrecognize(struct ast_channel *chan, AGI *agi, int argc, /* Go into loop reading in frames, passing to speech thingy, checking for hangup, all that jazz */ while (ast_strlen_zero(reason)) { /* Run scheduled items */ - ast_sched_runq(chan->sched); + ast_sched_runq(ast_channel_sched(chan)); /* See maximum time of waiting */ - if ((res = ast_sched_wait(chan->sched)) < 0) + if ((res = ast_sched_wait(ast_channel_sched(chan))) < 0) res = 1000; /* Wait for frame */ @@ -2984,8 +2984,8 @@ static int handle_speechrecognize(struct ast_channel *chan, AGI *agi, int argc, ast_mutex_lock(&speech->lock); /* See if we need to quiet the audio stream playback */ - if (ast_test_flag(speech, AST_SPEECH_QUIET) && chan->stream) { - current_offset = ast_tellstream(chan->stream); + if (ast_test_flag(speech, AST_SPEECH_QUIET) && ast_channel_stream(chan)) { + current_offset = ast_tellstream(ast_channel_stream(chan)); ast_stopstream(chan); ast_clear_flag(speech, AST_SPEECH_QUIET); } @@ -2994,7 +2994,7 @@ static int handle_speechrecognize(struct ast_channel *chan, AGI *agi, int argc, switch (speech->state) { case AST_SPEECH_STATE_READY: /* If the stream is done, start timeout calculation */ - if ((timeout > 0) && start == 0 && ((!chan->stream) || (chan->streamid == -1 && chan->timingfunc == NULL))) { + if ((timeout > 0) && start == 0 && ((!ast_channel_stream(chan)) || (ast_channel_streamid(chan) == -1 && chan->timingfunc == NULL))) { ast_stopstream(chan); time(&start); } @@ -3004,7 +3004,7 @@ static int handle_speechrecognize(struct ast_channel *chan, AGI *agi, int argc, break; case AST_SPEECH_STATE_WAIT: /* Cue waiting sound if not already playing */ - if ((!chan->stream) || (chan->streamid == -1 && chan->timingfunc == NULL)) { + if ((!ast_channel_stream(chan)) || (ast_channel_streamid(chan) == -1 && chan->timingfunc == NULL)) { ast_stopstream(chan); /* If a processing sound exists, or is not none - play it */ if (!ast_strlen_zero(speech->processing_sound) && strcasecmp(speech->processing_sound, "none")) @@ -3393,8 +3393,8 @@ static enum agi_result agi_handle_command(struct ast_channel *chan, AGI *agi, ch ast_module_ref(c->mod); /* If the AGI command being executed is an actual application (using agi exec) the app field will be updated in pbx_exec via handle_exec */ - if (chan->cdr && !ast_check_hangup(chan) && strcasecmp(argv[0], "EXEC")) - ast_cdr_setapp(chan->cdr, "AGI", buf); + if (ast_channel_cdr(chan) && !ast_check_hangup(chan) && strcasecmp(argv[0], "EXEC")) + ast_cdr_setapp(ast_channel_cdr(chan), "AGI", buf); res = c->handler(chan, agi, argc, argv); if (c->mod != ast_module_info->self) diff --git a/res/res_calendar.c b/res/res_calendar.c index 382d34e08..e5a0d929e 100644 --- a/res/res_calendar.c +++ b/res/res_calendar.c @@ -743,13 +743,13 @@ static void *do_notify(void *data) goto notify_cleanup; } - chan->tech = &null_tech; + ast_channel_tech_set(chan, &null_tech); ast_format_set(&chan->writeformat, AST_FORMAT_SLINEAR, 0); ast_format_set(&chan->readformat, AST_FORMAT_SLINEAR, 0); ast_format_set(&chan->rawwriteformat, AST_FORMAT_SLINEAR, 0); ast_format_set(&chan->rawreadformat, AST_FORMAT_SLINEAR, 0); /* clear native formats and set to slinear. write format is signlear so just use that to set it */ - ast_format_cap_set(chan->nativeformats, &chan->writeformat); + ast_format_cap_set(ast_channel_nativeformats(chan), &chan->writeformat); if (!(datastore = ast_datastore_alloc(&event_notification_datastore, NULL))) { ast_log(LOG_ERROR, "Could not allocate datastore, notification not being sent!\n"); @@ -793,7 +793,7 @@ static void *do_notify(void *data) if (ast_strlen_zero(event->owner->notify_app)) { ast_channel_context_set(answered, event->owner->notify_context); ast_channel_exten_set(answered, event->owner->notify_extension); - answered->priority = 1; + ast_channel_priority_set(answered, 1); ast_pbx_run(answered); } } diff --git a/res/res_fax.c b/res/res_fax.c index 28b46a3ce..cea74b726 100644 --- a/res/res_fax.c +++ b/res/res_fax.c @@ -1882,7 +1882,7 @@ static int receivefax_exec(struct ast_channel *chan, const char *data) } /* make sure the channel is up */ - if (chan->_state != AST_STATE_UP) { + if (ast_channel_state(chan) != AST_STATE_UP) { if (ast_answer(chan)) { ast_string_field_set(details, resultstr, "error answering channel"); set_channel_variables(chan, details); @@ -2374,7 +2374,7 @@ static int sendfax_exec(struct ast_channel *chan, const char *data) } /* make sure the channel is up */ - if (chan->_state != AST_STATE_UP) { + if (ast_channel_state(chan) != AST_STATE_UP) { if (ast_answer(chan)) { ast_string_field_set(details, resultstr, "error answering channel"); set_channel_variables(chan, details); @@ -3097,7 +3097,7 @@ static struct ast_frame *fax_gateway_framehook(struct ast_channel *chan, struct /* framehooks are called in __ast_read() before frame format * translation is done, so we need to translate here */ if ((f->frametype == AST_FRAME_VOICE) && (f->subclass.format.id != AST_FORMAT_SLINEAR)) { - if (active->readtrans && (f = ast_translate(active->readtrans, f, 1)) == NULL) { + if (ast_channel_readtrans(active) && (f = ast_translate(ast_channel_readtrans(active), f, 1)) == NULL) { f = &ast_null_frame; ao2_ref(details, -1); return f; @@ -3109,7 +3109,7 @@ static struct ast_frame *fax_gateway_framehook(struct ast_channel *chan, struct * write would fail, or even if a failure would be fatal so for * now we'll just ignore the return value. */ gateway->s->tech->write(gateway->s, f); - if ((f->frametype == AST_FRAME_VOICE) && (f->subclass.format.id != AST_FORMAT_SLINEAR) && active->readtrans) { + if ((f->frametype == AST_FRAME_VOICE) && (f->subclass.format.id != AST_FORMAT_SLINEAR) && ast_channel_readtrans(active)) { /* Only free the frame if we translated / duplicated it - otherwise, * let whatever is outside the frame hook do it */ ast_frfree(f); diff --git a/res/res_monitor.c b/res/res_monitor.c index b87d0e757..045fa6aa7 100644 --- a/res/res_monitor.c +++ b/res/res_monitor.c @@ -267,11 +267,11 @@ static unsigned long seq = 0; static int ast_monitor_set_state(struct ast_channel *chan, int state) { LOCK_IF_NEEDED(chan, 1); - if (!chan->monitor) { + if (!ast_channel_monitor(chan)) { UNLOCK_IF_NEEDED(chan, 1); return -1; } - chan->monitor->state = state; + ast_channel_monitor(chan)->state = state; UNLOCK_IF_NEEDED(chan, 1); return 0; } @@ -294,7 +294,7 @@ int AST_OPTIONAL_API_NAME(ast_monitor_start)(struct ast_channel *chan, const cha LOCK_IF_NEEDED(chan, need_lock); - if (!(chan->monitor)) { + if (!(ast_channel_monitor(chan))) { struct ast_channel_monitor *monitor; char *channel_name, *p; @@ -386,7 +386,7 @@ int AST_OPTIONAL_API_NAME(ast_monitor_start)(struct ast_channel *chan, const cha } else monitor->write_stream = NULL; - chan->monitor = monitor; + ast_channel_monitor_set(chan, monitor); ast_monitor_set_state(chan, AST_MONITOR_RUNNING); /* so we know this call has been monitored in case we need to bill for it or something */ pbx_builtin_setvar_helper(chan, "__MONITORED","true"); @@ -438,43 +438,43 @@ int AST_OPTIONAL_API_NAME(ast_monitor_stop)(struct ast_channel *chan, int need_l LOCK_IF_NEEDED(chan, need_lock); - if (chan->monitor) { + if (ast_channel_monitor(chan)) { char filename[ FILENAME_MAX ]; - if (chan->monitor->read_stream) { - ast_closestream(chan->monitor->read_stream); + if (ast_channel_monitor(chan)->read_stream) { + ast_closestream(ast_channel_monitor(chan)->read_stream); } - if (chan->monitor->write_stream) { - ast_closestream(chan->monitor->write_stream); + if (ast_channel_monitor(chan)->write_stream) { + ast_closestream(ast_channel_monitor(chan)->write_stream); } - if (chan->monitor->filename_changed && !ast_strlen_zero(chan->monitor->filename_base)) { - if (ast_fileexists(chan->monitor->read_filename,NULL,NULL) > 0) { - snprintf(filename, FILENAME_MAX, "%s-in", chan->monitor->filename_base); + if (ast_channel_monitor(chan)->filename_changed && !ast_strlen_zero(ast_channel_monitor(chan)->filename_base)) { + if (ast_fileexists(ast_channel_monitor(chan)->read_filename,NULL,NULL) > 0) { + snprintf(filename, FILENAME_MAX, "%s-in", ast_channel_monitor(chan)->filename_base); if (ast_fileexists(filename, NULL, NULL) > 0) { ast_filedelete(filename, NULL); } - ast_filerename(chan->monitor->read_filename, filename, chan->monitor->format); + ast_filerename(ast_channel_monitor(chan)->read_filename, filename, ast_channel_monitor(chan)->format); } else { - ast_log(LOG_WARNING, "File %s not found\n", chan->monitor->read_filename); + ast_log(LOG_WARNING, "File %s not found\n", ast_channel_monitor(chan)->read_filename); } - if (ast_fileexists(chan->monitor->write_filename,NULL,NULL) > 0) { - snprintf(filename, FILENAME_MAX, "%s-out", chan->monitor->filename_base); + if (ast_fileexists(ast_channel_monitor(chan)->write_filename,NULL,NULL) > 0) { + snprintf(filename, FILENAME_MAX, "%s-out", ast_channel_monitor(chan)->filename_base); if (ast_fileexists(filename, NULL, NULL) > 0) { ast_filedelete(filename, NULL); } - ast_filerename(chan->monitor->write_filename, filename, chan->monitor->format); + ast_filerename(ast_channel_monitor(chan)->write_filename, filename, ast_channel_monitor(chan)->format); } else { - ast_log(LOG_WARNING, "File %s not found\n", chan->monitor->write_filename); + ast_log(LOG_WARNING, "File %s not found\n", ast_channel_monitor(chan)->write_filename); } } - if (chan->monitor->joinfiles && !ast_strlen_zero(chan->monitor->filename_base)) { + if (ast_channel_monitor(chan)->joinfiles && !ast_strlen_zero(ast_channel_monitor(chan)->filename_base)) { char tmp[1024]; char tmp2[1024]; - const char *format = !strcasecmp(chan->monitor->format,"wav49") ? "WAV" : chan->monitor->format; - char *fname_base = chan->monitor->filename_base; + const char *format = !strcasecmp(ast_channel_monitor(chan)->format,"wav49") ? "WAV" : ast_channel_monitor(chan)->format; + char *fname_base = ast_channel_monitor(chan)->filename_base; const char *execute, *execute_args; /* at this point, fname_base really is the full path */ @@ -505,9 +505,9 @@ int AST_OPTIONAL_API_NAME(ast_monitor_stop)(struct ast_channel *chan, int need_l ast_log(LOG_WARNING, "Execute of %s failed.\n",tmp); } - ast_free(chan->monitor->format); - ast_free(chan->monitor); - chan->monitor = NULL; + ast_free(ast_channel_monitor(chan)->format); + ast_free(ast_channel_monitor(chan)); + ast_channel_monitor_set(chan, NULL); ast_manager_event(chan, EVENT_FLAG_CALL, "MonitorStop", "Channel: %s\r\n" @@ -566,11 +566,11 @@ int AST_OPTIONAL_API_NAME(ast_monitor_change_fname)(struct ast_channel *chan, co LOCK_IF_NEEDED(chan, need_lock); - if (chan->monitor) { + if (ast_channel_monitor(chan)) { int directory = strchr(fname_base, '/') ? 1 : 0; const char *absolute = *fname_base == '/' ? "" : ast_config_AST_MONITOR_DIR; const char *absolute_suffix = *fname_base == '/' ? "" : "/"; - char tmpstring[sizeof(chan->monitor->filename_base)] = ""; + char tmpstring[sizeof(ast_channel_monitor(chan)->filename_base)] = ""; int i, fd[2] = { -1, -1 }, doexit = 0; /* before continuing, see if we're trying to rename the file to itself... */ @@ -594,10 +594,10 @@ int AST_OPTIONAL_API_NAME(ast_monitor_change_fname)(struct ast_channel *chan, co * the file without the format suffix), so it does not already exist * and we aren't interfering with the recording itself. */ - ast_debug(2, "comparing tmpstring %s to filename_base %s\n", tmpstring, chan->monitor->filename_base); + ast_debug(2, "comparing tmpstring %s to filename_base %s\n", tmpstring, ast_channel_monitor(chan)->filename_base); if ((fd[0] = open(tmpstring, O_CREAT | O_WRONLY, 0644)) < 0 || - (fd[1] = open(chan->monitor->filename_base, O_CREAT | O_EXCL | O_WRONLY, 0644)) < 0) { + (fd[1] = open(ast_channel_monitor(chan)->filename_base, O_CREAT | O_EXCL | O_WRONLY, 0644)) < 0) { if (fd[0] < 0) { ast_log(LOG_ERROR, "Unable to compare filenames: %s\n", strerror(errno)); } else { @@ -614,15 +614,15 @@ int AST_OPTIONAL_API_NAME(ast_monitor_change_fname)(struct ast_channel *chan, co } unlink(tmpstring); /* if previous monitor file existed in a subdirectory, the directory will not be removed */ - unlink(chan->monitor->filename_base); + unlink(ast_channel_monitor(chan)->filename_base); if (doexit) { UNLOCK_IF_NEEDED(chan, need_lock); return 0; } - ast_copy_string(chan->monitor->filename_base, tmpstring, sizeof(chan->monitor->filename_base)); - chan->monitor->filename_changed = 1; + ast_copy_string(ast_channel_monitor(chan)->filename_base, tmpstring, sizeof(ast_channel_monitor(chan)->filename_base)); + ast_channel_monitor(chan)->filename_changed = 1; } else { ast_log(LOG_WARNING, "Cannot change monitor filename of channel %s to %s, monitoring not started\n", ast_channel_name(chan), fname_base); } @@ -685,13 +685,15 @@ static int start_monitor_exec(struct ast_channel *chan, const char *data) } if (!ast_strlen_zero(urlprefix) && !ast_strlen_zero(args.fname_base)) { + struct ast_cdr *chan_cdr; snprintf(tmp, sizeof(tmp), "%s/%s.%s", urlprefix, args.fname_base, ((strcmp(args.format, "gsm")) ? "wav" : "gsm")); ast_channel_lock(chan); - if (!chan->cdr && !(chan->cdr = ast_cdr_alloc())) { + if (!ast_channel_cdr(chan) && !(chan_cdr = ast_cdr_alloc())) { ast_channel_unlock(chan); return -1; } + ast_channel_cdr_set(chan, chan_cdr); ast_cdr_setuserfield(chan, tmp); ast_channel_unlock(chan); } @@ -860,8 +862,8 @@ static int change_monitor_action(struct mansession *s, const struct message *m) void AST_OPTIONAL_API_NAME(ast_monitor_setjoinfiles)(struct ast_channel *chan, int turnon) { - if (chan->monitor) - chan->monitor->joinfiles = turnon; + if (ast_channel_monitor(chan)) + ast_channel_monitor(chan)->joinfiles = turnon; } enum MONITOR_PAUSING_ACTION diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c index e505c3ee1..eb4330e21 100644 --- a/res/res_musiconhold.c +++ b/res/res_musiconhold.c @@ -260,15 +260,15 @@ static void moh_files_release(struct ast_channel *chan, void *data) { struct moh_files_state *state; - if (!chan || !chan->music_state) { + if (!chan || !ast_channel_music_state(chan)) { return; } - state = chan->music_state; + state = ast_channel_music_state(chan); - 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); } ast_verb(3, "Stopped music on hold on %s\n", ast_channel_name(chan)); @@ -286,13 +286,13 @@ static void moh_files_release(struct ast_channel *chan, void *data) static int ast_moh_files_next(struct ast_channel *chan) { - struct moh_files_state *state = chan->music_state; + struct moh_files_state *state = ast_channel_music_state(chan); int tries; /* Discontinue a stream if it is running already */ - 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); } if (ast_test_flag(state->class, MOH_ANNOUNCEMENT) && state->announcement == 0) { @@ -357,13 +357,13 @@ static int ast_moh_files_next(struct ast_channel *chan) if (state->samples) { size_t loc; /* seek *SHOULD* be good since it's from a known location */ - ast_seekstream(chan->stream, state->samples, SEEK_SET); + ast_seekstream(ast_channel_stream(chan), state->samples, SEEK_SET); /* if the seek failed then recover because if there is not a valid read, * moh_files_generate will return -1 and MOH will stop */ - loc = ast_tellstream(chan->stream); + loc = ast_tellstream(ast_channel_stream(chan)); if (state->samples > loc && loc) { /* seek one sample from the end for one guaranteed valid read */ - ast_seekstream(chan->stream, 1, SEEK_END); + ast_seekstream(ast_channel_stream(chan), 1, SEEK_END); } } @@ -374,9 +374,9 @@ static struct ast_frame *moh_files_readframe(struct ast_channel *chan) { struct ast_frame *f = NULL; - if (!(chan->stream && (f = ast_readframe(chan->stream)))) { + if (!(ast_channel_stream(chan) && (f = ast_readframe(ast_channel_stream(chan))))) { if (!ast_moh_files_next(chan)) - f = ast_readframe(chan->stream); + f = ast_readframe(ast_channel_stream(chan)); } return f; @@ -384,7 +384,7 @@ static struct ast_frame *moh_files_readframe(struct ast_channel *chan) static void moh_files_write_format_change(struct ast_channel *chan, void *data) { - struct moh_files_state *state = chan->music_state; + struct moh_files_state *state = ast_channel_music_state(chan); /* In order to prevent a recursive call to this function as a result * of setting the moh write format back on the channel. Clear @@ -403,7 +403,7 @@ static void moh_files_write_format_change(struct ast_channel *chan, void *data) static int moh_files_generator(struct ast_channel *chan, void *data, int len, int samples) { - struct moh_files_state *state = chan->music_state; + struct moh_files_state *state = ast_channel_music_state(chan); struct ast_frame *f = NULL; int res = 0; @@ -443,11 +443,11 @@ static void *moh_files_alloc(struct ast_channel *chan, void *params) struct moh_files_state *state; struct mohclass *class = params; - if (!chan->music_state && (state = ast_calloc(1, sizeof(*state)))) { - chan->music_state = state; + if (!ast_channel_music_state(chan) && (state = ast_calloc(1, sizeof(*state)))) { + ast_channel_music_state_set(chan, state); ast_module_ref(ast_module_info->self); } else { - state = chan->music_state; + state = ast_channel_music_state(chan); if (!state) { return NULL; } @@ -479,7 +479,7 @@ static void *moh_files_alloc(struct ast_channel *chan, void *params) ast_verb(3, "Started music on hold, class '%s', on %s\n", class->name, ast_channel_name(chan)); - return chan->music_state; + return ast_channel_music_state(chan); } static int moh_digit_match(void *obj, void *arg, int flags) @@ -956,7 +956,7 @@ static void moh_release(struct ast_channel *chan, void *data) if (chan) { struct moh_files_state *state; - state = chan->music_state; + state = ast_channel_music_state(chan); if (state && state->class) { state->class = mohclass_unref(state->class, "Unreffing channel's music class upon deactivation of generator"); } @@ -976,11 +976,11 @@ static void *moh_alloc(struct ast_channel *chan, void *params) struct moh_files_state *state; /* Initiating music_state for current channel. Channel should know name of moh class */ - if (!chan->music_state && (state = ast_calloc(1, sizeof(*state)))) { - chan->music_state = state; + if (!ast_channel_music_state(chan) && (state = ast_calloc(1, sizeof(*state)))) { + ast_channel_music_state_set(chan, state); ast_module_ref(ast_module_info->self); } else { - state = chan->music_state; + state = ast_channel_music_state(chan); if (!state) { return NULL; } @@ -1312,7 +1312,7 @@ static int _moh_register(struct mohclass *moh, int reload, int unref, const char static void local_ast_moh_cleanup(struct ast_channel *chan) { - struct moh_files_state *state = chan->music_state; + struct moh_files_state *state = ast_channel_music_state(chan); if (state) { if (state->class) { @@ -1321,8 +1321,8 @@ static void local_ast_moh_cleanup(struct ast_channel *chan) mohclass_unref(state->class, "Uh Oh. Cleaning up MOH with an active class"); ast_log(LOG_WARNING, "Uh Oh. Cleaning up MOH with an active class\n"); } - ast_free(chan->music_state); - chan->music_state = NULL; + ast_free(ast_channel_music_state(chan)); + ast_channel_music_state_set(chan, NULL); /* Only held a module reference if we had a music state */ ast_module_unref(ast_module_info->self); } @@ -1355,7 +1355,7 @@ static struct mohclass *_moh_class_malloc(const char *file, int line, const char static int local_ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass) { struct mohclass *mohclass = NULL; - struct moh_files_state *state = chan->music_state; + struct moh_files_state *state = ast_channel_music_state(chan); struct ast_variable *var = NULL; int res; int realtime_possible = ast_check_realtime("musiconhold"); @@ -1578,10 +1578,10 @@ static void local_ast_moh_stop(struct ast_channel *chan) ast_deactivate_generator(chan); ast_channel_lock(chan); - if (chan->music_state) { - if (chan->stream) { - ast_closestream(chan->stream); - chan->stream = NULL; + if (ast_channel_music_state(chan)) { + if (ast_channel_stream(chan)) { + ast_closestream(ast_channel_stream(chan)); + ast_channel_stream_set(chan, NULL); } } diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c index d804d2cb0..17e3980b0 100644 --- a/res/res_rtp_asterisk.c +++ b/res/res_rtp_asterisk.c @@ -2716,7 +2716,7 @@ static int ast_rtp_dtmf_compatible(struct ast_channel *chan0, struct ast_rtp_ins * -------------------------------------------------- */ return (((ast_rtp_instance_get_prop(instance0, AST_RTP_PROPERTY_DTMF) != ast_rtp_instance_get_prop(instance1, AST_RTP_PROPERTY_DTMF)) || - (!chan0->tech->send_digit_begin != !chan1->tech->send_digit_begin)) ? 0 : 1); + (!ast_channel_tech(chan0)->send_digit_begin != !ast_channel_tech(chan1)->send_digit_begin)) ? 0 : 1); } static void ast_rtp_stun_request(struct ast_rtp_instance *instance, struct ast_sockaddr *suggestion, const char *username) diff --git a/res/snmp/agent.c b/res/snmp/agent.c index 9d02a7a5b..3c0c48e1b 100644 --- a/res/snmp/agent.c +++ b/res/snmp/agent.c @@ -284,7 +284,7 @@ static u_char *ast_var_channels_table(struct variable *vp, oid *name, size_t *le } break; case ASTCHANTYPE: - strncpy(string_ret, chan->tech->type, sizeof(string_ret)); + strncpy(string_ret, ast_channel_tech(chan)->type, sizeof(string_ret)); string_ret[sizeof(string_ret) - 1] = '\0'; *var_len = strlen(string_ret); ret = (u_char *)string_ret; @@ -306,16 +306,16 @@ static u_char *ast_var_channels_table(struct variable *vp, oid *name, size_t *le } break; case ASTCHANMASQ: - if (chan->masq && !ast_strlen_zero(ast_channel_name(chan->masq))) { - strncpy(string_ret, ast_channel_name(chan->masq), sizeof(string_ret)); + if (ast_channel_masq(chan) && !ast_strlen_zero(ast_channel_name(ast_channel_masq(chan)))) { + strncpy(string_ret, ast_channel_name(ast_channel_masq(chan)), sizeof(string_ret)); string_ret[sizeof(string_ret) - 1] = '\0'; *var_len = strlen(string_ret); ret = (u_char *)string_ret; } break; case ASTCHANMASQR: - if (chan->masqr && !ast_strlen_zero(ast_channel_name(chan->masqr))) { - strncpy(string_ret, ast_channel_name(chan->masqr), sizeof(string_ret)); + if (ast_channel_masqr(chan) && !ast_strlen_zero(ast_channel_name(ast_channel_masqr(chan)))) { + strncpy(string_ret, ast_channel_name(ast_channel_masqr(chan)), sizeof(string_ret)); string_ret[sizeof(string_ret) - 1] = '\0'; *var_len = strlen(string_ret); ret = (u_char *)string_ret; @@ -363,7 +363,7 @@ static u_char *ast_var_channels_table(struct variable *vp, oid *name, size_t *le ret = (u_char *)string_ret; break; case ASTCHANMACROPRI: - long_ret = chan->macropriority; + long_ret = ast_channel_macropriority(chan); ret = (u_char *)&long_ret; break; case ASTCHANEXTEN: @@ -373,7 +373,7 @@ static u_char *ast_var_channels_table(struct variable *vp, oid *name, size_t *le ret = (u_char *)string_ret; break; case ASTCHANPRI: - long_ret = chan->priority; + long_ret = ast_channel_priority(chan); ret = (u_char *)&long_ret; break; case ASTCHANACCOUNTCODE: @@ -407,15 +407,15 @@ static u_char *ast_var_channels_table(struct variable *vp, oid *name, size_t *le ret = (u_char *)&long_ret; break; case ASTCHANSTATE: - long_ret = chan->_state & 0xffff; + long_ret = ast_channel_state(chan) & 0xffff; ret = (u_char *)&long_ret; break; case ASTCHANMUTED: - long_ret = chan->_state & AST_STATE_MUTE ? 1 : 2; + long_ret = ast_channel_state(chan) & AST_STATE_MUTE ? 1 : 2; ret = (u_char *)&long_ret; break; case ASTCHANRINGS: - long_ret = chan->rings; + long_ret = ast_channel_rings(chan); ret = (u_char *)&long_ret; break; case ASTCHANCIDDNID: @@ -475,23 +475,23 @@ static u_char *ast_var_channels_table(struct variable *vp, oid *name, size_t *le ret = (u_char *)&long_ret; break; case ASTCHANAMAFLAGS: - long_ret = chan->amaflags; + long_ret = ast_channel_amaflags(chan); ret = (u_char *)&long_ret; break; case ASTCHANADSI: - long_ret = chan->adsicpe; + long_ret = ast_channel_adsicpe(chan); ret = (u_char *)&long_ret; break; case ASTCHANTONEZONE: - if (chan->zone) { - strncpy(string_ret, chan->zone->country, sizeof(string_ret)); + if (ast_channel_zone(chan)) { + strncpy(string_ret, ast_channel_zone(chan)->country, sizeof(string_ret)); string_ret[sizeof(string_ret) - 1] = '\0'; *var_len = strlen(string_ret); ret = (u_char *)string_ret; } break; case ASTCHANHANGUPCAUSE: - long_ret = chan->hangupcause; + long_ret = ast_channel_hangupcause(chan); ret = (u_char *)&long_ret; break; case ASTCHANVARIABLES: @@ -511,7 +511,7 @@ static u_char *ast_var_channels_table(struct variable *vp, oid *name, size_t *le ret = bits_ret; break; case ASTCHANTRANSFERCAP: - long_ret = chan->transfercapability; + long_ret = ast_channel_transfercapability(chan); ret = (u_char *)&long_ret; default: break; @@ -593,7 +593,7 @@ static u_char *ast_var_channel_types_table(struct variable *vp, oid *name, size_ } while ((chan = ast_channel_iterator_next(iter))) { - if (chan->tech == tech) { + if (ast_channel_tech(chan) == tech) { long_ret++; } chan = ast_channel_unref(chan); -- cgit v1.2.3