]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 370619 via svnmerge from
authorAutomerge script <automerge@asterisk.org>
Tue, 31 Jul 2012 16:22:23 +0000 (16:22 +0000)
committerAutomerge script <automerge@asterisk.org>
Tue, 31 Jul 2012 16:22:23 +0000 (16:22 +0000)
file:///srv/subversion/repos/asterisk/branches/10

................
  r370619 | mmichelson | 2012-07-31 10:31:57 -0500 (Tue, 31 Jul 2012) | 34 lines

  Help mitigate potential reinvite glare scenarios.

  When Asterisk servers are set up back-to-back, and
  direct media is to be used betweeen endpoints, it is
  fairly common for the two Asterisk servers to send
  direct media reinvites to each other simultaneously.
  This results in 491s and ACKs being exchanged between
  the servers. While the media eventually gets set up
  properly, the problem is that there can be a noticeable
  delay for the streams to stabilize.

  This patch adds a new directmedia option called "outgoing".
  With this set, an immediate direct media reinvite will only
  be sent if the call direction is outgoing. For incoming
  dialogs, an immediate direct media reinvite will not be sent,
  but further "reactionary" direct media reinvites may be sent.

  For those who are having some deja vu, that's because this
  patch was originally committed to trunk since there is a
  new configuration option added. After seeing a bug report
  about audio being slow to set up on SIP calls, it became
  apparent that this patch would be the best solution for
  resolving the issue. The patch is unintrusive and will
  have no effect unless the option is explicitly enabled.

  (closes issue AST-896)
  reported by Thomas Arimont

  (closes issue ASTERISK-19857)
  reported by Matt Jordan
  ........

  Merged revisions 370618 from http://svn.asterisk.org/svn/asterisk/branches/1.8
................

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/10-digiumphones@370633 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c
channels/sip/include/sip.h
configs/sip.conf.sample

index 0993233728bc0c152f448933ba55dbeedbdc5c55..b2ab54a6761e51786a98e5885207690d386da4db 100644 (file)
@@ -28069,6 +28069,10 @@ static int handle_common_options(struct ast_flags *flags, struct ast_flags *mask
                                } else if (!strcasecmp(word, "nonat")) {
                                        ast_set_flag(&flags[0], SIP_DIRECT_MEDIA);
                                        ast_clear_flag(&flags[0], SIP_DIRECT_MEDIA_NAT);
+                               } else if (!strcasecmp(word, "outgoing")) {
+                                       ast_set_flag(&flags[0], SIP_DIRECT_MEDIA);
+                                       ast_set_flag(&mask[2], SIP_PAGE3_DIRECT_MEDIA_OUTGOING);
+                                       ast_set_flag(&flags[2], SIP_PAGE3_DIRECT_MEDIA_OUTGOING);
                                } else {
                                        ast_log(LOG_WARNING, "Unknown directmedia mode '%s' on line %d\n", v->value, v->lineno);
                                }
@@ -30641,6 +30645,18 @@ static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *i
                ast_format_cap_copy(p->redircaps, cap);
                changed = 1;
        }
+
+       if (ast_test_flag(&p->flags[2], SIP_PAGE3_DIRECT_MEDIA_OUTGOING) && !p->outgoing_call) {
+               /* We only wish to withhold sending the initial direct media reinvite on the incoming dialog.
+                * Further direct media reinvites beyond the initial should be sent. In order to allow further
+                * direct media reinvites to be sent, we clear this flag.
+                */
+               ast_clear_flag(&p->flags[2], SIP_PAGE3_DIRECT_MEDIA_OUTGOING);
+               sip_pvt_unlock(p);
+               ast_channel_unlock(chan);
+               return 0;
+       }
+
        if (changed && !ast_test_flag(&p->flags[0], SIP_GOTREFER) && !ast_test_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER)) {
                if (chan->_state != AST_STATE_UP) {     /* We are in early state */
                        if (p->do_history)
index 271fd997b178770ddaaea15b2945a3dca164c4e2..3166814386c06fb104cb939f26b72a8a9cd4d5d3 100644 (file)
 
 #define SIP_PAGE3_SNOM_AOC               (1 << 0)  /*!< DPG: Allow snom aoc messages */
 #define SIP_PAGE3_SRTP_TAG_32            (1 << 1)  /*!< DP: Use a 32bit auth tag in INVITE not 80bit */
+#define SIP_PAGE3_DIRECT_MEDIA_OUTGOING  (1 << 2)  /*!< DP: Only send direct media reinvites on outgoing calls */
 
 #define SIP_PAGE3_FLAGS_TO_COPY \
-       (SIP_PAGE3_SNOM_AOC | SIP_PAGE3_SRTP_TAG_32)
+       (SIP_PAGE3_SNOM_AOC | SIP_PAGE3_SRTP_TAG_32 | SIP_PAGE3_DIRECT_MEDIA_OUTGOING)
 
 #define CHECK_AUTH_BUF_INITLEN   256
 
index 70657a283fc5c1ef9c5f5ff2f5b948de7fb51f29..a235779c2149eb2a2d8427ac6adef175dbf7168f 100644 (file)
@@ -888,6 +888,13 @@ srvlookup=yes                   ; Enable DNS SRV lookups on outbound calls
                                 ; instead of INVITE. This can be combined with 'nonat', as
                                 ; 'directmedia=update,nonat'. It implies 'yes'.
 
+;directmedia=outgoing           ; When sending directmedia reinvites, do not send an immediate
+                                ; reinvite on an incoming call leg. This option is useful when
+                                ; peered with another SIP user agent that is known to send
+                                ; immediate direct media reinvites upon call establishment. Setting
+                                ; the option in this situation helps to prevent potential glares.
+                                ; Setting this option implies 'yes'.
+
 ;directrtpsetup=yes             ; Enable the new experimental direct RTP setup. This sets up
                                 ; the call directly with media peer-2-peer without re-invites.
                                 ; Will not work for video and cases where the callee sends