summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Harwell <kharwell@digium.com>2017-08-04 16:47:30 -0500
committerKevin Harwell <kharwell@digium.com>2017-08-04 17:16:25 -0500
commit09995fae5376a5ab6184a916076108f4af0640b5 (patch)
treeeb427d51eb34ba0e5f3399d535aa55d9c64ab9f5
parent2014a695f735d14456b5631bec9e2a32a8226609 (diff)
res_pjsip_session/_sdp_rtp: Handling of 'msid' is incorrect
Currently, the handling of the msid attribute is not quite right. According to the spec the msid's between the offer/answer are not dependent upon one another. Meaning the same msid's given in an offer do not have to be returned in the answer for a given stream. And they probably shouldn't be (copied/reused) since this can potentially cause some browser side confusion. This patch generates new msids when both an offer and answer are sent from Asterisk. However, Asterisk does reuse the original msid it sent out for a reinvite. Also audio+video streams are paired together by sharing the same stream id, but a different track id. ASTERISK-27179 #close Change-Id: Ifaec06dc7e65ad841633a24ebec8c8a9302d6643
-rw-r--r--include/asterisk/res_pjsip_session.h6
-rw-r--r--res/res_pjsip_sdp_rtp.c53
-rw-r--r--res/res_pjsip_session.c1
3 files changed, 31 insertions, 29 deletions
diff --git a/include/asterisk/res_pjsip_session.h b/include/asterisk/res_pjsip_session.h
index caf10db11..5f49c8237 100644
--- a/include/asterisk/res_pjsip_session.h
+++ b/include/asterisk/res_pjsip_session.h
@@ -105,8 +105,10 @@ struct ast_sip_session_media {
int bundle_group;
/*! \brief Whether this stream is currently bundled or not */
unsigned int bundled;
- /*! \brief RTP/Media streams association identifier */
- char *msid;
+ /*! \brief Media stream label */
+ char mslabel[AST_UUID_STR_LEN];
+ /*! \brief Track label */
+ char label[AST_UUID_STR_LEN];
};
/*!
diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c
index f79c4cbf0..77cd80782 100644
--- a/res/res_pjsip_sdp_rtp.c
+++ b/res/res_pjsip_sdp_rtp.c
@@ -1025,44 +1025,46 @@ static void process_ssrc_attributes(struct ast_sip_session *session, struct ast_
}
}
-static void process_msid_attribute(struct ast_sip_session *session,
- struct ast_sip_session_media *session_media, pjmedia_sdp_media *media)
+static void add_msid_to_stream(struct ast_sip_session *session,
+ struct ast_sip_session_media *session_media, pj_pool_t *pool, pjmedia_sdp_media *media,
+ struct ast_stream *stream)
{
+ pj_str_t stmp;
pjmedia_sdp_attr *attr;
+ char msid[(AST_UUID_STR_LEN * 2) + 2];
if (!session->endpoint->media.webrtc) {
return;
}
- attr = pjmedia_sdp_media_find_attr2(media, "msid", NULL);
- if (attr) {
- ast_free(session_media->msid);
- ast_copy_pj_str2(&session_media->msid, &attr->value);
- }
-}
+ if (ast_strlen_zero(session_media->mslabel)) {
+ if (ast_sip_session_is_pending_stream_default(session, stream)) {
+ int index;
-static void add_msid_to_stream(struct ast_sip_session *session,
- struct ast_sip_session_media *session_media, pj_pool_t *pool, pjmedia_sdp_media *media)
-{
- pj_str_t stmp;
- pjmedia_sdp_attr *attr;
+ /* If this is a default stream we group them together under the same stream, but as different tracks */
+ for (index = 0; index < AST_VECTOR_SIZE(&session->pending_media_state->sessions); ++index) {
+ struct ast_sip_session_media *other_session_media = AST_VECTOR_GET(&session->pending_media_state->sessions, index);
- if (!session->endpoint->media.webrtc) {
- return;
- }
+ if (session_media == other_session_media) {
+ continue;
+ }
- if (ast_strlen_zero(session_media->msid)) {
- char uuid1[AST_UUID_STR_LEN], uuid2[AST_UUID_STR_LEN];
+ ast_copy_string(session_media->mslabel, other_session_media->mslabel, sizeof(session_media->mslabel));
+ break;
+ }
+ }
- if (ast_asprintf(&session_media->msid, "{%s} {%s}",
- ast_uuid_generate_str(uuid1, sizeof(uuid1)),
- ast_uuid_generate_str(uuid2, sizeof(uuid2))) < 0) {
- session_media->msid = NULL;
- return;
+ if (ast_strlen_zero(session_media->mslabel)) {
+ ast_uuid_generate_str(session_media->mslabel, sizeof(session_media->mslabel));
}
}
- attr = pjmedia_sdp_attr_create(pool, "msid", pj_cstr(&stmp, session_media->msid));
+ if (ast_strlen_zero(session_media->label)) {
+ ast_uuid_generate_str(session_media->label, sizeof(session_media->label));
+ }
+
+ snprintf(msid, sizeof(msid), "%s %s", session_media->mslabel, session_media->label);
+ attr = pjmedia_sdp_attr_create(pool, "msid", pj_cstr(&stmp, msid));
pjmedia_sdp_attr_add(&media->attr_count, media->attr, attr);
}
@@ -1127,7 +1129,6 @@ static int negotiate_incoming_sdp_stream(struct ast_sip_session *session,
}
process_ssrc_attributes(session, session_media, stream);
- process_msid_attribute(session, session_media, stream);
session_media_transport = ast_sip_session_media_get_transport(session, session_media);
if (session_media_transport == session_media || !session_media->bundled) {
@@ -1586,7 +1587,7 @@ static int create_outgoing_sdp_stream(struct ast_sip_session *session, struct as
}
add_ssrc_to_stream(session, session_media, pool, media);
- add_msid_to_stream(session, session_media, pool, media);
+ add_msid_to_stream(session, session_media, pool, media, stream);
add_rtcp_fb_to_stream(session, session_media, pool, media);
/* Add the media stream to the SDP */
diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index bb349a4b6..607f329ab 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -395,7 +395,6 @@ static void session_media_dtor(void *obj)
}
ast_free(session_media->mid);
- ast_free(session_media->msid);
}
struct ast_sip_session_media *ast_sip_session_media_state_add(struct ast_sip_session *session,