[asterisk-commits] Add initial SDP options. (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Feb 21 13:37:04 CST 2017


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/4908 )

Change subject: Add initial SDP options.
......................................................................


Add initial SDP options.

This is step one of adding an SDP API: defining some
configurable settings for SDPs. This is based on options
that are currently supported in Asterisk.

Change-Id: I1ede91aafed403b12a9ccdfb91a88389baa7e5d7
---
A include/asterisk/sdp_options.h
A main/sdp_options.c
2 files changed, 275 insertions(+), 0 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, approved
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, but someone else must approve



diff --git a/include/asterisk/sdp_options.h b/include/asterisk/sdp_options.h
new file mode 100644
index 0000000..52f6f55
--- /dev/null
+++ b/include/asterisk/sdp_options.h
@@ -0,0 +1,155 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2017, Digium, Inc.
+ *
+ * Mark Michelson <mmichelson at 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,
+};
+
+/*!
+ * \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/main/sdp_options.c b/main/sdp_options.c
new file mode 100644
index 0000000..e18dfa5
--- /dev/null
+++ b/main/sdp_options.c
@@ -0,0 +1,120 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2017, Digium, Inc.
+ *
+ * Mark Michelson <mmichelson at 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.
+ */
+
+#include "asterisk.h"
+
+#include "asterisk/utils.h"
+#include "asterisk/sdp_options.h"
+
+struct ast_sdp_options {
+	enum ast_sdp_options_ice ice;
+	int telephone_event;
+	enum ast_sdp_options_repr repr;
+	enum ast_sdp_options_encryption encryption;
+};
+
+#define DEFAULT_ICE AST_SDP_ICE_DISABLED
+#define DEFAULT_TELEPHONE_EVENT 0
+#define DEFAULT_REPR AST_SDP_REPR_STRING
+#define DEFAULT_ENCRYPTION AST_SDP_ENCRYPTION_DISABLED
+
+static void set_defaults(struct ast_sdp_options *options)
+{
+	options->ice = DEFAULT_ICE;
+	options->telephone_event = DEFAULT_TELEPHONE_EVENT;
+	options->repr = DEFAULT_REPR;
+	options->encryption = DEFAULT_ENCRYPTION;
+}
+
+struct ast_sdp_options *ast_sdp_options_alloc(void)
+{
+	struct ast_sdp_options *options;
+
+	options = ast_calloc(1, sizeof(*options));
+	if (!options) {
+		return NULL;
+	}
+	set_defaults(options);
+	return options;
+}
+
+void ast_sdp_options_free(struct ast_sdp_options *options)
+{
+	ast_free(options);
+}
+
+int ast_sdp_options_set_ice(struct ast_sdp_options *options, enum ast_sdp_options_ice ice_setting)
+{
+	ast_assert(options != NULL);
+
+	options->ice = ice_setting;
+	return 0;
+}
+
+enum ast_sdp_options_ice ast_sdp_options_get_ice(const struct ast_sdp_options *options)
+{
+	ast_assert(options != NULL);
+
+	return options->ice;
+}
+
+int ast_sdp_options_set_telephone_event(struct ast_sdp_options *options, int telephone_event_enabled)
+{
+	ast_assert(options != NULL);
+
+	options->telephone_event = telephone_event_enabled;
+	return 0;
+}
+
+int ast_sdp_options_get_telephone_event(const struct ast_sdp_options *options)
+{
+	ast_assert(options != NULL);
+
+	return options->telephone_event;
+}
+
+int ast_sdp_options_set_repr(struct ast_sdp_options *options, enum ast_sdp_options_repr repr)
+{
+	ast_assert(options != NULL);
+
+	options->repr = repr;
+	return 0;
+}
+
+enum ast_sdp_options_repr ast_sdp_options_get_repr(const struct ast_sdp_options *options)
+{
+	ast_assert(options != NULL);
+
+	return options->repr;
+}
+
+int ast_sdp_options_set_encryption(struct ast_sdp_options *options,
+	enum ast_sdp_options_encryption encryption)
+{
+	ast_assert(options != NULL);
+
+	options->encryption = encryption;
+	return 0;
+}
+
+enum ast_sdp_options_encryption ast_sdp_options_get_encryption(const struct ast_sdp_options *options)
+{
+	ast_assert(options != NULL);
+
+	return options->encryption;
+}

-- 
To view, visit https://gerrit.asterisk.org/4908
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I1ede91aafed403b12a9ccdfb91a88389baa7e5d7
Gerrit-PatchSet: 8
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-commits mailing list