[asterisk-commits] file: branch file/pimp_sip_media r380852 - /team/file/pimp_sip_media/res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Feb 5 12:01:20 CST 2013


Author: file
Date: Tue Feb  5 12:01:18 2013
New Revision: 380852

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=380852
Log:
Reduce pool usage and add sendrecv attribute to the SDP.

You might say "but Josh! the sendrecv attribute needs to change based on an offer". You would be correct!
Thankfully pjmedia-sdp will change the answer SDP for us automatically.

Modified:
    team/file/pimp_sip_media/res/res_sip_sdp_audio.c

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=380852&r1=380851&r2=380852
==============================================================================
--- team/file/pimp_sip_media/res/res_sip_sdp_audio.c (original)
+++ team/file/pimp_sip_media/res/res_sip_sdp_audio.c Tue Feb  5 12:01:18 2013
@@ -126,6 +126,12 @@
 /*! \brief Function which creates an outgoing 'audio' stream */
 static int audio_create_outgoing_sdp_stream(struct ast_sip_session *session, struct pjmedia_sdp_session *sdp)
 {
+	static const pj_str_t STR_AUDIO = { "audio", 5};
+	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};
+	static const pj_str_t STR_RTP_AVP = { "RTP/AVP", 7 };
+	static const pj_str_t STR_SENDRECV = { "sendrecv", 8 };
 	pj_pool_t *pool = session->inv_session->pool_active;
 	pjmedia_sdp_media *media;
 	struct ast_sockaddr addr;
@@ -147,13 +153,13 @@
 	}
 
 	/* TODO: This should eventually support SRTP */
-	pj_strdup2(pool, &media->desc.media, "audio");
-	pj_strdup2(pool, &media->desc.transport, "RTP/AVP");
+	media->desc.media = STR_AUDIO;
+	media->desc.transport = STR_RTP_AVP;
 
 	/* Add connection level details */
 	ast_rtp_instance_get_local_address(session->media[AST_SIP_MEDIA_AUDIO].rtp, &addr);
-	pj_strdup2(pool, &media->conn->net_type, "IN");
-	pj_strdup2(pool, &media->conn->addr_type, (ast_sockaddr_is_ipv6(&addr) && !ast_sockaddr_is_ipv4_mapped(&addr)) ? "IP6" : "IP4");
+	media->conn->net_type = STR_IN;
+	media->conn->addr_type = (ast_sockaddr_is_ipv6(&addr) && !ast_sockaddr_is_ipv4_mapped(&addr)) ? STR_IP6 : STR_IP4;
 	pj_strdup2(pool, &media->conn->addr, ast_sockaddr_stringify_addr_remote(&addr));
 	media->desc.port = (pj_uint16_t) ast_sockaddr_port(&addr);
 	media->desc.port_count = 1;
@@ -226,6 +232,11 @@
 		media->attr[media->attr_count++] = attr;
 	}
 
+	/* Add the sendrecv attribute - we purposely don't keep track because pjmedia-sdp will automatically change our offer for us */
+	attr = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_attr);
+	attr->name = STR_SENDRECV;
+	media->attr[media->attr_count++] = attr;
+
 	/* Add the media stream to the SDP */
 	sdp->media[sdp->media_count++] = media;
 




More information about the asterisk-commits mailing list