diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 2ab4c07984..62af4f9aaf 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -1402,6 +1402,9 @@ SMBF_READ_REPLACE - Replace the Read Stream SMBF_STEREO - Record in stereo SMBF_ANSWER_RECORD_REQ - Don't record until the channel is answered SMBF_THREAD_LOCK - Only let the same thread who created the bug remove it. +SMBF_PRUNE - +SMBF_NO_PAUSE - +SMBF_STEREO_SWAP - Record in stereo: Write Stream - left channel, Read Stream - right channel */ typedef enum { @@ -1415,7 +1418,8 @@ typedef enum { SMBF_ANSWER_REQ = (1 << 6), SMBF_THREAD_LOCK = (1 << 7), SMBF_PRUNE = (1 << 8), - SMBF_NO_PAUSE = (1 << 9) + SMBF_NO_PAUSE = (1 << 9), + SMBF_STEREO_SWAP = (1 << 10) } switch_media_bug_flag_enum_t; typedef uint32_t switch_media_bug_flag_t; diff --git a/src/switch_core_media_bug.c b/src/switch_core_media_bug.c index 2c33ca2707..7e75ae9e96 100644 --- a/src/switch_core_media_bug.c +++ b/src/switch_core_media_bug.c @@ -207,14 +207,27 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *b } if (switch_test_flag(bug, SMBF_STEREO)) { + int16_t *left, *right; + size_t left_len, right_len; + if (switch_test_flag(bug, SMBF_STEREO_SWAP)) { + left = dp; /* write stream */ + left_len = wlen; + right = fp; /* read stream */ + right_len = rlen; + } else { + left = fp; /* read stream */ + left_len = rlen; + right = dp; /* write stream */ + right_len = wlen; + } for (x = 0; x < blen; x++) { - if (x < rlen) { - *(tp++) = *(fp + x); + if (x < left_len) { + *(tp++) = *(left + x); } else { *(tp++) = 0; } - if (x < wlen) { - *(tp++) = *(dp + x); + if (x < right_len) { + *(tp++) = *(right + x); } else { *(tp++) = 0; } diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index 0ecc89c166..ec3d1fa4ee 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -1589,6 +1589,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t if ((p = switch_channel_get_variable(channel, "RECORD_STEREO")) && switch_true(p)) { flags |= SMBF_STEREO; + flags &= ~SMBF_STEREO_SWAP; + channels = 2; + } + + if ((p = switch_channel_get_variable(channel, "RECORD_STEREO_SWAP")) && switch_true(p)) { + flags |= SMBF_STEREO; + flags |= SMBF_STEREO_SWAP; channels = 2; }