[svn-commits] file: branch file/pimp_sip_media r381010 - in /team/file/pimp_sip_media: conf...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Feb 6 16:46:25 CST 2013


Author: file
Date: Wed Feb  6 16:46:21 2013
New Revision: 381010

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=381010
Log:
Incorporate review feedback from Mark.

Modified:
    team/file/pimp_sip_media/configs/res_sip.conf.sample
    team/file/pimp_sip_media/include/asterisk/res_sip_session.h
    team/file/pimp_sip_media/res/res_sip_sdp_audio.c
    team/file/pimp_sip_media/res/res_sip_session.c

Modified: team/file/pimp_sip_media/configs/res_sip.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_media/configs/res_sip.conf.sample?view=diff&rev=381010&r1=381009&r2=381010
==============================================================================
--- team/file/pimp_sip_media/configs/res_sip.conf.sample (original)
+++ team/file/pimp_sip_media/configs/res_sip.conf.sample Wed Feb  6 16:46:21 2013
@@ -19,6 +19,6 @@
 ;timers_min_se=90         ; Minimum session timers expiration period, in seconds
 ;timers_sess_expires=1800 ; Session timers expiration period, in seconds
 ;mohsuggest=example	      ; What musiconhold class to suggest that the peer channel use when this endpoint places them on hold
-;rtp_ipv6=yes             ; Use IPv6 for RTP transport
+;rtp_ipv6=yes             ; Force IPv6 for RTP transport
 ;rtp_symmetric=yes        ; Enable symmetric RTP support
 ;use_ptime=yes            ; Whether to use the ptime value received from the endpoint or not

Modified: team/file/pimp_sip_media/include/asterisk/res_sip_session.h
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_media/include/asterisk/res_sip_session.h?view=diff&rev=381010&r1=381009&r2=381010
==============================================================================
--- team/file/pimp_sip_media/include/asterisk/res_sip_session.h (original)
+++ team/file/pimp_sip_media/include/asterisk/res_sip_session.h Wed Feb  6 16:46:21 2013
@@ -84,8 +84,6 @@
 	struct ast_sip_session_media media[AST_SIP_MEDIA_SIZE];
 	/* Workspace for tasks relating to this SIP session */
 	struct ast_sip_work *work;
-	/* Whether IPv6 RTP support is in use or not */
-	unsigned int rtp_ipv6:1;
 };
 
 /*!

Modified: team/file/pimp_sip_media/res/res_sip_sdp_audio.c
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_media/res/res_sip_sdp_audio.c?view=diff&rev=381010&r1=381009&r2=381010
==============================================================================
--- team/file/pimp_sip_media/res/res_sip_sdp_audio.c (original)
+++ team/file/pimp_sip_media/res/res_sip_sdp_audio.c Wed Feb  6 16:46:21 2013
@@ -81,7 +81,7 @@
 	char hostip[PJ_INET6_ADDRSTRLEN+2];
 	struct ast_sockaddr tmp;
 
-	if (pj_gethostip(session->rtp_ipv6 ? pj_AF_INET6() : pj_AF_INET(), &addr) != PJ_SUCCESS) {
+	if (pj_gethostip(session->endpoint->rtp_ipv6 ? pj_AF_INET6() : pj_AF_INET(), &addr) != PJ_SUCCESS) {
 		return -1;
 	}
 
@@ -100,7 +100,7 @@
 
 	ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(session->media[AST_SIP_MEDIA_AUDIO].rtp),
 					 session->media[AST_SIP_MEDIA_AUDIO].rtp, &session->endpoint->prefs);
-	
+
 	return 0;
 }
 
@@ -108,18 +108,14 @@
 static int audio_negotiate_incoming_sdp_stream(struct ast_sip_session *session, const struct pjmedia_sdp_session *sdp, const struct pjmedia_sdp_media *stream)
 {
 	char host[NI_MAXHOST];
-	RAII_VAR(struct ast_sockaddr *, addrs, NULL, ast_free);
+	RAII_VAR(struct ast_sockaddr *, addrs, NULL, ast_free_ptr);
 
 	/* If no audio formats have been configured reject this stream */
 	if (!ast_format_cap_has_type(session->endpoint->codecs, AST_FORMAT_TYPE_AUDIO)) {
 		return 0;
 	}
 
-	if (!stream->conn) {
-		snprintf(host, sizeof(host), "%.*s", (int) pj_strlen(&sdp->conn->addr), pj_strbuf(&sdp->conn->addr));
-	} else {
-		snprintf(host, sizeof(host), "%.*s", (int) pj_strlen(&stream->conn->addr), pj_strbuf(&stream->conn->addr));
-	}
+	ast_copy_pj_str(host, stream->conn ? &stream->conn->addr : &sdp->conn->addr, sizeof(host));
 
 	/* Ensure that the address provided is valid */
 	if (ast_sockaddr_resolve(&addrs, host, PARSE_PORT_FORBID, AST_AF_UNSPEC) <= 0) {
@@ -128,7 +124,7 @@
 	}
 
 	/* If IPv6 is configured but the media stream does not have it reject this stream */
-	if (session->rtp_ipv6 && !ast_sockaddr_is_ipv6(addrs)) {
+	if (session->endpoint->rtp_ipv6 && !ast_sockaddr_is_ipv6(addrs)) {
 		return -1;
 	}
 
@@ -259,12 +255,14 @@
 /*! \brief Function which applies a negotiated SDP stream */
 static int audio_apply_negotiated_sdp_stream(struct ast_sip_session *session, const struct pjmedia_sdp_session *sdp, const struct pjmedia_sdp_media *stream)
 {
-	int res = 1, format, othercapability = 0;
+	int format, othercapability = 0;
 	char host[NI_MAXHOST];
-	struct ast_sockaddr *addrs = NULL;
+	RAII_VAR(struct ast_sockaddr *, addrs, NULL, ast_free_ptr);
 	struct ast_rtp_codecs codecs;
 	const pjmedia_sdp_attr *attr;
-	struct ast_format_cap *cap, *jointcap = NULL, *peercap = NULL;
+	RAII_VAR(struct ast_format_cap *, cap, NULL, ast_format_cap_destroy);
+	RAII_VAR(struct ast_format_cap *, jointcap, NULL, ast_format_cap_destroy);
+	RAII_VAR(struct ast_format_cap *, peercap, NULL, ast_format_cap_destroy);
 	struct ast_format fmt;
 
 	/* Create an RTP instance if need be */
@@ -272,11 +270,7 @@
 		return -1;
 	}
 
-	if (!stream->conn) {
-		snprintf(host, sizeof(host), "%.*s", (int) pj_strlen(&sdp->conn->addr), pj_strbuf(&sdp->conn->addr));
-	} else {
-		snprintf(host, sizeof(host), "%.*s", (int) pj_strlen(&stream->conn->addr), pj_strbuf(&stream->conn->addr));
-	}
+	ast_copy_pj_str(host, stream->conn ? &stream->conn->addr : &sdp->conn->addr, sizeof(host));
 
 	/* Ensure that the address provided is valid */
 	if (ast_sockaddr_resolve(&addrs, host, PARSE_PORT_FORBID, AST_AF_UNSPEC) <= 0) {
@@ -288,8 +282,7 @@
 	if (!(cap = ast_format_cap_alloc_nolock()) ||
 	    !(peercap = ast_format_cap_alloc_nolock())) {
 		ast_log(LOG_ERROR, "Failed to allocate audio capabilities\n");
-		res = -1;
-		goto cleanup;
+		return -1;
 	}
 
 	/* Apply connection information to the RTP instance */
@@ -311,7 +304,7 @@
 			if ((pjmedia_sdp_attr_to_rtpmap(session->inv_session->pool_active, attr, &rtpmap)) == PJ_SUCCESS) {
 				char name[32];
 
-				snprintf(name, sizeof(name), "%.*s", (int) pj_strlen(&rtpmap->enc_name), pj_strbuf(&rtpmap->enc_name));
+				ast_copy_pj_str(name, &rtpmap->enc_name, sizeof(name));
 				ast_rtp_codecs_payloads_set_rtpmap_type_rate(&codecs, NULL, pj_strtoul(&stream->desc.fmt[format]),
 									     "audio", name, 0, rtpmap->clock_rate);
 			}
@@ -353,8 +346,9 @@
 		ast_getformatname_multiple(usbuf, sizeof(usbuf), cap);
 		ast_getformatname_multiple(thembuf, sizeof(thembuf), peercap);
 		ast_log(LOG_WARNING, "No joint capabilities between our configuration(%s) and incoming SDP(%s)\n", usbuf, thembuf);
-		res = -1;
-		goto cleanup;
+
+		ast_rtp_codecs_payloads_destroy(&codecs);
+		return -1;
 	}
 
 	ast_rtp_codecs_payloads_copy(&codecs, ast_rtp_instance_get_codecs(session->media[AST_SIP_MEDIA_AUDIO].rtp),
@@ -394,14 +388,8 @@
 		ast_rtp_instance_activate(session->media[AST_SIP_MEDIA_AUDIO].rtp);
 	}
 
-cleanup:
-	ast_format_cap_destroy(peercap);
-	ast_format_cap_destroy(jointcap);
-	ast_format_cap_destroy(cap);
-	ast_free(addrs);
 	ast_rtp_codecs_payloads_destroy(&codecs);
-
-	return res;
+	return 1;
 }
 
 /*! \brief Function which destroys the audio RTP instance when session ends */

Modified: team/file/pimp_sip_media/res/res_sip_session.c
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_media/res/res_sip_session.c?view=diff&rev=381010&r1=381009&r2=381010
==============================================================================
--- team/file/pimp_sip_media/res/res_sip_session.c (original)
+++ team/file/pimp_sip_media/res/res_sip_session.c Wed Feb  6 16:46:21 2013
@@ -497,7 +497,6 @@
 	session->work = ast_sip_create_work();
 	session->endpoint = endpoint;
 	session->inv_session = inv_session;
-	session->rtp_ipv6 = endpoint->rtp_ipv6;
 	if (add_supplements(session)) {
 		return NULL;
 	}
@@ -1083,6 +1082,7 @@
 	static const pj_str_t STR_ASTERISK = { "Asterisk", 8 };
 	static const pj_str_t STR_IN = { "IN", 2 };
 	static const pj_str_t STR_IP4 = { "IP4", 3 };
+	static const pj_str_t STR_IP6 = { "IP6", 3 };
 	pjmedia_sdp_session *local;
 
 	if (!(local = PJ_POOL_ZALLOC_T(inv->pool, pjmedia_sdp_session))) {
@@ -1098,10 +1098,7 @@
 
 	local->origin.user = STR_ASTERISK;
 	local->origin.net_type = STR_IN;
-	local->origin.addr_type = STR_IP4;
-	/* XXX Hardcoded origin net stuff for now. Replace with transport
-	 * stuff later
-	 */
+	local->origin.addr_type = session->endpoint->rtp_ipv6 ? STR_IP6 : STR_IP4;
 	local->origin.addr = *pj_gethostname();
 	local->name = local->origin.user;
 




More information about the svn-commits mailing list