[asterisk-commits] rizzo: branch rizzo/astobj2 r48244 -
/team/rizzo/astobj2/channels/chan_sip.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Mon Dec 4 13:59:57 MST 2006
Author: rizzo
Date: Mon Dec 4 14:59:56 2006
New Revision: 48244
URL: http://svn.digium.com/view/asterisk?view=rev&rev=48244
Log:
merge from trunk
47893, 48004,48032,48123,
48167, 48178,48200
Modified:
team/rizzo/astobj2/channels/chan_sip.c
Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=48244&r1=48243&r2=48244
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Mon Dec 4 14:59:56 2006
@@ -548,7 +548,7 @@
static int allow_external_domains; /*!< Accept calls to external SIP domains? */
static int global_callevents; /*!< Whether we send manager events or not */
static int global_t1min; /*!< T1 roundtrip time minimum */
-static int global_autoframing; /*!< ?????????? */
+static int global_autoframing; /*!< Turn autoframing on or off. */
static enum transfermodes global_allowtransfer; /*!< SIP Refer restriction scheme */
/*! \brief Codecs that we support by default: */
@@ -975,8 +975,6 @@
time_t lastrtprx; /*!< Last RTP received */
time_t lastrtptx; /*!< Last RTP sent */
int rtptimeout; /*!< RTP timeout time */
- int rtpholdtimeout; /*!< RTP timeout when on hold */
- int rtpkeepalive; /*!< Send RTP packets for keepalive */
struct sockaddr_in recv; /*!< Received as */
struct in_addr ourip; /*!< Our IP */
struct ast_channel *owner; /*!< Who owns us (if we have an owner) */
@@ -2935,17 +2933,21 @@
if (dialog->rtp) {
ast_rtp_setdtmf(dialog->rtp, ast_test_flag(&dialog->flags[0], SIP_DTMF) != SIP_DTMF_INFO);
ast_rtp_setdtmfcompensate(dialog->rtp, ast_test_flag(&dialog->flags[1], SIP_PAGE2_RFC2833_COMPENSATE));
+ ast_rtp_set_rtptimeout(dialog->rtp, peer->rtptimeout);
+ ast_rtp_set_rtpholdtimeout(dialog->rtp, peer->rtpholdtimeout);
+ ast_rtp_set_rtpkeepalive(dialog->rtp, peer->rtpkeepalive);
+ /* Set Frame packetization */
+ ast_rtp_codec_setpref(dialog->rtp, &dialog->prefs);
+ dialog->autoframing = peer->autoframing;
}
if (dialog->vrtp) {
ast_rtp_setdtmf(dialog->vrtp, 0);
ast_rtp_setdtmfcompensate(dialog->vrtp, 0);
- }
-
- /* Set Frame packetization */
- if (dialog->rtp) {
- ast_rtp_codec_setpref(dialog->rtp, &dialog->prefs);
- dialog->autoframing = peer->autoframing;
- }
+ ast_rtp_set_rtptimeout(dialog->vrtp, peer->rtptimeout);
+ ast_rtp_set_rtpholdtimeout(dialog->vrtp, peer->rtpholdtimeout);
+ ast_rtp_set_rtpkeepalive(dialog->vrtp, peer->rtpkeepalive);
+ }
+
ast_string_field_set(dialog, peername, peer->username);
ast_string_field_set(dialog, authname, peer->username);
ast_string_field_set(dialog, username, peer->username);
@@ -2983,8 +2985,6 @@
dialog->noncodeccapability &= ~AST_RTP_DTMF;
ast_string_field_set(dialog, context, peer->context);
dialog->rtptimeout = peer->rtptimeout;
- dialog->rtpholdtimeout = peer->rtpholdtimeout;
- dialog->rtpkeepalive = peer->rtpkeepalive;
if (peer->call_limit)
ast_set_flag(&dialog->flags[0], SIP_CALL_LIMIT);
dialog->maxcallbitrate = peer->maxcallbitrate;
@@ -3837,15 +3837,12 @@
case AST_FRAME_MODEM:
if (p) {
sip_pvt_lock(p);
- if (p->udptl) {
- if ((ast->_state != AST_STATE_UP) &&
- !ast_test_flag(&p->flags[0], SIP_PROGRESS_SENT) &&
- !ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
- transmit_response_with_t38_sdp(p, "183 Session Progress", &p->initreq, XMIT_UNRELIABLE);
- ast_set_flag(&p->flags[0], SIP_PROGRESS_SENT);
- }
+ /* UDPTL requires two-way communication, so early media is not needed here.
+ we simply forget the frames if we get modem frames before the bridge is up.
+ Fax will re-transmit.
+ */
+ if (p->udptl && ast->_state != AST_STATE_UP)
res = ast_udptl_write(p->udptl, frame);
- }
sip_pvt_unlock(p);
}
break;
@@ -4561,16 +4558,19 @@
ast_rtp_setdtmf(p->rtp, ast_test_flag(&p->flags[0], SIP_DTMF) != SIP_DTMF_INFO);
ast_rtp_setdtmfcompensate(p->rtp, ast_test_flag(&p->flags[1], SIP_PAGE2_RFC2833_COMPENSATE));
ast_rtp_settos(p->rtp, global_tos_audio);
+ ast_rtp_set_rtptimeout(p->rtp, global_rtptimeout);
+ ast_rtp_set_rtpholdtimeout(p->rtp, global_rtpholdtimeout);
+ ast_rtp_set_rtpkeepalive(p->rtp, global_rtpkeepalive);
if (p->vrtp) {
ast_rtp_settos(p->vrtp, global_tos_video);
ast_rtp_setdtmf(p->vrtp, 0);
ast_rtp_setdtmfcompensate(p->vrtp, 0);
+ ast_rtp_set_rtptimeout(p->vrtp, global_rtptimeout);
+ ast_rtp_set_rtpholdtimeout(p->vrtp, global_rtpholdtimeout);
+ ast_rtp_set_rtpkeepalive(p->vrtp, global_rtpkeepalive);
}
if (p->udptl)
ast_udptl_settos(p->udptl, global_tos_audio);
- p->rtptimeout = global_rtptimeout;
- p->rtpholdtimeout = global_rtpholdtimeout;
- p->rtpkeepalive = global_rtpkeepalive;
p->maxcallbitrate = default_maxcallbitrate;
ast_mark(prof_rtp, 0);
}
@@ -7695,7 +7695,7 @@
ast_string_field_set(p, domain, r->domain);
ast_string_field_set(p, opaque, r->opaque);
ast_string_field_set(p, qop, r->qop);
- p->noncecount = r->noncecount++;
+ p->noncecount = ++r->noncecount;
memset(digest,0,sizeof(digest));
if(!build_reply_digest(p, SIP_REGISTER, digest, sizeof(digest))) {
@@ -10829,6 +10829,7 @@
ast_cli(fd, " T1 minimum: %d\n", global_t1min);
ast_cli(fd, " Relax DTMF: %s\n", global_relaxdtmf ? "Yes" : "No");
ast_cli(fd, " Compact SIP headers: %s\n", compactheaders ? "Yes" : "No");
+ ast_cli(fd, " RTP Keepalive: %d %s\n", global_rtpkeepalive, global_rtpkeepalive ? "" : "(Disabled)" );
ast_cli(fd, " RTP Timeout: %d %s\n", global_rtptimeout, global_rtptimeout ? "" : "(Disabled)" );
ast_cli(fd, " RTP Hold Timeout: %d %s\n", global_rtpholdtimeout, global_rtpholdtimeout ? "" : "(Disabled)");
ast_cli(fd, " MWI NOTIFY mime type: %s\n", default_notifymime);
@@ -12145,7 +12146,7 @@
/* RFC3261 says we must treat every 1xx response (but not 100)
that we don't recognize as if it was 183.
*/
- if (resp > 100 && resp < 200 && resp != 180 && resp != 183)
+ if (resp > 100 && resp < 200 && resp != 101 && resp != 180 && resp != 183)
resp = 183;
/* Any response between 100 and 199 is PROCEEDING */
@@ -12159,6 +12160,7 @@
switch (resp) {
case 100: /* Trying */
+ case 101: /* Dialog establishment */
if (!req_ignore(req))
sip_cancel_destroy(p);
check_pendings(p);
@@ -12245,6 +12247,9 @@
if (bridgepvt->udptl) {
if (p->t38.state == T38_PEER_REINVITE) {
sip_handle_t38_reinvite(bridgepeer, p, 0);
+ ast_rtp_set_rtptimers_onhold(p->rtp);
+ if (p->vrtp)
+ ast_rtp_set_rtptimers_onhold(p->vrtp); /* Turn off RTP timers while we send fax */
} else if (p->t38.state == T38_DISABLED && bridgepeer && (bridgepvt->t38.state == T38_ENABLED)) {
ast_log(LOG_WARNING, "RTP re-inivte after T38 session not handled yet !\n");
/* Insted of this we should somehow re-invite the other side of the bridge to RTP */
@@ -12721,6 +12726,7 @@
switch(resp) {
case 100: /* 100 Trying */
+ case 101: /* 101 Dialog establishment */
case 183: /* 183 Session Progress */
case 180: /* 180 Ringing */
if (sipmethod == SIP_INVITE)
@@ -12814,7 +12820,8 @@
if (sipmethod == SIP_INVITE) {
/* First we ACK */
transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, FALSE);
- ast_log(LOG_WARNING, "INVITE with REPLACEs failed to '%s'\n", get_header(&p->initreq, "From"));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Got 481 on Invite. Assuming INVITE with REPLACEs failed to '%s'\n", get_header(&p->initreq, "From"));
if (owner)
ast_queue_control(p->owner, AST_CONTROL_CONGESTION);
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
@@ -13425,6 +13432,7 @@
respcode = atoi(code);
switch (respcode) {
case 100: /* Trying: */
+ case 101: /* dialog establishment */
/* Don't do anything yet */
break;
case 183: /* Ringing: */
@@ -14945,7 +14953,7 @@
} else {
if ((firststate = ast_extension_state(NULL, p->context, p->exten)) < 0) {
- ast_log(LOG_ERROR, "Got SUBSCRIBE for extension %s@%s from %s, but there is no hint for that extension\n", p->exten, p->context, ast_inet_ntoa(p->sa.sin_addr));
+ ast_log(LOG_NOTICE, "Got SUBSCRIBE for extension %s@%s from %s, but there is no hint for that extension\n", p->exten, p->context, ast_inet_ntoa(p->sa.sin_addr));
transmit_response(p, "404 Not found", req);
set_destroy(p);
return 0;
@@ -15487,53 +15495,72 @@
* helper function for the monitoring thread.
* Called only in one place with dialoglist locked.
*/
-static void check_rtp_timeout(struct sip_pvt *sip, time_t t)
+static void check_rtp_timeout(struct sip_pvt *dialog, time_t t)
{
struct sockaddr_in sin;
- if (! (sip->rtp && sip->owner && (sip->owner->_state == AST_STATE_UP) && !sip->redirip.sin_addr.s_addr) )
+ /* If we have no RTP or no active owner, no need to check timers */
+ if (!dialog->rtp || !dialog->owner)
return;
-
- if (sip->lastrtptx && sip->rtpkeepalive && (t > sip->lastrtptx + sip->rtpkeepalive)) {
+ /* If the call is not in UP state or redirected outside Asterisk, no need to check timers */
+ if (dialog->owner->_state != AST_STATE_UP || !dialog->redirip.sin_addr.s_addr)
+ return;
+
+ /* If we have no timers set, return now */
+ if (ast_rtp_get_rtpkeepalive(dialog->rtp) == 0 || (ast_rtp_get_rtptimeout(dialog->rtp) == 0 && ast_rtp_get_rtpholdtimeout(dialog->rtp) == 0))
+ return;
+
+ /* Check AUDIO RTP keepalives */
+ if (dialog->lastrtptx && ast_rtp_get_rtpkeepalive(dialog->rtp) && (t > dialog->lastrtptx + ast_rtp_get_rtpkeepalive(dialog->rtp))) {
/* Need to send an empty RTP packet */
- sip->lastrtptx = time(NULL);
- ast_rtp_sendcng(sip->rtp, 0);
- }
-
+ dialog->lastrtptx = time(NULL);
+ ast_rtp_sendcng(dialog->rtp, 0);
+ }
+
+ /*! \todo Check video RTP keepalives
+ Do we need to move the lastrtptx to the RTP structure to have one for audio and one
+ for video? It really does belong to the RTP structure.
+ */
/* XXX probably wrong check if rtptimeout == 0 */
- if (! (sip->lastrtprx && (sip->rtptimeout || sip->rtpholdtimeout) && (t > sip->lastrtprx + sip->rtptimeout)) )
+ /* Check AUDIO RTP timers */
+ if (! (dialog->lastrtprx && (ast_rtp_get_rtptimeout(dialog->rtp) || ast_rtp_get_rtpholdtimeout(dialog->rtp)) &&
+ (t > dialog->lastrtprx + ast_rtp_get_rtptimeout(dialog->rtp)) ) )
return;
/* Might be a timeout now -- see if we're on hold */
- ast_rtp_get_peer(sip->rtp, &sin);
- if (! (sin.sin_addr.s_addr || (sip->rtpholdtimeout && (t > sip->lastrtprx + sip->rtpholdtimeout))) )
+ ast_rtp_get_peer(dialog->rtp, &sin);
+ if (! (sin.sin_addr.s_addr || (ast_rtp_get_rtpholdtimeout(dialog->rtp) && (t > dialog->lastrtprx + ast_rtp_get_rtpholdtimeout(dialog->rtp)))) )
return;
- if (!sip->rtptimeout)
+ if (!ast_rtp_get_rtptimeout(dialog->rtp))
return;
- lock_pvt_and_owner(sip, 0 /* forever */); /* safe, dialoglist is locked */
- if (!sip->owner)
+ lock_pvt_and_owner(dialog, 0 /* forever */); /* safe, dialoglist is locked */
+ if (!dialog->owner)
return;
- if (!(ast_rtp_get_bridged(sip->rtp))) {
+ if (!(ast_rtp_get_bridged(dialog->rtp))) {
ast_log(LOG_NOTICE,
"Disconnecting call '%s' for lack of RTP activity in %ld seconds\n",
- sip->owner->name,
- (long) (t - sip->lastrtprx));
+ dialog->owner->name,
+ (long) (t - dialog->lastrtprx));
/* Issue a softhangup */
- ast_softhangup_nolock(sip->owner, AST_SOFTHANGUP_DEV);
+ ast_softhangup_nolock(dialog->owner, AST_SOFTHANGUP_DEV);
} else
ast_log(LOG_NOTICE,
"'%s' will not be disconnected in %ld seconds because it is directly bridged to another RTP stream\n",
- sip->owner->name, (long) (t - sip->lastrtprx));
- ast_channel_unlock(sip->owner);
+ dialog->owner->name, (long) (t - dialog->lastrtprx));
+ ast_channel_unlock(dialog->owner);
/* forget the timeouts for this call, since a hangup
has already been requested and we don't want to
repeatedly request hangups
*/
- sip->rtptimeout = 0;
- sip->rtpholdtimeout = 0;
+ ast_rtp_set_rtptimeout(dialog->rtp, 0);
+ ast_rtp_set_rtpholdtimeout(dialog->rtp, 0);
+ if (dialog->vrtp) {
+ ast_rtp_set_rtptimeout(dialog->vrtp, 0);
+ ast_rtp_set_rtpholdtimeout(dialog->vrtp, 0);
+ }
}
/*! \brief The SIP monitoring thread
@@ -16820,8 +16847,8 @@
M_INT_GE0("rtpkeepalive", global_rtpkeepalive, 0)
M_BOOL("compactheaders", compactheaders)
M_STR("notifymimetype", default_notifymime)
+ M_BOOL("limitonpeers", global_limitonpeers)
M_BOOL("notifyringing", global_notifyringing)
- M_BOOL("limitpeersonly", global_limitonpeers)
M_BOOL("notifyhold", global_notifyhold)
M_BOOL("alwaysauthreject", global_alwaysauthreject)
M_STR("|mohinterpret|musicclass|musiconhold", default_mohinterpret)
@@ -16849,7 +16876,7 @@
outboundproxyip.sin_port = htons(format); } )
M_BOOL("autocreatepeer", autocreatepeer)
M_BOOL("match_auth_username", global_match_auth_username)
- M_BOOL("global_srvlookup", global_srvlookup)
+ M_BOOL("srvlookup", global_srvlookup)
M_BOOL("pedantic", pedanticsipchecking)
M_INT_GE("|maxexpirey|maxexpiry|", max_expiry, 1, DEFAULT_MAX_EXPIRY)
M_INT_GE("|minexpirey|minexpiry|", min_expiry, 1, DEFAULT_MIN_EXPIRY)
More information about the asterisk-commits
mailing list