summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/alertpipe.h159
-rw-r--r--include/asterisk/autoconfig.h.in4
-rw-r--r--include/asterisk/channel.h7
-rw-r--r--include/asterisk/codec.h11
-rw-r--r--include/asterisk/format_cache.h5
-rw-r--r--include/asterisk/res_pjsip_session.h4
-rw-r--r--include/asterisk/rtp_engine.h6
-rw-r--r--include/asterisk/sdp.h99
-rw-r--r--include/asterisk/sdp_options.h133
-rw-r--r--include/asterisk/sdp_state.h23
-rw-r--r--include/asterisk/vector.h62
11 files changed, 485 insertions, 28 deletions
diff --git a/include/asterisk/alertpipe.h b/include/asterisk/alertpipe.h
new file mode 100644
index 000000000..5ff854ce8
--- /dev/null
+++ b/include/asterisk/alertpipe.h
@@ -0,0 +1,159 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2017, Sean Bright
+ *
+ * Sean Bright <sean.bright@gmail.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_ALERTPIPE_H
+#define ASTERISK_ALERTPIPE_H
+
+#include "asterisk/utils.h"
+
+typedef enum {
+ AST_ALERT_READ_SUCCESS = 0,
+ AST_ALERT_NOT_READABLE,
+ AST_ALERT_READ_FAIL,
+ AST_ALERT_READ_FATAL,
+} ast_alert_status_t;
+
+/*!
+ * \brief Initialize an alert pipe
+ * \since 13.16.0
+ *
+ * \param p a two-element array to hold the alert pipe's file descriptors
+ *
+ * \return non-zero if a failure occurred, zero otherwise.
+ */
+int ast_alertpipe_init(int alert_pipe[2]);
+
+/*!
+ * \brief Close an alert pipe
+ * \since 13.16.0
+ *
+ * \param p a two-element containing the alert pipe's file descriptors
+ */
+void ast_alertpipe_close(int alert_pipe[2]);
+
+/*!
+ * \brief Read an event from an alert pipe
+ * \since 13.16.0
+ *
+ * \param p a two-element array containing the alert pipe's file descriptors
+ *
+ * \retval AST_ALERT_READ_SUCCESS on success
+ * \retval AST_ALERT_NOT_READABLE if the alert pipe is not readable
+ * \retval AST_ALERT_READ_FATAL if the alert pipe's file descriptors are in
+ * blocking mode, or a read error occurs.
+ */
+ast_alert_status_t ast_alertpipe_read(int alert_pipe[2]);
+
+/*!
+ * \brief Write an event to an alert pipe
+ * \since 13.16.0
+ *
+ * \param p a two-element array containing the alert pipe's file descriptors
+ *
+ * \return see write(2)
+ */
+ssize_t ast_alertpipe_write(int alert_pipe[2]);
+
+/*!
+ * \brief Consume all alerts written to the alert pipe
+ * \since 13.16.0
+ *
+ * \param p a two-element array containing the alert pipe's file descriptors
+ *
+ * \retval AST_ALERT_READ_SUCCESS on success
+ * \retval AST_ALERT_NOT_READABLE if the alert pipe is not readable
+ * \retval AST_ALERT_READ_FATAL if the alert pipe's file descriptors are in
+ * blocking mode, or a read error occurs.
+ */
+ast_alert_status_t ast_alertpipe_flush(int alert_pipe[2]);
+
+/*!
+ * \brief Sets the alert pipe file descriptors to default values
+ * \since 13.16.0
+ *
+ * \param p a two-element array containing the alert pipe's file descriptors
+ */
+AST_INLINE_API(
+void ast_alertpipe_clear(int alert_pipe[2]),
+{
+ alert_pipe[0] = alert_pipe[1] = -1;
+}
+)
+
+/*!
+ * \brief Determine if the alert pipe is readable
+ * \since 13.16.0
+ *
+ * \param p a two-element array containing the alert pipe's file descriptors
+ *
+ * \return non-zero if the alert pipe is readable, zero otherwise.
+ */
+AST_INLINE_API(
+int attribute_pure ast_alertpipe_readable(int alert_pipe[2]),
+{
+ return alert_pipe[0] > -1;
+}
+)
+
+/*!
+ * \brief Determine if the alert pipe is writable
+ * \since 13.16.0
+ *
+ * \param p a two-element array containing the alert pipe's file descriptors
+ *
+ * \return non-zero if the alert pipe is writable, zero otherwise.
+ */
+AST_INLINE_API(
+int attribute_pure ast_alertpipe_writable(int alert_pipe[2]),
+{
+ return alert_pipe[1] > -1;
+}
+)
+
+/*!
+ * \brief Get the alert pipe's read file descriptor
+ * \since 13.16.0
+ *
+ * \param p a two-element array containing the alert pipe's file descriptors
+ *
+ * \return -1 if the file descriptor is not initialized, a non-negative value
+ * otherwise.
+ */
+AST_INLINE_API(
+int attribute_pure ast_alertpipe_readfd(int alert_pipe[2]),
+{
+ return alert_pipe[0];
+}
+)
+
+/*!
+ * \brief Swap the file descriptors from two alert pipes
+ * \since 13.16.0
+ *
+ * \param p1 a two-element array containing an alert pipe's file descriptors
+ * \param p2 a two-element array containing an alert pipe's file descriptors
+ */
+AST_INLINE_API(
+void ast_alertpipe_swap(int alert_pipe_1[2], int alert_pipe_2[2]),
+{
+ SWAP(alert_pipe_1[0], alert_pipe_2[0]);
+ SWAP(alert_pipe_1[1], alert_pipe_2[1]);
+}
+)
+
+#endif /* ASTERISK_ALERTPIPE_H */
diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in
index 5f8a9d37c..b39386b43 100644
--- a/include/asterisk/autoconfig.h.in
+++ b/include/asterisk/autoconfig.h.in
@@ -225,6 +225,10 @@
/* Define to 1 if you have the `euidaccess' function. */
#undef HAVE_EUIDACCESS
+/* Define to 1 if your system supports eventfd and the EFD_NONBLOCK and
+ EFD_SEMAPHORE flags. */
+#undef HAVE_EVENTFD
+
/* Define to 1 if you have the `exp' function. */
#undef HAVE_EXP
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index 70856a96f..128cd3056 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -123,6 +123,7 @@ References:
#ifndef _ASTERISK_CHANNEL_H
#define _ASTERISK_CHANNEL_H
+#include "asterisk/alertpipe.h"
#include "asterisk/abstract_jb.h"
#include "asterisk/astobj2.h"
#include "asterisk/poll-compat.h"
@@ -4308,12 +4309,6 @@ struct ast_namedgroups *ast_channel_named_pickupgroups(const struct ast_channel
void ast_channel_named_pickupgroups_set(struct ast_channel *chan, struct ast_namedgroups *value);
/* Alertpipe accessors--the "internal" functions for channel.c use only */
-typedef enum {
- AST_ALERT_READ_SUCCESS = 0,
- AST_ALERT_NOT_READABLE,
- AST_ALERT_READ_FAIL,
- AST_ALERT_READ_FATAL,
-} ast_alert_status_t;
int ast_channel_alert_write(struct ast_channel *chan);
int ast_channel_alert_writable(struct ast_channel *chan);
ast_alert_status_t ast_channel_internal_alert_flush(struct ast_channel *chan);
diff --git a/include/asterisk/codec.h b/include/asterisk/codec.h
index 2ae955181..2f5756cd1 100644
--- a/include/asterisk/codec.h
+++ b/include/asterisk/codec.h
@@ -166,6 +166,17 @@ int ast_codec_get_max(void);
const char *ast_codec_media_type2str(enum ast_media_type type);
/*!
+ * \brief Conversion function to take a media string and convert it to a media type
+ *
+ * \param media_type_str The media type string
+ *
+ * \retval The ast_media_type that corresponds to the string
+ *
+ * \since 15.0.0
+ */
+enum ast_media_type ast_media_type_from_str(const char *media_type_str);
+
+/*!
* \brief Get the number of samples contained within a frame
*
* \param frame The frame itself
diff --git a/include/asterisk/format_cache.h b/include/asterisk/format_cache.h
index 6099c59ea..92272e8eb 100644
--- a/include/asterisk/format_cache.h
+++ b/include/asterisk/format_cache.h
@@ -224,6 +224,11 @@ extern struct ast_format *ast_format_t140;
extern struct ast_format *ast_format_t140_red;
/*!
+ * \brief Built-in cached T.38 format.
+ */
+extern struct ast_format *ast_format_t38;
+
+/*!
* \brief Built-in "null" format.
*/
extern struct ast_format *ast_format_none;
diff --git a/include/asterisk/res_pjsip_session.h b/include/asterisk/res_pjsip_session.h
index d4d3f705a..10e55f133 100644
--- a/include/asterisk/res_pjsip_session.h
+++ b/include/asterisk/res_pjsip_session.h
@@ -459,6 +459,10 @@ struct ast_sip_session *ast_sip_session_create_outgoing(struct ast_sip_endpoint
*
* \param session The session to terminate
* \param response The response code to use for termination if possible
+ *
+ * \warning Calling this function MAY cause the last session reference to be
+ * released and the session destructor to be called. If you need to do something
+ * with session after this call, be sure to bump the ref count before calling terminate.
*/
void ast_sip_session_terminate(struct ast_sip_session *session, int response);
diff --git a/include/asterisk/rtp_engine.h b/include/asterisk/rtp_engine.h
index fa7fed8a1..55acf6529 100644
--- a/include/asterisk/rtp_engine.h
+++ b/include/asterisk/rtp_engine.h
@@ -81,6 +81,12 @@ extern "C" {
/*! Maximum number of payload types RTP can support. */
#define AST_RTP_MAX_PT 128
+/*!
+ * Last RTP payload type statically assigned, see
+ * http://www.iana.org/assignments/rtp-parameters
+ */
+#define AST_RTP_PT_LAST_STATIC 34
+
/*! First dynamic RTP payload type */
#define AST_RTP_PT_FIRST_DYNAMIC 96
diff --git a/include/asterisk/sdp.h b/include/asterisk/sdp.h
index 3649b4037..d5bf9147b 100644
--- a/include/asterisk/sdp.h
+++ b/include/asterisk/sdp.h
@@ -147,6 +147,22 @@ struct ast_sdp {
};
/*!
+ * \brief A structure representing an SDP rtpmap attribute
+ */
+struct ast_sdp_rtpmap {
+ /*! The RTP payload number for the rtpmap */
+ int payload;
+ /*! The Name of the codec */
+ char *encoding_name;
+ /*! The clock rate of the codec */
+ int clock_rate;
+ /*! Optional encoding parameters */
+ char *encoding_parameters;
+ /*! Area where strings are stored */
+ char buf[0];
+};
+
+/*!
* \brief Free an SDP Attribute
*
* \param a_line The attribute to free
@@ -545,15 +561,88 @@ struct ast_sdp *ast_sdp_alloc(struct ast_sdp_o_line *o_line,
struct ast_sdp_t_line *t_line);
/*!
- * \brief Create an SDP from an existing SDP State local topology
+ * \brief Find an attribute on the top-level SDP
+ *
+ * \note This will not search within streams for the given attribute.
+ *
+ * \param sdp The SDP in which to search
+ * \param attr_name The name of the attribute to search for
+ * \param payload Optional payload number to search for. If irrelevant, set to -1
+ *
+ * \retval NULL Could not find the given attribute
+ * \retval Non-NULL The attribute to find
+ *
+ * \since 15.0.0
+ */
+struct ast_sdp_a_line *ast_sdp_find_attribute(const struct ast_sdp *sdp,
+ const char *attr_name, int payload);
+
+/*!
+ * \brief Find an attribute on an SDP stream (m-line)
*
- * \param sdp_state SDP State
+ * \param sdp The SDP in which to search
+ * \param attr_name The name of the attribute to search for
+ * \param payload Optional payload number to search for. If irrelevant, set to -1
*
+ * \retval NULL Could not find the given attribute
+ * \retval Non-NULL The attribute to find
+ *
+ * \since 15.0.0
+ */
+struct ast_sdp_a_line *ast_sdp_m_find_attribute(const struct ast_sdp_m_line *m_line,
+ const char *attr_name, int payload);
+
+/*!
+ * \brief Convert an SDP a_line into an rtpmap
+ *
+ * The returned value is heap-allocated and must be freed with
+ * ast_sdp_rtpmap_free()
+ *
+ * \param a_line The SDP a_line to convert
+ *
+ * \retval NULL Fail
* \retval non-NULL Success
- * \retval NULL Failure
*
- * \since 15
+ * \since 15.0.0
*/
-struct ast_sdp *ast_sdp_create_from_state(const struct ast_sdp_state *sdp_state);
+struct ast_sdp_rtpmap *ast_sdp_a_get_rtpmap(const struct ast_sdp_a_line *a_line);
+
+/*!
+ * \brief Allocate a new SDP rtpmap
+ *
+ * \param payload The RTP payload number
+ * \param encoding_name The human-readable name for the codec
+ * \param clock_rate The rate of the codec, in cycles per second
+ * \param encoding_parameters Optional codec-specific parameters (such as number of channels)
+ *
+ * \retval NULL Fail
+ * \retval non-NULL Success
+ *
+ * \since 15.0.0
+ */
+struct ast_sdp_rtpmap *ast_sdp_rtpmap_alloc(int payload, const char *encoding_name,
+ int clock_rate, const char *encoding_parameters);
+
+/*!
+ * \brief Free an SDP rtpmap
+ *
+ * \since 15.0.0
+ */
+void ast_sdp_rtpmap_free(struct ast_sdp_rtpmap *rtpmap);
+
+/*!
+ * \brief Turn an SDP into a stream topology
+ *
+ * This traverses the m-lines of the SDP and creates a stream topology, with
+ * each m-line corresponding to a stream in the created topology.
+ *
+ * \param sdp The SDP to convert
+ *
+ * \retval NULL An error occurred when converting
+ * \retval non-NULL The generated stream topology
+ *
+ * \since 15.0.0
+ */
+struct ast_stream_topology *ast_get_topology_from_sdp(const struct ast_sdp *sdp);
#endif /* _SDP_PRIV_H */
diff --git a/include/asterisk/sdp_options.h b/include/asterisk/sdp_options.h
index 0186eea57..af694cd14 100644
--- a/include/asterisk/sdp_options.h
+++ b/include/asterisk/sdp_options.h
@@ -19,6 +19,8 @@
#ifndef _ASTERISK_SDP_OPTIONS_H
#define _ASTERISK_SDP_OPTIONS_H
+#include "asterisk/udptl.h"
+
struct ast_sdp_options;
/*!
@@ -106,7 +108,7 @@ void ast_sdp_options_set_media_address(struct ast_sdp_options *options,
*
* \returns media_address
*/
-const char *ast_sdp_options_get_media_address(struct ast_sdp_options *options);
+const char *ast_sdp_options_get_media_address(const struct ast_sdp_options *options);
/*!
* \since 15.0.0
@@ -126,7 +128,7 @@ void ast_sdp_options_set_sdpowner(struct ast_sdp_options *options,
*
* \returns sdpowner
*/
-const char *ast_sdp_options_get_sdpowner(struct ast_sdp_options *options);
+const char *ast_sdp_options_get_sdpowner(const struct ast_sdp_options *options);
/*!
* \since 15.0.0
@@ -146,7 +148,7 @@ void ast_sdp_options_set_sdpsession(struct ast_sdp_options *options,
*
* \returns sdpsession
*/
-const char *ast_sdp_options_get_sdpsession(struct ast_sdp_options *options);
+const char *ast_sdp_options_get_sdpsession(const struct ast_sdp_options *options);
/*!
* \since 15.0.0
@@ -166,7 +168,7 @@ void ast_sdp_options_set_rtp_engine(struct ast_sdp_options *options,
*
* \returns rtp_engine
*/
-const char *ast_sdp_options_get_rtp_engine(struct ast_sdp_options *options);
+const char *ast_sdp_options_get_rtp_engine(const struct ast_sdp_options *options);
/*!
* \since 15.0.0
@@ -186,7 +188,7 @@ void ast_sdp_options_set_bind_rtp_to_media_address(struct ast_sdp_options *optio
*
* \returns bind_rtp_to_media_address
*/
-unsigned int ast_sdp_options_get_bind_rtp_to_media_address(struct ast_sdp_options *options);
+unsigned int ast_sdp_options_get_bind_rtp_to_media_address(const struct ast_sdp_options *options);
/*!
* \since 15.0.0
@@ -206,7 +208,7 @@ void ast_sdp_options_set_rtp_symmetric(struct ast_sdp_options *options,
*
* \returns rtp_symmetric
*/
-unsigned int ast_sdp_options_get_rtp_symmetric(struct ast_sdp_options *options);
+unsigned int ast_sdp_options_get_rtp_symmetric(const struct ast_sdp_options *options);
/*!
* \since 15.0.0
@@ -226,7 +228,7 @@ void ast_sdp_options_set_telephone_event(struct ast_sdp_options *options,
*
* \returns telephone_event
*/
-unsigned int ast_sdp_options_get_telephone_event(struct ast_sdp_options *options);
+unsigned int ast_sdp_options_get_telephone_event(const struct ast_sdp_options *options);
/*!
* \since 15.0.0
@@ -246,7 +248,7 @@ void ast_sdp_options_set_rtp_ipv6(struct ast_sdp_options *options,
*
* \returns rtp_ipv6
*/
-unsigned int ast_sdp_options_get_rtp_ipv6(struct ast_sdp_options *options);
+unsigned int ast_sdp_options_get_rtp_ipv6(const struct ast_sdp_options *options);
/*!
* \since 15.0.0
@@ -266,7 +268,7 @@ void ast_sdp_options_set_g726_non_standard(struct ast_sdp_options *options,
*
* \returns g726_non_standard
*/
-unsigned int ast_sdp_options_get_g726_non_standard(struct ast_sdp_options *options);
+unsigned int ast_sdp_options_get_g726_non_standard(const struct ast_sdp_options *options);
/*!
* \since 15.0.0
@@ -286,7 +288,7 @@ void ast_sdp_options_set_tos_audio(struct ast_sdp_options *options,
*
* \returns tos_audio
*/
-unsigned int ast_sdp_options_get_tos_audio(struct ast_sdp_options *options);
+unsigned int ast_sdp_options_get_tos_audio(const struct ast_sdp_options *options);
/*!
* \since 15.0.0
@@ -306,7 +308,7 @@ void ast_sdp_options_set_cos_audio(struct ast_sdp_options *options,
*
* \returns cos_audio
*/
-unsigned int ast_sdp_options_get_cos_audio(struct ast_sdp_options *options);
+unsigned int ast_sdp_options_get_cos_audio(const struct ast_sdp_options *options);
/*!
* \since 15.0.0
@@ -326,7 +328,7 @@ void ast_sdp_options_set_tos_video(struct ast_sdp_options *options,
*
* \returns tos_video
*/
-unsigned int ast_sdp_options_get_tos_video(struct ast_sdp_options *options);
+unsigned int ast_sdp_options_get_tos_video(const struct ast_sdp_options *options);
/*!
* \since 15.0.0
@@ -346,7 +348,7 @@ void ast_sdp_options_set_cos_video(struct ast_sdp_options *options,
*
* \returns cos_video
*/
-unsigned int ast_sdp_options_get_cos_video(struct ast_sdp_options *options);
+unsigned int ast_sdp_options_get_cos_video(const struct ast_sdp_options *options);
/*!
* \since 15.0.0
@@ -366,7 +368,7 @@ void ast_sdp_options_set_ice(struct ast_sdp_options *options,
*
* \returns ice
*/
-enum ast_sdp_options_ice ast_sdp_options_get_ice(struct ast_sdp_options *options);
+enum ast_sdp_options_ice ast_sdp_options_get_ice(const struct ast_sdp_options *options);
/*!
* \since 15.0.0
@@ -386,7 +388,7 @@ void ast_sdp_options_set_impl(struct ast_sdp_options *options,
*
* \returns impl
*/
-enum ast_sdp_options_impl ast_sdp_options_get_impl(struct ast_sdp_options *options);
+enum ast_sdp_options_impl ast_sdp_options_get_impl(const struct ast_sdp_options *options);
/*!
* \since 15.0.0
@@ -406,6 +408,105 @@ void ast_sdp_options_set_encryption(struct ast_sdp_options *options,
*
* \returns encryption
*/
-enum ast_sdp_options_encryption ast_sdp_options_get_encryption(struct ast_sdp_options *options);
+enum ast_sdp_options_encryption ast_sdp_options_get_encryption(const struct ast_sdp_options *options);
+
+/*!
+ * \since 15.0.0
+ * \brief Get SDP Options RTCP MUX
+ *
+ * \param options SDP Options
+ *
+ * \returns Boolean indicating if RTCP MUX is enabled.
+ */
+unsigned int ast_sdp_options_get_rtcp_mux(const struct ast_sdp_options *options);
+
+/*!
+ * \since 15.0.0
+ * \brief Set SDP Options RTCP MUX
+ *
+ * \param options SDP Options
+ * \param value Boolean that indicates if RTCP MUX should be enabled.
+ */
+void ast_sdp_options_set_rtcp_mux(struct ast_sdp_options *options, unsigned int value);
+
+/*!
+ * \since 15.0.0
+ * \brief Set SDP Options udptl_symmetric
+ *
+ * \param options SDP Options
+ * \param udptl_symmetric
+ */
+void ast_sdp_options_set_udptl_symmetric(struct ast_sdp_options *options,
+ unsigned int udptl_symmetric);
+
+/*!
+ * \since 15.0.0
+ * \brief Get SDP Options udptl_symmetric
+ *
+ * \param options SDP Options
+ *
+ * \returns udptl_symmetric
+ */
+unsigned int ast_sdp_options_get_udptl_symmetric(const struct ast_sdp_options *options);
+
+/*!
+ * \since 15.0.0
+ * \brief Set SDP Options udptl_error_correction
+ *
+ * \param options SDP Options
+ * \param error_correction
+ */
+void ast_sdp_options_set_udptl_error_correction(struct ast_sdp_options *options,
+ enum ast_t38_ec_modes error_correction);
+
+/*!
+ * \since 15.0.0
+ * \brief Get SDP Options udptl_error_correction
+ *
+ * \param options SDP Options
+ *
+ * \returns udptl_error_correction
+ */
+enum ast_t38_ec_modes ast_sdp_options_get_udptl_error_correction(const struct ast_sdp_options *options);
+
+/*!
+ * \since 15.0.0
+ * \brief Set SDP Options udptl_far_max_datagram
+ *
+ * \param options SDP Options
+ * \param far_max_datagram
+ */
+void ast_sdp_options_set_udptl_far_max_datagram(struct ast_sdp_options *options,
+ unsigned int far_max_datagram);
+
+/*!
+ * \since 15.0.0
+ * \brief Get SDP Options udptl_far_max_datagram
+ *
+ * \param options SDP Options
+ *
+ * \returns udptl_far_max_datagram
+ */
+unsigned int ast_sdp_options_get_udptl_far_max_datagram(const struct ast_sdp_options *options);
+
+/*!
+ * \since 15.0.0
+ * \brief Set SDP Options bind_udptl_to_media_address
+ *
+ * \param options SDP Options
+ * \param bind_udptl_to_media_address
+ */
+void ast_sdp_options_set_bind_udptl_to_media_address(struct ast_sdp_options *options,
+ unsigned int bind_udptl_to_media_address);
+
+/*!
+ * \since 15.0.0
+ * \brief Get SDP Options bind_udptl_to_media_address
+ *
+ * \param options SDP Options
+ *
+ * \returns bind_udptl_to_media_address
+ */
+unsigned int ast_sdp_options_get_bind_udptl_to_media_address(const struct ast_sdp_options *options);
#endif /* _ASTERISK_SDP_OPTIONS_H */
diff --git a/include/asterisk/sdp_state.h b/include/asterisk/sdp_state.h
index a186d7eef..1382ed6af 100644
--- a/include/asterisk/sdp_state.h
+++ b/include/asterisk/sdp_state.h
@@ -24,6 +24,8 @@
struct ast_sdp_state;
struct ast_sockaddr;
+struct ast_udptl;
+struct ast_control_t38_parameters;
/*!
* \brief Allocate a new SDP state
@@ -52,6 +54,14 @@ struct ast_rtp_instance *ast_sdp_state_get_rtp_instance(const struct ast_sdp_sta
int stream_index);
/*!
+ * \brief Get the associated UDPTL instance for a particular stream on the SDP state.
+ *
+ * Stream numbers correspond to the streams in the topology of the associated channel
+ */
+struct ast_udptl *ast_sdp_state_get_udptl_instance(const struct ast_sdp_state *sdp_state,
+ int stream_index);
+
+/*!
* \brief Get the global connection address on the SDP state.
*/
const struct ast_sockaddr *ast_sdp_state_get_connection_address(const struct ast_sdp_state *sdp_state);
@@ -138,7 +148,7 @@ const void *ast_sdp_state_get_local_sdp_impl(struct ast_sdp_state *sdp_state);
*
* \since 15
*/
-void ast_sdp_state_set_remote_sdp(struct ast_sdp_state *sdp_state, struct ast_sdp *sdp);
+void ast_sdp_state_set_remote_sdp(struct ast_sdp_state *sdp_state, const struct ast_sdp *sdp);
/*!
* \brief Set the remote SDP from an Implementation
@@ -225,6 +235,17 @@ void ast_sdp_state_set_locally_held(struct ast_sdp_state *sdp_state,
/*!
* \since 15.0.0
+ * \brief Set the UDPTL session parameters
+ *
+ * \param sdp_state
+ * \param stream_index The stream to set the UDPTL session parameters for
+ * \param params
+ */
+void ast_sdp_state_set_t38_parameters(struct ast_sdp_state *sdp_state,
+ int stream_index, struct ast_control_t38_parameters *params);
+
+/*!
+ * \since 15.0.0
* \brief Get whether a stream is held or not
*
* \param sdp_state
diff --git a/include/asterisk/vector.h b/include/asterisk/vector.h
index 83732e7c8..2de84d295 100644
--- a/include/asterisk/vector.h
+++ b/include/asterisk/vector.h
@@ -48,6 +48,9 @@
size_t current; \
}
+/*! \brief Integer vector definition */
+AST_VECTOR(ast_vector_int, int);
+
/*!
* \brief Define a vector structure with a read/write lock
*
@@ -241,6 +244,29 @@
})
/*!
+ * \brief Default a vector up to size with the given value.
+ *
+ * \note If a size of 0 is given then all elements in the given vector are set.
+ * \note The vector will grow to the given size if needed.
+ *
+ * \param vec Vector to default.
+ * \param size The number of elements to default
+ * \param value The default value to set each element to
+ */
+#define AST_VECTOR_DEFAULT(vec, size, value) ({ \
+ int res = 0; \
+ typeof((size)) __size = (size) ? (size) : AST_VECTOR_SIZE(vec); \
+ size_t idx; \
+ for (idx = 0; idx < __size; ++idx) { \
+ res = AST_VECTOR_REPLACE(vec, idx, value); \
+ if (res == -1) { \
+ break; \
+ } \
+ } \
+ res; \
+})
+
+/*!
* \brief Insert an element at a specific position in a vector, growing the vector if needed.
*
* \param vec Vector to insert into.
@@ -553,6 +579,42 @@
})
/*!
+ * \brief Get the nth index from a vector that matches the given comparison
+ *
+ * \param vec Vector to get from.
+ * \param nth The nth index to find
+ * \param value Value to pass into comparator.
+ * \param cmp Comparator function/macros (called as \c cmp(elem, value))
+ *
+ * \return a pointer to the element that was found or NULL
+ */
+#define AST_VECTOR_GET_INDEX_NTH(vec, nth, value, cmp) ({ \
+ int res = -1; \
+ size_t idx; \
+ typeof(nth) __nth = (nth); \
+ typeof(value) __value = (value); \
+ for (idx = 0; idx < (vec)->current; ++idx) { \
+ if (cmp((vec)->elems[idx], __value) && !(--__nth)) { \
+ res = (int)idx; \
+ break; \
+ } \
+ } \
+ res; \
+})
+
+/*!
+ * \brief Get the 1st index from a vector that matches the given comparison
+ *
+ * \param vec Vector to get from.
+ * \param value Value to pass into comparator.
+ * \param cmp Comparator function/macros (called as \c cmp(elem, value))
+ *
+ * \return a pointer to the element that was found or NULL
+ */
+#define AST_VECTOR_GET_INDEX(vec, value, cmp) \
+ AST_VECTOR_GET_INDEX_NTH(vec, 1, value, cmp)
+
+/*!
* \brief Get an element from a vector that matches the given comparison
*
* \param vec Vector to get from.