diff options
author | Mark Michelson <mmichelson@digium.com> | 2017-04-26 16:14:00 -0500 |
---|---|---|
committer | Mark Michelson <mmichelson@digium.com> | 2017-04-27 15:03:51 -0500 |
commit | d6535c0080632bce5ed555904d5198c04e040ffb (patch) | |
tree | c473dd2aa7b2061b41f9b6559490dca215f811e8 /main/sdp_state.c | |
parent | 413de95ab247ed9b48fc48f440e5c397146e07cb (diff) |
SDP API: Add SSRC-level attributes
RFC 5576 defines how SSRC-level attributes may be added to SDP media
descriptions. In general, this is useful for grouping related SSRCes,
indicating SSRC-level format attributes, and resolving collisions in RTP
SSRC values. These attributes are used widely by browsers during WebRTC
communications, including attributes defined by documents outside of RFC
5576.
This commit introduces the addition of SSRC-level attributes into SDPs
generated by Asterisk. Since Asterisk does not tend to use multiple
SSRCs on a media stream, the initial support is minimal. Asterisk
includes an SSRC-level CNAME attribute if configured to do so. This at
least gives browsers (and possibly others) the ability to resolve SSRC
collisions at offer-answer time.
In order to facilitate this, the RTP engine API has been enhanced to be
able to retrieve the SSRC and CNAME on a given RTP instance.
res_rtp_asterisk currently does not provide meaningful CNAME values in
its RTCP SDES items, and therefore it currently will always return an
empty string as the CNAME value. A task in the near future will result
in res_rtp_asterisk generating more meaningful CNAMEs.
Change-Id: I29e7f23e7db77524f82a3b6e8531b1195ff57789
Diffstat (limited to 'main/sdp_state.c')
-rw-r--r-- | main/sdp_state.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/main/sdp_state.c b/main/sdp_state.c index 5aee567d3..988034912 100644 --- a/main/sdp_state.c +++ b/main/sdp_state.c @@ -1182,6 +1182,37 @@ void ast_sdp_state_set_t38_parameters(struct ast_sdp_state *sdp_state, 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) { @@ -1312,6 +1343,8 @@ static int sdp_add_m_from_rtp_stream(struct ast_sdp *sdp, const struct ast_sdp_s return -1; } + add_ssrc_attributes(m_line, options, rtp); + if (ast_sdp_add_m(sdp, m_line)) { ast_sdp_m_free(m_line); return -1; |