[asterisk-commits] mmichelson: branch 1.6.0 r166097 - in /branches/1.6.0: ./ include/asterisk/ m...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Dec 19 17:04:07 CST 2008


Author: mmichelson
Date: Fri Dec 19 17:04:07 2008
New Revision: 166097

URL: http://svn.digium.com/view/asterisk?view=rev&rev=166097
Log:
Merged revisions 166092,166095 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
r166092 | mmichelson | 2008-12-19 16:26:16 -0600 (Fri, 19 Dec 2008) | 28 lines

Adding a new dialplan function AUDIOHOOK_INHERIT

This function is being added as a method to allow for
an audiohook to move to a new channel during a channel
masquerade. The most obvious use for such a facility is
for MixMonitor when a transfer is performed. Prior to
the addition of this functionality, if a channel 
running MixMonitor was transferred by another party, then
the recording would stop once the transfer had completed.
By using AUDIOHOOK_INHERIT, you can make MixMonitor 
continue recording the call even after the transfer
has completed.

It has also been determined that since this is seen
by most as a bug fix and is not an invasive change,
this functionality will also be backported to 1.4 and
merged into the 1.6.0 branches, even though they are
feature-frozen.

(closes issue #13538)
Reported by: mbit
Patches:
      13538.patch uploaded by putnopvut (license 60)
	  Tested by: putnopvut

Review: http://reviewboard.digium.com/r/102/


........
r166095 | mmichelson | 2008-12-19 16:40:57 -0600 (Fri, 19 Dec 2008) | 5 lines

Remove the verbatim tag from the author line

I could have sworn I already did that before, though...


........

Modified:
    branches/1.6.0/   (props changed)
    branches/1.6.0/CHANGES
    branches/1.6.0/include/asterisk/audiohook.h
    branches/1.6.0/main/audiohook.c
    branches/1.6.0/main/channel.c

Propchange: branches/1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.0/CHANGES
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/CHANGES?view=diff&rev=166097&r1=166096&r2=166097
==============================================================================
--- branches/1.6.0/CHANGES (original)
+++ branches/1.6.0/CHANGES Fri Dec 19 17:04:07 2008
@@ -92,6 +92,10 @@
      ID for the call (not the Asterisk call ID or unique ID), provided that the
      channel driver supports this. For SIP, you get the SIP call-ID for the
      bridged channel which you can store in the CDR with a custom field.
+  * Added the function AUDIOHOOK_INHERIT. This actually is already in Asterisk
+    1.4, but since it was added late in the release cycle, I felt it was a good
+	idea to list it here as well. See the CLI output for "core show function
+	AUDIOHOOK_INHERIT" for more details
 
 CLI Changes
 -----------

Modified: branches/1.6.0/include/asterisk/audiohook.h
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/include/asterisk/audiohook.h?view=diff&rev=166097&r1=166096&r2=166097
==============================================================================
--- branches/1.6.0/include/asterisk/audiohook.h (original)
+++ branches/1.6.0/include/asterisk/audiohook.h Fri Dec 19 17:04:07 2008
@@ -150,6 +150,21 @@
  */
 int ast_audiohook_detach_list(struct ast_audiohook_list *audiohook_list);
 
+/*! \brief Move an audiohook from one channel to a new one
+ *
+ * \todo Currently only the first audiohook of a specific source found will be moved.
+ * We should add the capability to move multiple audiohooks from a single source as well.
+ *
+ * \note It is required that both old_chan and new_chan are locked prior to calling
+ * this function. Besides needing to protect the data within the channels, not locking
+ * these channels can lead to a potential deadlock
+ *
+ * \param old_chan The source of the audiohook to move
+ * \param new_chan The destination to which we want the audiohook to move
+ * \param source The source of the audiohook we want to move
+ */
+void ast_audiohook_move_by_source(struct ast_channel *old_chan, struct ast_channel *new_chan, const char *source);
+
 /*! 
  * \brief Detach specified source audiohook from channel
  *
@@ -161,6 +176,18 @@
  * \note The channel does not need to be locked before calling this function.
  */
 int ast_audiohook_detach_source(struct ast_channel *chan, const char *source);
+
+/*!
+ * \brief Remove an audiohook from a specified channel
+ *
+ * \param chan Channel to remove from
+ * \param audiohook Audiohook to remove
+ *
+ * \return Returns 0 on success, -1 on failure
+ *
+ * \note The channel does not need to be locked before calling this function
+ */
+int ast_audiohook_remove(struct ast_channel *chan, struct ast_audiohook *audiohook);
 
 /*! \brief Pass a frame off to be handled by the audiohook core
  * \param chan Channel that the list is coming off of

Modified: branches/1.6.0/main/audiohook.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/main/audiohook.c?view=diff&rev=166097&r1=166096&r2=166097
==============================================================================
--- branches/1.6.0/main/audiohook.c (original)
+++ branches/1.6.0/main/audiohook.c Fri Dec 19 17:04:07 2008
@@ -412,6 +412,11 @@
 	return 0;
 }
 
+/*! \brief find an audiohook based on its source
+ * \param audiohook_list The list of audiohooks to search in
+ * \param source The source of the audiohook we wish to find
+ * \return Return the corresponding audiohook or NULL if it cannot be found.
+ */
 static struct ast_audiohook *find_audiohook_by_source(struct ast_audiohook_list *audiohook_list, const char *source)
 {
 	struct ast_audiohook *audiohook = NULL;
@@ -432,6 +437,25 @@
 	}
 
 	return NULL;
+}
+
+void ast_audiohook_move_by_source (struct ast_channel *old_chan, struct ast_channel *new_chan, const char *source)
+{
+	struct ast_audiohook *audiohook = find_audiohook_by_source(old_chan->audiohooks, source);
+
+	if (!audiohook) {
+		return;
+	}
+	
+	/* By locking both channels and the audiohook, we can assure that
+	 * another thread will not have a chance to read the audiohook's status
+	 * as done, even though ast_audiohook_remove signals the trigger
+	 * condition
+	 */
+	ast_audiohook_lock(audiohook);
+	ast_audiohook_remove(old_chan, audiohook);
+	ast_audiohook_attach(new_chan, audiohook);
+	ast_audiohook_unlock(audiohook);
 }
 
 /*! \brief Detach specified source audiohook from channel
@@ -459,6 +483,42 @@
 		audiohook->status = AST_AUDIOHOOK_STATUS_SHUTDOWN;
 
 	return (audiohook ? 0 : -1);
+}
+
+/*!
+ * \brief Remove an audiohook from a specified channel
+ *
+ * \param chan Channel to remove from
+ * \param audiohook Audiohook to remove
+ *
+ * \return Returns 0 on success, -1 on failure
+ *
+ * \note The channel does not need to be locked before calling this function
+ */
+int ast_audiohook_remove(struct ast_channel *chan, struct ast_audiohook *audiohook)
+{
+	ast_channel_lock(chan);
+
+	if (!chan->audiohooks) {
+		ast_channel_unlock(chan);
+		return -1;
+	}
+
+	if (audiohook->type == AST_AUDIOHOOK_TYPE_SPY)
+		AST_LIST_REMOVE(&chan->audiohooks->spy_list, audiohook, list);
+	else if (audiohook->type == AST_AUDIOHOOK_TYPE_WHISPER)
+		AST_LIST_REMOVE(&chan->audiohooks->whisper_list, audiohook, list);
+	else if (audiohook->type == AST_AUDIOHOOK_TYPE_MANIPULATE)
+		AST_LIST_REMOVE(&chan->audiohooks->manipulate_list, audiohook, list);
+
+	ast_audiohook_lock(audiohook);
+	audiohook->status = AST_AUDIOHOOK_STATUS_DONE;
+	ast_cond_signal(&audiohook->trigger);
+	ast_audiohook_unlock(audiohook);
+
+	ast_channel_unlock(chan);
+
+	return 0;
 }
 
 /*! \brief Pass a DTMF frame off to be handled by the audiohook core

Modified: branches/1.6.0/main/channel.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/main/channel.c?view=diff&rev=166097&r1=166096&r2=166097
==============================================================================
--- branches/1.6.0/main/channel.c (original)
+++ branches/1.6.0/main/channel.c Fri Dec 19 17:04:07 2008
@@ -4084,11 +4084,11 @@
 	/* Move data stores over */
 	if (AST_LIST_FIRST(&clone->datastores)) {
 		struct ast_datastore *ds;
-		AST_LIST_APPEND_LIST(&original->datastores, &clone->datastores, entry);
-		AST_LIST_TRAVERSE(&original->datastores, ds, entry) {
+		AST_LIST_TRAVERSE(&clone->datastores, ds, entry) {
 			if (ds->info->chan_fixup)
 				ds->info->chan_fixup(ds->data, clone, original);
 		}
+		AST_LIST_APPEND_LIST(&original->datastores, &clone->datastores, entry);
 	}
 
 	clone_variables(original, clone);




More information about the asterisk-commits mailing list