summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorDavid Vossel <dvossel@digium.com>2011-02-03 16:22:10 +0000
committerDavid Vossel <dvossel@digium.com>2011-02-03 16:22:10 +0000
commitc26c190711a1bbe3b5fff1a93facae333757c56e (patch)
tree00da0caa5a07b7b25729f089dbcafb08129fa9be /apps
parent652fb64a01c7a8656697d07e606620ee0ced6929 (diff)
Asterisk media architecture conversion - no more format bitfields
This patch is the foundation of an entire new way of looking at media in Asterisk. The code present in this patch is everything required to complete phase1 of my Media Architecture proposal. For more information about this project visit the link below. https://wiki.asterisk.org/wiki/display/AST/Media+Architecture+Proposal The primary function of this patch is to convert all the usages of format bitfields in Asterisk to use the new format and format_cap APIs. Functionally no change in behavior should be present in this patch. Thanks to twilson and russell for all the time they spent reviewing these changes. Review: https://reviewboard.asterisk.org/r/1083/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@306010 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps')
-rw-r--r--apps/app_alarmreceiver.c6
-rw-r--r--apps/app_amd.c12
-rw-r--r--apps/app_chanspy.c35
-rw-r--r--apps/app_confbridge.c11
-rw-r--r--apps/app_dahdibarge.c10
-rw-r--r--apps/app_dictate.c11
-rw-r--r--apps/app_dumpchan.c8
-rw-r--r--apps/app_echo.c8
-rw-r--r--apps/app_fax.c33
-rw-r--r--apps/app_festival.c13
-rw-r--r--apps/app_followme.c2
-rw-r--r--apps/app_ices.c11
-rw-r--r--apps/app_jack.c10
-rw-r--r--apps/app_meetme.c53
-rw-r--r--apps/app_milliwatt.c6
-rw-r--r--apps/app_mixmonitor.c4
-rw-r--r--apps/app_mp3.c13
-rw-r--r--apps/app_nbscat.c15
-rw-r--r--apps/app_originate.c12
-rw-r--r--apps/app_parkandannounce.c34
-rw-r--r--apps/app_record.c13
-rw-r--r--apps/app_rpt.c135
-rw-r--r--apps/app_sms.c6
-rw-r--r--apps/app_speech_utils.c9
-rw-r--r--apps/app_talkdetect.c15
-rw-r--r--apps/app_test.c13
-rw-r--r--apps/app_voicemail.c10
-rw-r--r--apps/app_waitforsilence.c10
28 files changed, 311 insertions, 207 deletions
diff --git a/apps/app_alarmreceiver.c b/apps/app_alarmreceiver.c
index 952ef722e..6936cb5a0 100644
--- a/apps/app_alarmreceiver.c
+++ b/apps/app_alarmreceiver.c
@@ -191,7 +191,7 @@ static int send_tone_burst(struct ast_channel *chan, float freq, int duration, i
if (f->frametype == AST_FRAME_VOICE) {
wf.frametype = AST_FRAME_VOICE;
- wf.subclass.codec = AST_FORMAT_ULAW;
+ ast_format_set(&wf.subclass.format, AST_FORMAT_ULAW, 0);
wf.offset = AST_FRIENDLY_OFFSET;
wf.mallocd = 0;
wf.data.ptr = tone_block.buf;
@@ -578,12 +578,12 @@ static int alarmreceiver_exec(struct ast_channel *chan, const char *data)
/* Set write and read formats to ULAW */
ast_verb(4, "AlarmReceiver: Setting read and write formats to ULAW\n");
- if (ast_set_write_format(chan,AST_FORMAT_ULAW)) {
+ if (ast_set_write_format_by_id(chan,AST_FORMAT_ULAW)) {
ast_log(LOG_WARNING, "AlarmReceiver: Unable to set write format to Mu-law on %s\n",chan->name);
return -1;
}
- if (ast_set_read_format(chan,AST_FORMAT_ULAW)) {
+ if (ast_set_read_format_by_id(chan,AST_FORMAT_ULAW)) {
ast_log(LOG_WARNING, "AlarmReceiver: Unable to set read format to Mu-law on %s\n",chan->name);
return -1;
}
diff --git a/apps/app_amd.c b/apps/app_amd.c
index c978ce0f4..60c13fd95 100644
--- a/apps/app_amd.c
+++ b/apps/app_amd.c
@@ -148,7 +148,8 @@ static void isAnsweringMachine(struct ast_channel *chan, const char *data)
int res = 0;
struct ast_frame *f = NULL;
struct ast_dsp *silenceDetector = NULL;
- int dspsilence = 0, readFormat, framelength = 0;
+ int dspsilence = 0, framelength = 0;
+ struct ast_format readFormat;
int inInitialSilence = 1;
int inGreeting = 0;
int voiceDuration = 0;
@@ -188,10 +189,11 @@ static void isAnsweringMachine(struct ast_channel *chan, const char *data)
AST_APP_ARG(argMaximumWordLength);
);
+ ast_format_clear(&readFormat);
ast_verb(3, "AMD: %s %s %s (Fmt: %s)\n", chan->name,
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(&chan->readformat));
/* Lets parse the arguments. */
if (!ast_strlen_zero(parse)) {
@@ -240,8 +242,8 @@ static void isAnsweringMachine(struct ast_channel *chan, const char *data)
minimumWordLength, betweenWordsSilence, maximumNumberOfWords, silenceThreshold, maximumWordLength);
/* Set read format to signed linear so we get signed linear frames in */
- readFormat = chan->readformat;
- if (ast_set_read_format(chan, AST_FORMAT_SLINEAR) < 0 ) {
+ ast_format_copy(&readFormat, &chan->readformat);
+ 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", chan->name );
pbx_builtin_setvar_helper(chan , "AMDSTATUS", "");
pbx_builtin_setvar_helper(chan , "AMDCAUSE", "");
@@ -399,7 +401,7 @@ static void isAnsweringMachine(struct ast_channel *chan, const char *data)
pbx_builtin_setvar_helper(chan , "AMDCAUSE" , amdCause);
/* Restore channel read format */
- if (readFormat && ast_set_read_format(chan, readFormat))
+ if (readFormat.id && ast_set_read_format(chan, &readFormat))
ast_log(LOG_WARNING, "AMD: Unable to restore read format on '%s'\n", chan->name);
/* Free the DSP used to detect silence */
diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c
index 4b671df26..1fc544afb 100644
--- a/apps/app_chanspy.c
+++ b/apps/app_chanspy.c
@@ -427,6 +427,9 @@ static int spy_generate(struct ast_channel *chan, void *data, int len, int sampl
{
struct chanspy_translation_helper *csth = data;
struct ast_frame *f, *cur;
+ struct ast_format format_slin;
+
+ ast_format_set(&format_slin, AST_FORMAT_SLINEAR, 0);
ast_audiohook_lock(&csth->spy_audiohook);
if (csth->spy_audiohook.status != AST_AUDIOHOOK_STATUS_RUNNING) {
@@ -437,9 +440,9 @@ static int spy_generate(struct ast_channel *chan, void *data, int len, int sampl
if (ast_test_flag(&csth->spy_audiohook, OPTION_READONLY)) {
/* Option 'o' was set, so don't mix channel audio */
- f = ast_audiohook_read_frame(&csth->spy_audiohook, samples, AST_AUDIOHOOK_DIRECTION_READ, AST_FORMAT_SLINEAR);
+ f = ast_audiohook_read_frame(&csth->spy_audiohook, samples, AST_AUDIOHOOK_DIRECTION_READ, &format_slin);
} else {
- f = ast_audiohook_read_frame(&csth->spy_audiohook, samples, AST_AUDIOHOOK_DIRECTION_BOTH, AST_FORMAT_SLINEAR);
+ f = ast_audiohook_read_frame(&csth->spy_audiohook, samples, AST_AUDIOHOOK_DIRECTION_BOTH, &format_slin);
}
ast_audiohook_unlock(&csth->spy_audiohook);
@@ -1006,7 +1009,7 @@ static int chanspy_exec(struct ast_channel *chan, const char *data)
.volume = '#',
.exit = '\0',
};
- int oldwf = 0;
+ struct ast_format oldwf;
int volfactor = 0;
int res;
char *mailbox = NULL;
@@ -1019,6 +1022,7 @@ static int chanspy_exec(struct ast_channel *chan, const char *data)
char *parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
+ ast_format_clear(&oldwf);
if (args.spec && !strcmp(args.spec, "all"))
args.spec = NULL;
@@ -1082,8 +1086,8 @@ static int chanspy_exec(struct ast_channel *chan, const char *data)
ast_clear_flag(&flags, AST_FLAGS_ALL);
}
- oldwf = chan->writeformat;
- if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) {
+ ast_format_copy(&oldwf, &chan->writeformat);
+ if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR) < 0) {
ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
return -1;
}
@@ -1103,7 +1107,7 @@ static int chanspy_exec(struct ast_channel *chan, const char *data)
if (fd)
close(fd);
- if (oldwf && ast_set_write_format(chan, oldwf) < 0)
+ if (oldwf.id && ast_set_write_format(chan, &oldwf) < 0)
ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
if (ast_test_flag(&flags, OPTION_EXITONHANGUP)) {
@@ -1125,7 +1129,7 @@ static int extenspy_exec(struct ast_channel *chan, const char *data)
.volume = '#',
.exit = '\0',
};
- int oldwf = 0;
+ struct ast_format oldwf;
int volfactor = 0;
int res;
char *mailbox = NULL;
@@ -1137,12 +1141,13 @@ static int extenspy_exec(struct ast_channel *chan, const char *data)
char *parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
+ ast_format_clear(&oldwf);
+
if (!ast_strlen_zero(args.context) && (ptr = strchr(args.context, '@'))) {
exten = args.context;
*ptr++ = '\0';
args.context = ptr;
}
-
if (ast_strlen_zero(args.context))
args.context = ast_strdupa(chan->context);
@@ -1206,7 +1211,7 @@ static int extenspy_exec(struct ast_channel *chan, const char *data)
}
oldwf = chan->writeformat;
- if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) {
+ if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR) < 0) {
ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
return -1;
}
@@ -1227,7 +1232,7 @@ static int extenspy_exec(struct ast_channel *chan, const char *data)
if (fd)
close(fd);
- if (oldwf && ast_set_write_format(chan, oldwf) < 0)
+ if (oldwf.id && ast_set_write_format(chan, &oldwf) < 0)
ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
return res;
@@ -1242,12 +1247,12 @@ static int dahdiscan_exec(struct ast_channel *chan, const char *data)
.volume = '\0',
.exit = '*',
};
- int oldwf = 0;
+ struct ast_format oldwf;
int res;
char *mygroup = NULL;
ast_clear_flag(&flags, AST_FLAGS_ALL);
-
+ ast_format_clear(&oldwf);
if (!ast_strlen_zero(data)) {
mygroup = ast_strdupa(data);
}
@@ -1255,15 +1260,15 @@ static int dahdiscan_exec(struct ast_channel *chan, const char *data)
ast_set_flag(&flags, OPTION_DTMF_CYCLE);
ast_set_flag(&flags, OPTION_DAHDI_SCAN);
- oldwf = chan->writeformat;
- if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) {
+ ast_format_copy(&oldwf, &chan->writeformat);
+ if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR) < 0) {
ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
return -1;
}
res = common_exec(chan, &flags, 0, 0, &user_options, mygroup, NULL, spec, NULL, NULL, NULL, NULL);
- if (oldwf && ast_set_write_format(chan, oldwf) < 0)
+ if (oldwf.id && ast_set_write_format(chan, &oldwf) < 0)
ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
return res;
diff --git a/apps/app_confbridge.c b/apps/app_confbridge.c
index 71608d426..e533c80e7 100644
--- a/apps/app_confbridge.c
+++ b/apps/app_confbridge.c
@@ -568,11 +568,18 @@ static int play_sound_file(struct conference_bridge *conference_bridge, const ch
if (!(conference_bridge->playback_chan)) {
int cause;
-
- if (!(conference_bridge->playback_chan = ast_request("Bridge", AST_FORMAT_SLINEAR, NULL, "", &cause))) {
+ struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
+ struct ast_format tmpfmt;
+ if (!cap) {
+ return -1;
+ }
+ ast_format_cap_add(cap, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
+ if (!(conference_bridge->playback_chan = ast_request("Bridge", cap, NULL, "", &cause))) {
ast_mutex_unlock(&conference_bridge->playback_lock);
+ cap = ast_format_cap_destroy(cap);
return -1;
}
+ cap = ast_format_cap_destroy(cap);
conference_bridge->playback_chan->bridge = conference_bridge->bridge;
diff --git a/apps/app_dahdibarge.c b/apps/app_dahdibarge.c
index d9dd59054..082405e80 100644
--- a/apps/app_dahdibarge.c
+++ b/apps/app_dahdibarge.c
@@ -113,13 +113,13 @@ static int conf_run(struct ast_channel *chan, int confno, int confflags)
char *buf = __buf + AST_FRIENDLY_OFFSET;
/* Set it into U-law mode (write) */
- if (ast_set_write_format(chan, AST_FORMAT_ULAW) < 0) {
+ if (ast_set_write_format_by_id(chan, AST_FORMAT_ULAW) < 0) {
ast_log(LOG_WARNING, "Unable to set '%s' to write ulaw mode\n", chan->name);
goto outrun;
}
/* Set it into U-law mode (read) */
- if (ast_set_read_format(chan, AST_FORMAT_ULAW) < 0) {
+ if (ast_set_read_format_by_id(chan, AST_FORMAT_ULAW) < 0) {
ast_log(LOG_WARNING, "Unable to set '%s' to read ulaw mode\n", chan->name);
goto outrun;
}
@@ -214,11 +214,11 @@ dahdiretry:
break;
} else if (fd != chan->fds[0]) {
if (f->frametype == AST_FRAME_VOICE) {
- if (f->subclass.codec == AST_FORMAT_ULAW) {
+ if (f->subclass.format.id == AST_FORMAT_ULAW) {
/* Carefully write */
careful_write(fd, f->data.ptr, f->datalen);
} else
- ast_log(LOG_WARNING, "Huh? Got a non-ulaw (%s) frame in the conference\n", ast_getformatname(f->subclass.codec));
+ ast_log(LOG_WARNING, "Huh? Got a non-ulaw (%s) frame in the conference\n", ast_getformatname(&f->subclass.format));
}
}
ast_frfree(f);
@@ -227,7 +227,7 @@ dahdiretry:
if (res > 0) {
memset(&fr, 0, sizeof(fr));
fr.frametype = AST_FRAME_VOICE;
- fr.subclass.codec = AST_FORMAT_ULAW;
+ ast_format_set(&fr.subclass.format, AST_FORMAT_ULAW, 0);
fr.datalen = res;
fr.samples = res;
fr.data.ptr = buf;
diff --git a/apps/app_dictate.c b/apps/app_dictate.c
index e9e5f0d53..5bf439d16 100644
--- a/apps/app_dictate.c
+++ b/apps/app_dictate.c
@@ -97,7 +97,6 @@ static int dictate_exec(struct ast_channel *chan, const char *data)
int ffactor = 320 * 80,
res = 0,
done = 0,
- oldr = 0,
lastop = 0,
samples = 0,
speed = 1,
@@ -105,6 +104,8 @@ static int dictate_exec(struct ast_channel *chan, const char *data)
len = 0,
maxlen = 0,
mode = 0;
+ struct ast_format oldr;
+ ast_format_clear(&oldr);
snprintf(dftbase, sizeof(dftbase), "%s/dictate", ast_config_AST_SPOOL_DIR);
if (!ast_strlen_zero(data)) {
@@ -121,8 +122,8 @@ static int dictate_exec(struct ast_channel *chan, const char *data)
if (args.argc > 1 && args.filename) {
filename = args.filename;
}
- oldr = chan->readformat;
- if ((res = ast_set_read_format(chan, AST_FORMAT_SLINEAR)) < 0) {
+ ast_format_copy(&oldr, &chan->readformat);
+ 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;
}
@@ -330,8 +331,8 @@ static int dictate_exec(struct ast_channel *chan, const char *data)
ast_frfree(f);
}
}
- if (oldr) {
- ast_set_read_format(chan, oldr);
+ if (oldr.id) {
+ ast_set_read_format(chan, &oldr);
}
return 0;
}
diff --git a/apps/app_dumpchan.c b/apps/app_dumpchan.c
index feaeda29e..47888935b 100644
--- a/apps/app_dumpchan.c
+++ b/apps/app_dumpchan.c
@@ -126,10 +126,10 @@ static int serialize_showchan(struct ast_channel *c, char *buf, size_t size)
c->_state,
c->rings,
ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->nativeformats),
- ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->writeformat),
- ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->readformat),
- ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->rawwriteformat),
- ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->rawreadformat),
+ ast_getformatname(&c->writeformat),
+ ast_getformatname(&c->readformat),
+ ast_getformatname(&c->rawwriteformat),
+ ast_getformatname(&c->rawreadformat),
c->fds[0], c->fin & ~DEBUGCHAN_FLAG, (c->fin & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
c->fout & ~DEBUGCHAN_FLAG, (c->fout & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "", (long)c->whentohangup.tv_sec,
hour,
diff --git a/apps/app_echo.c b/apps/app_echo.c
index 1c7211060..ab991427d 100644
--- a/apps/app_echo.c
+++ b/apps/app_echo.c
@@ -51,11 +51,11 @@ static const char app[] = "Echo";
static int echo_exec(struct ast_channel *chan, const char *data)
{
int res = -1;
- format_t format;
+ struct ast_format format;
- format = ast_best_codec(chan->nativeformats);
- ast_set_write_format(chan, format);
- ast_set_read_format(chan, format);
+ ast_best_codec(chan->nativeformats, &format);
+ ast_set_write_format(chan, &format);
+ ast_set_read_format(chan, &format);
while (ast_waitfor(chan, -1) > -1) {
struct ast_frame *f = ast_read(chan);
diff --git a/apps/app_fax.c b/apps/app_fax.c
index 54d22db16..ce8541910 100644
--- a/apps/app_fax.c
+++ b/apps/app_fax.c
@@ -329,9 +329,9 @@ static int fax_generator_generate(struct ast_channel *chan, void *data, int len,
struct ast_frame outf = {
.frametype = AST_FRAME_VOICE,
- .subclass.codec = AST_FORMAT_SLINEAR,
.src = __FUNCTION__,
};
+ ast_format_set(&outf.subclass.format, AST_FORMAT_SLINEAR, 0);
if (samples > MAX_SAMPLES) {
ast_log(LOG_WARNING, "Only generating %d samples, where %d requested\n", MAX_SAMPLES, samples);
@@ -362,8 +362,8 @@ static struct ast_generator generator = {
static int transmit_audio(fax_session *s)
{
int res = -1;
- int original_read_fmt = AST_FORMAT_SLINEAR;
- int original_write_fmt = AST_FORMAT_SLINEAR;
+ struct ast_format original_read_fmt;
+ struct ast_format original_write_fmt;
fax_state_t fax;
t30_state_t *t30state;
struct ast_frame *inf = NULL;
@@ -383,6 +383,9 @@ static int transmit_audio(fax_session *s)
*/
};
+ ast_format_clear(&original_read_fmt);
+ ast_format_clear(&original_write_fmt);
+
/* if in called party mode, try to use T.38 */
if (s->caller_mode == FALSE) {
/* check if we are already in T.38 mode (unlikely), or if we can request
@@ -455,18 +458,18 @@ static int transmit_audio(fax_session *s)
t30state = &fax.t30_state;
#endif
- original_read_fmt = s->chan->readformat;
- if (original_read_fmt != AST_FORMAT_SLINEAR) {
- res = ast_set_read_format(s->chan, AST_FORMAT_SLINEAR);
+ ast_format_copy(&original_read_fmt, &s->chan->readformat);
+ if (original_read_fmt.id != AST_FORMAT_SLINEAR) {
+ res = ast_set_read_format_by_id(s->chan, AST_FORMAT_SLINEAR);
if (res < 0) {
ast_log(LOG_WARNING, "Unable to set to linear read mode, giving up\n");
goto done;
}
}
- original_write_fmt = s->chan->writeformat;
- if (original_write_fmt != AST_FORMAT_SLINEAR) {
- res = ast_set_write_format(s->chan, AST_FORMAT_SLINEAR);
+ ast_format_copy(&original_write_fmt, &s->chan->writeformat);
+ if (original_write_fmt.id != AST_FORMAT_SLINEAR) {
+ res = ast_set_write_format_by_id(s->chan, AST_FORMAT_SLINEAR);
if (res < 0) {
ast_log(LOG_WARNING, "Unable to set to linear write mode, giving up\n");
goto done;
@@ -523,12 +526,12 @@ static int transmit_audio(fax_session *s)
break;
}
- ast_debug(10, "frame %d/%llu, len=%d\n", inf->frametype, (unsigned long long) inf->subclass.codec, inf->datalen);
+ ast_debug(10, "frame %d/%u, len=%d\n", inf->frametype, (unsigned int) inf->subclass.format.id, inf->datalen);
/* Check the frame type. Format also must be checked because there is a chance
that a frame in old format was already queued before we set channel format
to slinear so it will still be received by ast_read */
- if (inf->frametype == AST_FRAME_VOICE && inf->subclass.codec == AST_FORMAT_SLINEAR) {
+ if (inf->frametype == AST_FRAME_VOICE && inf->subclass.format.id == AST_FORMAT_SLINEAR) {
if (fax_rx(&fax, inf->data.ptr, inf->samples) < 0) {
/* I know fax_rx never returns errors. The check here is for good style only */
ast_log(LOG_WARNING, "fax_rx returned error\n");
@@ -582,13 +585,13 @@ static int transmit_audio(fax_session *s)
fax_release(&fax);
done:
- if (original_write_fmt != AST_FORMAT_SLINEAR) {
- if (ast_set_write_format(s->chan, original_write_fmt) < 0)
+ if (original_write_fmt.id != AST_FORMAT_SLINEAR) {
+ if (ast_set_write_format(s->chan, &original_write_fmt) < 0)
ast_log(LOG_WARNING, "Unable to restore write format on '%s'\n", s->chan->name);
}
- if (original_read_fmt != AST_FORMAT_SLINEAR) {
- if (ast_set_read_format(s->chan, original_read_fmt) < 0)
+ if (original_read_fmt.id != AST_FORMAT_SLINEAR) {
+ if (ast_set_read_format(s->chan, &original_read_fmt) < 0)
ast_log(LOG_WARNING, "Unable to restore read format on '%s'\n", s->chan->name);
}
diff --git a/apps/app_festival.c b/apps/app_festival.c
index ef8827adb..f6f3734ca 100644
--- a/apps/app_festival.c
+++ b/apps/app_festival.c
@@ -165,7 +165,7 @@ static int send_waveform_to_channel(struct ast_channel *chan, char *waveform, in
int fds[2];
int pid = -1;
int needed = 0;
- int owriteformat;
+ struct ast_format owriteformat;
struct ast_frame *f;
struct myframe {
struct ast_frame f;
@@ -175,6 +175,7 @@ static int send_waveform_to_channel(struct ast_channel *chan, char *waveform, in
.f = { 0, },
};
+ ast_format_clear(&owriteformat);
if (pipe(fds)) {
ast_log(LOG_WARNING, "Unable to create pipe\n");
return -1;
@@ -186,8 +187,8 @@ static int send_waveform_to_channel(struct ast_channel *chan, char *waveform, in
ast_stopstream(chan);
ast_indicate(chan, -1);
- owriteformat = chan->writeformat;
- res = ast_set_write_format(chan, AST_FORMAT_SLINEAR);
+ ast_format_copy(&owriteformat, &chan->writeformat);
+ 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;
@@ -229,7 +230,7 @@ static int send_waveform_to_channel(struct ast_channel *chan, char *waveform, in
res = read(fds[0], myf.frdata, needed);
if (res > 0) {
myf.f.frametype = AST_FRAME_VOICE;
- myf.f.subclass.codec = AST_FORMAT_SLINEAR;
+ ast_format_set(&myf.f.subclass.format, AST_FORMAT_SLINEAR, 0);
myf.f.datalen = res;
myf.f.samples = res / 2;
myf.f.offset = AST_FRIENDLY_OFFSET;
@@ -261,8 +262,8 @@ static int send_waveform_to_channel(struct ast_channel *chan, char *waveform, in
if (pid > -1)
kill(pid, SIGKILL);
#endif
- if (!res && owriteformat)
- ast_set_write_format(chan, owriteformat);
+ if (!res && owriteformat.id)
+ ast_set_write_format(chan, &owriteformat);
return res;
}
diff --git a/apps/app_followme.c b/apps/app_followme.c
index 95b1ceafb..8b9f1061b 100644
--- a/apps/app_followme.c
+++ b/apps/app_followme.c
@@ -848,7 +848,7 @@ static void findmeexec(struct fm_args *tpargs)
return;
}
- outbound = ast_request("Local", ast_best_codec(caller->nativeformats), caller, dialarg, &dg);
+ outbound = ast_request("Local", caller->nativeformats, caller, dialarg, &dg);
if (outbound) {
ast_set_callerid(outbound,
S_COR(caller->caller.id.number.valid, caller->caller.id.number.str, NULL),
diff --git a/apps/app_ices.c b/apps/app_ices.c
index f2b9498a6..b7eea944c 100644
--- a/apps/app_ices.c
+++ b/apps/app_ices.c
@@ -111,12 +111,13 @@ static int ices_exec(struct ast_channel *chan, const char *data)
int ms = -1;
int pid = -1;
int flags;
- int oreadformat;
+ struct ast_format oreadformat;
struct timeval last;
struct ast_frame *f;
char filename[256]="";
char *c;
+ ast_format_clear(&oreadformat);
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "ICES requires an argument (configfile.xml)\n");
return -1;
@@ -143,8 +144,8 @@ static int ices_exec(struct ast_channel *chan, const char *data)
return -1;
}
- oreadformat = chan->readformat;
- res = ast_set_read_format(chan, AST_FORMAT_SLINEAR);
+ ast_format_copy(&oreadformat, &chan->readformat);
+ res = ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR);
if (res < 0) {
close(fds[0]);
close(fds[1]);
@@ -195,8 +196,8 @@ static int ices_exec(struct ast_channel *chan, const char *data)
if (pid > -1)
kill(pid, SIGKILL);
- if (!res && oreadformat)
- ast_set_read_format(chan, oreadformat);
+ if (!res && oreadformat.id)
+ ast_set_read_format(chan, &oreadformat);
return res;
}
diff --git a/apps/app_jack.c b/apps/app_jack.c
index 2f263b693..d073451a8 100644
--- a/apps/app_jack.c
+++ b/apps/app_jack.c
@@ -604,12 +604,12 @@ static void handle_jack_audio(struct ast_channel *chan, struct jack_data *jack_d
short buf[160];
struct ast_frame f = {
.frametype = AST_FRAME_VOICE,
- .subclass.codec = AST_FORMAT_SLINEAR,
.src = "JACK",
.data.ptr = buf,
.datalen = sizeof(buf),
.samples = ARRAY_LEN(buf),
};
+ ast_format_set(&f.subclass.format, AST_FORMAT_SLINEAR, 0);
for (;;) {
size_t res, read_len;
@@ -754,12 +754,12 @@ static int jack_exec(struct ast_channel *chan, const char *data)
return -1;
}
- if (ast_set_read_format(chan, AST_FORMAT_SLINEAR)) {
+ if (ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR)) {
destroy_jack_data(jack_data);
return -1;
}
- if (ast_set_write_format(chan, AST_FORMAT_SLINEAR)) {
+ if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR)) {
destroy_jack_data(jack_data);
return -1;
}
@@ -823,9 +823,9 @@ static int jack_hook_callback(struct ast_audiohook *audiohook, struct ast_channe
if (frame->frametype != AST_FRAME_VOICE)
return 0;
- if (frame->subclass.codec != AST_FORMAT_SLINEAR) {
+ if (frame->subclass.format.id != AST_FORMAT_SLINEAR) {
ast_log(LOG_WARNING, "Expected frame in SLINEAR for the audiohook, but got format %s\n",
- ast_getformatname(frame->subclass.codec));
+ ast_getformatname(&frame->subclass.format));
return 0;
}
diff --git a/apps/app_meetme.c b/apps/app_meetme.c
index 18b1e1100..ae60cfb90 100644
--- a/apps/app_meetme.c
+++ b/apps/app_meetme.c
@@ -1189,6 +1189,8 @@ static struct ast_conference *build_conf(const char *confno, const char *pin,
struct ast_conference *cnf;
struct dahdi_confinfo dahdic = { 0, };
int confno_int = 0;
+ struct ast_format_cap *cap_slin = ast_format_cap_alloc_nolock();
+ struct ast_format tmp_fmt;
AST_LIST_LOCK(&confs);
@@ -1197,9 +1199,10 @@ static struct ast_conference *build_conf(const char *confno, const char *pin,
break;
}
- if (cnf || (!make && !dynamic))
+ if (cnf || (!make && !dynamic) || !cap_slin)
goto cnfout;
+ ast_format_cap_add(cap_slin, ast_format_set(&tmp_fmt, AST_FORMAT_SLINEAR, 0));
/* Make a new one */
if (!(cnf = ast_calloc(1, sizeof(*cnf))) ||
!(cnf->usercontainer = ao2_container_alloc(1, NULL, user_no_cmp))) {
@@ -1245,10 +1248,10 @@ static struct ast_conference *build_conf(const char *confno, const char *pin,
cnf->dahdiconf = dahdic.confno;
/* Setup a new channel for playback of audio files */
- cnf->chan = ast_request("DAHDI", AST_FORMAT_SLINEAR, chan, "pseudo", NULL);
+ cnf->chan = ast_request("DAHDI", cap_slin, chan, "pseudo", NULL);
if (cnf->chan) {
- ast_set_read_format(cnf->chan, AST_FORMAT_SLINEAR);
- ast_set_write_format(cnf->chan, AST_FORMAT_SLINEAR);
+ ast_set_read_format_by_id(cnf->chan, AST_FORMAT_SLINEAR);
+ ast_set_write_format_by_id(cnf->chan, AST_FORMAT_SLINEAR);
dahdic.chan = 0;
dahdic.confno = cnf->dahdiconf;
dahdic.confmode = DAHDI_CONF_CONFANN | DAHDI_CONF_CONFANNMON;
@@ -1284,6 +1287,7 @@ static struct ast_conference *build_conf(const char *confno, const char *pin,
conf_map[confno_int] = 1;
cnfout:
+ cap_slin = ast_format_cap_destroy(cap_slin);
if (cnf)
ast_atomic_fetchadd_int(&cnf->refcount, refcount);
@@ -2260,9 +2264,16 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, struc
int setusercount = 0;
int confsilence = 0, totalsilence = 0;
char *mailbox, *context;
+ struct ast_format_cap *cap_slin = ast_format_cap_alloc_nolock();
+ struct ast_format tmpfmt;
+
+ if (!cap_slin) {
+ goto conf_run_cleanup;
+ }
+ ast_format_cap_add(cap_slin, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
if (!(user = ao2_alloc(sizeof(*user), NULL))) {
- return ret;
+ goto conf_run_cleanup;
}
/* Possible timeout waiting for marked user */
@@ -2372,9 +2383,9 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, struc
ast_mutex_lock(&conf->recordthreadlock);
if ((conf->recordthread == AST_PTHREADT_NULL) && ast_test_flag64(confflags, CONFFLAG_RECORDCONF) &&
- ((conf->lchan = ast_request("DAHDI", AST_FORMAT_SLINEAR, chan, "pseudo", NULL)))) {
- ast_set_read_format(conf->lchan, AST_FORMAT_SLINEAR);
- ast_set_write_format(conf->lchan, AST_FORMAT_SLINEAR);
+ ((conf->lchan = ast_request("DAHDI", cap_slin, chan, "pseudo", NULL)))) {
+ ast_set_read_format_by_id(conf->lchan, AST_FORMAT_SLINEAR);
+ ast_set_write_format_by_id(conf->lchan, AST_FORMAT_SLINEAR);
dahdic.chan = 0;
dahdic.confno = conf->dahdiconf;
dahdic.confmode = DAHDI_CONF_CONFANN | DAHDI_CONF_CONFANNMON;
@@ -2601,12 +2612,12 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, struc
ast_indicate(chan, -1);
}
- if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) {
+ if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR) < 0) {
ast_log(LOG_WARNING, "Unable to set '%s' to write linear mode\n", chan->name);
goto outrun;
}
- if (ast_set_read_format(chan, AST_FORMAT_SLINEAR) < 0) {
+ if (ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR) < 0) {
ast_log(LOG_WARNING, "Unable to set '%s' to read linear mode\n", chan->name);
goto outrun;
}
@@ -3167,7 +3178,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, struc
dtmfstr[1] = '\0';
}
- if ((f->frametype == AST_FRAME_VOICE) && (f->subclass.codec == AST_FORMAT_SLINEAR)) {
+ if ((f->frametype == AST_FRAME_VOICE) && (f->subclass.format.id == AST_FORMAT_SLINEAR)) {
if (user->talk.actual) {
ast_frame_adjust_volume(f, user->talk.actual);
}
@@ -3339,9 +3350,9 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, struc
}
ast_mutex_lock(&conf->recordthreadlock);
- if ((conf->recordthread == AST_PTHREADT_NULL) && ast_test_flag64(confflags, CONFFLAG_RECORDCONF) && ((conf->lchan = ast_request("DAHDI", AST_FORMAT_SLINEAR, chan, "pseudo", NULL)))) {
- ast_set_read_format(conf->lchan, AST_FORMAT_SLINEAR);
- ast_set_write_format(conf->lchan, AST_FORMAT_SLINEAR);
+ if ((conf->recordthread == AST_PTHREADT_NULL) && ast_test_flag64(confflags, CONFFLAG_RECORDCONF) && ((conf->lchan = ast_request("DAHDI", cap_slin, chan, "pseudo", NULL)))) {
+ ast_set_read_format_by_id(conf->lchan, AST_FORMAT_SLINEAR);
+ ast_set_write_format_by_id(conf->lchan, AST_FORMAT_SLINEAR);
dahdic.chan = 0;
dahdic.confno = conf->dahdiconf;
dahdic.confmode = DAHDI_CONF_CONFANN | DAHDI_CONF_CONFANNMON;
@@ -3627,7 +3638,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, struc
if (res > 0) {
memset(&fr, 0, sizeof(fr));
fr.frametype = AST_FRAME_VOICE;
- fr.subclass.codec = AST_FORMAT_SLINEAR;
+ ast_format_set(&fr.subclass.format, AST_FORMAT_SLINEAR, 0);
fr.datalen = res;
fr.samples = res / 2;
fr.data.ptr = buf;
@@ -3639,7 +3650,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, struc
)) {
int idx;
for (idx = 0; idx < AST_FRAME_BITS; idx++) {
- if (chan->rawwriteformat & (1 << idx)) {
+ if (ast_format_to_old_bitfield(&chan->rawwriteformat) & (1 << idx)) {
break;
}
}
@@ -3654,7 +3665,11 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, struc
mohtempstopped = 1;
}
if (!conf->transpath[idx]) {
- conf->transpath[idx] = ast_translator_build_path((1 << idx), AST_FORMAT_SLINEAR);
+ struct ast_format src;
+ struct ast_format dst;
+ ast_format_set(&src, AST_FORMAT_SLINEAR, 0);
+ ast_format_from_old_bitfield(&dst, (1 << idx));
+ conf->transpath[idx] = ast_translator_build_path(&dst, &src);
}
if (conf->transpath[idx]) {
conf->transframe[idx] = ast_translate(conf->transpath[idx], conf->origframe, 0);
@@ -3821,6 +3836,10 @@ bailoutandtrynormal:
ao2_ref(user, -1);
AST_LIST_UNLOCK(&confs);
+
+conf_run_cleanup:
+ cap_slin = ast_format_cap_destroy(cap_slin);
+
return ret;
}
diff --git a/apps/app_milliwatt.c b/apps/app_milliwatt.c
index 24137606d..26cba3c40 100644
--- a/apps/app_milliwatt.c
+++ b/apps/app_milliwatt.c
@@ -78,10 +78,10 @@ static int milliwatt_generate(struct ast_channel *chan, void *data, int len, int
int i, *indexp = (int *) data;
struct ast_frame wf = {
.frametype = AST_FRAME_VOICE,
- .subclass.codec = AST_FORMAT_ULAW,
.offset = AST_FRIENDLY_OFFSET,
.src = __FUNCTION__,
};
+ ast_format_set(&wf.subclass.format, AST_FORMAT_ULAW, 0);
wf.data.ptr = buf + AST_FRIENDLY_OFFSET;
/* Instead of len, use samples, because channel.c generator_force
@@ -120,8 +120,8 @@ static struct ast_generator milliwattgen = {
static int old_milliwatt_exec(struct ast_channel *chan)
{
- ast_set_write_format(chan, AST_FORMAT_ULAW);
- ast_set_read_format(chan, AST_FORMAT_ULAW);
+ ast_set_write_format_by_id(chan, AST_FORMAT_ULAW);
+ ast_set_read_format_by_id(chan, AST_FORMAT_ULAW);
if (chan->_state != AST_STATE_UP) {
ast_answer(chan);
diff --git a/apps/app_mixmonitor.c b/apps/app_mixmonitor.c
index ca3a23991..8e6adead1 100644
--- a/apps/app_mixmonitor.c
+++ b/apps/app_mixmonitor.c
@@ -281,7 +281,9 @@ static void *mixmonitor_thread(void *obj)
unsigned int oflags;
char *ext;
int errflag = 0;
+ struct ast_format format_slin;
+ ast_format_set(&format_slin, AST_FORMAT_SLINEAR, 0);
ast_verb(2, "Begin MixMonitor Recording %s\n", mixmonitor->name);
fs = &mixmonitor->mixmonitor_ds->fs;
@@ -291,7 +293,7 @@ static void *mixmonitor_thread(void *obj)
while (mixmonitor->audiohook.status == AST_AUDIOHOOK_STATUS_RUNNING && !mixmonitor->mixmonitor_ds->fs_quit) {
struct ast_frame *fr = NULL;
- if (!(fr = ast_audiohook_read_frame(&mixmonitor->audiohook, SAMPLES_PER_FRAME, AST_AUDIOHOOK_DIRECTION_BOTH, AST_FORMAT_SLINEAR))) {
+ if (!(fr = ast_audiohook_read_frame(&mixmonitor->audiohook, SAMPLES_PER_FRAME, AST_AUDIOHOOK_DIRECTION_BOTH, &format_slin))) {
ast_audiohook_trigger_wait(&mixmonitor->audiohook);
if (mixmonitor->audiohook.status != AST_AUDIOHOOK_STATUS_RUNNING) {
diff --git a/apps/app_mp3.c b/apps/app_mp3.c
index f8e42a12c..f8c5a0578 100644
--- a/apps/app_mp3.c
+++ b/apps/app_mp3.c
@@ -137,7 +137,7 @@ static int mp3_exec(struct ast_channel *chan, const char *data)
int fds[2];
int ms = -1;
int pid = -1;
- int owriteformat;
+ struct ast_format owriteformat;
int timeout = 2000;
struct timeval next;
struct ast_frame *f;
@@ -149,6 +149,7 @@ static int mp3_exec(struct ast_channel *chan, const char *data)
.f = { 0, },
};
+ ast_format_clear(&owriteformat);
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "MP3 Playback requires an argument (filename)\n");
return -1;
@@ -161,8 +162,8 @@ static int mp3_exec(struct ast_channel *chan, const char *data)
ast_stopstream(chan);
- owriteformat = chan->writeformat;
- res = ast_set_write_format(chan, AST_FORMAT_SLINEAR);
+ ast_format_copy(&owriteformat, &chan->writeformat);
+ 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;
@@ -185,7 +186,7 @@ static int mp3_exec(struct ast_channel *chan, const char *data)
res = timed_read(fds[0], myf.frdata, sizeof(myf.frdata), timeout);
if (res > 0) {
myf.f.frametype = AST_FRAME_VOICE;
- myf.f.subclass.codec = AST_FORMAT_SLINEAR;
+ ast_format_set(&myf.f.subclass.format, AST_FORMAT_SLINEAR, 0);
myf.f.datalen = res;
myf.f.samples = res / 2;
myf.f.mallocd = 0;
@@ -234,8 +235,8 @@ static int mp3_exec(struct ast_channel *chan, const char *data)
if (pid > -1)
kill(pid, SIGKILL);
- if (!res && owriteformat)
- ast_set_write_format(chan, owriteformat);
+ if (!res && owriteformat.id)
+ ast_set_write_format(chan, &owriteformat);
return res;
}
diff --git a/apps/app_nbscat.c b/apps/app_nbscat.c
index dd7637a83..2bbde630e 100644
--- a/apps/app_nbscat.c
+++ b/apps/app_nbscat.c
@@ -111,7 +111,7 @@ static int NBScat_exec(struct ast_channel *chan, const char *data)
int fds[2];
int ms = -1;
int pid = -1;
- int owriteformat;
+ struct ast_format owriteformat;
struct timeval next;
struct ast_frame *f;
struct myframe {
@@ -119,7 +119,8 @@ static int NBScat_exec(struct ast_channel *chan, const char *data)
char offset[AST_FRIENDLY_OFFSET];
short frdata[160];
} myf;
-
+
+ ast_format_clear(&owriteformat);
if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fds)) {
ast_log(LOG_WARNING, "Unable to create socketpair\n");
return -1;
@@ -127,8 +128,8 @@ static int NBScat_exec(struct ast_channel *chan, const char *data)
ast_stopstream(chan);
- owriteformat = chan->writeformat;
- res = ast_set_write_format(chan, AST_FORMAT_SLINEAR);
+ ast_format_copy(&owriteformat, &chan->writeformat);
+ 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;
@@ -148,7 +149,7 @@ static int NBScat_exec(struct ast_channel *chan, const char *data)
res = timed_read(fds[0], myf.frdata, sizeof(myf.frdata));
if (res > 0) {
myf.f.frametype = AST_FRAME_VOICE;
- myf.f.subclass.codec = AST_FORMAT_SLINEAR;
+ ast_format_set(&myf.f.subclass.format, AST_FORMAT_SLINEAR, 0);
myf.f.datalen = res;
myf.f.samples = res / 2;
myf.f.mallocd = 0;
@@ -197,8 +198,8 @@ static int NBScat_exec(struct ast_channel *chan, const char *data)
if (pid > -1)
kill(pid, SIGKILL);
- if (!res && owriteformat)
- ast_set_write_format(chan, owriteformat);
+ if (!res && owriteformat.id)
+ ast_set_write_format(chan, &owriteformat);
return res;
}
diff --git a/apps/app_originate.c b/apps/app_originate.c
index 659ea2949..94ac3596c 100644
--- a/apps/app_originate.c
+++ b/apps/app_originate.c
@@ -105,8 +105,14 @@ static int originate_exec(struct ast_channel *chan, const char *data)
int outgoing_status = 0;
static const unsigned int timeout = 30;
static const char default_exten[] = "s";
+ struct ast_format tmpfmt;
+ struct ast_format_cap *cap_slin = ast_format_cap_alloc_nolock();
ast_autoservice_start(chan);
+ if (!cap_slin) {
+ goto return_cleanup;
+ }
+ ast_format_cap_add(cap_slin, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
if (ast_strlen_zero(data)) {
ast_log(LOG_ERROR, "Originate() requires arguments\n");
@@ -148,14 +154,14 @@ static int originate_exec(struct ast_channel *chan, const char *data)
ast_debug(1, "Originating call to '%s/%s' and connecting them to extension %s,%s,%d\n",
chantech, chandata, args.arg1, exten, priority);
- outgoing_res = ast_pbx_outgoing_exten(chantech, AST_FORMAT_SLINEAR, chandata,
+ outgoing_res = ast_pbx_outgoing_exten(chantech, cap_slin, chandata,
timeout * 1000, args.arg1, exten, priority, &outgoing_status, 0, NULL,
NULL, NULL, NULL, NULL);
} else if (!strcasecmp(args.type, "app")) {
ast_debug(1, "Originating call to '%s/%s' and connecting them to %s(%s)\n",
chantech, chandata, args.arg1, S_OR(args.arg2, ""));
- outgoing_res = ast_pbx_outgoing_app(chantech, AST_FORMAT_SLINEAR, chandata,
+ outgoing_res = ast_pbx_outgoing_app(chantech, cap_slin, chandata,
timeout * 1000, args.arg1, args.arg2, &outgoing_status, 0, NULL,
NULL, NULL, NULL, NULL);
} else {
@@ -194,7 +200,7 @@ return_cleanup:
break;
}
}
-
+ cap_slin = ast_format_cap_destroy(cap_slin);
ast_autoservice_stop(chan);
return res;
diff --git a/apps/app_parkandannounce.c b/apps/app_parkandannounce.c
index 5bb8b6594..fb3e713e1 100644
--- a/apps/app_parkandannounce.c
+++ b/apps/app_parkandannounce.c
@@ -96,6 +96,9 @@ static int parkandannounce_exec(struct ast_channel *chan, const char *data)
struct ast_channel *dchan;
struct outgoing_helper oh = { 0, };
int outstate;
+ struct ast_format tmpfmt;
+ struct ast_format_cap *cap_slin = ast_format_cap_alloc_nolock();
+
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(template);
AST_APP_ARG(timeout);
@@ -104,9 +107,15 @@ static int parkandannounce_exec(struct ast_channel *chan, const char *data)
);
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "ParkAndAnnounce requires arguments: (announce:template|timeout|dial|[return_context])\n");
- return -1;
+ res = -1;
+ goto parkcleanup;
+ }
+ if (!cap_slin) {
+ res = -1;
+ goto parkcleanup;
}
-
+ ast_format_cap_add(cap_slin, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
+
s = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, s);
@@ -115,7 +124,8 @@ static int parkandannounce_exec(struct ast_channel *chan, const char *data)
if (ast_strlen_zero(args.dial)) {
ast_log(LOG_WARNING, "PARK: A dial resource must be specified i.e: Console/dsp or DAHDI/g1/5551212\n");
- return -1;
+ res = -1;
+ goto parkcleanup;
}
dialtech = strsep(&args.dial, "/");
@@ -138,8 +148,9 @@ static int parkandannounce_exec(struct ast_channel *chan, const char *data)
before we are done announcing and the channel is messed with, Kablooeee. So we use Masq to prevent this. */
res = ast_masq_park_call(chan, NULL, timeout, &lot);
- if (res == -1)
- return res;
+ if (res == -1) {
+ goto parkcleanup;
+ }
ast_verb(3, "Call Parking Called, lot: %d, timeout: %d, context: %s\n", lot, timeout, args.return_context);
@@ -148,7 +159,7 @@ static int parkandannounce_exec(struct ast_channel *chan, const char *data)
snprintf(buf, sizeof(buf), "%d", lot);
oh.parent_channel = chan;
oh.vars = ast_variable_new("_PARKEDAT", buf, "");
- dchan = __ast_request_and_dial(dialtech, AST_FORMAT_SLINEAR, chan, args.dial, 30000,
+ dchan = __ast_request_and_dial(dialtech, cap_slin, chan, args.dial, 30000,
&outstate,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL),
S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, NULL),
@@ -160,11 +171,13 @@ static int parkandannounce_exec(struct ast_channel *chan, const char *data)
ast_verb(4, "Channel %s was never answered.\n", dchan->name);
ast_log(LOG_WARNING, "PARK: Channel %s was never answered for the announce.\n", dchan->name);
ast_hangup(dchan);
- return -1;
+ res = -1;
+ goto parkcleanup;
}
} else {
ast_log(LOG_WARNING, "PARK: Unable to allocate announce channel.\n");
- return -1;
+ res = -1;
+ goto parkcleanup;
}
ast_stopstream(dchan);
@@ -197,7 +210,10 @@ static int parkandannounce_exec(struct ast_channel *chan, const char *data)
ast_stopstream(dchan);
ast_hangup(dchan);
-
+
+parkcleanup:
+ cap_slin = ast_format_cap_destroy(cap_slin);
+
return res;
}
diff --git a/apps/app_record.c b/apps/app_record.c
index 64e635018..a192b1adc 100644
--- a/apps/app_record.c
+++ b/apps/app_record.c
@@ -154,7 +154,7 @@ static int record_exec(struct ast_channel *chan, const char *data)
int maxduration = 0; /* max duration of recording in milliseconds */
int gottimeout = 0; /* did we timeout for maxduration exceeded? */
int terminator = '#';
- int rfmt = 0;
+ struct ast_format rfmt;
int ioflags;
int waitres;
struct ast_silence_generator *silgen = NULL;
@@ -165,7 +165,8 @@ static int record_exec(struct ast_channel *chan, const char *data)
AST_APP_ARG(maxduration);
AST_APP_ARG(options);
);
-
+
+ ast_format_clear(&rfmt);
/* The next few lines of code parse out the filename and header from the input string */
if (ast_strlen_zero(data)) { /* no data implies no filename or anything is present */
ast_log(LOG_WARNING, "Record requires an argument (filename)\n");
@@ -286,8 +287,8 @@ static int record_exec(struct ast_channel *chan, const char *data)
/* The end of beep code. Now the recording starts */
if (silence > 0) {
- rfmt = chan->readformat;
- res = ast_set_read_format(chan, AST_FORMAT_SLINEAR);
+ ast_format_copy(&rfmt, &chan->readformat);
+ 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");
pbx_builtin_setvar_helper(chan, "RECORD_STATUS", "ERROR");
@@ -408,8 +409,8 @@ static int record_exec(struct ast_channel *chan, const char *data)
ast_channel_stop_silence_generator(chan, silgen);
out:
- if ((silence > 0) && rfmt) {
- res = ast_set_read_format(chan, rfmt);
+ if ((silence > 0) && rfmt.id) {
+ res = ast_set_read_format(chan, &rfmt);
if (res)
ast_log(LOG_WARNING, "Unable to restore read format on '%s'\n", chan->name);
if (sildet)
diff --git a/apps/app_rpt.c b/apps/app_rpt.c
index a4d350d32..765f73184 100644
--- a/apps/app_rpt.c
+++ b/apps/app_rpt.c
@@ -882,6 +882,7 @@ static int setrem(struct rpt *myrpt);
static int setrtx_check(struct rpt *myrpt);
static int channel_revert(struct rpt *myrpt);
static int channel_steer(struct rpt *myrpt, char *data);
+static struct ast_format_cap *get_slin_cap(struct ast_format_cap *cap);
AST_MUTEX_DEFINE_STATIC(nodeloglock);
@@ -951,7 +952,6 @@ int i;
return(NULL);
}
-
static void rpt_mutex_spew(void)
{
struct by_lightning lock_ring_copy[32];
@@ -1070,6 +1070,18 @@ pthread_t id;
#endif /* APP_RPT_LOCK_DEBUG */
+static struct ast_format_cap *get_slin_cap(struct ast_format_cap *cap)
+{
+ struct ast_format tmp;
+ cap = ast_format_cap_alloc_nolock();
+ if (!cap) {
+ return NULL;
+ }
+ ast_format_cap_add(cap, ast_format_set(&tmp, AST_FORMAT_SLINEAR, 0));
+
+ return cap;
+}
+
/*
* Return 1 if rig is multimode capable
*/
@@ -3961,7 +3973,7 @@ char mhz[MAXREMSTR];
char decimals[MAXREMSTR];
char mystr[200];
struct dahdi_params par;
-
+struct ast_format_cap *cap = NULL;
/* get a pointer to myrpt */
myrpt = mytele->rpt;
@@ -4004,7 +4016,8 @@ struct dahdi_params par;
/* allocate a pseudo-channel thru asterisk */
- mychannel = ast_request("DAHDI", AST_FORMAT_SLINEAR, NULL, "pseudo", NULL);
+ mychannel = ast_request("DAHDI", get_slin_cap(cap), NULL, "pseudo", NULL);
+ cap = ast_format_cap_destroy(cap);
if (!mychannel)
{
fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
@@ -5288,10 +5301,12 @@ struct rpt *myrpt = (struct rpt *)this;
int res;
int stopped,congstarted,dialtimer,lastcidx,aborted;
struct ast_channel *mychannel,*genchannel;
+struct ast_format_cap *cap = NULL;
myrpt->mydtmf = 0;
/* allocate a pseudo-channel thru asterisk */
- mychannel = ast_request("DAHDI", AST_FORMAT_SLINEAR, NULL, "pseudo", NULL);
+ mychannel = ast_request("DAHDI", get_slin_cap(cap), NULL, "pseudo", NULL);
+ cap = ast_format_cap_destroy(cap);
if (!mychannel)
{
fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
@@ -5317,7 +5332,8 @@ struct ast_channel *mychannel,*genchannel;
pthread_exit(NULL);
}
/* allocate a pseudo-channel thru asterisk */
- genchannel = ast_request("DAHDI", AST_FORMAT_SLINEAR, NULL, "pseudo", NULL);
+ genchannel = ast_request("DAHDI", get_slin_cap(cap), NULL, "pseudo", NULL);
+ cap = ast_format_cap_destroy(cap);
if (!genchannel)
{
fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
@@ -5689,6 +5705,7 @@ static int connect_link(struct rpt *myrpt, char* node, int mode, int perma)
int reconnects = 0;
int i,n;
struct dahdi_confinfo ci; /* conference info */
+ struct ast_format_cap *cap = NULL;
val = node_lookup(myrpt,node);
if (!val){
@@ -5792,10 +5809,11 @@ static int connect_link(struct rpt *myrpt, char* node, int mode, int perma)
return -1;
}
*tele++ = 0;
- l->chan = ast_request(deststr, AST_FORMAT_SLINEAR, NULL, tele, NULL);
+ l->chan = ast_request(deststr, get_slin_cap(cap), NULL, tele, NULL);
+ cap = ast_format_cap_destroy(cap);
if (l->chan){
- ast_set_read_format(l->chan, AST_FORMAT_SLINEAR);
- ast_set_write_format(l->chan, AST_FORMAT_SLINEAR);
+ ast_set_read_format_by_id(l->chan, AST_FORMAT_SLINEAR);
+ ast_set_write_format_by_id(l->chan, AST_FORMAT_SLINEAR);
#ifdef AST_CDR_FLAG_POST_DISABLED
if (l->chan->cdr)
ast_set_flag(l->chan->cdr,AST_CDR_FLAG_POST_DISABLED);
@@ -5827,15 +5845,16 @@ static int connect_link(struct rpt *myrpt, char* node, int mode, int perma)
return -1;
}
/* allocate a pseudo-channel thru asterisk */
- l->pchan = ast_request("DAHDI", AST_FORMAT_SLINEAR, NULL, "pseudo", NULL);
+ l->pchan = ast_request("DAHDI", get_slin_cap(cap), NULL, "pseudo", NULL);
+ cap = ast_format_cap_destroy(cap);
if (!l->pchan){
ast_log(LOG_WARNING,"rpt connect: Sorry unable to obtain pseudo channel\n");
ast_hangup(l->chan);
ast_free(l);
return -1;
}
- ast_set_read_format(l->pchan, AST_FORMAT_SLINEAR);
- ast_set_write_format(l->pchan, AST_FORMAT_SLINEAR);
+ ast_set_read_format_by_id(l->pchan, AST_FORMAT_SLINEAR);
+ ast_set_write_format_by_id(l->pchan, AST_FORMAT_SLINEAR);
#ifdef AST_CDR_FLAG_POST_DISABLED
if (l->pchan->cdr)
ast_set_flag(l->pchan->cdr,AST_CDR_FLAG_POST_DISABLED);
@@ -10341,6 +10360,7 @@ static int attempt_reconnect(struct rpt *myrpt, struct rpt_link *l)
char *val, *s, *s1, *s2, *tele;
char tmp[300], deststr[300] = "";
char sx[320],*sy;
+ struct ast_format_cap *cap = NULL;
val = node_lookup(myrpt,l->name);
@@ -10376,10 +10396,11 @@ static int attempt_reconnect(struct rpt *myrpt, struct rpt_link *l)
l->connecttime = 0;
l->thisconnected = 0;
l->newkey = 0;
- l->chan = ast_request(deststr, AST_FORMAT_SLINEAR, NULL, tele, NULL);
+ l->chan = ast_request(deststr, get_slin_cap(cap), NULL, tele, NULL);
+ cap = ast_format_cap_destroy(cap);
if (l->chan){
- ast_set_read_format(l->chan, AST_FORMAT_SLINEAR);
- ast_set_write_format(l->chan, AST_FORMAT_SLINEAR);
+ ast_set_read_format_by_id(l->chan, AST_FORMAT_SLINEAR);
+ ast_set_write_format_by_id(l->chan, AST_FORMAT_SLINEAR);
#ifndef NEW_ASTERISK
l->chan->whentohangup = 0;
#endif
@@ -10743,6 +10764,7 @@ time_t t;
struct rpt_link *l,*m;
struct rpt_tele *telem;
char tmpstr[300],lstr[MAXLINKLIST];
+struct ast_format_cap *cap = NULL;
if (myrpt->p.archivedir) mkdir(myrpt->p.archivedir,0600);
@@ -10795,7 +10817,8 @@ char tmpstr[300],lstr[MAXLINKLIST];
pthread_exit(NULL);
}
*tele++ = 0;
- myrpt->rxchannel = ast_request(tmpstr, AST_FORMAT_SLINEAR, NULL, tele, NULL);
+ myrpt->rxchannel = ast_request(tmpstr, get_slin_cap(cap), NULL, tele, NULL);
+ cap = ast_format_cap_destroy(cap);
myrpt->dahdirxchannel = NULL;
if (!strcasecmp(tmpstr,"DAHDI"))
myrpt->dahdirxchannel = myrpt->rxchannel;
@@ -10809,8 +10832,8 @@ char tmpstr[300],lstr[MAXLINKLIST];
myrpt->rpt_thread = AST_PTHREADT_STOP;
pthread_exit(NULL);
}
- ast_set_read_format(myrpt->rxchannel,AST_FORMAT_SLINEAR);
- ast_set_write_format(myrpt->rxchannel,AST_FORMAT_SLINEAR);
+ ast_set_read_format_by_id(myrpt->rxchannel,AST_FORMAT_SLINEAR);
+ ast_set_write_format_by_id(myrpt->rxchannel,AST_FORMAT_SLINEAR);
#ifdef AST_CDR_FLAG_POST_DISABLED
if (myrpt->rxchannel->cdr)
ast_set_flag(myrpt->rxchannel->cdr,AST_CDR_FLAG_POST_DISABLED);
@@ -10853,7 +10876,8 @@ char tmpstr[300],lstr[MAXLINKLIST];
pthread_exit(NULL);
}
*tele++ = 0;
- myrpt->txchannel = ast_request(tmpstr, AST_FORMAT_SLINEAR, NULL, tele, NULL);
+ myrpt->txchannel = ast_request(tmpstr, get_slin_cap(cap), NULL, tele, NULL);
+ cap = ast_format_cap_destroy(cap);
if (!strcasecmp(tmpstr,"DAHDI"))
myrpt->dahditxchannel = myrpt->txchannel;
if (myrpt->txchannel)
@@ -10867,8 +10891,8 @@ char tmpstr[300],lstr[MAXLINKLIST];
myrpt->rpt_thread = AST_PTHREADT_STOP;
pthread_exit(NULL);
}
- ast_set_read_format(myrpt->txchannel,AST_FORMAT_SLINEAR);
- ast_set_write_format(myrpt->txchannel,AST_FORMAT_SLINEAR);
+ ast_set_read_format_by_id(myrpt->txchannel,AST_FORMAT_SLINEAR);
+ ast_set_write_format_by_id(myrpt->txchannel,AST_FORMAT_SLINEAR);
#ifdef AST_CDR_FLAG_POST_DISABLED
if (myrpt->txchannel->cdr)
ast_set_flag(myrpt->txchannel->cdr,AST_CDR_FLAG_POST_DISABLED);
@@ -10909,7 +10933,8 @@ char tmpstr[300],lstr[MAXLINKLIST];
ast_indicate(myrpt->txchannel,AST_CONTROL_RADIO_KEY);
ast_indicate(myrpt->txchannel,AST_CONTROL_RADIO_UNKEY);
/* allocate a pseudo-channel thru asterisk */
- myrpt->pchannel = ast_request("DAHDI", AST_FORMAT_SLINEAR, NULL, "pseudo", NULL);
+ myrpt->pchannel = ast_request("DAHDI", get_slin_cap(cap), NULL, "pseudo", NULL);
+ cap = ast_format_cap_destroy(cap);
if (!myrpt->pchannel)
{
fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
@@ -10928,7 +10953,8 @@ char tmpstr[300],lstr[MAXLINKLIST];
if (!myrpt->dahditxchannel)
{
/* allocate a pseudo-channel thru asterisk */
- myrpt->dahditxchannel = ast_request("DAHDI", AST_FORMAT_SLINEAR, NULL, "pseudo", NULL);
+ myrpt->dahditxchannel = ast_request("DAHDI", get_slin_cap(cap), NULL, "pseudo", NULL);
+ cap = ast_format_cap_destroy(cap);
if (!myrpt->dahditxchannel)
{
fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
@@ -10939,15 +10965,16 @@ char tmpstr[300],lstr[MAXLINKLIST];
myrpt->rpt_thread = AST_PTHREADT_STOP;
pthread_exit(NULL);
}
- ast_set_read_format(myrpt->dahditxchannel,AST_FORMAT_SLINEAR);
- ast_set_write_format(myrpt->dahditxchannel,AST_FORMAT_SLINEAR);
+ ast_set_read_format_by_id(myrpt->dahditxchannel,AST_FORMAT_SLINEAR);
+ ast_set_write_format_by_id(myrpt->dahditxchannel,AST_FORMAT_SLINEAR);
#ifdef AST_CDR_FLAG_POST_DISABLED
if (myrpt->dahditxchannel->cdr)
ast_set_flag(myrpt->dahditxchannel->cdr,AST_CDR_FLAG_POST_DISABLED);
#endif
}
/* allocate a pseudo-channel thru asterisk */
- myrpt->monchannel = ast_request("DAHDI", AST_FORMAT_SLINEAR, NULL, "pseudo", NULL);
+ myrpt->monchannel = ast_request("DAHDI", get_slin_cap(cap), NULL, "pseudo", NULL);
+ cap = ast_format_cap_destroy(cap);
if (!myrpt->monchannel)
{
fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
@@ -10958,8 +10985,8 @@ char tmpstr[300],lstr[MAXLINKLIST];
myrpt->rpt_thread = AST_PTHREADT_STOP;
pthread_exit(NULL);
}
- ast_set_read_format(myrpt->monchannel,AST_FORMAT_SLINEAR);
- ast_set_write_format(myrpt->monchannel,AST_FORMAT_SLINEAR);
+ ast_set_read_format_by_id(myrpt->monchannel,AST_FORMAT_SLINEAR);
+ ast_set_write_format_by_id(myrpt->monchannel,AST_FORMAT_SLINEAR);
#ifdef AST_CDR_FLAG_POST_DISABLED
if (myrpt->monchannel->cdr)
ast_set_flag(myrpt->monchannel->cdr,AST_CDR_FLAG_POST_DISABLED);
@@ -11042,7 +11069,8 @@ char tmpstr[300],lstr[MAXLINKLIST];
pthread_exit(NULL);
}
/* allocate a pseudo-channel thru asterisk */
- myrpt->parrotchannel = ast_request("DAHDI", AST_FORMAT_SLINEAR, NULL, "pseudo", NULL);
+ myrpt->parrotchannel = ast_request("DAHDI", get_slin_cap(cap), NULL, "pseudo", NULL);
+ cap = ast_format_cap_destroy(cap);
if (!myrpt->parrotchannel)
{
fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
@@ -11053,14 +11081,15 @@ char tmpstr[300],lstr[MAXLINKLIST];
myrpt->rpt_thread = AST_PTHREADT_STOP;
pthread_exit(NULL);
}
- ast_set_read_format(myrpt->parrotchannel,AST_FORMAT_SLINEAR);
- ast_set_write_format(myrpt->parrotchannel,AST_FORMAT_SLINEAR);
+ ast_set_read_format_by_id(myrpt->parrotchannel,AST_FORMAT_SLINEAR);
+ ast_set_write_format_by_id(myrpt->parrotchannel,AST_FORMAT_SLINEAR);
#ifdef AST_CDR_FLAG_POST_DISABLED
if (myrpt->parrotchannel->cdr)
ast_set_flag(myrpt->parrotchannel->cdr,AST_CDR_FLAG_POST_DISABLED);
#endif
/* allocate a pseudo-channel thru asterisk */
- myrpt->voxchannel = ast_request("DAHDI", AST_FORMAT_SLINEAR, NULL, "pseudo", NULL);
+ myrpt->voxchannel = ast_request("DAHDI", get_slin_cap(cap), NULL, "pseudo", NULL);
+ cap = ast_format_cap_destroy(cap);
if (!myrpt->voxchannel)
{
fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
@@ -11071,14 +11100,15 @@ char tmpstr[300],lstr[MAXLINKLIST];
myrpt->rpt_thread = AST_PTHREADT_STOP;
pthread_exit(NULL);
}
- ast_set_read_format(myrpt->voxchannel,AST_FORMAT_SLINEAR);
- ast_set_write_format(myrpt->voxchannel,AST_FORMAT_SLINEAR);
+ ast_set_read_format_by_id(myrpt->voxchannel,AST_FORMAT_SLINEAR);
+ ast_set_write_format_by_id(myrpt->voxchannel,AST_FORMAT_SLINEAR);
#ifdef AST_CDR_FLAG_POST_DISABLED
if (myrpt->voxchannel->cdr)
ast_set_flag(myrpt->voxchannel->cdr,AST_CDR_FLAG_POST_DISABLED);
#endif
/* allocate a pseudo-channel thru asterisk */
- myrpt->txpchannel = ast_request("DAHDI", AST_FORMAT_SLINEAR, NULL, "pseudo", NULL);
+ myrpt->txpchannel = ast_request("DAHDI", get_slin_cap(cap), NULL, "pseudo", NULL);
+ cap = ast_format_cap_destroy(cap);
if (!myrpt->txpchannel)
{
fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
@@ -13146,6 +13176,7 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
struct dahdi_radio_param z;
struct rpt_tele *telem;
int numlinks;
+ struct ast_format_cap *cap = NULL;
nullfd = open("/dev/null",O_RDWR);
if (ast_strlen_zero(data)) {
@@ -13631,17 +13662,18 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
l->lastf2 = NULL;
l->dtmfed = 0;
voxinit_link(l,1);
- ast_set_read_format(l->chan,AST_FORMAT_SLINEAR);
- ast_set_write_format(l->chan,AST_FORMAT_SLINEAR);
+ ast_set_read_format_by_id(l->chan,AST_FORMAT_SLINEAR);
+ ast_set_write_format_by_id(l->chan,AST_FORMAT_SLINEAR);
/* allocate a pseudo-channel thru asterisk */
- l->pchan = ast_request("DAHDI", AST_FORMAT_SLINEAR, NULL, "pseudo", NULL);
+ l->pchan = ast_request("DAHDI", get_slin_cap(cap), NULL, "pseudo", NULL);
+ cap = ast_format_cap_destroy(cap);
if (!l->pchan)
{
fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
pthread_exit(NULL);
}
- ast_set_read_format(l->pchan,AST_FORMAT_SLINEAR);
- ast_set_write_format(l->pchan,AST_FORMAT_SLINEAR);
+ ast_set_read_format_by_id(l->pchan,AST_FORMAT_SLINEAR);
+ ast_set_write_format_by_id(l->pchan,AST_FORMAT_SLINEAR);
#ifdef AST_CDR_FLAG_POST_DISABLED
if (l->pchan->cdr)
ast_set_flag(l->pchan->cdr,AST_CDR_FLAG_POST_DISABLED);
@@ -13778,14 +13810,15 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
pthread_exit(NULL);
}
*tele++ = 0;
- myrpt->rxchannel = ast_request(myrpt->rxchanname, AST_FORMAT_SLINEAR, NULL, tele, NULL);
+ myrpt->rxchannel = ast_request(myrpt->rxchanname, get_slin_cap(cap), NULL, tele, NULL);
+ cap = ast_format_cap_destroy(cap);
myrpt->dahdirxchannel = NULL;
if (!strcasecmp(myrpt->rxchanname,"DAHDI"))
myrpt->dahdirxchannel = myrpt->rxchannel;
if (myrpt->rxchannel)
{
- ast_set_read_format(myrpt->rxchannel,AST_FORMAT_SLINEAR);
- ast_set_write_format(myrpt->rxchannel,AST_FORMAT_SLINEAR);
+ ast_set_read_format_by_id(myrpt->rxchannel,AST_FORMAT_SLINEAR);
+ ast_set_write_format_by_id(myrpt->rxchannel,AST_FORMAT_SLINEAR);
#ifdef AST_CDR_FLAG_POST_DISABLED
if (myrpt->rxchannel->cdr)
ast_set_flag(myrpt->rxchannel->cdr,AST_CDR_FLAG_POST_DISABLED);
@@ -13821,13 +13854,14 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
pthread_exit(NULL);
}
*tele++ = 0;
- myrpt->txchannel = ast_request(myrpt->txchanname, AST_FORMAT_SLINEAR, NULL, tele, NULL);
+ myrpt->txchannel = ast_request(myrpt->txchanname, get_slin_cap(cap), NULL, tele, NULL);
+ cap = ast_format_cap_destroy(cap);
if (!strncasecmp(myrpt->txchanname,"DAHDI",3))
myrpt->dahditxchannel = myrpt->txchannel;
if (myrpt->txchannel)
{
- ast_set_read_format(myrpt->txchannel,AST_FORMAT_SLINEAR);
- ast_set_write_format(myrpt->txchannel,AST_FORMAT_SLINEAR);
+ ast_set_read_format_by_id(myrpt->txchannel,AST_FORMAT_SLINEAR);
+ ast_set_write_format_by_id(myrpt->txchannel,AST_FORMAT_SLINEAR);
#ifdef AST_CDR_FLAG_POST_DISABLED
if (myrpt->txchannel->cdr)
ast_set_flag(myrpt->txchannel->cdr,AST_CDR_FLAG_POST_DISABLED);
@@ -13860,7 +13894,8 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
myrpt->dahditxchannel = myrpt->rxchannel;
}
/* allocate a pseudo-channel thru asterisk */
- myrpt->pchannel = ast_request("DAHDI", AST_FORMAT_SLINEAR, NULL, "pseudo", NULL);
+ myrpt->pchannel = ast_request("DAHDI", get_slin_cap(cap), NULL, "pseudo", NULL);
+ cap = ast_format_cap_destroy(cap);
if (!myrpt->pchannel)
{
fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
@@ -13870,8 +13905,8 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
ast_hangup(myrpt->rxchannel);
pthread_exit(NULL);
}
- ast_set_read_format(myrpt->pchannel,AST_FORMAT_SLINEAR);
- ast_set_write_format(myrpt->pchannel,AST_FORMAT_SLINEAR);
+ ast_set_read_format_by_id(myrpt->pchannel,AST_FORMAT_SLINEAR);
+ ast_set_write_format_by_id(myrpt->pchannel,AST_FORMAT_SLINEAR);
#ifdef AST_CDR_FLAG_POST_DISABLED
if (myrpt->pchannel->cdr)
ast_set_flag(myrpt->pchannel->cdr,AST_CDR_FLAG_POST_DISABLED);
@@ -13987,8 +14022,8 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
myrpt->tele.prev = &myrpt->tele;
myrpt->newkey = 0;
rpt_mutex_unlock(&myrpt->lock);
- ast_set_write_format(chan, AST_FORMAT_SLINEAR);
- ast_set_read_format(chan, AST_FORMAT_SLINEAR);
+ ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR);
+ ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR);
rem_rx = 0;
remkeyed = 0;
/* if we are on 2w loop and are a remote, turn EC on */
diff --git a/apps/app_sms.c b/apps/app_sms.c
index b5c471b8e..07af71d1c 100644
--- a/apps/app_sms.c
+++ b/apps/app_sms.c
@@ -1603,7 +1603,7 @@ static int sms_generate(struct ast_channel *chan, void *data, int len, int sampl
buf = alloca(len);
f.frametype = AST_FRAME_VOICE;
- f.subclass.codec = __OUT_FMT;
+ ast_format_set(&f.subclass.format, __OUT_FMT, 0);
f.datalen = samples * sizeof(*buf);
f.offset = AST_FRIENDLY_OFFSET;
f.mallocd = 0;
@@ -2001,9 +2001,9 @@ static int sms_exec(struct ast_channel *chan, const char *data)
sms_messagetx(&h);
}
- res = ast_set_write_format(chan, __OUT_FMT);
+ res = ast_set_write_format_by_id(chan, __OUT_FMT);
if (res >= 0) {
- res = ast_set_read_format(chan, AST_FORMAT_SLINEAR);
+ res = ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR);
}
if (res < 0) {
ast_log(LOG_ERROR, "Unable to set to linear mode, giving up\n");
diff --git a/apps/app_speech_utils.c b/apps/app_speech_utils.c
index 0323f7c47..fe99157e9 100644
--- a/apps/app_speech_utils.c
+++ b/apps/app_speech_utils.c
@@ -642,7 +642,7 @@ static int speech_background(struct ast_channel *chan, const char *data)
int res = 0, done = 0, started = 0, quieted = 0, max_dtmf_len = 0;
struct ast_speech *speech = find_speech(chan);
struct ast_frame *f = NULL;
- int oldreadformat = AST_FORMAT_SLINEAR;
+ struct ast_format oldreadformat;
char dtmf[AST_MAX_EXTENSION] = "";
struct timeval start = { 0, 0 }, current;
struct ast_datastore *datastore = NULL;
@@ -658,6 +658,7 @@ static int speech_background(struct ast_channel *chan, const char *data)
parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
+ ast_format_clear(&oldreadformat);
if (speech == NULL)
return -1;
@@ -673,10 +674,10 @@ static int speech_background(struct ast_channel *chan, const char *data)
}
/* Record old read format */
- oldreadformat = chan->readformat;
+ ast_format_copy(&oldreadformat, &chan->readformat);
/* Change read format to be signed linear */
- if (ast_set_read_format(chan, speech->format))
+ if (ast_set_read_format(chan, &speech->format))
return -1;
if (!ast_strlen_zero(args.soundfile)) {
@@ -881,7 +882,7 @@ static int speech_background(struct ast_channel *chan, const char *data)
ast_channel_datastore_remove(chan, datastore);
} else {
/* Channel is okay so restore read format */
- ast_set_read_format(chan, oldreadformat);
+ ast_set_read_format(chan, &oldreadformat);
}
return 0;
diff --git a/apps/app_talkdetect.c b/apps/app_talkdetect.c
index 615929e94..545261c72 100644
--- a/apps/app_talkdetect.c
+++ b/apps/app_talkdetect.c
@@ -87,7 +87,7 @@ static int background_detect_exec(struct ast_channel *chan, const char *data)
int analysistime = -1;
int continue_analysis = 1;
int x;
- int origrformat = 0;
+ struct ast_format origrformat;
struct ast_dsp *dsp = NULL;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(filename);
@@ -96,7 +96,8 @@ static int background_detect_exec(struct ast_channel *chan, const char *data)
AST_APP_ARG(max);
AST_APP_ARG(analysistime);
);
-
+
+ ast_format_clear(&origrformat);
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "BackgroundDetect requires an argument (filename)\n");
return -1;
@@ -126,8 +127,8 @@ static int background_detect_exec(struct ast_channel *chan, const char *data)
}
}
- origrformat = chan->readformat;
- if ((ast_set_read_format(chan, AST_FORMAT_SLINEAR))) {
+ ast_format_copy(&origrformat, &chan->readformat);
+ 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;
break;
@@ -182,7 +183,7 @@ static int background_detect_exec(struct ast_channel *chan, const char *data)
ast_frfree(fr);
break;
}
- } else if ((fr->frametype == AST_FRAME_VOICE) && (fr->subclass.codec == AST_FORMAT_SLINEAR) && continue_analysis) {
+ } else if ((fr->frametype == AST_FRAME_VOICE) && (fr->subclass.format.id == AST_FORMAT_SLINEAR) && continue_analysis) {
int totalsilence;
int ms;
res = ast_dsp_silence(dsp, fr, &totalsilence);
@@ -228,9 +229,9 @@ static int background_detect_exec(struct ast_channel *chan, const char *data)
} while (0);
if (res > -1) {
- if (origrformat && ast_set_read_format(chan, origrformat)) {
+ if (origrformat.id && ast_set_read_format(chan, &origrformat)) {
ast_log(LOG_WARNING, "Failed to restore read format for %s to %s\n",
- chan->name, ast_getformatname(origrformat));
+ chan->name, ast_getformatname(&origrformat));
}
}
if (dsp) {
diff --git a/apps/app_test.c b/apps/app_test.c
index a7aa7b657..7d0214a59 100644
--- a/apps/app_test.c
+++ b/apps/app_test.c
@@ -87,9 +87,10 @@ static int measurenoise(struct ast_channel *chan, int ms, char *who)
short *foo;
struct timeval start;
struct ast_frame *f;
- int rformat;
- rformat = chan->readformat;
- if (ast_set_read_format(chan, AST_FORMAT_SLINEAR)) {
+ struct ast_format rformat;
+
+ ast_format_copy(&rformat, &chan->readformat);
+ if (ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR)) {
ast_log(LOG_NOTICE, "Unable to set to linear mode!\n");
return -1;
}
@@ -106,7 +107,7 @@ static int measurenoise(struct ast_channel *chan, int ms, char *who)
res = -1;
break;
}
- if ((f->frametype == AST_FRAME_VOICE) && (f->subclass.codec == AST_FORMAT_SLINEAR)) {
+ if ((f->frametype == AST_FRAME_VOICE) && (f->subclass.format.id == AST_FORMAT_SLINEAR)) {
foo = (short *)f->data.ptr;
for (x=0;x<f->samples;x++) {
noise += abs(foo[x]);
@@ -116,8 +117,8 @@ static int measurenoise(struct ast_channel *chan, int ms, char *who)
ast_frfree(f);
}
- if (rformat) {
- if (ast_set_read_format(chan, rformat)) {
+ if (rformat.id) {
+ if (ast_set_read_format(chan, &rformat)) {
ast_log(LOG_NOTICE, "Unable to restore original format!\n");
return -1;
}
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 166df4c94..f7882c20d 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -12347,11 +12347,11 @@ AST_TEST_DEFINE(test_voicemail_vmsayname)
}
/* normally this is done in the channel driver */
- test_channel1->nativeformats = AST_FORMAT_GSM;
- test_channel1->writeformat = AST_FORMAT_GSM;
- test_channel1->rawwriteformat = AST_FORMAT_GSM;
- test_channel1->readformat = AST_FORMAT_GSM;
- test_channel1->rawreadformat = AST_FORMAT_GSM;
+ ast_format_set(&test_channel1->writeformat, AST_FORMAT_GSM, 0);
+ ast_format_cap_add(test_channel1->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);
test_channel1->tech = &fake_tech;
ast_test_status_update(test, "Test playing of extension when greeting is not available...\n");
diff --git a/apps/app_waitforsilence.c b/apps/app_waitforsilence.c
index fb76f9134..fe4b1e14d 100644
--- a/apps/app_waitforsilence.c
+++ b/apps/app_waitforsilence.c
@@ -125,7 +125,7 @@ static char *app_noise = "WaitForNoise";
static int do_waiting(struct ast_channel *chan, int timereqd, time_t waitstart, int timeout, int wait_for_silence) {
struct ast_frame *f = NULL;
int dsptime = 0;
- int rfmt = 0;
+ struct ast_format rfmt;
int res = 0;
struct ast_dsp *sildet; /* silence detector dsp */
time_t now;
@@ -134,8 +134,8 @@ static int do_waiting(struct ast_channel *chan, int timereqd, time_t waitstart,
int (*ast_dsp_func)(struct ast_dsp*, struct ast_frame*, int*) =
wait_for_silence ? ast_dsp_silence : ast_dsp_noise;
- rfmt = chan->readformat; /* Set to linear mode */
- if ((res = ast_set_read_format(chan, AST_FORMAT_SLINEAR)) < 0) {
+ ast_format_copy(&rfmt, &chan->readformat); /* 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;
}
@@ -195,8 +195,8 @@ static int do_waiting(struct ast_channel *chan, int timereqd, time_t waitstart,
}
- if (rfmt && ast_set_read_format(chan, rfmt)) {
- ast_log(LOG_WARNING, "Unable to restore format %s to channel '%s'\n", ast_getformatname(rfmt), chan->name);
+ if (rfmt.id && ast_set_read_format(chan, &rfmt)) {
+ ast_log(LOG_WARNING, "Unable to restore format %s to channel '%s'\n", ast_getformatname(&rfmt), chan->name);
}
ast_dsp_free(sildet);
return res;