From a0f451c35ed56b08353c4c3150bf847867f74fe7 Mon Sep 17 00:00:00 2001 From: Matt Jordan Date: Sun, 9 Aug 2015 17:56:48 -0500 Subject: 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 --- include/asterisk/format.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'include') diff --git a/include/asterisk/format.h b/include/asterisk/format.h index 3da2d8236..2ce1b97e5 100644 --- a/include/asterisk/format.h +++ b/include/asterisk/format.h @@ -120,6 +120,18 @@ struct ast_format_interface { */ void (* const format_generate_sdp_fmtp)(const struct ast_format *format, unsigned int payload, struct ast_str **str); + + /*! + * \since 13.6.0 + * \brief Retrieve a particular format attribute setting + * + * \param format The format containing attributes + * \param name The name of the attribute to retrieve + * + * \retval NULL if the parameter is not set on the format + * \retval non-NULL the format attribute value + */ + const void *(* const format_attribute_get)(const struct ast_format *format, const char *name); }; /*! @@ -203,6 +215,17 @@ struct ast_format *ast_format_joint(const struct ast_format *format1, const stru struct ast_format *ast_format_attribute_set(const struct ast_format *format, const char *name, const char *value); +/*! + * \since 13.6.0 + * + * \param format The format to retrieve the attribute from + * \param name Attribute name + * + * \retval non-NULL the attribute value + * \retval NULL the attribute does not exist or is unset + */ +const void *ast_format_attribute_get(const struct ast_format *format, const char *name); + /*! * \brief This function is used to have a media format aware module parse and interpret * SDP attribute information. Once interpreted this information is stored on the format -- cgit v1.2.3