ast_channel_tech_set(chn, &mbl_tech);
ast_format_cap_add(ast_channel_nativeformats(chn), &prefformat);
- ast_format_copy(&chn->rawreadformat, &prefformat);
- ast_format_copy(&chn->rawwriteformat, &prefformat);
- ast_format_copy(&chn->writeformat, &prefformat);
- ast_format_copy(&chn->readformat, &prefformat);
+ ast_format_copy(ast_channel_rawreadformat(chn), &prefformat);
+ ast_format_copy(ast_channel_rawwriteformat(chn), &prefformat);
+ ast_format_copy(ast_channel_writeformat(chn), &prefformat);
+ ast_format_copy(ast_channel_readformat(chn), &prefformat);
ast_channel_tech_pvt_set(chn, pvt);
if (state == AST_STATE_RING)
ast_codec_pref_index(&i->prefs, 0, &tmpfmt);
ast_format_cap_add(ast_channel_nativeformats(ch), &tmpfmt);
- ast_format_copy(&ch->rawwriteformat, &tmpfmt);
- ast_format_copy(&ch->rawreadformat, &tmpfmt);
+ ast_format_copy(ast_channel_rawwriteformat(ch), &tmpfmt);
+ ast_format_copy(ast_channel_rawreadformat(ch), &tmpfmt);
ast_jb_configure(ch, &global_jbconf);
"Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n",
ast_getformatname(&f->subclass.format),
ast_getformatname_multiple(buf, sizeof(buf), ast_channel_nativeformats(ast)),
- ast_getformatname(&ast->readformat),
- ast_getformatname(&ast->writeformat));
+ ast_getformatname(ast_channel_readformat(ast)),
+ ast_getformatname(ast_channel_writeformat(ast)));
ast_set_write_format(ast, &f->subclass.format);
} else {
}
if (gH323Debug)
ast_verb(0, "Writeformat before update %s/%s\n",
- ast_getformatname(&p->owner->writeformat),
+ ast_getformatname(ast_channel_writeformat(p->owner)),
ast_getformatname_multiple(formats, sizeof(formats), ast_channel_nativeformats(p->owner)));
if (txframes)
ast_codec_pref_setsize(&p->prefs, fmt, txframes);
}
ast_format_cap_set(ast_channel_nativeformats(p->owner), fmt);
- ast_set_write_format(p->owner, &p->owner->writeformat);
- ast_set_read_format(p->owner, &p->owner->readformat);
+ ast_set_write_format(p->owner, ast_channel_writeformat(p->owner));
+ ast_set_read_format(p->owner, ast_channel_readformat(p->owner));
ast_channel_unlock(p->owner);
} else
ast_log(LOG_ERROR, "No owner found\n");
if (gH323Debug)
ast_verb(0, "Readformat before update %s\n",
- ast_getformatname(&p->owner->readformat));
+ ast_getformatname(ast_channel_readformat(p->owner)));
ast_format_cap_set(ast_channel_nativeformats(p->owner), fmt);
- ast_set_read_format(p->owner, &p->owner->readformat);
+ ast_set_read_format(p->owner, ast_channel_readformat(p->owner));
ast_channel_unlock(p->owner);
} else
ast_log(LOG_ERROR, "No owner found\n");
return 0;
}
- if (ooh323_convertAsteriskCapToH323Cap(&chan->writeformat) < 0) {
+ if (ooh323_convertAsteriskCapToH323Cap(ast_channel_writeformat(chan)) < 0) {
ast_log(LOG_WARNING, "Unknown format.\n");
return -1;
}
if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(p->owner), &f->subclass.format))) {
ast_debug(1, "Oooh, voice format changed to %s\n", ast_getformatname(&f->subclass.format));
ast_format_cap_set(ast_channel_nativeformats(p->owner), &f->subclass.format);
- ast_set_read_format(p->owner, &p->owner->readformat);
- ast_set_write_format(p->owner, &p->owner->writeformat);
+ ast_set_read_format(p->owner, ast_channel_readformat(p->owner));
+ ast_set_write_format(p->owner, ast_channel_writeformat(p->owner));
}
if (((p->dtmfmode & H323_DTMF_INBAND) || (p->faxdetect & FAXDETECT_CNG)) && p->vad &&
(f->subclass.format.id == AST_FORMAT_SLINEAR || f->subclass.format.id == AST_FORMAT_ALAW ||
ast_verb(3, "AMD: %s %s %s (Fmt: %s)\n", ast_channel_name(chan),
S_COR(chan->caller.ani.number.valid, chan->caller.ani.number.str, "(N/A)"),
S_COR(chan->redirecting.from.number.valid, chan->redirecting.from.number.str, "(N/A)"),
- ast_getformatname(&chan->readformat));
+ ast_getformatname(ast_channel_readformat(chan)));
/* Lets parse the arguments. */
if (!ast_strlen_zero(parse)) {
minimumWordLength, betweenWordsSilence, maximumNumberOfWords, silenceThreshold, maximumWordLength);
/* Set read format to signed linear so we get signed linear frames in */
- ast_format_copy(&readFormat, &chan->readformat);
+ ast_format_copy(&readFormat, ast_channel_readformat(chan));
if (ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR) < 0 ) {
ast_log(LOG_WARNING, "AMD: Channel [%s]. Unable to set to linear mode, giving up\n", ast_channel_name(chan));
pbx_builtin_setvar_helper(chan , "AMDSTATUS", "");
ast_clear_flag(&flags, AST_FLAGS_ALL);
}
- ast_format_copy(&oldwf, &chan->writeformat);
+ ast_format_copy(&oldwf, ast_channel_writeformat(chan));
if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR) < 0) {
ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
return -1;
ast_clear_flag(&flags, AST_FLAGS_ALL);
}
- oldwf = chan->writeformat;
+ ast_format_copy(&oldwf, ast_channel_writeformat(chan));
if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR) < 0) {
ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
return -1;
ast_set_flag(&flags, OPTION_DTMF_CYCLE);
ast_set_flag(&flags, OPTION_DAHDI_SCAN);
- ast_format_copy(&oldwf, &chan->writeformat);
+ ast_format_copy(&oldwf, ast_channel_writeformat(chan));
if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR) < 0) {
ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
return -1;
ast_format_set(&fmt, AST_FORMAT_SLINEAR, 0);
ast_channel_tech_set(tmp, &record_tech);
ast_format_cap_add_all(ast_channel_nativeformats(tmp));
- ast_format_copy(&tmp->writeformat, &fmt);
- ast_format_copy(&tmp->rawwriteformat, &fmt);
- ast_format_copy(&tmp->readformat, &fmt);
- ast_format_copy(&tmp->rawreadformat, &fmt);
+ ast_format_copy(ast_channel_writeformat(tmp), &fmt);
+ ast_format_copy(ast_channel_rawwriteformat(tmp), &fmt);
+ ast_format_copy(ast_channel_readformat(tmp), &fmt);
+ ast_format_copy(ast_channel_rawreadformat(tmp), &fmt);
return tmp;
}
if (args.argc > 1 && args.filename) {
filename = args.filename;
}
- ast_format_copy(&oldr, &chan->readformat);
+ ast_format_copy(&oldr, ast_channel_readformat(chan));
if ((res = ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR)) < 0) {
ast_log(LOG_WARNING, "Unable to set to linear mode.\n");
return -1;
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),
- ast_getformatname(&c->rawwriteformat),
- ast_getformatname(&c->rawreadformat),
+ ast_getformatname(ast_channel_writeformat(c)),
+ ast_getformatname(ast_channel_readformat(c)),
+ ast_getformatname(ast_channel_rawwriteformat(c)),
+ ast_getformatname(ast_channel_rawreadformat(c)),
ast_channel_writetrans(c) ? "Yes" : "No",
ast_translate_path_to_str(ast_channel_writetrans(c), &write_transpath),
ast_channel_readtrans(c) ? "Yes" : "No",
t30state = &fax.t30_state;
#endif
- ast_format_copy(&original_read_fmt, &s->chan->readformat);
+ ast_format_copy(&original_read_fmt, ast_channel_readformat(s->chan));
if (original_read_fmt.id != AST_FORMAT_SLINEAR) {
res = ast_set_read_format_by_id(s->chan, AST_FORMAT_SLINEAR);
if (res < 0) {
}
}
- ast_format_copy(&original_write_fmt, &s->chan->writeformat);
+ ast_format_copy(&original_write_fmt, ast_channel_writeformat(s->chan));
if (original_write_fmt.id != AST_FORMAT_SLINEAR) {
res = ast_set_write_format_by_id(s->chan, AST_FORMAT_SLINEAR);
if (res < 0) {
ast_stopstream(chan);
ast_indicate(chan, -1);
- ast_format_copy(&owriteformat, &chan->writeformat);
+ ast_format_copy(&owriteformat, ast_channel_writeformat(chan));
res = ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR);
if (res < 0) {
ast_log(LOG_WARNING, "Unable to set write format to signed linear\n");
return -1;
}
- ast_format_copy(&oreadformat, &chan->readformat);
+ ast_format_copy(&oreadformat, ast_channel_readformat(chan));
res = ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR);
if (res < 0) {
close(fds[0]);
)) {
int idx;
for (idx = 0; idx < AST_FRAME_BITS; idx++) {
- if (ast_format_to_old_bitfield(&chan->rawwriteformat) & (1 << idx)) {
+ if (ast_format_to_old_bitfield(ast_channel_rawwriteformat(chan)) & (1 << idx)) {
break;
}
}
ast_stopstream(chan);
- ast_format_copy(&owriteformat, &chan->writeformat);
+ ast_format_copy(&owriteformat, ast_channel_writeformat(chan));
res = ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR);
if (res < 0) {
ast_log(LOG_WARNING, "Unable to set write format to signed linear\n");
ast_stopstream(chan);
- ast_format_copy(&owriteformat, &chan->writeformat);
+ ast_format_copy(&owriteformat, ast_channel_writeformat(chan));
res = ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR);
if (res < 0) {
ast_log(LOG_WARNING, "Unable to set write format to signed linear\n");
/* The end of beep code. Now the recording starts */
if (silence > 0) {
- ast_format_copy(&rfmt, &chan->readformat);
+ ast_format_copy(&rfmt, ast_channel_readformat(chan));
res = ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR);
if (res < 0) {
ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n");
}
/* Record old read format */
- ast_format_copy(&oldreadformat, &chan->readformat);
+ ast_format_copy(&oldreadformat, ast_channel_readformat(chan));
/* Change read format to be signed linear */
if (ast_set_read_format(chan, &speech->format))
}
}
- ast_format_copy(&origrformat, &chan->readformat);
+ ast_format_copy(&origrformat, ast_channel_readformat(chan));
if ((ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR))) {
ast_log(LOG_WARNING, "Unable to set read format to linear!\n");
res = -1;
struct ast_frame *f;
struct ast_format rformat;
- ast_format_copy(&rformat, &chan->readformat);
+ ast_format_copy(&rformat, ast_channel_readformat(chan));
if (ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR)) {
ast_log(LOG_NOTICE, "Unable to set to linear mode!\n");
return -1;
}
/* normally this is done in the channel driver */
- ast_format_set(&test_channel1->writeformat, AST_FORMAT_GSM, 0);
+ ast_format_set(ast_channel_writeformat(test_channel1), AST_FORMAT_GSM, 0);
nativeformats = ast_channel_nativeformats(test_channel1);
- ast_format_cap_add(nativeformats, &test_channel1->writeformat);
- 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);
+ ast_format_cap_add(nativeformats, ast_channel_writeformat(test_channel1));
+ ast_format_set(ast_channel_rawwriteformat(test_channel1), AST_FORMAT_GSM, 0);
+ ast_format_set(ast_channel_readformat(test_channel1), AST_FORMAT_GSM, 0);
+ ast_format_set(ast_channel_rawreadformat(test_channel1), AST_FORMAT_GSM, 0);
ast_channel_tech_set(test_channel1, &fake_tech);
ast_test_status_update(test, "Test playing of extension when greeting is not available...\n");
int (*ast_dsp_func)(struct ast_dsp*, struct ast_frame*, int*) =
wait_for_silence ? ast_dsp_silence : ast_dsp_noise;
- ast_format_copy(&rfmt, &chan->readformat); /* Set to linear mode */
+ ast_format_copy(&rfmt, ast_channel_readformat(chan)); /* Set to linear mode */
if ((res = ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR)) < 0) {
ast_log(LOG_WARNING, "Unable to set channel to linear mode, giving up\n");
return -1;
return 0;
}
- if ((ast_format_cmp(&c0->writeformat, &c1->readformat) == AST_FORMAT_CMP_EQUAL) &&
- (ast_format_cmp(&c0->readformat, &c1->writeformat) == AST_FORMAT_CMP_EQUAL) &&
+ if ((ast_format_cmp(ast_channel_writeformat(c0), ast_channel_readformat(c1)) == AST_FORMAT_CMP_EQUAL) &&
+ (ast_format_cmp(ast_channel_readformat(c0), ast_channel_writeformat(c1)) == AST_FORMAT_CMP_EQUAL) &&
(ast_format_cap_identical(ast_channel_nativeformats(c0), ast_channel_nativeformats(c1)))) {
return 0;
}
}
/* See if we need to make these compatible */
- if ((ast_format_cmp(&c0->writeformat, &c1->readformat) == AST_FORMAT_CMP_EQUAL) &&
- (ast_format_cmp(&c0->readformat, &c1->writeformat) == AST_FORMAT_CMP_EQUAL) &&
+ if ((ast_format_cmp(ast_channel_writeformat(c0), ast_channel_readformat(c1)) == AST_FORMAT_CMP_EQUAL) &&
+ (ast_format_cmp(ast_channel_readformat(c0), ast_channel_writeformat(c1)) == AST_FORMAT_CMP_EQUAL) &&
(ast_format_cap_identical(ast_channel_nativeformats(c0), ast_channel_nativeformats(c1)))) {
return 0;
}
static void set_softmix_bridge_data(int rate, int interval, struct ast_bridge_channel *bridge_channel, int reset)
{
struct softmix_channel *sc = bridge_channel->bridge_pvt;
- unsigned int channel_read_rate = ast_format_rate(&bridge_channel->chan->rawreadformat);
+ unsigned int channel_read_rate = ast_format_rate(ast_channel_rawreadformat(bridge_channel->chan));
ast_mutex_lock(&sc->lock);
if (reset) {
int channel_native_rate;
int i;
/* Gather stats about channel sample rates. */
- channel_native_rate = MAX(ast_format_rate(&bridge_channel->chan->rawwriteformat),
- ast_format_rate(&bridge_channel->chan->rawreadformat));
+ channel_native_rate = MAX(ast_format_rate(ast_channel_rawwriteformat(bridge_channel->chan)),
+ ast_format_rate(ast_channel_rawreadformat(bridge_channel->chan)));
if (channel_native_rate > stats->highest_supported_rate) {
stats->highest_supported_rate = channel_native_rate;
memcpy(sc->final_buf, buf, softmix_datalen);
/* process the softmix channel's new write audio */
- softmix_process_write_audio(&trans_helper, &bridge_channel->chan->rawwriteformat, sc);
+ softmix_process_write_audio(&trans_helper, ast_channel_rawwriteformat(bridge_channel->chan), sc);
/* The frame is now ready for use... */
sc->have_frame = 1;
ast_debug(1, "Native formats changing from '%s' to '%s'\n", ast_getformatname_multiple(tmp1, sizeof(tmp1), ast_channel_nativeformats(ast)), ast_getformatname_multiple(tmp2, sizeof(tmp2), ast_channel_nativeformats(p->chan))); \
/* Native formats changed, reset things */ \
ast_format_cap_copy(ast_channel_nativeformats(ast), ast_channel_nativeformats(p->chan)); \
- ast_debug(1, "Resetting read to '%s' and write to '%s'\n", ast_getformatname(&ast->readformat), ast_getformatname(&ast->writeformat));\
- ast_set_read_format(ast, &ast->readformat); \
- ast_set_write_format(ast, &ast->writeformat); \
+ ast_debug(1, "Resetting read to '%s' and write to '%s'\n", ast_getformatname(ast_channel_readformat(ast)), ast_getformatname(ast_channel_writeformat(ast)));\
+ ast_set_read_format(ast, ast_channel_readformat(ast)); \
+ ast_set_write_format(ast, ast_channel_writeformat(ast)); \
} \
- if ((ast_format_cmp(&p->chan->readformat, &ast->rawreadformat) != AST_FORMAT_CMP_EQUAL) && !ast_channel_generator(p->chan)) \
- ast_set_read_format(p->chan, &ast->rawreadformat); \
- if ((ast_format_cmp(&p->chan->writeformat, &ast->rawwriteformat) != AST_FORMAT_CMP_EQUAL) && !ast_channel_generator(p->chan)) \
- ast_set_write_format(p->chan, &ast->rawwriteformat); \
+ if ((ast_format_cmp(ast_channel_readformat(p->chan), ast_channel_rawreadformat(ast)) != AST_FORMAT_CMP_EQUAL) && !ast_channel_generator(p->chan)) \
+ ast_set_read_format(p->chan, ast_channel_rawreadformat(ast)); \
+ if ((ast_format_cmp(ast_channel_writeformat(p->chan), ast_channel_rawwriteformat(ast)) != AST_FORMAT_CMP_EQUAL) && !ast_channel_generator(p->chan)) \
+ ast_set_write_format(p->chan, ast_channel_rawwriteformat(ast)); \
} \
} while(0)
else {
if ((f->frametype != AST_FRAME_VOICE) ||
(f->frametype != AST_FRAME_VIDEO) ||
- (ast_format_cmp(&f->subclass.format, &p->chan->writeformat) != AST_FORMAT_CMP_NOT_EQUAL)) {
+ (ast_format_cmp(&f->subclass.format, ast_channel_writeformat(p->chan)) != AST_FORMAT_CMP_NOT_EQUAL)) {
res = ast_write(p->chan, f);
} else {
ast_debug(1, "Dropping one incompatible %s frame on '%s' to '%s'\n",
ast_channel_tech_set(tmp, &agent_tech);
if (p->chan) {
ast_format_cap_copy(ast_channel_nativeformats(tmp), ast_channel_nativeformats(p->chan));
- ast_format_copy(&tmp->writeformat, &p->chan->writeformat);
- ast_format_copy(&tmp->rawwriteformat, &p->chan->writeformat);
- ast_format_copy(&tmp->readformat, &p->chan->readformat);
- ast_format_copy(&tmp->rawreadformat, &p->chan->readformat);
+ ast_format_copy(ast_channel_writeformat(tmp), ast_channel_writeformat(p->chan));
+ ast_format_copy(ast_channel_rawwriteformat(tmp), ast_channel_writeformat(p->chan));
+ ast_format_copy(ast_channel_readformat(tmp), ast_channel_readformat(p->chan));
+ ast_format_copy(ast_channel_rawreadformat(tmp), ast_channel_readformat(p->chan));
ast_channel_language_set(tmp, ast_channel_language(p->chan));
ast_channel_context_set(tmp, ast_channel_context(p->chan));
ast_channel_exten_set(tmp, ast_channel_exten(p->chan));
/* XXX Is this really all we copy form the originating channel?? */
} else {
- ast_format_set(&tmp->writeformat, AST_FORMAT_SLINEAR, 0);
- ast_format_set(&tmp->rawwriteformat, AST_FORMAT_SLINEAR, 0);
- ast_format_set(&tmp->readformat, AST_FORMAT_SLINEAR, 0);
- ast_format_set(&tmp->rawreadformat, AST_FORMAT_SLINEAR, 0);
- ast_format_cap_add(ast_channel_nativeformats(tmp), &tmp->writeformat);
+ ast_format_set(ast_channel_writeformat(tmp), AST_FORMAT_SLINEAR, 0);
+ ast_format_set(ast_channel_rawwriteformat(tmp), AST_FORMAT_SLINEAR, 0);
+ ast_format_set(ast_channel_readformat(tmp), AST_FORMAT_SLINEAR, 0);
+ ast_format_set(ast_channel_rawreadformat(tmp), AST_FORMAT_SLINEAR, 0);
+ ast_format_cap_add(ast_channel_nativeformats(tmp), ast_channel_writeformat(tmp));
}
/* Safe, agentlock already held */
ast_channel_tech_pvt_set(tmp, p);
snprintf(ast_channel_cdr(chan)->channel, sizeof(ast_channel_cdr(chan)->channel), "Agent/%s", p->agent);
ast_queue_log("NONE", ast_channel_uniqueid(chan), agent, "AGENTLOGIN", "%s", ast_channel_name(chan));
ast_verb(2, "Agent '%s' logged in (format %s/%s)\n", p->agent,
- ast_getformatname(&chan->readformat), ast_getformatname(&chan->writeformat));
+ ast_getformatname(ast_channel_readformat(chan)), ast_getformatname(ast_channel_writeformat(chan)));
/* Login this channel and wait for it to go away */
p->chan = chan;
if (p->ackcall) {
ast_channel_tech_set(tmp, &alsa_tech);
ast_channel_set_fd(tmp, 0, readdev);
- ast_format_set(&tmp->readformat, AST_FORMAT_SLINEAR, 0);
- ast_format_set(&tmp->writeformat, AST_FORMAT_SLINEAR, 0);
- ast_format_cap_add(ast_channel_nativeformats(tmp), &tmp->writeformat);
+ ast_format_set(ast_channel_readformat(tmp), AST_FORMAT_SLINEAR, 0);
+ ast_format_set(ast_channel_writeformat(tmp), AST_FORMAT_SLINEAR, 0);
+ ast_format_cap_add(ast_channel_nativeformats(tmp), ast_channel_writeformat(tmp));
ast_channel_tech_pvt_set(tmp, p);
if (!ast_strlen_zero(p->context))
ast_format_cap_add(ast_channel_nativeformats(p->input), &slin);
ast_format_cap_add(ast_channel_nativeformats(p->output), &slin);
- ast_format_copy(&p->input->readformat, &slin);
- ast_format_copy(&p->output->readformat, &slin);
- ast_format_copy(&p->input->rawreadformat, &slin);
- ast_format_copy(&p->output->rawreadformat, &slin);
- ast_format_copy(&p->input->writeformat, &slin);
- ast_format_copy(&p->output->writeformat, &slin);
- ast_format_copy(&p->input->rawwriteformat, &slin);
- ast_format_copy(&p->output->rawwriteformat, &slin);
+ ast_format_copy(ast_channel_readformat(p->input), &slin);
+ ast_format_copy(ast_channel_readformat(p->output), &slin);
+ ast_format_copy(ast_channel_rawreadformat(p->input), &slin);
+ ast_format_copy(ast_channel_rawreadformat(p->output), &slin);
+ ast_format_copy(ast_channel_writeformat(p->input), &slin);
+ ast_format_copy(ast_channel_writeformat(p->output), &slin);
+ ast_format_copy(ast_channel_rawwriteformat(p->input), &slin);
+ ast_format_copy(ast_channel_rawwriteformat(p->output), &slin);
ast_answer(p->output);
ast_answer(p->input);
}
ast_channel_tech_set(chan, &console_tech);
- ast_format_set(&chan->readformat, AST_FORMAT_SLINEAR16, 0);
- ast_format_set(&chan->writeformat, AST_FORMAT_SLINEAR16, 0);
- ast_format_cap_add(ast_channel_nativeformats(chan), &chan->readformat);
+ ast_format_set(ast_channel_readformat(chan), AST_FORMAT_SLINEAR16, 0);
+ ast_format_set(ast_channel_writeformat(chan), AST_FORMAT_SLINEAR16, 0);
+ ast_format_cap_add(ast_channel_nativeformats(chan), ast_channel_readformat(chan));
ast_channel_tech_pvt_set(chan, ref_pvt(pvt));
pvt->owner = chan;
return f;
}
- if (ast->rawreadformat.id == AST_FORMAT_SLINEAR) {
+ if (ast_channel_rawreadformat(ast)->id == AST_FORMAT_SLINEAR) {
if (!p->subs[idx].linear) {
p->subs[idx].linear = 1;
res = dahdi_setlinear(p->subs[idx].dfd, p->subs[idx].linear);
if (res)
ast_log(LOG_WARNING, "Unable to set channel %d (index %d) to linear mode.\n", p->channel, idx);
}
- } else if ((ast->rawreadformat.id == AST_FORMAT_ULAW) ||
- (ast->rawreadformat.id == AST_FORMAT_ALAW)) {
+ } else if ((ast_channel_rawreadformat(ast)->id == AST_FORMAT_ULAW) ||
+ (ast_channel_rawreadformat(ast)->id == AST_FORMAT_ALAW)) {
if (p->subs[idx].linear) {
p->subs[idx].linear = 0;
res = dahdi_setlinear(p->subs[idx].dfd, p->subs[idx].linear);
ast_log(LOG_WARNING, "Unable to set channel %d (index %d) to companded mode.\n", p->channel, idx);
}
} else {
- ast_log(LOG_WARNING, "Don't know how to read frames in format %s\n", ast_getformatname(&ast->rawreadformat));
+ ast_log(LOG_WARNING, "Don't know how to read frames in format %s\n", ast_getformatname(ast_channel_rawreadformat(ast)));
ast_mutex_unlock(&p->lock);
return NULL;
}
}
p->subs[idx].f.frametype = AST_FRAME_VOICE;
- ast_format_copy(&p->subs[idx].f.subclass.format, &ast->rawreadformat);
+ ast_format_copy(&p->subs[idx].f.subclass.format, ast_channel_rawreadformat(ast));
p->subs[idx].f.samples = READ_SIZE;
p->subs[idx].f.mallocd = 0;
p->subs[idx].f.offset = AST_FRIENDLY_OFFSET;
ast_channel_set_fd(tmp, 0, i->subs[idx].dfd);
ast_format_cap_add(ast_channel_nativeformats(tmp), &deflaw);
/* Start out assuming ulaw since it's smaller :) */
- ast_format_copy(&tmp->rawreadformat, &deflaw);
- ast_format_copy(&tmp->readformat, &deflaw);
- ast_format_copy(&tmp->rawwriteformat, &deflaw);
- ast_format_copy(&tmp->writeformat, &deflaw);
+ ast_format_copy(ast_channel_rawreadformat(tmp), &deflaw);
+ ast_format_copy(ast_channel_readformat(tmp), &deflaw);
+ ast_format_copy(ast_channel_rawwriteformat(tmp), &deflaw);
+ ast_format_copy(ast_channel_writeformat(tmp), &deflaw);
i->subs[idx].linear = 0;
dahdi_setlinear(i->subs[idx].dfd, i->subs[idx].linear);
features = 0;
ast_channel_adsicpe_set(tmp, AST_ADSI_UNAVAILABLE);
ast_best_codec(ast_channel_nativeformats(tmp), &tmpfmt);
- ast_format_copy(&tmp->writeformat, &tmpfmt);
- ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
- ast_format_copy(&tmp->readformat, &tmpfmt);
- ast_format_copy(&tmp->rawreadformat, &tmpfmt);
+ ast_format_copy(ast_channel_writeformat(tmp), &tmpfmt);
+ ast_format_copy(ast_channel_rawwriteformat(tmp), &tmpfmt);
+ ast_format_copy(ast_channel_readformat(tmp), &tmpfmt);
+ ast_format_copy(ast_channel_rawreadformat(tmp), &tmpfmt);
ast_channel_tech_pvt_set(tmp, i);
tmp->callgroup = client->callgroup;
ast_debug(1, "Oooh, format changed to %s\n", ast_getformatname(&f->subclass.format));
ast_format_cap_remove_bytype(ast_channel_nativeformats(p->owner), AST_FORMAT_TYPE_AUDIO);
ast_format_cap_add(ast_channel_nativeformats(p->owner), &f->subclass.format);
- ast_set_read_format(p->owner, &p->owner->readformat);
- ast_set_write_format(p->owner, &p->owner->writeformat);
+ ast_set_read_format(p->owner, ast_channel_readformat(p->owner));
+ ast_set_write_format(p->owner, ast_channel_writeformat(p->owner));
}
/* if ((ast_test_flag(p, SIP_DTMF) == SIP_DTMF_INBAND) && p->vad) {
f = ast_dsp_process(p->owner, p->vad, f);
"Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n",
ast_getformatname(&frame->subclass.format),
ast_getformatname_multiple(buf, sizeof(buf), ast_channel_nativeformats(ast)),
- ast_getformatname(&ast->readformat),
- ast_getformatname(&ast->writeformat));
+ ast_getformatname(ast_channel_readformat(ast)),
+ ast_getformatname(ast_channel_writeformat(ast)));
return 0;
}
if (p) {
ast_channel_name(chan),
jid,
resource,
- ast_getformatname(&chan->readformat),
- ast_getformatname(&chan->writeformat)
+ ast_getformatname(ast_channel_readformat(chan)),
+ ast_getformatname(ast_channel_writeformat(chan))
);
else
ast_log(LOG_WARNING, "No available channel\n");
ast_format_cap_from_old_bitfield(ast_channel_nativeformats(tmp), capability);
ast_best_codec(ast_channel_nativeformats(tmp), &tmpfmt);
- ast_format_copy(&tmp->readformat, &tmpfmt);
- ast_format_copy(&tmp->rawreadformat, &tmpfmt);
- ast_format_copy(&tmp->writeformat, &tmpfmt);
- ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
+ ast_format_copy(ast_channel_readformat(tmp), &tmpfmt);
+ ast_format_copy(ast_channel_rawreadformat(tmp), &tmpfmt);
+ ast_format_copy(ast_channel_writeformat(tmp), &tmpfmt);
+ ast_format_copy(ast_channel_rawwriteformat(tmp), &tmpfmt);
ast_channel_tech_pvt_set(tmp, CALLNO_TO_PTR(i->callno));
}
/* Make formats okay */
- chan1m->readformat = chan1->readformat;
- chan1m->writeformat = chan1->writeformat;
+ ast_format_copy(ast_channel_readformat(chan1m), ast_channel_readformat(chan1));
+ ast_format_copy(ast_channel_writeformat(chan1m), ast_channel_writeformat(chan1));
/* Prepare for taking over the channel */
if (ast_channel_masquerade(chan1m, chan1)) {
back the announcement */
/* Make formats okay */
- chan2m->readformat = chan2->readformat;
- chan2m->writeformat = chan2->writeformat;
+ ast_format_copy(ast_channel_readformat(chan2m), ast_channel_readformat(chan2));
+ ast_format_copy(ast_channel_writeformat(chan2m), ast_channel_writeformat(chan2));
ast_channel_parkinglot_set(chan2m, ast_channel_parkinglot(chan2));
/* Prepare for taking over the channel */
struct ast_format_cap *native = ast_channel_nativeformats(iaxs[fr->callno]->owner);
if (orignative) {
ast_format_cap_set(native, &f.subclass.format);
- if (iaxs[fr->callno]->owner->readformat.id) {
- ast_set_read_format(iaxs[fr->callno]->owner, &iaxs[fr->callno]->owner->readformat);
+ if (ast_channel_readformat(iaxs[fr->callno]->owner)->id) {
+ ast_set_read_format(iaxs[fr->callno]->owner, ast_channel_readformat(iaxs[fr->callno]->owner));
}
ast_format_cap_copy(native, orignative);
ast_channel_unlock(iaxs[fr->callno]->owner);
ast_verb(3, "Format for call is %s\n", ast_getformatname_multiple(tmp, sizeof(tmp), ast_channel_nativeformats(iaxs[fr->callno]->owner)));
/* Setup read/write formats properly. */
- if (iaxs[fr->callno]->owner->writeformat.id)
- ast_set_write_format(iaxs[fr->callno]->owner, &iaxs[fr->callno]->owner->writeformat);
- if (iaxs[fr->callno]->owner->readformat.id)
- ast_set_read_format(iaxs[fr->callno]->owner, &iaxs[fr->callno]->owner->readformat);
+ if (ast_channel_writeformat(iaxs[fr->callno]->owner)->id)
+ ast_set_write_format(iaxs[fr->callno]->owner, ast_channel_writeformat(iaxs[fr->callno]->owner));
+ if (ast_channel_readformat(iaxs[fr->callno]->owner)->id)
+ ast_set_read_format(iaxs[fr->callno]->owner, ast_channel_readformat(iaxs[fr->callno]->owner));
ast_channel_unlock(iaxs[fr->callno]->owner);
}
}
}
ast_format_cap_set(ast_channel_nativeformats(c), &best_fmt_native);
}
- ast_best_codec(ast_channel_nativeformats(c), &c->readformat);
- ast_format_copy(&c->writeformat, &c->readformat);
+ ast_best_codec(ast_channel_nativeformats(c), ast_channel_readformat(c));
+ ast_format_copy(ast_channel_writeformat(c), ast_channel_readformat(c));
}
return c;
ast_best_codec(ast_channel_nativeformats(tmp), &tmpfmt);
- ast_format_copy(&tmp->writeformat, &tmpfmt);
- ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
- ast_format_copy(&tmp->readformat, &tmpfmt);
- ast_format_copy(&tmp->rawreadformat, &tmpfmt);
+ ast_format_copy(ast_channel_writeformat(tmp), &tmpfmt);
+ ast_format_copy(ast_channel_rawwriteformat(tmp), &tmpfmt);
+ ast_format_copy(ast_channel_readformat(tmp), &tmpfmt);
+ ast_format_copy(ast_channel_rawreadformat(tmp), &tmpfmt);
ast_channel_tech_pvt_set(tmp, i);
tmp->callgroup = client->callgroup;
ast_debug(1, "Oooh, format changed to %s\n", ast_getformatname(&f->subclass.format));
ast_format_cap_remove_bytype(ast_channel_nativeformats(p->owner), AST_FORMAT_TYPE_AUDIO);
ast_format_cap_add(ast_channel_nativeformats(p->owner), &f->subclass.format);
- ast_set_read_format(p->owner, &p->owner->readformat);
- ast_set_write_format(p->owner, &p->owner->writeformat);
+ ast_set_read_format(p->owner, ast_channel_readformat(p->owner));
+ ast_set_write_format(p->owner, ast_channel_writeformat(p->owner));
}
/* if ((ast_test_flag(p, SIP_DTMF) == SIP_DTMF_INBAND) && p->vad) {
f = ast_dsp_process(p->owner, p->vad, f);
"Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n",
ast_getformatname(&frame->subclass.format),
ast_getformatname_multiple(buf, sizeof(buf), ast_channel_nativeformats(ast)),
- ast_getformatname(&ast->readformat),
- ast_getformatname(&ast->writeformat));
+ ast_getformatname(ast_channel_readformat(ast)),
+ ast_getformatname(ast_channel_writeformat(ast)));
return 0;
}
if (p) {
ast_channel_name(chan),
jid,
resource,
- ast_getformatname(&chan->readformat),
- ast_getformatname(&chan->writeformat)
+ ast_getformatname(ast_channel_readformat(chan)),
+ ast_getformatname(ast_channel_writeformat(chan))
);
else
ast_log(LOG_WARNING, "No available channel\n");
/* Determine our read/write format and set it on each channel */
ast_best_codec(p->reqcap, &fmt);
- ast_format_copy(&tmp->writeformat, &fmt);
- ast_format_copy(&tmp2->writeformat, &fmt);
- ast_format_copy(&tmp->rawwriteformat, &fmt);
- ast_format_copy(&tmp2->rawwriteformat, &fmt);
- ast_format_copy(&tmp->readformat, &fmt);
- ast_format_copy(&tmp2->readformat, &fmt);
- ast_format_copy(&tmp->rawreadformat, &fmt);
- ast_format_copy(&tmp2->rawreadformat, &fmt);
+ ast_format_copy(ast_channel_writeformat(tmp), &fmt);
+ ast_format_copy(ast_channel_writeformat(tmp2), &fmt);
+ ast_format_copy(ast_channel_rawwriteformat(tmp), &fmt);
+ ast_format_copy(ast_channel_rawwriteformat(tmp2), &fmt);
+ ast_format_copy(ast_channel_readformat(tmp), &fmt);
+ ast_format_copy(ast_channel_readformat(tmp2), &fmt);
+ ast_format_copy(ast_channel_rawreadformat(tmp), &fmt);
+ ast_format_copy(ast_channel_rawreadformat(tmp2), &fmt);
ast_channel_tech_pvt_set(tmp, p);
ast_channel_tech_pvt_set(tmp2, p);
if (!ast_format_cap_iscompatible(ast_channel_nativeformats(sub->owner), &f->subclass.format)) {
ast_debug(1, "Oooh, format changed to %s\n", ast_getformatname(&f->subclass.format));
ast_format_cap_set(ast_channel_nativeformats(sub->owner), &f->subclass.format);
- ast_set_read_format(sub->owner, &sub->owner->readformat);
- ast_set_write_format(sub->owner, &sub->owner->writeformat);
+ ast_set_read_format(sub->owner, ast_channel_readformat(sub->owner));
+ ast_set_write_format(sub->owner, ast_channel_writeformat(sub->owner));
}
/* Courtesy fearnor aka alex@pilosoft.com */
if ((sub->parent->dtmfmode & MGCP_DTMF_INBAND) && (sub->parent->dsp)) {
ast_log(LOG_WARNING, "Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n",
ast_getformatname(&frame->subclass.format),
ast_getformatname_multiple(buf, sizeof(buf), ast_channel_nativeformats(ast)),
- ast_getformatname(&ast->readformat),
- ast_getformatname(&ast->writeformat));
+ ast_getformatname(ast_channel_readformat(ast)),
+ ast_getformatname(ast_channel_writeformat(ast)));
/* return -1; */
}
}
ast_channel_rings_set(tmp, 1);
ast_best_codec(ast_channel_nativeformats(tmp), &tmpfmt);
- ast_format_copy(&tmp->writeformat, &tmpfmt);
- ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
- ast_format_copy(&tmp->readformat, &tmpfmt);
- ast_format_copy(&tmp->rawreadformat, &tmpfmt);
+ ast_format_copy(ast_channel_writeformat(tmp), &tmpfmt);
+ ast_format_copy(ast_channel_rawwriteformat(tmp), &tmpfmt);
+ ast_format_copy(ast_channel_readformat(tmp), &tmpfmt);
+ ast_format_copy(ast_channel_rawreadformat(tmp), &tmpfmt);
ast_channel_tech_pvt_set(tmp, sub);
if (!ast_strlen_zero(i->language))
ast_channel_language_set(tmp, i->language);
ast_best_codec(cap, &tmpfmt);
ast_format_cap_add(ast_channel_nativeformats(tmp), &prefformat);
- ast_format_copy(&tmp->writeformat, &tmpfmt);
- ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
- ast_format_copy(&tmp->readformat, &tmpfmt);
- ast_format_copy(&tmp->rawreadformat, &tmpfmt);
+ ast_format_copy(ast_channel_writeformat(tmp), &tmpfmt);
+ ast_format_copy(ast_channel_rawwriteformat(tmp), &tmpfmt);
+ ast_format_copy(ast_channel_readformat(tmp), &tmpfmt);
+ ast_format_copy(ast_channel_rawreadformat(tmp), &tmpfmt);
/* Link the channel and private together */
chan_list_ref(chlist, "Give a reference to ast_channel");
ast_channel_tech_set(chan, &multicast_rtp_tech);
ast_format_cap_add(ast_channel_nativeformats(chan), &fmt);
- ast_format_copy(&chan->writeformat, &fmt);
- ast_format_copy(&chan->rawwriteformat, &fmt);
- ast_format_copy(&chan->readformat, &fmt);
- ast_format_copy(&chan->rawreadformat, &fmt);
+ ast_format_copy(ast_channel_writeformat(chan), &fmt);
+ ast_format_copy(ast_channel_rawwriteformat(chan), &fmt);
+ ast_format_copy(ast_channel_readformat(chan), &fmt);
+ ast_format_copy(ast_channel_rawreadformat(chan), &fmt);
ast_channel_tech_pvt_set(chan, instance);
ast_channel_set_fd(tmp, 0, nbs_fd(i->nbs));
ast_format_cap_add(ast_channel_nativeformats(tmp), &prefformat);
- ast_format_copy(&tmp->rawreadformat, &prefformat);
- ast_format_copy(&tmp->rawwriteformat, &prefformat);
- ast_format_copy(&tmp->writeformat, &prefformat);
- ast_format_copy(&tmp->readformat, &prefformat);
+ ast_format_copy(ast_channel_rawreadformat(tmp), &prefformat);
+ ast_format_copy(ast_channel_rawwriteformat(tmp), &prefformat);
+ ast_format_copy(ast_channel_writeformat(tmp), &prefformat);
+ ast_format_copy(ast_channel_readformat(tmp), &prefformat);
if (state == AST_STATE_RING)
ast_channel_rings_set(tmp, 1);
ast_channel_tech_pvt_set(tmp, i);
setformat(o, O_RDWR);
ast_channel_set_fd(c, 0, o->sounddev); /* -1 if device closed, override later */
- ast_format_set(&c->readformat, AST_FORMAT_SLINEAR, 0);
- ast_format_set(&c->writeformat, AST_FORMAT_SLINEAR, 0);
- ast_format_cap_add(ast_channel_nativeformats(c), &c->readformat);
+ ast_format_set(ast_channel_readformat(c), AST_FORMAT_SLINEAR, 0);
+ ast_format_set(ast_channel_writeformat(c), AST_FORMAT_SLINEAR, 0);
+ ast_format_cap_add(ast_channel_nativeformats(c), ast_channel_readformat(c));
/* if the console makes the call, add video to the offer */
/* if (state == AST_STATE_RINGING) TODO XXX CONSOLE VIDEO IS DISABLED UNTIL IT GETS A MAINTAINER
p = ast_channel_tech_pvt(ast);
ioctl(p->fd, PHONE_CPT_STOP);
/* Nothing to answering really, just start recording */
- if (ast->rawreadformat.id == AST_FORMAT_G729A) {
+ if (ast_channel_rawreadformat(ast)->id == AST_FORMAT_G729A) {
/* Prefer g729 */
ioctl(p->fd, PHONE_REC_STOP);
if (p->lastinput.id != AST_FORMAT_G729A) {
return -1;
}
}
- } else if (ast->rawreadformat.id == AST_FORMAT_G723_1) {
+ } else if (ast_channel_rawreadformat(ast)->id == AST_FORMAT_G723_1) {
ioctl(p->fd, PHONE_REC_STOP);
if (p->lastinput.id != AST_FORMAT_G723_1) {
ast_format_set(&p->lastinput, AST_FORMAT_G723_1, 0);
return -1;
}
}
- } else if (ast->rawreadformat.id == AST_FORMAT_SLINEAR) {
+ } else if (ast_channel_rawreadformat(ast)->id == AST_FORMAT_SLINEAR) {
ioctl(p->fd, PHONE_REC_STOP);
if (p->lastinput.id != AST_FORMAT_SLINEAR) {
ast_format_set(&p->lastinput, AST_FORMAT_SLINEAR, 0);
return -1;
}
}
- } else if (ast->rawreadformat.id == AST_FORMAT_ULAW) {
+ } else if (ast_channel_rawreadformat(ast)->id == AST_FORMAT_ULAW) {
ioctl(p->fd, PHONE_REC_STOP);
if (p->lastinput.id != AST_FORMAT_ULAW) {
ast_format_set(&p->lastinput, AST_FORMAT_ULAW, 0);
}
} else if (p->mode == MODE_FXS) {
ioctl(p->fd, PHONE_REC_STOP);
- if (ast_format_cmp(&p->lastinput, &ast->rawreadformat) == AST_FORMAT_CMP_NOT_EQUAL) {
- ast_format_copy(&p->lastinput, &ast->rawreadformat);
- if (ioctl(p->fd, PHONE_REC_CODEC, &ast->rawreadformat)) {
+ if (ast_format_cmp(&p->lastinput, ast_channel_rawreadformat(ast)) == AST_FORMAT_CMP_NOT_EQUAL) {
+ ast_format_copy(&p->lastinput, ast_channel_rawreadformat(ast));
+ if (ioctl(p->fd, PHONE_REC_CODEC, ast_channel_rawreadformat(ast))) {
ast_log(LOG_WARNING, "Failed to set codec to %s\n",
- ast_getformatname(&ast->rawreadformat));
+ ast_getformatname(ast_channel_rawreadformat(ast)));
return -1;
}
}
} else {
- ast_log(LOG_WARNING, "Can't do format %s\n", ast_getformatname(&ast->rawreadformat));
+ ast_log(LOG_WARNING, "Can't do format %s\n", ast_getformatname(ast_channel_rawreadformat(ast)));
return -1;
}
if (ioctl(p->fd, PHONE_REC_START)) {
ioctl(i->fd, PHONE_QUERY_CODEC, &queried_codec) == 0) {
if (queried_codec.type == LINEAR16) {
ast_format_cap_add(ast_channel_nativeformats(tmp), ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
- ast_format_copy(&tmp->rawreadformat, &tmpfmt);
- ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
+ ast_format_copy(ast_channel_rawreadformat(tmp), &tmpfmt);
+ ast_format_copy(ast_channel_rawwriteformat(tmp), &tmpfmt);
} else {
ast_format_cap_remove(prefcap, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
}
} else {
ast_format_cap_copy(ast_channel_nativeformats(tmp), prefcap);
ast_best_codec(ast_channel_nativeformats(tmp), &tmpfmt);
- ast_format_copy(&tmp->rawreadformat, &tmpfmt);
- ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
+ ast_format_copy(ast_channel_rawreadformat(tmp), &tmpfmt);
+ ast_format_copy(ast_channel_rawwriteformat(tmp), &tmpfmt);
}
/* no need to call ast_setstate: the channel_alloc already did its job */
if (state == AST_STATE_RING)
ast_log(LOG_WARNING, "Asked to transmit frame type %s, while native formats is %s read/write = %s/%s\n",
ast_getformatname(&frame->subclass.format),
ast_getformatname_multiple(s1, sizeof(s1), ast_channel_nativeformats(ast)),
- ast_getformatname(&ast->readformat),
- ast_getformatname(&ast->writeformat));
+ ast_getformatname(ast_channel_readformat(ast)),
+ ast_getformatname(ast_channel_writeformat(ast)));
return 0;
}
if (p) {
}
ast_channel_adsicpe_set(tmp, AST_ADSI_UNAVAILABLE);
- ast_format_copy(&tmp->writeformat, &fmt);
- ast_format_copy(&tmp->rawwriteformat, &fmt);
+ ast_format_copy(ast_channel_writeformat(tmp), &fmt);
+ ast_format_copy(ast_channel_rawwriteformat(tmp), &fmt);
ast_rtp_instance_set_write_format(i->rtp, &fmt);
- ast_format_copy(&tmp->readformat, &fmt);
- ast_format_copy(&tmp->rawreadformat, &fmt);
+ ast_format_copy(ast_channel_readformat(tmp), &fmt);
+ ast_format_copy(ast_channel_rawreadformat(tmp), &fmt);
ast_rtp_instance_set_read_format(i->rtp, &fmt);
ast_channel_tech_pvt_set(tmp, dialog_ref(i, "sip_new: set chan->tech_pvt to i"));
ast_getformatname(&f->subclass.format));
ast_format_cap_remove_bytype(ast_channel_nativeformats(p->owner), AST_FORMAT_TYPE_AUDIO);
ast_format_cap_add(ast_channel_nativeformats(p->owner), &f->subclass.format);
- ast_set_read_format(p->owner, &p->owner->readformat);
- ast_set_write_format(p->owner, &p->owner->writeformat);
+ ast_set_read_format(p->owner, ast_channel_readformat(p->owner));
+ ast_set_write_format(p->owner, ast_channel_writeformat(p->owner));
}
if (f && p->dsp) {
ast_format_cap_joint_append(p->caps, vpeercapability, ast_channel_nativeformats(p->owner));
ast_format_cap_joint_append(p->caps, tpeercapability, ast_channel_nativeformats(p->owner));
- ast_set_read_format(p->owner, &p->owner->readformat);
- ast_set_write_format(p->owner, &p->owner->writeformat);
+ ast_set_read_format(p->owner, ast_channel_readformat(p->owner));
+ ast_set_write_format(p->owner, ast_channel_writeformat(p->owner));
}
if (ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD) && (!ast_sockaddr_isnull(sa) || !ast_sockaddr_isnull(vsa) || !ast_sockaddr_isnull(tsa) || !ast_sockaddr_isnull(isa)) && (!sendonly || sendonly == -1)) {
}
/* Make formats okay */
- transferee->readformat = chan1->readformat;
- transferee->writeformat = chan1->writeformat;
+ ast_format_copy(ast_channel_readformat(transferee), ast_channel_readformat(chan1));
+ ast_format_copy(ast_channel_writeformat(transferee), ast_channel_writeformat(chan1));
/* Prepare for taking over the channel */
if (ast_channel_masquerade(transferee, chan1)) {
back the announcement */
/* Make formats okay */
- transferer->readformat = chan2->readformat;
- transferer->writeformat = chan2->writeformat;
+ ast_format_copy(ast_channel_readformat(transferer), ast_channel_readformat(chan2));
+ ast_format_copy(ast_channel_writeformat(transferer), ast_channel_writeformat(chan2));
ast_channel_parkinglot_set(transferer, ast_channel_parkinglot(chan2));
/* Prepare for taking over the channel */
if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(ast), &f->subclass.format))) {
ast_debug(1, "Oooh, format changed to %s\n", ast_getformatname(&f->subclass.format));
ast_format_cap_set(ast_channel_nativeformats(ast), &f->subclass.format);
- ast_set_read_format(ast, &ast->readformat);
- ast_set_write_format(ast, &ast->writeformat);
+ ast_set_read_format(ast, ast_channel_readformat(ast));
+ ast_set_write_format(ast, ast_channel_writeformat(ast));
}
}
}
ast_log(LOG_WARNING, "Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n",
ast_getformatname(&frame->subclass.format),
ast_getformatname_multiple(buf, sizeof(buf), ast_channel_nativeformats(ast)),
- ast_getformatname(&ast->readformat),
- ast_getformatname(&ast->writeformat));
+ ast_getformatname(ast_channel_readformat(ast)),
+ ast_getformatname(ast_channel_writeformat(ast)));
return -1;
}
}
if (state == AST_STATE_RING) {
ast_channel_rings_set(tmp, 1);
}
- ast_format_copy(&tmp->writeformat, &tmpfmt);
- ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
- ast_format_copy(&tmp->readformat, &tmpfmt);
- ast_format_copy(&tmp->rawreadformat, &tmpfmt);
+ ast_format_copy(ast_channel_writeformat(tmp), &tmpfmt);
+ ast_format_copy(ast_channel_rawwriteformat(tmp), &tmpfmt);
+ ast_format_copy(ast_channel_readformat(tmp), &tmpfmt);
+ ast_format_copy(ast_channel_rawreadformat(tmp), &tmpfmt);
if (!ast_strlen_zero(l->language))
ast_channel_language_set(tmp, l->language);
sin.sin_port = htons(sub->parent->parent->rtp_port);
ast_sockaddr_from_sin(&sin_tmp, &sin);
ast_rtp_instance_set_remote_address(sub->rtp, &sin_tmp);
- if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(sub->owner), &sub->owner->readformat))) {
+ if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(sub->owner), ast_channel_readformat(sub->owner)))) {
struct ast_format tmpfmt;
char tmp[256];
ast_best_codec(ast_channel_nativeformats(sub->owner), &tmpfmt);
ast_log(LOG_WARNING,
"Our read/writeformat has been changed to something incompatible: %s, using %s best codec from %s\n",
- ast_getformatname(&sub->owner->readformat),
+ ast_getformatname(ast_channel_readformat(sub->owner)),
ast_getformatname(&tmpfmt),
ast_getformatname_multiple(tmp, sizeof(tmp), ast_channel_nativeformats(sub->owner)));
- ast_format_copy(&sub->owner->readformat, &tmpfmt);
- ast_format_copy(&sub->owner->writeformat, &tmpfmt);
+ ast_format_copy(ast_channel_readformat(sub->owner), &tmpfmt);
+ ast_format_copy(ast_channel_writeformat(sub->owner), &tmpfmt);
}
- codec = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(sub->rtp), 1, &sub->owner->readformat, 0);
+ codec = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(sub->rtp), 1, ast_channel_readformat(sub->owner), 0);
/* Setting up RTP of the phone */
if (public_ip.sin_family == 0) /* NAT IP override ? */
memcpy(&public, &us, sizeof(public)); /* No defined, using IP from recvmsg */
if (unistimdebug) {
ast_verb(0, "RTP started : Our IP/port is : %s:%hd with codec %s\n",
ast_inet_ntoa(us.sin_addr),
- htons(us.sin_port), ast_getformatname(&sub->owner->readformat));
+ htons(us.sin_port), ast_getformatname(ast_channel_readformat(sub->owner)));
ast_verb(0, "Starting phone RTP stack. Our public IP is %s\n",
ast_inet_ntoa(public.sin_addr));
}
- if ((sub->owner->readformat.id == AST_FORMAT_ULAW) ||
- (sub->owner->readformat.id == AST_FORMAT_ALAW)) {
+ if ((ast_channel_readformat(sub->owner)->id == AST_FORMAT_ULAW) ||
+ (ast_channel_readformat(sub->owner)->id == AST_FORMAT_ALAW)) {
if (unistimdebug)
ast_verb(0, "Sending packet_send_rtp_packet_size for codec %d\n", codec);
memcpy(buffsend + SIZE_HEADER, packet_send_rtp_packet_size,
/* Codec */
buffsend[40] = codec;
buffsend[41] = codec;
- if (sub->owner->readformat.id == AST_FORMAT_ULAW)
+ if (ast_channel_readformat(sub->owner)->id == AST_FORMAT_ULAW)
buffsend[42] = 1; /* 1 = 20ms (160 bytes), 2 = 40ms (320 bytes) */
- else if (sub->owner->readformat.id == AST_FORMAT_ALAW)
+ else if (ast_channel_readformat(sub->owner)->id == AST_FORMAT_ALAW)
buffsend[42] = 1; /* 1 = 20ms (160 bytes), 2 = 40ms (320 bytes) */
- else if (sub->owner->readformat.id == AST_FORMAT_G723_1)
+ else if (ast_channel_readformat(sub->owner)->id == AST_FORMAT_G723_1)
buffsend[42] = 2; /* 1 = 30ms (24 bytes), 2 = 60 ms (48 bytes) */
- else if (sub->owner->readformat.id == AST_FORMAT_G729A)
+ else if (ast_channel_readformat(sub->owner)->id == AST_FORMAT_G729A)
buffsend[42] = 2; /* 1 = 10ms (10 bytes), 2 = 20ms (20 bytes) */
else
ast_log(LOG_WARNING, "Unsupported codec %s!\n",
- ast_getformatname(&sub->owner->readformat));
+ ast_getformatname(ast_channel_readformat(sub->owner)));
/* Source port for transmit RTP and Destination port for receiving RTP */
buffsend[45] = (htons(sin.sin_port) & 0xff00) >> 8;
buffsend[46] = (htons(sin.sin_port) & 0x00ff);
ast_getformatname(&f->subclass.format));
ast_format_cap_set(ast_channel_nativeformats(sub->owner), &f->subclass.format);
- ast_set_read_format(sub->owner, &sub->owner->readformat);
- ast_set_write_format(sub->owner, &sub->owner->writeformat);
+ ast_set_read_format(sub->owner, ast_channel_readformat(sub->owner));
+ ast_set_write_format(sub->owner, ast_channel_writeformat(sub->owner));
}
}
}
"Asked to transmit frame type %s, while native formats is %s (read/write = (%s/%s)\n",
ast_getformatname(&frame->subclass.format),
ast_getformatname_multiple(tmp, sizeof(tmp), ast_channel_nativeformats(ast)),
- ast_getformatname(&ast->readformat),
- ast_getformatname(&ast->writeformat));
+ ast_getformatname(ast_channel_readformat(ast)),
+ ast_getformatname(ast_channel_writeformat(ast)));
return -1;
}
}
if (state == AST_STATE_RING)
ast_channel_rings_set(tmp, 1);
ast_channel_adsicpe_set(tmp, AST_ADSI_UNAVAILABLE);
- ast_format_copy(&tmp->writeformat, &tmpfmt);
- ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
- ast_format_copy(&tmp->readformat, &tmpfmt);
- ast_format_copy(&tmp->rawreadformat, &tmpfmt);
+ ast_format_copy(ast_channel_writeformat(tmp), &tmpfmt);
+ ast_format_copy(ast_channel_rawwriteformat(tmp), &tmpfmt);
+ ast_format_copy(ast_channel_readformat(tmp), &tmpfmt);
+ ast_format_copy(ast_channel_rawreadformat(tmp), &tmpfmt);
ast_channel_tech_pvt_set(tmp, sub);
ast_channel_tech_set(tmp, &unistim_tech);
if (!ast_strlen_zero(l->language))
setformat(o, O_RDWR);
c->fds[0] = o->sounddev; /* -1 if device closed, override later */
ast_format_cap_add(ast_channel_nativeformats(c), &slin);
- ast_format_set(&c->readformat, AST_FORMAT_SLINEAR, 0);
- ast_format_set(&c->writeformat, AST_FORMAT_SLINEAR, 0);
+ ast_format_set(ast_channel_readformat(c), AST_FORMAT_SLINEAR, 0);
+ ast_format_set(ast_channel_writeformat(c), AST_FORMAT_SLINEAR, 0);
ast_channel_tech_pvt_set(c, o);
if (!ast_strlen_zero(o->language))
ast_mutex_unlock(&p->play_dtmf_lock);
if (p->owner) {
- ast_format_copy(&tmpfmt, &p->owner->rawreadformat);
+ ast_format_copy(&tmpfmt, ast_channel_rawreadformat(p->owner));
} else {
ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0);
}
* linear since we can then adjust volume in this modules.
*/
ast_format_cap_add(ast_channel_nativeformats(tmp), ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
- ast_format_copy(&tmp->rawreadformat, &tmpfmt);
- ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
+ ast_format_copy(ast_channel_rawreadformat(tmp), &tmpfmt);
+ ast_format_copy(ast_channel_rawwriteformat(tmp), &tmpfmt);
if (state == AST_STATE_RING) {
ast_channel_rings_set(tmp, 1);
cid_name[0] = '\0';
tmpcap = ast_format_cap_destroy(tmpcap);
}
} else if (!strcasecmp(data, "audioreadformat")) {
- ast_copy_string(buf, ast_getformatname(&chan->readformat), len);
+ ast_copy_string(buf, ast_getformatname(ast_channel_readformat(chan)), len);
} else if (!strcasecmp(data, "audiowriteformat")) {
- ast_copy_string(buf, ast_getformatname(&chan->writeformat), len);
+ ast_copy_string(buf, ast_getformatname(ast_channel_writeformat(chan)), len);
#ifdef CHANNEL_TRACE
} else if (!strcasecmp(data, "trace")) {
ast_channel_lock(chan);
int __do_not_use_fdno; /*!< Which fd had an event detected on */
int __do_not_use_streamid; /*!< For streaming playback, the schedule ID */
int __do_not_use_vstreamid; /*!< For streaming video playback, the schedule ID */
- struct ast_format oldwriteformat; /*!< Original writer format */
+ struct ast_format __do_not_use_oldwriteformat; /*!< Original writer format */
int __do_not_use_timingfd; /*!< Timing fd */
enum ast_channel_state __do_not_use_state; /*!< State of line -- Don't write directly, use ast_setstate() */
int __do_not_use_rings; /*!< Number of rings so far */
unsigned int flags; /*!< channel flags of AST_FLAG_ type */
int alertpipe[2];
struct ast_format_cap *__do_not_use_nativeformats; /*!< Kinds of data this channel can natively handle */
- struct ast_format readformat; /*!< Requested read format (after translation) */
- struct ast_format writeformat; /*!< Requested write format (after translation) */
- struct ast_format rawreadformat; /*!< Raw read format (before translation) */
- struct ast_format rawwriteformat; /*!< Raw write format (before translation) */
+ struct ast_format __do_not_use_readformat; /*!< Requested read format (after translation) */
+ struct ast_format __do_not_use_writeformat; /*!< Requested write format (after translation) */
+ struct ast_format __do_not_use_rawreadformat; /*!< Raw read format (before translation) */
+ struct ast_format __do_not_use_rawwriteformat; /*!< Raw write format (before translation) */
unsigned int __do_not_use_emulate_dtmf_duration; /*!< Number of ms left to emulate DTMF for */
#ifdef HAVE_EPOLL
int __do_not_use_epfd;
enum ast_channel_state ast_channel_state(const struct ast_channel *chan);
/* XXX Internal use only, make sure to move later */
void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state);
+
+/* Format getters */
+struct ast_format *ast_channel_oldwriteformat(struct ast_channel *chan);
+struct ast_format *ast_channel_rawreadformat(struct ast_channel *chan);
+struct ast_format *ast_channel_rawwriteformat(struct ast_channel *chan);
+struct ast_format *ast_channel_readformat(struct ast_channel *chan);
+struct ast_format *ast_channel_writeformat(struct ast_channel *chan);
+
#endif /* _ASTERISK_CHANNEL_H */
ast_clear_flag(chan, AST_FLAG_WRITE_INT);
}
- ast_format_copy(&ls->origwfmt, &chan->writeformat);
+ ast_format_copy(&ls->origwfmt, ast_channel_writeformat(chan));
if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR)) {
ast_log(LOG_WARNING, "Unable to set '%s' to linear format (write)\n", ast_channel_name(chan));
return -1;
}
ast_dsp_set_threshold(sildet, silencethreshold);
- ast_format_copy(&rfmt, &chan->readformat);
+ ast_format_copy(&rfmt, ast_channel_readformat(chan));
res = ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR);
if (res < 0) {
ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n");
static int bridge_make_compatible(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
{
struct ast_format formats[2];
- ast_format_copy(&formats[0], &bridge_channel->chan->readformat);
- ast_format_copy(&formats[1], &bridge_channel->chan->writeformat);
+ ast_format_copy(&formats[0], ast_channel_readformat(bridge_channel->chan));
+ ast_format_copy(&formats[1], ast_channel_writeformat(bridge_channel->chan));
/* Are the formats currently in use something ths bridge can handle? */
- if (!ast_format_cap_iscompatible(bridge->technology->format_capabilities, &bridge_channel->chan->readformat)) {
+ if (!ast_format_cap_iscompatible(bridge->technology->format_capabilities, ast_channel_readformat(bridge_channel->chan))) {
struct ast_format best_format;
ast_best_codec(bridge->technology->format_capabilities, &best_format);
{
struct ast_format formats[2];
enum ast_bridge_channel_state state;
- ast_format_copy(&formats[0], &bridge_channel->chan->readformat);
- ast_format_copy(&formats[1], &bridge_channel->chan->writeformat);
+ ast_format_copy(&formats[0], ast_channel_readformat(bridge_channel->chan));
+ ast_format_copy(&formats[1], ast_channel_writeformat(bridge_channel->chan));
/* Record the thread that will be the owner of us */
bridge_channel->thread = pthread_self();
ao2_unlock(bridge_channel->bridge);
/* Restore original formats of the channel as they came in */
- if (ast_format_cmp(&bridge_channel->chan->readformat, &formats[0]) == AST_FORMAT_CMP_NOT_EQUAL) {
+ if (ast_format_cmp(ast_channel_readformat(bridge_channel->chan), &formats[0]) == AST_FORMAT_CMP_NOT_EQUAL) {
ast_debug(1, "Bridge is returning %p to read format %s(%d)\n", bridge_channel, ast_getformatname(&formats[0]), formats[0].id);
if (ast_set_read_format(bridge_channel->chan, &formats[0])) {
ast_debug(1, "Bridge failed to return channel %p to read format %s(%d)\n", bridge_channel, ast_getformatname(&formats[0]), formats[0].id);
}
}
- if (ast_format_cmp(&bridge_channel->chan->writeformat, &formats[1]) == AST_FORMAT_CMP_NOT_EQUAL) {
+ if (ast_format_cmp(ast_channel_writeformat(bridge_channel->chan), &formats[1]) == AST_FORMAT_CMP_NOT_EQUAL) {
ast_debug(1, "Bridge is returning %p to write format %s(%d)\n", bridge_channel, ast_getformatname(&formats[1]), formats[1].id);
if (ast_set_write_format(bridge_channel->chan, &formats[1])) {
ast_debug(1, "Bridge failed to return channel %p to write format %s(%d)\n", bridge_channel, ast_getformatname(&formats[1]), formats[1].id);
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);
+ ast_format_clear(ast_channel_rawwriteformat(clonechan));
+ ast_format_clear(ast_channel_rawreadformat(clonechan));
} else {
struct ast_format tmpfmt;
ast_best_codec(ast_channel_nativeformats(clonechan), &tmpfmt);
- ast_format_copy(&clonechan->rawwriteformat, &tmpfmt);
- ast_format_copy(&clonechan->rawreadformat, &tmpfmt);
+ ast_format_copy(ast_channel_rawwriteformat(clonechan), &tmpfmt);
+ ast_format_copy(ast_channel_rawreadformat(clonechan), &tmpfmt);
}
}
if (!tmp || !generate)
return 0;
- res = generate(chan, tmp, 0, ast_format_rate(&chan->writeformat) / 50);
+ res = generate(chan, tmp, 0, ast_format_rate(ast_channel_writeformat(chan)) / 50);
ast_channel_generatordata_set(chan, tmp);
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) {
+ if (ast_format_cmp(&f->subclass.format, ast_channel_writeformat(chan)) == AST_FORMAT_CMP_NOT_EQUAL) {
float factor;
- factor = ((float) ast_format_rate(&chan->writeformat)) / ((float) ast_format_rate(&f->subclass.format));
+ factor = ((float) ast_format_rate(ast_channel_writeformat(chan))) / ((float) ast_format_rate(&f->subclass.format));
samples = (int) ( ((float) f->samples) * factor );
} else {
samples = f->samples;
/* Send an empty audio frame to get things moving */
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);
+ ast_format_copy(&a.subclass.format, ast_channel_rawwriteformat(chan));
a.data.ptr = nothing + AST_FRIENDLY_OFFSET;
a.src = "ast_prod"; /* this better match check in ast_write */
if (ast_write(chan, &a))
}
/* If the frame is in the raw write format, then it's easy... just use the frame - otherwise we will have to translate */
- if (ast_format_cmp(&fr->subclass.format, &chan->rawwriteformat) != AST_FORMAT_CMP_NOT_EQUAL) {
+ if (ast_format_cmp(&fr->subclass.format, ast_channel_rawwriteformat(chan)) != AST_FORMAT_CMP_NOT_EQUAL) {
f = fr;
} else {
/* XXX Something is not right we are not compatible with this frame bad things can happen
* JIRA issues related to this :-
* ASTERISK-14384, ASTERISK-17502, ASTERISK-17541, ASTERISK-18063, ASTERISK-18325, ASTERISK-18422*/
if ((!ast_format_cap_iscompatible(ast_channel_nativeformats(chan), &fr->subclass.format)) &&
- (ast_format_cmp(&chan->writeformat, &fr->subclass.format) != AST_FORMAT_CMP_EQUAL)) {
+ (ast_format_cmp(ast_channel_writeformat(chan), &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_channel_name(chan), ast_getformatname(&fr->subclass.format), ast_getformatname(ast_channel_writeformat(chan)),
ast_getformatname_multiple(nf, sizeof(nf), ast_channel_nativeformats(chan)));
ast_set_write_format_by_id(chan, fr->subclass.format.id);
}
res = set_format(chan,
cap,
- &chan->rawreadformat,
- &chan->readformat,
+ ast_channel_rawreadformat(chan),
+ ast_channel_readformat(chan),
&trans,
0);
res = set_format(chan,
cap,
- &chan->rawreadformat,
- &chan->readformat,
+ ast_channel_rawreadformat(chan),
+ ast_channel_readformat(chan),
&trans,
0);
int res;
res = set_format(chan,
cap,
- &chan->rawreadformat,
- &chan->readformat,
+ ast_channel_rawreadformat(chan),
+ ast_channel_readformat(chan),
&trans,
0);
ast_channel_readtrans_set(chan, trans);
res = set_format(chan,
cap,
- &chan->rawwriteformat,
- &chan->writeformat,
+ ast_channel_rawwriteformat(chan),
+ ast_channel_writeformat(chan),
&trans,
1);
res = set_format(chan,
cap,
- &chan->rawwriteformat,
- &chan->writeformat,
+ ast_channel_rawwriteformat(chan),
+ ast_channel_writeformat(chan),
&trans,
1);
int res;
res = set_format(chan,
cap,
- &chan->rawwriteformat,
- &chan->writeformat,
+ ast_channel_rawwriteformat(chan),
+ ast_channel_writeformat(chan),
&trans,
1);
ast_channel_writetrans_set(chan, trans);
return 0;
}
- if ((ast_format_cmp(&from->readformat, &to->writeformat) != AST_FORMAT_CMP_NOT_EQUAL) &&
- (ast_format_cmp(&to->readformat, &from->writeformat) != AST_FORMAT_CMP_NOT_EQUAL)) {
+ if ((ast_format_cmp(ast_channel_readformat(from), ast_channel_writeformat(to)) != AST_FORMAT_CMP_NOT_EQUAL) &&
+ (ast_format_cmp(ast_channel_readformat(to), ast_channel_writeformat(from)) != AST_FORMAT_CMP_NOT_EQUAL)) {
/* Already compatible! Moving on ... */
return 0;
}
char masqn[AST_CHANNEL_NAME];
char zombn[AST_CHANNEL_NAME];
- ast_format_copy(&rformat, &original->readformat);
- ast_format_copy(&wformat, &original->writeformat);
+ ast_format_copy(&rformat, ast_channel_readformat(original));
+ ast_format_copy(&wformat, ast_channel_writeformat(original));
/* XXX This operation is a bit odd. We're essentially putting the guts of
* the clone channel into the original channel. Start by killing off the
}
/* Swap the raw formats */
- ast_format_copy(&tmp_format, &original->rawreadformat);
- ast_format_copy(&original->rawreadformat, &clonechan->rawreadformat);
- ast_format_copy(&clonechan->rawreadformat, &tmp_format);
+ ast_format_copy(&tmp_format, ast_channel_rawreadformat(original));
+ ast_format_copy(ast_channel_rawreadformat(original), ast_channel_rawreadformat(clonechan));
+ ast_format_copy(ast_channel_rawreadformat(clonechan), &tmp_format);
- ast_format_copy(&tmp_format, &original->rawwriteformat);
- ast_format_copy(&original->rawwriteformat, &clonechan->rawwriteformat);
- ast_format_copy(&clonechan->rawwriteformat, &tmp_format);
+ ast_format_copy(&tmp_format, ast_channel_rawwriteformat(original));
+ ast_format_copy(ast_channel_rawwriteformat(original), ast_channel_rawwriteformat(clonechan));
+ ast_format_copy(ast_channel_rawwriteformat(clonechan), &tmp_format);
clonechan->_softhangup = AST_SOFTHANGUP_DEV;
}
}
- 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) ||
+ if (((ast_format_cmp(ast_channel_readformat(c1), ast_channel_writeformat(c0)) == AST_FORMAT_CMP_NOT_EQUAL) ||
+ (ast_format_cmp(ast_channel_readformat(c0), ast_channel_writeformat(c1)) == AST_FORMAT_CMP_NOT_EQUAL) ||
!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 (!(ts = ast_calloc(1, sizeof(*ts))))
return NULL;
- ast_format_copy(&ts->origwfmt, &chan->writeformat);
+ ast_format_copy(&ts->origwfmt, ast_channel_writeformat(chan));
if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR)) {
ast_log(LOG_WARNING, "Unable to set '%s' to signed linear format (write)\n", ast_channel_name(chan));
tonepair_release(NULL, ts);
return NULL;
}
- ast_format_copy(&state->old_write_format, &chan->writeformat);
+ ast_format_copy(&state->old_write_format, ast_channel_writeformat(chan));
if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR) < 0) {
ast_log(LOG_ERROR, "Could not set write format to SLINEAR\n");
}
}
- ast_data_add_codec(tree, "oldwriteformat", &chan->oldwriteformat);
- ast_data_add_codec(tree, "readformat", &chan->readformat);
- 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_codec(tree, "oldwriteformat", ast_channel_oldwriteformat(chan));
+ ast_data_add_codec(tree, "readformat", ast_channel_readformat(chan));
+ ast_data_add_codec(tree, "writeformat", ast_channel_writeformat(chan));
+ ast_data_add_codec(tree, "rawreadformat", ast_channel_rawreadformat(chan));
+ ast_data_add_codec(tree, "rawwriteformat", ast_channel_rawwriteformat(chan));
ast_data_add_codecs(tree, "nativeformats", ast_channel_nativeformats(chan));
/* state */
{
chan->__do_not_use_state = value;
}
+struct ast_format *ast_channel_oldwriteformat(struct ast_channel *chan)
+{
+ return &chan->__do_not_use_oldwriteformat;
+}
+struct ast_format *ast_channel_rawreadformat(struct ast_channel *chan)
+{
+ return &chan->__do_not_use_rawreadformat;
+}
+struct ast_format *ast_channel_rawwriteformat(struct ast_channel *chan)
+{
+ return &chan->__do_not_use_rawwriteformat;
+}
+struct ast_format *ast_channel_readformat(struct ast_channel *chan)
+{
+ return &chan->__do_not_use_readformat;
+}
+struct ast_format *ast_channel_writeformat(struct ast_channel *chan)
+{
+ return &chan->__do_not_use_writeformat;
+}
ast_channel_language(c),
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),
+ ast_getformatname(ast_channel_writeformat(c)),
+ ast_getformatname(ast_channel_readformat(c)),
ast_channel_writetrans(c) ? "Yes" : "No",
ast_translate_path_to_str(ast_channel_writetrans(c), &write_transpath),
ast_channel_readtrans(c) ? "Yes" : "No",
}
/* Make formats okay */
- xferchan->readformat = chan->readformat;
- xferchan->writeformat = chan->writeformat;
+ ast_format_copy(ast_channel_readformat(xferchan), ast_channel_readformat(chan));
+ ast_format_copy(ast_channel_writeformat(xferchan), ast_channel_writeformat(chan));
if (ast_channel_masquerade(xferchan, chan)) {
/* Failed to setup masquerade. */
}
/* Make formats okay */
- chan->readformat = rchan->readformat;
- chan->writeformat = rchan->writeformat;
+ ast_format_copy(ast_channel_readformat(chan), ast_channel_readformat(rchan));
+ ast_format_copy(ast_channel_writeformat(chan), ast_channel_writeformat(rchan));
if (ast_channel_masquerade(chan, rchan)) {
park_space_abort(args->pu);
ast_channel_visible_indication_set(xferchan, AST_CONTROL_RINGING);
/* Make formats okay */
- xferchan->readformat = transferee->readformat;
- xferchan->writeformat = transferee->writeformat;
+ ast_format_copy(ast_channel_readformat(xferchan), ast_channel_readformat(transferee));
+ ast_format_copy(ast_channel_writeformat(xferchan), ast_channel_writeformat(transferee));
ast_channel_masquerade(xferchan, transferee);
ast_explicit_goto(xferchan, ast_channel_context(transferee), ast_channel_exten(transferee), ast_channel_priority(transferee));
ast_moh_stop(chan);
ast_channel_lock_both(chan, tmpchan);
ast_setstate(tmpchan, ast_channel_state(chan));
- tmpchan->readformat = chan->readformat;
- tmpchan->writeformat = chan->writeformat;
+ ast_format_copy(ast_channel_readformat(tmpchan), ast_channel_readformat(chan));
+ ast_format_copy(ast_channel_writeformat(tmpchan), ast_channel_writeformat(chan));
ast_channel_unlock(chan);
ast_channel_unlock(tmpchan);
/* normally this is done in the channel driver */
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);
+ ast_format_set(ast_channel_writeformat(test_channel1), AST_FORMAT_GSM, 0);
+ ast_format_set(ast_channel_rawwriteformat(test_channel1), AST_FORMAT_GSM, 0);
+ ast_format_set(ast_channel_readformat(test_channel1), AST_FORMAT_GSM, 0);
+ ast_format_set(ast_channel_rawreadformat(test_channel1), AST_FORMAT_GSM, 0);
ast_channel_tech_set(test_channel1, fake_tech);
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));
+ if (ast_channel_oldwriteformat(tmp)->id && ast_set_write_format(tmp, ast_channel_oldwriteformat(tmp)))
+ ast_log(LOG_WARNING, "Unable to restore format back to %s\n", ast_getformatname(ast_channel_oldwriteformat(tmp)));
}
/* Stop the video stream too */
if (ast_channel_vstream(tmp) != NULL) {
FILE *bfile;
struct ast_filestream *s;
- if ((ast_format_cmp(&chan->writeformat, &f->format) == AST_FORMAT_CMP_NOT_EQUAL) &&
+ if ((ast_format_cmp(ast_channel_writeformat(chan), &f->format) == AST_FORMAT_CMP_NOT_EQUAL) &&
!(((AST_FORMAT_GET_TYPE(f->format.id) == AST_FORMAT_TYPE_AUDIO) && fmt) ||
((AST_FORMAT_GET_TYPE(f->format.id) == AST_FORMAT_TYPE_VIDEO) && fmt))) {
ast_free(fn);
}
/* Set the channel to a format we can work with and save off the previous format. */
- ast_format_copy(&chan->oldwriteformat, &chan->writeformat);
+ ast_format_copy(ast_channel_oldwriteformat(chan), ast_channel_writeformat(chan));
/* Set the channel to the best format that exists for the file. */
res = ast_set_write_format_from_cap(chan, file_fmt_cap);
/* don't need this anymore now that the channel's write format is set. */
res = ast_playstream(fs);
if (!res && vfs)
res = ast_playstream(vfs);
- ast_verb(3, "<%s> Playing '%s.%s' (language '%s')\n", ast_channel_name(chan), filename, ast_getformatname(&chan->writeformat), preflang ? preflang : "default");
+ ast_verb(3, "<%s> Playing '%s.%s' (language '%s')\n", ast_channel_name(chan), filename, ast_getformatname(ast_channel_writeformat(chan)), preflang ? preflang : "default");
return res;
}
return NULL;
}
- ast_format_copy(&ps->origwfmt, &chan->writeformat);
+ ast_format_copy(&ps->origwfmt, ast_channel_writeformat(chan));
if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR)) {
ast_log(LOG_WARNING, "Unable to set '%s' to signed linear format (write)\n", ast_channel_name(chan));
tmpvars.name = ast_strdupa(ast_channel_name(chan));
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);
+ ast_format_copy(&tmpvars.writeformat, ast_channel_writeformat(chan));
+ ast_format_copy(&tmpvars.readformat, ast_channel_readformat(chan));
tmpvars.cdr = ast_channel_cdr(chan) ? ast_cdr_dup(ast_channel_cdr(chan)) : NULL;
ast_channel_unlock(chan);
}
/* Make formats okay */
- ast_format_copy(&tmpchan->readformat, &tmpvars.readformat);
- ast_format_copy(&tmpchan->writeformat, &tmpvars.writeformat);
+ ast_format_copy(ast_channel_readformat(tmpchan), &tmpvars.readformat);
+ ast_format_copy(ast_channel_writeformat(tmpchan), &tmpvars.writeformat);
/* Setup proper location. Never hold another channel lock while calling this function. */
ast_explicit_goto(tmpchan, S_OR(context, tmpvars.context), S_OR(exten, tmpvars.exten), priority);
cs[2] = NULL;
for (;;) {
/* If the underlying formats have changed force this bridge to break */
- if ((ast_format_cmp(&c0->rawreadformat, &c1->rawwriteformat) == AST_FORMAT_CMP_NOT_EQUAL) ||
- (ast_format_cmp(&c1->rawreadformat, &c0->rawwriteformat) == AST_FORMAT_CMP_NOT_EQUAL)) {
+ if ((ast_format_cmp(ast_channel_rawreadformat(c0), ast_channel_rawwriteformat(c1)) == AST_FORMAT_CMP_NOT_EQUAL) ||
+ (ast_format_cmp(ast_channel_rawreadformat(c1), ast_channel_rawwriteformat(c0)) == AST_FORMAT_CMP_NOT_EQUAL)) {
ast_debug(1, "rtp-engine-local-bridge: Oooh, formats changed, backing out\n");
res = AST_BRIDGE_FAILED_NOWARN;
break;
struct ast_format writeformat;
struct ast_format readformat;
- ast_format_copy(&writeformat, &chan->writeformat);
- ast_format_copy(&readformat, &chan->readformat);
+ ast_format_copy(&writeformat, ast_channel_writeformat(chan));
+ ast_format_copy(&readformat, ast_channel_readformat(chan));
for (x = 0; x < msglen; x += (msg[x+1]+2)) {
if (msg[x] == ADSI_SWITCH_TO_DATA) {
}
if (silence > 0) {
- ast_format_copy(&rfmt, &chan->readformat);
+ ast_format_copy(&rfmt, ast_channel_readformat(chan));
res = ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR);
if (res < 0) {
ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n");
offset = atoi(argv[4]);
/* We want frames coming in signed linear */
- ast_format_copy(&old_read_format, &chan->readformat);
+ ast_format_copy(&old_read_format, ast_channel_readformat(chan));
if (ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR)) {
ast_agi_send(agi->fd, chan, "200 result=0\n");
return RESULT_SUCCESS;
ast_log(LOG_ERROR, "EAGI cannot be run on a dead/hungup channel, please use AGI.\n");
return 0;
}
- ast_format_copy(&readformat, &chan->readformat);
+ ast_format_copy(&readformat, ast_channel_readformat(chan));
if (ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR)) {
ast_log(LOG_WARNING, "Unable to set channel '%s' to linear mode\n", ast_channel_name(chan));
return -1;
}
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);
+ ast_format_set(ast_channel_writeformat(chan), AST_FORMAT_SLINEAR, 0);
+ ast_format_set(ast_channel_readformat(chan), AST_FORMAT_SLINEAR, 0);
+ ast_format_set(ast_channel_rawwriteformat(chan), AST_FORMAT_SLINEAR, 0);
+ ast_format_set(ast_channel_rawreadformat(chan), 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(ast_channel_nativeformats(chan), &chan->writeformat);
+ ast_format_cap_set(ast_channel_nativeformats(chan), ast_channel_writeformat(chan));
if (!(datastore = ast_datastore_alloc(&event_notification_datastore, NULL))) {
ast_log(LOG_ERROR, "Could not allocate datastore, notification not being sent!\n");
if (details->caps & AST_FAX_TECH_AUDIO) {
expected_frametype = AST_FRAME_VOICE;;
ast_format_set(&expected_framesubclass.format, AST_FORMAT_SLINEAR, 0);
- ast_format_copy(&orig_write_format, &chan->writeformat);
+ ast_format_copy(&orig_write_format, ast_channel_writeformat(chan));
if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR) < 0) {
ast_log(LOG_ERROR, "channel '%s' failed to set write format to signed linear'.\n", ast_channel_name(chan));
ao2_lock(faxregistry.container);
ast_channel_unlock(chan);
return -1;
}
- ast_format_copy(&orig_read_format, &chan->readformat);
+ ast_format_copy(&orig_read_format, ast_channel_readformat(chan));
if (ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR) < 0) {
ast_log(LOG_ERROR, "channel '%s' failed to set read format to signed linear.\n", ast_channel_name(chan));
ao2_lock(faxregistry.container);
/* we are bridged, change r/w formats to SLIN for v21 preamble
* detection and T.30 */
- ast_format_copy(&gateway->chan_read_format, &chan->readformat);
- ast_format_copy(&gateway->chan_write_format, &chan->readformat);
+ ast_format_copy(&gateway->chan_read_format, ast_channel_readformat(chan));
+ ast_format_copy(&gateway->chan_write_format, ast_channel_readformat(chan));
- ast_format_copy(&gateway->peer_read_format, &peer->readformat);
- ast_format_copy(&gateway->peer_write_format, &peer->readformat);
+ ast_format_copy(&gateway->peer_read_format, ast_channel_readformat(peer));
+ ast_format_copy(&gateway->peer_write_format, ast_channel_readformat(peer));
ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR);
ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR);
switch (event) {
case AST_FRAMEHOOK_EVENT_ATTACHED:
/* Setup format for DSP on ATTACH*/
- ast_format_copy(&faxdetect->orig_format, &chan->readformat);
- switch (chan->readformat.id) {
+ ast_format_copy(&faxdetect->orig_format, ast_channel_readformat(chan));
+ switch (ast_channel_readformat(chan)->id) {
case AST_FORMAT_SLINEAR:
case AST_FORMAT_ALAW:
case AST_FORMAT_ULAW:
if (&state->origwfmt.id) {
struct ast_format tmp;
- ast_format_copy(&tmp, &chan->writeformat);
+ ast_format_copy(&tmp, ast_channel_writeformat(chan));
if (state->mohwfmt.id) {
ast_format_clear(&state->origwfmt);
ast_set_write_format(chan, &state->mohwfmt);
}
state->class = mohclass_ref(class, "Reffing music class for channel");
- ast_format_copy(&state->origwfmt, &chan->writeformat);
- ast_format_copy(&state->mohwfmt, &chan->writeformat);
+ ast_format_copy(&state->origwfmt, ast_channel_writeformat(chan));
+ ast_format_copy(&state->mohwfmt, ast_channel_writeformat(chan));
/* For comparison on restart of MOH (see above) */
ast_copy_string(state->name, class->name, sizeof(state->name));
}
if ((res = mohalloc(class))) {
- ast_format_copy(&res->origwfmt, &chan->writeformat);
+ ast_format_copy(&res->origwfmt, ast_channel_writeformat(chan));
if (ast_set_write_format(chan, &class->format)) {
ast_log(LOG_WARNING, "Unable to set channel '%s' to format '%s'\n", ast_channel_name(chan), ast_codec2str(&class->format));
moh_release(NULL, res);