set the variable RECORD_STEREO=true to make record_session create stereo files with each leg in it's own channel, note you cannot play these files with freewitch with playback because we don't support stereo files

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5772 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale
2007-10-01 16:34:28 +00:00
parent e7583f98b5
commit 2ffb61f283
3 changed files with 46 additions and 19 deletions

View File

@@ -119,32 +119,49 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *b
bytes = (datalen > frame->datalen) ? datalen : frame->datalen;
if (bytes) {
int16_t tmp[960], *tp = tmp;
dp = (int16_t *) data;
fp = (int16_t *) frame->data;
rlen = frame->datalen / 2;
wlen = datalen / 2;
blen = bytes / 2;
for (x = 0; x < blen; x++) {
int32_t z = 0;
if (switch_test_flag(bug, SMBF_STEREO)) {
for (x = 0; x < blen; x++) {
if (x < rlen) {
*(tp++) = *(fp + x);
} else {
*(tp++) = 0;
}
if (x < wlen) {
*(tp++) = *(dp + x);
} else {
*(tp++) = 0;
}
}
memcpy(frame->data, tmp, bytes * 2);
} else {
for (x = 0; x < blen; x++) {
int32_t z = 0;
if (x < rlen) {
z += (int32_t) *(fp + x);
if (x < rlen) {
z += (int32_t) *(fp + x);
}
if (x < wlen) {
z += (int32_t) *(dp + x);
}
switch_normalize_to_16bit(z);
*(fp + x) = (int16_t) z;
}
if (x < wlen) {
z += (int32_t) *(dp + x);
}
switch_normalize_to_16bit(z);
*(fp + x) = (int16_t) z;
}
frame->datalen = bytes;
frame->samples = bytes / sizeof(int16_t);
frame->rate = read_codec->implementation->samples_per_second;
return SWITCH_STATUS_SUCCESS;
}