[Asterisk-code-review] core: Remove unused/incomplete SDP modules from released bra... (asterisk[15])

Richard Mudgett asteriskteam at digium.com
Fri Dec 22 13:30:52 CST 2017


Richard Mudgett has uploaded this change for review. ( https://gerrit.asterisk.org/7715


Change subject: core: Remove unused/incomplete SDP modules from released branches.
......................................................................

core: Remove unused/incomplete SDP modules from released branches.

Change-Id: Icc28fbdc46f58e54a21554e6fe8b078f841b1f86
---
D include/asterisk/sdp.h
D include/asterisk/sdp_options.h
D include/asterisk/sdp_state.h
D include/asterisk/sdp_translator.h
D main/sdp.c
D main/sdp_options.c
D main/sdp_private.h
D main/sdp_srtp.c
D main/sdp_state.c
D main/sdp_translator.c
D res/res_sdp_translator_pjmedia.c
D tests/test_sdp.c
12 files changed, 0 insertions(+), 6,584 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/15/7715/1

diff --git a/include/asterisk/sdp.h b/include/asterisk/sdp.h
deleted file mode 100644
index 224a0e5..0000000
--- a/include/asterisk/sdp.h
+++ /dev/null
@@ -1,713 +0,0 @@
-/*
- * 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.
- */
-
-/* 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"
-#include "asterisk/format.h"
-#include "asterisk/sdp_state.h"
-#include "asterisk/stream.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 A collection of SDP Attributes
- */
-AST_VECTOR(ast_sdp_a_lines, struct ast_sdp_a_line *);
-
-/*!
- * \brief Structure representing an SDP Connection
- */
-struct ast_sdp_c_line {
-	/* IP family string (e.g. IP4 or IP6) */
-	char *address_type;
-	/* Connection address. Can be an IP address or FQDN */
-	char *address;
-};
-
-/*!
- * \brief Structre representing SDP Media Payloads
- */
-struct ast_sdp_payload {
-	/* Media format description */
-	char *fmt;
-};
-
-/*!
- * \brief A collection of SDP Media Payloads
- */
-AST_VECTOR(ast_sdp_payloads, struct ast_sdp_payload *);
-
-/*!
- * \brief Structure representing 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;
-	/*! RTP profile string (e.g. "RTP/AVP") */
-	char *proto;
-	/*! Port number in m line */
-	uint16_t port;
-	/*! Number of ports specified in m line */
-	uint16_t port_count;
-	/*! RTP payloads */
-	struct ast_sdp_payloads *payloads;
-	/*! Connection information for this media stream */
-	struct ast_sdp_c_line *c_line;
-	/*! The attributes for this media stream */
-	struct ast_sdp_a_lines *a_lines;
-};
-
-/*!
- * \brief A collection of SDP Media Streams
- */
-AST_VECTOR(ast_sdp_m_lines, struct ast_sdp_m_line *);
-
-/*!
- * \brief Structure representing an SDP Origin
- */
-struct ast_sdp_o_line {
-	/*! Origin user name */
-	char *username;
-	/*! Origin id */
-	uint64_t session_id;
-	/*! Origin version */
-	uint64_t session_version;
-	/*! Origin IP address type (e.g. "IP4" or "IP6") */
-	char *address_type;
-	/*! Origin address. Can be an IP address or FQDN */
-	char *address;
-};
-
-/*!
- * \brief Structure representing an SDP Session Name
- */
-struct ast_sdp_s_line {
-	/* Session Name */
-	char *session_name;
-};
-
-/*!
- * \brief Structure representing SDP Timing
- */
-struct ast_sdp_t_line {
-	/*! Session start time */
-	uint64_t start_time;
-	/*! Session end time */
-	uint64_t stop_time;
-};
-
-/*!
- * \brief An SDP
- */
-struct ast_sdp {
-	/*! SDP Origin line */
-	struct ast_sdp_o_line *o_line;
-	/*! SDP Session name */
-	struct ast_sdp_s_line *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_lines *a_lines;
-	/*! SDP media streams */
-	struct ast_sdp_m_lines *m_lines;
-};
-
-/*!
- * \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
- *
- * \since 15
- */
-void ast_sdp_a_free(struct ast_sdp_a_line *a_line);
-
-/*!
- * \brief Free an SDP Attribute collection
- *
- * \param a_lines The attribute collection to free
- *
- * \since 15
- */
-void ast_sdp_a_lines_free(struct ast_sdp_a_lines *a_lines);
-
-/*!
- * \brief Free SDP Connection Data
- *
- * \param c_line The connection data to free
- *
- * \since 15
- */
-void ast_sdp_c_free(struct ast_sdp_c_line *c_line);
-
-/*!
- * \brief Free an SDP Media Description Payload
- *
- * \param payload The payload to free
- *
- * \since 15
- */
-void ast_sdp_payload_free(struct ast_sdp_payload *payload);
-
-/*!
- * \brief Free an SDP Media Description Payload collection
- *
- * \param payloads collection to free
- *
- * \since 15
- */
-void ast_sdp_payloads_free(struct ast_sdp_payloads *payloads);
-
-/*!
- * \brief Free an SDP Media Description
- * Frees the media description and all resources it contains
- *
- * \param m_line The media description to free
- *
- * \since 15
- */
-void ast_sdp_m_free(struct ast_sdp_m_line *m_line);
-
-/*!
- * \brief Free an SDP Media Description collection
- *
- * \param m_lines The collection description to free
- *
- * \since 15
- */
-void ast_sdp_m_lines_free(struct ast_sdp_m_lines *m_lines);
-
-/*!
- * \brief Free an SDP Origin
- *
- * \param o_line The origin description to free
- *
- * \since 15
- */
-void ast_sdp_o_free(struct ast_sdp_o_line *o_line);
-
-/*!
- * \brief Free an SDP Session
- *
- * \param s_line The session to free
- *
- * \since 15
- */
-void ast_sdp_s_free(struct ast_sdp_s_line *s_line);
-
-/*!
- * \brief Free SDP Timing
- *
- * \param t_line The timing description to free
- *
- * \since 15
- */
-void ast_sdp_t_free(struct ast_sdp_t_line *t_line);
-
-/*!
- * \brief Free an SDP
- * Frees the sdp and all resources it contains
- *
- * \param sdp The sdp to free
- *
- * \since 15
- */
-void ast_sdp_free(struct ast_sdp *sdp);
-
-/*!
- * \brief Allocate an SDP Attribute
- *
- * \param name Attribute Name
- * \param value Attribute Name
- *
- * \retval non-NULL Success
- * \retval NULL Failure
- *
- * \since 15
- */
-struct ast_sdp_a_line *ast_sdp_a_alloc(const char *name, const char *value);
-
-/*!
- * \brief Allocate an SDP Connection
- *
- * \param family Family ("IN", etc)
- * \param addr Address
- *
- * \retval non-NULL Success
- * \retval NULL Failure
- *
- * \since 15
- */
-struct ast_sdp_c_line *ast_sdp_c_alloc(const char *family, const char *addr);
-
-/*!
- * \brief Allocate an SDP Media Description Payload
- *
- * \param fmt The media format description
- *
- * \retval non-NULL Success
- * \retval NULL Failure
- *
- * \since 15
- */
-struct ast_sdp_payload *ast_sdp_payload_alloc(const char *fmt);
-
-/*!
- * \brief Allocate an SDP Media Description
- *
- * \param type ("audio", "video", etc)
- * \param port Starting port
- * \param port_count Port pairs to allocate
- * \param proto ("RTP/AVP", "RTP/SAVP", "udp")
- * \param c_line Connection to add.  May be NULL
- *
- * \retval non-NULL Success
- * \retval NULL Failure
- *
- * \since 15
- */
-struct ast_sdp_m_line *ast_sdp_m_alloc(const char *type, uint16_t port,
-	uint16_t port_count, 	const char *proto, struct ast_sdp_c_line *c_line);
-
-/*!
- * \brief Allocate an SDP Session
- *
- * \param session_name The session name
- *
- * \retval non-NULL Success
- * \retval NULL Failure
- *
- * \since 15
- */
-struct ast_sdp_s_line *ast_sdp_s_alloc(const char *session_name);
-
-/*!
- * \brief Allocate SDP Timing
- *
- * \param start_time (Seconds since 1900)
- * \param end_time (Seconds since 1900)
- *
- * \retval non-NULL Success
- * \retval NULL Failure
- *
- * \since 15
- */
-struct ast_sdp_t_line *ast_sdp_t_alloc(uint64_t start_time, uint64_t stop_time);
-
-/*!
- * \brief Allocate an SDP Origin
- *
- * \param username User name
- * \param sesison_id Session ID
- * \param sesison_version Session Version
- * \param address_type Address type ("IN4", "IN6", etc)
- * \param address Unicast address
- *
- * \retval non-NULL Success
- * \retval NULL Failure
- *
- * \since 15
- */
-struct ast_sdp_o_line *ast_sdp_o_alloc(const char *username, uint64_t session_id,
-	uint64_t session_version, const char *address_type, const char *address);
-
-/*!
- * \brief Add an SDP Attribute to an SDP
- *
- * \param sdp SDP
- * \param a_line Attribute
- *
- * \retval 0 Success
- * \retval non-0 Failure
- *
- * \since 15
- */
-int ast_sdp_add_a(struct ast_sdp *sdp, struct ast_sdp_a_line *a_line);
-
-/*!
- * \brief Get the count of Attributes on an SDP
- *
- * \param sdp SDP
- *
- * \returns Number of Attributes
- *
- * \since 15
- */
-int ast_sdp_get_a_count(const struct ast_sdp *sdp);
-
-/*!
- * \brief Get an Attribute from an SDP
- *
- * \param sdp SDP
- * \param index Attribute index
- *
- * \retval non-NULL Success
- * \retval NULL Failure
- *
- * \since 15
- */
-struct ast_sdp_a_line *ast_sdp_get_a(const struct ast_sdp *sdp, int index);
-
-/*!
- * \brief Add a Media Description to an SDP
- *
- * \param sdp SDP
- * \param m_line Media Description
- *
- * \retval 0 Success
- * \retval non-0 Failure
- *
- * \since 15
- */
-int ast_sdp_add_m(struct ast_sdp *sdp, struct ast_sdp_m_line *m_line);
-
-/*!
- * \brief Add an RTP Media Description to an SDP
- *
- * \param sdp SDP
- * \param sdp_state SDP state information
- * \param options SDP Options
- * \param stream_index stream
- *
- * \retval 0 Success
- * \retval non-0 Failure
- *
- * \since 15
- */
-int ast_sdp_add_m_from_rtp_stream(struct ast_sdp *sdp, const struct ast_sdp_state *sdp_state,
-	const struct ast_sdp_options *options, int stream_index);
-
-/*!
- * \brief Get the count of Media Descriptions on an SDP
- *
- * \param sdp SDP
- *
- * \returns The number of Media Descriptions
- *
- * \since 15
- */
-int ast_sdp_get_m_count(const struct ast_sdp *sdp);
-
-/*!
- * \brief Get a Media Descriptions from an SDP
- *
- * \param sdp SDP
- * \param index Media Description index
- *
- * \retval non-NULL Success
- * \retval NULL Failure
- *
- * \since 15
- */
-struct ast_sdp_m_line *ast_sdp_get_m(const struct ast_sdp *sdp, int index);
-
-/*!
- * \brief Add an SDP Attribute to a Media Description
- *
- * \param m_line Media Description
- * \param a_line Attribute
- *
- * \retval 0 Success
- * \retval non-0 Failure
- *
- * \since 15
- */
-int ast_sdp_m_add_a(struct ast_sdp_m_line *m_line, struct ast_sdp_a_line *a_line);
-
-/*!
- * \brief Get the count of Attributes on a Media Description
- *
- * \param m_line Media Description
- *
- * \returns Number of Attributes
- *
- * \since 15
- */
-int ast_sdp_m_get_a_count(const struct ast_sdp_m_line *m_line);
-
-/*!
- * \brief Get an Attribute from a Media Description
- *
- * \param m_line Media Description
- * \param index Attribute index
- *
- * \retval non-NULL Success
- * \retval NULL Failure
- *
- * \since 15
- */
-struct ast_sdp_a_line *ast_sdp_m_get_a(const struct ast_sdp_m_line *m_line, int index);
-
-/*!
- * \brief Add a Payload to a Media Description
- *
- * \param m_line Media Description
- * \param payload Payload
- *
- * \retval 0 Success
- * \retval non-0 Failure
- *
- * \since 15
- */
-int ast_sdp_m_add_payload(struct ast_sdp_m_line *m_line,
-	struct ast_sdp_payload *payload);
-
-/*!
- * \brief Get the count of Payloads on a Media Description
- *
- * \param m_line Media Description
- *
- * \returns Number of Attributes
- *
- * \since 15
- */
-int ast_sdp_m_get_payload_count(const struct ast_sdp_m_line *m_line);
-
-/*!
- * \brief Get a Payload from a Media Description
- *
- * \param m_line Media Description
- * \param index Payload index
- *
- * \retval non-NULL Success
- * \retval NULL Failure
- *
- * \since 15
- */
-struct ast_sdp_payload *ast_sdp_m_get_payload(const struct ast_sdp_m_line *m_line, int index);
-
-/*!
- * \brief Add a Format to a Media Description
- *
- * \param m_line Media Description
- * \param options SDP Options
- * \param rtp_code rtp_code from ast_rtp_codecs_payload_code
- * \param asterisk_format True if the value in format is to be used.
- * \param format Format
- * \param code from AST_RTP list
- *
- * \retval 0 Success
- * \retval non-0 Failure
- *
- * \since 15
- */
-int ast_sdp_m_add_format(struct ast_sdp_m_line *m_line, const struct ast_sdp_options *options,
-	int rtp_code, int asterisk_format, const struct ast_format *format, int code);
-
-/*!
- * \brief Create an SDP
- *
- * \param o_line Origin
- * \param c_line Connection
- * \param s_line Session
- * \param t_line Timing
- *
- * \retval non-NULL Success
- * \retval NULL Failure
- *
- * \since 15
- */
-struct ast_sdp *ast_sdp_alloc(struct ast_sdp_o_line *o_line,
-	struct ast_sdp_c_line *c_line, struct ast_sdp_s_line *s_line,
-	struct ast_sdp_t_line *t_line);
-
-/*!
- * \brief Find the first attribute match index in 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 index of attribute line on success.
- * \retval -1 on failure or not found.
- *
- * \since 15.0.0
- */
-int ast_sdp_find_a_first(const struct ast_sdp *sdp, const char *attr_name, int payload);
-
-/*!
- * \brief Find the next attribute match index in the top-level SDP
- *
- * \note This will not search within streams for the given attribute.
- *
- * \param sdp The SDP in which to search
- * \param last The last matching index found
- * \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 index of attribute line on success.
- * \retval -1 on failure or not found.
- *
- * \since 15.0.0
- */
-int ast_sdp_find_a_next(const struct ast_sdp *sdp, int last, const char *attr_name, int payload);
-
-/*!
- * \brief Find an attribute in 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 the first attribute match index in an SDP stream (m-line)
- *
- * \param m_line The SDP m-line 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 index of attribute line on success.
- * \retval -1 on failure or not found.
- *
- * \since 15.0.0
- */
-int ast_sdp_m_find_a_first(const struct ast_sdp_m_line *m_line, const char *attr_name,
-	int payload);
-
-/*!
- * \brief Find the next attribute match index in an SDP stream (m-line)
- *
- * \param m_line The SDP m-line in which to search
- * \param last The last matching index found
- * \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 index of attribute line on success.
- * \retval -1 on failure or not found.
- *
- * \since 15.0.0
- */
-int ast_sdp_m_find_a_next(const struct ast_sdp_m_line *m_line, int last,
-	const char *attr_name, int payload);
-
-/*!
- * \brief Find an attribute in an SDP stream (m-line)
- *
- * \param m_line The SDP m-line 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
- *
- * \since 15.0.0
- */
-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
- * \param g726_non_standard Non-zero if G.726 is non-standard
- *
- * \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, int g726_non_standard);
-#endif /* _SDP_PRIV_H */
diff --git a/include/asterisk/sdp_options.h b/include/asterisk/sdp_options.h
deleted file mode 100644
index b8c1bbd..0000000
--- a/include/asterisk/sdp_options.h
+++ /dev/null
@@ -1,550 +0,0 @@
-/*
- * 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
-
-#include "asterisk/udptl.h"
-
-struct ast_sdp_options;
-
-/*!
- * \brief SDP DTMF mode options
- */
-enum ast_sdp_options_dtmf {
-	/*! No DTMF to be used */
-	AST_SDP_DTMF_NONE,
-	/*! Use RFC 4733 events for DTMF */
-	AST_SDP_DTMF_RFC_4733,
-	/*! Use DTMF in the audio stream */
-	AST_SDP_DTMF_INBAND,
-	/*! Use SIP 4733 if supported by the other side or INBAND if not */
-	AST_SDP_DTMF_AUTO,
-};
-
-/*!
- * \brief ICE options
- *
- * This is an enum because it will support a TRICKLE-ICE option
- * in the future.
- */
-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,
-};
-
-/*!
- * \brief Implementation of the SDP
- *
- * Users of the SDP API set the implementation 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_impl {
-	/*! SDP is represented as a string */
-	AST_SDP_IMPL_STRING,
-	/*! SDP is represented as a pjmedia_sdp_session */
-	AST_SDP_IMPL_PJMEDIA,
-	/*! End of the list */
-	AST_SDP_IMPL_END,
-};
-
-/*!
- * \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 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);
-
-/*!
- * \since 15.0.0
- * \brief Set SDP Options media_address
- *
- * \param options SDP Options
- * \param media_address
- */
-void ast_sdp_options_set_media_address(struct ast_sdp_options *options,
-	const char *media_address);
-
-/*!
- * \since 15.0.0
- * \brief Get SDP Options media_address
- *
- * \param options SDP Options
- *
- * \returns media_address
- */
-const char *ast_sdp_options_get_media_address(const struct ast_sdp_options *options);
-
-/*!
- * \since 15.0.0
- * \brief Set SDP Options interface_address
- *
- * \param options SDP Options
- * \param interface_address
- */
-void ast_sdp_options_set_interface_address(struct ast_sdp_options *options,
-	const char *interface_address);
-
-/*!
- * \since 15.0.0
- * \brief Get SDP Options interface_address
- *
- * \param options SDP Options
- *
- * \returns interface_address
- */
-const char *ast_sdp_options_get_interface_address(const struct ast_sdp_options *options);
-
-/*!
- * \since 15.0.0
- * \brief Set SDP Options sdpowner
- *
- * \param options SDP Options
- * \param sdpowner
- */
-void ast_sdp_options_set_sdpowner(struct ast_sdp_options *options,
-	const char *sdpowner);
-
-/*!
- * \since 15.0.0
- * \brief Get SDP Options sdpowner
- *
- * \param options SDP Options
- *
- * \returns sdpowner
- */
-const char *ast_sdp_options_get_sdpowner(const struct ast_sdp_options *options);
-
-/*!
- * \since 15.0.0
- * \brief Set SDP Options sdpsession
- *
- * \param options SDP Options
- * \param sdpsession
- */
-void ast_sdp_options_set_sdpsession(struct ast_sdp_options *options,
-	const char *sdpsession);
-
-/*!
- * \since 15.0.0
- * \brief Get SDP Options sdpsession
- *
- * \param options SDP Options
- *
- * \returns sdpsession
- */
-const char *ast_sdp_options_get_sdpsession(const struct ast_sdp_options *options);
-
-/*!
- * \since 15.0.0
- * \brief Set SDP Options rtp_engine
- *
- * \param options SDP Options
- * \param rtp_engine
- */
-void ast_sdp_options_set_rtp_engine(struct ast_sdp_options *options,
-	const char *rtp_engine);
-
-/*!
- * \since 15.0.0
- * \brief Get SDP Options rtp_engine
- *
- * \param options SDP Options
- *
- * \returns rtp_engine
- */
-const char *ast_sdp_options_get_rtp_engine(const struct ast_sdp_options *options);
-
-/*!
- * \since 15.0.0
- * \brief Set SDP Options rtp_symmetric
- *
- * \param options SDP Options
- * \param rtp_symmetric
- */
-void ast_sdp_options_set_rtp_symmetric(struct ast_sdp_options *options,
-	unsigned int rtp_symmetric);
-
-/*!
- * \since 15.0.0
- * \brief Get SDP Options rtp_symmetric
- *
- * \param options SDP Options
- *
- * \returns rtp_symmetric
- */
-unsigned int ast_sdp_options_get_rtp_symmetric(const struct ast_sdp_options *options);
-
-/*!
- * \since 15.0.0
- * \brief Set SDP Options rtp_ipv6
- *
- * \param options SDP Options
- * \param rtp_ipv6
- */
-void ast_sdp_options_set_rtp_ipv6(struct ast_sdp_options *options,
-	unsigned int rtp_ipv6);
-
-/*!
- * \since 15.0.0
- * \brief Get SDP Options rtp_ipv6
- *
- * \param options SDP Options
- *
- * \returns rtp_ipv6
- */
-unsigned int ast_sdp_options_get_rtp_ipv6(const struct ast_sdp_options *options);
-
-/*!
- * \since 15.0.0
- * \brief Set SDP Options g726_non_standard
- *
- * \param options SDP Options
- * \param g726_non_standard
- */
-void ast_sdp_options_set_g726_non_standard(struct ast_sdp_options *options,
-	unsigned int g726_non_standard);
-
-/*!
- * \since 15.0.0
- * \brief Get SDP Options g726_non_standard
- *
- * \param options SDP Options
- *
- * \returns g726_non_standard
- */
-unsigned int ast_sdp_options_get_g726_non_standard(const struct ast_sdp_options *options);
-
-/*!
- * \since 15.0.0
- * \brief Set SDP Options tos_audio
- *
- * \param options SDP Options
- * \param tos_audio
- */
-void ast_sdp_options_set_tos_audio(struct ast_sdp_options *options,
-	unsigned int tos_audio);
-
-/*!
- * \since 15.0.0
- * \brief Get SDP Options tos_audio
- *
- * \param options SDP Options
- *
- * \returns tos_audio
- */
-unsigned int ast_sdp_options_get_tos_audio(const struct ast_sdp_options *options);
-
-/*!
- * \since 15.0.0
- * \brief Set SDP Options cos_audio
- *
- * \param options SDP Options
- * \param cos_audio
- */
-void ast_sdp_options_set_cos_audio(struct ast_sdp_options *options,
-	unsigned int cos_audio);
-
-/*!
- * \since 15.0.0
- * \brief Get SDP Options cos_audio
- *
- * \param options SDP Options
- *
- * \returns cos_audio
- */
-unsigned int ast_sdp_options_get_cos_audio(const struct ast_sdp_options *options);
-
-/*!
- * \since 15.0.0
- * \brief Set SDP Options tos_video
- *
- * \param options SDP Options
- * \param tos_video
- */
-void ast_sdp_options_set_tos_video(struct ast_sdp_options *options,
-	unsigned int tos_video);
-
-/*!
- * \since 15.0.0
- * \brief Get SDP Options tos_video
- *
- * \param options SDP Options
- *
- * \returns tos_video
- */
-unsigned int ast_sdp_options_get_tos_video(const struct ast_sdp_options *options);
-
-/*!
- * \since 15.0.0
- * \brief Set SDP Options cos_video
- *
- * \param options SDP Options
- * \param cos_video
- */
-void ast_sdp_options_set_cos_video(struct ast_sdp_options *options,
-	unsigned int cos_video);
-
-/*!
- * \since 15.0.0
- * \brief Get SDP Options cos_video
- *
- * \param options SDP Options
- *
- * \returns cos_video
- */
-unsigned int ast_sdp_options_get_cos_video(const struct ast_sdp_options *options);
-
-/*!
- * \since 15.0.0
- * \brief Set SDP Options dtmf
- *
- * \param options SDP Options
- * \param dtmf
- */
-void ast_sdp_options_set_dtmf(struct ast_sdp_options *options,
-	enum ast_sdp_options_dtmf dtmf);
-
-/*!
- * \since 15.0.0
- * \brief Get SDP Options dtmf
- *
- * \param options SDP Options
- *
- * \returns dtmf
- */
-enum ast_sdp_options_dtmf ast_sdp_options_get_dtmf(const struct ast_sdp_options *options);
-
-/*!
- * \since 15.0.0
- * \brief Set SDP Options ice
- *
- * \param options SDP Options
- * \param ice
- */
-void ast_sdp_options_set_ice(struct ast_sdp_options *options,
-	enum ast_sdp_options_ice ice);
-
-/*!
- * \since 15.0.0
- * \brief Get SDP Options ice
- *
- * \param options SDP Options
- *
- * \returns ice
- */
-enum ast_sdp_options_ice ast_sdp_options_get_ice(const struct ast_sdp_options *options);
-
-/*!
- * \since 15.0.0
- * \brief Set SDP Options impl
- *
- * \param options SDP Options
- * \param impl
- */
-void ast_sdp_options_set_impl(struct ast_sdp_options *options,
-	enum ast_sdp_options_impl impl);
-
-/*!
- * \since 15.0.0
- * \brief Get SDP Options impl
- *
- * \param options SDP Options
- *
- * \returns impl
- */
-enum ast_sdp_options_impl ast_sdp_options_get_impl(const struct ast_sdp_options *options);
-
-/*!
- * \since 15.0.0
- * \brief Set SDP Options encryption
- *
- * \param options SDP Options
- * \param encryption
- */
-void ast_sdp_options_set_encryption(struct ast_sdp_options *options,
-	enum ast_sdp_options_encryption encryption);
-
-/*!
- * \since 15.0.0
- * \brief Get SDP Options encryption
- *
- * \param options SDP Options
- *
- * \returns encryption
- */
-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 Enable setting SSRC level attributes on SDPs
- *
- * \param options SDP Options
- * \param ssrc Boolean indicating if SSRC attributes should be included in generated SDPs
- */
-void ast_sdp_options_set_ssrc(struct ast_sdp_options *options, unsigned int ssrc);
-
-/*!
- * \since 15.0.0
- * \brief Get SDP Options ssrc
- *
- * \param options SDP Options
- *
- * \returns Whether SSRC-level attributes will be added to our SDP.
- */
-unsigned int ast_sdp_options_get_ssrc(const struct ast_sdp_options *options);
-
-/*!
- * \brief Set the SDP options scheduler context used to create new streams of the type.
- * \since 15.0.0
- *
- * \param options SDP Options
- * \param type Media type the scheduler context is for.
- * \param sched Scheduler context to use for the specified media type.
- *
- * \return Nothing
- */
-void ast_sdp_options_set_sched_type(struct ast_sdp_options *options,
-	enum ast_media_type type, struct ast_sched_context *sched);
-
-/*!
- * \brief Get the SDP options scheduler context used to create new streams of the type.
- * \since 15.0.0
- *
- * \param options SDP Options
- * \param type Media type the format cap represents.
- *
- * \return The stored scheduler context to create new streams of the type.
- */
-struct ast_sched_context *ast_sdp_options_get_sched_type(const struct ast_sdp_options *options,
-	enum ast_media_type type);
-
-#endif /* _ASTERISK_SDP_OPTIONS_H */
diff --git a/include/asterisk/sdp_state.h b/include/asterisk/sdp_state.h
deleted file mode 100644
index b8209e1..0000000
--- a/include/asterisk/sdp_state.h
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * 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_STATE_H
-#define _ASTERISK_SDP_STATE_H
-
-#include "asterisk/stream.h"
-#include "asterisk/sdp_options.h"
-
-struct ast_sdp_state;
-struct ast_sockaddr;
-struct ast_udptl;
-struct ast_control_t38_parameters;
-
-/*!
- * \brief Allocate a new SDP state
- *
- * SDP state keeps tabs on everything SDP-related for a media session.
- * Most SDP operations will require the state to be provided.
- * Ownership of the SDP options is taken on by the SDP state.
- * A good strategy is to call this during session creation.
- */
-struct ast_sdp_state *ast_sdp_state_alloc(struct ast_stream_topology *streams,
-	struct ast_sdp_options *options);
-
-/*!
- * \brief Free the SDP state.
- *
- * A good strategy is to call this during session destruction
- */
-void ast_sdp_state_free(struct ast_sdp_state *sdp_state);
-
-/*!
- * \brief Get the associated RTP instance for a particular stream on the SDP state.
- *
- * Stream numbers correspond to the streams in the topology of the associated channel
- */
-struct ast_rtp_instance *ast_sdp_state_get_rtp_instance(const struct ast_sdp_state *sdp_state,
-	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);
-
-/*!
- * \brief Get the connection address for a particular stream.
- *
- * \param sdp_state
- * \param stream_index The particular stream to get the connection address of
- * \param address[out] A place to store the address in
- *
- * \retval 0 Success
- *
- * \note
- * Stream numbers correspond to the streams in the topology of the associated channel
- */
-int ast_sdp_state_get_stream_connection_address(const struct ast_sdp_state *sdp_state,
-	int stream_index, struct ast_sockaddr *address);
-
-/*!
- * \brief Get the joint negotiated streams based on local and remote capabilities.
- *
- * If this is called prior to receiving a remote SDP, then this will just mirror
- * the local configured endpoint capabilities.
- */
-const struct ast_stream_topology *ast_sdp_state_get_joint_topology(
-	const struct ast_sdp_state *sdp_state);
-
-/*!
- * \brief Get the local topology
- *
- */
-const struct ast_stream_topology *ast_sdp_state_get_local_topology(
-	const struct ast_sdp_state *sdp_state);
-
-/*!
- * \brief Get the sdp_state options
- *
- */
-const struct ast_sdp_options *ast_sdp_state_get_options(
-	const struct ast_sdp_state *sdp_state);
-
-
-/*!
- * \brief Get the local SDP.
- *
- * \param sdp_state
- *
- * \retval non-NULL Success
- * \retval NULL Failure
- *
- * \note
- * This function will allocate a new SDP with RTP instances if it has not already
- * been allocated.
- *
- */
-const struct ast_sdp *ast_sdp_state_get_local_sdp(struct ast_sdp_state *sdp_state);
-
-/*!
- * \brief Get the local SDP Implementation.
- *
- * \param sdp_state
- *
- * \retval non-NULL Success
- * \retval NULL Failure
- *
- * \note
- * This function calls ast_sdp_state_get_local_sdp then translates it into
- * the defined implementation.
- *
- * The return here is const. The use case for this is so that a channel can add
- * the SDP to an outgoing message. The API user should not attempt to modify the SDP.
- * SDP modification should only be done through the API.
- *
- * \since 15
- */
-const void *ast_sdp_state_get_local_sdp_impl(struct ast_sdp_state *sdp_state);
-
-/*!
- * \brief Set the remote SDP
- *
- * \param sdp_state
- * \param sdp
- *
- * \note It is assumed that the passed in SDP has been checked for sanity
- * already.  e.g., There are no syntax errors, a c= line is reachable for
- * each m= line, etc...
- *
- * \retval 0 Success
- * \retval non-0 Failure
- *
- * \since 15
- */
-int 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
- *
- * \param sdp_state
- * \param remote The implementation's representation of an SDP.
- *
- * \retval 0 Success
- * \retval non-0 Failure
- *
- * \since 15
- */
-int ast_sdp_state_set_remote_sdp_from_impl(struct ast_sdp_state *sdp_state, const void *remote);
-
-/*!
- * \brief Reset the SDP state and stream capabilities as if the SDP state had just been allocated.
- *
- * \param sdp_state
- * \param remote The implementation's representation of an SDP.
- *
- * \retval 0 Success
- *
- * \note
- * This is most useful for when a channel driver is sending a session refresh message
- * and needs to re-advertise its initial capabilities instead of the previously-negotiated
- * joint capabilities.
- *
- * \since 15
- */
-int ast_sdp_state_reset(struct ast_sdp_state *sdp_state);
-
-/*!
- * \brief Update the local stream topology on the SDP state.
- *
- * \param sdp_state
- * \param streams The new stream topology.
- *
- * \retval 0 Success
- *
- * \since 15
- */
-int ast_sdp_state_update_local_topology(struct ast_sdp_state *sdp_state, struct ast_stream_topology *streams);
-
-/*!
- * \brief Set the local address (IP address) to use for connection addresses
- *
- * \param sdp_state
- * \param address The local address
- *
- * \note
- * Passing NULL as an address will unset the explicit local connection address.
- *
- * \since 15
- */
-void ast_sdp_state_set_local_address(struct ast_sdp_state *sdp_state, struct ast_sockaddr *address);
-
-/*!
- * \brief Set the connection address (IP address and port) to use for a specific stream
- *
- * \param sdp_state
- * \param stream_index The stream to set the connection address for
- * \param address The connection address
- *
- * \retval 0 Success
- *
- * \note
- * Passing NULL as an address will unset the explicit local connection address.
- *
- * \since 15
- */
-int ast_sdp_state_set_connection_address(struct ast_sdp_state *sdp_state, int stream_index,
-	struct ast_sockaddr *address);
-
-/*!
- * \since 15.0.0
- * \brief Set a stream to be held or unheld
- *
- * \param sdp_state
- * \param stream_index The stream to set the held value for
- * \param locally_held
- */
-void ast_sdp_state_set_locally_held(struct ast_sdp_state *sdp_state,
-	int stream_index, unsigned int locally_held);
-
-/*!
- * \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
- * \param stream_index The stream to get the held state for
- *
- * \returns locally_held
- */
-unsigned int ast_sdp_state_get_locally_held(const struct ast_sdp_state *sdp_state,
-	int stream_index);
-
-#endif /* _ASTERISK_SDP_STATE_H */
diff --git a/include/asterisk/sdp_translator.h b/include/asterisk/sdp_translator.h
deleted file mode 100644
index e1d51f0..0000000
--- a/include/asterisk/sdp_translator.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * 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_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_impl 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)(const void *repr_sdp, void *translator_priv);
-	/*! Convert an internal Asterisk SDP into a channel-native SDP */
-	const void *(*from_sdp)(const 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_impl 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, const 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
- */
-const void *ast_sdp_translator_from_sdp(struct ast_sdp_translator *translator,
-	const struct ast_sdp *ast_sdp);
-
-#endif /* _ASTERISK_SDP_TRANSLATOR_H */
diff --git a/main/sdp.c b/main/sdp.c
deleted file mode 100644
index 010f9d9..0000000
--- a/main/sdp.c
+++ /dev/null
@@ -1,880 +0,0 @@
-/*
- * Asterisk -- An open source telephony toolkit.
- *
- * Copyright (C) 2017, Digium, Inc.
- *
- * George Joseph <gjoseph 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/netsock2.h"
-#include "asterisk/codec.h"
-#include "asterisk/format.h"
-#include "asterisk/format_cap.h"
-#include "asterisk/format_cache.h"
-#include "asterisk/rtp_engine.h"
-#include "asterisk/sdp_state.h"
-#include "asterisk/sdp_options.h"
-#include "asterisk/sdp_translator.h"
-#include "asterisk/sdp.h"
-#include "asterisk/vector.h"
-#include "asterisk/utils.h"
-#include "asterisk/stream.h"
-#include "sdp_private.h"
-
-void ast_sdp_a_free(struct ast_sdp_a_line *a_line)
-{
-	ast_free(a_line);
-}
-
-void ast_sdp_a_lines_free(struct ast_sdp_a_lines *a_lines)
-{
-	if (!a_lines) {
-		return;
-	}
-
-	AST_VECTOR_CALLBACK_VOID(a_lines, ast_sdp_a_free);
-	AST_VECTOR_FREE(a_lines);
-	ast_free(a_lines);
-}
-
-void ast_sdp_c_free(struct ast_sdp_c_line *c_line)
-{
-	ast_free(c_line);
-}
-
-void ast_sdp_payload_free(struct ast_sdp_payload *payload)
-{
-	ast_free(payload);
-}
-
-void ast_sdp_payloads_free(struct ast_sdp_payloads *payloads)
-{
-	if (!payloads) {
-		return;
-	}
-
-	AST_VECTOR_CALLBACK_VOID(payloads, ast_sdp_payload_free);
-	AST_VECTOR_FREE(payloads);
-	ast_free(payloads);
-}
-
-void ast_sdp_m_free(struct ast_sdp_m_line *m_line)
-{
-	if (!m_line) {
-		return;
-	}
-
-	ast_sdp_a_lines_free(m_line->a_lines);
-	ast_sdp_payloads_free(m_line->payloads);
-	ast_sdp_c_free(m_line->c_line);
-	ast_free(m_line);
-}
-
-void ast_sdp_m_lines_free(struct ast_sdp_m_lines *m_lines)
-{
-	if (!m_lines) {
-		return;
-	}
-
-	AST_VECTOR_CALLBACK_VOID(m_lines, ast_sdp_m_free);
-	AST_VECTOR_FREE(m_lines);
-	ast_free(m_lines);
-}
-
-void ast_sdp_o_free(struct ast_sdp_o_line *o_line)
-{
-	ast_free(o_line);
-}
-
-void ast_sdp_s_free(struct ast_sdp_s_line *s_line)
-{
-	ast_free(s_line);
-}
-
-void ast_sdp_t_free(struct ast_sdp_t_line *t_line)
-{
-	ast_free(t_line);
-}
-
-void ast_sdp_free(struct ast_sdp *sdp)
-{
-	if (!sdp) {
-		return;
-	}
-
-	ast_sdp_o_free(sdp->o_line);
-	ast_sdp_s_free(sdp->s_line);
-	ast_sdp_c_free(sdp->c_line);
-	ast_sdp_t_free(sdp->t_line);
-	ast_sdp_a_lines_free(sdp->a_lines);
-	ast_sdp_m_lines_free(sdp->m_lines);
-	ast_free(sdp);
-}
-
-#define COPY_STR_AND_ADVANCE(p, dest, source) \
-({ \
-	dest = p; \
-	strcpy(dest, source); \
-	p += (strlen(source) + 1); \
-})
-
-struct ast_sdp_a_line *ast_sdp_a_alloc(const char *name, const char *value)
-{
-	struct ast_sdp_a_line *a_line;
-	size_t len;
-	char *p;
-
-	ast_assert(!ast_strlen_zero(name));
-
-	if (ast_strlen_zero(value)) {
-		value = "";
-	}
-
-	len = sizeof(*a_line) + strlen(name) + strlen(value) + 2;
-	a_line = ast_calloc(1, len);
-	if (!a_line) {
-		return NULL;
-	}
-
-	p = ((char *)a_line) + sizeof(*a_line);
-
-	COPY_STR_AND_ADVANCE(p, a_line->name, name);
-	COPY_STR_AND_ADVANCE(p, a_line->value, value);
-
-	return a_line;
-}
-
-struct ast_sdp_c_line *ast_sdp_c_alloc(const char *address_type, const char *address)
-{
-	struct ast_sdp_c_line *c_line;
-	size_t len;
-	char *p;
-
-	ast_assert(!ast_strlen_zero(address_type) && !ast_strlen_zero(address));
-
-	len = sizeof(*c_line) + strlen(address_type) + strlen(address) + 2;
-	c_line = ast_calloc(1, len);
-	if (!c_line) {
-		return NULL;
-	}
-
-	p = ((char *)c_line) + sizeof(*c_line);
-
-	COPY_STR_AND_ADVANCE(p, c_line->address_type, address_type);
-	COPY_STR_AND_ADVANCE(p, c_line->address, address);
-
-	return c_line;
-}
-
-struct ast_sdp_payload *ast_sdp_payload_alloc(const char *fmt)
-{
-	struct ast_sdp_payload *payload;
-	size_t len;
-
-	ast_assert(!ast_strlen_zero(fmt));
-
-	len = sizeof(*payload) + strlen(fmt) + 1;
-	payload = ast_calloc(1, len);
-	if (!payload) {
-		return NULL;
-	}
-
-	payload->fmt = ((char *)payload) + sizeof(*payload);
-	strcpy(payload->fmt, fmt);  /* Safe */
-
-	return payload;
-}
-
-struct ast_sdp_m_line *ast_sdp_m_alloc(const char *type, uint16_t port,
-	uint16_t port_count, const char *proto, struct ast_sdp_c_line *c_line)
-{
-	struct ast_sdp_m_line *m_line;
-	size_t len;
-	char *p;
-
-	ast_assert(!ast_strlen_zero(type) && !ast_strlen_zero(proto));
-
-	len = sizeof(*m_line) + strlen(type) + strlen(proto) + 2;
-	m_line = ast_calloc(1, len);
-	if (!m_line) {
-		return NULL;
-	}
-
-	m_line->a_lines = ast_calloc(1, sizeof(*m_line->a_lines));
-	if (!m_line->a_lines) {
-		ast_sdp_m_free(m_line);
-		return NULL;
-	}
-	if (AST_VECTOR_INIT(m_line->a_lines, 20)) {
-		ast_sdp_m_free(m_line);
-		return NULL;
-	}
-
-	m_line->payloads = ast_calloc(1, sizeof(*m_line->payloads));
-	if (!m_line->payloads) {
-		ast_sdp_m_free(m_line);
-		return NULL;
-	}
-	if (AST_VECTOR_INIT(m_line->payloads, 20)) {
-		ast_sdp_m_free(m_line);
-		return NULL;
-	}
-
-	p = ((char *)m_line) + sizeof(*m_line);
-
-	COPY_STR_AND_ADVANCE(p, m_line->type, type);
-	COPY_STR_AND_ADVANCE(p, m_line->proto, proto);
-	m_line->port = port;
-	m_line->port_count = port_count;
-	m_line->c_line = c_line;
-
-	return m_line;
-}
-
-struct ast_sdp_s_line *ast_sdp_s_alloc(const char *session_name)
-{
-	struct ast_sdp_s_line *s_line;
-	size_t len;
-
-	if (ast_strlen_zero(session_name)) {
-		session_name = " ";
-	}
-
-	len = sizeof(*s_line) + strlen(session_name) + 1;
-	s_line = ast_calloc(1, len);
-	if (!s_line) {
-		return NULL;
-	}
-
-	s_line->session_name = ((char *)s_line) + sizeof(*s_line);
-	strcpy(s_line->session_name, session_name);  /* Safe */
-
-	return s_line;
-}
-
-struct ast_sdp_t_line *ast_sdp_t_alloc(uint64_t start_time, uint64_t stop_time)
-{
-	struct ast_sdp_t_line *t_line;
-
-	t_line = ast_calloc(1, sizeof(*t_line));
-	if (!t_line) {
-		return NULL;
-	}
-
-	t_line->start_time = start_time;
-	t_line->stop_time = stop_time;
-
-	return t_line;
-}
-
-struct ast_sdp_o_line *ast_sdp_o_alloc(const char *username, uint64_t session_id,
-	uint64_t session_version, const char *address_type, const char *address)
-{
-	struct ast_sdp_o_line *o_line;
-	size_t len;
-	char *p;
-
-	ast_assert(!ast_strlen_zero(username) && !ast_strlen_zero(address_type)
-		&& !ast_strlen_zero(address));
-
-	len = sizeof(*o_line) + strlen(username) + strlen(address_type) + strlen(address) + 3;
-	o_line = ast_calloc(1, len);
-	if (!o_line) {
-		return NULL;
-	}
-
-	o_line->session_id = session_id;
-	o_line->session_version = session_version;
-
-	p = ((char *)o_line) + sizeof(*o_line);
-
-	COPY_STR_AND_ADVANCE(p, o_line->username, username);
-	COPY_STR_AND_ADVANCE(p, o_line->address_type, address_type);
-	COPY_STR_AND_ADVANCE(p, o_line->address, address);
-
-	return o_line;
-}
-
-struct ast_sdp *ast_sdp_alloc(struct ast_sdp_o_line *o_line,
-	struct ast_sdp_c_line *c_line, struct ast_sdp_s_line *s_line,
-	struct ast_sdp_t_line *t_line)
-{
-	struct ast_sdp *new_sdp;
-
-	new_sdp = ast_calloc(1, sizeof *new_sdp);
-	if (!new_sdp) {
-		return NULL;
-	}
-
-	new_sdp->a_lines = ast_calloc(1, sizeof(*new_sdp->a_lines));
-	if (!new_sdp->a_lines) {
-		ast_sdp_free(new_sdp);
-		return NULL;
-	}
-	if (AST_VECTOR_INIT(new_sdp->a_lines, 20)) {
-		ast_sdp_free(new_sdp);
-		return NULL;
-	}
-
-	new_sdp->m_lines = ast_calloc(1, sizeof(*new_sdp->m_lines));
-	if (!new_sdp->m_lines) {
-		ast_sdp_free(new_sdp);
-		return NULL;
-	}
-	if (AST_VECTOR_INIT(new_sdp->m_lines, 20)) {
-		ast_sdp_free(new_sdp);
-		return NULL;
-	}
-
-	new_sdp->o_line = o_line;
-	new_sdp->c_line = c_line;
-	new_sdp->s_line = s_line;
-	new_sdp->t_line = t_line;
-
-	return new_sdp;
-}
-
-int ast_sdp_add_a(struct ast_sdp *sdp, struct ast_sdp_a_line *a_line)
-{
-	ast_assert(sdp && a_line);
-
-	return AST_VECTOR_APPEND(sdp->a_lines, a_line);
-}
-
-int ast_sdp_get_a_count(const struct ast_sdp *sdp)
-{
-	ast_assert(sdp != NULL);
-
-	return AST_VECTOR_SIZE(sdp->a_lines);
-}
-
-struct ast_sdp_a_line *ast_sdp_get_a(const struct ast_sdp *sdp, int index)
-{
-	ast_assert(sdp != NULL);
-
-	return AST_VECTOR_GET(sdp->a_lines, index);
-}
-
-int ast_sdp_add_m(struct ast_sdp *sdp, struct ast_sdp_m_line *m_line)
-{
-	ast_assert(sdp && m_line);
-
-	return AST_VECTOR_APPEND(sdp->m_lines, m_line);
-}
-
-int ast_sdp_get_m_count(const struct ast_sdp *sdp)
-{
-	ast_assert(sdp != NULL);
-
-	return AST_VECTOR_SIZE(sdp->m_lines);
-}
-
-struct ast_sdp_m_line *ast_sdp_get_m(const struct ast_sdp *sdp, int index)
-{
-	ast_assert(sdp != NULL);
-
-	return AST_VECTOR_GET(sdp->m_lines, index);
-}
-
-int ast_sdp_m_add_a(struct ast_sdp_m_line *m_line, struct ast_sdp_a_line *a_line)
-{
-	ast_assert(m_line && a_line);
-
-	return AST_VECTOR_APPEND(m_line->a_lines, a_line);
-}
-
-int ast_sdp_m_get_a_count(const struct ast_sdp_m_line *m_line)
-{
-	ast_assert(m_line != NULL);
-
-	return AST_VECTOR_SIZE(m_line->a_lines);
-}
-
-struct ast_sdp_a_line *ast_sdp_m_get_a(const struct ast_sdp_m_line *m_line, int index)
-{
-	ast_assert(m_line != NULL);
-
-	return AST_VECTOR_GET(m_line->a_lines, index);
-}
-
-int ast_sdp_m_add_payload(struct ast_sdp_m_line *m_line, struct ast_sdp_payload *payload)
-{
-	ast_assert(m_line && payload);
-
-	return AST_VECTOR_APPEND(m_line->payloads, payload);
-}
-
-int ast_sdp_m_get_payload_count(const struct ast_sdp_m_line *m_line)
-{
-	ast_assert(m_line != NULL);
-
-	return AST_VECTOR_SIZE(m_line->payloads);
-}
-
-struct ast_sdp_payload *ast_sdp_m_get_payload(const struct ast_sdp_m_line *m_line, int index)
-{
-	ast_assert(m_line != NULL);
-
-	return AST_VECTOR_GET(m_line->payloads, index);
-}
-
-static int sdp_m_add_fmtp(struct ast_sdp_m_line *m_line, const struct ast_format *format,
-	int rtp_code)
-{
-	struct ast_str *fmtp0 = ast_str_alloca(256);
-	struct ast_sdp_a_line *a_line;
-	char *tmp;
-
-	ast_format_generate_sdp_fmtp(format, rtp_code, &fmtp0);
-	if (ast_str_strlen(fmtp0) == 0) {
-		/* Format doesn't have fmtp attributes */
-		return 0;
-	}
-
-	tmp = ast_str_buffer(fmtp0) + ast_str_strlen(fmtp0) - 1;
-	/* remove any carriage return line feeds */
-	while (*tmp == '\r' || *tmp == '\n') --tmp;
-	*++tmp = '\0';
-
-	/*
-	 * ast...generate gives us everything, just need value
-	 *
-	 * It can also give multiple fmtp attribute lines. (silk does)
-	 */
-	tmp = strchr(ast_str_buffer(fmtp0), ':');
-	if (tmp && tmp[1] != '\0') {
-		tmp++;
-	} else {
-		tmp = ast_str_buffer(fmtp0);
-	}
-
-	a_line = ast_sdp_a_alloc("fmtp", tmp);
-	if (!a_line || ast_sdp_m_add_a(m_line, a_line)) {
-		return -1;
-	}
-
-	return 0;
-}
-
-static int sdp_m_add_rtpmap(struct ast_sdp_m_line *m_line,
-	const struct ast_sdp_options *options, int rtp_code, int asterisk_format,
-	const struct ast_format *format, int code)
-{
-	char tmp[64];
-	const char *enc_name;
-	struct ast_sdp_payload *payload;
-	struct ast_sdp_a_line *a_line;
-
-	snprintf(tmp, sizeof(tmp), "%d", rtp_code);
-	payload = ast_sdp_payload_alloc(tmp);
-	if (!payload || ast_sdp_m_add_payload(m_line, payload)) {
-		ast_sdp_payload_free(payload);
-		return -1;
-	}
-
-	enc_name = ast_rtp_lookup_mime_subtype2(asterisk_format, format, code,
-		options->g726_non_standard ? AST_RTP_OPT_G726_NONSTANDARD : 0);
-
-	snprintf(tmp, sizeof(tmp), "%d %s/%d%s%s", rtp_code, enc_name,
-		ast_rtp_lookup_sample_rate2(asterisk_format, format, code),
-		strcmp(enc_name, "opus") ? "" : "/", strcmp(enc_name, "opus") ? "" : "2");
-
-	a_line = ast_sdp_a_alloc("rtpmap", tmp);
-	if (!a_line || ast_sdp_m_add_a(m_line, a_line)) {
-		ast_sdp_a_free(a_line);
-		return -1;
-	}
-
-	return 0;
-}
-
-int ast_sdp_m_add_format(struct ast_sdp_m_line *m_line, const struct ast_sdp_options *options,
-	int rtp_code, int asterisk_format, const struct ast_format *format, int code)
-{
-	return sdp_m_add_rtpmap(m_line, options, rtp_code, asterisk_format, format, code)
-		|| sdp_m_add_fmtp(m_line, format, rtp_code) ? -1 : 0;
-}
-
-static int sdp_find_a_common(const struct ast_sdp_a_lines *a_lines, int start,
-	const char *attr_name, int payload)
-{
-	struct ast_sdp_a_line *a_line;
-	int idx;
-
-	ast_assert(-1 <= start);
-
-	for (idx = start + 1; idx < AST_VECTOR_SIZE(a_lines); ++idx) {
-		int a_line_payload;
-
-		a_line = AST_VECTOR_GET(a_lines, idx);
-		if (strcmp(a_line->name, attr_name)) {
-			continue;
-		}
-
-		if (payload >= 0) {
-			int sscanf_res;
-
-			sscanf_res = sscanf(a_line->value, "%30d", &a_line_payload);
-			if (sscanf_res == 1 && payload == a_line_payload) {
-				return idx;
-			}
-		} else {
-			return idx;
-		}
-	}
-
-	return -1;
-}
-
-int ast_sdp_find_a_first(const struct ast_sdp *sdp, const char *attr_name, int payload)
-{
-	return sdp_find_a_common(sdp->a_lines, -1, attr_name, payload);
-}
-
-int ast_sdp_find_a_next(const struct ast_sdp *sdp, int last, const char *attr_name, int payload)
-{
-	return sdp_find_a_common(sdp->a_lines, last, attr_name, payload);
-}
-
-struct ast_sdp_a_line *ast_sdp_find_attribute(const struct ast_sdp *sdp,
-	const char *attr_name, int payload)
-{
-	int idx;
-
-	idx = ast_sdp_find_a_first(sdp, attr_name, payload);
-	if (idx < 0) {
-		return NULL;
-	}
-	return ast_sdp_get_a(sdp, idx);
-}
-
-int ast_sdp_m_find_a_first(const struct ast_sdp_m_line *m_line, const char *attr_name,
-	int payload)
-{
-	return sdp_find_a_common(m_line->a_lines, -1, attr_name, payload);
-}
-
-int ast_sdp_m_find_a_next(const struct ast_sdp_m_line *m_line, int last,
-	const char *attr_name, int payload)
-{
-	return sdp_find_a_common(m_line->a_lines, last, attr_name, payload);
-}
-
-struct ast_sdp_a_line *ast_sdp_m_find_attribute(const struct ast_sdp_m_line *m_line,
-	const char *attr_name, int payload)
-{
-	int idx;
-
-	idx = ast_sdp_m_find_a_first(m_line, attr_name, payload);
-	if (idx < 0) {
-		return NULL;
-	}
-	return ast_sdp_m_get_a(m_line, idx);
-}
-
-struct ast_sdp_rtpmap *ast_sdp_rtpmap_alloc(int payload, const char *encoding_name,
-	int clock_rate, const char *encoding_parameters)
-{
-	struct ast_sdp_rtpmap *rtpmap;
-	char *buf_pos;
-
-	rtpmap = ast_calloc(1, sizeof(*rtpmap) + strlen(encoding_name) + strlen(encoding_parameters) + 2);
-	if (!rtpmap) {
-		return NULL;
-	}
-
-	rtpmap->payload = payload;
-	rtpmap->clock_rate = clock_rate;
-
-	buf_pos = rtpmap->buf;
-	COPY_STR_AND_ADVANCE(buf_pos, rtpmap->encoding_name, encoding_name);
-	COPY_STR_AND_ADVANCE(buf_pos, rtpmap->encoding_parameters, encoding_parameters);
-
-	return rtpmap;
-}
-
-void ast_sdp_rtpmap_free(struct ast_sdp_rtpmap *rtpmap)
-{
-	ast_free(rtpmap);
-}
-
-struct ast_sdp_rtpmap *ast_sdp_a_get_rtpmap(const struct ast_sdp_a_line *a_line)
-{
-	char *value_copy;
-	char *slash;
-	int payload;
-	char encoding_name[64];
-	int clock_rate;
-	char *encoding_parameters;
-	struct ast_sdp_rtpmap *rtpmap;
-	int clock_rate_len;
-
-	value_copy = ast_strip(ast_strdupa(a_line->value));
-
-	if (sscanf(value_copy, "%30d %63s", &payload, encoding_name) != 2) {
-		return NULL;
-	}
-
-	slash = strchr(encoding_name, '/');
-	if (!slash) {
-		return NULL;
-	}
-	*slash++ = '\0';
-	if (ast_strlen_zero(encoding_name)) {
-		return NULL;
-	}
-	if (sscanf(slash, "%30d%n", &clock_rate, &clock_rate_len) < 1) {
-		return NULL;
-	}
-
-	slash += clock_rate_len;
-	if (!ast_strlen_zero(slash)) {
-		if (*slash == '/') {
-			*slash++ = '\0';
-			encoding_parameters = slash;
-			if (ast_strlen_zero(encoding_parameters)) {
-				return NULL;
-			}
-		} else {
-			return NULL;
-		}
-	} else {
-		encoding_parameters = "";
-	}
-
-	rtpmap = ast_sdp_rtpmap_alloc(payload, encoding_name, clock_rate,
-		encoding_parameters);
-
-	return rtpmap;
-}
-
-/*!
- * \brief Turn an SDP attribute into an sdp_rtpmap structure
- *
- * \param m_line The media section where this attribute was found.
- * \param payload The RTP payload to find an rtpmap for
- * \param[out] rtpmap The rtpmap to fill in.
- * \return Zero if successful, otherwise less than zero
- */
-static struct ast_sdp_rtpmap *sdp_payload_get_rtpmap(const struct ast_sdp_m_line *m_line, int payload)
-{
-	struct ast_sdp_a_line *rtpmap_attr;
-
-	rtpmap_attr = ast_sdp_m_find_attribute(m_line, "rtpmap", payload);
-	if (!rtpmap_attr) {
-		return NULL;
-	}
-
-	return ast_sdp_a_get_rtpmap(rtpmap_attr);
-}
-
-static void process_fmtp_value(const char *value, int payload, struct ast_rtp_codecs *codecs)
-{
-	char *param;
-	char *param_start;
-	char *param_end;
-	size_t len;
-	struct ast_format *replace;
-	struct ast_format *format;
-
-	/*
-	 * Extract the "a=fmtp:%d %s" attribute parameter string value which
-	 * starts after the colon.
-	 */
-	param_start = ast_skip_nonblanks(value);/* Skip payload type */
-	param_start = ast_skip_blanks(param_start);
-	param_end = ast_skip_nonblanks(param_start);
-	if (param_end == param_start) {
-		/* There is no parameter string */
-		return;
-	}
-	len = param_end - param_start;
-	param = ast_alloca(len + 1);
-	memcpy(param, param_start, len);
-	param[len] = '\0';
-
-	format = ast_rtp_codecs_get_payload_format(codecs, payload);
-	if (!format) {
-		return;
-	}
-
-	replace = ast_format_parse_sdp_fmtp(format, param);
-	if (replace) {
-		ast_rtp_codecs_payload_replace_format(codecs, payload, replace);
-		ao2_ref(replace, -1);
-	}
-	ao2_ref(format, -1);
-}
-
-/*!
- * \brief Find and process all fmtp attribute lines for a given payload
- *
- * \param m_line The stream on which to search for the fmtp attributes
- * \param payload The specific fmtp attribute to search for
- * \param codecs The current RTP codecs that have been built up
- */
-static void process_fmtp_lines(const struct ast_sdp_m_line *m_line, int payload,
-	struct ast_rtp_codecs *codecs)
-{
-	const struct ast_sdp_a_line *a_line;
-	int idx;
-
-	idx = ast_sdp_m_find_a_first(m_line, "fmtp", payload);
-	for (; 0 <= idx; idx = ast_sdp_m_find_a_next(m_line, idx, "fmtp", payload)) {
-		a_line = ast_sdp_m_get_a(m_line, idx);
-		ast_assert(a_line != NULL);
-
-		process_fmtp_value(a_line->value, payload, codecs);
-	}
-}
-
-/*
- * Needed so we don't have an external function referenced as data.
- * The dynamic linker doesn't handle that very well.
- */
-static void rtp_codecs_free(struct ast_rtp_codecs *codecs)
-{
-	if (codecs) {
-		ast_rtp_codecs_payloads_destroy(codecs);
-	}
-}
-
-/*!
- * \brief Convert an SDP stream into an Asterisk stream
- *
- * Given an m-line from an SDP, convert it into an ast_stream structure.
- * This takes formats, as well as clock-rate and fmtp attributes into account.
- *
- * \param m_line The SDP media section to convert
- * \param g726_non_standard Non-zero if G.726 is non-standard
- *
- * \retval NULL An error occurred
- * \retval non-NULL The converted stream
- */
-static struct ast_stream *get_stream_from_m(const struct ast_sdp_m_line *m_line, int g726_non_standard)
-{
-	int i;
-	int non_ast_fmts;
-	struct ast_rtp_codecs *codecs;
-	struct ast_format_cap *caps;
-	struct ast_stream *stream;
-	enum ast_rtp_options options;
-
-	caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
-	if (!caps) {
-		return NULL;
-	}
-	stream = ast_stream_alloc(m_line->type, ast_media_type_from_str(m_line->type));
-	if (!stream) {
-		ao2_ref(caps, -1);
-		return NULL;
-	}
-
-	switch (ast_stream_get_type(stream)) {
-	case AST_MEDIA_TYPE_AUDIO:
-	case AST_MEDIA_TYPE_VIDEO:
-		codecs = ast_calloc(1, sizeof(*codecs));
-		if (!codecs || ast_rtp_codecs_payloads_initialize(codecs)) {
-			rtp_codecs_free(codecs);
-			ast_stream_free(stream);
-			ao2_ref(caps, -1);
-			ast_free(codecs);
-			return NULL;
-		}
-
-		options = g726_non_standard ? AST_RTP_OPT_G726_NONSTANDARD : 0;
-		for (i = 0; i < ast_sdp_m_get_payload_count(m_line); ++i) {
-			struct ast_sdp_payload *payload_s;
-			struct ast_sdp_rtpmap *rtpmap;
-			int payload;
-
-			payload_s = ast_sdp_m_get_payload(m_line, i);
-			sscanf(payload_s->fmt, "%30d", &payload);
-
-			rtpmap = sdp_payload_get_rtpmap(m_line, payload);
-			if (!rtpmap) {
-				/* No rtpmap attribute.  Try static payload type format assignment */
-				ast_rtp_codecs_payloads_set_m_type(codecs, NULL, payload);
-				continue;
-			}
-
-			if (!ast_rtp_codecs_payloads_set_rtpmap_type_rate(codecs, NULL, payload,
-				m_line->type, rtpmap->encoding_name, options, rtpmap->clock_rate)) {
-				/* Successfully mapped the payload type to format */
-				process_fmtp_lines(m_line, payload, codecs);
-			}
-			ast_sdp_rtpmap_free(rtpmap);
-		}
-
-		ast_rtp_codecs_payload_formats(codecs, caps, &non_ast_fmts);
-		ast_stream_set_data(stream, AST_STREAM_DATA_RTP_CODECS, codecs,
-			(ast_stream_data_free_fn) rtp_codecs_free);
-		break;
-	case AST_MEDIA_TYPE_IMAGE:
-		for (i = 0; i < ast_sdp_m_get_payload_count(m_line); ++i) {
-			struct ast_sdp_payload *payload;
-
-			/* As we don't carry T.38 over RTP we do our own format check */
-			payload = ast_sdp_m_get_payload(m_line, i);
-			if (!strcasecmp(payload->fmt, "t38")) {
-				ast_format_cap_append(caps, ast_format_t38, 0);
-			}
-		}
-		break;
-	case AST_MEDIA_TYPE_UNKNOWN:
-	case AST_MEDIA_TYPE_TEXT:
-	case AST_MEDIA_TYPE_END:
-		break;
-	}
-
-	ast_stream_set_formats(stream, caps);
-	ao2_ref(caps, -1);
-
-	return stream;
-}
-
-struct ast_stream_topology *ast_get_topology_from_sdp(const struct ast_sdp *sdp, int g726_non_standard)
-{
-	struct ast_stream_topology *topology;
-	int i;
-
-	topology = ast_stream_topology_alloc();
-	if (!topology) {
-		return NULL;
-	}
-
-	for (i = 0; i < ast_sdp_get_m_count(sdp); ++i) {
-		struct ast_stream *stream;
-
-		stream = get_stream_from_m(ast_sdp_get_m(sdp, i), g726_non_standard);
-		if (!stream) {
-			/*
-			 * The topology cannot match the SDP because
-			 * we failed to create a corresponding stream.
-			 */
-			ast_stream_topology_free(topology);
-			return NULL;
-		}
-		if (ast_stream_topology_append_stream(topology, stream) < 0) {
-			/* Failed to add stream to topology */
-			ast_stream_free(stream);
-			ast_stream_topology_free(topology);
-			return NULL;
-		}
-	}
-
-	return topology;
-}
diff --git a/main/sdp_options.c b/main/sdp_options.c
deleted file mode 100644
index a938583..0000000
--- a/main/sdp_options.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * 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"
-
-#include "sdp_private.h"
-
-#define DEFAULT_DTMF AST_SDP_DTMF_NONE
-#define DEFAULT_ICE AST_SDP_ICE_DISABLED
-#define DEFAULT_IMPL AST_SDP_IMPL_STRING
-#define DEFAULT_ENCRYPTION AST_SDP_ENCRYPTION_DISABLED
-
-#define DEFINE_STRINGFIELD_GETTERS_SETTERS_FOR(field, assert_on_null) \
-void ast_sdp_options_set_##field(struct ast_sdp_options *options, const char *value) \
-{ \
-	ast_assert(options != NULL); \
-	if ((assert_on_null)) ast_assert(!ast_strlen_zero(value)); \
-	if (!strcmp(value, options->field)) return; \
-	ast_string_field_set(options, field, value); \
-} \
-const char *ast_sdp_options_get_##field(const struct ast_sdp_options *options) \
-{ \
-	ast_assert(options != NULL); \
-	return options->field; \
-} \
-
-#define DEFINE_GETTERS_SETTERS_FOR(type, field) \
-void ast_sdp_options_set_##field(struct ast_sdp_options *options, type value) \
-{ \
-	ast_assert(options != NULL); \
-	options->field = value; \
-} \
-type ast_sdp_options_get_##field(const struct ast_sdp_options *options) \
-{ \
-	ast_assert(options != NULL); \
-	return options->field; \
-} \
-
-DEFINE_STRINGFIELD_GETTERS_SETTERS_FOR(media_address, 0);
-DEFINE_STRINGFIELD_GETTERS_SETTERS_FOR(interface_address, 0);
-DEFINE_STRINGFIELD_GETTERS_SETTERS_FOR(sdpowner, 0);
-DEFINE_STRINGFIELD_GETTERS_SETTERS_FOR(sdpsession, 0);
-DEFINE_STRINGFIELD_GETTERS_SETTERS_FOR(rtp_engine, 0);
-
-DEFINE_GETTERS_SETTERS_FOR(unsigned int, rtp_symmetric);
-DEFINE_GETTERS_SETTERS_FOR(unsigned int, udptl_symmetric);
-DEFINE_GETTERS_SETTERS_FOR(enum ast_t38_ec_modes, udptl_error_correction);
-DEFINE_GETTERS_SETTERS_FOR(unsigned int, udptl_far_max_datagram);
-DEFINE_GETTERS_SETTERS_FOR(unsigned int, rtp_ipv6);
-DEFINE_GETTERS_SETTERS_FOR(unsigned int, g726_non_standard);
-DEFINE_GETTERS_SETTERS_FOR(unsigned int, rtcp_mux);
-DEFINE_GETTERS_SETTERS_FOR(unsigned int, tos_audio);
-DEFINE_GETTERS_SETTERS_FOR(unsigned int, cos_audio);
-DEFINE_GETTERS_SETTERS_FOR(unsigned int, tos_video);
-DEFINE_GETTERS_SETTERS_FOR(unsigned int, cos_video);
-DEFINE_GETTERS_SETTERS_FOR(enum ast_sdp_options_dtmf, dtmf);
-DEFINE_GETTERS_SETTERS_FOR(enum ast_sdp_options_ice, ice);
-DEFINE_GETTERS_SETTERS_FOR(enum ast_sdp_options_impl, impl);
-DEFINE_GETTERS_SETTERS_FOR(enum ast_sdp_options_encryption, encryption);
-DEFINE_GETTERS_SETTERS_FOR(unsigned int, ssrc);
-
-struct ast_sched_context *ast_sdp_options_get_sched_type(const struct ast_sdp_options *options, enum ast_media_type type)
-{
-	struct ast_sched_context *sched = NULL;
-
-	switch (type) {
-	case AST_MEDIA_TYPE_AUDIO:
-	case AST_MEDIA_TYPE_VIDEO:
-	case AST_MEDIA_TYPE_IMAGE:
-	case AST_MEDIA_TYPE_TEXT:
-		sched = options->sched[type];
-		break;
-	case AST_MEDIA_TYPE_UNKNOWN:
-	case AST_MEDIA_TYPE_END:
-		break;
-	}
-	return sched;
-}
-
-void ast_sdp_options_set_sched_type(struct ast_sdp_options *options, enum ast_media_type type, struct ast_sched_context *sched)
-{
-	switch (type) {
-	case AST_MEDIA_TYPE_AUDIO:
-	case AST_MEDIA_TYPE_VIDEO:
-	case AST_MEDIA_TYPE_IMAGE:
-	case AST_MEDIA_TYPE_TEXT:
-		options->sched[type] = sched;
-		break;
-	case AST_MEDIA_TYPE_UNKNOWN:
-	case AST_MEDIA_TYPE_END:
-		break;
-	}
-}
-
-static void set_defaults(struct ast_sdp_options *options)
-{
-	options->dtmf = DEFAULT_DTMF;
-	options->ice = DEFAULT_ICE;
-	options->impl = DEFAULT_IMPL;
-	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;
-	}
-
-	if (ast_string_field_init(options, 256)) {
-		ast_free(options);
-		return NULL;
-	}
-
-	set_defaults(options);
-	return options;
-}
-
-void ast_sdp_options_free(struct ast_sdp_options *options)
-{
-	ast_string_field_free_memory(options);
-	ast_free(options);
-}
diff --git a/main/sdp_private.h b/main/sdp_private.h
deleted file mode 100644
index 62228a5..0000000
--- a/main/sdp_private.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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 _MAIN_SDP_PRIVATE_H
-#define _MAIN_SDP_PRIVATE_H
-
-#include "asterisk/stringfields.h"
-#include "asterisk/sdp_options.h"
-
-struct ast_sdp_options {
-	AST_DECLARE_STRING_FIELDS(
-		/*! Media address to use in SDP */
-		AST_STRING_FIELD(media_address);
-		/*! Optional address of the interface media should use. */
-		AST_STRING_FIELD(interface_address);
-		/*! SDP origin username */
-		AST_STRING_FIELD(sdpowner);
-		/*! SDP session name */
-		AST_STRING_FIELD(sdpsession);
-		/*! RTP Engine Name */
-		AST_STRING_FIELD(rtp_engine);
-	);
-	/*! Scheduler context for the media stream types (Mainly for RTP) */
-	struct ast_sched_context *sched[AST_MEDIA_TYPE_END];
-	struct {
-		unsigned int rtp_symmetric:1;
-		unsigned int udptl_symmetric:1;
-		unsigned int rtp_ipv6:1;
-		unsigned int g726_non_standard:1;
-		unsigned int locally_held:1;
-		unsigned int rtcp_mux:1;
-		unsigned int ssrc:1;
-	};
-	struct {
-		unsigned int tos_audio;
-		unsigned int cos_audio;
-		unsigned int tos_video;
-		unsigned int cos_video;
-		unsigned int udptl_far_max_datagram;
-	};
-	enum ast_sdp_options_dtmf dtmf;
-	enum ast_sdp_options_ice ice;
-	enum ast_sdp_options_impl impl;
-	enum ast_sdp_options_encryption encryption;
-	enum ast_t38_ec_modes udptl_error_correction;
-};
-
-#endif /* _MAIN_SDP_PRIVATE_H */
diff --git a/main/sdp_srtp.c b/main/sdp_srtp.c
deleted file mode 100644
index b2ae234..0000000
--- a/main/sdp_srtp.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Asterisk -- An open source telephony toolkit.
- *
- * Copyright (C) 2006 - 2007, Mikael Magnusson
- *
- * Mikael Magnusson <mikma at users.sourceforge.net>
- *
- * 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.
- */
-
-/*! \file
- *
- * \brief SRTP and SDP Security descriptions
- *
- * Specified in RFC 3711, 6188, 7714, and 4568
- *
- * \author Mikael Magnusson <mikma at users.sourceforge.net>
- */
-
-/*** MODULEINFO
-	<support_level>core</support_level>
- ***/
-
-#include "asterisk.h"
-
-#include "asterisk/linkedlists.h"       /* for AST_LIST_NEXT, etc */
-#include "asterisk/logger.h"            /* for ast_log, LOG_ERROR, etc */
-#include "asterisk/sdp_srtp.h"          /* for ast_sdp_srtp, etc */
-
-/*! Registered SDP crypto API */
-static struct ast_sdp_crypto_api *sdp_crypto_api;
-
-struct ast_sdp_srtp *ast_sdp_srtp_alloc(void)
-{
-	if (!ast_rtp_engine_srtp_is_registered()) {
-	       ast_debug(1, "No SRTP module loaded, can't setup SRTP session.\n");
-	       return NULL;
-	}
-
-	return ast_calloc(1, sizeof(struct ast_sdp_srtp));
-}
-
-void ast_sdp_srtp_destroy(struct ast_sdp_srtp *srtp)
-{
-	struct ast_sdp_srtp *next;
-
-	for (next = AST_LIST_NEXT(srtp, sdp_srtp_list);
-	     srtp;
-	     srtp = next, next = srtp ? AST_LIST_NEXT(srtp, sdp_srtp_list) : NULL) {
-		ast_sdp_crypto_destroy(srtp->crypto);
-		srtp->crypto = NULL;
-		ast_free(srtp);
-	}
-}
-
-void ast_sdp_crypto_destroy(struct ast_sdp_crypto *crypto)
-{
-	if (sdp_crypto_api) {
-		sdp_crypto_api->dtor(crypto);
-	}
-}
-
-struct ast_sdp_crypto *ast_sdp_crypto_alloc(void)
-{
-	if (!sdp_crypto_api) {
-		return NULL;
-	}
-	return sdp_crypto_api->alloc();
-}
-
-int ast_sdp_crypto_process(struct ast_rtp_instance *rtp, struct ast_sdp_srtp *srtp, const char *attr)
-{
-	if (!sdp_crypto_api) {
-		return -1;
-	}
-	return sdp_crypto_api->parse_offer(rtp, srtp, attr);
-}
-
-int ast_sdp_crypto_build_offer(struct ast_sdp_crypto *p, int taglen)
-{
-	if (!sdp_crypto_api) {
-		return -1;
-	}
-	return sdp_crypto_api->build_offer(p, taglen);
-}
-
-const char *ast_sdp_srtp_get_attrib(struct ast_sdp_srtp *srtp, int dtls_enabled, int default_taglen_32)
-{
-	if (!sdp_crypto_api) {
-		return NULL;
-	}
-	return sdp_crypto_api->get_attr(srtp, dtls_enabled, default_taglen_32);
-}
-
-char *ast_sdp_get_rtp_profile(unsigned int sdes_active, struct ast_rtp_instance *instance, unsigned int using_avpf,
-	unsigned int force_avp)
-{
-	struct ast_rtp_engine_dtls *dtls;
-
-	if ((dtls = ast_rtp_instance_get_dtls(instance)) && dtls->active(instance)) {
-		if (force_avp) {
-			return using_avpf ? "RTP/SAVPF" : "RTP/SAVP";
-		} else {
-			return using_avpf ? "UDP/TLS/RTP/SAVPF" : "UDP/TLS/RTP/SAVP";
-		}
-	} else {
-		if (using_avpf) {
-			return sdes_active ? "RTP/SAVPF" : "RTP/AVPF";
-		} else {
-			return sdes_active ? "RTP/SAVP" : "RTP/AVP";
-		}
-	}
-}
-
-int ast_sdp_crypto_register(struct ast_sdp_crypto_api *api)
-{
-	if (sdp_crypto_api) {
-		return -1;
-	}
-	sdp_crypto_api = api;
-	return 0;
-}
-
-void ast_sdp_crypto_unregister(struct ast_sdp_crypto_api *api)
-{
-	if (sdp_crypto_api == api) {
-		sdp_crypto_api = NULL;
-	}
-}
diff --git a/main/sdp_state.c b/main/sdp_state.c
deleted file mode 100644
index 522c876..0000000
--- a/main/sdp_state.c
+++ /dev/null
@@ -1,1810 +0,0 @@
-/*
- * 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/sdp_state.h"
-#include "asterisk/sdp_options.h"
-#include "asterisk/sdp_translator.h"
-#include "asterisk/vector.h"
-#include "asterisk/utils.h"
-#include "asterisk/netsock2.h"
-#include "asterisk/rtp_engine.h"
-#include "asterisk/format.h"
-#include "asterisk/format_cap.h"
-#include "asterisk/config.h"
-#include "asterisk/codec.h"
-#include "asterisk/udptl.h"
-
-#include "asterisk/sdp.h"
-#include "asterisk/stream.h"
-
-#include "sdp_private.h"
-
-enum ast_sdp_role {
-	/*!
-	 * \brief The role has not yet been determined.
-	 *
-	 * When the SDP state is allocated, this is the starting role.
-	 * Similarly, when the SDP state is reset, the role is reverted
-	 * to this.
-	 */
-	SDP_ROLE_NOT_SET,
-	/*!
-	 * \brief We are the offerer.
-	 *
-	 * If a local SDP is requested before a remote SDP has been set, then
-	 * we assume the role of offerer. This means that we will generate an
-	 * SDP from the local capabilities and configured options.
-	 */
-	SDP_ROLE_OFFERER,
-	/*!
-	 * \brief We are the answerer.
-	 *
-	 * If a remote SDP is set before a local SDP is requested, then we
-	 * assume the role of answerer. This means that we will generate an
-	 * SDP based on a merge of the remote capabilities and our local capabilities.
-	 */
-	SDP_ROLE_ANSWERER,
-};
-
-typedef int (*state_fn)(struct ast_sdp_state *state);
-
-struct sdp_state_rtp {
-	/*! The underlying RTP instance */
-	struct ast_rtp_instance *instance;
-};
-
-struct sdp_state_udptl {
-	/*! The underlying UDPTL instance */
-	struct ast_udptl *instance;
-};
-
-struct sdp_state_stream {
-	/*! Type of the stream */
-	enum ast_media_type type;
-	union {
-		/*! The underlying RTP instance */
-		struct sdp_state_rtp *rtp;
-		/*! The underlying UDPTL instance */
-		struct sdp_state_udptl *udptl;
-	};
-	/*! An explicit connection address for this stream */
-	struct ast_sockaddr connection_address;
-	/*! Whether this stream is held or not */
-	unsigned int locally_held;
-	/*! UDPTL session parameters */
-	struct ast_control_t38_parameters t38_local_params;
-};
-
-static void sdp_state_rtp_destroy(void *obj)
-{
-	struct sdp_state_rtp *rtp = obj;
-
-	if (rtp->instance) {
-		ast_rtp_instance_stop(rtp->instance);
-		ast_rtp_instance_destroy(rtp->instance);
-	}
-}
-
-static void sdp_state_udptl_destroy(void *obj)
-{
-	struct sdp_state_udptl *udptl = obj;
-
-	if (udptl->instance) {
-		ast_udptl_destroy(udptl->instance);
-	}
-}
-
-static void sdp_state_stream_free(struct sdp_state_stream *state_stream)
-{
-	switch (state_stream->type) {
-	case AST_MEDIA_TYPE_AUDIO:
-	case AST_MEDIA_TYPE_VIDEO:
-		ao2_cleanup(state_stream->rtp);
-		break;
-	case AST_MEDIA_TYPE_IMAGE:
-		ao2_cleanup(state_stream->udptl);
-		break;
-	case AST_MEDIA_TYPE_UNKNOWN:
-	case AST_MEDIA_TYPE_TEXT:
-	case AST_MEDIA_TYPE_END:
-		break;
-	}
-	ast_free(state_stream);
-}
-
-AST_VECTOR(sdp_state_streams, struct sdp_state_stream *);
-
-struct sdp_state_capabilities {
-	/*! Stream topology */
-	struct ast_stream_topology *topology;
-	/*! Additional information about the streams */
-	struct sdp_state_streams streams;
-	/*! An explicit global connection address */
-	struct ast_sockaddr connection_address;
-};
-
-static void sdp_state_capabilities_free(struct sdp_state_capabilities *capabilities)
-{
-	if (!capabilities) {
-		return;
-	}
-
-	ast_stream_topology_free(capabilities->topology);
-	AST_VECTOR_CALLBACK_VOID(&capabilities->streams, sdp_state_stream_free);
-	AST_VECTOR_FREE(&capabilities->streams);
-	ast_free(capabilities);
-}
-
-/*! \brief Internal function which creates an RTP instance */
-static struct sdp_state_rtp *create_rtp(const struct ast_sdp_options *options,
-	enum ast_media_type media_type)
-{
-	struct sdp_state_rtp *rtp;
-	struct ast_rtp_engine_ice *ice;
-	static struct ast_sockaddr address_rtp;
-	struct ast_sockaddr *media_address = &address_rtp;
-
-	if (!ast_strlen_zero(options->interface_address)) {
-		if (!ast_sockaddr_parse(&address_rtp, options->interface_address, 0)) {
-			ast_log(LOG_ERROR, "Attempted to bind RTP to invalid media address: %s\n",
-				options->interface_address);
-			return NULL;
-		}
-	} else {
-		if (ast_check_ipv6()) {
-			ast_sockaddr_parse(&address_rtp, "::", 0);
-		} else {
-			ast_sockaddr_parse(&address_rtp, "0.0.0.0", 0);
-		}
-	}
-
-	rtp = ao2_alloc_options(sizeof(*rtp), sdp_state_rtp_destroy, AO2_ALLOC_OPT_LOCK_NOLOCK);
-	if (!rtp) {
-		return NULL;
-	}
-
-	rtp->instance = ast_rtp_instance_new(options->rtp_engine,
-		ast_sdp_options_get_sched_type(options, media_type), media_address, NULL);
-	if (!rtp->instance) {
-		ast_log(LOG_ERROR, "Unable to create RTP instance using RTP engine '%s'\n",
-			options->rtp_engine);
-		ao2_ref(rtp, -1);
-		return NULL;
-	}
-
-	ast_rtp_instance_set_prop(rtp->instance, AST_RTP_PROPERTY_RTCP,
-		AST_RTP_INSTANCE_RTCP_STANDARD);
-	ast_rtp_instance_set_prop(rtp->instance, AST_RTP_PROPERTY_NAT,
-		options->rtp_symmetric);
-
-	if (options->ice == AST_SDP_ICE_DISABLED
-		&& (ice = ast_rtp_instance_get_ice(rtp->instance))) {
-		ice->stop(rtp->instance);
-	}
-
-	if (options->dtmf == AST_SDP_DTMF_RFC_4733 || options->dtmf == AST_SDP_DTMF_AUTO) {
-		ast_rtp_instance_dtmf_mode_set(rtp->instance, AST_RTP_DTMF_MODE_RFC2833);
-		ast_rtp_instance_set_prop(rtp->instance, AST_RTP_PROPERTY_DTMF, 1);
-	} else if (options->dtmf == AST_SDP_DTMF_INBAND) {
-		ast_rtp_instance_dtmf_mode_set(rtp->instance, AST_RTP_DTMF_MODE_INBAND);
-	}
-
-	switch (media_type) {
-	case AST_MEDIA_TYPE_AUDIO:
-		if (options->tos_audio || options->cos_audio) {
-			ast_rtp_instance_set_qos(rtp->instance, options->tos_audio,
-				options->cos_audio, "SIP RTP Audio");
-		}
-		break;
-	case AST_MEDIA_TYPE_VIDEO:
-		if (options->tos_video || options->cos_video) {
-			ast_rtp_instance_set_qos(rtp->instance, options->tos_video,
-				options->cos_video, "SIP RTP Video");
-		}
-		break;
-	case AST_MEDIA_TYPE_IMAGE:
-	case AST_MEDIA_TYPE_TEXT:
-	case AST_MEDIA_TYPE_UNKNOWN:
-	case AST_MEDIA_TYPE_END:
-		break;
-	}
-
-	ast_rtp_instance_set_last_rx(rtp->instance, time(NULL));
-
-	return rtp;
-}
-
-/*! \brief Internal function which creates a UDPTL instance */
-static struct sdp_state_udptl *create_udptl(const struct ast_sdp_options *options)
-{
-	struct sdp_state_udptl *udptl;
-	static struct ast_sockaddr address_udptl;
-	struct ast_sockaddr *media_address = &address_udptl;
-
-	if (!ast_strlen_zero(options->interface_address)) {
-		if (!ast_sockaddr_parse(&address_udptl, options->interface_address, 0)) {
-			ast_log(LOG_ERROR, "Attempted to bind UDPTL to invalid media address: %s\n",
-				options->interface_address);
-			return NULL;
-		}
-	} else {
-		if (ast_check_ipv6()) {
-			ast_sockaddr_parse(&address_udptl, "::", 0);
-		} else {
-			ast_sockaddr_parse(&address_udptl, "0.0.0.0", 0);
-		}
-	}
-
-	udptl = ao2_alloc_options(sizeof(*udptl), sdp_state_udptl_destroy, AO2_ALLOC_OPT_LOCK_NOLOCK);
-	if (!udptl) {
-		return NULL;
-	}
-
-	udptl->instance = ast_udptl_new_with_bindaddr(NULL, NULL, 0, media_address);
-	if (!udptl->instance) {
-		ao2_ref(udptl, -1);
-		return NULL;
-	}
-
-	ast_udptl_set_error_correction_scheme(udptl->instance, ast_sdp_options_get_udptl_error_correction(options));
-	ast_udptl_setnat(udptl->instance, ast_sdp_options_get_udptl_symmetric(options));
-	ast_udptl_set_far_max_datagram(udptl->instance, ast_sdp_options_get_udptl_far_max_datagram(options));
-
-	return udptl;
-}
-
-static struct sdp_state_capabilities *sdp_initialize_state_capabilities(const struct ast_stream_topology *topology,
-	const struct ast_sdp_options *options)
-{
-	struct sdp_state_capabilities *capabilities;
-	int i;
-
-	capabilities = ast_calloc(1, sizeof(*capabilities));
-	if (!capabilities) {
-		return NULL;
-	}
-
-	capabilities->topology = ast_stream_topology_clone(topology);
-	if (!capabilities->topology) {
-		sdp_state_capabilities_free(capabilities);
-		return NULL;
-	}
-
-	if (AST_VECTOR_INIT(&capabilities->streams, ast_stream_topology_get_count(topology))) {
-		sdp_state_capabilities_free(capabilities);
-		return NULL;
-	}
-	ast_sockaddr_setnull(&capabilities->connection_address);
-
-	for (i = 0; i < ast_stream_topology_get_count(topology); ++i) {
-		struct sdp_state_stream *state_stream;
-
-		state_stream = ast_calloc(1, sizeof(*state_stream));
-		if (!state_stream) {
-			sdp_state_capabilities_free(capabilities);
-			return NULL;
-		}
-
-		state_stream->type = ast_stream_get_type(ast_stream_topology_get_stream(topology, i));
-		switch (state_stream->type) {
-		case AST_MEDIA_TYPE_AUDIO:
-		case AST_MEDIA_TYPE_VIDEO:
-			state_stream->rtp = create_rtp(options, state_stream->type);
-			if (!state_stream->rtp) {
-				sdp_state_stream_free(state_stream);
-				sdp_state_capabilities_free(capabilities);
-				return NULL;
-			}
-			break;
-		case AST_MEDIA_TYPE_IMAGE:
-			state_stream->udptl = create_udptl(options);
-			if (!state_stream->udptl) {
-				sdp_state_stream_free(state_stream);
-				sdp_state_capabilities_free(capabilities);
-				return NULL;
-			}
-			break;
-		case AST_MEDIA_TYPE_UNKNOWN:
-		case AST_MEDIA_TYPE_TEXT:
-		case AST_MEDIA_TYPE_END:
-			ast_assert(0);
-			sdp_state_stream_free(state_stream);
-			sdp_state_capabilities_free(capabilities);
-			return NULL;
-		}
-
-		if (AST_VECTOR_APPEND(&capabilities->streams, state_stream)) {
-			sdp_state_stream_free(state_stream);
-			sdp_state_capabilities_free(capabilities);
-			return NULL;
-		}
-	}
-
-	return capabilities;
-}
-
-/*!
- * \brief SDP state, the main structure used to keep track of SDP negotiation
- * and settings.
- *
- * Most fields are pretty self-explanatory, but negotiated_capabilities and
- * proposed_capabilities could use some further explanation. When an SDP
- * state is allocated, a stream topology is provided that dictates the
- * types of streams to offer in the resultant SDP. At the time the SDP
- * is allocated, this topology is used to create the proposed_capabilities.
- *
- * If we are the SDP offerer, then the proposed_capabilities are what are used
- * to generate the SDP offer. When the SDP answer arrives, the proposed capabilities
- * are merged with the SDP answer to create the negotiated capabilities.
- *
- * If we are the SDP answerer, then the incoming SDP offer is merged with our
- * proposed capabilities to to create the negotiated capabilities. These negotiated
- * capabilities are what we send in our SDP answer.
- *
- * Any changes that a user of the API performs will occur on the proposed capabilities.
- * The negotiated capabilities are only altered based on actual SDP negotiation. This is
- * done so that the negotiated capabilities can be fallen back on if the proposed
- * capabilities run into some sort of issue.
- */
-struct ast_sdp_state {
-	/*! Current capabilities */
-	struct sdp_state_capabilities *negotiated_capabilities;
-	/*! Proposed capabilities */
-	struct sdp_state_capabilities *proposed_capabilities;
-	/*! Local SDP. Generated via the options and currently negotiated/proposed capabilities. */
-	struct ast_sdp *local_sdp;
-	/*! SDP options. Configured options beyond media capabilities. */
-	struct ast_sdp_options *options;
-	/*! Translator that puts SDPs into the expected representation */
-	struct ast_sdp_translator *translator;
-	/*! The role that we occupy in SDP negotiation */
-	enum ast_sdp_role role;
-};
-
-struct ast_sdp_state *ast_sdp_state_alloc(struct ast_stream_topology *streams,
-	struct ast_sdp_options *options)
-{
-	struct ast_sdp_state *sdp_state;
-
-	sdp_state = ast_calloc(1, sizeof(*sdp_state));
-	if (!sdp_state) {
-		return NULL;
-	}
-
-	sdp_state->options = options;
-
-	sdp_state->translator = ast_sdp_translator_new(ast_sdp_options_get_impl(sdp_state->options));
-	if (!sdp_state->translator) {
-		ast_sdp_state_free(sdp_state);
-		return NULL;
-	}
-
-	sdp_state->proposed_capabilities = sdp_initialize_state_capabilities(streams, options);
-	if (!sdp_state->proposed_capabilities) {
-		ast_sdp_state_free(sdp_state);
-		return NULL;
-	}
-
-	sdp_state->role = SDP_ROLE_NOT_SET;
-
-	return sdp_state;
-}
-
-void ast_sdp_state_free(struct ast_sdp_state *sdp_state)
-{
-	if (!sdp_state) {
-		return;
-	}
-
-	sdp_state_capabilities_free(sdp_state->negotiated_capabilities);
-	sdp_state_capabilities_free(sdp_state->proposed_capabilities);
-	ast_sdp_free(sdp_state->local_sdp);
-	ast_sdp_options_free(sdp_state->options);
-	ast_sdp_translator_free(sdp_state->translator);
-	ast_free(sdp_state);
-}
-
-static struct sdp_state_stream *sdp_state_get_stream(const struct ast_sdp_state *sdp_state, int stream_index)
-{
-	if (stream_index >= AST_VECTOR_SIZE(&sdp_state->proposed_capabilities->streams)) {
-		return NULL;
-	}
-
-	return AST_VECTOR_GET(&sdp_state->proposed_capabilities->streams, stream_index);
-}
-
-struct ast_rtp_instance *ast_sdp_state_get_rtp_instance(
-	const struct ast_sdp_state *sdp_state, int stream_index)
-{
-	struct sdp_state_stream *stream_state;
-
-	ast_assert(sdp_state != NULL);
-	ast_assert(ast_stream_get_type(ast_stream_topology_get_stream(sdp_state->proposed_capabilities->topology,
-		stream_index)) == AST_MEDIA_TYPE_AUDIO || ast_stream_get_type(ast_stream_topology_get_stream(
-			sdp_state->proposed_capabilities->topology, stream_index)) == AST_MEDIA_TYPE_VIDEO);
-
-	stream_state = sdp_state_get_stream(sdp_state, stream_index);
-	if (!stream_state || !stream_state->rtp) {
-		return NULL;
-	}
-
-	return stream_state->rtp->instance;
-}
-
-struct ast_udptl *ast_sdp_state_get_udptl_instance(
-	const struct ast_sdp_state *sdp_state, int stream_index)
-{
-	struct sdp_state_stream *stream_state;
-
-	ast_assert(sdp_state != NULL);
-	ast_assert(ast_stream_get_type(ast_stream_topology_get_stream(sdp_state->proposed_capabilities->topology,
-		stream_index)) == AST_MEDIA_TYPE_IMAGE);
-
-	stream_state = sdp_state_get_stream(sdp_state, stream_index);
-	if (!stream_state || !stream_state->udptl) {
-		return NULL;
-	}
-
-	return stream_state->udptl->instance;
-}
-
-const struct ast_sockaddr *ast_sdp_state_get_connection_address(const struct ast_sdp_state *sdp_state)
-{
-	ast_assert(sdp_state != NULL);
-
-	return &sdp_state->proposed_capabilities->connection_address;
-}
-
-int ast_sdp_state_get_stream_connection_address(const struct ast_sdp_state *sdp_state,
-	int stream_index, struct ast_sockaddr *address)
-{
-	struct sdp_state_stream *stream_state;
-
-	ast_assert(sdp_state != NULL);
-	ast_assert(address != NULL);
-
-	stream_state = sdp_state_get_stream(sdp_state, stream_index);
-	if (!stream_state) {
-		return -1;
-	}
-
-	/* If an explicit connection address has been provided for the stream return it */
-	if (!ast_sockaddr_isnull(&stream_state->connection_address)) {
-		ast_sockaddr_copy(address, &stream_state->connection_address);
-		return 0;
-	}
-
-	switch (ast_stream_get_type(ast_stream_topology_get_stream(sdp_state->proposed_capabilities->topology,
-		stream_index))) {
-	case AST_MEDIA_TYPE_AUDIO:
-	case AST_MEDIA_TYPE_VIDEO:
-		ast_rtp_instance_get_local_address(stream_state->rtp->instance, address);
-		break;
-	case AST_MEDIA_TYPE_IMAGE:
-		ast_udptl_get_us(stream_state->udptl->instance, address);
-		break;
-	case AST_MEDIA_TYPE_UNKNOWN:
-	case AST_MEDIA_TYPE_TEXT:
-	case AST_MEDIA_TYPE_END:
-		return -1;
-	}
-
-	/* If an explicit global connection address is set use it here for the IP part */
-	if (!ast_sockaddr_isnull(&sdp_state->proposed_capabilities->connection_address)) {
-		int port = ast_sockaddr_port(address);
-
-		ast_sockaddr_copy(address, &sdp_state->proposed_capabilities->connection_address);
-		ast_sockaddr_set_port(address, port);
-	}
-
-	return 0;
-}
-
-const struct ast_stream_topology *ast_sdp_state_get_joint_topology(
-	const struct ast_sdp_state *sdp_state)
-{
-	ast_assert(sdp_state != NULL);
-
-	if (sdp_state->negotiated_capabilities) {
-		return sdp_state->negotiated_capabilities->topology;
-	}
-
-	return sdp_state->proposed_capabilities->topology;
-}
-
-const struct ast_stream_topology *ast_sdp_state_get_local_topology(
-	const struct ast_sdp_state *sdp_state)
-{
-	ast_assert(sdp_state != NULL);
-
-	return sdp_state->proposed_capabilities->topology;
-}
-
-const struct ast_sdp_options *ast_sdp_state_get_options(
-	const struct ast_sdp_state *sdp_state)
-{
-	ast_assert(sdp_state != NULL);
-
-	return sdp_state->options;
-}
-
-/*!
- * \brief Merge two streams into a joint stream.
- *
- * \param local Our local stream
- * \param remote A remote stream
- *
- * \retval NULL An error occurred
- * \retval non-NULL The joint stream created
- */
-static struct ast_stream *merge_streams(const struct ast_stream *local,
-	const struct ast_stream *remote)
-{
-	struct ast_stream *joint_stream;
-	struct ast_format_cap *joint_cap;
-	struct ast_format_cap *local_cap;
-	struct ast_format_cap *remote_cap;
-	struct ast_str *local_buf = ast_str_alloca(128);
-	struct ast_str *remote_buf = ast_str_alloca(128);
-	struct ast_str *joint_buf = ast_str_alloca(128);
-
-	joint_stream = ast_stream_alloc(ast_codec_media_type2str(ast_stream_get_type(remote)),
-		ast_stream_get_type(remote));
-	if (!joint_stream) {
-		return NULL;
-	}
-
-	joint_cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
-	if (!joint_cap) {
-		ast_stream_free(joint_stream);
-		return NULL;
-	}
-
-	local_cap = ast_stream_get_formats(local);
-	remote_cap = ast_stream_get_formats(remote);
-
-	ast_format_cap_get_compatible(local_cap, remote_cap, joint_cap);
-
-	ast_debug(3, "Combined local '%s' with remote '%s' to get joint '%s'. Joint has %zu formats\n",
-		ast_format_cap_get_names(local_cap, &local_buf),
-		ast_format_cap_get_names(remote_cap, &remote_buf),
-		ast_format_cap_get_names(joint_cap, &joint_buf),
-		ast_format_cap_count(joint_cap));
-
-	ast_stream_set_formats(joint_stream, joint_cap);
-
-	ao2_ref(joint_cap, -1);
-
-	return joint_stream;
-}
-
-/*!
- * \brief Get a local stream that corresponds with a remote stream.
- *
- * \param local The local topology
- * \param media_type The type of stream we are looking for
- * \param[in,out] media_indices Keeps track of where to start searching in the topology
- *
- * \retval -1 No corresponding stream found
- * \retval index The corresponding stream index
- */
-static int get_corresponding_index(const struct ast_stream_topology *local,
-	enum ast_media_type media_type, int *media_indices)
-{
-	int i;
-
-	for (i = media_indices[media_type]; i < ast_stream_topology_get_count(local); ++i) {
-		struct ast_stream *candidate;
-
-		candidate = ast_stream_topology_get_stream(local, i);
-		if (ast_stream_get_type(candidate) == media_type) {
-			media_indices[media_type] = i + 1;
-			return i;
-		}
-	}
-
-	/* No stream of the type left in the topology */
-	media_indices[media_type] = i;
-	return -1;
-}
-
-/*!
- * XXX TODO The merge_capabilities() function needs to be split into
- * merging for new local topologies and new remote topologies.  Also
- * the possibility of changing the stream types needs consideration.
- * Audio to video may or may not need us to keep the same RTP instance
- * because the stream position is still RTP.  A new RTP instance would
- * cause us to change ports.  Audio to image is definitely going to
- * happen for T.38.
- *
- * A new remote topology as an initial offer needs to dictate the
- * number of streams and the order.  As a sdp_state option we may
- * allow creation of new active streams not defined by the current
- * local topology.  A subsequent remote offer can change the stream
- * types and add streams.  The sdp_state option could regulate
- * creation of new active streams here as well.  An answer cannot
- * change stream types or the number of streams but can decline
- * streams.  Any attempt to do so should report an error and possibly
- * disconnect the call.
- *
- * A local topology update needs to be merged differently.  It cannot
- * reduce the number of streams already defined without violating the
- * SDP RFC.  The local merge could take the new topology stream
- * verbatim and add declined streams to fill out any shortfall with
- * the exiting topology.  This strategy is needed if we want to change
- * an audio stream to an image stream for T.38 fax and vice versa.
- * The local merge could take the new topology and map the streams to
- * the existing local topology.  The new topology stream format caps
- * would be copied into the merged topology so we could change what
- * codecs are negotiated.
- */
-/*!
- * \brief Merge existing stream capabilities and a new topology into joint capabilities.
- *
- * \param sdp_state The state needing capabilities merged
- * \param new_topology The new topology to base merged capabilities on
- * \param is_local If new_topology is a local update.
- *
- * \details
- * This is a bit complicated. The idea is that we already have some
- * capabilities set, and we've now been confronted with a new stream
- * topology.  We want to take what's been presented to us and merge
- * those new capabilities with our own.
- *
- * For each of the new streams, we try to find a corresponding stream
- * in our proposed capabilities.  If we find one, then we get the
- * compatible formats of the two streams and create a new stream with
- * those formats set.  We then will re-use the underlying media
- * instance (such as an RTP instance) on this merged stream.
- *
- * The is_local parameter determines whether we should attempt to
- * create new media instances.  If we do not find a corresponding
- * stream, then we create a new one.  If the is_local parameter is
- * true, this created stream is made a clone of the new stream, and a
- * media instance is created.  If the is_local parameter is not true,
- * then the created stream has no formats set and no media instance is
- * created for it.
- *
- * \retval NULL An error occurred
- * \retval non-NULL The merged capabilities
- */
-static struct sdp_state_capabilities *merge_capabilities(const struct ast_sdp_state *sdp_state,
-	const struct ast_stream_topology *new_topology, int is_local)
-{
-	const struct sdp_state_capabilities *local = sdp_state->proposed_capabilities;
-	struct sdp_state_capabilities *joint_capabilities;
-	int media_indices[AST_MEDIA_TYPE_END] = {0};
-	int i;
-	static const char dummy_name[] = "dummy";
-
-	ast_assert(local != NULL);
-
-	joint_capabilities = ast_calloc(1, sizeof(*joint_capabilities));
-	if (!joint_capabilities) {
-		return NULL;
-	}
-
-	joint_capabilities->topology = ast_stream_topology_alloc();
-	if (!joint_capabilities->topology) {
-		goto fail;
-	}
-
-	if (AST_VECTOR_INIT(&joint_capabilities->streams, AST_VECTOR_SIZE(&local->streams))) {
-		goto fail;
-	}
-	ast_sockaddr_copy(&joint_capabilities->connection_address, &local->connection_address);
-
-	for (i = 0; i < ast_stream_topology_get_count(new_topology); ++i) {
-		enum ast_media_type new_stream_type;
-		struct ast_stream *new_stream;
-		struct ast_stream *local_stream;
-		struct ast_stream *joint_stream;
-		struct sdp_state_stream *joint_state_stream;
-		int local_index;
-
-		joint_state_stream = ast_calloc(1, sizeof(*joint_state_stream));
-		if (!joint_state_stream) {
-			goto fail;
-		}
-
-		new_stream = ast_stream_topology_get_stream(new_topology, i);
-		new_stream_type = ast_stream_get_type(new_stream);
-
-		local_index = get_corresponding_index(local->topology, new_stream_type, media_indices);
-		if (0 <= local_index) {
-			local_stream = ast_stream_topology_get_stream(local->topology, local_index);
-			if (!strcmp(ast_stream_get_name(local_stream), dummy_name)) {
-				/* The local stream is a non-exixtent dummy stream. */
-				local_stream = NULL;
-			}
-		} else {
-			local_stream = NULL;
-		}
-		if (local_stream) {
-			struct sdp_state_stream *local_state_stream;
-			struct ast_rtp_codecs *codecs;
-
-			if (is_local) {
-				/* Replace the local stream with the new local stream. */
-				joint_stream = ast_stream_clone(new_stream, NULL);
-			} else {
-				joint_stream = merge_streams(local_stream, new_stream);
-			}
-			if (!joint_stream) {
-				sdp_state_stream_free(joint_state_stream);
-				goto fail;
-			}
-
-			local_state_stream = AST_VECTOR_GET(&local->streams, local_index);
-			joint_state_stream->type = local_state_stream->type;
-
-			switch (joint_state_stream->type) {
-			case AST_MEDIA_TYPE_AUDIO:
-			case AST_MEDIA_TYPE_VIDEO:
-				joint_state_stream->rtp = ao2_bump(local_state_stream->rtp);
-				if (is_local) {
-					break;
-				}
-				codecs = ast_stream_get_data(new_stream, AST_STREAM_DATA_RTP_CODECS);
-				ast_assert(codecs != NULL);
-				if (sdp_state->role == SDP_ROLE_ANSWERER) {
-					/*
-					 * Setup rx payload type mapping to prefer the mapping
-					 * from the peer that the RFC says we SHOULD use.
-					 */
-					ast_rtp_codecs_payloads_xover(codecs, codecs, NULL);
-				}
-				ast_rtp_codecs_payloads_copy(codecs,
-					ast_rtp_instance_get_codecs(joint_state_stream->rtp->instance),
-					joint_state_stream->rtp->instance);
-				break;
-			case AST_MEDIA_TYPE_IMAGE:
-				joint_state_stream->udptl = ao2_bump(local_state_stream->udptl);
-				joint_state_stream->t38_local_params = local_state_stream->t38_local_params;
-				break;
-			case AST_MEDIA_TYPE_UNKNOWN:
-			case AST_MEDIA_TYPE_TEXT:
-			case AST_MEDIA_TYPE_END:
-				break;
-			}
-
-			if (!ast_sockaddr_isnull(&local_state_stream->connection_address)) {
-				ast_sockaddr_copy(&joint_state_stream->connection_address,
-					&local_state_stream->connection_address);
-			} else {
-				ast_sockaddr_setnull(&joint_state_stream->connection_address);
-			}
-			joint_state_stream->locally_held = local_state_stream->locally_held;
-		} else if (is_local) {
-			/* We don't have a stream state that corresponds to the stream in the new topology, so
-			 * create a stream state as appropriate.
-			 */
-			joint_stream = ast_stream_clone(new_stream, NULL);
-			if (!joint_stream) {
-				sdp_state_stream_free(joint_state_stream);
-				goto fail;
-			}
-
-			switch (new_stream_type) {
-			case AST_MEDIA_TYPE_AUDIO:
-			case AST_MEDIA_TYPE_VIDEO:
-				joint_state_stream->rtp = create_rtp(sdp_state->options,
-					new_stream_type);
-				if (!joint_state_stream->rtp) {
-					ast_stream_free(joint_stream);
-					sdp_state_stream_free(joint_state_stream);
-					goto fail;
-				}
-				break;
-			case AST_MEDIA_TYPE_IMAGE:
-				joint_state_stream->udptl = create_udptl(sdp_state->options);
-				if (!joint_state_stream->udptl) {
-					ast_stream_free(joint_stream);
-					sdp_state_stream_free(joint_state_stream);
-					goto fail;
-				}
-				break;
-			case AST_MEDIA_TYPE_UNKNOWN:
-			case AST_MEDIA_TYPE_TEXT:
-			case AST_MEDIA_TYPE_END:
-				break;
-			}
-			ast_sockaddr_setnull(&joint_state_stream->connection_address);
-			joint_state_stream->locally_held = 0;
-		} else {
-			/* We don't have a stream that corresponds to the stream in the new topology. Create a
-			 * dummy stream to go in its place so that the resulting SDP created will contain
-			 * the stream but will have no port or codecs set
-			 */
-			joint_stream = ast_stream_alloc(dummy_name, new_stream_type);
-			if (!joint_stream) {
-				sdp_state_stream_free(joint_state_stream);
-				goto fail;
-			}
-		}
-
-		if (ast_stream_topology_append_stream(joint_capabilities->topology, joint_stream) < 0) {
-			ast_stream_free(joint_stream);
-			sdp_state_stream_free(joint_state_stream);
-			goto fail;
-		}
-		if (AST_VECTOR_APPEND(&joint_capabilities->streams, joint_state_stream)) {
-			sdp_state_stream_free(joint_state_stream);
-			goto fail;
-		}
-	}
-
-	return joint_capabilities;
-
-fail:
-	sdp_state_capabilities_free(joint_capabilities);
-	return NULL;
-}
-
-/*!
- * \brief Apply remote SDP's ICE information to our RTP session
- *
- * \param state The SDP state on which negotiation has taken place
- * \param options The SDP options we support
- * \param remote_sdp The SDP we most recently received
- * \param remote_m_line The stream on which we are examining ICE candidates
- */
-static void update_ice(const struct ast_sdp_state *state, struct ast_rtp_instance *rtp, const struct ast_sdp_options *options,
-	const struct ast_sdp *remote_sdp, const struct ast_sdp_m_line *remote_m_line)
-{
-	struct ast_rtp_engine_ice *ice;
-	const struct ast_sdp_a_line *attr;
-	const struct ast_sdp_a_line *attr_rtcp_mux;
-	unsigned int attr_i;
-
-	/* If ICE support is not enabled or available exit early */
-	if (ast_sdp_options_get_ice(options) != AST_SDP_ICE_ENABLED_STANDARD || !(ice = ast_rtp_instance_get_ice(rtp))) {
-		return;
-	}
-
-	attr = ast_sdp_m_find_attribute(remote_m_line, "ice-ufrag", -1);
-	if (!attr) {
-		attr = ast_sdp_find_attribute(remote_sdp, "ice-ufrag", -1);
-	}
-	if (attr) {
-		ice->set_authentication(rtp, attr->value, NULL);
-	} else {
-		return;
-	}
-
-	attr = ast_sdp_m_find_attribute(remote_m_line, "ice-pwd", -1);
-	if (!attr) {
-		attr = ast_sdp_find_attribute(remote_sdp, "ice-pwd", -1);
-	}
-	if (attr) {
-		ice->set_authentication(rtp, NULL, attr->value);
-	} else {
-		return;
-	}
-
-	if (ast_sdp_find_attribute(remote_sdp, "ice-lite", -1)) {
-		ice->ice_lite(rtp);
-	}
-
-	attr_rtcp_mux = ast_sdp_m_find_attribute(remote_m_line, "rtcp-mux", -1);
-
-	/* Find all of the candidates */
-	for (attr_i = 0; attr_i < ast_sdp_m_get_a_count(remote_m_line); ++attr_i) {
-		char foundation[32];
-		char transport[32];
-		char address[INET6_ADDRSTRLEN + 1];
-		char cand_type[6];
-		char relay_address[INET6_ADDRSTRLEN + 1] = "";
-		unsigned int port;
-		unsigned int relay_port = 0;
-		struct ast_rtp_engine_ice_candidate candidate = { 0, };
-
-		attr = ast_sdp_m_get_a(remote_m_line, attr_i);
-
-		/* If this is not a candidate line skip it */
-		if (strcmp(attr->name, "candidate")) {
-			continue;
-		}
-
-		if (sscanf(attr->value, "%31s %30u %31s %30u %46s %30u typ %5s %*s %23s %*s %30u",
-			foundation, &candidate.id, transport, (unsigned *)&candidate.priority, address,
-			&port, cand_type, relay_address, &relay_port) < 7) {
-			/* Candidate did not parse properly */
-			continue;
-		}
-
-		if (candidate.id > 1
-			&& attr_rtcp_mux
-			&& ast_sdp_options_get_rtcp_mux(options)) {
-			/* Remote side may have offered RTP and RTCP candidates. However, if we're using RTCP MUX,
-			 * then we should ignore RTCP candidates.
-			 */
-			continue;
-		}
-
-		candidate.foundation = foundation;
-		candidate.transport = transport;
-
-		ast_sockaddr_parse(&candidate.address, address, PARSE_PORT_FORBID);
-		ast_sockaddr_set_port(&candidate.address, port);
-
-		if (!strcasecmp(cand_type, "host")) {
-			candidate.type = AST_RTP_ICE_CANDIDATE_TYPE_HOST;
-		} else if (!strcasecmp(cand_type, "srflx")) {
-			candidate.type = AST_RTP_ICE_CANDIDATE_TYPE_SRFLX;
-		} else if (!strcasecmp(cand_type, "relay")) {
-			candidate.type = AST_RTP_ICE_CANDIDATE_TYPE_RELAYED;
-		} else {
-			continue;
-		}
-
-		if (!ast_strlen_zero(relay_address)) {
-			ast_sockaddr_parse(&candidate.relay_address, relay_address, PARSE_PORT_FORBID);
-		}
-
-		if (relay_port) {
-			ast_sockaddr_set_port(&candidate.relay_address, relay_port);
-		}
-
-		ice->add_remote_candidate(rtp, &candidate);
-	}
-
-	if (state->role == SDP_ROLE_OFFERER) {
-		ice->set_role(rtp, AST_RTP_ICE_ROLE_CONTROLLING);
-	} else {
-		ice->set_role(rtp, AST_RTP_ICE_ROLE_CONTROLLED);
-	}
-
-	ice->start(rtp);
-}
-
-/*!
- * \brief Update RTP instances based on merged SDPs
- *
- * RTP instances, when first allocated, cannot make assumptions about what the other
- * side supports and thus has to go with some default behaviors. This function gets
- * called after we know both what we support and what the remote endpoint supports.
- * This way, we can update the RTP instance to reflect what is supported by both
- * sides.
- *
- * \param state The SDP state in which SDPs have been negotiated
- * \param rtp The RTP wrapper that is being updated
- * \param options Our locally-supported SDP options
- * \param remote_sdp The SDP we most recently received
- * \param remote_m_line The remote SDP stream that corresponds to the RTP instance we are modifying
- */
-static void update_rtp_after_merge(const struct ast_sdp_state *state,
-	struct sdp_state_rtp *rtp,
-    const struct ast_sdp_options *options,
-	const struct ast_sdp *remote_sdp,
-	const struct ast_sdp_m_line *remote_m_line)
-{
-	struct ast_sdp_c_line *c_line;
-	struct ast_sockaddr *addrs;
-
-	if (!rtp) {
-		/* This is a dummy stream */
-		return;
-	}
-
-	c_line = remote_m_line->c_line;
-	if (!c_line) {
-		c_line = remote_sdp->c_line;
-	}
-	/*
-	 * There must be a c= line somewhere but that would be an error by
-	 * the far end that should have been caught by a validation check
-	 * before we processed the SDP.
-	 */
-	ast_assert(c_line != NULL);
-
-	if (ast_sockaddr_resolve(&addrs, c_line->address, PARSE_PORT_FORBID, AST_AF_UNSPEC) > 0) {
-		/* Apply connection information to the RTP instance */
-		ast_sockaddr_set_port(addrs, remote_m_line->port);
-		ast_rtp_instance_set_remote_address(rtp->instance, addrs);
-		ast_free(addrs);
-	}
-
-	if (ast_sdp_options_get_rtcp_mux(options)
-		&& ast_sdp_m_find_attribute(remote_m_line, "rtcp-mux", -1)) {
-		ast_rtp_instance_set_prop(rtp->instance, AST_RTP_PROPERTY_RTCP,
-			AST_RTP_INSTANCE_RTCP_MUX);
-	} else {
-		ast_rtp_instance_set_prop(rtp->instance, AST_RTP_PROPERTY_RTCP,
-			AST_RTP_INSTANCE_RTCP_STANDARD);
-	}
-
-	update_ice(state, rtp->instance, options, remote_sdp, remote_m_line);
-}
-
-/*!
- * \brief Update UDPTL instances based on merged SDPs
- *
- * UDPTL instances, when first allocated, cannot make assumptions about what the other
- * side supports and thus has to go with some default behaviors. This function gets
- * called after we know both what we support and what the remote endpoint supports.
- * This way, we can update the UDPTL instance to reflect what is supported by both
- * sides.
- *
- * \param state The SDP state in which SDPs have been negotiated
- * \param udptl The UDPTL instance that is being updated
- * \param options Our locally-supported SDP options
- * \param remote_sdp The SDP we most recently received
- * \param remote_m_line The remote SDP stream that corresponds to the RTP instance we are modifying
- */
-static void update_udptl_after_merge(const struct ast_sdp_state *state, struct sdp_state_udptl *udptl,
-    const struct ast_sdp_options *options,
-	const struct ast_sdp *remote_sdp,
-	const struct ast_sdp_m_line *remote_m_line)
-{
-	struct ast_sdp_a_line *a_line;
-	struct ast_sdp_c_line *c_line;
-	unsigned int fax_max_datagram;
-	struct ast_sockaddr *addrs;
-
-	if (!udptl) {
-		/* This is a dummy stream */
-		return;
-	}
-
-	a_line = ast_sdp_m_find_attribute(remote_m_line, "t38faxmaxdatagram", -1);
-	if (!a_line) {
-		a_line = ast_sdp_m_find_attribute(remote_m_line, "t38maxdatagram", -1);
-	}
-	if (a_line && !ast_sdp_options_get_udptl_far_max_datagram(options) &&
-		(sscanf(a_line->value, "%30u", &fax_max_datagram) == 1)) {
-		ast_udptl_set_far_max_datagram(udptl->instance, fax_max_datagram);
-	}
-
-	a_line = ast_sdp_m_find_attribute(remote_m_line, "t38faxudpec", -1);
-	if (a_line) {
-		if (!strcasecmp(a_line->value, "t38UDPRedundancy")) {
-			ast_udptl_set_error_correction_scheme(udptl->instance, UDPTL_ERROR_CORRECTION_REDUNDANCY);
-		} else if (!strcasecmp(a_line->value, "t38UDPFEC")) {
-			ast_udptl_set_error_correction_scheme(udptl->instance, UDPTL_ERROR_CORRECTION_FEC);
-		} else {
-			ast_udptl_set_error_correction_scheme(udptl->instance, UDPTL_ERROR_CORRECTION_NONE);
-		}
-	}
-
-	c_line = remote_m_line->c_line;
-	if (!c_line) {
-		c_line = remote_sdp->c_line;
-	}
-	/*
-	 * There must be a c= line somewhere but that would be an error by
-	 * the far end that should have been caught by a validation check
-	 * before we processed the SDP.
-	 */
-	ast_assert(c_line != NULL);
-
-	if (ast_sockaddr_resolve(&addrs, c_line->address, PARSE_PORT_FORBID, AST_AF_UNSPEC) > 0) {
-		/* Apply connection information to the UDPTL instance */
-		ast_sockaddr_set_port(addrs, remote_m_line->port);
-		ast_udptl_set_peer(udptl->instance, addrs);
-		ast_free(addrs);
-	}
-}
-
-static void set_negotiated_capabilities(struct ast_sdp_state *sdp_state,
-	struct sdp_state_capabilities *new_capabilities)
-{
-	struct sdp_state_capabilities *old_capabilities = sdp_state->negotiated_capabilities;
-
-	sdp_state->negotiated_capabilities = new_capabilities;
-	sdp_state_capabilities_free(old_capabilities);
-}
-
-static void set_proposed_capabilities(struct ast_sdp_state *sdp_state,
-	struct sdp_state_capabilities *new_capabilities)
-{
-	struct sdp_state_capabilities *old_capabilities = sdp_state->proposed_capabilities;
-
-	sdp_state->proposed_capabilities = new_capabilities;
-	sdp_state_capabilities_free(old_capabilities);
-}
-
-static struct ast_sdp *sdp_create_from_state(const struct ast_sdp_state *sdp_state,
-	const struct sdp_state_capabilities *capabilities);
-
-/*!
- * \brief Merge SDPs into a joint SDP.
- *
- * This function is used to take a remote SDP and merge it with our local
- * capabilities to produce a new local SDP. After creating the new local SDP,
- * it then iterates through media instances and updates them as necessary. For
- * instance, if a specific RTP feature is supported by both us and the far end,
- * then we can ensure that the feature is enabled.
- *
- * \param sdp_state The current SDP state
- * \retval -1 Failure
- * \retval 0 Success
- */
-static int merge_sdps(struct ast_sdp_state *sdp_state, const struct ast_sdp *remote_sdp)
-{
-	struct sdp_state_capabilities *joint_capabilities;
-	struct ast_stream_topology *remote_capabilities;
-	int i;
-
-	remote_capabilities = ast_get_topology_from_sdp(remote_sdp,
-		sdp_state->options->g726_non_standard);
-	if (!remote_capabilities) {
-		return -1;
-	}
-
-	joint_capabilities = merge_capabilities(sdp_state, remote_capabilities, 0);
-	ast_stream_topology_free(remote_capabilities);
-	if (!joint_capabilities) {
-		return -1;
-	}
-	set_negotiated_capabilities(sdp_state, joint_capabilities);
-
-	if (sdp_state->local_sdp) {
-		ast_sdp_free(sdp_state->local_sdp);
-		sdp_state->local_sdp = NULL;
-	}
-
-	sdp_state->local_sdp = sdp_create_from_state(sdp_state, joint_capabilities);
-	if (!sdp_state->local_sdp) {
-		return -1;
-	}
-
-	for (i = 0; i < AST_VECTOR_SIZE(&joint_capabilities->streams); ++i) {
-		struct sdp_state_stream *state_stream;
-
-		state_stream = AST_VECTOR_GET(&joint_capabilities->streams, i);
-
-		switch (ast_stream_get_type(ast_stream_topology_get_stream(joint_capabilities->topology, i))) {
-		case AST_MEDIA_TYPE_AUDIO:
-		case AST_MEDIA_TYPE_VIDEO:
-			update_rtp_after_merge(sdp_state, state_stream->rtp, sdp_state->options,
-				remote_sdp, ast_sdp_get_m(remote_sdp, i));
-			break;
-		case AST_MEDIA_TYPE_IMAGE:
-			update_udptl_after_merge(sdp_state, state_stream->udptl, sdp_state->options,
-				remote_sdp, ast_sdp_get_m(remote_sdp, i));
-			break;
-		case AST_MEDIA_TYPE_UNKNOWN:
-		case AST_MEDIA_TYPE_TEXT:
-		case AST_MEDIA_TYPE_END:
-			break;
-		}
-	}
-
-	return 0;
-}
-
-const struct ast_sdp *ast_sdp_state_get_local_sdp(struct ast_sdp_state *sdp_state)
-{
-	ast_assert(sdp_state != NULL);
-
-	if (sdp_state->role == SDP_ROLE_NOT_SET) {
-		ast_assert(sdp_state->local_sdp == NULL);
-		sdp_state->role = SDP_ROLE_OFFERER;
-		sdp_state->local_sdp = sdp_create_from_state(sdp_state, sdp_state->proposed_capabilities);
-	}
-
-	return sdp_state->local_sdp;
-}
-
-const void *ast_sdp_state_get_local_sdp_impl(struct ast_sdp_state *sdp_state)
-{
-	const struct ast_sdp *sdp = ast_sdp_state_get_local_sdp(sdp_state);
-
-	if (!sdp) {
-		return NULL;
-	}
-
-	return ast_sdp_translator_from_sdp(sdp_state->translator, sdp);
-}
-
-int ast_sdp_state_set_remote_sdp(struct ast_sdp_state *sdp_state, const struct ast_sdp *sdp)
-{
-	ast_assert(sdp_state != NULL);
-
-	if (sdp_state->role == SDP_ROLE_NOT_SET) {
-		sdp_state->role = SDP_ROLE_ANSWERER;
-	}
-
-	return merge_sdps(sdp_state, sdp);
-}
-
-int ast_sdp_state_set_remote_sdp_from_impl(struct ast_sdp_state *sdp_state, const void *remote)
-{
-	struct ast_sdp *sdp;
-	int ret;
-
-	ast_assert(sdp_state != NULL);
-
-	sdp = ast_sdp_translator_to_sdp(sdp_state->translator, remote);
-	if (!sdp) {
-		return -1;
-	}
-	ret = ast_sdp_state_set_remote_sdp(sdp_state, sdp);
-	ast_sdp_free(sdp);
-	return ret;
-}
-
-int ast_sdp_state_reset(struct ast_sdp_state *sdp_state)
-{
-	ast_assert(sdp_state != NULL);
-
-	ast_sdp_free(sdp_state->local_sdp);
-	sdp_state->local_sdp = NULL;
-
-	set_proposed_capabilities(sdp_state, NULL);
-
-	sdp_state->role = SDP_ROLE_NOT_SET;
-
-	return 0;
-}
-
-int ast_sdp_state_update_local_topology(struct ast_sdp_state *sdp_state, struct ast_stream_topology *streams)
-{
-	struct sdp_state_capabilities *capabilities;
-	ast_assert(sdp_state != NULL);
-	ast_assert(streams != NULL);
-
-	capabilities = merge_capabilities(sdp_state, streams, 1);
-	if (!capabilities) {
-		return -1;
-	}
-	set_proposed_capabilities(sdp_state, capabilities);
-
-	return 0;
-}
-
-void ast_sdp_state_set_local_address(struct ast_sdp_state *sdp_state, struct ast_sockaddr *address)
-{
-	ast_assert(sdp_state != NULL);
-
-	if (!address) {
-		ast_sockaddr_setnull(&sdp_state->proposed_capabilities->connection_address);
-	} else {
-		ast_sockaddr_copy(&sdp_state->proposed_capabilities->connection_address, address);
-	}
-}
-
-int ast_sdp_state_set_connection_address(struct ast_sdp_state *sdp_state, int stream_index,
-	struct ast_sockaddr *address)
-{
-	struct sdp_state_stream *stream_state;
-	ast_assert(sdp_state != NULL);
-
-	stream_state = sdp_state_get_stream(sdp_state, stream_index);
-	if (!stream_state) {
-		return -1;
-	}
-
-	if (!address) {
-		ast_sockaddr_setnull(&stream_state->connection_address);
-	} else {
-		ast_sockaddr_copy(&stream_state->connection_address, address);
-	}
-
-	return 0;
-}
-
-void ast_sdp_state_set_locally_held(struct ast_sdp_state *sdp_state,
-	int stream_index, unsigned int locally_held)
-{
-	struct sdp_state_stream *stream_state;
-	ast_assert(sdp_state != NULL);
-
-	stream_state = sdp_state_get_stream(sdp_state, stream_index);
-	if (!stream_state) {
-		return;
-	}
-
-	stream_state->locally_held = locally_held;
-}
-
-unsigned int ast_sdp_state_get_locally_held(const struct ast_sdp_state *sdp_state,
-	int stream_index)
-{
-	struct sdp_state_stream *stream_state;
-	ast_assert(sdp_state != NULL);
-
-	stream_state = sdp_state_get_stream(sdp_state, stream_index);
-	if (!stream_state) {
-		return 0;
-	}
-
-	return stream_state->locally_held;
-}
-
-void ast_sdp_state_set_t38_parameters(struct ast_sdp_state *sdp_state,
-	int stream_index, struct ast_control_t38_parameters *params)
-{
-	struct sdp_state_stream *stream_state;
-	ast_assert(sdp_state != NULL && params != NULL);
-
-	stream_state = sdp_state_get_stream(sdp_state, stream_index);
-	if (!stream_state) {
-		return;
-	}
-
-	stream_state->t38_local_params = *params;
-}
-
-/*!
- * \brief Add SSRC-level attributes if appropriate.
- *
- * This function does nothing if the SDP options indicate not to add SSRC-level attributes.
- *
- * Currently, the only attribute added is cname, which is retrieved from the RTP instance.
- *
- * \param m_line The m_line on which to add the SSRC attributes
- * \param options Options that indicate what, if any, SSRC attributes to add
- * \param rtp RTP instance from which we get SSRC-level information
- */
-static void add_ssrc_attributes(struct ast_sdp_m_line *m_line, const struct ast_sdp_options *options,
-	struct ast_rtp_instance *rtp)
-{
-	struct ast_sdp_a_line *a_line;
-	char attr_buffer[128];
-
-	if (!ast_sdp_options_get_ssrc(options)) {
-		return;
-	}
-
-	snprintf(attr_buffer, sizeof(attr_buffer), "%u cname:%s", ast_rtp_instance_get_ssrc(rtp),
-		ast_rtp_instance_get_cname(rtp));
-
-	a_line = ast_sdp_a_alloc("ssrc", attr_buffer);
-	if (!a_line) {
-		return;
-	}
-	ast_sdp_m_add_a(m_line, a_line);
-}
-
-static int sdp_add_m_from_rtp_stream(struct ast_sdp *sdp, const struct ast_sdp_state *sdp_state,
-	const struct ast_sdp_options *options, const struct sdp_state_capabilities *capabilities, int stream_index)
-{
-	struct ast_stream *stream;
-	struct ast_sdp_m_line *m_line;
-	struct ast_format_cap *caps;
-	int i;
-	int rtp_code;
-	int rtp_port;
-	int min_packet_size = 0;
-	int max_packet_size = 0;
-	enum ast_media_type media_type;
-	char tmp[64];
-	struct sdp_state_stream *stream_state;
-	struct ast_rtp_instance *rtp;
-	struct ast_sdp_a_line *a_line;
-
-	stream = ast_stream_topology_get_stream(capabilities->topology, stream_index);
-
-	ast_assert(sdp && options && stream);
-
-	caps = ast_stream_get_formats(stream);
-
-	stream_state = AST_VECTOR_GET(&capabilities->streams, stream_index);
-	if (stream_state->rtp && caps && ast_format_cap_count(caps)) {
-		rtp = stream_state->rtp->instance;
-	} else {
-		/* This is a disabled stream */
-		rtp = NULL;
-	}
-
-	if (rtp) {
-		struct ast_sockaddr address_rtp;
-
-		if (ast_sdp_state_get_stream_connection_address(sdp_state, 0, &address_rtp)) {
-			return -1;
-		}
-		rtp_port = ast_sockaddr_port(&address_rtp);
-	} else {
-		rtp_port = 0;
-	}
-
-	m_line = ast_sdp_m_alloc(
-		ast_codec_media_type2str(ast_stream_get_type(stream)),
-		rtp_port, 1,
-		options->encryption != AST_SDP_ENCRYPTION_DISABLED ? "RTP/SAVP" : "RTP/AVP",
-		NULL);
-	if (!m_line) {
-		return -1;
-	}
-
-	if (rtp_port) {
-		/* Stream is not declined/disabled */
-		for (i = 0; i < ast_format_cap_count(caps); i++) {
-			struct ast_format *format = ast_format_cap_get_format(caps, i);
-
-			rtp_code = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(rtp), 1,
-				format, 0);
-			if (rtp_code == -1) {
-				ast_log(LOG_WARNING,"Unable to get rtp codec payload code for %s\n",
-					ast_format_get_name(format));
-				ao2_ref(format, -1);
-				continue;
-			}
-
-			if (ast_sdp_m_add_format(m_line, options, rtp_code, 1, format, 0)) {
-				ast_sdp_m_free(m_line);
-				ao2_ref(format, -1);
-				return -1;
-			}
-
-			if (ast_format_get_maximum_ms(format)
-				&& ((ast_format_get_maximum_ms(format) < max_packet_size)
-					|| !max_packet_size)) {
-				max_packet_size = ast_format_get_maximum_ms(format);
-			}
-
-			ao2_ref(format, -1);
-		}
-
-		media_type = ast_stream_get_type(stream);
-		if (media_type != AST_MEDIA_TYPE_VIDEO
-			&& (options->dtmf == AST_SDP_DTMF_RFC_4733 || options->dtmf == AST_SDP_DTMF_AUTO)) {
-			i = AST_RTP_DTMF;
-			rtp_code = ast_rtp_codecs_payload_code(
-				ast_rtp_instance_get_codecs(rtp), 0, NULL, i);
-			if (-1 < rtp_code) {
-				if (ast_sdp_m_add_format(m_line, options, rtp_code, 0, NULL, i)) {
-					ast_sdp_m_free(m_line);
-					return -1;
-				}
-
-				snprintf(tmp, sizeof(tmp), "%d 0-16", rtp_code);
-				a_line = ast_sdp_a_alloc("fmtp", tmp);
-				if (!a_line || ast_sdp_m_add_a(m_line, a_line)) {
-					ast_sdp_a_free(a_line);
-					ast_sdp_m_free(m_line);
-					return -1;
-				}
-			}
-		}
-
-		/* If ptime is set add it as an attribute */
-		min_packet_size = ast_rtp_codecs_get_framing(ast_rtp_instance_get_codecs(rtp));
-		if (!min_packet_size) {
-			min_packet_size = ast_format_cap_get_framing(caps);
-		}
-		if (min_packet_size) {
-			snprintf(tmp, sizeof(tmp), "%d", min_packet_size);
-
-			a_line = ast_sdp_a_alloc("ptime", tmp);
-			if (!a_line || ast_sdp_m_add_a(m_line, a_line)) {
-				ast_sdp_a_free(a_line);
-				ast_sdp_m_free(m_line);
-				return -1;
-			}
-		}
-
-		if (max_packet_size) {
-			snprintf(tmp, sizeof(tmp), "%d", max_packet_size);
-			a_line = ast_sdp_a_alloc("maxptime", tmp);
-			if (!a_line || ast_sdp_m_add_a(m_line, a_line)) {
-				ast_sdp_a_free(a_line);
-				ast_sdp_m_free(m_line);
-				return -1;
-			}
-		}
-
-		a_line = ast_sdp_a_alloc(ast_sdp_state_get_locally_held(sdp_state, stream_index)
-			? "sendonly" : "sendrecv", "");
-		if (!a_line || ast_sdp_m_add_a(m_line, a_line)) {
-			ast_sdp_a_free(a_line);
-			ast_sdp_m_free(m_line);
-			return -1;
-		}
-
-		add_ssrc_attributes(m_line, options, rtp);
-	} else {
-		/* Declined/disabled stream */
-		struct ast_sdp_payload *payload;
-		const char *fmt;
-
-		/*
-		 * Add a static payload type placeholder to the declined/disabled stream.
-		 *
-		 * XXX We should use the default payload type in the received offer but
-		 * we don't have that available.
-		 */
-		switch (ast_stream_get_type(stream)) {
-		default:
-		case AST_MEDIA_TYPE_AUDIO:
-			fmt = "0"; /* ulaw */
-			break;
-		case AST_MEDIA_TYPE_VIDEO:
-			fmt = "31"; /* H.261 */
-			break;
-		}
-		payload = ast_sdp_payload_alloc(fmt);
-		if (!payload || ast_sdp_m_add_payload(m_line, payload)) {
-			ast_sdp_payload_free(payload);
-			ast_sdp_m_free(m_line);
-			return -1;
-		}
-	}
-
-	if (ast_sdp_add_m(sdp, m_line)) {
-		ast_sdp_m_free(m_line);
-		return -1;
-	}
-
-	return 0;
-}
-
-/*! \brief Get Max T.38 Transmission rate from T38 capabilities */
-static unsigned int t38_get_rate(enum ast_control_t38_rate rate)
-{
-	switch (rate) {
-	case AST_T38_RATE_2400:
-		return 2400;
-	case AST_T38_RATE_4800:
-		return 4800;
-	case AST_T38_RATE_7200:
-		return 7200;
-	case AST_T38_RATE_9600:
-		return 9600;
-	case AST_T38_RATE_12000:
-		return 12000;
-	case AST_T38_RATE_14400:
-		return 14400;
-	default:
-		return 0;
-	}
-}
-
-static int sdp_add_m_from_udptl_stream(struct ast_sdp *sdp, const struct ast_sdp_state *sdp_state,
-	const struct ast_sdp_options *options, const struct sdp_state_capabilities *capabilities, int stream_index)
-{
-	struct ast_stream *stream;
-	struct ast_sdp_m_line *m_line;
-	struct ast_sdp_payload *payload;
-	char tmp[64];
-	struct sdp_state_udptl *udptl;
-	struct ast_sdp_a_line *a_line;
-	struct sdp_state_stream *stream_state;
-	int udptl_port;
-
-	stream = ast_stream_topology_get_stream(capabilities->topology, stream_index);
-
-	ast_assert(sdp && options && stream);
-
-	stream_state = AST_VECTOR_GET(&capabilities->streams, stream_index);
-	if (stream_state->udptl) {
-		udptl = stream_state->udptl;
-	} else {
-		/* This is a disabled stream */
-		udptl = NULL;
-	}
-
-	if (udptl) {
-		struct ast_sockaddr address_udptl;
-
-		if (ast_sdp_state_get_stream_connection_address(sdp_state, 0, &address_udptl)) {
-			return -1;
-		}
-		udptl_port = ast_sockaddr_port(&address_udptl);
-	} else {
-		udptl_port = 0;
-	}
-
-	m_line = ast_sdp_m_alloc(
-		ast_codec_media_type2str(ast_stream_get_type(stream)),
-		udptl_port, 1, "udptl", NULL);
-	if (!m_line) {
-		return -1;
-	}
-
-	payload = ast_sdp_payload_alloc("t38");
-	if (!payload || ast_sdp_m_add_payload(m_line, payload)) {
-		ast_sdp_payload_free(payload);
-		ast_sdp_m_free(m_line);
-		return -1;
-	}
-
-	if (udptl_port) {
-		/* Stream is not declined/disabled */
-		stream_state = sdp_state_get_stream(sdp_state, stream_index);
-
-		snprintf(tmp, sizeof(tmp), "%u", stream_state->t38_local_params.version);
-		a_line = ast_sdp_a_alloc("T38FaxVersion", tmp);
-		if (!a_line || ast_sdp_m_add_a(m_line, a_line)) {
-			ast_sdp_a_free(a_line);
-			ast_sdp_m_free(m_line);
-			return -1;
-		}
-
-		snprintf(tmp, sizeof(tmp), "%u", t38_get_rate(stream_state->t38_local_params.rate));
-		a_line = ast_sdp_a_alloc("T38FaxMaxBitRate", tmp);
-		if (!a_line || ast_sdp_m_add_a(m_line, a_line)) {
-			ast_sdp_a_free(a_line);
-			ast_sdp_m_free(m_line);
-			return -1;
-		}
-
-		if (stream_state->t38_local_params.fill_bit_removal) {
-			a_line = ast_sdp_a_alloc("T38FaxFillBitRemoval", "");
-			if (!a_line || ast_sdp_m_add_a(m_line, a_line)) {
-				ast_sdp_a_free(a_line);
-				ast_sdp_m_free(m_line);
-				return -1;
-			}
-		}
-
-		if (stream_state->t38_local_params.transcoding_mmr) {
-			a_line = ast_sdp_a_alloc("T38FaxTranscodingMMR", "");
-			if (!a_line || ast_sdp_m_add_a(m_line, a_line)) {
-				ast_sdp_a_free(a_line);
-				ast_sdp_m_free(m_line);
-				return -1;
-			}
-		}
-
-		if (stream_state->t38_local_params.transcoding_jbig) {
-			a_line = ast_sdp_a_alloc("T38FaxTranscodingJBIG", "");
-			if (!a_line || ast_sdp_m_add_a(m_line, a_line)) {
-				ast_sdp_a_free(a_line);
-				ast_sdp_m_free(m_line);
-				return -1;
-			}
-		}
-
-		switch (stream_state->t38_local_params.rate_management) {
-		case AST_T38_RATE_MANAGEMENT_TRANSFERRED_TCF:
-			a_line = ast_sdp_a_alloc("T38FaxRateManagement", "transferredTCF");
-			if (!a_line || ast_sdp_m_add_a(m_line, a_line)) {
-				ast_sdp_a_free(a_line);
-				ast_sdp_m_free(m_line);
-				return -1;
-			}
-			break;
-		case AST_T38_RATE_MANAGEMENT_LOCAL_TCF:
-			a_line = ast_sdp_a_alloc("T38FaxRateManagement", "localTCF");
-			if (!a_line || ast_sdp_m_add_a(m_line, a_line)) {
-				ast_sdp_a_free(a_line);
-				ast_sdp_m_free(m_line);
-				return -1;
-			}
-			break;
-		}
-
-		snprintf(tmp, sizeof(tmp), "%u", ast_udptl_get_local_max_datagram(udptl->instance));
-		a_line = ast_sdp_a_alloc("T38FaxMaxDatagram", tmp);
-		if (!a_line || ast_sdp_m_add_a(m_line, a_line)) {
-			ast_sdp_a_free(a_line);
-			ast_sdp_m_free(m_line);
-			return -1;
-		}
-
-		switch (ast_udptl_get_error_correction_scheme(udptl->instance)) {
-		case UDPTL_ERROR_CORRECTION_NONE:
-			break;
-		case UDPTL_ERROR_CORRECTION_FEC:
-			a_line = ast_sdp_a_alloc("T38FaxUdpEC", "t38UDPFEC");
-			if (!a_line || ast_sdp_m_add_a(m_line, a_line)) {
-				ast_sdp_a_free(a_line);
-				ast_sdp_m_free(m_line);
-				return -1;
-			}
-			break;
-		case UDPTL_ERROR_CORRECTION_REDUNDANCY:
-			a_line = ast_sdp_a_alloc("T38FaxUdpEC", "t38UDPRedundancy");
-			if (!a_line || ast_sdp_m_add_a(m_line, a_line)) {
-				ast_sdp_a_free(a_line);
-				ast_sdp_m_free(m_line);
-				return -1;
-			}
-			break;
-		}
-	}
-
-	if (ast_sdp_add_m(sdp, m_line)) {
-		ast_sdp_m_free(m_line);
-		return -1;
-	}
-
-	return 0;
-}
-
-/*!
- * \brief Create an SDP based on current SDP state
- *
- * \param sdp_state The current SDP state
- * \retval NULL Failed to create SDP
- * \retval non-NULL Newly-created SDP
- */
-static struct ast_sdp *sdp_create_from_state(const struct ast_sdp_state *sdp_state,
-	const struct sdp_state_capabilities *capabilities)
-{
-	struct ast_sdp *sdp = NULL;
-	struct ast_stream_topology *topology;
-	const struct ast_sdp_options *options;
-	int stream_num;
-	struct ast_sdp_o_line *o_line = NULL;
-	struct ast_sdp_c_line *c_line = NULL;
-	struct ast_sdp_s_line *s_line = NULL;
-	struct ast_sdp_t_line *t_line = NULL;
-	char *address_type;
-	struct timeval tv = ast_tvnow();
-	uint32_t t;
-	int stream_count;
-
-	options = ast_sdp_state_get_options(sdp_state);
-	topology = capabilities->topology;
-
-	t = tv.tv_sec + 2208988800UL;
-	address_type = (strchr(options->media_address, ':') ? "IP6" : "IP4");
-
-	o_line = ast_sdp_o_alloc(options->sdpowner, t, t, address_type, options->media_address);
-	if (!o_line) {
-		goto error;
-	}
-	c_line = ast_sdp_c_alloc(address_type, options->media_address);
-	if (!c_line) {
-		goto error;
-	}
-	s_line = ast_sdp_s_alloc(options->sdpsession);
-	if (!s_line) {
-		goto error;
-	}
-	t_line = ast_sdp_t_alloc(0, 0);
-	if (!t_line) {
-		goto error;
-	}
-
-	sdp = ast_sdp_alloc(o_line, c_line, s_line, t_line);
-	if (!sdp) {
-		goto error;
-	}
-
-	stream_count = ast_stream_topology_get_count(topology);
-
-	for (stream_num = 0; stream_num < stream_count; stream_num++) {
-		switch (ast_stream_get_type(ast_stream_topology_get_stream(topology, stream_num))) {
-		case AST_MEDIA_TYPE_AUDIO:
-		case AST_MEDIA_TYPE_VIDEO:
-			if (sdp_add_m_from_rtp_stream(sdp, sdp_state, options, capabilities, stream_num)) {
-				goto error;
-			}
-			break;
-		case AST_MEDIA_TYPE_IMAGE:
-			if (sdp_add_m_from_udptl_stream(sdp, sdp_state, options, capabilities, stream_num)) {
-				goto error;
-			}
-			break;
-		case AST_MEDIA_TYPE_UNKNOWN:
-		case AST_MEDIA_TYPE_TEXT:
-		case AST_MEDIA_TYPE_END:
-			break;
-		}
-	}
-
-	return sdp;
-
-error:
-	if (sdp) {
-		ast_sdp_free(sdp);
-	} else {
-		ast_sdp_t_free(t_line);
-		ast_sdp_s_free(s_line);
-		ast_sdp_c_free(c_line);
-		ast_sdp_o_free(o_line);
-	}
-
-	return NULL;
-}
diff --git a/main/sdp_translator.c b/main/sdp_translator.c
deleted file mode 100644
index 6fe330a..0000000
--- a/main/sdp_translator.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * 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/sdp_options.h"
-#include "asterisk/sdp_translator.h"
-#include "asterisk/logger.h"
-#include "asterisk/utils.h"
-#include "asterisk/lock.h"
-
-AST_RWLOCK_DEFINE_STATIC(registered_ops_lock);
-static struct ast_sdp_translator_ops *registered_ops[AST_SDP_IMPL_END];
-
-int ast_sdp_register_translator(struct ast_sdp_translator_ops *ops)
-{
-	SCOPED_WRLOCK(lock, &registered_ops_lock);
-
-	if (ops->repr >= AST_SDP_IMPL_END) {
-		ast_log(LOG_ERROR, "SDP translator has unrecognized representation\n");
-		return -1;
-	}
-
-	if (registered_ops[ops->repr] != NULL) {
-		ast_log(LOG_ERROR, "SDP_translator with this representation already registered\n");
-		return -1;
-	}
-
-	registered_ops[ops->repr] = ops;
-	ast_log(LOG_NOTICE, "Placed ops %p at slot %d\n", ops, ops->repr);
-	return 0;
-}
-
-void ast_sdp_unregister_translator(struct ast_sdp_translator_ops *ops)
-{
-	SCOPED_WRLOCK(lock, &registered_ops_lock);
-
-	if (ops->repr >= AST_SDP_IMPL_END) {
-		return;
-	}
-
-	registered_ops[ops->repr] = NULL;
-}
-
-struct ast_sdp_translator *ast_sdp_translator_new(enum ast_sdp_options_impl repr)
-{
-	struct ast_sdp_translator *translator;
-	SCOPED_RDLOCK(lock, &registered_ops_lock);
-
-	if (registered_ops[repr] == NULL) {
-		ast_log(LOG_NOTICE, "No registered SDP translator with representation %d\n", repr);
-		return NULL;
-	}
-
-	translator = ast_calloc(1, sizeof(*translator));
-	if (!translator) {
-		return NULL;
-	}
-
-	translator->ops = registered_ops[repr];
-
-	translator->translator_priv = translator->ops->translator_new();
-	if (!translator->translator_priv) {
-		ast_free(translator);
-		return NULL;
-	}
-
-	return translator;
-}
-
-void ast_sdp_translator_free(struct ast_sdp_translator *translator)
-{
-	if (!translator) {
-		return;
-	}
-	translator->ops->translator_free(translator->translator_priv);
-	ast_free(translator);
-}
-
-struct ast_sdp *ast_sdp_translator_to_sdp(struct ast_sdp_translator *translator,
-	const void *native_sdp)
-{
-	return translator->ops->to_sdp(native_sdp, translator->translator_priv);
-}
-
-const void *ast_sdp_translator_from_sdp(struct ast_sdp_translator *translator,
-	const struct ast_sdp *ast_sdp)
-{
-	return translator->ops->from_sdp(ast_sdp, translator->translator_priv);
-}
diff --git a/res/res_sdp_translator_pjmedia.c b/res/res_sdp_translator_pjmedia.c
deleted file mode 100644
index 7ee7c46..0000000
--- a/res/res_sdp_translator_pjmedia.c
+++ /dev/null
@@ -1,603 +0,0 @@
-/*
- * 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/sdp_translator.h"
-#include "asterisk/sdp_options.h"
-#include "asterisk/vector.h"
-#include "asterisk/netsock2.h"
-#include "asterisk/utils.h"
-#include "asterisk/config.h"
-#include "asterisk/test.h"
-#include "asterisk/module.h"
-
-#include "asterisk/sdp.h"
-#ifdef HAVE_PJPROJECT
-#include <pjlib.h>
-#include <pjmedia.h>
-#endif
-
-/*** MODULEINFO
-	<depend>pjproject</depend>
-	<support_level>core</support_level>
- ***/
-
-/*
- * XXX TODO: The memory in the pool is held onto longer than necessary.  It
- * is kept and grows for the duration of the associated chan_pjsip session.
- *
- * The translation API does not need to be so generic.  The users will know
- * at compile time what the non-Asterisk SDP format they have or need.  They
- * should simply call the specific translation functions.  However, to make
- * this a loadable module we need to be able to keep it in memory when a
- * dependent module is loaded.
- *
- * To address both issues I propose this API:
- *
- * void ast_sdp_translate_pjmedia_ref(void) - Inc this module's user ref
- * void ast_sdp_translate_pjmedia_unref(void) - Dec this module's user ref.
- *    The res_pjsip_session.c:ast_sip_session_alloc() can call the module ref
- *    and the session's destructor can call the module unref.
- *
- * struct ast_sdp *ast_sdp_translate_pjmedia_from(const pjmedia_sdp_session *pjmedia_sdp);
- *
- * pjmedia_sdp_session *ast_sdp_translate_pjmedia_to(const struct ast_sdp *sdp, pj_pool_t *pool);
- *    Passing in a memory pool allows the memory to be obtained from an
- *    rdata memory pool that will be released when the message processing
- *    is complete.  This prevents memory from accumulating for the duration
- *    of a call.
- *
- * int ast_sdp_translate_pjmedia_set_remote_sdp(struct ast_sdp_state *sdp_state, const pjmedia_sdp_session *remote);
- * const pjmedia_sdp_session *ast_sdp_translate_pjmedia_get_local_sdp(struct ast_sdp_state *sdp_state, pj_pool_t *pool);
- *    These two functions just do the bookkeeping to translate and set or get
- *    the requested SDP.
- *
- *
- * XXX TODO: This code doesn't handle allocation failures very well.  i.e.,
- *   It assumes they will never happen.
- *
- * XXX TODO: This code uses ast_alloca() inside loops.  Doing so if the number
- *   of times through the loop is unconstrained will blow the stack.
- *   See dupa_pj_str() usage.
- */
-
-static pj_caching_pool sdp_caching_pool;
-
-
-static void *pjmedia_new(void)
-{
-	pj_pool_t *pool;
-
-	pool = pj_pool_create(&sdp_caching_pool.factory, "pjmedia sdp translator", 1024, 1024, NULL);
-
-	return pool;
-}
-
-static void pjmedia_free(void *translator_priv)
-{
-	pj_pool_t *pool = translator_priv;
-
-	pj_pool_release(pool);
-}
-
-#define dupa_pj_str(pjstr) \
-({ \
-	char *dest = ast_alloca(pjstr.slen + 1); \
-	memcpy(dest, pjstr.ptr, pjstr.slen); \
-	dest[pjstr.slen] = '\0'; \
-	dest; \
-})
-
-static struct ast_sdp_m_line *pjmedia_copy_m_line(struct pjmedia_sdp_media *pjmedia_m_line)
-{
-	int i;
-
-	struct ast_sdp_c_line *c_line = pjmedia_m_line->conn ?
-		ast_sdp_c_alloc(dupa_pj_str(pjmedia_m_line->conn->addr_type),
-		dupa_pj_str(pjmedia_m_line->conn->addr)) : NULL;
-
-	struct ast_sdp_m_line *m_line = ast_sdp_m_alloc(dupa_pj_str(pjmedia_m_line->desc.media),
-		pjmedia_m_line->desc.port, pjmedia_m_line->desc.port_count,
-		dupa_pj_str(pjmedia_m_line->desc.transport), c_line);
-
-	for (i = 0; i < pjmedia_m_line->desc.fmt_count; ++i) {
-		ast_sdp_m_add_payload(m_line,
-			ast_sdp_payload_alloc(dupa_pj_str(pjmedia_m_line->desc.fmt[i])));
-	}
-
-	for (i = 0; i < pjmedia_m_line->attr_count; ++i) {
-		ast_sdp_m_add_a(m_line, ast_sdp_a_alloc(dupa_pj_str(pjmedia_m_line->attr[i]->name),
-			dupa_pj_str(pjmedia_m_line->attr[i]->value)));
-	}
-
-	return m_line;
-}
-
-static void pjmedia_copy_a_lines(struct ast_sdp *new_sdp, const pjmedia_sdp_session *pjmedia_sdp)
-{
-	int i;
-
-	for (i = 0; i < pjmedia_sdp->attr_count; ++i) {
-		ast_sdp_add_a(new_sdp, ast_sdp_a_alloc(dupa_pj_str(pjmedia_sdp->attr[i]->name),
-			dupa_pj_str(pjmedia_sdp->attr[i]->value)));
-	}
-}
-
-static void pjmedia_copy_m_lines(struct ast_sdp *new_sdp,
-	const struct pjmedia_sdp_session *pjmedia_sdp)
-{
-	int i;
-
-	for (i = 0; i < pjmedia_sdp->media_count; ++i) {
-		ast_sdp_add_m(new_sdp, pjmedia_copy_m_line(pjmedia_sdp->media[i]));
-	}
-}
-
-static struct ast_sdp *pjmedia_to_sdp(const void *in, void *translator_priv)
-{
-	const struct pjmedia_sdp_session *pjmedia_sdp = in;
-
-	struct ast_sdp_o_line *o_line = ast_sdp_o_alloc(dupa_pj_str(pjmedia_sdp->origin.user),
-		pjmedia_sdp->origin.id, pjmedia_sdp->origin.version,
-		dupa_pj_str(pjmedia_sdp->origin.addr_type), dupa_pj_str(pjmedia_sdp->origin.addr));
-
-	struct ast_sdp_c_line *c_line = pjmedia_sdp->conn ?
-		ast_sdp_c_alloc(dupa_pj_str(pjmedia_sdp->conn->addr_type),
-			dupa_pj_str(pjmedia_sdp->conn->addr)) : NULL;
-
-	struct ast_sdp_s_line *s_line = ast_sdp_s_alloc(dupa_pj_str(pjmedia_sdp->name));
-
-	struct ast_sdp_t_line *t_line = ast_sdp_t_alloc(pjmedia_sdp->time.start,
-		pjmedia_sdp->time.stop);
-
-	struct ast_sdp *new_sdp = ast_sdp_alloc(o_line, c_line, s_line, t_line);
-
-	pjmedia_copy_a_lines(new_sdp, pjmedia_sdp);
-	pjmedia_copy_m_lines(new_sdp, pjmedia_sdp);
-
-	return new_sdp;
-}
-
-static void copy_o_line_pjmedia(pj_pool_t *pool, pjmedia_sdp_session *pjmedia_sdp,
-	struct ast_sdp_o_line *o_line)
-{
-	pjmedia_sdp->origin.id = o_line->session_id;
-	pjmedia_sdp->origin.version = o_line->session_version;
-	pj_strdup2(pool, &pjmedia_sdp->origin.user, o_line->username);
-	pj_strdup2(pool, &pjmedia_sdp->origin.addr_type, o_line->address_type);
-	pj_strdup2(pool, &pjmedia_sdp->origin.addr, o_line->address);
-	pj_strdup2(pool, &pjmedia_sdp->origin.net_type, "IN");
-}
-
-static void copy_s_line_pjmedia(pj_pool_t *pool, pjmedia_sdp_session *pjmedia_sdp,
-	struct ast_sdp_s_line *s_line)
-{
-	pj_strdup2(pool, &pjmedia_sdp->name, s_line->session_name);
-}
-
-static void copy_t_line_pjmedia(pj_pool_t *pool, pjmedia_sdp_session *pjmedia_sdp,
-	struct ast_sdp_t_line *t_line)
-{
-	pjmedia_sdp->time.start = t_line->start_time;
-	pjmedia_sdp->time.stop = t_line->stop_time;
-}
-
-static void copy_c_line_pjmedia(pj_pool_t *pool, pjmedia_sdp_conn **conn,
-	struct ast_sdp_c_line *c_line)
-{
-	pjmedia_sdp_conn *local_conn;
-	local_conn = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_conn);
-	pj_strdup2(pool, &local_conn->addr_type, c_line->address_type);
-	pj_strdup2(pool, &local_conn->addr, c_line->address);
-	pj_strdup2(pool, &local_conn->net_type, "IN");
-
-	*conn = local_conn;
-}
-
-static void copy_a_lines_pjmedia(pj_pool_t *pool, pjmedia_sdp_session *pjmedia_sdp,
-	const struct ast_sdp *sdp)
-{
-	int i;
-
-	for (i = 0; i < ast_sdp_get_a_count(sdp); ++i) {
-		pjmedia_sdp_attr *attr;
-		pj_str_t value;
-		struct ast_sdp_a_line *a_line;
-
-		a_line = ast_sdp_get_a(sdp, i);
-		pj_strdup2(pool, &value, a_line->value);
-		attr = pjmedia_sdp_attr_create(pool, a_line->name, &value);
-		pjmedia_sdp_session_add_attr(pjmedia_sdp, attr);
-	}
-}
-
-static void copy_a_lines_pjmedia_media(pj_pool_t *pool, pjmedia_sdp_media *media,
-	struct ast_sdp_m_line *m_line)
-{
-	int i;
-
-	for (i = 0; i < ast_sdp_m_get_a_count(m_line); ++i) {
-		pjmedia_sdp_attr *attr;
-		pj_str_t value;
-		struct ast_sdp_a_line *a_line;
-
-		a_line = ast_sdp_m_get_a(m_line, i);
-		pj_strdup2(pool, &value, a_line->value);
-		attr = pjmedia_sdp_attr_create(pool, a_line->name, &value);
-		pjmedia_sdp_media_add_attr(media, attr);
-	}
-}
-
-static void copy_m_line_pjmedia(pj_pool_t *pool, pjmedia_sdp_media *media,
-	struct ast_sdp_m_line *m_line)
-{
-	int i;
-
-	media->desc.port = m_line->port;
-	media->desc.port_count = m_line->port_count;
-	pj_strdup2(pool, &media->desc.transport, m_line->proto);
-	pj_strdup2(pool, &media->desc.media, m_line->type);
-
-	for (i = 0; i < ast_sdp_m_get_payload_count(m_line); ++i) {
-		pj_strdup2(pool, &media->desc.fmt[i], ast_sdp_m_get_payload(m_line, i)->fmt);
-		++media->desc.fmt_count;
-	}
-	if (m_line->c_line && m_line->c_line->address) {
-		copy_c_line_pjmedia(pool, &media->conn, m_line->c_line);
-	}
-	copy_a_lines_pjmedia_media(pool, media, m_line);
-}
-
-static void copy_m_lines_pjmedia(pj_pool_t *pool, pjmedia_sdp_session *pjmedia_sdp,
-	const struct ast_sdp *sdp)
-{
-	int i;
-
-	for (i = 0; i < ast_sdp_get_m_count(sdp); ++i) {
-		pjmedia_sdp_media *media;
-
-		media = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_media);
-		copy_m_line_pjmedia(pool, media, ast_sdp_get_m(sdp, i));
-		pjmedia_sdp->media[pjmedia_sdp->media_count] = media;
-		++pjmedia_sdp->media_count;
-	}
-}
-
-static const void *sdp_to_pjmedia(const struct ast_sdp *sdp, void *translator_priv)
-{
-	pj_pool_t *pool = translator_priv;
-	pjmedia_sdp_session *pjmedia_sdp;
-
-	pjmedia_sdp = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_session);
-	copy_o_line_pjmedia(pool, pjmedia_sdp, sdp->o_line);
-	copy_s_line_pjmedia(pool, pjmedia_sdp, sdp->s_line);
-	copy_t_line_pjmedia(pool, pjmedia_sdp, sdp->t_line);
-	copy_c_line_pjmedia(pool, &pjmedia_sdp->conn, sdp->c_line);
-	copy_a_lines_pjmedia(pool, pjmedia_sdp, sdp);
-	copy_m_lines_pjmedia(pool, pjmedia_sdp, sdp);
-	return pjmedia_sdp;
-}
-
-static struct ast_sdp_translator_ops pjmedia_translator = {
-	.repr = AST_SDP_IMPL_PJMEDIA,
-	.translator_new = pjmedia_new,
-	.translator_free = pjmedia_free,
-	.to_sdp = pjmedia_to_sdp,
-	.from_sdp = sdp_to_pjmedia,
-};
-
-#ifdef TEST_FRAMEWORK
-
-static int verify_s_line(struct ast_sdp_s_line *s_line, char *expected)
-{
-	return strcmp(s_line->session_name, expected) == 0;
-}
-
-static int verify_c_line(struct ast_sdp_c_line *c_line, char *family, char *addr)
-{
-	return strcmp(c_line->address_type, family) == 0 && strcmp(c_line->address, addr) == 0;
-}
-
-static int verify_t_line(struct ast_sdp_t_line *t_line, uint32_t start, uint32_t end)
-{
-	return t_line->start_time == start && t_line->stop_time == end;
-}
-
-static int verify_m_line(struct ast_sdp *sdp, int index, char *type, int port,
-	int port_count, char *profile, ...)
-{
-	struct ast_sdp_m_line *m_line;
-	int res;
-	va_list ap;
-	int i;
-
-	m_line = ast_sdp_get_m(sdp, index);
-
-	res = strcmp(m_line->type, type) == 0;
-	res |= m_line->port == port;
-	res |= m_line->port_count == port_count;
-	res |= strcmp(m_line->proto, profile) == 0;
-
-	va_start(ap, profile);
-	for (i = 0; i < ast_sdp_m_get_payload_count(m_line); ++i) {
-		char *payload;
-
-		payload = va_arg(ap, char *);
-		if (!payload) {
-			res = -1;
-			break;
-		}
-		res |= strcmp(ast_sdp_m_get_payload(m_line, i)->fmt, payload) == 0;
-	}
-	va_end(ap);
-	return res;
-}
-
-static int verify_a_line(struct ast_sdp *sdp, int m_index, int a_index, char *name,
-	char *value)
-{
-	struct ast_sdp_m_line *m_line;
-	struct ast_sdp_a_line *a_line;
-
-	m_line = ast_sdp_get_m(sdp, m_index);
-	a_line = ast_sdp_m_get_a(m_line, a_index);
-
-	return strcmp(a_line->name, name) == 0 && strcmp(a_line->value, value) == 0;
-}
-
-AST_TEST_DEFINE(pjmedia_to_sdp_test)
-{
-	struct ast_sdp_translator *translator;
-	pj_pool_t *pool;
-	char *sdp_str =
-      "v=0\r\n"
-      "o=alice 2890844526 2890844527 IN IP4 host.atlanta.example.com\r\n"
-      "s= \r\n"
-      "c=IN IP4 host.atlanta.example.com\r\n"
-      "t=123 456\r\n"
-      "m=audio 49170 RTP/AVP 0 8 97\r\n"
-      "a=rtpmap:0 PCMU/8000\r\n"
-      "a=rtpmap:8 PCMA/8000\r\n"
-      "a=rtpmap:97 iLBC/8000\r\n"
-	  "a=sendrecv\r\n"
-      "m=video 51372 RTP/AVP 31 32\r\n"
-      "a=rtpmap:31 H261/90000\r\n"
-      "a=rtpmap:32 MPV/90000\r\n";
-	pjmedia_sdp_session *pjmedia_sdp;
-	struct ast_sdp *sdp = NULL;
-	pj_status_t status;
-	enum ast_test_result_state res = AST_TEST_PASS;
-
-	switch (cmd) {
-	case TEST_INIT:
-		info->name = "pjmedia_to_sdp";
-		info->category = "/main/sdp/";
-		info->summary = "PJMEDIA to SDP unit test";
-		info->description =
-			"Ensures PJMEDIA SDPs are translated correctly";
-		return AST_TEST_NOT_RUN;
-	case TEST_EXECUTE:
-		break;
-	}
-
-	pool = pj_pool_create(&sdp_caching_pool.factory, "pjmedia to sdp test", 1024, 1024, NULL);
-
-	translator = ast_sdp_translator_new(AST_SDP_IMPL_PJMEDIA);
-	if (!translator) {
-		ast_test_status_update(test, "Failed to create SDP translator\n");
-		res = AST_TEST_FAIL;
-		goto cleanup;
-	}
-
-	status = pjmedia_sdp_parse(pool, sdp_str, strlen(sdp_str), &pjmedia_sdp);
-	if (status != PJ_SUCCESS) {
-		ast_test_status_update(test, "Error parsing SDP\n");
-		res = AST_TEST_FAIL;
-		goto cleanup;
-	}
-
-	sdp = ast_sdp_translator_to_sdp(translator, pjmedia_sdp);
-
-	if (strcmp(sdp->o_line->username, "alice")) {
-		ast_test_status_update(test, "Unexpected SDP user '%s'\n", sdp->o_line->username);
-		res = AST_TEST_FAIL;
-		goto cleanup;
-	} else if (sdp->o_line->session_id != 2890844526UL) {
-		ast_test_status_update(test, "Unexpected SDP id '%" PRId64 "lu'\n", sdp->o_line->session_id);
-		res = AST_TEST_FAIL;
-		goto cleanup;
-	} else if (sdp->o_line->session_version != 2890844527UL) {
-		ast_test_status_update(test, "Unexpected SDP version '%" PRId64 "'\n", sdp->o_line->session_version);
-		res = AST_TEST_FAIL;
-		goto cleanup;
-	} else if (strcmp(sdp->o_line->address_type, "IP4")) {
-		ast_test_status_update(test, "Unexpected address family '%s'\n", sdp->o_line->address_type);
-		res = AST_TEST_FAIL;
-		goto cleanup;
-	} else if (strcmp(sdp->o_line->address, "host.atlanta.example.com")) {
-		ast_test_status_update(test, "Unexpected address '%s'\n", sdp->o_line->address);
-		res = AST_TEST_FAIL;
-		goto cleanup;
-	}
-
-	if (!verify_s_line(sdp->s_line, " ")) {
-		ast_test_status_update(test, "Bad s line\n");
-		res = AST_TEST_FAIL;
-		goto cleanup;
-	} else if (!verify_c_line(sdp->c_line, "IP4", "host.atlanta.example.com")) {
-		ast_test_status_update(test, "Bad c line\n");
-		res = AST_TEST_FAIL;
-		goto cleanup;
-	} else if (!verify_t_line(sdp->t_line, 123, 456)) {
-		ast_test_status_update(test, "Bad t line\n");
-		res = AST_TEST_FAIL;
-		goto cleanup;
-	}
-
-	if (!verify_m_line(sdp, 0, "audio", 49170, 1, "RTP/AVP", "0", "8", "97", NULL)) {
-		ast_test_status_update(test, "Bad m line 1\n");
-		res = AST_TEST_FAIL;
-		goto cleanup;
-	} else if (!verify_a_line(sdp, 0, 0, "rtpmap", "0 PCMU/8000")) {
-		ast_test_status_update(test, "Bad a line 1\n");
-		res = AST_TEST_FAIL;
-		goto cleanup;
-	} else if (!verify_a_line(sdp, 0, 1, "rtpmap", "8 PCMA/8000")) {
-		ast_test_status_update(test, "Bad a line 2\n");
-		res = AST_TEST_FAIL;
-		goto cleanup;
-	} else if (!verify_a_line(sdp, 0, 2, "rtpmap", "97 iLBC/8000")) {
-		ast_test_status_update(test, "Bad a line 3\n");
-		res = AST_TEST_FAIL;
-		goto cleanup;
-	} else if (!verify_a_line(sdp, 0, 3, "sendrecv", "")) {
-		ast_test_status_update(test, "Bad a line 3\n");
-		res = AST_TEST_FAIL;
-		goto cleanup;
-	} else if (!verify_m_line(sdp, 1, "video", 51372, 1, "RTP/AVP", "31", "32", NULL)) {
-		ast_test_status_update(test, "Bad m line 2\n");
-		res = AST_TEST_FAIL;
-		goto cleanup;
-	} else if (!verify_a_line(sdp, 1, 0, "rtpmap", "31 H261/90000")) {
-		ast_test_status_update(test, "Bad a line 4\n");
-		res = AST_TEST_FAIL;
-		goto cleanup;
-	} else if (!verify_a_line(sdp, 1, 1, "rtpmap", "32 MPV/90000")) {
-		ast_test_status_update(test, "Bad a line 5\n");
-		res = AST_TEST_FAIL;
-		goto cleanup;
-	}
-
-cleanup:
-	ast_sdp_free(sdp);
-	ast_sdp_translator_free(translator);
-	pj_pool_release(pool);
-	return res;
-}
-
-AST_TEST_DEFINE(sdp_to_pjmedia_test)
-{
-	struct ast_sdp_translator *translator;
-	char *sdp_str =
-      "v=0\r\n"
-      "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
-      "s= \r\n"
-      "c=IN IP4 host.atlanta.example.com\r\n"
-      "t=123 456\r\n"
-      "m=audio 49170 RTP/AVP 0 8 97\r\n"
-      "a=rtpmap:0 PCMU/8000\r\n"
-      "a=rtpmap:8 PCMA/8000\r\n"
-      "a=rtpmap:97 iLBC/8000\r\n"
-	  "a=sendrecv\r\n"
-      "m=video 51372 RTP/AVP 31 32\r\n"
-      "a=rtpmap:31 H261/90000\r\n"
-      "a=rtpmap:32 MPV/90000\r\n\r\n";
-	pj_pool_t *pool;
-	pjmedia_sdp_session *pjmedia_sdp_orig;
-	const pjmedia_sdp_session *pjmedia_sdp_dup;
-	struct ast_sdp *sdp = NULL;
-	pj_status_t status;
-	enum ast_test_result_state res = AST_TEST_PASS;
-	char buf[2048];
-	char errbuf[256];
-
-	switch (cmd) {
-	case TEST_INIT:
-		info->name = "sdp_to_pjmedia";
-		info->category = "/main/sdp/";
-		info->summary = "SDP to PJMEDIA unit test";
-		info->description =
-			"Ensures PJMEDIA SDPs are translated correctly";
-		return AST_TEST_NOT_RUN;
-	case TEST_EXECUTE:
-		break;
-	}
-
-	pool = pj_pool_create(&sdp_caching_pool.factory, "pjmedia to sdp test", 1024, 1024, NULL);
-
-	translator = ast_sdp_translator_new(AST_SDP_IMPL_PJMEDIA);
-	if (!translator) {
-		ast_test_status_update(test, "Failed to create SDP translator\n");
-		res = AST_TEST_FAIL;
-		goto cleanup;
-	}
-
-	status = pjmedia_sdp_parse(pool, sdp_str, strlen(sdp_str), &pjmedia_sdp_orig);
-	if (status != PJ_SUCCESS) {
-		ast_test_status_update(test, "Error parsing SDP\n");
-		res = AST_TEST_FAIL;
-		goto cleanup;
-	}
-
-	sdp = ast_sdp_translator_to_sdp(translator, pjmedia_sdp_orig);
-	pjmedia_sdp_dup = ast_sdp_translator_from_sdp(translator, sdp);
-
-	if ((status = pjmedia_sdp_session_cmp(pjmedia_sdp_orig, pjmedia_sdp_dup, 0)) != PJ_SUCCESS) {
-		ast_test_status_update(test, "SDPs aren't equal\n");
-		pjmedia_sdp_print(pjmedia_sdp_orig, buf, sizeof(buf));
-		ast_test_status_update(test, "Original SDP is %s\n", buf);
-		pjmedia_sdp_print(pjmedia_sdp_dup, buf, sizeof(buf));
-		ast_test_status_update(test, "New SDP is %s\n", buf);
-		pjmedia_strerror(status, errbuf, sizeof(errbuf));
-		ast_test_status_update(test, "PJMEDIA says %d: '%s'\n", status, errbuf);
-		res = AST_TEST_FAIL;
-		goto cleanup;
-	}
-
-cleanup:
-	ast_sdp_free(sdp);
-	ast_sdp_translator_free(translator);
-	pj_pool_release(pool);
-	return res;
-}
-
-#endif /* TEST_FRAMEWORK */
-
-static int load_module(void)
-{
-	if (ast_sdp_register_translator(&pjmedia_translator)) {
-		return AST_MODULE_LOAD_DECLINE;
-	}
-	pj_caching_pool_init(&sdp_caching_pool, NULL, 1024 * 1024);
-	AST_TEST_REGISTER(pjmedia_to_sdp_test);
-	AST_TEST_REGISTER(sdp_to_pjmedia_test);
-
-	return AST_MODULE_LOAD_SUCCESS;
-}
-
-static int unload_module(void)
-{
-	ast_sdp_unregister_translator(&pjmedia_translator);
-	pj_caching_pool_destroy(&sdp_caching_pool);
-	AST_TEST_UNREGISTER(pjmedia_to_sdp_test);
-	AST_TEST_UNREGISTER(sdp_to_pjmedia_test);
-	return 0;
-}
-
-static int reload_module(void)
-{
-	return 0;
-}
-
-AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PJMEDIA SDP Translator",
-	.support_level = AST_MODULE_SUPPORT_CORE,
-	.load = load_module,
-	.unload = unload_module,
-	.reload = reload_module,
-	.load_pri = AST_MODPRI_CHANNEL_DEPEND,
-);
diff --git a/tests/test_sdp.c b/tests/test_sdp.c
deleted file mode 100644
index 7eef3f7..0000000
--- a/tests/test_sdp.c
+++ /dev/null
@@ -1,1212 +0,0 @@
-/*
- * Asterisk -- An open source telephony toolkit.
- *
- * Copyright (C) 2017, Digium Inc.
- *
- * Mark Michelson <mmmichelson 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.
- */
-
-/*** MODULEINFO
-	<depend>TEST_FRAMEWORK</depend>
-	<support_level>core</support_level>
- ***/
-
-#include "asterisk.h"
-#include "asterisk/test.h"
-#include "asterisk/module.h"
-#include "asterisk/sdp.h"
-#include "asterisk/stream.h"
-#include "asterisk/format.h"
-#include "asterisk/format_cache.h"
-#include "asterisk/format_cap.h"
-#include "asterisk/rtp_engine.h"
-
-static int validate_o_line(struct ast_test *test, const struct ast_sdp_o_line *o_line,
-	const char *sdpowner, const char *address_type, const char *address)
-{
-	if (!o_line) {
-		return -1;
-	}
-
-	if (strcmp(o_line->username, sdpowner)) {
-		ast_test_status_update(test, "Expected o-line SDP owner %s but got %s\n",
-			sdpowner, o_line->username);
-		return -1;
-	}
-
-	if (strcmp(o_line->address_type, address_type)) {
-		ast_test_status_update(test, "Expected o-line SDP address type %s but got %s\n",
-			address_type, o_line->address_type);
-		return -1;
-	}
-
-	if (strcmp(o_line->address, address)) {
-		ast_test_status_update(test, "Expected o-line SDP address %s but got %s\n",
-			address, o_line->address);
-		return -1;
-	}
-
-	ast_test_status_update(test, "SDP o-line is as expected!\n");
-	return 0;
-}
-
-static int validate_c_line(struct ast_test *test, const struct ast_sdp_c_line *c_line,
-	const char *address_type, const char *address)
-{
-	if (strcmp(c_line->address_type, address_type)) {
-		ast_test_status_update(test, "Expected c-line SDP address type %s but got %s\n",
-			address_type, c_line->address_type);
-		return -1;
-	}
-
-	if (strcmp(c_line->address, address)) {
-		ast_test_status_update(test, "Expected c-line SDP address %s but got %s\n",
-			address, c_line->address);
-		return -1;
-	}
-
-	ast_test_status_update(test, "SDP c-line is as expected!\n");
-	return 0;
-}
-
-static int validate_m_line(struct ast_test *test, const struct ast_sdp_m_line *m_line,
-	const char *media_type, int num_payloads)
-{
-	if (strcmp(m_line->type, media_type)) {
-		ast_test_status_update(test, "Expected m-line media type %s but got %s\n",
-			media_type, m_line->type);
-		return -1;
-	}
-
-	if (ast_sdp_m_get_payload_count(m_line) != num_payloads) {
-		ast_test_status_update(test, "Expected m-line payload count %d but got %d\n",
-			num_payloads, ast_sdp_m_get_payload_count(m_line));
-		return -1;
-	}
-
-	ast_test_status_update(test, "SDP m-line is as expected\n");
-	return 0;
-}
-
-static int validate_rtpmap(struct ast_test *test, const struct ast_sdp_m_line *m_line,
-	const char *media_name)
-{
-	struct ast_sdp_a_line *a_line;
-	int i;
-
-	for (i = 0; i < ast_sdp_m_get_a_count(m_line); ++i) {
-		struct ast_sdp_rtpmap *rtpmap;
-		int match;
-
-		a_line = ast_sdp_m_get_a(m_line, i);
-		if (strcmp(a_line->name, "rtpmap")) {
-			continue;
-		}
-
-		rtpmap = ast_sdp_a_get_rtpmap(a_line);
-		if (!rtpmap) {
-			return -1;
-		}
-
-		match = !strcmp(rtpmap->encoding_name, media_name);
-
-		ast_sdp_rtpmap_free(rtpmap);
-		if (match) {
-			return 0;
-		}
-	}
-
-	ast_test_status_update(test, "Could not find rtpmap with encoding name %s\n", media_name);
-
-	return -1;
-}
-
-static enum ast_test_result_state validate_t38(struct ast_test *test, const struct ast_sdp_m_line *m_line)
-{
-	struct ast_sdp_a_line *a_line;
-
-	a_line = ast_sdp_m_find_attribute(m_line, "T38FaxVersion", -1);
-	ast_test_validate(test, a_line && !strcmp(a_line->value, "0"));
-
-	a_line = ast_sdp_m_find_attribute(m_line, "T38FaxMaxBitRate", -1);
-	ast_test_validate(test, a_line && !strcmp(a_line->value, "14400"));
-
-	a_line = ast_sdp_m_find_attribute(m_line, "T38FaxRateManagement", -1);
-	ast_test_validate(test, a_line && !strcmp(a_line->value, "transferredTCF"));
-
-	return AST_TEST_PASS;
-}
-
-AST_TEST_DEFINE(invalid_rtpmap)
-{
-	/* a=rtpmap: is already assumed. This is the part after that */
-	static const char *invalids[] = {
-		"J PCMU/8000",
-		"0 PCMU:8000",
-		"0 PCMU/EIGHT-THOUSAND",
-		"0 PCMU/8000million/2",
-		"0 PCMU//2",
-		"0 /8000/2",
-		"0 PCMU/8000/",
-		"0 PCMU/8000million",
-	};
-	int i;
-	enum ast_test_result_state res = AST_TEST_PASS;
-
-	switch(cmd) {
-	case TEST_INIT:
-		info->name = "invalid_rtpmap";
-		info->category = "/main/sdp/";
-		info->summary = "Ensure invalid rtpmaps are rejected";
-		info->description =
-			"Try to convert several invalid rtpmap attributes. If\n"
-			"any succeeds, the test fails.";
-		return AST_TEST_NOT_RUN;
-	case TEST_EXECUTE:
-		break;
-	}
-
-	for (i = 0; i < ARRAY_LEN(invalids); ++i) {
-		struct ast_sdp_a_line *a_line;
-		struct ast_sdp_rtpmap *rtpmap;
-
-		a_line = ast_sdp_a_alloc("rtpmap", invalids[i]);
-		rtpmap = ast_sdp_a_get_rtpmap(a_line);
-		if (rtpmap) {
-			ast_test_status_update(test, "Invalid rtpmap '%s' was accepted as valid\n",
-				invalids[i]);
-			res = AST_TEST_FAIL;
-		}
-		ast_sdp_a_free(a_line);
-		ast_sdp_rtpmap_free(rtpmap);
-	}
-
-	return res;
-}
-
-AST_TEST_DEFINE(rtpmap)
-{
-	static const char *valids[] = {
-		"0 PCMU/8000",
-		"107 opus/48000/2",
-	};
-	static int payloads[] = {
-		0,
-		107,
-	};
-	static const char *encoding_names[] = {
-		"PCMU",
-		"opus",
-	};
-	static int clock_rates[] = {
-		8000,
-		48000,
-	};
-	static const char *encoding_parameters[] = {
-		"",
-		"2",
-	};
-	int i;
-	enum ast_test_result_state res = AST_TEST_PASS;
-
-	switch(cmd) {
-	case TEST_INIT:
-		info->name = "rtpmap";
-		info->category = "/main/sdp/";
-		info->summary = "Ensure rtpmap attribute values are parsed correctly";
-		info->description =
-			"Parse several valid rtpmap attributes. Ensure that the parsed values\n"
-			"are what we expect";
-		return AST_TEST_NOT_RUN;
-	case TEST_EXECUTE:
-		break;
-	}
-
-	for (i = 0; i < ARRAY_LEN(valids); ++i) {
-		struct ast_sdp_a_line *a_line;
-		struct ast_sdp_rtpmap *rtpmap;
-
-		a_line = ast_sdp_a_alloc("rtpmap", valids[i]);
-		rtpmap = ast_sdp_a_get_rtpmap(a_line);
-		if (!rtpmap) {
-			ast_test_status_update(test, "Valid rtpmap '%s' was rejected as invalid\n",
-				valids[i]);
-			res = AST_TEST_FAIL;
-			continue;
-		}
-		if (rtpmap->payload != payloads[i]) {
-			ast_test_status_update(test, "RTPmap payload '%d' does not match expected '%d'\n",
-				rtpmap->payload, payloads[i]);
-			res = AST_TEST_FAIL;
-		}
-		if (strcmp(rtpmap->encoding_name, encoding_names[i])) {
-			ast_test_status_update(test, "RTPmap encoding_name '%s' does not match expected '%s'\n",
-				rtpmap->encoding_name, encoding_names[i]);
-			res = AST_TEST_FAIL;
-		}
-		if (rtpmap->clock_rate != clock_rates[i]) {
-			ast_test_status_update(test, "RTPmap clock rate '%d' does not match expected '%d'\n",
-				rtpmap->clock_rate, clock_rates[i]);
-			res = AST_TEST_FAIL;
-		}
-		if (strcmp(rtpmap->encoding_parameters, encoding_parameters[i])) {
-			ast_test_status_update(test, "RTPmap encoding_parameter '%s' does not match expected '%s'\n",
-				rtpmap->encoding_parameters, encoding_parameters[i]);
-			res = AST_TEST_FAIL;
-		}
-		ast_sdp_a_free(a_line);
-		ast_sdp_rtpmap_free(rtpmap);
-	}
-
-	return res;
-}
-
-AST_TEST_DEFINE(find_attr)
-{
-	enum ast_test_result_state res = AST_TEST_PASS;
-	struct ast_sdp_m_line *m_line;
-	struct ast_sdp_a_line *a_line;
-	int idx;
-
-	switch(cmd) {
-	case TEST_INIT:
-		info->name = "find_attr";
-		info->category = "/main/sdp/";
-		info->summary = "Ensure that finding attributes works as expected";
-		info->description =
-			"A SDP m-line is created, and attributes are added.\n"
-			"We then attempt a series of attribute-finding calls that are expected to work\n"
-			"followed by a series of attribute-finding calls that are expected fo fail.";
-		return AST_TEST_NOT_RUN;
-	case TEST_EXECUTE:
-		break;
-	}
-
-	m_line = ast_sdp_m_alloc("audio", 666, 1, "RTP/AVP", NULL);
-	if (!m_line) {
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-	a_line = ast_sdp_a_alloc("foo", "0 bar");
-	if (!a_line) {
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-	ast_sdp_m_add_a(m_line, a_line);
-	a_line = ast_sdp_a_alloc("foo", "0 bee");
-	if (!a_line) {
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-	ast_sdp_m_add_a(m_line, a_line);
-
-	a_line = ast_sdp_a_alloc("baz", "howdy");
-	if (!a_line) {
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-	ast_sdp_m_add_a(m_line, a_line);
-
-	/* These should work */
-	a_line = ast_sdp_m_find_attribute(m_line, "foo", 0);
-	if (!a_line || strcmp(a_line->value, "0 bar")) {
-		ast_test_status_update(test, "Failed to find attribute 'foo' with payload '0'\n");
-		res = AST_TEST_FAIL;
-	}
-	a_line = ast_sdp_m_find_attribute(m_line, "foo", -1);
-	if (!a_line || strcmp(a_line->value, "0 bar")) {
-		ast_test_status_update(test, "Failed to find attribute 'foo' with unspecified payload\n");
-		res = AST_TEST_FAIL;
-	}
-	a_line = ast_sdp_m_find_attribute(m_line, "baz", -1);
-	if (!a_line || strcmp(a_line->value, "howdy")) {
-		ast_test_status_update(test, "Failed to find attribute 'baz' with unspecified payload\n");
-		res = AST_TEST_FAIL;
-	}
-
-	idx = ast_sdp_m_find_a_first(m_line, "foo", 0);
-	if (idx < 0) {
-		ast_test_status_update(test, "Failed to find first attribute 'foo' with payload '0'\n");
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-	a_line = ast_sdp_m_get_a(m_line, idx);
-	if (!a_line || strcmp(a_line->value, "0 bar")) {
-		ast_test_status_update(test, "Find first attribute 'foo' with payload '0' didn't match\n");
-		res = AST_TEST_FAIL;
-	}
-	idx = ast_sdp_m_find_a_next(m_line, idx, "foo", 0);
-	if (idx < 0) {
-		ast_test_status_update(test, "Failed to find next attribute 'foo' with payload '0'\n");
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-	a_line = ast_sdp_m_get_a(m_line, idx);
-	if (!a_line || strcmp(a_line->value, "0 bee")) {
-		ast_test_status_update(test, "Find next attribute 'foo' with payload '0' didn't match\n");
-		res = AST_TEST_FAIL;
-	}
-	idx = ast_sdp_m_find_a_next(m_line, idx, "foo", 0);
-	if (0 <= idx) {
-		ast_test_status_update(test, "Find next attribute 'foo' with payload '0' found too many\n");
-		res = AST_TEST_FAIL;
-	}
-
-	idx = ast_sdp_m_find_a_first(m_line, "foo", -1);
-	if (idx < 0) {
-		ast_test_status_update(test, "Failed to find first attribute 'foo' with unspecified payload\n");
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-	a_line = ast_sdp_m_get_a(m_line, idx);
-	if (!a_line || strcmp(a_line->value, "0 bar")) {
-		ast_test_status_update(test, "Find first attribute 'foo' with unspecified payload didn't match\n");
-		res = AST_TEST_FAIL;
-	}
-	idx = ast_sdp_m_find_a_next(m_line, idx, "foo", -1);
-	if (idx < 0) {
-		ast_test_status_update(test, "Failed to find next attribute 'foo' with unspecified payload\n");
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-	a_line = ast_sdp_m_get_a(m_line, idx);
-	if (!a_line || strcmp(a_line->value, "0 bee")) {
-		ast_test_status_update(test, "Find next attribute 'foo' with unspecified payload didn't match\n");
-		res = AST_TEST_FAIL;
-	}
-	idx = ast_sdp_m_find_a_next(m_line, idx, "foo", -1);
-	if (0 <= idx) {
-		ast_test_status_update(test, "Find next attribute 'foo' with unspecified payload found too many\n");
-		res = AST_TEST_FAIL;
-	}
-
-	/* These should fail */
-	a_line = ast_sdp_m_find_attribute(m_line, "foo", 1);
-	if (a_line) {
-		ast_test_status_update(test, "Found non-existent attribute 'foo' with payload '1'\n");
-		res = AST_TEST_FAIL;
-	}
-	a_line = ast_sdp_m_find_attribute(m_line, "baz", 0);
-	if (a_line) {
-		ast_test_status_update(test, "Found non-existent attribute 'baz' with payload '0'\n");
-		res = AST_TEST_FAIL;
-	}
-	a_line = ast_sdp_m_find_attribute(m_line, "wibble", 0);
-	if (a_line) {
-		ast_test_status_update(test, "Found non-existent attribute 'wibble' with payload '0'\n");
-		res = AST_TEST_FAIL;
-	}
-	a_line = ast_sdp_m_find_attribute(m_line, "wibble", -1);
-	if (a_line) {
-		ast_test_status_update(test, "Found non-existent attribute 'wibble' with unspecified payload\n");
-		res = AST_TEST_FAIL;
-	}
-
-end:
-	ast_sdp_m_free(m_line);
-	return res;
-}
-
-static struct ast_sdp_options *sdp_options_common(void)
-{
-	struct ast_sdp_options *options;
-
-	options = ast_sdp_options_alloc();
-	if (!options) {
-		return NULL;
-	}
-	ast_sdp_options_set_media_address(options, "127.0.0.1");
-	ast_sdp_options_set_sdpowner(options, "me");
-	ast_sdp_options_set_rtp_engine(options, "asterisk");
-	ast_sdp_options_set_impl(options, AST_SDP_IMPL_PJMEDIA);
-
-	return options;
-}
-
-struct sdp_format {
-	enum ast_media_type type;
-	const char *formats;
-};
-
-/*!
- * \brief Common method to build an SDP state for a test.
- *
- * This uses the passed-in formats to create a stream topology, which is then used to create the SDP
- * state.
- *
- * There is an optional test_options field you can use if your test has specific options you need to
- * set. If your test does not require anything special, it can just pass NULL for this parameter. If
- * you do pass in test_options, this function steals ownership of those options.
- *
- * \param num_streams The number of elements in the formats array.
- * \param formats Array of media types and formats that will be in the state.
- * \param test_options Optional SDP options.
- */
-static struct ast_sdp_state *build_sdp_state(int num_streams, const struct sdp_format *formats, struct ast_sdp_options *test_options)
-{
-	struct ast_stream_topology *topology = NULL;
-	struct ast_sdp_state *state = NULL;
-	struct ast_sdp_options *options;
-	int i;
-
-	if (!test_options) {
-		options = sdp_options_common();
-		if (!options) {
-			goto end;
-		}
-	} else {
-		options = test_options;
-	}
-
-	topology = ast_stream_topology_alloc();
-	if (!topology) {
-		goto end;
-	}
-
-	for (i = 0; i < num_streams; ++i) {
-		RAII_VAR(struct ast_format_cap *, caps, NULL, ao2_cleanup);
-		struct ast_stream *stream;
-
-		caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
-		if (!caps) {
-			goto end;
-		}
-		if (ast_format_cap_update_by_allow_disallow(caps, formats[i].formats, 1) < 0) {
-			goto end;
-		}
-		stream = ast_stream_alloc("sure_thing", formats[i].type);
-		if (!stream) {
-			goto end;
-		}
-		ast_stream_set_formats(stream, caps);
-		ast_stream_topology_append_stream(topology, stream);
-	}
-
-	state = ast_sdp_state_alloc(topology, options);
-	if (!state) {
-		goto end;
-	}
-
-end:
-	ast_stream_topology_free(topology);
-	if (!state) {
-		ast_sdp_options_free(options);
-	}
-
-	return state;
-}
-
-AST_TEST_DEFINE(topology_to_sdp)
-{
-	enum ast_test_result_state res = AST_TEST_FAIL;
-	struct ast_sdp_state *sdp_state = NULL;
-	const struct ast_sdp *sdp = NULL;
-	struct ast_sdp_m_line *m_line = NULL;
-	struct sdp_format formats[] = {
-		{ AST_MEDIA_TYPE_AUDIO, "ulaw,alaw,g722,opus" },
-		{ AST_MEDIA_TYPE_VIDEO, "h264,vp8" },
-		{ AST_MEDIA_TYPE_IMAGE, "t38" },
-	};
-
-	switch(cmd) {
-	case TEST_INIT:
-		info->name = "topology_to_sdp";
-		info->category = "/main/sdp/";
-		info->summary = "Convert a topology into an SDP";
-		info->description =
-			"Ensure SDPs get converted to expected stream topology";
-		return AST_TEST_NOT_RUN;
-	case TEST_EXECUTE:
-		break;
-	}
-
-	sdp_state = build_sdp_state(ARRAY_LEN(formats), formats, NULL);
-	if (!sdp_state) {
-		goto end;
-	}
-
-	sdp = ast_sdp_state_get_local_sdp(sdp_state);
-	if (!sdp) {
-		goto end;
-	}
-
-	if (validate_o_line(test, sdp->o_line, "me", "IP4", "127.0.0.1")) {
-		goto end;
-	}
-
-	if (validate_c_line(test, sdp->c_line, "IP4", "127.0.0.1")) {
-		goto end;
-	}
-
-	if (ast_sdp_get_m_count(sdp) != 3) {
-		ast_test_status_update(test, "Unexpected number of streams in generated SDP: %d\n",
-			ast_sdp_get_m_count(sdp));
-		goto end;
-	}
-
-	m_line = ast_sdp_get_m(sdp, 0);
-
-	if (validate_m_line(test, m_line, "audio", 4)) {
-		goto end;
-	}
-
-	if (validate_rtpmap(test, m_line, "PCMU")) {
-		goto end;
-	}
-
-	if (validate_rtpmap(test, m_line, "PCMA")) {
-		goto end;
-	}
-
-	if (validate_rtpmap(test, m_line, "G722")) {
-		goto end;
-	}
-
-	if (validate_rtpmap(test, m_line, "opus")) {
-		goto end;
-	}
-
-	m_line = ast_sdp_get_m(sdp, 1);
-	if (validate_m_line(test, m_line, "video", 2)) {
-		goto end;
-	}
-
-	if (validate_rtpmap(test, m_line, "VP8")) {
-		goto end;
-	}
-
-	if (validate_rtpmap(test, m_line, "H264")) {
-		goto end;
-	}
-
-	m_line = ast_sdp_get_m(sdp, 2);
-	if (validate_m_line(test, m_line, "image", 1)) {
-		goto end;
-	}
-	if (validate_t38(test, m_line) != AST_TEST_PASS) {
-		goto end;
-	}
-
-	res = AST_TEST_PASS;
-
-end:
-	ast_sdp_state_free(sdp_state);
-	return res;
-}
-
-static int validate_formats(struct ast_test *test, struct ast_stream_topology *topology, int index,
-	enum ast_media_type type, int format_count, const char **expected_formats)
-{
-	struct ast_stream *stream;
-	struct ast_format_cap *caps;
-	struct ast_format *format;
-	int i;
-
-	stream = ast_stream_topology_get_stream(topology, index);
-	if (ast_stream_get_type(stream) != type) {
-		ast_test_status_update(test, "Unexpected stream type encountered\n");
-		return -1;
-	}
-	caps = ast_stream_get_formats(stream);
-
-	if (ast_format_cap_count(caps) != format_count) {
-		ast_test_status_update(test, "Unexpected format count '%d'. Expecting '%d'\n",
-			(int) ast_format_cap_count(caps), format_count);
-		return -1;
-	}
-
-	for (i = 0; i < ast_format_cap_count(caps); ++i) {
-		format = ast_format_cap_get_format(caps, i);
-		if (strcmp(ast_format_get_name(format), expected_formats[i])) {
-			ast_test_status_update(test, "Unexpected format '%s'at index %d. Expected '%s'\n",
-				ast_format_get_name(format), i, expected_formats[i]);
-			return -1;
-		}
-	}
-
-	return 0;
-}
-
-AST_TEST_DEFINE(sdp_to_topology)
-{
-	enum ast_test_result_state res = AST_TEST_PASS;
-	struct ast_sdp_state *sdp_state;
-	const struct ast_sdp *sdp;
-	struct ast_stream_topology *topology = NULL;
-	struct sdp_format sdp_formats[] = {
-		{ AST_MEDIA_TYPE_AUDIO, "ulaw,alaw,g722,opus" },
-		{ AST_MEDIA_TYPE_VIDEO, "h264,vp8" },
-		{ AST_MEDIA_TYPE_IMAGE, "t38" },
-	};
-	static const char *expected_audio_formats[] = {
-		"ulaw",
-		"alaw",
-		"g722",
-		"opus",
-	};
-	static const char *expected_video_formats[] = {
-		"h264",
-		"vp8",
-	};
-	static const char *expected_image_formats[] = {
-		"t38",
-	};
-
-	switch(cmd) {
-	case TEST_INIT:
-		info->name = "sdp_to_topology";
-		info->category = "/main/sdp/";
-		info->summary = "Convert an SDP into a topology";
-		info->description =
-			"Ensure SDPs get converted to expected stream topology";
-		return AST_TEST_NOT_RUN;
-	case TEST_EXECUTE:
-		break;
-	}
-
-	sdp_state = build_sdp_state(ARRAY_LEN(sdp_formats), sdp_formats, NULL);
-	if (!sdp_state) {
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-
-	sdp = ast_sdp_state_get_local_sdp(sdp_state);
-	if (!sdp) {
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-
-	topology = ast_get_topology_from_sdp(sdp, 0);
-	if (!topology) {
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-
-	if (ast_stream_topology_get_count(topology) != 3) {
-		ast_test_status_update(test, "Unexpected topology count '%d'. Expecting 3\n",
-			ast_stream_topology_get_count(topology));
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-
-	if (validate_formats(test, topology, 0, AST_MEDIA_TYPE_AUDIO,
-			ARRAY_LEN(expected_audio_formats), expected_audio_formats)) {
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-
-	if (validate_formats(test, topology, 1, AST_MEDIA_TYPE_VIDEO,
-			ARRAY_LEN(expected_video_formats), expected_video_formats)) {
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-
-	if (validate_formats(test, topology, 2, AST_MEDIA_TYPE_IMAGE,
-			ARRAY_LEN(expected_image_formats), expected_image_formats)) {
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-
-end:
-	ast_sdp_state_free(sdp_state);
-	ast_stream_topology_free(topology);
-	return res;
-}
-
-static int validate_merged_sdp(struct ast_test *test, const struct ast_sdp *sdp)
-{
-	struct ast_sdp_m_line *m_line;
-
-	if (!sdp) {
-		return -1;
-	}
-
-	m_line = ast_sdp_get_m(sdp, 0);
-	if (validate_m_line(test, m_line, "audio", 1)) {
-		return -1;
-	}
-	if (validate_rtpmap(test, m_line, "PCMU")) {
-		return -1;
-	}
-
-	/* The other audio formats should *NOT* be present */
-	if (!validate_rtpmap(test, m_line, "PCMA")) {
-		return -1;
-	}
-	if (!validate_rtpmap(test, m_line, "G722")) {
-		return -1;
-	}
-	if (!validate_rtpmap(test, m_line, "opus")) {
-		return -1;
-	}
-
-	m_line = ast_sdp_get_m(sdp, 1);
-	if (validate_m_line(test, m_line, "video", 1)) {
-		return -1;
-	}
-	if (validate_rtpmap(test, m_line, "VP8")) {
-		return -1;
-	}
-	if (!validate_rtpmap(test, m_line, "H264")) {
-		return -1;
-	}
-
-	m_line = ast_sdp_get_m(sdp, 2);
-	if (validate_m_line(test, m_line, "image", 1)) {
-		return -1;
-	}
-
-	return 0;
-}
-
-AST_TEST_DEFINE(sdp_merge_symmetric)
-{
-	enum ast_test_result_state res = AST_TEST_PASS;
-	struct ast_sdp_state *sdp_state_offerer = NULL;
-	struct ast_sdp_state *sdp_state_answerer = NULL;
-	const struct ast_sdp *offerer_sdp;
-	const struct ast_sdp *answerer_sdp;
-
-	static const struct sdp_format offerer_formats[] = {
-		{ AST_MEDIA_TYPE_AUDIO, "ulaw,alaw,g722,opus" },
-		{ AST_MEDIA_TYPE_VIDEO, "h264,vp8" },
-		{ AST_MEDIA_TYPE_IMAGE, "t38" },
-	};
-	static const struct sdp_format answerer_formats[] = {
-		{ AST_MEDIA_TYPE_AUDIO, "ulaw" },
-		{ AST_MEDIA_TYPE_VIDEO, "vp8" },
-		{ AST_MEDIA_TYPE_IMAGE, "t38" },
-	};
-
-	switch(cmd) {
-	case TEST_INIT:
-		info->name = "sdp_merge_symmetric";
-		info->category = "/main/sdp/";
-		info->summary = "Merge two SDPs with symmetric stream types";
-		info->description =
-			"SDPs 1 and 2 each have one audio and one video stream (in that order).\n"
-			"SDP 1 offers to SDP 2, who answers. We ensure that both local SDPs have\n"
-			"the expected stream types and the expected formats";
-		return AST_TEST_NOT_RUN;
-	case TEST_EXECUTE:
-		break;
-	}
-
-	sdp_state_offerer = build_sdp_state(ARRAY_LEN(offerer_formats), offerer_formats, NULL);
-	if (!sdp_state_offerer) {
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-
-	sdp_state_answerer = build_sdp_state(ARRAY_LEN(answerer_formats), answerer_formats, NULL);
-	if (!sdp_state_answerer) {
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-
-	offerer_sdp = ast_sdp_state_get_local_sdp(sdp_state_offerer);
-	if (!offerer_sdp) {
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-
-	ast_sdp_state_set_remote_sdp(sdp_state_answerer, offerer_sdp);
-	answerer_sdp = ast_sdp_state_get_local_sdp(sdp_state_answerer);
-	if (!answerer_sdp) {
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-
-	ast_sdp_state_set_remote_sdp(sdp_state_offerer, answerer_sdp);
-
-	/* Get the offerer SDP again because it's now going to be the joint SDP */
-	offerer_sdp = ast_sdp_state_get_local_sdp(sdp_state_offerer);
-	if (validate_merged_sdp(test, offerer_sdp)) {
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-	if (validate_merged_sdp(test, answerer_sdp)) {
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-
-end:
-	ast_sdp_state_free(sdp_state_offerer);
-	ast_sdp_state_free(sdp_state_answerer);
-
-	return res;
-}
-
-AST_TEST_DEFINE(sdp_merge_crisscross)
-{
-	enum ast_test_result_state res = AST_TEST_PASS;
-	struct ast_sdp_state *sdp_state_offerer = NULL;
-	struct ast_sdp_state *sdp_state_answerer = NULL;
-	const struct ast_sdp *offerer_sdp;
-	const struct ast_sdp *answerer_sdp;
-
-	static const struct sdp_format offerer_formats[] = {
-		{ AST_MEDIA_TYPE_AUDIO, "ulaw,alaw,g722,opus" },
-		{ AST_MEDIA_TYPE_VIDEO, "h264,vp8" },
-		{ AST_MEDIA_TYPE_IMAGE, "t38" },
-	};
-	static const struct sdp_format answerer_formats[] = {
-		{ AST_MEDIA_TYPE_IMAGE, "t38" },
-		{ AST_MEDIA_TYPE_VIDEO, "vp8" },
-		{ AST_MEDIA_TYPE_AUDIO, "ulaw" },
-	};
-
-	switch(cmd) {
-	case TEST_INIT:
-		info->name = "sdp_merge_crisscross";
-		info->category = "/main/sdp/";
-		info->summary = "Merge two SDPs with symmetric stream types";
-		info->description =
-			"SDPs 1 and 2 each have one audio and one video stream. However, SDP 1 and\n"
-			"2 natively have the formats in a different order.\n"
-			"SDP 1 offers to SDP 2, who answers. We ensure that both local SDPs have\n"
-			"the expected stream types and the expected formats. Since SDP 1 was the\n"
-			"offerer, the format order on SDP 1 should determine the order of formats in the SDPs";
-		return AST_TEST_NOT_RUN;
-	case TEST_EXECUTE:
-		break;
-	}
-
-	sdp_state_offerer = build_sdp_state(ARRAY_LEN(offerer_formats), offerer_formats, NULL);
-	if (!sdp_state_offerer) {
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-
-	sdp_state_answerer = build_sdp_state(ARRAY_LEN(answerer_formats), answerer_formats, NULL);
-	if (!sdp_state_answerer) {
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-
-	offerer_sdp = ast_sdp_state_get_local_sdp(sdp_state_offerer);
-	if (!offerer_sdp) {
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-
-	ast_sdp_state_set_remote_sdp(sdp_state_answerer, offerer_sdp);
-	answerer_sdp = ast_sdp_state_get_local_sdp(sdp_state_answerer);
-	if (!answerer_sdp) {
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-
-	ast_sdp_state_set_remote_sdp(sdp_state_offerer, answerer_sdp);
-
-	/* Get the offerer SDP again because it's now going to be the joint SDP */
-	offerer_sdp = ast_sdp_state_get_local_sdp(sdp_state_offerer);
-	if (validate_merged_sdp(test, offerer_sdp)) {
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-	if (validate_merged_sdp(test, answerer_sdp)) {
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-
-end:
-	ast_sdp_state_free(sdp_state_offerer);
-	ast_sdp_state_free(sdp_state_answerer);
-
-	return res;
-}
-
-static int validate_merged_sdp_asymmetric(struct ast_test *test, const struct ast_sdp *sdp, int is_offer)
-{
-	struct ast_sdp_m_line *m_line;
-	const char *side = is_offer ? "Offer side" : "Answer side";
-
-	if (!sdp) {
-		ast_test_status_update(test, "%s does not have a SDP\n", side);
-		return -1;
-	}
-
-	/* Stream 0 */
-	m_line = ast_sdp_get_m(sdp, 0);
-	if (validate_m_line(test, m_line, "audio", 1)) {
-		return -1;
-	}
-	if (!m_line->port) {
-		ast_test_status_update(test, "%s stream %d does%s have a port\n", side, 0, "n't");
-		return -1;
-	}
-	if (validate_rtpmap(test, m_line, "PCMU")) {
-		return -1;
-	}
-
-	/* The other audio formats should *NOT* be present */
-	if (!validate_rtpmap(test, m_line, "PCMA")) {
-		return -1;
-	}
-	if (!validate_rtpmap(test, m_line, "G722")) {
-		return -1;
-	}
-	if (!validate_rtpmap(test, m_line, "opus")) {
-		return -1;
-	}
-
-	/* The remaining streams should be declined */
-
-	/* Stream 1 */
-	m_line = ast_sdp_get_m(sdp, 1);
-	if (validate_m_line(test, m_line, "audio", 1)) {
-		return -1;
-	}
-	if (m_line->port) {
-		ast_test_status_update(test, "%s stream %d does%s have a port\n", side, 1, "");
-		return -1;
-	}
-
-	/* Stream 2 */
-	m_line = ast_sdp_get_m(sdp, 2);
-	if (validate_m_line(test, m_line, "video", 1)) {
-		return -1;
-	}
-	if (m_line->port) {
-		ast_test_status_update(test, "%s stream %d does%s have a port\n", side, 2, "");
-		return -1;
-	}
-
-	/* Stream 3 */
-	m_line = ast_sdp_get_m(sdp, 3);
-	if (validate_m_line(test, m_line, "image", 1)) {
-		return -1;
-	}
-	if (m_line->port) {
-		ast_test_status_update(test, "%s stream %d does%s have a port\n", side, 3, "");
-		return -1;
-	}
-
-	return 0;
-}
-
-AST_TEST_DEFINE(sdp_merge_asymmetric)
-{
-	enum ast_test_result_state res = AST_TEST_PASS;
-	struct ast_sdp_state *sdp_state_offerer = NULL;
-	struct ast_sdp_state *sdp_state_answerer = NULL;
-	const struct ast_sdp *offerer_sdp;
-	const struct ast_sdp *answerer_sdp;
-
-	static const struct sdp_format offerer_formats[] = {
-		{ AST_MEDIA_TYPE_AUDIO, "ulaw,alaw,g722,opus" },
-		{ AST_MEDIA_TYPE_AUDIO, "ulaw" },
-		{ AST_MEDIA_TYPE_VIDEO, "h261" },
-		{ AST_MEDIA_TYPE_IMAGE, "t38" },
-	};
-	static const struct sdp_format answerer_formats[] = {
-		{ AST_MEDIA_TYPE_AUDIO, "ulaw" },
-	};
-
-	switch(cmd) {
-	case TEST_INIT:
-		info->name = "sdp_merge_asymmetric";
-		info->category = "/main/sdp/";
-		info->summary = "Merge two SDPs with an asymmetric number of streams";
-		info->description =
-			"SDP 1 offers a four stream topology: Audio,Audio,Video,T.38\n"
-			"SDP 2 only has a single audio stream topology\n"
-			"We ensure that both local SDPs have the expected stream types and\n"
-			"the expected declined streams";
-		return AST_TEST_NOT_RUN;
-	case TEST_EXECUTE:
-		break;
-	}
-
-	sdp_state_offerer = build_sdp_state(ARRAY_LEN(offerer_formats), offerer_formats, NULL);
-	if (!sdp_state_offerer) {
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-
-	sdp_state_answerer = build_sdp_state(ARRAY_LEN(answerer_formats), answerer_formats, NULL);
-	if (!sdp_state_answerer) {
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-
-	offerer_sdp = ast_sdp_state_get_local_sdp(sdp_state_offerer);
-	if (!offerer_sdp) {
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-
-	ast_sdp_state_set_remote_sdp(sdp_state_answerer, offerer_sdp);
-	answerer_sdp = ast_sdp_state_get_local_sdp(sdp_state_answerer);
-	if (!answerer_sdp) {
-		res = AST_TEST_FAIL;
-		goto end;
-	}
-
-	ast_sdp_state_set_remote_sdp(sdp_state_offerer, answerer_sdp);
-
-#if defined(XXX_TODO_NEED_TO_HANDLE_DECLINED_STREAMS_ON_OFFER_SIDE)
-	/* Get the offerer SDP again because it's now going to be the joint SDP */
-	offerer_sdp = ast_sdp_state_get_local_sdp(sdp_state_offerer);
-	if (validate_merged_sdp_asymmetric(test, offerer_sdp, 1)) {
-		res = AST_TEST_FAIL;
-	}
-#endif
-	if (validate_merged_sdp_asymmetric(test, answerer_sdp, 0)) {
-		res = AST_TEST_FAIL;
-	}
-
-end:
-	ast_sdp_state_free(sdp_state_offerer);
-	ast_sdp_state_free(sdp_state_answerer);
-
-	return res;
-}
-
-static int validate_ssrc(struct ast_test *test, struct ast_sdp_m_line *m_line,
-	struct ast_rtp_instance *rtp)
-{
-	unsigned int ssrc;
-	const char *cname;
-	struct ast_sdp_a_line *a_line;
-	char attr_value[128];
-
-	ssrc = ast_rtp_instance_get_ssrc(rtp);
-	cname = ast_rtp_instance_get_cname(rtp);
-
-	snprintf(attr_value, sizeof(attr_value), "%u cname:%s", ssrc, cname);
-
-	a_line = ast_sdp_m_find_attribute(m_line, "ssrc", -1);
-	if (!a_line) {
-		ast_test_status_update(test, "Could not find 'ssrc' attribute\n");
-		return -1;
-	}
-
-	if (strcmp(a_line->value, attr_value)) {
-		ast_test_status_update(test, "SDP attribute '%s' did not match expected attribute '%s'\n",
-			a_line->value, attr_value);
-		return -1;
-	}
-
-	return 0;
-}
-
-AST_TEST_DEFINE(sdp_ssrc_attributes)
-{
-	enum ast_test_result_state res;
-	struct ast_sdp_state *test_state = NULL;
-	struct ast_sdp_options *options;
-	struct sdp_format formats[] = {
-		{ AST_MEDIA_TYPE_AUDIO, "ulaw,alaw,g722,opus" },
-	};
-	const struct ast_sdp *sdp;
-	struct ast_sdp_m_line *m_line;
-	struct ast_rtp_instance *rtp;
-
-	switch(cmd) {
-	case TEST_INIT:
-		info->name = "sdp_ssrc_attributes";
-		info->category = "/main/sdp/";
-		info->summary = "Ensure SSRC-level attributes are added to local SDPs";
-		info->description =
-			"An SDP is created and is instructed to include SSRC-level attributes.\n"
-			"This test ensures that the CNAME SSRC-level attribute is present and\n"
-			"that the values match what the RTP instance reports";
-		return AST_TEST_NOT_RUN;
-	case TEST_EXECUTE:
-		break;
-	}
-
-	res = AST_TEST_FAIL;
-
-	options = sdp_options_common();
-	if (!options) {
-		ast_test_status_update(test, "Failed to allocate SDP options\n");
-		goto end;
-	}
-	ast_sdp_options_set_ssrc(options, 1);
-
-	test_state = build_sdp_state(ARRAY_LEN(formats), formats, options);
-	if (!test_state) {
-		ast_test_status_update(test, "Failed to create SDP state\n");
-		goto end;
-	}
-
-	sdp = ast_sdp_state_get_local_sdp(test_state);
-	if (!sdp) {
-		ast_test_status_update(test, "Failed to get local SDP\n");
-		goto end;
-	}
-
-	/* Need a couple of sanity checks */
-	if (ast_sdp_get_m_count(sdp) != ARRAY_LEN(formats)) {
-		ast_test_status_update(test, "SDP m count is %d instead of %zu\n",
-			ast_sdp_get_m_count(sdp), ARRAY_LEN(formats));
-		goto end;
-	}
-
-	m_line = ast_sdp_get_m(sdp, 0);
-	if (!m_line) {
-		ast_test_status_update(test, "Failed to get SDP m-line\n");
-		goto end;
-	}
-
-	rtp = ast_sdp_state_get_rtp_instance(test_state, 0);
-	if (!rtp) {
-		ast_test_status_update(test, "Failed to get the RTP instance\n");
-		goto end;
-	}
-
-	if (validate_ssrc(test, m_line, rtp)) {
-		goto end;
-	}
-
-	res = AST_TEST_PASS;
-
-end:
-	ast_sdp_state_free(test_state);
-	return res;
-}
-
-static int unload_module(void)
-{
-	AST_TEST_UNREGISTER(invalid_rtpmap);
-	AST_TEST_UNREGISTER(rtpmap);
-	AST_TEST_UNREGISTER(find_attr);
-	AST_TEST_UNREGISTER(topology_to_sdp);
-	AST_TEST_UNREGISTER(sdp_to_topology);
-	AST_TEST_UNREGISTER(sdp_merge_symmetric);
-	AST_TEST_UNREGISTER(sdp_merge_crisscross);
-	AST_TEST_UNREGISTER(sdp_merge_asymmetric);
-	AST_TEST_UNREGISTER(sdp_ssrc_attributes);
-
-	return 0;
-}
-
-static int load_module(void)
-{
-	AST_TEST_REGISTER(invalid_rtpmap);
-	AST_TEST_REGISTER(rtpmap);
-	AST_TEST_REGISTER(find_attr);
-	AST_TEST_REGISTER(topology_to_sdp);
-	AST_TEST_REGISTER(sdp_to_topology);
-	AST_TEST_REGISTER(sdp_merge_symmetric);
-	AST_TEST_REGISTER(sdp_merge_crisscross);
-	AST_TEST_REGISTER(sdp_merge_asymmetric);
-	AST_TEST_REGISTER(sdp_ssrc_attributes);
-
-	return AST_MODULE_LOAD_SUCCESS;
-}
-
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "SDP tests");

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

Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icc28fbdc46f58e54a21554e6fe8b078f841b1f86
Gerrit-Change-Number: 7715
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171222/b6ad4061/attachment-0001.html>


More information about the asterisk-code-review mailing list