[asterisk-commits] qwell: branch qwell/hold_events r389586 - in /team/qwell/hold_events: channel...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu May 23 15:11:03 CDT 2013


Author: qwell
Date: Thu May 23 15:10:59 2013
New Revision: 389586

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=389586
Log:
Take 1

Modified:
    team/qwell/hold_events/channels/chan_dahdi.c
    team/qwell/hold_events/channels/chan_h323.c
    team/qwell/hold_events/channels/chan_mgcp.c
    team/qwell/hold_events/channels/chan_misdn.c
    team/qwell/hold_events/channels/chan_motif.c
    team/qwell/hold_events/channels/chan_sip.c
    team/qwell/hold_events/channels/chan_skinny.c
    team/qwell/hold_events/channels/chan_unistim.c
    team/qwell/hold_events/channels/sig_analog.c
    team/qwell/hold_events/include/asterisk/channel.h
    team/qwell/hold_events/include/asterisk/stasis_channels.h
    team/qwell/hold_events/main/channel.c
    team/qwell/hold_events/main/manager_channels.c
    team/qwell/hold_events/main/stasis_channels.c
    team/qwell/hold_events/res/res_sip_sdp_rtp.c

Modified: team/qwell/hold_events/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/channels/chan_dahdi.c?view=diff&rev=389586&r1=389585&r2=389586
==============================================================================
--- team/qwell/hold_events/channels/chan_dahdi.c (original)
+++ team/qwell/hold_events/channels/chan_dahdi.c Thu May 23 15:10:59 2013
@@ -6560,7 +6560,7 @@
 				p->owner = p->subs[SUB_REAL].owner;
 				if (ast_channel_state(p->owner) != AST_STATE_UP)
 					p->subs[SUB_REAL].needanswer = 1;
-				ast_queue_control(p->subs[SUB_REAL].owner, AST_CONTROL_UNHOLD);
+				ast_queue_hold(p->subs[SUB_REAL].owner, NULL);
 			} else if (p->subs[SUB_THREEWAY].dfd > -1) {
 				swap_subs(p, SUB_THREEWAY, SUB_REAL);
 				unalloc_sub(p, SUB_THREEWAY);
@@ -6582,9 +6582,7 @@
 				/* This is actually part of a three way, placed on hold.  Place the third part
 				   on music on hold now */
 				if (p->subs[SUB_THREEWAY].owner) {
-					ast_queue_control_data(p->subs[SUB_THREEWAY].owner, AST_CONTROL_HOLD,
-						S_OR(p->mohsuggest, NULL),
-						!ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
+					ast_queue_hold(p->subs[SUB_THREEWAY].owner, S_OR(p->mohsuggest, NULL));
 				}
 				p->subs[SUB_THREEWAY].inthreeway = 0;
 				/* Make it the call wait now */
@@ -6597,9 +6595,7 @@
 				/* The other party of the three way call is currently in a call-wait state.
 				   Start music on hold for them, and take the main guy out of the third call */
 				if (p->subs[SUB_CALLWAIT].owner) {
-					ast_queue_control_data(p->subs[SUB_CALLWAIT].owner, AST_CONTROL_HOLD,
-						S_OR(p->mohsuggest, NULL),
-						!ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
+					ast_queue_hold(p->subs[SUB_CALLWAIT].owner, S_OR(p->mohsuggest, NULL));
 				}
 				p->subs[SUB_CALLWAIT].inthreeway = 0;
 			}
@@ -7851,7 +7847,7 @@
 	if (ast_bridged_channel(p->subs[SUB_REAL].owner)) {
 		/* The three-way person we're about to transfer to could still be in MOH, so
 		   stop it now */
-		ast_queue_control(p->subs[SUB_THREEWAY].owner, AST_CONTROL_UNHOLD);
+		ast_queue_unhold(p->subs[SUB_THREEWAY].owner);
 		if (ast_channel_state(p->subs[SUB_REAL].owner) == AST_STATE_RINGING) {
 			ast_queue_control(p->subs[SUB_REAL].owner, AST_CONTROL_RINGING);
 		}
@@ -7867,7 +7863,7 @@
 		ast_channel_unlock(p->subs[SUB_THREEWAY].owner);
 		unalloc_sub(p, SUB_THREEWAY);
 	} else if (ast_bridged_channel(p->subs[SUB_THREEWAY].owner)) {
-		ast_queue_control(p->subs[SUB_REAL].owner, AST_CONTROL_UNHOLD);
+		ast_queue_unhold(p->subs[SUB_REAL].owner);
 		if (ast_channel_state(p->subs[SUB_THREEWAY].owner) == AST_STATE_RINGING) {
 			ast_queue_control(p->subs[SUB_THREEWAY].owner, AST_CONTROL_RINGING);
 		}
@@ -8535,7 +8531,7 @@
 				/* Make sure it stops ringing */
 				dahdi_set_hook(p->subs[idx].dfd, DAHDI_OFFHOOK);
 				/* Okay -- probably call waiting*/
-				ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
+				ast_queue_unhold(p->owner);
 				p->subs[idx].needunhold = 1;
 				break;
 			case AST_STATE_RESERVED:
@@ -8690,14 +8686,10 @@
 				p->cid_suppress_expire = 0;
 				/* Start music on hold if appropriate */
 				if (!p->subs[SUB_CALLWAIT].inthreeway) {
-					ast_queue_control_data(p->subs[SUB_CALLWAIT].owner, AST_CONTROL_HOLD,
-						S_OR(p->mohsuggest, NULL),
-						!ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
+					ast_queue_hold(p->subs[SUB_CALLWAIT].owner, S_OR(p->mohsuggest, NULL));
 				}
 				p->subs[SUB_CALLWAIT].needhold = 1;
-				ast_queue_control_data(p->subs[SUB_REAL].owner, AST_CONTROL_HOLD,
-					S_OR(p->mohsuggest, NULL),
-					!ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
+				ast_queue_hold(p->subs[SUB_REAL].owner, S_OR(p->mohsuggest, NULL));
 				p->subs[SUB_REAL].needunhold = 1;
 			} else if (!p->subs[SUB_THREEWAY].owner) {
 				if (!p->threewaycalling) {
@@ -8775,9 +8767,7 @@
 						ast_verb(3, "Started three way call on channel %d\n", p->channel);
 
 						/* Start music on hold */
-						ast_queue_control_data(p->subs[SUB_THREEWAY].owner, AST_CONTROL_HOLD,
-							S_OR(p->mohsuggest, NULL),
-							!ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
+						ast_queue_hold(p->subs[SUB_THREEWAY].owner, S_OR(p->mohsuggest, NULL));
 						p->subs[SUB_THREEWAY].needhold = 1;
 					}
 					ast_callid_threadstorage_auto_clean(callid, callid_created);
@@ -8814,8 +8804,9 @@
 							swap_subs(p, SUB_THREEWAY, SUB_REAL);
 							otherindex = SUB_REAL;
 						}
-						if (p->subs[otherindex].owner)
-							ast_queue_control(p->subs[otherindex].owner, AST_CONTROL_UNHOLD);
+						if (p->subs[otherindex].owner) {
+							ast_queue_unhold(p->subs[otherindex].owner);
+						}
 						p->subs[otherindex].needunhold = 1;
 						p->owner = p->subs[SUB_REAL].owner;
 					} else {
@@ -8823,8 +8814,9 @@
 						swap_subs(p, SUB_THREEWAY, SUB_REAL);
 						ast_channel_softhangup_internal_flag_add(p->subs[SUB_THREEWAY].owner, AST_SOFTHANGUP_DEV);
 						p->owner = p->subs[SUB_REAL].owner;
-						if (p->subs[SUB_REAL].owner)
-							ast_queue_control(p->subs[SUB_REAL].owner, AST_CONTROL_UNHOLD);
+						if (p->subs[SUB_REAL].owner) {
+							ast_queue_unhold(p->subs[SUB_REAL].owner);
+						}
 						p->subs[SUB_REAL].needunhold = 1;
 						dahdi_enable_ec(p);
 					}
@@ -9017,8 +9009,9 @@
 			(res != DAHDI_EVENT_HOOKCOMPLETE)) {
 			ast_debug(1, "Restoring owner of channel %d on event %d\n", p->channel, res);
 			p->owner = p->subs[SUB_REAL].owner;
-			if (p->owner)
-				ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
+			if (p->owner) {
+				ast_queue_unhold(p->owner);
+			}
 			p->subs[SUB_REAL].needunhold = 1;
 		}
 		switch (res) {
@@ -9062,7 +9055,7 @@
 				p->callwaitingrepeat = 0;
 				p->cidcwexpire = 0;
 				p->cid_suppress_expire = 0;
-				ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
+				ast_queue_unhold(p->owner);
 				p->subs[SUB_REAL].needunhold = 1;
 			} else
 				ast_log(LOG_WARNING, "Absorbed on hook, but nobody is left!?!?\n");
@@ -10699,7 +10692,7 @@
 					swap_subs(p, SUB_REAL, SUB_THREEWAY);
 					unalloc_sub(p, SUB_THREEWAY);
 					p->owner = p->subs[SUB_REAL].owner;
-					ast_queue_control(p->subs[SUB_REAL].owner, AST_CONTROL_UNHOLD);
+					ast_queue_unhold(p->subs[SUB_REAL].owner);
 					ast_hangup(chan);
 					goto quit;
 				} else {

Modified: team/qwell/hold_events/channels/chan_h323.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/channels/chan_h323.c?view=diff&rev=389586&r1=389585&r2=389586
==============================================================================
--- team/qwell/hold_events/channels/chan_h323.c (original)
+++ team/qwell/hold_events/channels/chan_h323.c Thu May 23 15:10:59 2013
@@ -2096,18 +2096,17 @@
 				ast_queue_control(pvt->owner, AST_CONTROL_PROGRESS);
 			switch (rtp_change) {
 			case NEED_HOLD:
-				ast_queue_control(pvt->owner, AST_CONTROL_HOLD);
+				ast_queue_hold(pvt->owner, NULL);
 				break;
 			case NEED_UNHOLD:
-				ast_queue_control(pvt->owner, AST_CONTROL_UNHOLD);
+				ast_queue_unhold(pvt->owner);
 				break;
 			default:
 				break;
 			}
 			ast_channel_unlock(pvt->owner);
 			pvt_native = ast_format_cap_destroy(pvt_native);
-		}
-		else {
+		} else {
 			if (pvt->options.progress_audio)
 				pvt->newcontrol = AST_CONTROL_PROGRESS;
 			else if (rtp_change == NEED_HOLD)
@@ -2599,10 +2598,11 @@
 	if (!pvt)
 		return;
 	if (pvt->owner && !ast_channel_trylock(pvt->owner)) {
-		if (is_hold)
-			ast_queue_control(pvt->owner, AST_CONTROL_HOLD);
-		else
-			ast_queue_control(pvt->owner, AST_CONTROL_UNHOLD);
+		if (is_hold) {
+			ast_queue_hold(pvt->owner, NULL);
+		} else {
+			ast_queue_unhold(pvt->owner);
+		}
 		ast_channel_unlock(pvt->owner);
 	}
 	else {

Modified: team/qwell/hold_events/channels/chan_mgcp.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/channels/chan_mgcp.c?view=diff&rev=389586&r1=389585&r2=389586
==============================================================================
--- team/qwell/hold_events/channels/chan_mgcp.c (original)
+++ team/qwell/hold_events/channels/chan_mgcp.c Thu May 23 15:10:59 2013
@@ -3229,7 +3229,7 @@
 	enum ast_transfer_result res;
 
 	/* Ensure that the other channel goes off hold and that it is indicating properly */
-	ast_queue_control(sub->next->owner, AST_CONTROL_UNHOLD);
+	ast_queue_unhold(sub->next->owner);
 	if (ast_channel_state(sub->owner) == AST_STATE_RINGING) {
 		ast_queue_control(sub->next->owner, AST_CONTROL_RINGING);
 	}
@@ -3275,7 +3275,7 @@
 	if (sub->outgoing) {
 		/* Answered */
 		if (sub->owner) {
-			ast_queue_control(sub->owner, AST_CONTROL_UNHOLD);
+			ast_queue_unhold(sub->owner);
 			sub->cxmode = MGCP_CX_SENDRECV;
 			if (!sub->rtp) {
 				start_rtp(sub);
@@ -3331,7 +3331,7 @@
 				ast_log(LOG_WARNING, "On hook, but already have owner on %s@%s\n", p->name, p->parent->name);
 				ast_log(LOG_WARNING, "If we're onhook why are we here trying to handle a hd or hf?\n");
 			}
-			ast_queue_control(sub->owner, AST_CONTROL_UNHOLD);
+			ast_queue_unhold(sub->owner);
 			sub->cxmode = MGCP_CX_SENDRECV;
 			if (!sub->rtp) {
 				start_rtp(sub);
@@ -3448,8 +3448,9 @@
 					sub->cxmode = MGCP_CX_MUTE;
 					ast_verb(3, "MGCP Muting %d on %s@%s\n", sub->id, p->name, p->parent->name);
 					transmit_modify_request(sub);
-					if (sub->owner)
-						ast_queue_control(sub->owner, AST_CONTROL_HOLD);
+					if (sub->owner) {
+						ast_queue_hold(sub->owner, NULL);
+					}
 					sub->next->cxmode = MGCP_CX_RECVONLY;
 					handle_hd_hf(sub->next, ev);
 				} else if (sub->owner && sub->next->owner) {
@@ -3460,7 +3461,7 @@
 								sub->id, sub->next->id, p->name, p->parent->name);
 						sub->cxmode = MGCP_CX_CONF;
 						sub->next->cxmode = MGCP_CX_CONF;
-						ast_queue_control(sub->next->owner, AST_CONTROL_UNHOLD);
+						ast_queue_unhold(sub->next->owner);
 						transmit_modify_request(sub);
 						transmit_modify_request(sub->next);
 					} else {
@@ -3473,8 +3474,8 @@
 						ast_verb(3, "MGCP Muting %d on %s@%s\n", sub->id, p->name, p->parent->name);
 						transmit_modify_request(sub);
 
-						ast_queue_control(sub->owner, AST_CONTROL_HOLD);
-						ast_queue_control(sub->next->owner, AST_CONTROL_HOLD);
+						ast_queue_hold(sub->owner, NULL);
+						ast_queue_hold(sub->next->owner, NULL);
 
 						handle_hd_hf(sub->next, ev);
 					}
@@ -3489,7 +3490,7 @@
 						/* XXX - What do we do now? */
 						return -1;
 					}
-					ast_queue_control(p->sub->owner, AST_CONTROL_UNHOLD);
+					ast_queue_unhold(p->sub->owner);
 					p->sub->cxmode = MGCP_CX_SENDRECV;
 					transmit_modify_request(p->sub);
 				}

Modified: team/qwell/hold_events/channels/chan_misdn.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/channels/chan_misdn.c?view=diff&rev=389586&r1=389585&r2=389586
==============================================================================
--- team/qwell/hold_events/channels/chan_misdn.c (original)
+++ team/qwell/hold_events/channels/chan_misdn.c Thu May 23 15:10:59 2013
@@ -10943,7 +10943,7 @@
 		ch->hold.port = 0;
 		ch->hold.channel = 0;
 
-		ast_queue_control(ch->ast, AST_CONTROL_UNHOLD);
+		ast_queue_unhold(ch->ast);
 
 		if (misdn_lib_send_event(bc, EVENT_RETRIEVE_ACKNOWLEDGE) < 0) {
 			chan_misdn_log(4, bc->port, " --> RETRIEVE_ACK failed\n");
@@ -10973,7 +10973,7 @@
 			ch->hold.port = bc->port;
 			ch->hold.channel = bc->channel;
 
-			ast_queue_control(ch->ast, AST_CONTROL_HOLD);
+			ast_queue_hold(ch->ast, NULL);
 
 			misdn_lib_send_event(bc, EVENT_HOLD_ACKNOWLEDGE);
 		} else {

Modified: team/qwell/hold_events/channels/chan_motif.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/channels/chan_motif.c?view=diff&rev=389586&r1=389585&r2=389586
==============================================================================
--- team/qwell/hold_events/channels/chan_motif.c (original)
+++ team/qwell/hold_events/channels/chan_motif.c Thu May 23 15:10:59 2013
@@ -2481,9 +2481,9 @@
 			ast_setstate(chan, AST_STATE_RINGING);
 		}
 	} else if (iks_find_with_attrib(pak->query, "hold", "xmlns", JINGLE_RTP_INFO_NS)) {
-		ast_queue_control(chan, AST_CONTROL_HOLD);
+		ast_queue_hold(chan, NULL);
 	} else if (iks_find_with_attrib(pak->query, "unhold", "xmlns", JINGLE_RTP_INFO_NS)) {
-		ast_queue_control(chan, AST_CONTROL_UNHOLD);
+		ast_queue_unhold(chan);
 	}
 
 	ast_channel_unlock(chan);

Modified: team/qwell/hold_events/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/channels/chan_sip.c?view=diff&rev=389586&r1=389585&r2=389586
==============================================================================
--- team/qwell/hold_events/channels/chan_sip.c (original)
+++ team/qwell/hold_events/channels/chan_sip.c Thu May 23 15:10:59 2013
@@ -9879,16 +9879,9 @@
 /*! \brief Change hold state for a call */
 static void change_hold_state(struct sip_pvt *dialog, struct sip_request *req, int holdstate, int sendonly)
 {
-	if (sip_cfg.notifyhold && (!holdstate || !ast_test_flag(&dialog->flags[1], SIP_PAGE2_CALL_ONHOLD)))
+	if (sip_cfg.notifyhold && (!holdstate || !ast_test_flag(&dialog->flags[1], SIP_PAGE2_CALL_ONHOLD))) {
 		sip_peer_hold(dialog, holdstate);
-	if (sip_cfg.callevents)
-		manager_event(EVENT_FLAG_CALL, "Hold",
-			      "Status: %s\r\n"
-			      "Channel: %s\r\n"
-			      "Uniqueid: %s\r\n",
-			      holdstate ? "On" : "Off",
-			      ast_channel_name(dialog->owner),
-			      ast_channel_uniqueid(dialog->owner));
+	}
 	append_history(dialog, holdstate ? "Hold" : "Unhold", "%s", ast_str_buffer(req->data));
 	if (!holdstate) {	/* Put off remote hold */
 		ast_clear_flag(&dialog->flags[1], SIP_PAGE2_CALL_ONHOLD);	/* Clear both flags */
@@ -10795,16 +10788,14 @@
 
 	if (ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD) && (!ast_sockaddr_isnull(sa) || !ast_sockaddr_isnull(vsa) || !ast_sockaddr_isnull(tsa) || !ast_sockaddr_isnull(isa)) && (!sendonly || sendonly == -1)) {
 		if (!ast_test_flag(&p->flags[2], SIP_PAGE3_DISCARD_REMOTE_HOLD_RETRIEVAL)) {
-			ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
+			ast_queue_unhold(p->owner);
 		}
 		/* Activate a re-invite */
 		ast_queue_frame(p->owner, &ast_null_frame);
 		change_hold_state(p, req, FALSE, sendonly);
 	} else if ((sockaddr_is_null_or_any(sa) && sockaddr_is_null_or_any(vsa) && sockaddr_is_null_or_any(tsa) && sockaddr_is_null_or_any(isa)) || (sendonly && sendonly != -1)) {
 		if (!ast_test_flag(&p->flags[2], SIP_PAGE3_DISCARD_REMOTE_HOLD_RETRIEVAL)) {
-			ast_queue_control_data(p->owner, AST_CONTROL_HOLD,
-				       S_OR(p->mohsuggest, NULL),
-				       !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
+			ast_queue_hold(p->owner, S_OR(p->mohsuggest, NULL));
 		}
 		if (sendonly)
 			ast_rtp_instance_stop(p->rtp);
@@ -25440,7 +25431,7 @@
 				   *without* an SDP, which is supposed to mean "Go back to your state"
 				   and since they put os on remote hold, we go back to off hold */
 				if (ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD)) {
-					ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
+					ast_queue_unhold(p->owner);
 					/* Activate a re-invite */
 					ast_queue_frame(p->owner, &ast_null_frame);
 					change_hold_state(p, req, FALSE, 0);
@@ -26703,7 +26694,7 @@
 				bridged_to = ast_bridged_channel(c);
 				if (bridged_to) {
 					/* Don't actually hangup here... */
-					ast_queue_control(c, AST_CONTROL_UNHOLD);
+					ast_queue_unhold(c);
 					ast_channel_unlock(c);  /* async_goto can do a masquerade, no locks can be held during a masq */
 					ast_async_goto(bridged_to, p->context, p->refer->refer_to, 1);
 					ast_channel_lock(c);

Modified: team/qwell/hold_events/channels/chan_skinny.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/channels/chan_skinny.c?view=diff&rev=389586&r1=389585&r2=389586
==============================================================================
--- team/qwell/hold_events/channels/chan_skinny.c (original)
+++ team/qwell/hold_events/channels/chan_skinny.c Thu May 23 15:10:59 2013
@@ -5263,7 +5263,7 @@
 			ast_channel_name(xferor->owner), ast_bridged_channel(xferor->owner) ? ast_channel_name(ast_bridged_channel(xferor->owner)) : "");
 
 		if (ast_bridged_channel(xferor->owner)) {
-			ast_queue_control(xferee->owner, AST_CONTROL_UNHOLD);
+			ast_queue_unhold(xferee->owner);
 			if (ast_channel_state(xferor->owner) == AST_STATE_RING) {
 				/* play ringing inband */
 				if ((ts = ast_get_indication_tone(ast_channel_zone(xferor->owner), "ring"))) {
@@ -5279,7 +5279,7 @@
 				return -1;
 			}
 		} else if (ast_bridged_channel(xferee->owner)) {
-			ast_queue_control(xferee->owner, AST_CONTROL_UNHOLD);
+			ast_queue_unhold(xferee->owner);
 			if (ast_channel_state(xferor->owner) == AST_STATE_RING) {
 				/* play ringing inband */
 				if ((ts = ast_get_indication_tone(ast_channel_zone(xferor->owner), "ring"))) {
@@ -5690,9 +5690,7 @@
 
 			sub->substate = SUBSTATE_HOLD;
 
-			ast_queue_control_data(sub->owner, AST_CONTROL_HOLD,
-				S_OR(l->mohsuggest, NULL),
-				!ast_strlen_zero(l->mohsuggest) ? strlen(l->mohsuggest) + 1 : 0);
+			ast_queue_hold(sub->owner, S_OR(l->mohsuggest, NULL));
 
 			return;
 		default:
@@ -5874,7 +5872,7 @@
 			transmit_callstate(d, l->instance, sub->callid, SKINNY_OFFHOOK);
 		}
 		if (sub->substate == SUBSTATE_HOLD) {
-			ast_queue_control(sub->owner, AST_CONTROL_UNHOLD);
+			ast_queue_unhold(sub->owner);
 			transmit_connect(d, sub);
 		}
 		transmit_ringer_mode(d, SKINNY_RING_OFF);
@@ -5952,9 +5950,7 @@
 			ast_log(LOG_WARNING, "Cannot set substate to SUBSTATE_HOLD from %s (on call-%d)\n", substate2str(sub->substate), sub->callid);
 			return;
 		}
-		ast_queue_control_data(sub->owner, AST_CONTROL_HOLD,
-			S_OR(l->mohsuggest, NULL),
-			!ast_strlen_zero(l->mohsuggest) ? strlen(l->mohsuggest) + 1 : 0);
+		ast_queue_hold(sub->owner, S_OR(l->mohsuggest, NULL));
 
 		transmit_activatecallplane(d, l);
 		transmit_closereceivechannel(d, sub);

Modified: team/qwell/hold_events/channels/chan_unistim.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/channels/chan_unistim.c?view=diff&rev=389586&r1=389585&r2=389586
==============================================================================
--- team/qwell/hold_events/channels/chan_unistim.c (original)
+++ team/qwell/hold_events/channels/chan_unistim.c Thu May 23 15:10:59 2013
@@ -2453,7 +2453,7 @@
 	send_select_output(pte, pte->device->output, pte->device->volume, MUTE_ON);
 	send_stop_timer(pte);
 	if (sub->owner) {
-		ast_queue_control_data(sub->owner, AST_CONTROL_HOLD, NULL, 0);
+		ast_queue_hold(sub->owner, NULL);
 		send_end_call(pte);
 	}
 	return;
@@ -2474,7 +2474,7 @@
 	send_select_output(pte, pte->device->output, pte->device->volume, MUTE_OFF);
 	send_start_timer(pte);
 	if (sub->owner) {
-		ast_queue_control_data(sub->owner, AST_CONTROL_UNHOLD, NULL, 0);
+		ast_queue_unhold(sub->owner);
 		if (sub->rtp) {
 			send_start_rtp(sub);
 		}
@@ -2961,8 +2961,7 @@
 	if (sub->moh) {
 		ast_log(LOG_WARNING, "Transfer with peer already listening music on hold\n");
 	} else {
-		ast_queue_control_data(sub->owner, AST_CONTROL_HOLD,
-			sub->parent->musicclass, strlen(sub->parent->musicclass) + 1);
+		ast_queue_hold(sub->owner, sub->parent->musicclass);
 		sub->moh = 1;
 		sub->subtype = SUB_THREEWAY;
 	}
@@ -2988,7 +2987,7 @@
 		}
 		if (sub->owner) {
 			swap_subs(sub, sub_trans);
-			ast_queue_control(sub_trans->owner, AST_CONTROL_UNHOLD);
+			ast_queue_unhold(sub_trans->owner);
 			sub_trans->moh = 0;
 			sub_trans->subtype = SUB_REAL;
 			sub->subtype = SUB_THREEWAY;
@@ -3498,7 +3497,7 @@
 		if (sub && sub->owner) {
 			sub_stop_silence(pte, sub);
 			send_tone(pte, 0, 0);
-			ast_queue_control(sub->owner, AST_CONTROL_UNHOLD);
+			ast_queue_unhold(sub->owner);
 			sub->moh = 0;
 			sub->subtype = SUB_REAL;
 			pte->state = STATE_CALL;
@@ -4789,7 +4788,7 @@
 		if (unistimdebug) {
 			ast_verb(0, "Threeway call disconnected, switching to real call\n");
 		}
-		ast_queue_control(sub_trans->owner, AST_CONTROL_UNHOLD);
+		ast_queue_unhold(sub_trans->owner);
 		sub_trans->moh = 0;
 		sub_trans->subtype = SUB_REAL;
 		swap_subs(sub_trans, sub);

Modified: team/qwell/hold_events/channels/sig_analog.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/channels/sig_analog.c?view=diff&rev=389586&r1=389585&r2=389586
==============================================================================
--- team/qwell/hold_events/channels/sig_analog.c (original)
+++ team/qwell/hold_events/channels/sig_analog.c Thu May 23 15:10:59 2013
@@ -1354,7 +1354,7 @@
 				if (ast_channel_state(p->owner) != AST_STATE_UP) {
 					ast_queue_control(p->subs[ANALOG_SUB_REAL].owner, AST_CONTROL_ANSWER);
 				}
-				ast_queue_control(p->subs[ANALOG_SUB_REAL].owner, AST_CONTROL_UNHOLD);
+				ast_queue_unhold(p->subs[ANALOG_SUB_REAL].owner);
 				/* Unlock the call-waiting call that we swapped to real-call. */
 				ast_channel_unlock(p->subs[ANALOG_SUB_REAL].owner);
 			} else if (p->subs[ANALOG_SUB_THREEWAY].allocd) {
@@ -1382,9 +1382,7 @@
 				/* This is actually part of a three way, placed on hold.  Place the third part
 				   on music on hold now */
 				if (p->subs[ANALOG_SUB_THREEWAY].owner) {
-					ast_queue_control_data(p->subs[ANALOG_SUB_THREEWAY].owner, AST_CONTROL_HOLD,
-						S_OR(p->mohsuggest, NULL),
-						!ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
+					ast_queue_hold(p->subs[ANALOG_SUB_THREEWAY].owner, S_OR(p->mohsuggest, NULL));
 				}
 				analog_set_inthreeway(p, ANALOG_SUB_THREEWAY, 0);
 				/* Make it the call wait now */
@@ -1406,9 +1404,7 @@
 				   Start music on hold for them, and take the main guy out of the third call */
 				analog_set_inthreeway(p, ANALOG_SUB_CALLWAIT, 0);
 				if (p->subs[ANALOG_SUB_CALLWAIT].owner) {
-					ast_queue_control_data(p->subs[ANALOG_SUB_CALLWAIT].owner, AST_CONTROL_HOLD,
-						S_OR(p->mohsuggest, NULL),
-						!ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
+					ast_queue_hold(p->subs[ANALOG_SUB_CALLWAIT].owner, S_OR(p->mohsuggest, NULL));
 				}
 			}
 			if (p->subs[ANALOG_SUB_CALLWAIT].owner) {
@@ -2323,7 +2319,7 @@
 					analog_swap_subs(p, ANALOG_SUB_REAL, ANALOG_SUB_THREEWAY);
 					analog_unalloc_sub(p, ANALOG_SUB_THREEWAY);
 					analog_set_new_owner(p, p->subs[ANALOG_SUB_REAL].owner);
-					ast_queue_control(p->subs[ANALOG_SUB_REAL].owner, AST_CONTROL_UNHOLD);
+					ast_queue_unhold(p->subs[ANALOG_SUB_REAL].owner);
 					ast_hangup(chan);
 					goto quit;
 				} else {
@@ -3024,7 +3020,7 @@
 				/* Make sure it stops ringing */
 				analog_off_hook(p);
 				/* Okay -- probably call waiting */
-				ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
+				ast_queue_unhold(p->owner);
 				break;
 			case AST_STATE_RESERVED:
 				/* Start up dialtone */
@@ -3183,14 +3179,10 @@
 
 				/* Start music on hold if appropriate */
 				if (!p->subs[ANALOG_SUB_CALLWAIT].inthreeway) {
-					ast_queue_control_data(p->subs[ANALOG_SUB_CALLWAIT].owner, AST_CONTROL_HOLD,
-						S_OR(p->mohsuggest, NULL),
-						!ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
-				}
-				ast_queue_control_data(p->subs[ANALOG_SUB_REAL].owner, AST_CONTROL_HOLD,
-					S_OR(p->mohsuggest, NULL),
-					!ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
-				ast_queue_control(p->subs[ANALOG_SUB_REAL].owner, AST_CONTROL_UNHOLD);
+					ast_queue_hold(p->subs[ANALOG_SUB_CALLWAIT].owner, S_OR(p->mohsuggest, NULL));
+				}
+				ast_queue_hold(p->subs[ANALOG_SUB_REAL].owner, S_OR(p->mohsuggest, NULL));
+				ast_queue_unhold(p->subs[ANALOG_SUB_REAL].owner);
 
 				/* Unlock the call-waiting call that we swapped to real-call. */
 				ast_channel_unlock(p->subs[ANALOG_SUB_REAL].owner);
@@ -3282,9 +3274,7 @@
 						ast_verb(3, "Started three way call on channel %d\n", p->channel);
 
 						/* Start music on hold */
-						ast_queue_control_data(p->subs[ANALOG_SUB_THREEWAY].owner, AST_CONTROL_HOLD,
-							S_OR(p->mohsuggest, NULL),
-							!ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
+						ast_queue_hold(p->subs[ANALOG_SUB_THREEWAY].owner, S_OR(p->mohsuggest, NULL));
 					}
 					ast_callid_threadstorage_auto_clean(callid, callid_created);
 				}
@@ -3334,7 +3324,7 @@
 							analog_swap_subs(p, ANALOG_SUB_THREEWAY, ANALOG_SUB_REAL);
 							orig_3way_sub = ANALOG_SUB_REAL;
 						}
-						ast_queue_control(p->subs[orig_3way_sub].owner, AST_CONTROL_UNHOLD);
+						ast_queue_unhold(p->subs[orig_3way_sub].owner);
 						analog_set_new_owner(p, p->subs[ANALOG_SUB_REAL].owner);
 					} else {
 						ast_verb(3, "Dumping incomplete call on %s\n", ast_channel_name(p->subs[ANALOG_SUB_THREEWAY].owner));
@@ -3342,7 +3332,7 @@
 						orig_3way_sub = ANALOG_SUB_REAL;
 						ast_softhangup_nolock(p->subs[ANALOG_SUB_THREEWAY].owner, AST_SOFTHANGUP_DEV);
 						analog_set_new_owner(p, p->subs[ANALOG_SUB_REAL].owner);
-						ast_queue_control(p->subs[ANALOG_SUB_REAL].owner, AST_CONTROL_UNHOLD);
+						ast_queue_unhold(p->subs[ANALOG_SUB_REAL].owner);
 						analog_set_echocanceller(p, 1);
 					}
 				}
@@ -3585,7 +3575,7 @@
 					analog_event2str(res), ast_channel_name(ast), ast_channel_name(p->owner));
 			}
 			if (p->owner) {
-				ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
+				ast_queue_unhold(p->owner);
 			}
 		}
 		switch (res) {
@@ -3624,7 +3614,7 @@
 					ast_setstate(p->owner, AST_STATE_UP);
 				}
 				analog_stop_callwait(p);
-				ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
+				ast_queue_unhold(p->owner);
 			} else {
 				ast_log(LOG_WARNING, "Absorbed %s, but nobody is left!?!?\n",
 					analog_event2str(res));

Modified: team/qwell/hold_events/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/include/asterisk/channel.h?view=diff&rev=389586&r1=389585&r2=389586
==============================================================================
--- team/qwell/hold_events/include/asterisk/channel.h (original)
+++ team/qwell/hold_events/include/asterisk/channel.h Thu May 23 15:10:59 2013
@@ -1201,6 +1201,31 @@
  * \since 1.6.1
  */
 int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause);
+
+/*!
+ * \brief Queue a hold frame
+ *
+ * \param chan channel to queue frame onto
+ * \param musicclass The suggested musicclass for the other end to use
+ *
+ * \note The channel does not need to be locked before calling this function.
+ *
+ * \retval zero on success
+ * \retval non-zero on failure
+ */
+int ast_queue_hold(struct ast_channel *chan, const char *musicclass);
+
+/*!
+ * \brief Queue an unhold frame
+ *
+ * \param chan channel to queue frame onto
+ *
+ * \note The channel does not need to be locked before calling this function.
+ *
+ * \retval zero on success
+ * \retval non-zero on failure
+ */
+int ast_queue_unhold(struct ast_channel *chan);
 
 /*!
  * \brief Queue a control frame with payload

Modified: team/qwell/hold_events/include/asterisk/stasis_channels.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/include/asterisk/stasis_channels.h?view=diff&rev=389586&r1=389585&r2=389586
==============================================================================
--- team/qwell/hold_events/include/asterisk/stasis_channels.h (original)
+++ team/qwell/hold_events/include/asterisk/stasis_channels.h Thu May 23 15:10:59 2013
@@ -282,6 +282,22 @@
 
 /*!
  * \since 12
+ * \brief Message type for when a channel is placed on hold.
+ *
+ * \retval A stasis message type
+ */
+struct stasis_message_type *ast_channel_hold_type(void);
+
+/*!
+ * \since 12
+ * \brief Message type for when a channel is removed from hold.
+ *
+ * \retval A stasis message type
+ */
+struct stasis_message_type *ast_channel_unhold_type(void);
+
+/*!
+ * \since 12
  * \brief Publish in the \ref ast_channel_topic or \ref ast_channel_topic_all
  * topics a stasis message for the channels involved in a dial operation.
  *

Modified: team/qwell/hold_events/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/main/channel.c?view=diff&rev=389586&r1=389585&r2=389586
==============================================================================
--- team/qwell/hold_events/main/channel.c (original)
+++ team/qwell/hold_events/main/channel.c Thu May 23 15:10:59 2013
@@ -1353,9 +1353,11 @@
 	struct stasis_message_type *type, struct ast_json *blob)
 {
 	RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
-	if (blob) {
-		message = ast_channel_blob_create(chan, type, blob);
-	}
+	if (!blob) {
+		blob = ast_json_null();
+	}
+
+	message = ast_channel_blob_create(chan, type, blob);
 	if (message) {
 		stasis_publish(ast_channel_topic(chan), message);
 	}
@@ -1402,6 +1404,41 @@
 
 	res = ast_queue_frame(chan, &f);
 	ast_channel_unlock(chan);
+	return res;
+}
+
+/*! \brief Queue a hold frame for channel */
+int ast_queue_hold(struct ast_channel *chan, const char *musicclass)
+{
+	RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
+	RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
+	struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_HOLD };
+	int res;
+
+	if (!ast_strlen_zero(musicclass)) {
+		f.data.ptr = (void *) musicclass;
+		f.datalen = strlen(musicclass) + 1;
+
+		blob = ast_json_pack("{s: s}",
+				     "musicclass", musicclass);
+	}
+
+	publish_channel_blob(chan, ast_channel_hold_type(), blob);
+
+	res = ast_queue_frame(chan, &f);
+	return res;
+}
+
+/*! \brief Queue a unhold frame for channel */
+int ast_queue_unhold(struct ast_channel *chan)
+{
+	RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
+	struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_UNHOLD };
+	int res;
+
+	publish_channel_blob(chan, ast_channel_unhold_type(), NULL);
+
+	res = ast_queue_frame(chan, &f);
 	return res;
 }
 
@@ -6694,7 +6731,7 @@
 
 	/* Release any hold on the target. */
 	if (colp->target_held) {
-		ast_queue_control(transferee, AST_CONTROL_UNHOLD);
+		ast_queue_unhold(transferee);
 	}
 
 	/*

Modified: team/qwell/hold_events/main/manager_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/main/manager_channels.c?view=diff&rev=389586&r1=389585&r2=389586
==============================================================================
--- team/qwell/hold_events/main/manager_channels.c (original)
+++ team/qwell/hold_events/main/manager_channels.c Thu May 23 15:10:59 2013
@@ -735,6 +735,48 @@
 
 }
 
+static void channel_hold_cb(void *data, struct stasis_subscription *sub,
+	struct stasis_topic *topic, struct stasis_message *message)
+{
+	struct ast_channel_blob *obj = stasis_message_data(message);
+	const char *musicclass;
+	RAII_VAR(struct ast_str *, musicclass_string, NULL, ast_free);
+	RAII_VAR(struct ast_str *, channel_event_string, NULL, ast_free);
+
+	if (!(musicclass_string = ast_str_create(32))) {
+		return;
+	}
+
+	channel_event_string = ast_manager_build_channel_state_string(obj->snapshot);
+
+	if (obj->blob) {
+		musicclass = ast_json_string_get(ast_json_object_get(obj->blob, "musicclass"));
+
+		if (!ast_strlen_zero(musicclass)) {
+			ast_str_set(&musicclass_string, 0, "MusicClass: %s\r\n", musicclass);
+		}
+	}
+
+	manager_event(EVENT_FLAG_CALL, "Hold",
+		"%s"
+		"%s",
+		ast_str_buffer(channel_event_string),
+		ast_str_buffer(musicclass_string));
+}
+
+static void channel_unhold_cb(void *data, struct stasis_subscription *sub,
+	struct stasis_topic *topic, struct stasis_message *message)
+{
+	struct ast_channel_blob *obj = stasis_message_data(message);
+	RAII_VAR(struct ast_str *, channel_event_string, NULL, ast_free);
+
+	channel_event_string = ast_manager_build_channel_state_string(obj->snapshot);
+
+	manager_event(EVENT_FLAG_CALL, "Unhold",
+		"%s",
+		ast_str_buffer(channel_event_string));
+}
+
 static void manager_channels_shutdown(void)
 {
 	stasis_message_router_unsubscribe_and_join(channel_state_router);
@@ -792,6 +834,16 @@
 	ret |= stasis_message_router_add(channel_state_router,
 					 ast_channel_dial_type(),
 					 channel_dial_cb,
+					 NULL);
+
+	ret |= stasis_message_router_add(channel_state_router,
+					 ast_channel_hold_type(),
+					 channel_hold_cb,
+					 NULL);
+
+	ret |= stasis_message_router_add(channel_state_router,
+					 ast_channel_unhold_type(),
+					 channel_unhold_cb,
 					 NULL);
 
 	/* If somehow we failed to add any routes, just shut down the whole

Modified: team/qwell/hold_events/main/stasis_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/main/stasis_channels.c?view=diff&rev=389586&r1=389585&r2=389586
==============================================================================
--- team/qwell/hold_events/main/stasis_channels.c (original)
+++ team/qwell/hold_events/main/stasis_channels.c Thu May 23 15:10:59 2013
@@ -48,6 +48,8 @@
 STASIS_MESSAGE_TYPE_DEFN(ast_channel_hangup_request_type);
 STASIS_MESSAGE_TYPE_DEFN(ast_channel_dtmf_begin_type);
 STASIS_MESSAGE_TYPE_DEFN(ast_channel_dtmf_end_type);
+STASIS_MESSAGE_TYPE_DEFN(ast_channel_hold_type);
+STASIS_MESSAGE_TYPE_DEFN(ast_channel_unhold_type);
 /*! @} */
 
 /*! \brief Topic for all channels */
@@ -513,6 +515,8 @@
 	STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_hangup_request_type);
 	STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_dtmf_begin_type);
 	STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_dtmf_end_type);
+	STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_hold_type);
+	STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_unhold_type);
 }
 
 void ast_stasis_channels_init(void)
@@ -524,6 +528,8 @@
 	STASIS_MESSAGE_TYPE_INIT(ast_channel_hangup_request_type);
 	STASIS_MESSAGE_TYPE_INIT(ast_channel_dtmf_begin_type);
 	STASIS_MESSAGE_TYPE_INIT(ast_channel_dtmf_end_type);
+	STASIS_MESSAGE_TYPE_INIT(ast_channel_hold_type);
+	STASIS_MESSAGE_TYPE_INIT(ast_channel_unhold_type);
 
 	channel_topic_all = stasis_topic_create("ast_channel_topic_all");
 	channel_topic_all_cached = stasis_caching_topic_create(channel_topic_all, channel_snapshot_get_id);

Modified: team/qwell/hold_events/res/res_sip_sdp_rtp.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/res/res_sip_sdp_rtp.c?view=diff&rev=389586&r1=389585&r2=389586
==============================================================================
--- team/qwell/hold_events/res/res_sip_sdp_rtp.c (original)
+++ team/qwell/hold_events/res/res_sip_sdp_rtp.c Thu May 23 15:10:59 2013
@@ -698,15 +698,14 @@
 	    (!ast_sockaddr_isnull(addrs) ||
 	     !pjmedia_sdp_media_find_attr2(remote_stream, "sendonly", NULL))) {
 		/* The remote side has taken us off hold */
-		ast_queue_control(session->channel, AST_CONTROL_UNHOLD);
+		ast_queue_unhold(session->channel);
 		ast_queue_frame(session->channel, &ast_null_frame);
 		session_media->held = 0;
 	} else if (ast_sockaddr_isnull(addrs) ||
 		   ast_sockaddr_is_any(addrs) ||
 		   pjmedia_sdp_media_find_attr2(remote_stream, "sendonly", NULL)) {
 		/* The remote side has put us on hold */
-		ast_queue_control_data(session->channel, AST_CONTROL_HOLD, S_OR(session->endpoint->mohsuggest, NULL),
-				       !ast_strlen_zero(session->endpoint->mohsuggest) ? strlen(session->endpoint->mohsuggest) + 1 : 0);
+		ast_queue_hold(session->channel, S_OR(session->endpoint->mohsuggest, NULL));
 		ast_rtp_instance_stop(session_media->rtp);
 		ast_queue_frame(session->channel, &ast_null_frame);
 		session_media->held = 1;




More information about the asterisk-commits mailing list