diff options
author | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-12-19 22:26:16 +0000 |
---|---|---|
committer | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-12-19 22:26:16 +0000 |
commit | 1a28ef410a8ae28bbcc329353b0762966d85fe41 (patch) | |
tree | 7755ccd419fe98626d8ed1a778a114282864ff63 /main | |
parent | e679eac279a16050dc616c77b44c3d8ec3629f03 (diff) |
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/
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@166092 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r-- | main/audiohook.c | 24 | ||||
-rw-r--r-- | main/channel.c | 4 |
2 files changed, 26 insertions, 2 deletions
diff --git a/main/audiohook.c b/main/audiohook.c index e493cfc71..b67625ff0 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 diff --git a/main/channel.c b/main/channel.c index 37535998b..ea1305411 100644 --- a/main/channel.c +++ b/main/channel.c @@ -4086,11 +4086,11 @@ int ast_do_masquerade(struct ast_channel *original) /* Move data stores over */ if (AST_LIST_FIRST(&clonechan->datastores)) { struct ast_datastore *ds; - AST_LIST_APPEND_LIST(&original->datastores, &clonechan->datastores, entry); - AST_LIST_TRAVERSE(&original->datastores, ds, entry) { + AST_LIST_TRAVERSE(&clonechan->datastores, ds, entry) { if (ds->info->chan_fixup) ds->info->chan_fixup(ds->data, clonechan, original); } + AST_LIST_APPEND_LIST(&original->datastores, &clonechan->datastores, entry); } clone_variables(original, clonechan); |