sniffing glue

This commit is contained in:
Anthony Minessale 2013-06-20 22:25:25 -05:00
parent 5cb4cd9d9c
commit 1e9ab89bbb
1 changed files with 33 additions and 32 deletions

View File

@ -1089,6 +1089,9 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, s
break;
case SWITCH_ABC_TYPE_TAP_NATIVE_READ:
{
switch_time_t now = switch_micro_time_now();
switch_time_t diff;
rh->rready = 1;
nframe = switch_core_media_bug_get_native_read_frame(bug);
@ -1100,22 +1103,20 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, s
switch_core_gen_encoded_silence(fill_data, &rh->read_impl, len);
switch_core_file_write(&rh->out_fh, fill_data, &fill_len);
} else {
switch_time_t now = switch_micro_time_now();
switch_time_t diff;
}
if (rh->last_read_time && rh->last_read_time < now) {
diff = ((now - rh->last_read_time) + 3000 ) / rh->read_impl.microseconds_per_packet;
if (rh->last_read_time && rh->last_read_time < now) {
diff = ((now - rh->last_read_time) + 3000 ) / rh->read_impl.microseconds_per_packet;
if (diff > 1) {
unsigned char fill_data[SWITCH_RECOMMENDED_BUFFER_SIZE] = {0};
switch_core_gen_encoded_silence(fill_data, &rh->read_impl, len);
if (diff > 1) {
unsigned char fill_data[SWITCH_RECOMMENDED_BUFFER_SIZE] = {0};
switch_core_gen_encoded_silence(fill_data, &rh->read_impl, len);
while(diff > 1) {
switch_size_t fill_len = len;
switch_core_file_write(&rh->in_fh, fill_data, &fill_len);
diff--;
}
while(diff > 1) {
switch_size_t fill_len = len;
switch_core_file_write(&rh->in_fh, fill_data, &fill_len);
diff--;
}
}
}
@ -1127,6 +1128,8 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, s
break;
case SWITCH_ABC_TYPE_TAP_NATIVE_WRITE:
{
switch_time_t now = switch_micro_time_now();
switch_time_t diff;
rh->wready = 1;
if (!rh->rready) {
@ -1134,30 +1137,28 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, s
switch_size_t fill_len = len;
switch_core_gen_encoded_silence(fill_data, &rh->read_impl, len);
switch_core_file_write(&rh->in_fh, fill_data, &fill_len);
} else {
switch_time_t now = switch_micro_time_now();
switch_time_t diff;
nframe = switch_core_media_bug_get_native_write_frame(bug);
len = nframe->datalen;
}
if (rh->last_write_time && rh->last_write_time < now) {
diff = ((now - rh->last_write_time) + 3000 ) / rh->read_impl.microseconds_per_packet;
nframe = switch_core_media_bug_get_native_write_frame(bug);
len = nframe->datalen;
if (rh->last_write_time && rh->last_write_time < now) {
diff = ((now - rh->last_write_time) + 3000 ) / rh->read_impl.microseconds_per_packet;
if (diff > 1) {
unsigned char fill_data[SWITCH_RECOMMENDED_BUFFER_SIZE] = {0};
switch_core_gen_encoded_silence(fill_data, &rh->read_impl, len);
if (diff > 1) {
unsigned char fill_data[SWITCH_RECOMMENDED_BUFFER_SIZE] = {0};
switch_core_gen_encoded_silence(fill_data, &rh->read_impl, len);
while(diff > 1) {
switch_size_t fill_len = len;
switch_core_file_write(&rh->out_fh, fill_data, &fill_len);
diff--;
}
while(diff > 1) {
switch_size_t fill_len = len;
switch_core_file_write(&rh->out_fh, fill_data, &fill_len);
diff--;
}
}
}
switch_core_file_write(&rh->out_fh, mask ? null_data : nframe->data, &len);
rh->last_write_time = now;