diff options
author | Matt Jordan <mjordan@digium.com> | 2015-08-09 18:42:00 -0500 |
---|---|---|
committer | Matt Jordan <mjordan@digium.com> | 2015-08-11 18:24:29 -0500 |
commit | a87e2dd2549f1da3a81913f3209113dcfc61b20c (patch) | |
tree | 540fd10e43b517ed811323bdf0ac4d535aa131c9 | |
parent | e188192ad10a8570785986a46666b91d7a448b75 (diff) |
res/res_format_attr_silk: Expose format attributes to other modules
This patch adds the .get callback to the format attribute module, such
that the Asterisk core or other third party modules can query for the
negotiated format attributes.
Change-Id: Ia24f55cf9b661d651ce89b4f4b023d921380f19c
-rw-r--r-- | res/res_format_attr_silk.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/res/res_format_attr_silk.c b/res/res_format_attr_silk.c index 3467f5ae4..f3f43821c 100644 --- a/res/res_format_attr_silk.c +++ b/res/res_format_attr_silk.c @@ -200,12 +200,36 @@ static struct ast_format *silk_set(const struct ast_format *format, const char * return cloned; } +static const void *silk_get(const struct ast_format *format, const char *name) +{ + struct silk_attr *attr = ast_format_get_attribute_data(format); + unsigned int *val; + + if (!strcasecmp(name, "sample_rate")) { + val = &attr->samplerate; + } else if (!strcasecmp(name, "max_bitrate")) { + val = &attr->maxbitrate; + } else if (!strcasecmp(name, "dtx")) { + val = &attr->dtx; + } else if (!strcasecmp(name, "fec")) { + val = &attr->fec; + } else if (!strcasecmp(name, "packetloss_percentage")) { + val = &attr->packetloss_percentage; + } else { + ast_log(LOG_WARNING, "unknown attribute type %s\n", name); + return NULL; + } + + return val; +} + static struct ast_format_interface silk_interface = { .format_destroy = silk_destroy, .format_clone = silk_clone, .format_cmp = silk_cmp, .format_get_joint = silk_getjoint, .format_attribute_set = silk_set, + .format_attribute_get = silk_get, .format_parse_sdp_fmtp = silk_parse_sdp_fmtp, .format_generate_sdp_fmtp = silk_generate_sdp_fmtp, }; |