Merged revisions 31520 via svnmerge from
[asterisk/asterisk.git] / channel.c
index 545e002..65dcf2f 100644 (file)
--- a/channel.c
+++ b/channel.c
@@ -2829,6 +2829,14 @@ int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clo
 {
        int res = -1;
 
+       /* each of these channels may be sitting behind a channel proxy (i.e. chan_agent)
+          and if so, we don't really want to masquerade it, but its proxy */
+       if (original->_bridge && (original->_bridge != ast_bridged_channel(original)))
+               original = original->_bridge;
+
+       if (clone->_bridge && (clone->_bridge != ast_bridged_channel(clone)))
+               clone = clone->_bridge;
+
        if (original == clone) {
                ast_log(LOG_WARNING, "Can't masquerade channel '%s' into itself!\n", original->name);
                return -1;