diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk/sdp_options.h | 2 | ||||
-rw-r--r-- | include/asterisk/sdp_priv.h | 130 | ||||
-rw-r--r-- | include/asterisk/sdp_translator.h | 102 |
3 files changed, 234 insertions, 0 deletions
diff --git a/include/asterisk/sdp_options.h b/include/asterisk/sdp_options.h index 52f6f5545..a5c2d084e 100644 --- a/include/asterisk/sdp_options.h +++ b/include/asterisk/sdp_options.h @@ -108,6 +108,8 @@ enum ast_sdp_options_repr { AST_SDP_REPR_STRING, /*! SDP is represented as a pjmedia_sdp_session */ AST_SDP_REPR_PJMEDIA, + /*! End of the list */ + AST_SDP_REPR_END, }; /*! diff --git a/include/asterisk/sdp_priv.h b/include/asterisk/sdp_priv.h new file mode 100644 index 000000000..000d11143 --- /dev/null +++ b/include/asterisk/sdp_priv.h @@ -0,0 +1,130 @@ +/* + * Asterisk -- An open source telephony toolkit. + * + * Copyright (C) 2017, Digium, Inc. + * + * Mark Michelson <mmichelson@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. + */ + +/* NOTE: It is unlikely that you need to include this file. You probably will only need + * this if you are an SDP translator, or if you are an inner part of the SDP API + */ + +#ifndef _SDP_PRIV_H +#define _SDP_PRIV_H + +#include "asterisk/vector.h" + +/*! + * \brief Structure representing an SDP attribute + */ +struct ast_sdp_a_line { + /*! Attribute name */ + char *name; + /*! Attribute value. For attributes that have no value, this will be an empty string */ + char *value; +}; + +/*! + * \brief Structure representing an SDP connection + */ +struct ast_sdp_c_line { + /* IP family string (e.g. IP4 or IP6) */ + char *family; + /* Connection address. Can be an IP address or FQDN */ + char *addr; +}; + +/*! + * \brief A collection of SDP attributes + */ +AST_VECTOR(ast_sdp_a_line_vector, struct ast_sdp_a_line); + +/*! + * \brief An SDP media stream + * + * This contains both the m line, as well as its + * constituent a lines. + */ +struct ast_sdp_m_line { + /*! Media type (e.g. "audio" or "video") */ + char *type; + /*! Port number in m line */ + uint16_t port; + /*! Number of ports specified in m line */ + uint16_t port_count; + /*! RTP profile string (e.g. "RTP/AVP") */ + char *profile; + /*! RTP payloads */ + AST_VECTOR(, char *) payloads; + /*! Connection information for this media stream */ + struct ast_sdp_c_line c_line; + /*! The attributes for this media stream */ + struct ast_sdp_a_line_vector a_lines; +}; + +/*! + * \brief SDP time information + */ +struct ast_sdp_t_line { + /*! Session start time */ + uint32_t start; + /*! Session end time */ + uint32_t end; +}; + +/*! + * \brief An SDP + */ +struct ast_sdp { + /*! SDP Origin line */ + struct { + /*! Origin user name */ + char *user; + /*! Origin id */ + uint32_t id; + /*! Origin version */ + uint32_t version; + /*! Origin IP address family (e.g. "IP4" or "IP6") */ + char *family; + /*! Origin address. Can be an IP address or FQDN */ + char *addr; + } o_line; + /*! SDP Session name */ + char *s_line; + /*! SDP top-level connection information */ + struct ast_sdp_c_line c_line; + /*! SDP timing information */ + struct ast_sdp_t_line t_line; + /*! SDP top-level attributes */ + struct ast_sdp_a_line_vector a_lines; + /*! SDP media streams */ + AST_VECTOR(, struct ast_sdp_m_line) m_lines; +}; + +/*! + * \brief Allocate a new SDP. + * + * \note This does not perform any initialization. + * + * \retval NULL FAIL + * \retval non-NULL New SDP + */ +struct ast_sdp *ast_sdp_alloc(void); + +/*! + * \brief Free an SDP and all its constituent parts + */ +void ast_sdp_free(struct ast_sdp *dead); + +#endif /* _SDP_PRIV_H */ diff --git a/include/asterisk/sdp_translator.h b/include/asterisk/sdp_translator.h new file mode 100644 index 000000000..62a875e0a --- /dev/null +++ b/include/asterisk/sdp_translator.h @@ -0,0 +1,102 @@ +/* + * Asterisk -- An open source telephony toolkit. + * + * Copyright (C) 2017, Digium, Inc. + * + * Mark Michelson <mmichelson@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. + */ + +#ifndef _ASTERISK_SDP_TRANSLATOR_H +#define _ASTERISK_SDP_TRANSLATOR_H + +#include "asterisk/sdp_options.h" + +struct sdp; + +/*! + * \brief SDP translator operations + */ +struct ast_sdp_translator_ops { + /*! The SDP representation on which this translator operates */ + enum ast_sdp_options_repr repr; + /*! Allocate new translator private data for a translator */ + void *(*translator_new)(void); + /*! Free translator private data */ + void (*translator_free)(void *translator_priv); + /*! Convert the channel-native SDP into an internal Asterisk SDP */ + struct ast_sdp *(*to_sdp)(void *repr_sdp, void *translator_priv); + /*! Convert an internal Asterisk SDP into a channel-native SDP */ + void *(*from_sdp)(struct ast_sdp *sdp, void *translator_priv); +}; + +/*! + * \brief An SDP translator + * + * An SDP translator is responsible for converting between Asterisk's internal + * representation of an SDP and the representation that is native to the channel + * driver. Translators are allocated per-use. + */ +struct ast_sdp_translator { + /*! The operations this translator uses */ + struct ast_sdp_translator_ops *ops; + /*! Private data this translator uses */ + void *translator_priv; +}; + +/*! + * \brief Register an SDP translator + * \param ops The SDP operations defined by this translator + * \retval 0 Success + * \retval -1 FAIL + */ +int ast_sdp_register_translator(struct ast_sdp_translator_ops *ops); + +/*! + * \brief Unregister an SDP translator + */ +void ast_sdp_unregister_translator(struct ast_sdp_translator_ops *ops); + +/*! + * \brief Allocate a new SDP translator + * \param Representation corresponding to the translator_ops to use + * \retval NULL FAIL + * \retval non-NULL New SDP translator + */ +struct ast_sdp_translator *ast_sdp_translator_new(enum ast_sdp_options_repr repr); + +/*! + * \brief Free an SDP translator + */ +void ast_sdp_translator_free(struct ast_sdp_translator *translator); + +/*! + * \brief Translate a native SDP to internal Asterisk SDP + * + * \param translator The translator to use when translating + * \param native_sdp The SDP from the channel driver + * \retval NULL FAIL + * \retval Non-NULL The translated SDP + */ +struct ast_sdp *ast_sdp_translator_to_sdp(struct ast_sdp_translator *translator, void *native_sdp); + +/*! + * \brief Translate an internal Asterisk SDP to a native SDP + * + * \param translator The translator to use when translating + * \param ast_sdp The Asterisk SDP to translate + * \retval NULL FAIL + * \retval non-NULL The translated SDP + */ +void *ast_sdp_translator_from_sdp(struct ast_sdp_translator *translator, struct ast_sdp *ast_sdp); + +#endif /* _ASTERISK_SDP_TRANSLATOR_H */ |