Minor tweak. Only queue up an unhold control frame if we are actually on hold. This...
authorJoshua Colp <jcolp@digium.com>
Wed, 21 Mar 2007 03:33:57 +0000 (03:33 +0000)
committerJoshua Colp <jcolp@digium.com>
Wed, 21 Mar 2007 03:33:57 +0000 (03:33 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@59083 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 758d282..07e5099 100644 (file)
@@ -5644,11 +5644,22 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
                ast_set_write_format(p->owner, p->owner->writeformat);
        }
        
-       if (sin.sin_addr.s_addr && (!sendonly || sendonly == -1)) {
+       if (ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD) && sin.sin_addr.s_addr && (!sendonly || sendonly == -1)) {
                ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
                /* Activate a re-invite */
                ast_queue_frame(p->owner, &ast_null_frame);
-       } else if (!sin.sin_addr.s_addr || sendonly) {
+               /* Queue Manager Unhold event */
+               append_history(p, "Unhold", "%s", req->data);
+               if (global_callevents)
+                       manager_event(EVENT_FLAG_CALL, "Unhold",
+                                     "Channel: %s\r\n"
+                                     "Uniqueid: %s\r\n",
+                                     p->owner->name,
+                                     p->owner->uniqueid);
+               if (global_notifyhold)
+                       sip_peer_hold(p, FALSE);
+               ast_clear_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD); /* Clear both flags */
+       } else if (!sin.sin_addr.s_addr || (sendonly && sendonly != -1)) {
                ast_queue_control_data(p->owner, AST_CONTROL_HOLD, 
                                       S_OR(p->mohsuggest, NULL),
                                       !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
@@ -5657,32 +5668,14 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
                /* RTCP needs to go ahead, even if we're on hold!!! */
                /* Activate a re-invite */
                ast_queue_frame(p->owner, &ast_null_frame);
-       }
-
-       /* Manager Hold and Unhold events must be generated, if necessary */
-       if (sin.sin_addr.s_addr && (!sendonly || sendonly == -1)) {
-               if (ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD)) {
-                       append_history(p, "Unhold", "%s", req->data);
-                       if (global_callevents)
-                               manager_event(EVENT_FLAG_CALL, "Unhold",
-                                       "Channel: %s\r\n"
-                                       "Uniqueid: %s\r\n",
-                                       p->owner->name, 
-                                       p->owner->uniqueid);
-                       if (global_notifyhold)
-                               sip_peer_hold(p, FALSE);
-               } 
-               ast_clear_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD);    /* Clear both flags */
-       } else if (!sin.sin_addr.s_addr || sendonly ) {
-               /* No address for RTP, we're on hold */
+               /* Queue Manager Hold event */
                append_history(p, "Hold", "%s", req->data);
-
                if (global_callevents && !ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD)) {
                        manager_event(EVENT_FLAG_CALL, "Hold",
-                               "Channel: %s\r\n"
-                               "Uniqueid: %s\r\n",
-                               p->owner->name, 
-                               p->owner->uniqueid);
+                                     "Channel: %s\r\n"
+                                     "Uniqueid: %s\r\n",
+                                     p->owner->name, 
+                                     p->owner->uniqueid);
                }
                if (sendonly == 1)      /* One directional hold (sendonly/recvonly) */
                        ast_set_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD_ONEDIR);