[asterisk-commits] file: branch group/pimp_my_sip r380161 - /team/group/pimp_my_sip/res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Jan 27 08:02:45 CST 2013


Author: file
Date: Sun Jan 27 08:02:41 2013
New Revision: 380161

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=380161
Log:
Add non-codec formats to the SDP and enable RFC2833. It now gets negotiated and works happily.

Modified:
    team/group/pimp_my_sip/res/res_sip_sdp_audio.c

Modified: team/group/pimp_my_sip/res/res_sip_sdp_audio.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip_sdp_audio.c?view=diff&rev=380161&r1=380160&r2=380161
==============================================================================
--- team/group/pimp_my_sip/res/res_sip_sdp_audio.c (original)
+++ team/group/pimp_my_sip/res/res_sip_sdp_audio.c Sun Jan 27 08:02:41 2013
@@ -215,7 +215,8 @@
 	pj_pool_t *pool = session->inv_session->pool_active;
 	pjmedia_sdp_media *media;
 	struct ast_sockaddr addr;
-	int index = 0;
+	int index = 0, noncodec = AST_RTP_DTMF;
+	/* TODO: Make DTMF configurable */
 
 	if (!ast_format_cap_has_type(session->endpoint->codecs, AST_FORMAT_TYPE_AUDIO)) {
 		/* If no audio formats are configured don't add a stream */
@@ -268,7 +269,35 @@
 		media->attr[media->attr_count++] = attr;
 	}
 
-	/* TODO: Add noncodec formats */
+	/* Add non-codec formats */
+	for (index = 1LL; index <= AST_RTP_MAX; index <<= 1) {
+		int rtp_code;
+		char tmp[32];
+		pjmedia_sdp_rtpmap rtpmap;
+		pjmedia_sdp_attr *attr;
+
+		if (!(noncodec & index) || (rtp_code = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(session->media.audio), 0, NULL, index)) == -1) {
+			continue;
+		}
+
+		snprintf(tmp, sizeof(tmp), "%d", rtp_code);
+		pj_strdup2(pool, &media->desc.fmt[media->desc.fmt_count++], tmp);
+		rtpmap.pt = media->desc.fmt[media->desc.fmt_count - 1];
+		rtpmap.clock_rate = ast_rtp_lookup_sample_rate2(0, NULL, index);
+		pj_strdup2(pool, &rtpmap.enc_name, ast_rtp_lookup_mime_subtype2(0, NULL, index, 0));
+		rtpmap.param.slen = 0;
+
+		pjmedia_sdp_rtpmap_to_attr(pool, &rtpmap, &attr);
+		media->attr[media->attr_count++] = attr;
+
+		if (index == AST_RTP_DTMF) {
+			pj_str_t fmtp;
+
+			snprintf(tmp, sizeof(tmp), "%d 0-16", rtp_code);
+			attr = pjmedia_sdp_attr_create(pool, "fmtp", pj_cstr(&fmtp, tmp));
+			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