mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-23 19:45:35 +00:00
update
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5318 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
a035ec592c
commit
f1bede824c
@ -8,6 +8,7 @@ applications/mod_echo
|
|||||||
applications/mod_enum
|
applications/mod_enum
|
||||||
#applications/mod_ivrtest
|
#applications/mod_ivrtest
|
||||||
#applications/mod_park
|
#applications/mod_park
|
||||||
|
#applications/mod_soundtouch
|
||||||
applications/mod_playback
|
applications/mod_playback
|
||||||
#applications/mod_rss
|
#applications/mod_rss
|
||||||
#applications/mod_skel
|
#applications/mod_skel
|
||||||
|
@ -127,8 +127,10 @@ struct switch_core_session {
|
|||||||
struct switch_media_bug {
|
struct switch_media_bug {
|
||||||
switch_buffer_t *raw_write_buffer;
|
switch_buffer_t *raw_write_buffer;
|
||||||
switch_buffer_t *raw_read_buffer;
|
switch_buffer_t *raw_read_buffer;
|
||||||
switch_frame_t *replace_frame_in;
|
switch_frame_t *read_replace_frame_in;
|
||||||
switch_frame_t *replace_frame_out;
|
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_media_bug_callback_t callback;
|
||||||
switch_mutex_t *read_mutex;
|
switch_mutex_t *read_mutex;
|
||||||
switch_mutex_t *write_mutex;
|
switch_mutex_t *write_mutex;
|
||||||
|
@ -142,14 +142,27 @@ SWITCH_DECLARE(void *) switch_core_media_bug_get_user_data(switch_media_bug_t *b
|
|||||||
\brief Obtain a replace frame from a media bug
|
\brief Obtain a replace frame from a media bug
|
||||||
\param bug the bug to get the data from
|
\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
|
\brief Set a return replace frame
|
||||||
\param bug the bug to set the frame on
|
\param bug the bug to set the frame on
|
||||||
\param frame the frame to set
|
\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
|
\brief Remove a media bug from the session
|
||||||
|
@ -196,6 +196,7 @@ typedef enum {
|
|||||||
SWITCH_ABC_TYPE_READ,
|
SWITCH_ABC_TYPE_READ,
|
||||||
SWITCH_ABC_TYPE_WRITE,
|
SWITCH_ABC_TYPE_WRITE,
|
||||||
SWITCH_ABC_TYPE_WRITE_REPLACE,
|
SWITCH_ABC_TYPE_WRITE_REPLACE,
|
||||||
|
SWITCH_ABC_TYPE_READ_REPLACE,
|
||||||
SWITCH_ABC_TYPE_CLOSE
|
SWITCH_ABC_TYPE_CLOSE
|
||||||
} switch_abc_type_t;
|
} switch_abc_type_t;
|
||||||
|
|
||||||
@ -742,14 +743,16 @@ typedef enum {
|
|||||||
<pre>
|
<pre>
|
||||||
SMBF_READ_STREAM - Include the Read Stream
|
SMBF_READ_STREAM - Include the Read Stream
|
||||||
SMBF_WRITE_STREAM - Include the Write 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>
|
</pre>
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
SMBF_BOTH = 0,
|
SMBF_BOTH = 0,
|
||||||
SMBF_READ_STREAM = (1 << 0),
|
SMBF_READ_STREAM = (1 << 0),
|
||||||
SMBF_WRITE_STREAM = (1 << 1),
|
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;
|
} switch_media_bug_flag_t;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -215,7 +215,7 @@ static switch_bool_t soundtouch_callback(switch_media_bug_t *bug, void *user_dat
|
|||||||
assert(sth != NULL);
|
assert(sth != NULL);
|
||||||
assert(sth->st != 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);
|
sth->st->putSamples((SAMPLETYPE *)frame->data, frame->samples);
|
||||||
|
|
||||||
if (sth->st->numSamples() >= frame->samples * 2) {
|
if (sth->st->numSamples() >= frame->samples * 2) {
|
||||||
@ -225,7 +225,7 @@ static switch_bool_t soundtouch_callback(switch_media_bug_t *bug, void *user_dat
|
|||||||
memset(frame->data, 0, frame->datalen);
|
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);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
|
|||||||
|
|
||||||
if (session->bugs) {
|
if (session->bugs) {
|
||||||
switch_media_bug_t *bp, *dp, *last = NULL;
|
switch_media_bug_t *bp, *dp, *last = NULL;
|
||||||
|
switch_bool_t ok = SWITCH_TRUE;
|
||||||
switch_thread_rwlock_rdlock(session->bug_rwlock);
|
switch_thread_rwlock_rdlock(session->bug_rwlock);
|
||||||
for (bp = session->bugs; bp; bp = bp->next) {
|
for (bp = session->bugs; bp; bp = bp->next) {
|
||||||
if (bp->ready && switch_test_flag(bp, SMBF_READ_STREAM)) {
|
if (bp->ready && switch_test_flag(bp, SMBF_READ_STREAM)) {
|
||||||
@ -233,23 +233,35 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
|
|||||||
switch_buffer_write(bp->raw_read_buffer, read_frame->data, read_frame->datalen);
|
switch_buffer_write(bp->raw_read_buffer, read_frame->data, read_frame->datalen);
|
||||||
if (bp->callback) {
|
if (bp->callback) {
|
||||||
if (bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_READ) == SWITCH_FALSE || (bp->stop_time && bp->stop_time >= time(NULL))) {
|
if (bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_READ) == SWITCH_FALSE || (bp->stop_time && bp->stop_time >= time(NULL))) {
|
||||||
bp->ready = 0;
|
ok = SWITCH_FALSE;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch_mutex_unlock(bp->read_mutex);
|
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;
|
last = bp;
|
||||||
}
|
}
|
||||||
@ -497,10 +509,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
|
|||||||
} else if (switch_test_flag(bp, SMBF_WRITE_REPLACE)) {
|
} else if (switch_test_flag(bp, SMBF_WRITE_REPLACE)) {
|
||||||
do_bugs = 0;
|
do_bugs = 0;
|
||||||
if (bp->callback) {
|
if (bp->callback) {
|
||||||
bp->replace_frame_in = write_frame;
|
bp->write_replace_frame_in = write_frame;
|
||||||
bp->replace_frame_out = NULL;
|
bp->write_replace_frame_out = NULL;
|
||||||
if ((ok = bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_WRITE_REPLACE)) == SWITCH_TRUE) {
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,14 +41,24 @@ static void switch_core_media_bug_destroy(switch_media_bug_t *bug)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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)
|
SWITCH_DECLARE(void *) switch_core_media_bug_get_user_data(switch_media_bug_t *bug)
|
||||||
@ -161,6 +171,18 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t
|
|||||||
switch_thread_rwlock_unlock(session->bug_rwlock);
|
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)))) {
|
if (!(bug = switch_core_session_alloc(session, sizeof(*bug)))) {
|
||||||
return SWITCH_STATUS_MEMERR;
|
return SWITCH_STATUS_MEMERR;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user