[asterisk-commits] qwell: branch qwell/hold_events r389611 - /team/qwell/hold_events/channels/

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


Author: qwell
Date: Thu May 23 15:31:00 2013
New Revision: 389611

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=389611
Log:
Missed chan_iax2 and sig_pri

Modified:
    team/qwell/hold_events/channels/chan_iax2.c
    team/qwell/hold_events/channels/sig_pri.c

Modified: team/qwell/hold_events/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/channels/chan_iax2.c?view=diff&rev=389611&r1=389610&r2=389611
==============================================================================
--- team/qwell/hold_events/channels/chan_iax2.c (original)
+++ team/qwell/hold_events/channels/chan_iax2.c Thu May 23 15:31:00 2013
@@ -3095,6 +3095,52 @@
 }
 
 /*!
+ * \brief Queue a hold frame on the ast_channel owner
+ *
+ * This function queues a hold frame on the owner of the IAX2 pvt struct that
+ * is active for the given call number.
+ *
+ * \pre Assumes lock for callno is already held.
+ *
+ * \note IMPORTANT NOTE!!! Any time this function is used, even if iaxs[callno]
+ * was valid before calling it, it may no longer be valid after calling it.
+ * This function may unlock and lock the mutex associated with this callno,
+ * meaning that another thread may grab it and destroy the call.
+ */
+static int iax2_queue_hold(int callno, const char *musicclass)
+{
+	iax2_lock_owner(callno);
+	if (iaxs[callno] && iaxs[callno]->owner) {
+		ast_queue_hold(iaxs[callno]->owner, musicclass);
+		ast_channel_unlock(iaxs[callno]->owner);
+	}
+	return 0;
+}
+
+/*!
+ * \brief Queue an unhold frame on the ast_channel owner
+ *
+ * This function queues an unhold frame on the owner of the IAX2 pvt struct that
+ * is active for the given call number.
+ *
+ * \pre Assumes lock for callno is already held.
+ *
+ * \note IMPORTANT NOTE!!! Any time this function is used, even if iaxs[callno]
+ * was valid before calling it, it may no longer be valid after calling it.
+ * This function may unlock and lock the mutex associated with this callno,
+ * meaning that another thread may grab it and destroy the call.
+ */
+static int iax2_queue_unhold(int callno)
+{
+	iax2_lock_owner(callno);
+	if (iaxs[callno] && iaxs[callno]->owner) {
+		ast_queue_unhold(iaxs[callno]->owner);
+		ast_channel_unlock(iaxs[callno]->owner);
+	}
+	return 0;
+}
+
+/*!
  * \brief Queue a hangup frame on the ast_channel owner
  *
  * This function queues a hangup frame on the owner of the IAX2 pvt struct that
@@ -3112,30 +3158,6 @@
 	iax2_lock_owner(callno);
 	if (iaxs[callno] && iaxs[callno]->owner) {
 		ast_queue_hangup(iaxs[callno]->owner);
-		ast_channel_unlock(iaxs[callno]->owner);
-	}
-	return 0;
-}
-
-/*!
- * \brief Queue a control frame on the ast_channel owner
- *
- * This function queues a control frame on the owner of the IAX2 pvt struct that
- * is active for the given call number.
- *
- * \pre Assumes lock for callno is already held.
- *
- * \note IMPORTANT NOTE!!! Any time this function is used, even if iaxs[callno]
- * was valid before calling it, it may no longer be valid after calling it.
- * This function may unlock and lock the mutex associated with this callno,
- * meaning that another thread may grab it and destroy the call.
- */
-static int iax2_queue_control_data(int callno, 
-	enum ast_control_frame_type control, const void *data, size_t datalen)
-{
-	iax2_lock_owner(callno);
-	if (iaxs[callno] && iaxs[callno]->owner) {
-		ast_queue_control_data(iaxs[callno]->owner, control, data, datalen);
 		ast_channel_unlock(iaxs[callno]->owner);
 	}
 	return 0;
@@ -10302,16 +10324,6 @@
 				break;
 			case IAX_COMMAND_QUELCH:
 				if (ast_test_flag(&iaxs[fr->callno]->state, IAX_STATE_STARTED)) {
-				        /* Generate Manager Hold event, if necessary*/
-					if (iaxs[fr->callno]->owner) {
-						ast_manager_event(iaxs[fr->callno]->owner, EVENT_FLAG_CALL, "Hold",
-							"Status: On\r\n"
-							"Channel: %s\r\n"
-							"Uniqueid: %s\r\n",
-							ast_channel_name(iaxs[fr->callno]->owner),
-							ast_channel_uniqueid(iaxs[fr->callno]->owner));
-					}
-
 					ast_set_flag64(iaxs[fr->callno], IAX_QUELCH);
 					if (ies.musiconhold) {
 						const char *moh_suggest;
@@ -10326,9 +10338,7 @@
 						 * need to check iaxs[fr->callno] after it returns.
 						 */
 						moh_suggest = iaxs[fr->callno]->mohsuggest;
-						iax2_queue_control_data(fr->callno, AST_CONTROL_HOLD,
-							S_OR(moh_suggest, NULL),
-							!ast_strlen_zero(moh_suggest) ? strlen(moh_suggest) + 1 : 0);
+						iax2_queue_hold(fr->callno, S_OR(moh_suggest, NULL));
 						ast_channel_unlock(iaxs[fr->callno]->owner);
 					}
 				}
@@ -10339,15 +10349,6 @@
 					if (!iaxs[fr->callno]) {
 						break;
 					}
-					/* Generate Manager Unhold event, if necessary */
-					if (iaxs[fr->callno]->owner && ast_test_flag64(iaxs[fr->callno], IAX_QUELCH)) {
-						ast_manager_event(iaxs[fr->callno]->owner, EVENT_FLAG_CALL, "Hold",
-							"Status: Off\r\n"
-							"Channel: %s\r\n"
-							"Uniqueid: %s\r\n",
-							ast_channel_name(iaxs[fr->callno]->owner),
-							ast_channel_uniqueid(iaxs[fr->callno]->owner));
-					}
 
 					ast_clear_flag64(iaxs[fr->callno], IAX_QUELCH);
 					if (!iaxs[fr->callno]->owner) {
@@ -10358,7 +10359,7 @@
 					 * We already hold the owner lock so we do not
 					 * need to check iaxs[fr->callno] after it returns.
 					 */
-					iax2_queue_control_data(fr->callno, AST_CONTROL_UNHOLD, NULL, 0);
+					iax2_queue_unhold(fr->callno);
 					ast_channel_unlock(iaxs[fr->callno]->owner);
 				}
 				break;

Modified: team/qwell/hold_events/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/channels/sig_pri.c?view=diff&rev=389611&r1=389610&r2=389611
==============================================================================
--- team/qwell/hold_events/channels/sig_pri.c (original)
+++ team/qwell/hold_events/channels/sig_pri.c Thu May 23 15:31:00 2013
@@ -1241,6 +1241,50 @@
 	sig_pri_lock_owner(pri, chanpos);
 	if (pri->pvts[chanpos]->owner) {
 		ast_queue_frame(pri->pvts[chanpos]->owner, frame);
+		ast_channel_unlock(pri->pvts[chanpos]->owner);
+	}
+}
+
+/*!
+ * \internal
+ * \brief Queue a hold frame onto the owner channel.
+ * \since 12
+ *
+ * \param pri PRI span control structure.
+ * \param chanpos Channel position in the span.
+ *
+ * \note Assumes the pri->lock is already obtained.
+ * \note Assumes the sig_pri_lock_private(pri->pvts[chanpos]) is already obtained.
+ *
+ * \return Nothing
+ */
+static void pri_queue_hold(struct sig_pri_span *pri, int chanpos)
+{
+	sig_pri_lock_owner(pri, chanpos);
+	if (pri->pvts[chanpos]->owner) {
+		ast_queue_hold(pri->pvts[chanpos]->owner, NULL);
+		ast_channel_unlock(pri->pvts[chanpos]->owner);
+	}
+}
+
+/*!
+ * \internal
+ * \brief Queue an unhold frame onto the owner channel.
+ * \since 12
+ *
+ * \param pri PRI span control structure.
+ * \param chanpos Channel position in the span.
+ *
+ * \note Assumes the pri->lock is already obtained.
+ * \note Assumes the sig_pri_lock_private(pri->pvts[chanpos]) is already obtained.
+ *
+ * \return Nothing
+ */
+static void pri_queue_unhold(struct sig_pri_span *pri, int chanpos)
+{
+	sig_pri_lock_owner(pri, chanpos);
+	if (pri->pvts[chanpos]->owner) {
+		ast_queue_unhold(pri->pvts[chanpos]->owner);
 		ast_channel_unlock(pri->pvts[chanpos]->owner);
 	}
 }
@@ -5177,42 +5221,6 @@
 		(orig_state == next_state) ? "$" : sig_pri_moh_state_str(next_state));
 }
 
-#if defined(HAVE_PRI_CALL_HOLD)
-/*!
- * \internal
- * \brief Post an AMI hold event.
- * \since 10.0
- *
- * \param chan Channel to post event to
- * \param is_held TRUE if the call was placed on hold.
- *
- * \return Nothing
- */
-static void sig_pri_ami_hold_event(struct ast_channel *chan, int is_held)
-{
-	/*** DOCUMENTATION
-		<managerEventInstance>
-			<synopsis>Raised when a PRI channel is put on Hold.</synopsis>
-			<syntax>
-				<parameter name="Status">
-					<enumlist>
-						<enum name="On"/>
-						<enum name="Off"/>
-					</enumlist>
-				</parameter>
-			</syntax>
-		</managerEventInstance>
-	***/
-	ast_manager_event(chan, EVENT_FLAG_CALL, "Hold",
-		"Status: %s\r\n"
-		"Channel: %s\r\n"
-		"Uniqueid: %s\r\n",
-		is_held ? "On" : "Off",
-		ast_channel_name(chan),
-		ast_channel_uniqueid(chan));
-}
-#endif	/* defined(HAVE_PRI_CALL_HOLD) */
-
 /*!
  * \internal
  * \brief Set callid threadstorage for the pri_dchannel thread when a new call is created
@@ -5327,13 +5335,11 @@
 		goto done_with_owner;
 	}
 	sig_pri_handle_subcmds(pri, chanpos_old, ev->e, ev->hold.subcmds, ev->hold.call);
-	pri_queue_control(pri, chanpos_old, AST_CONTROL_HOLD);
+	pri_queue_hold(pri, chanpos_old);
 	chanpos_new = pri_fixup_principle(pri, chanpos_new, ev->hold.call);
 	if (chanpos_new < 0) {
 		/* Should never happen. */
-		pri_queue_control(pri, chanpos_old, AST_CONTROL_UNHOLD);
-	} else {
-		sig_pri_ami_hold_event(owner, 1);
+		pri_queue_unhold(pri, chanpos_old);
 	}
 
 done_with_owner:;
@@ -5522,9 +5528,8 @@
 	callid = func_pri_dchannel_chanpos_callid(pri, chanpos);
 	sig_pri_handle_subcmds(pri, chanpos, ev->e, ev->retrieve.subcmds, ev->retrieve.call);
 	sig_pri_lock_owner(pri, chanpos);
-	pri_queue_control(pri, chanpos, AST_CONTROL_UNHOLD);
+	pri_queue_unhold(pri, chanpos);
 	if (pri->pvts[chanpos]->owner) {
-		sig_pri_ami_hold_event(pri->pvts[chanpos]->owner, 0);
 		ast_channel_unlock(pri->pvts[chanpos]->owner);
 	}
 	pri_retrieve_ack(pri->pri, ev->retrieve.call,
@@ -7428,12 +7433,12 @@
 				switch (e->notify.info) {
 				case PRI_NOTIFY_REMOTE_HOLD:
 					if (!pri->discardremoteholdretrieval) {
-						pri_queue_control(pri, chanpos, AST_CONTROL_HOLD);
+						pri_queue_hold(pri, chanpos);
 					}
 					break;
 				case PRI_NOTIFY_REMOTE_RETRIEVAL:
 					if (!pri->discardremoteholdretrieval) {
-						pri_queue_control(pri, chanpos, AST_CONTROL_UNHOLD);
+						pri_queue_unhold(pri, chanpos);
 					}
 					break;
 				}




More information about the asterisk-commits mailing list