summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorMatt Jordan <mjordan@digium.com>2015-08-09 17:56:48 -0500
committerMatt Jordan <mjordan@digium.com>2015-08-09 17:56:48 -0500
commita0f451c35ed56b08353c4c3150bf847867f74fe7 (patch)
treecee624042cb44855fb0d94683a19411e73084976 /main
parentc3bd7fb83583b357add3638ea1022040197ad250 (diff)
main/format: Add an API call for retrieving format attributes
Some codecs that may be a third party library to Asterisk need to have knowledge of the format attributes that were negotiated. Unfortunately, when the great format migration of Asterisk 13 occurred, that ability was lost. This patch adds an API call, ast_format_attribute_get, to the core format API, along with updates to the unit test to check the new API call. A new callback is also now available for format attribute modules, such that they can provide the format attribute values they manage. Note that the API returns a void *. This is done as the format attribute modules themselves may store format attributes in any particular manner they like. Care should be taken by consumers of the API to check the return value before casting and dereferencing. Consumers will obviously need to have a priori knowledge of the type of the format attribute as well. Change-Id: Ieec76883dfb46ecd7aff3dc81a52c81f4dc1b9e3
Diffstat (limited to 'main')
-rw-r--r--main/format.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/main/format.c b/main/format.c
index 148c77f8d..8ac82f0ed 100644
--- a/main/format.c
+++ b/main/format.c
@@ -298,6 +298,17 @@ struct ast_format *ast_format_attribute_set(const struct ast_format *format, con
return interface->format_attribute_set(format, name, value);
}
+const void *ast_format_attribute_get(const struct ast_format *format, const char *name)
+{
+ const struct ast_format_interface *interface = format->interface;
+
+ if (!interface || !interface->format_attribute_get) {
+ return NULL;
+ }
+
+ return interface->format_attribute_get(format, name);
+}
+
struct ast_format *ast_format_parse_sdp_fmtp(const struct ast_format *format, const char *attributes)
{
const struct ast_format_interface *interface = format->interface;