[asterisk-commits] file: branch file/pimp_sip_media r380915 - in /team/file/pimp_sip_media: conf...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Feb 5 13:57:35 CST 2013


Author: file
Date: Tue Feb  5 13:57:34 2013
New Revision: 380915

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=380915
Log:
Add the ability to use the ptime attribute if received in an offer and configured to do so.

Modified:
    team/file/pimp_sip_media/configs/res_sip.conf.sample
    team/file/pimp_sip_media/include/asterisk/res_sip.h
    team/file/pimp_sip_media/res/res_sip/sip_configuration.c
    team/file/pimp_sip_media/res/res_sip_sdp_audio.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=380915&r1=380914&r2=380915
==============================================================================
--- team/file/pimp_sip_media/configs/res_sip.conf.sample (original)
+++ team/file/pimp_sip_media/configs/res_sip.conf.sample Tue Feb  5 13:57:34 2013
@@ -21,3 +21,4 @@
 ;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_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.h
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_media/include/asterisk/res_sip.h?view=diff&rev=380915&r1=380914&r2=380915
==============================================================================
--- team/file/pimp_sip_media/include/asterisk/res_sip.h (original)
+++ team/file/pimp_sip_media/include/asterisk/res_sip.h Tue Feb  5 13:57:34 2013
@@ -202,6 +202,8 @@
 	unsigned int rtp_ipv6;
 	/*! Whether symmetric RTP is enabled or not */
 	unsigned int rtp_symmetric;
+	/*! Whether to use the "ptime" attribute received from the endpoint or not */
+	unsigned int use_ptime;
 	/*! Enabled SIP extensions */
 	unsigned int extensions;
 	/*! Minimum session expiration period, in seconds */

Modified: team/file/pimp_sip_media/res/res_sip/sip_configuration.c
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_media/res/res_sip/sip_configuration.c?view=diff&rev=380915&r1=380914&r2=380915
==============================================================================
--- team/file/pimp_sip_media/res/res_sip/sip_configuration.c (original)
+++ team/file/pimp_sip_media/res/res_sip/sip_configuration.c Tue Feb  5 13:57:34 2013
@@ -229,6 +229,7 @@
 	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtmfmode", "rfc4733", dtmf_handler, NULL, 0, 0);
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtp_ipv6", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, rtp_ipv6));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtp_symmetric", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, rtp_symmetric));
+	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "use_ptime", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, use_ptime));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "transport", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, transport));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "mohsuggest", "default", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, mohsuggest));
 	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "100rel", "yes", prack_handler, NULL, 0, 0);

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=380915&r1=380914&r2=380915
==============================================================================
--- 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 13:57:34 2013
@@ -312,6 +312,28 @@
 	}
 
 	ast_rtp_codecs_payload_formats(&codecs, peercap, &othercapability);
+
+	/* Apply packetization if available and configured to do so */
+	if (session->endpoint->use_ptime && (attr = pjmedia_sdp_media_find_attr2(stream, "ptime", NULL))) {
+		pj_str_t value = attr->value;
+		unsigned long framing = pj_strtoul(pj_strltrim(&value));
+		int codec;
+		struct ast_codec_pref *pref = &ast_rtp_instance_get_codecs(session->media[AST_SIP_MEDIA_AUDIO].rtp)->pref;
+
+		for (codec = 0; codec < AST_RTP_MAX_PT; codec++) {
+			struct ast_rtp_payload_type format = ast_rtp_codecs_payload_lookup(ast_rtp_instance_get_codecs(
+				session->media[AST_SIP_MEDIA_AUDIO].rtp), codec);
+
+			if (!format.asterisk_format) {
+				continue;
+			}
+
+			ast_codec_pref_setsize(pref, &format.format, framing);
+		}
+
+		ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(session->media[AST_SIP_MEDIA_AUDIO].rtp),
+			session->media[AST_SIP_MEDIA_AUDIO].rtp, pref);
+	}
 
 	/* Using the configured codecs and the codecs in this SDP we determine the joint formats for *audio only* */
 	ast_format_cap_copy(cap, session->endpoint->codecs);




More information about the asterisk-commits mailing list