diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 79f6d92989..1aba54b683 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -1975,7 +1975,9 @@ typedef enum { SMBF_READ_VIDEO_PATCH = (1 << 24), SMBF_READ_TEXT_STREAM = (1 << 25), SMBF_FIRST = (1 << 26), - SMBF_PAUSE = (1 << 27) + SMBF_PAUSE = (1 << 27), + SMBF_STEREO_NO_DOWN_MIX = (1 << 28), + SMBF_REAL_STEREO = (1 << 29) } 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 191ab24393..7463423f1c 100644 --- a/src/switch_core_media_bug.c +++ b/src/switch_core_media_bug.c @@ -381,6 +381,10 @@ 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_NO_DOWN_MIX) && switch_test_flag(bug, SMBF_REAL_STEREO)) { + switch_mux_channels(dp, wlen, read_impl.number_of_channels, 1); + switch_mux_channels(fp, rlen, read_impl.number_of_channels, 1); + } if (switch_test_flag(bug, SMBF_STEREO_SWAP)) { left = dp; /* write stream */ left_len = wlen; @@ -406,6 +410,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *b } memcpy(frame->data, bug->tmp, bytes * 2); } else { + if (switch_test_flag(bug, SMBF_REAL_STEREO)) { + switch_mux_channels(dp, wlen, read_impl.number_of_channels, 1); + switch_mux_channels(fp, rlen, read_impl.number_of_channels, 1); + } for (x = 0; x < blen; x++) { int32_t w = 0, r = 0, z = 0; @@ -435,9 +443,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *b frame->rate = read_impl.actual_samples_per_second; frame->codec = NULL; - if (switch_test_flag(bug, SMBF_STEREO)) { + if (switch_test_flag(bug, SMBF_STEREO) && !switch_test_flag(bug, SMBF_REAL_STEREO)) { frame->datalen *= 2; frame->channels = 2; + } else if (!switch_test_flag(bug, SMBF_STEREO)) { + frame->channels = 1; } else { frame->channels = read_impl.number_of_channels; } diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index 42dade7866..eee6003a21 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -3127,6 +3127,20 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_session_event(switch_core_sess flags |= SMBF_STEREO_SWAP; channels = 2; } + } else if (channels == 2) { + flags |= SMBF_REAL_STEREO; + if (recording_var_true(channel, vars, "RECORD_STEREO")) { + flags |= SMBF_STEREO; + flags &= ~SMBF_STEREO_SWAP; + } + + if (recording_var_true(channel, vars, "RECORD_STEREO_SWAP")) { + flags |= SMBF_STEREO; + flags |= SMBF_STEREO_SWAP; + } + if (!(flags & SMBF_STEREO)) { + channels = 1; + } } if (recording_var_true(channel, vars, "RECORD_ANSWER_REQ")) { @@ -3137,6 +3151,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_session_event(switch_core_sess flags |= SMBF_BRIDGE_REQ; } + if (recording_var_true(channel, vars, "RECORD_STEREO_NO_DOWN_MIX")) { + flags |= SMBF_STEREO_NO_DOWN_MIX; + } + if (recording_var_true(channel, vars, "RECORD_APPEND")) { file_flags |= SWITCH_FILE_WRITE_APPEND; }