summaryrefslogtreecommitdiff
path: root/include/asterisk
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2017-02-21 13:37:03 -0600
committerGerrit Code Review <gerrit2@gerrit.digium.api>2017-02-21 13:37:03 -0600
commit16b0bb39c13e75b4d01c00aebb1d61b83f919a76 (patch)
treee34a24bf374238abd47a338a9637daec4277b5b3 /include/asterisk
parentcf7abc9dde7ad09bd4921617d46888e3b8379b44 (diff)
parent5a130b2e1730467cd209d3b3c929ff5f24a2aa02 (diff)
Merge changes from topic 'sdp_state_beginnings'
* changes: Add SDP translator and PJMEDIA implementation. Add initial SDP options.
Diffstat (limited to 'include/asterisk')
-rw-r--r--include/asterisk/sdp_options.h157
-rw-r--r--include/asterisk/sdp_priv.h130
-rw-r--r--include/asterisk/sdp_translator.h102
3 files changed, 389 insertions, 0 deletions
diff --git a/include/asterisk/sdp_options.h b/include/asterisk/sdp_options.h
new file mode 100644
index 000000000..a5c2d084e
--- /dev/null
+++ b/include/asterisk/sdp_options.h
@@ -0,0 +1,157 @@
+/*
+ * 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_OPTIONS_H
+#define _ASTERISK_SDP_OPTIONS_H
+
+struct ast_sdp_options;
+
+/*!
+ * \since 15.0.0
+ * \brief Allocate a new SDP options structure.
+ *
+ * This will heap-allocate an SDP options structure and
+ * initialize it to a set of default values.
+ *
+ * \retval NULL Allocation failure
+ * \retval non-NULL Newly allocated SDP options
+ */
+struct ast_sdp_options *ast_sdp_options_alloc(void);
+
+/*!
+ * \since 15.0.0
+ * \brief Free an SDP options structure.
+ *
+ * \note This only needs to be called if an error occurs between
+ * options allocation and a call to ast_sdp_state_alloc()
+ * Otherwise, the SDP state will take care of freeing the
+ * options for you.
+ *
+ * \param options The options to free
+ */
+void ast_sdp_options_free(struct ast_sdp_options *options);
+
+/*!
+ * \brief ICE options
+ *
+ * This is an enum because it is predicted that this eventually
+ * support a TRICKLE-ICE option.
+ */
+enum ast_sdp_options_ice {
+ /*! ICE is not enabled on this session */
+ AST_SDP_ICE_DISABLED,
+ /*! Standard ICE is enabled on this session */
+ AST_SDP_ICE_ENABLED_STANDARD,
+};
+
+/*!
+ * \since 15.0.0
+ * \brief Set ICE options
+ *
+ * The default is AST_SDP_ICE_DISABLED
+ */
+int ast_sdp_options_set_ice(struct ast_sdp_options *options,
+ enum ast_sdp_options_ice ice_setting);
+
+/*!
+ * \since 15.0.0
+ * \brief Retrieve ICE options
+ */
+enum ast_sdp_options_ice ast_sdp_options_get_ice(const struct ast_sdp_options *options);
+
+/*!
+ * \since 15.0.0
+ * \brief Enable or disable telephone events.
+ *
+ * A non-zero value indicates telephone events are enabled.
+ * A zero value indicates telephone events are disabled.
+ *
+ * The default is 0
+ */
+int ast_sdp_options_set_telephone_event(struct ast_sdp_options *options,
+ int telephone_event_enabled);
+
+/*!
+ * \since 15.0.0
+ * \brief Retrieve telephone event setting.
+ *
+ * \retval 0 Telephone events are currently disabled.
+ * \retval non-zero Telephone events are currently enabled.
+ */
+int ast_sdp_options_get_telephone_event(const struct ast_sdp_options *options);
+
+/*!
+ * \brief Representation of the SDP
+ *
+ * Users of the SDP API set the representation based on what they
+ * natively handle. This indicates the type of SDP that the API expects
+ * when being given an SDP, and it indicates the type of SDP that the API
+ * returns when asked for one.
+ */
+enum ast_sdp_options_repr {
+ /*! SDP is represented as a string */
+ AST_SDP_REPR_STRING,
+ /*! SDP is represented as a pjmedia_sdp_session */
+ AST_SDP_REPR_PJMEDIA,
+ /*! End of the list */
+ AST_SDP_REPR_END,
+};
+
+/*!
+ * \since 15.0.0
+ * \brief Set the SDP representation
+ *
+ * The default is AST_SDP_REPR_STRING
+ */
+int ast_sdp_options_set_repr(struct ast_sdp_options *options,
+ enum ast_sdp_options_repr repr);
+
+/*!
+ * \since 15.0.0
+ * \brief Get the SDP representation
+ */
+enum ast_sdp_options_repr ast_sdp_options_get_repr(const struct ast_sdp_options *options);
+
+/*!
+ * \brief SDP encryption options
+ */
+enum ast_sdp_options_encryption {
+ /*! No encryption */
+ AST_SDP_ENCRYPTION_DISABLED,
+ /*! SRTP SDES encryption */
+ AST_SDP_ENCRYPTION_SRTP_SDES,
+ /*! DTLS encryption */
+ AST_SDP_ENCRYPTION_DTLS,
+};
+
+/*!
+ * \since 15.0.0
+ * \brief Set the SDP encryption
+ *
+ * The default is AST_SDP_ENCRYPTION_DISABLED
+ */
+int ast_sdp_options_set_encryption(struct ast_sdp_options *options,
+ enum ast_sdp_options_encryption encryption);
+
+/*!
+ * \since 15.0.0
+ * \brief Get the SDP encryption
+ */
+enum ast_sdp_options_encryption ast_sdp_options_get_encryption(const struct ast_sdp_options *options);
+
+#endif /* _ASTERISK_SDP_OPTIONS_H */
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 */