diff options
author | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-12-19 23:04:07 +0000 |
---|---|---|
committer | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-12-19 23:04:07 +0000 |
commit | f616aed3d7d63dcfa37f669e63f51d3853d90d4a (patch) | |
tree | 3b53ee1c38ccff9501d47d0f389bd4abfddf4246 /main/audiohook.c | |
parent | 811d9372de1ef4443c3372ec8cf9aeb6951470ec (diff) |
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...
........
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@166097 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/audiohook.c')
-rw-r--r-- | main/audiohook.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/main/audiohook.c b/main/audiohook.c index ce0039bdd..08d762e18 100644 --- a/main/audiohook.c +++ b/main/audiohook.c @@ -412,6 +412,11 @@ int ast_audiohook_detach_list(struct ast_audiohook_list *audiohook_list) 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; @@ -434,6 +439,25 @@ static struct ast_audiohook *find_audiohook_by_source(struct ast_audiohook_list 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 * \param chan Channel to detach from * \param source Name of source to detach @@ -461,6 +485,42 @@ int ast_audiohook_detach_source(struct ast_channel *chan, const char *source) 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 * \param chan Channel that the list is coming off of * \param audiohook_list List of audiohooks |