[Asterisk-code-review] res pjsip sdp rtp: include ice in ANSWER only if offered (asterisk[15])
George Joseph
asteriskteam at digium.com
Wed Jul 18 14:48:00 CDT 2018
George Joseph has submitted this change and it was merged. ( https://gerrit.asterisk.org/9429 )
Change subject: res_pjsip_sdp_rtp: include ice in ANSWER only if offered
......................................................................
res_pjsip_sdp_rtp: include ice in ANSWER only if offered
Keep track if ICE candidates were in the SDP offer & only put them
in the corresponding SDP answer if the offer condaind ICE candidates
ASTERISK-27957 #close
Change-Id: Idf2597ee48e9a287e07aa4030bfa705430a13a92
---
M include/asterisk/res_pjsip_session.h
M res/res_pjsip_sdp_rtp.c
M res/res_pjsip_session.c
3 files changed, 37 insertions(+), 0 deletions(-)
Approvals:
Richard Mudgett: Looks good to me, but someone else must approve
Benjamin Keith Ford: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved; Approved for Submit
diff --git a/include/asterisk/res_pjsip_session.h b/include/asterisk/res_pjsip_session.h
index ddcebd7..e2a26c4 100644
--- a/include/asterisk/res_pjsip_session.h
+++ b/include/asterisk/res_pjsip_session.h
@@ -93,6 +93,8 @@
unsigned int locally_held:1;
/*! \brief Does remote support rtcp_mux */
unsigned int remote_rtcp_mux:1;
+ /*! \brief Does remote support ice */
+ unsigned int remote_ice:1;
/*! \brief Media type of this session media */
enum ast_media_type type;
/*! \brief The write callback when writing frames */
diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c
index c9c0f17..333eec6 100644
--- a/res/res_pjsip_sdp_rtp.c
+++ b/res/res_pjsip_sdp_rtp.c
@@ -585,6 +585,10 @@
return;
}
+ if (!session_media->remote_ice) {
+ return;
+ }
+
if ((username = ice->get_ufrag(session_media->rtp))) {
attr = pjmedia_sdp_attr_create(pool, "ice-ufrag", pj_cstr(&stmp, username));
media->attr[media->attr_count++] = attr;
@@ -639,6 +643,33 @@
ao2_ref(candidates, -1);
}
+/*! \brief Function which checks for ice attributes in an audio stream */
+static void check_ice_support(struct ast_sip_session *session, struct ast_sip_session_media *session_media,
+ const struct pjmedia_sdp_media *remote_stream)
+{
+ struct ast_rtp_engine_ice *ice;
+ const pjmedia_sdp_attr *attr;
+ unsigned int attr_i;
+
+ if (!session->endpoint->media.rtp.ice_support || !(ice = ast_rtp_instance_get_ice(session_media->rtp))) {
+ session_media->remote_ice = 0;
+ return;
+ }
+
+ /* Find all of the candidates */
+ for (attr_i = 0; attr_i < remote_stream->attr_count; ++attr_i) {
+ attr = remote_stream->attr[attr_i];
+ if (!pj_strcmp2(&attr->name, "candidate")) {
+ session_media->remote_ice = 1;
+ break;
+ }
+ }
+
+ if (attr_i == remote_stream->attr_count) {
+ session_media->remote_ice = 0;
+ }
+}
+
/*! \brief Function which processes ICE attributes in an audio stream */
static void process_ice_attributes(struct ast_sip_session *session, struct ast_sip_session_media *session_media,
const struct pjmedia_sdp_session *remote, const struct pjmedia_sdp_media *remote_stream)
@@ -1355,6 +1386,9 @@
enable_rtcp(session, session_media, stream);
}
+ /* If ICE support is enabled find all the needed attributes */
+ check_ice_support(session, session_media, stream);
+
if (set_caps(session, session_media, session_media_transport, stream, 1, asterisk_stream)) {
return 0;
}
diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index 496cf5e..5796117 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -445,6 +445,7 @@
}
session_media->encryption = session->endpoint->media.rtp.encryption;
+ session_media->remote_ice = session->endpoint->media.rtp.ice_support;
session_media->keepalive_sched_id = -1;
session_media->timeout_sched_id = -1;
session_media->type = type;
--
To view, visit https://gerrit.asterisk.org/9429
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: merged
Gerrit-Change-Id: Idf2597ee48e9a287e07aa4030bfa705430a13a92
Gerrit-Change-Number: 9429
Gerrit-PatchSet: 1
Gerrit-Owner: Torrey Searle <tsearle at gmail.com>
Gerrit-Reviewer: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180718/f10cafcc/attachment-0001.html>
More information about the asterisk-code-review
mailing list