mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 03:20:57 +00:00
Git does not support the ability to replace a token with a version string during check-in. While it does have support for replacing a token on clone, this is somewhat sub-optimal: the token is replaced with the object hash, which is not particularly easy for human consumption. What's more, in practice, the source file version was often not terribly useful. Generally, when triaging bugs, the overall version of Asterisk is far more useful than an individual SVN version of a file. As a result, this patch removes Asterisk's support for showing source file versions. Specifically, it does the following: * Rename ASTERISK_FILE_VERSION macro to ASTERISK_REGISTER_FILE, and remove passing the version in with the macro. Other facilities than 'core show file version' make use of the file names, such as setting a debug level only on a specific file. As such, the act of registering source files with the Asterisk core still has use. The macro rename now reflects the new macro purpose. * main/asterisk: - Refactor the file_version structure to reflect that it no longer tracks a version field. - Remove the "core show file version" CLI command. Without the file version, it is no longer useful. - Remove the ast_file_version_find function. The file version is no longer tracked. - Rename ast_register_file_version/ast_unregister_file_version to ast_register_file/ast_unregister_file, respectively. * main/manager: Remove value from the Version key of the ModuleCheck Action. The actual key itself has not been removed, as doing so would absolutely constitute a backwards incompatible change. However, since the file version is no longer tracked, there is no need to attempt to include it in the Version key. * UPGRADE: Add notes for: - Modification to the ModuleCheck AMI Action - Removal of the "core show file version" CLI command Change-Id: I6cf0ff280e1668bf4957dc21f32a5ff43444a40e
192 lines
4.2 KiB
C
192 lines
4.2 KiB
C
/*
|
|
* Asterisk -- An open source telephony toolkit.
|
|
*
|
|
* Copyright (C) 2011, Digium, Inc.
|
|
*
|
|
* Russell Bryant <russell@digium.com>
|
|
* David Vossel <dvossel@digium.com>
|
|
*
|
|
* See http://www.asterisk.org for more information about
|
|
* the Asterisk project. Please do not directly contact
|
|
* any of the maintainers of this project for assistance;
|
|
* the project provides a web site, mailing lists and IRC
|
|
* channels for your use.
|
|
*
|
|
* This program is free software, distributed under the terms of
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
* at the top of the source tree.
|
|
*/
|
|
|
|
/*!
|
|
* \file
|
|
*
|
|
* \brief Resample slinear audio
|
|
*
|
|
* \ingroup codecs
|
|
*/
|
|
|
|
/*** MODULEINFO
|
|
<support_level>core</support_level>
|
|
***/
|
|
|
|
#include "asterisk.h"
|
|
#include "speex/speex_resampler.h"
|
|
|
|
ASTERISK_REGISTER_FILE()
|
|
|
|
#include "asterisk/module.h"
|
|
#include "asterisk/translate.h"
|
|
#include "asterisk/slin.h"
|
|
|
|
#define OUTBUF_SIZE 8096
|
|
|
|
static struct ast_translator *translators;
|
|
static int trans_size;
|
|
static struct ast_codec codec_list[] = {
|
|
{
|
|
.name = "slin",
|
|
.type = AST_MEDIA_TYPE_AUDIO,
|
|
.sample_rate = 8000,
|
|
},
|
|
{
|
|
.name = "slin",
|
|
.type = AST_MEDIA_TYPE_AUDIO,
|
|
.sample_rate = 12000,
|
|
},
|
|
{
|
|
.name = "slin",
|
|
.type = AST_MEDIA_TYPE_AUDIO,
|
|
.sample_rate = 16000,
|
|
},
|
|
{
|
|
.name = "slin",
|
|
.type = AST_MEDIA_TYPE_AUDIO,
|
|
.sample_rate = 24000,
|
|
},
|
|
{
|
|
.name = "slin",
|
|
.type = AST_MEDIA_TYPE_AUDIO,
|
|
.sample_rate = 32000,
|
|
},
|
|
{
|
|
.name = "slin",
|
|
.type = AST_MEDIA_TYPE_AUDIO,
|
|
.sample_rate = 44100,
|
|
},
|
|
{
|
|
.name = "slin",
|
|
.type = AST_MEDIA_TYPE_AUDIO,
|
|
.sample_rate = 48000,
|
|
},
|
|
{
|
|
.name = "slin",
|
|
.type = AST_MEDIA_TYPE_AUDIO,
|
|
.sample_rate = 96000,
|
|
},
|
|
{
|
|
.name = "slin",
|
|
.type = AST_MEDIA_TYPE_AUDIO,
|
|
.sample_rate = 192000,
|
|
},
|
|
};
|
|
|
|
static int resamp_new(struct ast_trans_pvt *pvt)
|
|
{
|
|
int err;
|
|
|
|
if (!(pvt->pvt = speex_resampler_init(1, pvt->t->src_codec.sample_rate, pvt->t->dst_codec.sample_rate, 5, &err))) {
|
|
return -1;
|
|
}
|
|
|
|
ast_assert(pvt->f.subclass.format == NULL);
|
|
pvt->f.subclass.format = ao2_bump(ast_format_cache_get_slin_by_rate(pvt->t->dst_codec.sample_rate));
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void resamp_destroy(struct ast_trans_pvt *pvt)
|
|
{
|
|
SpeexResamplerState *resamp_pvt = pvt->pvt;
|
|
|
|
speex_resampler_destroy(resamp_pvt);
|
|
}
|
|
|
|
static int resamp_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
|
|
{
|
|
SpeexResamplerState *resamp_pvt = pvt->pvt;
|
|
unsigned int out_samples = (OUTBUF_SIZE / sizeof(int16_t)) - pvt->samples;
|
|
unsigned int in_samples;
|
|
|
|
if (!f->datalen) {
|
|
return -1;
|
|
}
|
|
in_samples = f->datalen / 2;
|
|
|
|
speex_resampler_process_int(resamp_pvt,
|
|
0,
|
|
f->data.ptr,
|
|
&in_samples,
|
|
pvt->outbuf.i16 + pvt->samples,
|
|
&out_samples);
|
|
|
|
pvt->samples += out_samples;
|
|
pvt->datalen += out_samples * 2;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int unload_module(void)
|
|
{
|
|
int res = 0;
|
|
int idx;
|
|
|
|
for (idx = 0; idx < trans_size; idx++) {
|
|
res |= ast_unregister_translator(&translators[idx]);
|
|
}
|
|
ast_free(translators);
|
|
|
|
return res;
|
|
}
|
|
|
|
static int load_module(void)
|
|
{
|
|
int res = 0;
|
|
int x, y, idx = 0;
|
|
|
|
trans_size = ARRAY_LEN(codec_list) * (ARRAY_LEN(codec_list) - 1);
|
|
if (!(translators = ast_calloc(1, sizeof(struct ast_translator) * trans_size))) {
|
|
return AST_MODULE_LOAD_FAILURE;
|
|
}
|
|
|
|
for (x = 0; x < ARRAY_LEN(codec_list); x++) {
|
|
for (y = 0; y < ARRAY_LEN(codec_list); y++) {
|
|
if (x == y) {
|
|
continue;
|
|
}
|
|
translators[idx].newpvt = resamp_new;
|
|
translators[idx].destroy = resamp_destroy;
|
|
translators[idx].framein = resamp_framein;
|
|
translators[idx].desc_size = 0;
|
|
translators[idx].buffer_samples = (OUTBUF_SIZE / sizeof(int16_t));
|
|
translators[idx].buf_size = OUTBUF_SIZE;
|
|
memcpy(&translators[idx].src_codec, &codec_list[x], sizeof(struct ast_codec));
|
|
memcpy(&translators[idx].dst_codec, &codec_list[y], sizeof(struct ast_codec));
|
|
snprintf(translators[idx].name, sizeof(translators[idx].name), "slin %ukhz -> %ukhz",
|
|
translators[idx].src_codec.sample_rate, translators[idx].dst_codec.sample_rate);
|
|
res |= ast_register_translator(&translators[idx]);
|
|
idx++;
|
|
}
|
|
|
|
}
|
|
/* in case ast_register_translator() failed, we call unload_module() and
|
|
ast_unregister_translator won't fail.*/
|
|
if (res) {
|
|
unload_module();
|
|
return AST_MODULE_LOAD_FAILURE;
|
|
}
|
|
|
|
return AST_MODULE_LOAD_SUCCESS;
|
|
}
|
|
|
|
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "SLIN Resampling Codec");
|