rtp adjustments when using jitterbuffer
This commit is contained in:
parent
a3b01c195b
commit
e80a40cf68
|
@ -100,7 +100,9 @@ struct stfu_instance {
|
|||
uint32_t sync_out;
|
||||
uint32_t sync_in;
|
||||
|
||||
|
||||
int32_t ts_offset;
|
||||
int32_t ts_drift;
|
||||
|
||||
int32_t ts_diff;
|
||||
int32_t last_ts_diff;
|
||||
int32_t same_ts;
|
||||
|
@ -126,6 +128,11 @@ static void default_logger(const char *file, const char *func, int line, int lev
|
|||
|
||||
stfu_logger_t stfu_log = null_logger;
|
||||
|
||||
int32_t stfu_n_get_drift(stfu_instance_t *i)
|
||||
{
|
||||
return i->ts_drift;
|
||||
}
|
||||
|
||||
void stfu_global_set_logger(stfu_logger_t logger)
|
||||
{
|
||||
if (logger) {
|
||||
|
@ -376,7 +383,7 @@ static void stfu_n_swap(stfu_instance_t *i)
|
|||
i->out_queue->last_jitter = 0;
|
||||
}
|
||||
|
||||
stfu_status_t stfu_n_add_data(stfu_instance_t *i, uint32_t ts, uint32_t pt, void *data, size_t datalen, int last)
|
||||
stfu_status_t stfu_n_add_data(stfu_instance_t *i, uint32_t ts, uint32_t pt, void *data, size_t datalen, uint32_t timer_ts, int last)
|
||||
{
|
||||
uint32_t index = 0;
|
||||
stfu_frame_t *frame;
|
||||
|
@ -402,6 +409,12 @@ stfu_status_t stfu_n_add_data(stfu_instance_t *i, uint32_t ts, uint32_t pt, void
|
|||
}
|
||||
}
|
||||
|
||||
if (timer_ts && ts && !i->ts_offset) {
|
||||
i->ts_offset = timer_ts - ts;
|
||||
}
|
||||
|
||||
i->ts_drift = ts + (i->ts_offset - timer_ts);
|
||||
|
||||
if (i->sync_in) {
|
||||
good_ts = 1;
|
||||
i->sync_in = 0;
|
||||
|
@ -480,12 +493,12 @@ stfu_status_t stfu_n_add_data(stfu_instance_t *i, uint32_t ts, uint32_t pt, void
|
|||
|
||||
|
||||
if (stfu_log != null_logger && i->debug) {
|
||||
stfu_log(STFU_LOG_EMERG, "%s %u i=%u/%u - g:%u/%u c:%u/%u b:%u - %u:%u - %u %d %u %u %d %d\n", i->name,
|
||||
i->qlen, i->period_packet_in_count, i->period_time, i->consecutive_good_count,
|
||||
i->decrement_time, i->period_clean_count, i->decrement_time, i->consecutive_bad_count,
|
||||
ts, ts / i->samples_per_packet,
|
||||
i->period_missing_count, i->period_need_range_avg,
|
||||
i->last_wr_ts, ts, i->diff, i->diff_total / least1(i->period_packet_in_count));
|
||||
stfu_log(STFU_LOG_EMERG, "I: %s %u i=%u/%u - g:%u/%u c:%u/%u b:%u - %u:%u - %u %d %u %u %d %d %d\n", i->name,
|
||||
i->qlen, i->period_packet_in_count, i->period_time, i->consecutive_good_count,
|
||||
i->decrement_time, i->period_clean_count, i->decrement_time, i->consecutive_bad_count,
|
||||
ts, ts / i->samples_per_packet,
|
||||
i->period_missing_count, i->period_need_range_avg,
|
||||
i->last_wr_ts, ts, i->diff, i->diff_total / least1(i->period_packet_in_count), i->ts_drift);
|
||||
}
|
||||
|
||||
if (last || i->in_queue->array_len == i->in_queue->array_size) {
|
||||
|
|
|
@ -181,15 +181,16 @@ void stfu_n_report(stfu_instance_t *i, stfu_report_t *r);
|
|||
void stfu_n_destroy(stfu_instance_t **i);
|
||||
stfu_instance_t *stfu_n_init(uint32_t qlen, uint32_t max_qlen, uint32_t samples_per_packet, uint32_t samples_per_second);
|
||||
stfu_status_t stfu_n_resize(stfu_instance_t *i, uint32_t qlen);
|
||||
stfu_status_t stfu_n_add_data(stfu_instance_t *i, uint32_t ts, uint32_t pt, void *data, size_t datalen, int last);
|
||||
stfu_status_t stfu_n_add_data(stfu_instance_t *i, uint32_t ts, uint32_t pt, void *data, size_t datalen, uint32_t timer_ts, int last);
|
||||
stfu_frame_t *stfu_n_read_a_frame(stfu_instance_t *i);
|
||||
void stfu_n_reset(stfu_instance_t *i);
|
||||
stfu_status_t stfu_n_sync(stfu_instance_t *i, uint32_t packets);
|
||||
void stfu_n_call_me(stfu_instance_t *i, stfu_n_call_me_t callback, void *udata);
|
||||
void stfu_n_debug(stfu_instance_t *i, const char *name);
|
||||
int32_t stfu_n_get_drift(stfu_instance_t *i);
|
||||
|
||||
#define stfu_im_done(i) stfu_n_add_data(i, 0, NULL, 0, 1)
|
||||
#define stfu_n_eat(i,t,p,d,l) stfu_n_add_data(i, t, p, d, l, 0)
|
||||
#define stfu_im_done(i) stfu_n_add_data(i, 0, NULL, 0, 0, 1)
|
||||
#define stfu_n_eat(i,t,p,d,l,tt) stfu_n_add_data(i, t, p, d, l, tt, 0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue