[Freeswitch-svn] [commit] r7438 - freeswitch/trunk/src/mod/applications/mod_conference
Freeswitch SVN
anthm at freeswitch.org
Wed Jan 30 12:23:36 EST 2008
Author: anthm
Date: Wed Jan 30 12:23:36 2008
New Revision: 7438
Modified:
freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
Log:
zag
Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Wed Jan 30 12:23:36 2008
@@ -133,7 +133,8 @@
MFLAG_INTREE = (1 << 6),
MFLAG_WASTE_BANDWIDTH = (1 << 7),
MFLAG_FLUSH_BUFFER = (1 << 8),
- MFLAG_ENDCONF = (1 << 9)
+ MFLAG_ENDCONF = (1 << 9),
+ MFLAG_HAS_AUDIO = (1 << 10)
} member_flag_t;
typedef enum {
@@ -222,6 +223,8 @@
uint8_t min;
switch_speech_handle_t lsh;
switch_speech_handle_t *sh;
+ switch_byte_t *not_talking_buf;
+ uint32_t not_talking_buf_len;
} conference_obj_t;
/* Relationship with another member */
@@ -715,12 +718,12 @@
conference_member_t *imember, *omember;
uint32_t samples = switch_bytes_per_frame(conference->rate, conference->interval);
uint32_t bytes = samples * 2;
- uint8_t ready = 0;
+ uint8_t ready = 0, total = 0;
switch_timer_t timer = { 0 };
switch_event_t *event;
uint8_t *file_frame;
uint8_t *async_file_frame;
-
+
file_frame = switch_core_alloc(conference->pool, SWITCH_RECOMMENDED_BUFFER_SIZE);
async_file_frame = switch_core_alloc(conference->pool, SWITCH_RECOMMENDED_BUFFER_SIZE);
@@ -753,10 +756,11 @@
break;
}
switch_mutex_lock(conference->mutex);
- ready = 0;
+ ready = total = 0;
/* Read one frame of audio from each member channel and save it for redistribution */
for (imember = conference->members; imember; imember = imember->next) {
+ total++;
if (imember->buflen) {
memset(imember->frame, 255, imember->buflen);
} else {
@@ -764,11 +768,12 @@
imember->mux_frame = switch_core_alloc(imember->pool, bytes);
imember->buflen = bytes;
}
-
+ switch_clear_flag(imember, MFLAG_HAS_AUDIO);
switch_mutex_lock(imember->audio_in_mutex);
/* if there is audio in the resample buffer it takes precedence over the other data */
if (imember->mux_resampler && switch_buffer_inuse(imember->resample_buffer) >= bytes) {
imember->read = (uint32_t) switch_buffer_read(imember->resample_buffer, imember->frame, bytes);
+ switch_set_flag(imember, MFLAG_HAS_AUDIO);
ready++;
} else if ((imember->read = (uint32_t) switch_buffer_read(imember->audio_buffer, imember->frame, imember->buflen))) {
/* If the caller is not at the right sample rate resample him to suit and buffer accordingly */
@@ -791,9 +796,11 @@
switch_buffer_write(imember->resample_buffer, out, len);
if (switch_buffer_inuse(imember->resample_buffer) >= bytes) {
imember->read = (uint32_t) switch_buffer_read(imember->resample_buffer, imember->frame, bytes);
+ switch_set_flag(imember, MFLAG_HAS_AUDIO);
ready++;
}
} else {
+ switch_set_flag(imember, MFLAG_HAS_AUDIO);
ready++; /* Tally of how many channels had data */
}
}
@@ -861,6 +868,7 @@
}
if (ready) {
+ int nt = 0;
/* Build a muxed frame for every member that contains the mixed audio of everyone else */
for (omember = conference->members; omember; omember = omember->next) {
omember->len = bytes;
@@ -901,6 +909,12 @@
}
}
}
+
+ if (nt && conference->not_talking_buf_len && !switch_test_flag(omember, MFLAG_HAS_AUDIO)) {
+ memcpy(omember->mux_frame, conference->not_talking_buf, conference->not_talking_buf_len);
+ continue;
+ }
+
if (imember->read > imember->len) {
imember->len = imember->read;
@@ -915,8 +929,15 @@
switch_normalize_to_16bit(z);
muxed[x] = (int16_t) z;
}
-
- ready++;
+
+ if (total - ready > 1) {
+ conference->not_talking_buf_len = imember->read;
+ if (!conference->not_talking_buf) {
+ conference->not_talking_buf = switch_core_alloc(conference->pool, imember->read + 128);
+ }
+ memcpy(conference->not_talking_buf, muxed, conference->not_talking_buf_len);
+ nt++;
+ }
}
}
}
More information about the Freeswitch-svn
mailing list