FS-5011 try this rev
This commit is contained in:
parent
cd0dc2c0af
commit
dba6530eb5
|
@ -99,7 +99,8 @@ typedef enum {
|
|||
SSF_WRITE_TRANSCODE = (1 << 6),
|
||||
SSF_READ_CODEC_RESET = (1 << 7),
|
||||
SSF_WRITE_CODEC_RESET = (1 << 8),
|
||||
SSF_DESTROYABLE = (1 << 9)
|
||||
SSF_DESTROYABLE = (1 << 9),
|
||||
SSF_MEDIA_BUG_TAP_ONLY = (1 << 10)
|
||||
} switch_session_flag_t;
|
||||
|
||||
|
||||
|
|
|
@ -111,6 +111,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
|
|||
|
||||
switch_assert(session != NULL);
|
||||
|
||||
tap_only = switch_test_flag(session, SSF_MEDIA_BUG_TAP_ONLY);
|
||||
|
||||
switch_os_yield();
|
||||
|
||||
|
@ -246,14 +247,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
|
|||
goto done;
|
||||
}
|
||||
|
||||
|
||||
if (session->bugs && !((*frame)->flags & SFF_NOT_AUDIO) && !((*frame)->flags & SFF_CNG)) {
|
||||
if (session->bugs && !((*frame)->flags & SFF_CNG) && !((*frame)->flags & SFF_NOT_AUDIO)) {
|
||||
switch_media_bug_t *bp;
|
||||
switch_bool_t ok = SWITCH_TRUE;
|
||||
int prune = 0;
|
||||
|
||||
tap_only = 1;
|
||||
|
||||
switch_thread_rwlock_rdlock(session->bug_rwlock);
|
||||
|
||||
for (bp = session->bugs; bp; bp = bp->next) {
|
||||
|
@ -270,11 +268,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
|
|||
}
|
||||
|
||||
if (bp->ready) {
|
||||
if (!switch_test_flag(bp, SMBF_TAP_NATIVE_READ) && !switch_test_flag(bp, SMBF_TAP_NATIVE_WRITE)) {
|
||||
printf("FUCKER\n\n\n");
|
||||
tap_only = 0;
|
||||
}
|
||||
|
||||
if (switch_test_flag(bp, SMBF_TAP_NATIVE_READ)) {
|
||||
if (bp->callback) {
|
||||
bp->native_read_frame = *frame;
|
||||
|
@ -306,7 +299,65 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
|
|||
do_resample = 1;
|
||||
}
|
||||
|
||||
if (session->bugs && !need_codec) {
|
||||
if (tap_only) {
|
||||
switch_media_bug_t *bp;
|
||||
switch_bool_t ok = SWITCH_TRUE;
|
||||
int prune = 0;
|
||||
|
||||
need_codec = 0;
|
||||
do_resample = 0;
|
||||
do_bugs = 0;
|
||||
|
||||
if (session->bugs && switch_test_flag(*frame, SFF_CNG)) {
|
||||
switch_thread_rwlock_rdlock(session->bug_rwlock);
|
||||
for (bp = session->bugs; bp; bp = bp->next) {
|
||||
if (switch_channel_test_flag(session->channel, CF_PAUSE_BUGS) && !switch_core_media_bug_test_flag(bp, SMBF_NO_PAUSE)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!switch_channel_test_flag(session->channel, CF_ANSWERED) && switch_core_media_bug_test_flag(bp, SMBF_ANSWER_REQ)) {
|
||||
continue;
|
||||
}
|
||||
if (switch_test_flag(bp, SMBF_PRUNE)) {
|
||||
prune++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (bp->ready && (*frame)->codec && (*frame)->codec->implementation && (*frame)->codec->implementation->encoded_bytes_per_packet) {
|
||||
if (switch_test_flag(bp, SMBF_TAP_NATIVE_READ)) {
|
||||
if (bp->callback) {
|
||||
switch_frame_t tmp_frame = {0};
|
||||
unsigned char data[SWITCH_RECOMMENDED_BUFFER_SIZE] = {0};
|
||||
|
||||
tmp_frame.codec = (*frame)->codec;
|
||||
tmp_frame.datalen = (*frame)->codec->implementation->encoded_bytes_per_packet;
|
||||
tmp_frame.samples = (*frame)->codec->implementation->samples_per_packet;
|
||||
tmp_frame.data = data;
|
||||
|
||||
bp->native_read_frame = &tmp_frame;
|
||||
ok = bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_TAP_NATIVE_READ);
|
||||
bp->native_read_frame = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((bp->stop_time && bp->stop_time <= switch_epoch_time_now(NULL)) || ok == SWITCH_FALSE) {
|
||||
switch_set_flag(bp, SMBF_PRUNE);
|
||||
prune++;
|
||||
}
|
||||
}
|
||||
switch_thread_rwlock_unlock(session->bug_rwlock);
|
||||
|
||||
if (prune) {
|
||||
switch_core_media_bug_prune(session);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
goto done;
|
||||
} else if (session->bugs && !need_codec) {
|
||||
do_bugs = 1;
|
||||
need_codec = 1;
|
||||
}
|
||||
|
@ -318,7 +369,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
|
|||
switch_core_session_t *other_session = NULL;
|
||||
if (switch_channel_test_flag(switch_core_session_get_channel(session), CF_BRIDGED) &&
|
||||
switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
|
||||
if (other_session->bugs) {
|
||||
if (other_session->bugs && !switch_test_flag(other_session, SSF_MEDIA_BUG_TAP_ONLY)) {
|
||||
other_session_bugs = 1;
|
||||
}
|
||||
switch_core_session_rwunlock(other_session);
|
||||
|
@ -338,14 +389,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
|
|||
need_codec = 0;
|
||||
}
|
||||
|
||||
if (tap_only) {
|
||||
need_codec = 0;
|
||||
do_resample = 0;
|
||||
do_bugs = 0;
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
||||
if (switch_test_flag(session, SSF_READ_TRANSCODE) && !need_codec && switch_core_codec_ready(session->read_codec)) {
|
||||
switch_core_session_t *other_session;
|
||||
const char *uuid = switch_channel_get_partner_uuid(switch_core_session_get_channel(session));
|
||||
|
@ -365,10 +408,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (status == SWITCH_STATUS_SUCCESS && need_codec) {
|
||||
switch_frame_t *enc_frame, *read_frame = *frame;
|
||||
|
||||
|
@ -690,7 +729,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
|
|||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (perfect || switch_buffer_inuse(session->raw_read_buffer) >= session->read_impl.decoded_bytes_per_packet) {
|
||||
if (perfect) {
|
||||
enc_frame = read_frame;
|
||||
|
@ -986,25 +1025,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
|
|||
need_codec = TRUE;
|
||||
}
|
||||
|
||||
if (session->bugs && !need_codec) {
|
||||
switch_media_bug_t *bp;
|
||||
int tap_only = 1;
|
||||
|
||||
switch_thread_rwlock_rdlock(session->bug_rwlock);
|
||||
for (bp = session->bugs; bp; bp = bp->next) {
|
||||
if (bp->ready) {
|
||||
if (!switch_test_flag(bp, SMBF_TAP_NATIVE_READ) && !switch_test_flag(bp, SMBF_TAP_NATIVE_WRITE)) {
|
||||
tap_only = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
switch_thread_rwlock_unlock(session->bug_rwlock);
|
||||
|
||||
if (!tap_only) {
|
||||
do_bugs = TRUE;
|
||||
need_codec = TRUE;
|
||||
}
|
||||
if (session->bugs && !need_codec && !switch_test_flag(session, SSF_MEDIA_BUG_TAP_ONLY)) {
|
||||
do_bugs = TRUE;
|
||||
need_codec = TRUE;
|
||||
}
|
||||
|
||||
if (frame->codec->implementation->actual_samples_per_second != session->write_impl.actual_samples_per_second) {
|
||||
|
|
|
@ -408,9 +408,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t
|
|||
switch_media_bug_flag_t flags,
|
||||
switch_media_bug_t **new_bug)
|
||||
{
|
||||
switch_media_bug_t *bug; //, *bp;
|
||||
switch_media_bug_t *bug, *bp;
|
||||
switch_size_t bytes;
|
||||
switch_event_t *event;
|
||||
int tap_only = 1;
|
||||
|
||||
const char *p;
|
||||
|
||||
|
@ -514,9 +515,23 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t
|
|||
switch_thread_rwlock_wrlock(session->bug_rwlock);
|
||||
bug->next = session->bugs;
|
||||
session->bugs = bug;
|
||||
|
||||
for(bp = session->bugs; bp; bp = bp->next) {
|
||||
if (bp->ready && !switch_test_flag(bp, SMBF_TAP_NATIVE_READ) && !switch_test_flag(bp, SMBF_TAP_NATIVE_WRITE)) {
|
||||
tap_only = 0;
|
||||
}
|
||||
}
|
||||
|
||||
switch_thread_rwlock_unlock(session->bug_rwlock);
|
||||
*new_bug = bug;
|
||||
|
||||
|
||||
if (tap_only) {
|
||||
switch_set_flag(session, SSF_MEDIA_BUG_TAP_ONLY);
|
||||
} else {
|
||||
switch_clear_flag(session, SSF_MEDIA_BUG_TAP_ONLY);
|
||||
}
|
||||
|
||||
if (switch_event_create(&event, SWITCH_EVENT_MEDIA_BUG_START) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Media-Bug-Function", "%s", bug->function);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Media-Bug-Target", "%s", bug->target);
|
||||
|
@ -738,9 +753,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_close(switch_media_bug_t *
|
|||
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_media_bug_remove(switch_core_session_t *session, switch_media_bug_t **bug)
|
||||
{
|
||||
switch_media_bug_t *bp = NULL, *last = NULL;
|
||||
switch_media_bug_t *bp = NULL, *bp2 = NULL, *last = NULL;
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
|
||||
int tap_only = 0;
|
||||
|
||||
if (switch_core_media_bug_test_flag(*bug, SMBF_LOCK)) {
|
||||
return status;
|
||||
}
|
||||
|
@ -765,6 +781,20 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_remove(switch_core_session
|
|||
switch_core_codec_destroy(&session->bug_codec);
|
||||
}
|
||||
|
||||
if (session->bugs) {
|
||||
for(bp2 = session->bugs; bp2; bp2 = bp2->next) {
|
||||
if (bp2->ready && !switch_test_flag(bp2, SMBF_TAP_NATIVE_READ) && !switch_test_flag(bp2, SMBF_TAP_NATIVE_WRITE)) {
|
||||
tap_only = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tap_only) {
|
||||
switch_set_flag(session, SSF_MEDIA_BUG_TAP_ONLY);
|
||||
} else {
|
||||
switch_clear_flag(session, SSF_MEDIA_BUG_TAP_ONLY);
|
||||
}
|
||||
|
||||
switch_thread_rwlock_unlock(session->bug_rwlock);
|
||||
|
||||
if (bp) {
|
||||
|
|
Loading…
Reference in New Issue