|
|
|
|
@ -29,6 +29,34 @@ static void push(call_jitter* j, int id, int64_t received_ms = -1) {
|
|
|
|
|
call_jitter_push(j, (const uint8_t*)&id, sizeof(id), (uint32_t)(id * 20), received_ms < 0 ? id * 20 : received_ms, nullptr); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void test_network_recovery() { |
|
|
|
|
for (int block : {240, 480, 777, 960}) { |
|
|
|
|
decoder d; |
|
|
|
|
auto* j = call_jitter_create(decode, &d, 1000); |
|
|
|
|
std::vector<int16_t> output(block); |
|
|
|
|
int next = 0, largest_reserve = 0; |
|
|
|
|
uint32_t stable_underruns = 0; |
|
|
|
|
call_jitter_diagnostics state{}; |
|
|
|
|
for (int64_t time = 0; time < 30 * 48000; time += block) { |
|
|
|
|
// Один перебой 80мс, затем приходит накопленная пачка и продолжается ровная доставка.
|
|
|
|
|
bool stalled = time >= 48000 && time < 48000 + 3840; |
|
|
|
|
while (!stalled && next * 960ll <= time) push(j, next++, time / 48); |
|
|
|
|
int n = call_jitter_pull(j, output.data(), block); |
|
|
|
|
if (n < block) call_jitter_silence(j, block - n); |
|
|
|
|
call_jitter_get_diagnostics(j, &state, 0); |
|
|
|
|
largest_reserve = std::max(largest_reserve, state.reserve_ms); |
|
|
|
|
if (time < 3 * 48000) stable_underruns = state.underruns; |
|
|
|
|
else CHECK(state.underruns == stable_underruns); |
|
|
|
|
} |
|
|
|
|
CHECK(largest_reserve >= 60 && state.reserve_ms == 20); |
|
|
|
|
CHECK(state.delay_mode == 0 && state.phase_samples == 0 && state.tempo_ppm == 1000000); |
|
|
|
|
CHECK(state.underruns > 0 && state.underruns <= 2); |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_CALL, "recovery block=%d max_reserve=%dms final=%dms phase=%u underruns=%u", |
|
|
|
|
block, largest_reserve, state.reserve_ms, state.phase_samples, state.underruns); |
|
|
|
|
call_jitter_destroy(j); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void test_audio_clock() { |
|
|
|
|
const uint64_t id = 987; |
|
|
|
|
CHECK(call_audio_start(id) == 0); |
|
|
|
|
@ -116,6 +144,7 @@ int main() {
|
|
|
|
|
debug_set_level(DEBUG_LEVEL_WARN); |
|
|
|
|
debug_enable_console(1); |
|
|
|
|
test_audio_clock(); |
|
|
|
|
test_network_recovery(); |
|
|
|
|
int16_t pcm[480]; |
|
|
|
|
int depth, tempo; |
|
|
|
|
uint32_t dropped, under; |
|
|
|
|
|