4a58261694
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
207 lines
5 KiB
C
207 lines
5 KiB
C
/*
|
|
* Asterisk -- An open source telephony toolkit.
|
|
*
|
|
* Copyright (C) 2011, Digium, Inc.
|
|
*
|
|
* 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 CELT format attribute interface
|
|
*
|
|
* \author David Vossel <dvossel@digium.com>
|
|
*/
|
|
|
|
/*** MODULEINFO
|
|
<support_level>core</support_level>
|
|
***/
|
|
|
|
#include "asterisk.h"
|
|
|
|
ASTERISK_REGISTER_FILE()
|
|
|
|
#include "asterisk/module.h"
|
|
#include "asterisk/format.h"
|
|
|
|
/*!
|
|
* \brief CELT attribute structure.
|
|
*
|
|
* \note The only attribute that affects compatibility here is the sample rate.
|
|
*/
|
|
struct celt_attr {
|
|
unsigned int samplerate;
|
|
unsigned int maxbitrate;
|
|
unsigned int framesize;
|
|
};
|
|
|
|
static void celt_destroy(struct ast_format *format)
|
|
{
|
|
struct celt_attr *attr = ast_format_get_attribute_data(format);
|
|
|
|
ast_free(attr);
|
|
}
|
|
|
|
static int celt_clone(const struct ast_format *src, struct ast_format *dst)
|
|
{
|
|
struct celt_attr *original = ast_format_get_attribute_data(src);
|
|
struct celt_attr *attr = ast_calloc(1, sizeof(*attr));
|
|
|
|
if (!attr) {
|
|
return -1;
|
|
}
|
|
|
|
if (original) {
|
|
*attr = *original;
|
|
}
|
|
|
|
ast_format_set_attribute_data(dst, attr);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static struct ast_format *celt_parse_sdp_fmtp(const struct ast_format *format, const char *attributes)
|
|
{
|
|
struct ast_format *cloned;
|
|
struct celt_attr *attr;
|
|
unsigned int val;
|
|
|
|
cloned = ast_format_clone(format);
|
|
if (!cloned) {
|
|
return NULL;
|
|
}
|
|
attr = ast_format_get_attribute_data(cloned);
|
|
|
|
if (sscanf(attributes, "framesize=%30u", &val) == 1) {
|
|
attr->framesize = val;
|
|
}
|
|
|
|
return cloned;
|
|
}
|
|
|
|
static void celt_generate_sdp_fmtp(const struct ast_format *format, unsigned int payload, struct ast_str **str)
|
|
{
|
|
struct celt_attr *attr = ast_format_get_attribute_data(format);
|
|
|
|
if (!attr || !attr->framesize) {
|
|
return;
|
|
}
|
|
|
|
ast_str_append(str, 0, "a=fmtp:%u framesize=%u\r\n", payload, attr->framesize);
|
|
}
|
|
|
|
static enum ast_format_cmp_res celt_cmp(const struct ast_format *format1, const struct ast_format *format2)
|
|
{
|
|
struct celt_attr *attr1 = ast_format_get_attribute_data(format1);
|
|
struct celt_attr *attr2 = ast_format_get_attribute_data(format2);
|
|
|
|
if (((!attr1 || !attr1->samplerate) && (!attr2 || !attr2->samplerate)) ||
|
|
(attr1->samplerate == attr2->samplerate)) {
|
|
return AST_FORMAT_CMP_EQUAL;
|
|
}
|
|
|
|
return AST_FORMAT_CMP_NOT_EQUAL;
|
|
}
|
|
|
|
static struct ast_format *celt_getjoint(const struct ast_format *format1, const struct ast_format *format2)
|
|
{
|
|
struct celt_attr *attr1 = ast_format_get_attribute_data(format1);
|
|
struct celt_attr *attr2 = ast_format_get_attribute_data(format2);
|
|
struct ast_format *jointformat;
|
|
struct celt_attr *jointattr;
|
|
|
|
if (attr1 && attr2 && (attr1->samplerate != attr2->samplerate)) {
|
|
return NULL;
|
|
}
|
|
|
|
jointformat = ast_format_clone(format1);
|
|
if (!jointformat) {
|
|
return NULL;
|
|
}
|
|
jointattr = ast_format_get_attribute_data(jointformat);
|
|
|
|
/* either would work, they are guaranteed the same at this point. */
|
|
jointattr->samplerate = attr1->samplerate;
|
|
/* Take the lowest max bitrate */
|
|
jointattr->maxbitrate = MIN(attr1->maxbitrate, attr2->maxbitrate);
|
|
|
|
jointattr->framesize = attr2->framesize; /* TODO figure out what joint framesize means */
|
|
|
|
return jointformat;
|
|
}
|
|
|
|
static struct ast_format *celt_set(const struct ast_format *format, const char *name, const char *value)
|
|
{
|
|
struct ast_format *cloned;
|
|
struct celt_attr *attr;
|
|
unsigned int val;
|
|
|
|
cloned = ast_format_clone(format);
|
|
if (!cloned) {
|
|
return NULL;
|
|
}
|
|
attr = ast_format_get_attribute_data(cloned);
|
|
|
|
if (sscanf(value, "%30u", &val) != 1) {
|
|
ast_log(LOG_WARNING, "Unknown value '%s' for attribute type '%s'\n",
|
|
value, name);
|
|
ao2_ref(cloned, -1);
|
|
return NULL;
|
|
}
|
|
|
|
if (!strcasecmp(name, "sample_rate")) {
|
|
attr->samplerate = val;
|
|
} else if (!strcasecmp(name, "max_bitrate")) {
|
|
attr->maxbitrate = val;
|
|
} else if (!strcasecmp(name, "frame_size")) {
|
|
attr->framesize = val;
|
|
} else {
|
|
ast_log(LOG_WARNING, "Unknown attribute type '%s'\n", name);
|
|
ao2_ref(cloned, -1);
|
|
return NULL;
|
|
}
|
|
|
|
return cloned;
|
|
}
|
|
|
|
static struct ast_format_interface celt_interface = {
|
|
.format_destroy = celt_destroy,
|
|
.format_clone = celt_clone,
|
|
.format_cmp = celt_cmp,
|
|
.format_get_joint = celt_getjoint,
|
|
.format_attribute_set = celt_set,
|
|
.format_parse_sdp_fmtp = celt_parse_sdp_fmtp,
|
|
.format_generate_sdp_fmtp = celt_generate_sdp_fmtp,
|
|
};
|
|
|
|
static int load_module(void)
|
|
{
|
|
if (ast_format_interface_register("celt", &celt_interface)) {
|
|
return AST_MODULE_LOAD_DECLINE;
|
|
}
|
|
|
|
return AST_MODULE_LOAD_SUCCESS;
|
|
}
|
|
|
|
static int unload_module(void)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "CELT Format Attribute Module",
|
|
.support_level = AST_MODULE_SUPPORT_CORE,
|
|
.load = load_module,
|
|
.unload = unload_module,
|
|
.load_pri = AST_MODPRI_CHANNEL_DEPEND,
|
|
);
|