summaryrefslogtreecommitdiff
path: root/include/asterisk/sdp.h
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2017-03-21 15:44:44 -0500
committerRichard Mudgett <rmudgett@digium.com>2017-04-25 13:03:33 -0500
commit32b3e36c683da0cea37a01c006037ff31f8a2b1d (patch)
tree24942142d9e821f99645c174ff626b49a0178f46 /include/asterisk/sdp.h
parent59203c51cc6a9676ef1ab42aebe070a55f55ead2 (diff)
SDP: Ensure SDPs "merge" properly.
The gist of this work ensures that when a remote SDP is received, it is merged properly with the local capabilities. The remote SDP is converted into a stream topology. That topology is then merged with the current local topology on the SDP state. That new merged topology is then used to create an SDP. Finally, adjustments are made to RTP instances based on knowledge gained from the remote SDP. There are also a battery of tests in this commit that ensure that some basic SDP merges work as expected. While this may not sound like a big change, it has the property that it caused lots of ancillary changes. * The remote SDP is no longer stored on the SDP state. Biggest reason: there's no need for it. The remote SDP is used at the time it is being set and nowhere else. * Some new SDP APIs were added in order to find attributes and convert generic SDP attributes into rtpmap structures. * Writing tests made me realize that retrieving a value from an SDP options structure, the SDP options needs to be made const. * The SDP state machine was essentially gutted by a previous commit. Initially, I attempted to reinstate it, but I found that as it had been defined, it was not all that useful. What was more useful was knowing the role we play in SDP negotiation, so the SDP state machine has been transformed into an indicator of role. * Rather than storing separate local and joint stream state capabilities, it makes more sense to keep track of current stream state and update it as things change. Change-Id: I5938c2be3c6f0a003aa88a39a59e0880f8b2df3d
Diffstat (limited to 'include/asterisk/sdp.h')
-rw-r--r--include/asterisk/sdp.h99
1 files changed, 94 insertions, 5 deletions
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 */