--- funcs/func_channel.c (svn) +++ funcs/func_channel.c (working copy) @@ -65,9 +65,9 @@ /* ast_getformatname_multiple(buf, len, chan->nativeformats & AST_FORMAT_VIDEO_MASK); */ ast_copy_string(buf, ast_getformatname(chan->nativeformats & AST_FORMAT_VIDEO_MASK), len); else if (!strcasecmp(data, "audioreadformat")) - ast_copy_string(buf, ast_getformatname(chan->readformat), len); + ast_copy_string(buf, ast_getformatname(ast_get_read_format(chan)), len); else if (!strcasecmp(data, "audiowriteformat")) - ast_copy_string(buf, ast_getformatname(chan->writeformat), len); + ast_copy_string(buf, ast_getformatname(ast_get_write_format(chan)), len); else if (!strcasecmp(data, "tonezone") && chan->zone) locked_copy_string(chan, buf, chan->zone->country, len); else if (!strcasecmp(data, "language")) --- channels/chan_skinny.c (svn) +++ channels/chan_skinny.c (working copy) @@ -2056,8 +2056,7 @@ if (f->subclass != sub->owner->nativeformats) { ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass); sub->owner->nativeformats = f->subclass; - ast_set_read_format(sub->owner, sub->owner->readformat); - ast_set_write_format(sub->owner, sub->owner->writeformat); + ast_channel_formats_reset(sub->owner); } } } @@ -2088,7 +2087,7 @@ } else { if (!(frame->subclass & ast->nativeformats)) { ast_log(LOG_WARNING, "Asked to transmit frame type %d, while native formats is %d (read/write = %d/%d)\n", - frame->subclass, ast->nativeformats, ast->readformat, ast->writeformat); + frame->subclass, ast->nativeformats, ast_get_read_format(ast), ast_get_write_format(ast)); return -1; } } @@ -2247,7 +2246,7 @@ tmp->nativeformats = l->capability; if (!tmp->nativeformats) tmp->nativeformats = capability; - fmt = ast_best_codec(tmp->nativeformats); + fmt = ast_channel_best_codec(tmp); if (skinnydebug) { ast_verbose("skinny_new: tmp->nativeformats=%d fmt=%d\n", tmp->nativeformats, fmt); } --- channels/chan_iax2.c (svn) +++ channels/chan_iax2.c (working copy) @@ -6139,8 +6139,8 @@ if (chan2m && chan1m) { ast_string_field_build(chan1m, name, "Parking/%s", chan1->name); /* Make formats okay */ - chan1m->readformat = chan1->readformat; - chan1m->writeformat = chan1->writeformat; + chan1m->readformat = ast_get_read_format(chan1); + chan1m->writeformat = ast_get_write_format(chan1); ast_channel_masquerade(chan1m, chan1); /* Setup the extensions and such */ ast_copy_string(chan1m->context, chan1->context, sizeof(chan1m->context)); @@ -6151,8 +6151,8 @@ back the announcement */ ast_string_field_build(chan2m, name, "IAXPeer/%s",chan2->name); /* Make formats okay */ - chan2m->readformat = chan2->readformat; - chan2m->writeformat = chan2->writeformat; + chan2m->readformat = ast_get_read_format(chan2); + chan2m->writeformat = ast_get_write_format(chan2); ast_channel_masquerade(chan2m, chan2); /* Setup the extensions and such */ ast_copy_string(chan2m->context, chan2->context, sizeof(chan2m->context)); @@ -8036,8 +8036,7 @@ } c->nativeformats = native; } - c->readformat = ast_best_codec(c->nativeformats); - c->writeformat = c->readformat; + c->writeformat = c->readformat = ast_channel_best_codec(c); } return c; --- channels/chan_features.c (svn) +++ channels/chan_features.c (working copy) @@ -188,12 +188,9 @@ p->subs[index].owner->timingfd = p->subchan->timingfd; p->subs[index].owner->alertpipe[0] = p->subchan->alertpipe[0]; p->subs[index].owner->alertpipe[1] = p->subchan->alertpipe[1]; - if (p->subs[index].owner->nativeformats != p->subchan->readformat) { - p->subs[index].owner->nativeformats = p->subchan->readformat; - if (p->subs[index].owner->readformat) - ast_set_read_format(p->subs[index].owner, p->subs[index].owner->readformat); - if (p->subs[index].owner->writeformat) - ast_set_write_format(p->subs[index].owner, p->subs[index].owner->writeformat); + if (p->subs[index].owner->nativeformats != ast_get_read_format(p->subchan)) { + p->subs[index].owner->nativeformats = ast_get_read_format(p->subchan); + ast_channel_formats_reset(p->subs[index].owner); } } else{ restore_channel(p, index); @@ -459,11 +456,11 @@ break; } ast_setstate(tmp, state); - tmp->writeformat = p->subchan->writeformat; + tmp->writeformat = ast_get_write_format(p->subchan); tmp->rawwriteformat = p->subchan->rawwriteformat; - tmp->readformat = p->subchan->readformat; + tmp->readformat = ast_get_read_format(p->subchan); tmp->rawreadformat = p->subchan->rawreadformat; - tmp->nativeformats = p->subchan->readformat; + tmp->nativeformats = ast_get_read_format(p->subchan); tmp->tech_pvt = p; p->subs[index].owner = tmp; if (!p->owner) --- channels/chan_mgcp.c (svn) +++ channels/chan_mgcp.c (working copy) @@ -1225,8 +1225,7 @@ if (f->subclass != sub->owner->nativeformats) { ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass); sub->owner->nativeformats = f->subclass; - ast_set_read_format(sub->owner, sub->owner->readformat); - ast_set_write_format(sub->owner, sub->owner->writeformat); + ast_channel_formats_reset(sub->owner); } /* Courtesy fearnor aka alex@pilosoft.com */ if ((sub->parent->dtmfmode & MGCP_DTMF_INBAND) && (sub->parent->dsp)) { @@ -1265,7 +1264,7 @@ } else { if (!(frame->subclass & ast->nativeformats)) { ast_log(LOG_WARNING, "Asked to transmit frame type %d, while native formats is %d (read/write = %d/%d)\n", - frame->subclass, ast->nativeformats, ast->readformat, ast->writeformat); + frame->subclass, ast->nativeformats, ast_get_read_format(ast), ast_get_write_format(ast)); return -1; } } @@ -1448,7 +1447,7 @@ tmp->nativeformats = i->capability; if (!tmp->nativeformats) tmp->nativeformats = capability; - fmt = ast_best_codec(tmp->nativeformats); + fmt = ast_channel_best_codec(tmp); ast_string_field_build(tmp, name, "MGCP/%s@%s-%d", i->name, i->parent->name, sub->id); if (sub->rtp) tmp->fds[0] = ast_rtp_fd(sub->rtp); --- channels/chan_agent.c (svn) +++ channels/chan_agent.c (working copy) @@ -211,13 +211,11 @@ ast_log(LOG_DEBUG, "Native formats changing from %d to %d\n", ast->nativeformats, p->chan->nativeformats); \ /* Native formats changed, reset things */ \ ast->nativeformats = p->chan->nativeformats; \ - ast_log(LOG_DEBUG, "Resetting read to %d and write to %d\n", ast->readformat, ast->writeformat);\ - ast_set_read_format(ast, ast->readformat); \ - ast_set_write_format(ast, ast->writeformat); \ + ast_channel_formats_reset(ast); \ } \ - if (p->chan->readformat != ast->rawreadformat) \ + if (ast_get_read_format(p->chan) != ast->rawreadformat) \ ast_set_read_format(p->chan, ast->rawreadformat); \ - if (p->chan->writeformat != ast->rawwriteformat) \ + if (ast_get_write_format(p->chan) != ast->rawwriteformat) \ ast_set_write_format(p->chan, ast->rawwriteformat); \ } \ } while(0) @@ -657,20 +655,20 @@ ast_log( LOG_DEBUG, "Waited for stream, result '%d'\n", res); } if (!res) { - res = ast_set_read_format(p->chan, ast_best_codec(p->chan->nativeformats)); + res = ast_set_read_format(p->chan, ast_channel_best_codec(p->chan)); ast_log( LOG_DEBUG, "Set read format, result '%d'\n", res); if (res) - ast_log(LOG_WARNING, "Unable to set read format to %s\n", ast_getformatname(ast_best_codec(p->chan->nativeformats))); + ast_log(LOG_WARNING, "Unable to set read format to %s\n", ast_getformatname(ast_channel_best_codec(p->chan))); } else { /* Agent hung-up */ p->chan = NULL; } if (!res) { - ast_set_write_format(p->chan, ast_best_codec(p->chan->nativeformats)); + ast_set_write_format(p->chan, ast_channel_best_codec(p->chan)); ast_log( LOG_DEBUG, "Set write format, result '%d'\n", res); if (res) - ast_log(LOG_WARNING, "Unable to set write format to %s\n", ast_getformatname(ast_best_codec(p->chan->nativeformats))); + ast_log(LOG_WARNING, "Unable to set write format to %s\n", ast_getformatname(ast_channel_best_codec(p->chan))); } if( !res ) { @@ -904,10 +902,10 @@ tmp->tech = &agent_tech; if (p->chan) { tmp->nativeformats = p->chan->nativeformats; - tmp->writeformat = p->chan->writeformat; - tmp->rawwriteformat = p->chan->writeformat; - tmp->readformat = p->chan->readformat; - tmp->rawreadformat = p->chan->readformat; + tmp->writeformat = ast_get_write_format(p->chan); + tmp->rawwriteformat = ast_get_write_format(p->chan); + tmp->readformat = ast_get_read_format(p->chan); + tmp->rawreadformat = ast_get_read_format(p->chan); ast_string_field_set(tmp, language, p->chan->language); ast_copy_string(tmp->context, p->chan->context, sizeof(tmp->context)); ast_copy_string(tmp->exten, p->chan->exten, sizeof(tmp->exten)); @@ -1945,14 +1943,14 @@ AST_LIST_LOCK(&agents); ast_mutex_lock(&p->lock); if (!res) { - res = ast_set_read_format(chan, ast_best_codec(chan->nativeformats)); + res = ast_set_read_format(chan, ast_channel_best_codec(chan)); if (res) - ast_log(LOG_WARNING, "Unable to set read format to %d\n", ast_best_codec(chan->nativeformats)); + ast_log(LOG_WARNING, "Unable to set read format to %d\n", ast_channel_best_codec(chan)); } if (!res) { - res = ast_set_write_format(chan, ast_best_codec(chan->nativeformats)); + res = ast_set_write_format(chan, ast_channel_best_codec(chan)); if (res) - ast_log(LOG_WARNING, "Unable to set write format to %d\n", ast_best_codec(chan->nativeformats)); + ast_log(LOG_WARNING, "Unable to set write format to %d\n", ast_channel_best_codec(chan)); } /* Check once more just in case */ if (p->chan) @@ -2004,7 +2002,7 @@ ast_queue_log("NONE", chan->uniqueid, agent, "AGENTLOGIN", "%s", chan->name); if (option_verbose > 1) ast_verbose(VERBOSE_PREFIX_2 "Agent '%s' logged in (format %s/%s)\n", p->agent, - ast_getformatname(chan->readformat), ast_getformatname(chan->writeformat)); + ast_getformatname(ast_get_read_format(chan)), ast_getformatname(chan->writeformat)); /* Login this channel and wait for it to go away */ p->chan = chan; --- channels/chan_sip.c (svn) +++ channels/chan_sip.c (working copy) @@ -2953,8 +2953,13 @@ switch (frame->frametype) { case AST_FRAME_VOICE: if (!(frame->subclass & ast->nativeformats)) { - ast_log(LOG_WARNING, "Asked to transmit frame type %d, while native formats is %d (read/write = %d/%d)\n", - frame->subclass, ast->nativeformats, ast->readformat, ast->writeformat); + ast_log(LOG_WARNING, "Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n", + ast_getformatname(frame->subclass), + ast_getformatname(ast->nativeformats), + ast_getformatname(ast_get_read_format(ast)), + ast_getformatname(ast_get_write_format(ast))); + ast_frame_dump(ast->name, frame, "<<"); + ast_backtrace(); return 0; } if (p) { @@ -3189,7 +3194,7 @@ else what = global_capability; tmp->nativeformats = ast_codec_choose(&i->prefs, what, 1) | (i->jointcapability & AST_FORMAT_VIDEO_MASK); - fmt = ast_best_codec(tmp->nativeformats); + fmt = ast_channel_best_codec(tmp); if (title) ast_string_field_build(tmp, name, "SIP/%s-%04lx", title, ast_random() & 0xffff); @@ -3439,8 +3444,7 @@ if (option_debug) ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass); p->owner->nativeformats = (p->owner->nativeformats & AST_FORMAT_VIDEO_MASK) | f->subclass; - ast_set_read_format(p->owner, p->owner->readformat); - ast_set_write_format(p->owner, p->owner->writeformat); + ast_channel_formats_reset(p->owner); } if ((ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_INBAND) && p->vad) { f = ast_dsp_process(p->owner, p->vad, f); @@ -4165,8 +4169,7 @@ ast_getformatname_multiple(s1, slen, p->jointcapability), ast_getformatname_multiple(s2, slen, p->owner->nativeformats)); p->owner->nativeformats = ast_codec_choose(&p->prefs, p->jointcapability, 1) | (p->capability & vpeercapability); - ast_set_read_format(p->owner, p->owner->readformat); - ast_set_write_format(p->owner, p->owner->writeformat); + ast_channel_formats_reset(p->owner); } if ((bridgepeer=ast_bridged_channel(p->owner))) { /* We have a bridge */ @@ -10854,8 +10857,8 @@ ast_string_field_build(transferee, name, "Parking/%s", chan1->name); /* Make formats okay */ - transferee->readformat = chan1->readformat; - transferee->writeformat = chan1->writeformat; + transferee->readformat = ast_get_read_format(chan1); + transferee->writeformat = ast_get_write_format(chan1); ast_channel_masquerade(transferee, chan1); /* Setup the extensions and such */ @@ -10868,8 +10871,8 @@ ast_string_field_build(transferer, name, "SIPPeer/%s", chan2->name); /* Make formats okay */ - transferer->readformat = chan2->readformat; - transferer->writeformat = chan2->writeformat; + transferer->readformat = ast_get_read_format(chan2); + transferer->writeformat = ast_get_write_format(chan2); ast_channel_masquerade(transferer, chan2); /* Setup the extensions and such */ --- channels/chan_h323.c (svn) +++ channels/chan_h323.c (working copy) @@ -234,8 +234,7 @@ if (h323debug) ast_log(LOG_DEBUG, "Preparing %s for new native format\n", c->name); c->nativeformats = pvt->nativeformats; - ast_set_read_format(c, c->readformat); - ast_set_write_format(c, c->writeformat); + ast_channel_formats_reset(c); } if (pvt->needhangup) { if (h323debug) @@ -564,8 +563,7 @@ ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass); pvt->owner->nativeformats = f->subclass; pvt->nativeformats = f->subclass; - ast_set_read_format(pvt->owner, pvt->owner->readformat); - ast_set_write_format(pvt->owner, pvt->owner->writeformat); + ast_channel_formats_reset(pvt->owner); ast_mutex_unlock(&pvt->owner->lock); } /* Do in-band DTMF detection */ @@ -610,7 +608,7 @@ } else { if (!(frame->subclass & c->nativeformats)) { ast_log(LOG_WARNING, "Asked to transmit frame type %d, while native formats is %d (read/write = %d/%d)\n", - frame->subclass, c->nativeformats, c->readformat, c->writeformat); + frame->subclass, c->nativeformats, ast_get_read_format(c), ast_get_write_format(c)); return 0; } } @@ -736,7 +734,7 @@ ch->nativeformats = global_options.capability; } pvt->nativeformats = ch->nativeformats; - fmt = ast_best_codec(ch->nativeformats); + fmt = ast_channel_best_codec(ch); ch->fds[0] = ast_rtp_fd(pvt->rtp); if (state == AST_STATE_RING) { ch->rings = 1; @@ -1195,8 +1193,7 @@ pvt->nativeformats = rtptype.code; if (pvt->owner && !ast_mutex_trylock(&pvt->owner->lock)) { pvt->owner->nativeformats = pvt->nativeformats; - ast_set_read_format(pvt->owner, pvt->owner->readformat); - ast_set_write_format(pvt->owner, pvt->owner->writeformat); + ast_channel_reset_formats(pvt->owner); if (pvt->options.progress_audio) ast_queue_control(pvt->owner, AST_CONTROL_PROGRESS); ast_mutex_unlock(&pvt->owner->lock); --- app.c (svn) +++ app.c (working copy) @@ -319,7 +319,7 @@ ast_set_flag(chan, AST_FLAG_WRITE_INT); else ast_clear_flag(chan, AST_FLAG_WRITE_INT); - ls->origwfmt = chan->writeformat; + ls->origwfmt = ast_get_write_format(chan); if (ast_set_write_format(chan, AST_FORMAT_SLINEAR)) { ast_log(LOG_WARNING, "Unable to set '%s' to linear format (write)\n", chan->name); free(ls); @@ -571,7 +571,7 @@ return -1; } ast_dsp_set_threshold(sildet, silencethreshold); - rfmt = chan->readformat; + rfmt = ast_get_read_format(chan); res = ast_set_read_format(chan, AST_FORMAT_SLINEAR); if (res < 0) { ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n"); --- pbx.c (svn) +++ pbx.c (working copy) @@ -4141,8 +4141,8 @@ ast_string_field_build(tmpchan, name, "AsyncGoto/%s", chan->name); ast_setstate(tmpchan, chan->_state); /* Make formats okay */ - tmpchan->readformat = chan->readformat; - tmpchan->writeformat = chan->writeformat; + tmpchan->readformat = ast_get_read_format(chan); + tmpchan->writeformat = ast_get_write_format(chan); /* Setup proper location */ ast_explicit_goto(tmpchan, S_OR(context, chan->context), S_OR(exten, chan->exten), priority); --- channel.c (svn) +++ channel.c (working copy) @@ -1993,7 +1993,7 @@ /* This frame can't be from the current native formats -- drop it on the floor */ ast_log(LOG_NOTICE, "Dropping incompatible voice frame on %s of format %s since our native format has changed to %s\n", - chan->name, ast_getformatname(f->subclass), ast_getformatname(chan->nativeformats)); + chan->name, ast_getformatname(f->subclass), ast_chan_getformatname(chan)); ast_frfree(f); f = &ast_null_frame; } else { @@ -2749,12 +2749,12 @@ return ast_channel_sendhtml(chan, AST_HTML_URL, url, strlen(url) + 1); } -int ast_channel_make_compatible(struct ast_channel *chan, struct ast_channel *peer) +/*! Set up translation from chan to peer */ +static int ast_channel_make_compatible_helper(struct ast_channel *chan, struct ast_channel *peer) { int src; int dst; - /* Set up translation from the chan to the peer */ src = chan->nativeformats; dst = peer->nativeformats; if (ast_translator_best_choice(&dst, &src) < 0) { @@ -2777,31 +2777,23 @@ ast_log(LOG_WARNING, "Unable to set write format on channel %s to %d\n", peer->name, dst); return -1; } + return 0; +} - /* Set up translation from the peer to the chan */ - src = peer->nativeformats; - dst = chan->nativeformats; - if (ast_translator_best_choice(&dst, &src) < 0) { - ast_log(LOG_WARNING, "No path to translate from %s(%d) to %s(%d)\n", peer->name, src, chan->name, dst); - return -1; +int ast_channel_make_compatible(struct ast_channel *chan, struct ast_channel *peer) +{ + /* Some callers not check return code, and we must try to set all call legs correctly */ + int rc = 0; + /* Set up translation from the chan to the peer */ + if (ast_channel_make_compatible_helper(chan, peer) < 0) { + rc = -1; } - /* if the best path is not 'pass through', then - transcoding is needed; if desired, force transcode path - to use SLINEAR between channels, but only if there is - no direct conversion available */ - if ((src != dst) && ast_opt_transcode_via_slin && - (ast_translate_path_steps(dst, src) != 1)) - dst = AST_FORMAT_SLINEAR; - if (ast_set_read_format(peer, dst) < 0) { - ast_log(LOG_WARNING, "Unable to set read format on channel %s to %d\n", peer->name, dst); - return -1; + /* Set up translation from the peer to the chan */ + if (ast_channel_make_compatible_helper(peer, chan) < 0) { + rc = -1; } - if (ast_set_write_format(chan, dst) < 0) { - ast_log(LOG_WARNING, "Unable to set write format on channel %s to %d\n", chan->name, dst); - return -1; - } - return 0; + return rc; } int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clone) @@ -2936,8 +2928,8 @@ void *t_pvt; struct ast_callerid tmpcid; struct ast_channel *clone = original->masq; - int rformat = original->readformat; - int wformat = original->writeformat; + int rformat = ast_get_read_format(original); + int wformat = ast_get_write_format(original); char newn[100]; char orig[100]; char masqn[100]; @@ -3573,7 +3565,8 @@ } } - if (((c0->writeformat != c1->readformat) || (c0->readformat != c1->writeformat) || + if (((ast_get_write_format(c0) != ast_get_read_format(c1)) || + (ast_get_read_format(c0) != ast_get_write_format(c1)) || (c0->nativeformats != o0nativeformats) || (c1->nativeformats != o1nativeformats)) && !(c0->generator || c1->generator)) { if (ast_channel_make_compatible(c0, c1)) { @@ -3671,7 +3664,7 @@ if (!(ts = ast_calloc(1, sizeof(*ts)))) return NULL; - ts->origwfmt = chan->writeformat; + ts->origwfmt = ast_get_write_format(chan); if (ast_set_write_format(chan, AST_FORMAT_SLINEAR)) { ast_log(LOG_WARNING, "Unable to set '%s' to signed linear format (write)\n", chan->name); tonepair_release(NULL, ts); @@ -4055,7 +4048,7 @@ return NULL; } - state->old_write_format = chan->writeformat; + state->old_write_format = ast_get_write_format(chan); if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) { ast_log(LOG_ERROR, "Could not set write format to SLINEAR\n"); --- cli.c (svn) +++ cli.c (working copy) @@ -736,8 +736,8 @@ S_OR(c->cid.cid_name, "(N/A)"), S_OR(c->cid.cid_dnid, "(N/A)"), ast_state2str(c->_state), c->_state, c->rings, ast_getformatname_multiple(nf, sizeof(nf), c->nativeformats), - ast_getformatname_multiple(wf, sizeof(wf), c->writeformat), - ast_getformatname_multiple(rf, sizeof(rf), c->readformat), + ast_getformatname_multiple(wf, sizeof(wf), ast_get_write_format(c)), + ast_getformatname_multiple(rf, sizeof(rf), ast_get_read_format(c)), c->fds[0], c->fin & ~DEBUGCHAN_FLAG, (c->fin & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "", c->fout & ~DEBUGCHAN_FLAG, (c->fout & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "", --- apps/app_amd.c (svn) +++ apps/app_amd.c (working copy) @@ -133,7 +133,7 @@ AST_APP_ARG(argSilenceThreshold); ); if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "AMD: %s %s %s (Fmt: %d)\n", chan->name ,chan->cid.cid_ani, chan->cid.cid_rdnis, chan->readformat); + ast_verbose(VERBOSE_PREFIX_3 "AMD: %s %s %s (Fmt: %d)\n", chan->name ,chan->cid.cid_ani, chan->cid.cid_rdnis, ast_get_read_format(chan)); /* Lets parse the arguments. */ if (ast_strlen_zero(data)) { @@ -178,7 +178,7 @@ initialSilence, greeting, afterGreetingSilence, totalAnalysisTime, minimumWordLength, betweenWordsSilence, maximumNumberOfWords, silenceThreshold ); - readFormat = chan->readformat; + readFormat = ast_get_read_format(chan); res = ast_set_read_format(chan, AST_FORMAT_SLINEAR); if (res < 0 ) { ast_log(LOG_WARNING, "AMD: Channel [%s]. Unable to set to linear mode, giving up\n", chan->name ); --- apps/app_dumpchan.c (svn) +++ apps/app_dumpchan.c (working copy) @@ -112,8 +112,8 @@ c->_state, c->rings, c->nativeformats, - c->writeformat, - c->readformat, + ast_get_write_format(c), + ast_get_read_format(c), c->fds[0], c->fin & ~DEBUGCHAN_FLAG, (c->fin & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "", c->fout & ~DEBUGCHAN_FLAG, (c->fout & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "", (long)c->whentohangup, hour, --- apps/app_festival.c (svn) +++ apps/app_festival.c (working copy) @@ -185,7 +185,7 @@ ast_stopstream(chan); ast_indicate(chan, -1); - owriteformat = chan->writeformat; + owriteformat = ast_get_write_format(chan); res = ast_set_write_format(chan, AST_FORMAT_SLINEAR); if (res < 0) { ast_log(LOG_WARNING, "Unable to set write format to signed linear\n"); --- apps/app_dial.c (svn) +++ apps/app_dial.c (working copy) @@ -469,7 +469,7 @@ if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "Now forwarding %s to '%s/%s' (thanks to %s)\n", in->name, tech, stuff, c->name); /* Setup parameters */ - c = o->chan = ast_request(tech, in->nativeformats, stuff, &cause); + c = o->chan = ast_request_inherit(in, tech, stuff, &cause); if (!c) ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s' (cause = %d)\n", tech, stuff, cause); else @@ -1021,7 +1021,7 @@ } ast_copy_string(numsubst, number, sizeof(numsubst)); /* Request the peer */ - tmp->chan = ast_request(tech, chan->nativeformats, numsubst, &cause); + tmp->chan = ast_request_inherit(chan, tech, numsubst, &cause); if (!tmp->chan) { /* If we can't, just go on to the next call */ ast_log(LOG_WARNING, "Unable to create channel of type '%s' (cause %d - %s)\n", tech, cause, ast_cause2str(cause)); @@ -1050,7 +1050,7 @@ ast_verbose(VERBOSE_PREFIX_3 "Now forwarding %s to '%s/%s' (thanks to %s)\n", chan->name, tech, stuff, tmp->chan->name); ast_hangup(tmp->chan); /* Setup parameters */ - tmp->chan = ast_request(tech, chan->nativeformats, stuff, &cause); + tmp->chan = ast_request_inherit(chan, tech, stuff, &cause); if (!tmp->chan) ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s' (cause = %d)\n", tech, stuff, cause); else --- apps/app_nbscat.c (svn) +++ apps/app_nbscat.c (working copy) @@ -132,7 +132,7 @@ ast_stopstream(chan); - owriteformat = chan->writeformat; + owriteformat = ast_get_write_format(chan); res = ast_set_write_format(chan, AST_FORMAT_SLINEAR); if (res < 0) { ast_log(LOG_WARNING, "Unable to set write format to signed linear\n"); --- apps/app_test.c (svn) +++ apps/app_test.c (working copy) @@ -76,7 +76,7 @@ struct timeval start; struct ast_frame *f; int rformat; - rformat = chan->readformat; + rformat = ast_get_read_format(chan); if (ast_set_read_format(chan, AST_FORMAT_SLINEAR)) { ast_log(LOG_NOTICE, "Unable to set to linear mode!\n"); return -1; --- apps/app_record.c (svn) +++ apps/app_record.c (working copy) @@ -218,7 +218,7 @@ /* The end of beep code. Now the recording starts */ if (silence > 0) { - rfmt = chan->readformat; + rfmt = ast_get_read_format(chan); res = ast_set_read_format(chan, AST_FORMAT_SLINEAR); if (res < 0) { ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n"); --- apps/app_mp3.c (svn) +++ apps/app_mp3.c (working copy) @@ -147,7 +147,7 @@ ast_stopstream(chan); - owriteformat = chan->writeformat; + owriteformat = ast_get_write_format(chan); res = ast_set_write_format(chan, AST_FORMAT_SLINEAR); if (res < 0) { ast_log(LOG_WARNING, "Unable to set write format to signed linear\n"); --- apps/app_ices.c (svn) +++ apps/app_ices.c (working copy) @@ -132,7 +132,7 @@ return -1; } - oreadformat = chan->readformat; + oreadformat = ast_get_read_format(chan); res = ast_set_read_format(chan, AST_FORMAT_SLINEAR); if (res < 0) { close(fds[0]); --- apps/app_talkdetect.c (svn) +++ apps/app_talkdetect.c (working copy) @@ -112,7 +112,7 @@ res = ast_answer(chan); } if (!res) { - origrformat = chan->readformat; + origrformat = ast_get_read_format(chan); if ((res = ast_set_read_format(chan, AST_FORMAT_SLINEAR))) ast_log(LOG_WARNING, "Unable to set read format to linear!\n"); } --- apps/app_chanisavail.c (svn) +++ apps/app_chanisavail.c (working copy) @@ -122,7 +122,7 @@ snprintf(trychan, sizeof(trychan), "%s/%s",cur,number); status = inuse = ast_device_state(trychan); } - if ((inuse <= 1) && (tempchan = ast_request(tech, chan->nativeformats, number, &status))) { + if ((inuse <= 1) && (tempchan = ast_request_inherit(chan, tech, number, &status))) { pbx_builtin_setvar_helper(chan, "AVAILCHAN", tempchan->name); /* Store the originally used channel too */ snprintf(tmp, sizeof(tmp), "%s/%s", tech, number); --- apps/app_chanspy.c (svn) +++ apps/app_chanspy.c (working copy) @@ -387,8 +387,8 @@ LOCAL_USER_ADD(u); - oldrf = chan->readformat; - oldwf = chan->writeformat; + oldrf = ast_get_read_format(chan); + oldwf = ast_get_write_format(chan); if (ast_set_read_format(chan, AST_FORMAT_SLINEAR) < 0) { ast_log(LOG_ERROR, "Could Not Set Read Format.\n"); LOCAL_USER_REMOVE(u); --- apps/app_echo.c (svn) +++ apps/app_echo.c (working copy) @@ -62,9 +62,7 @@ LOCAL_USER_ADD(u); - format = ast_best_codec(chan->nativeformats); - ast_set_write_format(chan, format); - ast_set_read_format(chan, format); + ast_set_best_format(chan); while (ast_waitfor(chan, -1) > -1) { struct ast_frame *f = ast_read(chan); --- apps/app_queue.c (svn) +++ apps/app_queue.c (working copy) @@ -1439,7 +1439,7 @@ location = ""; /* Request the peer */ - tmp->chan = ast_request(tech, qe->chan->nativeformats, location, &status); + tmp->chan = ast_request_inherit(qe->chan, tech, location, &status); if (!tmp->chan) { /* If we can't, just go on to the next call */ #if 0 ast_log(LOG_NOTICE, "Unable to create channel of type '%s' for Queue\n", cur->tech); @@ -1733,7 +1733,7 @@ if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "Now forwarding %s to '%s/%s' (thanks to %s)\n", in->name, tech, stuff, o->chan->name); /* Setup parameters */ - o->chan = ast_request(tech, in->nativeformats, stuff, &status); + o->chan = ast_request_inherit(in, tech, stuff, &status); if (status != o->oldstatus) update_dial_status(qe->parent, o->member, status); if (!o->chan) { --- apps/app_dictate.c (svn) +++ apps/app_dictate.c (working copy) @@ -120,7 +120,7 @@ if (args.argc > 1 && args.filename) { filename = args.filename; } - oldr = chan->readformat; + oldr = ast_get_read_format(chan); if ((res = ast_set_read_format(chan, AST_FORMAT_SLINEAR)) < 0) { ast_log(LOG_WARNING, "Unable to set to linear mode.\n"); LOCAL_USER_REMOVE(u); --- apps/app_waitforsilence.c (svn) +++ apps/app_waitforsilence.c (working copy) @@ -76,7 +76,7 @@ time_t start, now; time(&start); - rfmt = chan->readformat; /* Set to linear mode */ + rfmt = ast_get_read_format(chan); /* Set to linear mode */ res = ast_set_read_format(chan, AST_FORMAT_SLINEAR); if (res < 0) { ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n"); --- indications.c (svn) +++ indications.c (working copy) @@ -116,7 +116,7 @@ struct playtones_state *ps; if (!(ps = ast_calloc(1, sizeof(*ps)))) return NULL; - ps->origwfmt = chan->writeformat; + ps->origwfmt = ast_get_write_format(chan); if (ast_set_write_format(chan, AST_FORMAT_SLINEAR)) { ast_log(LOG_WARNING, "Unable to set '%s' to signed linear format (write)\n", chan->name); playtones_release(NULL, ps); --- res/res_adsi.c (svn) +++ res/res_adsi.c (working copy) @@ -360,8 +360,8 @@ int writeformat, readformat; int waitforswitch = 0; - writeformat = chan->writeformat; - readformat = chan->readformat; + writeformat = ast_get_write_format(chan); + readformat = ast_get_read_format(chan); newdatamode = chan->adsicpe & ADSI_FLAG_DATAMODE; --- res/res_features.c (svn) +++ res/res_features.c (working copy) @@ -380,8 +380,8 @@ ast_string_field_build(chan, name, "Parked/%s",rchan->name); /* Make formats okay */ - chan->readformat = rchan->readformat; - chan->writeformat = rchan->writeformat; + chan->readformat = ast_get_read_format(rchan); + chan->writeformat = ast_get_write_format(rchan); ast_channel_masquerade(chan, rchan); /* Setup the extensions and such */ @@ -690,7 +690,7 @@ l = strlen(xferto); snprintf(xferto + l, sizeof(xferto) - l, "@%s/n", transferer_real_context); /* append context */ - newchan = ast_feature_request_and_dial(transferer, "Local", ast_best_codec(transferer->nativeformats), + newchan = ast_feature_request_and_dial(transferer, "Local", ast_channel_best_codec(transferer), xferto, 15000, &outstate, transferer->cid.cid_num, transferer->cid.cid_name); ast_indicate(transferer, -1); if (!newchan) { @@ -738,8 +738,8 @@ } ast_string_field_build(xferchan, name, "Transfered/%s", transferee->name); /* Make formats okay */ - xferchan->readformat = transferee->readformat; - xferchan->writeformat = transferee->writeformat; + xferchan->readformat = ast_get_read_format(transferee); + xferchan->writeformat = ast_get_write_format(transferee); ast_channel_masquerade(xferchan, transferee); ast_explicit_goto(xferchan, transferee->context, transferee->exten, transferee->priority); xferchan->_state = AST_STATE_UP; --- res/res_musiconhold.c (svn) +++ res/res_musiconhold.c (working copy) @@ -301,7 +301,7 @@ state->class = class; } - state->origwfmt = chan->writeformat; + state->origwfmt = ast_get_write_format(chan); if (ast_set_write_format(chan, AST_FORMAT_SLINEAR)) { ast_log(LOG_WARNING, "Unable to set '%s' to linear format (write)\n", chan->name); @@ -678,7 +678,7 @@ struct mohclass *class = params; if ((res = mohalloc(class))) { - res->origwfmt = chan->writeformat; + res->origwfmt = ast_get_write_format(chan); if (ast_set_write_format(chan, class->format)) { ast_log(LOG_WARNING, "Unable to set channel '%s' to format '%s'\n", chan->name, ast_codec2str(class->format)); moh_release(NULL, res); --- res/res_agi.c (svn) +++ res/res_agi.c (working copy) @@ -865,7 +865,7 @@ } if (silence > 0) { - rfmt = chan->readformat; + rfmt = ast_get_read_format(chan); res = ast_set_read_format(chan, AST_FORMAT_SLINEAR); if (res < 0) { ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n"); @@ -1988,7 +1988,7 @@ if (chan->_softhangup) ast_log(LOG_WARNING, "If you want to run AGI on hungup channels you should use DeadAGI!\n"); - readformat = chan->readformat; + readformat = ast_get_read_format(chan); if (ast_set_read_format(chan, AST_FORMAT_SLINEAR)) { ast_log(LOG_WARNING, "Unable to set channel '%s' to linear mode\n", chan->name); return -1; --- file.c (svn) +++ file.c (working copy) @@ -391,7 +391,7 @@ FILE *bfile; struct ast_filestream *s; - if ( !(chan->writeformat & f->format) && + if ( !(ast_get_write_format(chan) & f->format) && !(f->format >= AST_FORMAT_MAX_AUDIO && fmt)) { free(fn); continue; /* not a supported format */ @@ -557,7 +557,7 @@ ast_log(LOG_WARNING, "File %s does not exist in any format\n", filename); return NULL; } - chan->oldwriteformat = chan->writeformat; + chan->oldwriteformat = ast_get_write_format(chan); /* Set the channel to a format we can work with */ res = ast_set_write_format(chan, fmts); res = ast_filehelper(buf, chan, NULL, ACTION_OPEN); @@ -807,7 +807,7 @@ #endif return 0; } - 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_chan_getformatname_multiple(fmt, sizeof(fmt), chan), strerror(errno)); return -1; }