[Freeswitch-svn] [commit] r5318 - in freeswitch/trunk: build src src/include src/include/private src/mod/applications/mod_soundtouch
Freeswitch SVN
anthm at freeswitch.org
Tue Jun 12 23:09:53 EDT 2007
Author: anthm
Date: Tue Jun 12 23:09:53 2007
New Revision: 5318
Modified:
freeswitch/trunk/build/modules.conf.in
freeswitch/trunk/src/include/private/switch_core_pvt.h
freeswitch/trunk/src/include/switch_core.h
freeswitch/trunk/src/include/switch_types.h
freeswitch/trunk/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp
freeswitch/trunk/src/switch_core_io.c
freeswitch/trunk/src/switch_core_media_bug.c
Log:
update
Modified: freeswitch/trunk/build/modules.conf.in
==============================================================================
--- freeswitch/trunk/build/modules.conf.in (original)
+++ freeswitch/trunk/build/modules.conf.in Tue Jun 12 23:09:53 2007
@@ -8,6 +8,7 @@
applications/mod_enum
#applications/mod_ivrtest
#applications/mod_park
+#applications/mod_soundtouch
applications/mod_playback
#applications/mod_rss
#applications/mod_skel
Modified: freeswitch/trunk/src/include/private/switch_core_pvt.h
==============================================================================
--- freeswitch/trunk/src/include/private/switch_core_pvt.h (original)
+++ freeswitch/trunk/src/include/private/switch_core_pvt.h Tue Jun 12 23:09:53 2007
@@ -127,8 +127,10 @@
struct switch_media_bug {
switch_buffer_t *raw_write_buffer;
switch_buffer_t *raw_read_buffer;
- switch_frame_t *replace_frame_in;
- switch_frame_t *replace_frame_out;
+ switch_frame_t *read_replace_frame_in;
+ switch_frame_t *read_replace_frame_out;
+ switch_frame_t *write_replace_frame_in;
+ switch_frame_t *write_replace_frame_out;
switch_media_bug_callback_t callback;
switch_mutex_t *read_mutex;
switch_mutex_t *write_mutex;
Modified: freeswitch/trunk/src/include/switch_core.h
==============================================================================
--- freeswitch/trunk/src/include/switch_core.h (original)
+++ freeswitch/trunk/src/include/switch_core.h Tue Jun 12 23:09:53 2007
@@ -142,14 +142,27 @@
\brief Obtain a replace frame from a media bug
\param bug the bug to get the data from
*/
-SWITCH_DECLARE(switch_frame_t *) switch_core_media_bug_get_replace_frame(switch_media_bug_t *bug);
+SWITCH_DECLARE(switch_frame_t *) switch_core_media_bug_get_write_replace_frame(switch_media_bug_t *bug);
/*!
\brief Set a return replace frame
\param bug the bug to set the frame on
\param frame the frame to set
*/
-SWITCH_DECLARE(void) switch_core_media_bug_set_replace_frame(switch_media_bug_t *bug, switch_frame_t *frame);
+SWITCH_DECLARE(void) switch_core_media_bug_set_write_replace_frame(switch_media_bug_t *bug, switch_frame_t *frame);
+
+/*!
+ \brief Obtain a replace frame from a media bug
+ \param bug the bug to get the data from
+*/
+SWITCH_DECLARE(switch_frame_t *) switch_core_media_bug_get_read_replace_frame(switch_media_bug_t *bug);
+
+/*!
+ \brief Set a return replace frame
+ \param bug the bug to set the frame on
+ \param frame the frame to set
+*/
+SWITCH_DECLARE(void) switch_core_media_bug_set_read_replace_frame(switch_media_bug_t *bug, switch_frame_t *frame);
/*!
\brief Remove a media bug from the session
Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h (original)
+++ freeswitch/trunk/src/include/switch_types.h Tue Jun 12 23:09:53 2007
@@ -196,6 +196,7 @@
SWITCH_ABC_TYPE_READ,
SWITCH_ABC_TYPE_WRITE,
SWITCH_ABC_TYPE_WRITE_REPLACE,
+ SWITCH_ABC_TYPE_READ_REPLACE,
SWITCH_ABC_TYPE_CLOSE
} switch_abc_type_t;
@@ -742,14 +743,16 @@
<pre>
SMBF_READ_STREAM - Include the Read Stream
SMBF_WRITE_STREAM - Include the Write Stream
-SMBF_WRITE_STREAM - Replace the Write Stream
+SMBF_WRITE_REPLACE - Replace the Write Stream
+SMBF_READ_REPLACE - Replace the Read Stream
</pre>
*/
typedef enum {
SMBF_BOTH = 0,
SMBF_READ_STREAM = (1 << 0),
SMBF_WRITE_STREAM = (1 << 1),
- SMBF_WRITE_REPLACE = (1 << 2)
+ SMBF_WRITE_REPLACE = (1 << 2),
+ SMBF_READ_REPLACE = (1 << 3)
} switch_media_bug_flag_t;
/*!
Modified: freeswitch/trunk/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp (original)
+++ freeswitch/trunk/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp Tue Jun 12 23:09:53 2007
@@ -215,7 +215,7 @@
assert(sth != NULL);
assert(sth->st != NULL);
- frame = switch_core_media_bug_get_replace_frame(bug);
+ frame = switch_core_media_bug_get_write_replace_frame(bug);
sth->st->putSamples((SAMPLETYPE *)frame->data, frame->samples);
if (sth->st->numSamples() >= frame->samples * 2) {
@@ -225,7 +225,7 @@
memset(frame->data, 0, frame->datalen);
}
- switch_core_media_bug_set_replace_frame(bug, frame);
+ switch_core_media_bug_set_write_replace_frame(bug, frame);
}
Modified: freeswitch/trunk/src/switch_core_io.c
==============================================================================
--- freeswitch/trunk/src/switch_core_io.c (original)
+++ freeswitch/trunk/src/switch_core_io.c Tue Jun 12 23:09:53 2007
@@ -225,7 +225,7 @@
if (session->bugs) {
switch_media_bug_t *bp, *dp, *last = NULL;
-
+ switch_bool_t ok = SWITCH_TRUE;
switch_thread_rwlock_rdlock(session->bug_rwlock);
for (bp = session->bugs; bp; bp = bp->next) {
if (bp->ready && switch_test_flag(bp, SMBF_READ_STREAM)) {
@@ -233,23 +233,35 @@
switch_buffer_write(bp->raw_read_buffer, read_frame->data, read_frame->datalen);
if (bp->callback) {
if (bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_READ) == SWITCH_FALSE || (bp->stop_time && bp->stop_time >= time(NULL))) {
- bp->ready = 0;
- if (last) {
- last->next = bp->next;
- } else {
- session->bugs = bp->next;
- }
- switch_mutex_unlock(bp->read_mutex);
- dp = bp;
- bp = last;
- switch_core_media_bug_close(&dp);
- if (!bp) {
- break;
- }
- continue;
+ ok = SWITCH_FALSE;
}
}
switch_mutex_unlock(bp->read_mutex);
+ } else if (switch_test_flag(bp, SMBF_READ_REPLACE)) {
+ do_bugs = 0;
+ if (bp->callback) {
+ bp->read_replace_frame_in = read_frame;
+ bp->read_replace_frame_out = NULL;
+ if ((ok = bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_READ_REPLACE)) == SWITCH_TRUE) {
+ read_frame = bp->read_replace_frame_out;
+ }
+ }
+ }
+
+ if (ok == SWITCH_FALSE) {
+ bp->ready = 0;
+ if (last) {
+ last->next = bp->next;
+ } else {
+ session->bugs = bp->next;
+ }
+ dp = bp;
+ bp = last;
+ switch_core_media_bug_close(&dp);
+ if (!bp) {
+ break;
+ }
+ continue;
}
last = bp;
}
@@ -497,10 +509,10 @@
} else if (switch_test_flag(bp, SMBF_WRITE_REPLACE)) {
do_bugs = 0;
if (bp->callback) {
- bp->replace_frame_in = write_frame;
- bp->replace_frame_out = NULL;
+ bp->write_replace_frame_in = write_frame;
+ bp->write_replace_frame_out = NULL;
if ((ok = bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_WRITE_REPLACE)) == SWITCH_TRUE) {
- write_frame = bp->replace_frame_out;
+ write_frame = bp->write_replace_frame_out;
}
}
}
Modified: freeswitch/trunk/src/switch_core_media_bug.c
==============================================================================
--- freeswitch/trunk/src/switch_core_media_bug.c (original)
+++ freeswitch/trunk/src/switch_core_media_bug.c Tue Jun 12 23:09:53 2007
@@ -41,14 +41,24 @@
}
-SWITCH_DECLARE(switch_frame_t *) switch_core_media_bug_get_replace_frame(switch_media_bug_t *bug)
+SWITCH_DECLARE(switch_frame_t *) switch_core_media_bug_get_write_replace_frame(switch_media_bug_t *bug)
{
- return bug->replace_frame_in;
+ return bug->write_replace_frame_in;
}
-SWITCH_DECLARE(void) switch_core_media_bug_set_replace_frame(switch_media_bug_t *bug, switch_frame_t *frame)
+SWITCH_DECLARE(void) switch_core_media_bug_set_write_replace_frame(switch_media_bug_t *bug, switch_frame_t *frame)
{
- bug->replace_frame_out = frame;
+ bug->write_replace_frame_out = frame;
+}
+
+SWITCH_DECLARE(switch_frame_t *) switch_core_media_bug_get_read_replace_frame(switch_media_bug_t *bug)
+{
+ return bug->read_replace_frame_in;
+}
+
+SWITCH_DECLARE(void) switch_core_media_bug_set_read_replace_frame(switch_media_bug_t *bug, switch_frame_t *frame)
+{
+ bug->read_replace_frame_out = frame;
}
SWITCH_DECLARE(void *) switch_core_media_bug_get_user_data(switch_media_bug_t *bug)
@@ -161,6 +171,18 @@
switch_thread_rwlock_unlock(session->bug_rwlock);
}
+ if (flags & SMBF_READ_REPLACE) {
+ switch_thread_rwlock_wrlock(session->bug_rwlock);
+ for (bp = session->bugs; bp; bp = bp->next) {
+ if (switch_test_flag(bp, SMBF_READ_REPLACE)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Only one bug of this type allowed!\n");
+ switch_thread_rwlock_unlock(session->bug_rwlock);
+ return SWITCH_STATUS_GENERR;
+ }
+ }
+ switch_thread_rwlock_unlock(session->bug_rwlock);
+ }
+
if (!(bug = switch_core_session_alloc(session, sizeof(*bug)))) {
return SWITCH_STATUS_MEMERR;
}
More information about the Freeswitch-svn
mailing list