[asterisk-commits] file: branch group/pimp_my_sip r380162 - /team/group/pimp_my_sip/res/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sun Jan 27 08:14:29 CST 2013
Author: file
Date: Sun Jan 27 08:14:25 2013
New Revision: 380162
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=380162
Log:
Add the ptime attribute to the audio media stream.
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=380162&r1=380161&r2=380162
==============================================================================
--- 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:14:25 2013
@@ -215,7 +215,10 @@
pj_pool_t *pool = session->inv_session->pool_active;
pjmedia_sdp_media *media;
struct ast_sockaddr addr;
- int index = 0, noncodec = AST_RTP_DTMF;
+ char tmp[32];
+ pj_str_t stmp;
+ pjmedia_sdp_attr *attr;
+ int index = 0, min_packet_size = 0, noncodec = AST_RTP_DTMF;
/* TODO: Make DTMF configurable */
if (!ast_format_cap_has_type(session->endpoint->codecs, AST_FORMAT_TYPE_AUDIO)) {
@@ -246,9 +249,8 @@
for (index = 0; (index < AST_CODEC_PREF_SIZE); index++) {
struct ast_format format;
int rtp_code;
- char tmp[32];
pjmedia_sdp_rtpmap rtpmap;
- pjmedia_sdp_attr *attr;
+ struct ast_codec_pref *pref = &ast_rtp_instance_get_codecs(session->media.audio)->pref;
if (!ast_codec_pref_index(&session->endpoint->prefs, index, &format)) {
break;
@@ -267,14 +269,19 @@
pjmedia_sdp_rtpmap_to_attr(pool, &rtpmap, &attr);
media->attr[media->attr_count++] = attr;
+
+ if (pref) {
+ struct ast_format_list fmt = ast_codec_pref_getsize(pref, &format);
+ if (fmt.cur_ms && ((fmt.cur_ms < min_packet_size) || !min_packet_size)) {
+ min_packet_size = fmt.cur_ms;
+ }
+ }
}
/* 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;
@@ -291,12 +298,17 @@
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));
+ attr = pjmedia_sdp_attr_create(pool, "fmtp", pj_cstr(&stmp, tmp));
media->attr[media->attr_count++] = attr;
}
+ }
+
+ /* If ptime is set add it as an attribute */
+ if (min_packet_size) {
+ snprintf(tmp, sizeof(tmp), "%d", min_packet_size);
+ attr = pjmedia_sdp_attr_create(pool, "ptime", pj_cstr(&stmp, tmp));
+ media->attr[media->attr_count++] = attr;
}
/* Add the media stream to the SDP */
More information about the asterisk-commits
mailing list