summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
authorNanang Izzuddin <nanang@teluu.com>2010-05-13 05:22:51 +0000
committerNanang Izzuddin <nanang@teluu.com>2010-05-13 05:22:51 +0000
commitf2d5263f261f4d2a1b714b3b91cc4229b86ad01d (patch)
treed0375502497c339d98dbd1def51c5985148a82ef /pjsip
parentdaa17786030e9fc8967d01228f453004ae7177f0 (diff)
Re #1069:
- Added new approach of SRTP optional mode in pjsua-lib by duplicating SDP media line for secured and unsecured version of media transport. - Integrated this feature into pjsua app, it is activated via --use-srtp=3 param. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3172 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/include/pjsua-lib/pjsua.h20
-rw-r--r--pjsip/src/pjsua-lib/pjsua_acc.c1
-rw-r--r--pjsip/src/pjsua-lib/pjsua_core.c1
-rw-r--r--pjsip/src/pjsua-lib/pjsua_media.c40
4 files changed, 62 insertions, 0 deletions
diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h
index 5d228083..58574e92 100644
--- a/pjsip/include/pjsua-lib/pjsua.h
+++ b/pjsip/include/pjsua-lib/pjsua.h
@@ -1083,6 +1083,16 @@ typedef struct pjsua_config
* Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
*/
int srtp_secure_signaling;
+
+ /**
+ * Specify whether SRTP in PJMEDIA_SRTP_OPTIONAL mode should compose
+ * duplicated media in SDP offer, i.e: unsecured and secured version.
+ * Otherwise, the SDP media will be composed as unsecured media but
+ * with SDP "crypto" attribute.
+ *
+ * Default: PJ_FALSE
+ */
+ pj_bool_t srtp_optional_dup_offer;
#endif
/**
@@ -2126,6 +2136,16 @@ typedef struct pjsua_acc_config
* Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
*/
int srtp_secure_signaling;
+
+ /**
+ * Specify whether SRTP in PJMEDIA_SRTP_OPTIONAL mode should compose
+ * duplicated media in SDP offer, i.e: unsecured and secured version.
+ * Otherwise, the SDP media will be composed as unsecured media but
+ * with SDP "crypto" attribute.
+ *
+ * Default: PJ_FALSE
+ */
+ pj_bool_t srtp_optional_dup_offer;
#endif
/**
diff --git a/pjsip/src/pjsua-lib/pjsua_acc.c b/pjsip/src/pjsua-lib/pjsua_acc.c
index 6af6b3d4..3ddcdd59 100644
--- a/pjsip/src/pjsua-lib/pjsua_acc.c
+++ b/pjsip/src/pjsua-lib/pjsua_acc.c
@@ -751,6 +751,7 @@ PJ_DEF(pj_status_t) pjsua_acc_modify( pjsua_acc_id acc_id,
#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
acc->cfg.use_srtp = cfg->use_srtp;
acc->cfg.srtp_secure_signaling = cfg->srtp_secure_signaling;
+ acc->cfg.srtp_optional_dup_offer = cfg->srtp_optional_dup_offer;
#endif
/* Global outbound proxy */
diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c
index dd892373..5d231cbf 100644
--- a/pjsip/src/pjsua-lib/pjsua_core.c
+++ b/pjsip/src/pjsua-lib/pjsua_core.c
@@ -175,6 +175,7 @@ PJ_DEF(void) pjsua_acc_config_default(pjsua_acc_config *cfg)
#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
cfg->use_srtp = pjsua_var.ua_cfg.use_srtp;
cfg->srtp_secure_signaling = pjsua_var.ua_cfg.srtp_secure_signaling;
+ cfg->srtp_optional_dup_offer = pjsua_var.ua_cfg.srtp_optional_dup_offer;
#endif
cfg->reg_retry_interval = PJSUA_REG_RETRY_INTERVAL;
}
diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c
index c0a7c3c2..ed5a99ad 100644
--- a/pjsip/src/pjsua-lib/pjsua_media.c
+++ b/pjsip/src/pjsua-lib/pjsua_media.c
@@ -1369,6 +1369,46 @@ pj_status_t pjsua_media_channel_create_sdp(pjsua_call_id call_id,
return status;
}
+#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
+ /* Check if SRTP is in optional mode and configured to use duplicated
+ * media, i.e: secured and unsecured version, in the SDP offer.
+ */
+ if (!rem_sdp &&
+ pjsua_var.acc[call->acc_id].cfg.use_srtp == PJMEDIA_SRTP_OPTIONAL &&
+ pjsua_var.acc[call->acc_id].cfg.srtp_optional_dup_offer)
+ {
+ unsigned i;
+
+ for (i = 0; i < sdp->media_count; ++i) {
+ pjmedia_sdp_media *m = sdp->media[i];
+
+ /* Check if this media is unsecured but has SDP "crypto"
+ * attribute.
+ */
+ if (pj_stricmp2(&m->desc.transport, "RTP/AVP") == 0 &&
+ pjmedia_sdp_media_find_attr2(m, "crypto", NULL) != NULL)
+ {
+ pjmedia_sdp_media *new_m;
+
+ /* Duplicate this media and apply secured transport */
+ new_m = pjmedia_sdp_media_clone(pool, m);
+ pj_strdup2(pool, &new_m->desc.transport, "RTP/SAVP");
+
+ /* Remove the "crypto" attribute in the unsecured media */
+ pjmedia_sdp_media_remove_all_attr(m, "crypto");
+
+ /* Insert the new media before the unsecured media */
+ if (sdp->media_count < PJMEDIA_MAX_SDP_MEDIA) {
+ pj_array_insert(sdp->media, sizeof(new_m),
+ sdp->media_count, i, &new_m);
+ ++sdp->media_count;
+ ++i;
+ }
+ }
+ }
+ }
+#endif
+
/* Update currently advertised RTP source address */
pj_memcpy(&call->med_rtp_addr, &tpinfo.sock_info.rtp_addr_name,
sizeof(pj_sockaddr));