[asterisk-commits] twilson: branch 1.6.0 r252134 - in /branches/1.6.0: channels/ configs/ includ...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Mar 12 17:39:16 CST 2010
Author: twilson
Date: Fri Mar 12 17:39:12 2010
New Revision: 252134
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=252134
Log:
Merged revisions 252089 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
........
r252089 | twilson | 2010-03-12 16:04:51 -0600 (Fri, 12 Mar 2010) | 20 lines
Only change the RTP ssrc when we see that it has changed
This change basically reverts the change reviewed in
https://reviewboard.asterisk.org/r/374/ and instead limits the
updating of the RTP synchronization source to only those times when we
detect that the other side of the conversation has changed the ssrc.
The problem is that SRCUPDATE control frames are sent many times where
we don't want a new ssrc, including whenever Asterisk has to send DTMF
in a normal bridge. This is also not the first time that this mistake
has been made. The initial implementation of the ast_rtp_new_source
function also changed the ssrc--and then it was removed because of
this same issue. Then, we put it back in again to fix a different
issue. This patch attempts to only change the ssrc when we see that
the other side of the conversation has changed the ssrc.
It also renames some functions to make their purpose more clear.
Review: https://reviewboard.asterisk.org/r/540/
........
Modified:
branches/1.6.0/channels/chan_h323.c
branches/1.6.0/channels/chan_mgcp.c
branches/1.6.0/channels/chan_sip.c
branches/1.6.0/channels/chan_skinny.c
branches/1.6.0/configs/sip.conf.sample
branches/1.6.0/include/asterisk/frame.h
branches/1.6.0/include/asterisk/rtp.h
branches/1.6.0/main/channel.c
branches/1.6.0/main/rtp.c
Modified: branches/1.6.0/channels/chan_h323.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/channels/chan_h323.c?view=diff&rev=252134&r1=252133&r2=252134
==============================================================================
--- branches/1.6.0/channels/chan_h323.c (original)
+++ branches/1.6.0/channels/chan_h323.c Fri Mar 12 17:39:12 2010
@@ -919,7 +919,11 @@
res = 0;
break;
case AST_CONTROL_SRCUPDATE:
- ast_rtp_new_source(pvt->rtp);
+ ast_rtp_update_source(pvt->rtp);
+ res = 0;
+ break;
+ case AST_CONTROL_SRCCHANGE:
+ ast_rtp_change_source(pvt->rtp);
res = 0;
break;
case AST_CONTROL_PROCEEDING:
Modified: branches/1.6.0/channels/chan_mgcp.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/channels/chan_mgcp.c?view=diff&rev=252134&r1=252133&r2=252134
==============================================================================
--- branches/1.6.0/channels/chan_mgcp.c (original)
+++ branches/1.6.0/channels/chan_mgcp.c Fri Mar 12 17:39:12 2010
@@ -1477,7 +1477,10 @@
ast_moh_stop(ast);
break;
case AST_CONTROL_SRCUPDATE:
- ast_rtp_new_source(sub->rtp);
+ ast_rtp_update_source(sub->rtp);
+ break;
+ case AST_CONTROL_SRCCHANGE:
+ ast_rtp_change_source(sub->rtp);
break;
case -1:
transmit_notify_request(sub, "");
Modified: branches/1.6.0/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/channels/chan_sip.c?view=diff&rev=252134&r1=252133&r2=252134
==============================================================================
--- branches/1.6.0/channels/chan_sip.c (original)
+++ branches/1.6.0/channels/chan_sip.c Fri Mar 12 17:39:12 2010
@@ -1008,13 +1008,12 @@
#define SIP_PAGE2_FAX_DETECT (1 << 28) /*!< DP: Fax Detection support */
#define SIP_PAGE2_REGISTERTRYING (1 << 29) /*!< DP: Send 100 Trying on REGISTER attempts */
#define SIP_PAGE2_UDPTL_DESTINATION (1 << 30) /*!< DP: Use source IP of RTP as destination if NAT is enabled */
-#define SIP_PAGE2_CONSTANT_SSRC (1 << 31) /*!< GDP: Don't change SSRC on reinvite */
#define SIP_PAGE2_FLAGS_TO_COPY \
(SIP_PAGE2_ALLOWSUBSCRIBE | SIP_PAGE2_ALLOWOVERLAP | SIP_PAGE2_IGNORESDPVERSION | \
SIP_PAGE2_VIDEOSUPPORT | SIP_PAGE2_T38SUPPORT | SIP_PAGE2_RFC2833_COMPENSATE | \
SIP_PAGE2_BUGGY_MWI | SIP_PAGE2_TEXTSUPPORT | SIP_PAGE2_UDPTL_DESTINATION | \
- SIP_PAGE2_CONSTANT_SSRC | SIP_PAGE2_FAX_DETECT)
+ SIP_PAGE2_FAX_DETECT)
/*@}*/
@@ -4333,9 +4332,6 @@
ast_rtp_set_rtptimeout(dialog->rtp, peer->rtptimeout);
ast_rtp_set_rtpholdtimeout(dialog->rtp, peer->rtpholdtimeout);
ast_rtp_set_rtpkeepalive(dialog->rtp, peer->rtpkeepalive);
- if (ast_test_flag(&dialog->flags[1], SIP_PAGE2_CONSTANT_SSRC)) {
- ast_rtp_set_constantssrc(dialog->rtp);
- }
/* Set Frame packetization */
ast_rtp_codec_setpref(dialog->rtp, &dialog->prefs);
dialog->autoframing = peer->autoframing;
@@ -4346,9 +4342,6 @@
ast_rtp_set_rtptimeout(dialog->vrtp, peer->rtptimeout);
ast_rtp_set_rtpholdtimeout(dialog->vrtp, peer->rtpholdtimeout);
ast_rtp_set_rtpkeepalive(dialog->vrtp, peer->rtpkeepalive);
- if (ast_test_flag(&dialog->flags[1], SIP_PAGE2_CONSTANT_SSRC)) {
- ast_rtp_set_constantssrc(dialog->vrtp);
- }
}
if (dialog->trtp) { /* Realtime text */
ast_rtp_setdtmf(dialog->trtp, 0);
@@ -5322,7 +5315,7 @@
ast_setstate(ast, AST_STATE_UP);
ast_debug(1, "SIP answering channel: %s\n", ast->name);
- ast_rtp_new_source(p->rtp);
+ ast_rtp_update_source(p->rtp);
ast_set_flag(&p->flags[1], SIP_PAGE2_DIALOG_ESTABLISHED);
res = transmit_response_with_sdp(p, "200 OK", &p->initreq, XMIT_CRITICAL, FALSE);
}
@@ -5357,7 +5350,7 @@
if ((ast->_state != AST_STATE_UP) &&
!ast_test_flag(&p->flags[0], SIP_PROGRESS_SENT) &&
!ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
- ast_rtp_new_source(p->rtp);
+ ast_rtp_update_source(p->rtp);
if (!global_prematuremediafilter) {
p->invitestate = INV_EARLY_MEDIA;
transmit_provisional_response(p, "183 Session Progress", &p->initreq, TRUE);
@@ -5677,11 +5670,11 @@
res = -1;
break;
case AST_CONTROL_HOLD:
- ast_rtp_new_source(p->rtp);
+ ast_rtp_update_source(p->rtp);
ast_moh_start(ast, data, p->mohinterpret);
break;
case AST_CONTROL_UNHOLD:
- ast_rtp_new_source(p->rtp);
+ ast_rtp_update_source(p->rtp);
ast_moh_stop(ast);
break;
case AST_CONTROL_VIDUPDATE: /* Request a video frame update */
@@ -5700,7 +5693,10 @@
}
break;
case AST_CONTROL_SRCUPDATE:
- ast_rtp_new_source(p->rtp);
+ ast_rtp_update_source(p->rtp);
+ break;
+ case AST_CONTROL_SRCCHANGE:
+ ast_rtp_change_source(p->rtp);
break;
case -1:
res = -1;
@@ -18168,14 +18164,6 @@
res = -1;
goto request_invite_cleanup;
}
- if (ast_test_flag(&p->flags[1], SIP_PAGE2_CONSTANT_SSRC)) {
- if (p->rtp) {
- ast_rtp_set_constantssrc(p->rtp);
- }
- if (p->vrtp) {
- ast_rtp_set_constantssrc(p->vrtp);
- }
- }
} else { /* No SDP in invite, call control session */
p->jointcapability = p->capability;
ast_debug(2, "No SDP in Invite, third party call control\n");
@@ -21367,9 +21355,6 @@
} else if (!strcasecmp(v->name, "t38pt_usertpsource")) {
ast_set_flag(&mask[1], SIP_PAGE2_UDPTL_DESTINATION);
ast_set2_flag(&flags[1], ast_true(v->value), SIP_PAGE2_UDPTL_DESTINATION);
- } else if (!strcasecmp(v->name, "constantssrc")) {
- ast_set_flag(&mask[1], SIP_PAGE2_CONSTANT_SSRC);
- ast_set2_flag(&flags[1], ast_true(v->value), SIP_PAGE2_CONSTANT_SSRC);
} else if (!strcasecmp(v->name, "faxdetect")) {
ast_set_flag(&mask[1], SIP_PAGE2_FAX_DETECT);
ast_set2_flag(&flags[1], ast_true(v->value), SIP_PAGE2_FAX_DETECT);
@@ -22878,8 +22863,6 @@
default_maxcallbitrate = DEFAULT_MAX_CALL_BITRATE;
} else if (!strcasecmp(v->name, "matchexterniplocally")) {
global_matchexterniplocally = ast_true(v->value);
- } else if (!strcasecmp(v->name, "constantssrc")) {
- ast_set2_flag(&global_flags[1], ast_true(v->value), SIP_PAGE2_CONSTANT_SSRC);
} else if (!strcasecmp(v->name, "session-timers")) {
int i = (int) str2stmode(v->value);
if (i < 0) {
Modified: branches/1.6.0/channels/chan_skinny.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/channels/chan_skinny.c?view=diff&rev=252134&r1=252133&r2=252134
==============================================================================
--- branches/1.6.0/channels/chan_skinny.c (original)
+++ branches/1.6.0/channels/chan_skinny.c Fri Mar 12 17:39:12 2010
@@ -3769,7 +3769,10 @@
case AST_CONTROL_PROCEEDING:
break;
case AST_CONTROL_SRCUPDATE:
- ast_rtp_new_source(sub->rtp);
+ ast_rtp_update_source(sub->rtp);
+ break;
+ case AST_CONTROL_SRCCHANGE:
+ ast_rtp_change_source(sub->rtp);
break;
default:
ast_log(LOG_WARNING, "Don't know how to indicate condition %d\n", ind);
Modified: branches/1.6.0/configs/sip.conf.sample
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/configs/sip.conf.sample?view=diff&rev=252134&r1=252133&r2=252134
==============================================================================
--- branches/1.6.0/configs/sip.conf.sample (original)
+++ branches/1.6.0/configs/sip.conf.sample Fri Mar 12 17:39:12 2010
@@ -622,8 +622,6 @@
; for devices that send us non standard SDP packets
; (observed with Microsoft OCS). By default this option is
; off.
-
-;constantssrc=yes ; Don't change the RTP SSRC when our media stream changes
;----------------------------------------- REALTIME SUPPORT ------------------------
; For additional information on ARA, the Asterisk Realtime Architecture,
Modified: branches/1.6.0/include/asterisk/frame.h
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/include/asterisk/frame.h?view=diff&rev=252134&r1=252133&r2=252134
==============================================================================
--- branches/1.6.0/include/asterisk/frame.h (original)
+++ branches/1.6.0/include/asterisk/frame.h Fri Mar 12 17:39:12 2010
@@ -83,7 +83,8 @@
\arg \b HOLD Call is placed on hold
\arg \b UNHOLD Call is back from hold
\arg \b VIDUPDATE Video update requested
- \arg \b SRCUPDATE The source of media has changed
+ \arg \b SRCUPDATE The source of media has changed (RTP marker bit must change)
+ \arg \b SRCCHANGE Media source has changed (RTP marker bit and SSRC must change)
*/
@@ -302,6 +303,7 @@
_XXX_AST_CONTROL_T38 = 19, /*!< T38 state change request/notification \deprecated This is no longer supported. Use AST_CONTROL_T38_PARAMETERS instead. */
AST_CONTROL_SRCUPDATE = 20, /*!< Indicate source of media has changed */
AST_CONTROL_T38_PARAMETERS = 24, /*!< T38 state change request/notification with parameters */
+ AST_CONTROL_SRCCHANGE = 25, /*!< Media source has changed and requires a new RTP SSRC */
};
enum ast_control_t38 {
Modified: branches/1.6.0/include/asterisk/rtp.h
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/include/asterisk/rtp.h?view=diff&rev=252134&r1=252133&r2=252134
==============================================================================
--- branches/1.6.0/include/asterisk/rtp.h (original)
+++ branches/1.6.0/include/asterisk/rtp.h Fri Mar 12 17:39:12 2010
@@ -187,10 +187,11 @@
int ast_rtp_setqos(struct ast_rtp *rtp, int tos, int cos, char *desc);
-/*! \brief When changing sources, don't generate a new SSRC */
-void ast_rtp_set_constantssrc(struct ast_rtp *rtp);
-
-void ast_rtp_new_source(struct ast_rtp *rtp);
+/*! \brief Indicate that we need to set the marker bit */
+void ast_rtp_update_source(struct ast_rtp *rtp);
+
+/*! \brief Indicate that we need to set the marker bit and change the ssrc */
+void ast_rtp_change_source(struct ast_rtp *rtp);
/*! \brief Setting RTP payload types from lines in a SDP description: */
void ast_rtp_pt_clear(struct ast_rtp* rtp);
Modified: branches/1.6.0/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/main/channel.c?view=diff&rev=252134&r1=252133&r2=252134
==============================================================================
--- branches/1.6.0/main/channel.c (original)
+++ branches/1.6.0/main/channel.c Fri Mar 12 17:39:12 2010
@@ -2461,6 +2461,7 @@
case AST_CONTROL_RINGING:
case AST_CONTROL_ANSWER:
case AST_CONTROL_SRCUPDATE:
+ case AST_CONTROL_SRCCHANGE:
/* Unimportant */
break;
default:
@@ -3102,6 +3103,7 @@
case AST_CONTROL_PROCEEDING:
case AST_CONTROL_VIDUPDATE:
case AST_CONTROL_SRCUPDATE:
+ case AST_CONTROL_SRCCHANGE:
case AST_CONTROL_RADIO_KEY:
case AST_CONTROL_RADIO_UNKEY:
case AST_CONTROL_OPTION:
@@ -3207,6 +3209,7 @@
case AST_CONTROL_PROCEEDING:
case AST_CONTROL_VIDUPDATE:
case AST_CONTROL_SRCUPDATE:
+ case AST_CONTROL_SRCCHANGE:
case AST_CONTROL_RADIO_KEY:
case AST_CONTROL_RADIO_UNKEY:
case AST_CONTROL_OPTION:
@@ -3911,6 +3914,7 @@
case AST_CONTROL_UNHOLD:
case AST_CONTROL_VIDUPDATE:
case AST_CONTROL_SRCUPDATE:
+ case AST_CONTROL_SRCCHANGE:
case -1: /* Ignore -- just stopping indications */
break;
@@ -4865,6 +4869,7 @@
case AST_CONTROL_UNHOLD:
case AST_CONTROL_VIDUPDATE:
case AST_CONTROL_SRCUPDATE:
+ case AST_CONTROL_SRCCHANGE:
case AST_CONTROL_T38_PARAMETERS:
ast_indicate_data(other, f->subclass, f->data, f->datalen);
if (jb_in_use) {
Modified: branches/1.6.0/main/rtp.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/main/rtp.c?view=diff&rev=252134&r1=252133&r2=252134
==============================================================================
--- branches/1.6.0/main/rtp.c (original)
+++ branches/1.6.0/main/rtp.c Fri Mar 12 17:39:12 2010
@@ -1434,6 +1434,7 @@
unsigned int *rtpheader;
struct rtpPayloadType rtpPT;
struct ast_rtp *bridged = NULL;
+ AST_LIST_HEAD_NOLOCK(, ast_frame) frames;
/* If time is up, kill it */
if (rtp->sending_digit)
@@ -1533,10 +1534,22 @@
timestamp = ntohl(rtpheader[1]);
ssrc = ntohl(rtpheader[2]);
- if (!mark && rtp->rxssrc && rtp->rxssrc != ssrc) {
- if (option_debug || rtpdebug)
- ast_debug(0, "Forcing Marker bit, because SSRC has changed\n");
- mark = 1;
+ AST_LIST_HEAD_INIT_NOLOCK(&frames);
+ /* Force a marker bit and change SSRC if the SSRC changes */
+ if (rtp->rxssrc && rtp->rxssrc != ssrc) {
+ struct ast_frame *f, srcupdate = {
+ AST_FRAME_CONTROL,
+ .subclass = AST_CONTROL_SRCCHANGE,
+ };
+
+ if (!mark) {
+ if (option_debug || rtpdebug) {
+ ast_debug(0, "Forcing Marker bit, because SSRC has changed\n");
+ }
+ mark = 1;
+ }
+ f = ast_frisolate(&srcupdate);
+ AST_LIST_INSERT_TAIL(&frames, f, frame_list);
}
rtp->rxssrc = ssrc;
@@ -1567,7 +1580,7 @@
if (res < hdrlen) {
ast_log(LOG_WARNING, "RTP Read too short (%d, expecting %d)\n", res, hdrlen);
- return &ast_null_frame;
+ return AST_LIST_FIRST(&frames) ? AST_LIST_FIRST(&frames) : &ast_null_frame;
}
rtp->rxcount++; /* Only count reasonably valid packets, this'll make the rtcp stats more accurate */
@@ -1629,7 +1642,11 @@
} else {
ast_log(LOG_NOTICE, "Unknown RTP codec %d received from '%s'\n", payloadtype, ast_inet_ntoa(rtp->them.sin_addr));
}
- return f ? f : &ast_null_frame;
+ if (f) {
+ AST_LIST_INSERT_TAIL(&frames, f, frame_list);
+ return AST_LIST_FIRST(&frames);
+ }
+ return &ast_null_frame;
}
rtp->lastrxformat = rtp->f.subclass = rtpPT.code;
rtp->f.frametype = (rtp->f.subclass & AST_FORMAT_AUDIO_MASK) ? AST_FRAME_VOICE : (rtp->f.subclass & AST_FORMAT_VIDEO_MASK) ? AST_FRAME_VIDEO : AST_FRAME_TEXT;
@@ -1645,7 +1662,8 @@
f->len = ast_tvdiff_ms(ast_samp2tv(rtp->dtmf_duration, rtp_get_rate(f->subclass)), ast_tv(0, 0));
rtp->resp = 0;
rtp->dtmf_timeout = rtp->dtmf_duration = 0;
- return f;
+ AST_LIST_INSERT_TAIL(&frames, f, frame_list);
+ return AST_LIST_FIRST(&frames);
}
}
@@ -1691,7 +1709,9 @@
rtp->f.delivery.tv_usec = 0;
}
rtp->f.src = "RTP";
- return &rtp->f;
+
+ AST_LIST_INSERT_TAIL(&frames, &rtp->f, frame_list);
+ return AST_LIST_FIRST(&frames);
}
/* The following array defines the MIME Media type (and subtype) for each
@@ -2382,18 +2402,22 @@
return ast_netsock_set_qos(rtp->s, tos, cos, desc);
}
-void ast_rtp_set_constantssrc(struct ast_rtp *rtp)
-{
- rtp->constantssrc = 1;
-}
-
-void ast_rtp_new_source(struct ast_rtp *rtp)
+void ast_rtp_update_source(struct ast_rtp *rtp)
{
if (rtp) {
rtp->set_marker_bit = 1;
- if (!rtp->constantssrc) {
- rtp->ssrc = ast_random();
- }
+ ast_debug(3, "Setting the marker bit due to a source update\n");
+ }
+}
+
+void ast_rtp_change_source(struct ast_rtp *rtp)
+{
+ if (rtp) {
+ unsigned int ssrc = ast_random();
+
+ rtp->set_marker_bit = 1;
+ ast_debug(3, "Changing ssrc from %u to %u due to a source change\n", rtp->ssrc, ssrc);
+ rtp->ssrc = ssrc;
}
}
More information about the asterisk-commits
mailing list