summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/rtp_engine.c26
-rw-r--r--main/sdp_options.c1
-rw-r--r--main/sdp_private.h1
-rw-r--r--main/sdp_state.c33
4 files changed, 61 insertions, 0 deletions
diff --git a/main/rtp_engine.c b/main/rtp_engine.c
index 82298901d..9cfae09f4 100644
--- a/main/rtp_engine.c
+++ b/main/rtp_engine.c
@@ -3340,3 +3340,29 @@ void ast_rtp_instance_set_last_rx(struct ast_rtp_instance *rtp, time_t time)
{
rtp->last_rx = time;
}
+
+unsigned int ast_rtp_instance_get_ssrc(struct ast_rtp_instance *rtp)
+{
+ unsigned int ssrc = 0;
+
+ ao2_lock(rtp);
+ if (rtp->engine->ssrc_get) {
+ ssrc = rtp->engine->ssrc_get(rtp);
+ }
+ ao2_unlock(rtp);
+
+ return ssrc;
+}
+
+const char *ast_rtp_instance_get_cname(struct ast_rtp_instance *rtp)
+{
+ const char *cname = "";
+
+ ao2_lock(rtp);
+ if (rtp->engine->cname_get) {
+ cname = rtp->engine->cname_get(rtp);
+ }
+ ao2_unlock(rtp);
+
+ return cname;
+}
diff --git a/main/sdp_options.c b/main/sdp_options.c
index ef056a190..3f25e4326 100644
--- a/main/sdp_options.c
+++ b/main/sdp_options.c
@@ -76,6 +76,7 @@ DEFINE_GETTERS_SETTERS_FOR(unsigned int, cos_video);
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);
static void set_defaults(struct ast_sdp_options *options)
{
diff --git a/main/sdp_private.h b/main/sdp_private.h
index f2efe86e5..f80cefb5f 100644
--- a/main/sdp_private.h
+++ b/main/sdp_private.h
@@ -43,6 +43,7 @@ struct ast_sdp_options {
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;
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;