46 unsigned int maxbitrate;
49 unsigned int packetloss_percentage;
52 static void silk_destroy(
struct ast_format *format)
59 static void attr_init(
struct silk_attr *attr)
61 memset(attr, 0,
sizeof(*attr));
84 static struct ast_format *silk_parse_sdp_fmtp(
const struct ast_format *format,
const char *attributes)
98 for (attrib = attribs; *attrib; ++attrib) {
99 *attrib = tolower(*attrib);
102 if (sscanf(attribs,
"maxaveragebitrate=%30u", &val) == 1) {
103 attr->maxbitrate = val;
105 if (sscanf(attribs,
"usedtx=%30u", &val) == 1) {
108 if (sscanf(attribs,
"useinbandfec=%30u", &val) == 1) {
115 static void silk_generate_sdp_fmtp(
const struct ast_format *format,
unsigned int payload,
struct ast_str **str)
123 if ((attr->maxbitrate > 5000) && (attr->maxbitrate < 40000)) {
124 ast_str_append(str, 0,
"a=fmtp:%u maxaveragebitrate=%u\r\n", payload, attr->maxbitrate);
128 ast_str_append(str, 0,
"a=fmtp:%u usedtx=%u\r\n", payload, attr->dtx);
131 ast_str_append(str, 0,
"a=fmtp:%u useinbandfec=%u\r\n", payload, attr->fec);
161 if (!attr1 || !attr2) {
165 attr_res->maxbitrate = MIN(attr1->maxbitrate, attr2->maxbitrate);
169 attr_res->dtx = attr1->dtx && attr2->dtx ? 1 : 0;
173 attr_res->fec = attr1->fec && attr2->fec ? 1 : 0;
177 attr_res->packetloss_percentage = MAX(attr1->packetloss_percentage, attr2->packetloss_percentage);
189 if (sscanf(value,
"%30u", &val) != 1) {
190 ast_log(LOG_WARNING,
"Unknown value '%s' for attribute type '%s'\n",
201 if (!strcasecmp(name,
"max_bitrate")) {
202 attr->maxbitrate = val;
203 }
else if (!strcasecmp(name,
"dtx")) {
205 }
else if (!strcasecmp(name,
"fec")) {
207 }
else if (!strcasecmp(name,
"packetloss_percentage")) {
208 attr->packetloss_percentage = val;
210 ast_log(LOG_WARNING,
"unknown attribute type %s\n", name);
216 static const void *silk_get(
const struct ast_format *format,
const char *name)
221 if (!strcasecmp(name,
"max_bitrate")) {
222 val = &attr->maxbitrate;
223 }
else if (!strcasecmp(name,
"dtx")) {
225 }
else if (!strcasecmp(name,
"fec")) {
227 }
else if (!strcasecmp(name,
"packetloss_percentage")) {
228 val = &attr->packetloss_percentage;
230 ast_log(LOG_WARNING,
"unknown attribute type %s\n", name);
239 .format_clone = silk_clone,
240 .format_cmp = silk_cmp,
241 .format_get_joint = silk_getjoint,
242 .format_attribute_set = silk_set,
243 .format_attribute_get = silk_get,
244 .format_parse_sdp_fmtp = silk_parse_sdp_fmtp,
245 .format_generate_sdp_fmtp = silk_generate_sdp_fmtp,
248 static int load_module(
void)
257 static int unload_module(
void)
262 AST_MODULE_INFO(
ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER,
"SILK Format Attribute Module",
263 .support_level = AST_MODULE_SUPPORT_CORE,
265 .unload = unload_module,
Asterisk main include file. File version handling, generic pbx functions.
String manipulation functions.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
SILK attribute structure.
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ast_malloc(len)
A wrapper for malloc()
Support for dynamic strings.
Support for logging to various files, console and syslog Configuration in file logger.conf.
Module has failed to load, may be in an inconsistent state.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.