ensure that Manager hold/unhold events are generated even for non-bridged channels...
authorKevin P. Fleming <kpfleming@digium.com>
Wed, 14 Sep 2005 02:18:45 +0000 (02:18 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Wed, 14 Sep 2005 02:18:45 +0000 (02:18 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6585 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_iax2.c
channels/chan_sip.c

index 1649d66..22ae30b 100755 (executable)
@@ -6592,6 +6592,15 @@ retryowner:
                                break;
                        case IAX_COMMAND_QUELCH:
                                if (iaxs[fr.callno]->state & IAX_STATE_STARTED) {
+                                       /* Generate Manager Hold event, if necessary*/
+                                       if (iaxs[fr.callno]->owner) {
+                                               manager_event(EVENT_FLAG_CALL, "Hold",
+                                                       "Channel: %s\r\n"
+                                                       "Uniqueid: %s\r\n",
+                                                       iaxs[fr.callno]->owner->name, 
+                                                       iaxs[fr.callno]->owner->uniqueid);
+                                       }
+
                                        ast_set_flag(iaxs[fr.callno], IAX_QUELCH);
                                        if (ies.musiconhold) {
                                                if (iaxs[fr.callno]->owner &&
@@ -6600,8 +6609,17 @@ retryowner:
                                        }
                                }
                                break;
-                       case IAX_COMMAND_UNQUELCH:
+                       case IAX_COMMAND_UNQUELCH:                       
                                if (iaxs[fr.callno]->state & IAX_STATE_STARTED) {
+                                       /* Generate Manager Unhold event, if necessary*/
+                                       if (iaxs[fr.callno]->owner && ast_test_flag(iaxs[fr.callno], IAX_QUELCH)) {
+                                               manager_event(EVENT_FLAG_CALL, "Unhold",
+                                                       "Channel: %s\r\n"
+                                                       "Uniqueid: %s\r\n",
+                                                       iaxs[fr.callno]->owner->name, 
+                                                       iaxs[fr.callno]->owner->uniqueid);
+                                       }
+
                                        ast_clear_flag(iaxs[fr.callno], IAX_QUELCH);
                                        if (iaxs[fr.callno]->owner &&
                                                ast_bridged_channel(iaxs[fr.callno]->owner))
index d7e1136..f605c33 100755 (executable)
@@ -3484,32 +3484,12 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
                struct ast_frame af = { AST_FRAME_NULL, };
                if (sin.sin_addr.s_addr && !sendonly) {
                        ast_moh_stop(bridgepeer);
-                       /* Indicate UNHOLD status to the other channel */
-                       ast_indicate(bridgepeer, AST_CONTROL_UNHOLD);
-                       append_history(p, "Unhold", req->data);
-                       if (callevents && ast_test_flag(p, SIP_CALL_ONHOLD)) {
-                               manager_event(EVENT_FLAG_CALL, "Unhold",
-                                       "Channel: %s\r\n"
-                                       "Uniqueid: %s\r\n",
-                                       p->owner->name, 
-                                       p->owner->uniqueid);
-                       }
-                       ast_clear_flag(p, SIP_CALL_ONHOLD);
+               
                        /* Activate a re-invite */
                        ast_queue_frame(p->owner, &af);
                } else {
                        /* No address for RTP, we're on hold */
-                       append_history(p, "Hold", req->data);
-                       if (callevents && !ast_test_flag(p, SIP_CALL_ONHOLD)) {
-                               manager_event(EVENT_FLAG_CALL, "Hold",
-                                       "Channel: %s\r\n"
-                                       "Uniqueid: %s\r\n",
-                                       p->owner->name, 
-                                       p->owner->uniqueid);
-                       }
-                       ast_set_flag(p, SIP_CALL_ONHOLD);
-                       /* Indicate HOLD status to the other channel */
-                       ast_indicate(bridgepeer, AST_CONTROL_HOLD);
+                       
                        ast_moh_start(bridgepeer, NULL);
                        if (sendonly)
                                ast_rtp_stop(p->rtp);
@@ -3517,6 +3497,34 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
                        ast_queue_frame(p->owner, &af);
                }
        }
+
+       /* Manager Hold and Unhold events must be generated, if necessary */
+       if (sin.sin_addr.s_addr && !sendonly) {         
+               append_history(p, "Unhold", req->data);
+
+               if (callevents && ast_test_flag(p, SIP_CALL_ONHOLD)) {
+                       manager_event(EVENT_FLAG_CALL, "Unhold",
+                               "Channel: %s\r\n"
+                               "Uniqueid: %s\r\n",
+                               p->owner->name, 
+                               p->owner->uniqueid);
+
+                       }
+               ast_clear_flag(p, SIP_CALL_ONHOLD);
+       } else {                
+               /* No address for RTP, we're on hold */
+               append_history(p, "Hold", req->data);
+
+               if (callevents && !ast_test_flag(p, SIP_CALL_ONHOLD)) {
+                       manager_event(EVENT_FLAG_CALL, "Hold",
+                               "Channel: %s\r\n"
+                               "Uniqueid: %s\r\n",
+                               p->owner->name, 
+                               p->owner->uniqueid);
+               }
+               ast_set_flag(p, SIP_CALL_ONHOLD);
+       }
+
        return 0;
 }