summaryrefslogtreecommitdiff
path: root/funcs
diff options
context:
space:
mode:
Diffstat (limited to 'funcs')
-rw-r--r--funcs/func_channel.c24
-rw-r--r--funcs/func_frame_trace.c4
-rw-r--r--funcs/func_pitchshift.c6
-rw-r--r--funcs/func_speex.c4
-rw-r--r--funcs/func_talkdetect.c2
5 files changed, 21 insertions, 19 deletions
diff --git a/funcs/func_channel.c b/funcs/func_channel.c
index 82fb4c348..3f756f0b5 100644
--- a/funcs/func_channel.c
+++ b/funcs/func_channel.c
@@ -427,23 +427,27 @@ static int func_channel_read(struct ast_channel *chan, const char *function,
}
if (!strcasecmp(data, "audionativeformat")) {
- char tmp[512];
+ tmpcap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
+ if (tmpcap) {
+ struct ast_str *codec_buf = ast_str_alloca(64);
- if ((tmpcap = ast_format_cap_get_type(ast_channel_nativeformats(chan), AST_FORMAT_TYPE_AUDIO))) {
- ast_copy_string(buf, ast_getformatname_multiple(tmp, sizeof(tmp), tmpcap), len);
- tmpcap = ast_format_cap_destroy(tmpcap);
+ ast_format_cap_append_from_cap(tmpcap, ast_channel_nativeformats(chan), AST_MEDIA_TYPE_AUDIO);
+ ast_copy_string(buf, ast_format_cap_get_names(tmpcap, &codec_buf), len);
+ ao2_ref(tmpcap, -1);
}
} else if (!strcasecmp(data, "videonativeformat")) {
- char tmp[512];
+ tmpcap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
+ if (tmpcap) {
+ struct ast_str *codec_buf = ast_str_alloca(64);
- if ((tmpcap = ast_format_cap_get_type(ast_channel_nativeformats(chan), AST_FORMAT_TYPE_VIDEO))) {
- ast_copy_string(buf, ast_getformatname_multiple(tmp, sizeof(tmp), tmpcap), len);
- tmpcap = ast_format_cap_destroy(tmpcap);
+ ast_format_cap_append_from_cap(tmpcap, ast_channel_nativeformats(chan), AST_MEDIA_TYPE_VIDEO);
+ ast_copy_string(buf, ast_format_cap_get_names(tmpcap, &codec_buf), len);
+ ao2_ref(tmpcap, -1);
}
} else if (!strcasecmp(data, "audioreadformat")) {
- ast_copy_string(buf, ast_getformatname(ast_channel_readformat(chan)), len);
+ ast_copy_string(buf, ast_format_get_name(ast_channel_readformat(chan)), len);
} else if (!strcasecmp(data, "audiowriteformat")) {
- ast_copy_string(buf, ast_getformatname(ast_channel_writeformat(chan)), len);
+ ast_copy_string(buf, ast_format_get_name(ast_channel_writeformat(chan)), len);
#ifdef CHANNEL_TRACE
} else if (!strcasecmp(data, "trace")) {
ast_channel_lock(chan);
diff --git a/funcs/func_frame_trace.c b/funcs/func_frame_trace.c
index ecebde4df..681a96924 100644
--- a/funcs/func_frame_trace.c
+++ b/funcs/func_frame_trace.c
@@ -219,14 +219,14 @@ static void print_frame(struct ast_frame *frame)
break;
case AST_FRAME_VOICE:
ast_verbose("FrameType: VOICE\n");
- ast_verbose("Codec: %s\n", ast_getformatname(&frame->subclass.format));
+ ast_verbose("Codec: %s\n", ast_format_get_name(frame->subclass.format));
ast_verbose("MS: %ld\n", frame->len);
ast_verbose("Samples: %d\n", frame->samples);
ast_verbose("Bytes: %d\n", frame->datalen);
break;
case AST_FRAME_VIDEO:
ast_verbose("FrameType: VIDEO\n");
- ast_verbose("Codec: %s\n", ast_getformatname(&frame->subclass.format));
+ ast_verbose("Codec: %s\n", ast_format_get_name(frame->subclass.format));
ast_verbose("MS: %ld\n", frame->len);
ast_verbose("Samples: %d\n", frame->samples);
ast_verbose("Bytes: %d\n", frame->datalen);
diff --git a/funcs/func_pitchshift.c b/funcs/func_pitchshift.c
index e5091d95d..0aaa2b602 100644
--- a/funcs/func_pitchshift.c
+++ b/funcs/func_pitchshift.c
@@ -172,9 +172,7 @@ static int pitchshift_cb(struct ast_audiohook *audiohook, struct ast_channel *ch
if (!f) {
return 0;
}
- if ((audiohook->status == AST_AUDIOHOOK_STATUS_DONE) ||
- (f->frametype != AST_FRAME_VOICE) ||
- !(ast_format_is_slinear(&f->subclass.format))) {
+ if (audiohook->status == AST_AUDIOHOOK_STATUS_DONE) {
return -1;
}
@@ -489,7 +487,7 @@ static int pitch_shift(struct ast_frame *f, float amount, struct fft_data *fft)
return 0;
}
for (samples = 0; samples < f->samples; samples += 32) {
- smb_pitch_shift(amount, 32, MAX_FRAME_LENGTH, 32, ast_format_rate(&f->subclass.format), fun+samples, fun+samples, fft);
+ smb_pitch_shift(amount, 32, MAX_FRAME_LENGTH, 32, ast_format_get_sample_rate(f->subclass.format), fun+samples, fun+samples, fft);
}
return 0;
diff --git a/funcs/func_speex.c b/funcs/func_speex.c
index 4e3c13b87..d0d451bd1 100644
--- a/funcs/func_speex.c
+++ b/funcs/func_speex.c
@@ -165,8 +165,8 @@ static int speex_callback(struct ast_audiohook *audiohook, struct ast_channel *c
return -1;
}
- if ((sdi->samples != frame->samples) || (ast_format_rate(&frame->subclass.format) != si->lastrate)) {
- si->lastrate = ast_format_rate(&frame->subclass.format);
+ if ((sdi->samples != frame->samples) || (ast_format_get_sample_rate(frame->subclass.format) != si->lastrate)) {
+ si->lastrate = ast_format_get_sample_rate(frame->subclass.format);
if (sdi->state) {
speex_preprocess_state_destroy(sdi->state);
}
diff --git a/funcs/func_talkdetect.c b/funcs/func_talkdetect.c
index c4783f51f..f127fa3d7 100644
--- a/funcs/func_talkdetect.c
+++ b/funcs/func_talkdetect.c
@@ -284,7 +284,7 @@ static int set_talk_detect(struct ast_channel *chan, int dsp_silence_threshold,
td_params->audiohook.manipulate_callback = talk_detect_audiohook_cb;
ast_set_flag(&td_params->audiohook, AST_AUDIOHOOK_TRIGGER_READ);
- td_params->dsp = ast_dsp_new_with_rate(ast_format_rate(ast_channel_rawreadformat(chan)));
+ td_params->dsp = ast_dsp_new_with_rate(ast_format_get_sample_rate(ast_channel_rawreadformat(chan)));
if (!td_params->dsp) {
ast_datastore_free(datastore);
ast_free(td_params);