identify meaning of rtp_next in time synchronization

This commit is contained in:
fduncanh
2022-04-27 13:14:07 -04:00
parent 956faa3e04
commit 82303e8be7

View File

@@ -452,15 +452,20 @@ raop_rtp_thread_udp(void *arg)
assert(result >= 0);
} else if (type_c == 0x54 && packetlen >= 20) {
// The unit for the rtp clock is 1 / sample rate = 1 / 44100
uint32_t sync_rtp = byteutils_get_int_be(packet, 4) - 11025;
uint64_t sync_ntp_raw = byteutils_get_long_be(packet, 8);
uint32_t sync_rtp = byteutils_get_int_be(packet, 4);
uint64_t sync_ntp_raw = byteutils_get_long_be(packet, 8);
uint32_t next_rtp = byteutils_get_int_be(packet, 16);
// next_rtp = sync_rtp + 7497 = 441 * 17 (0.17 sec) for AAC_ELD
// next_rtp = sync_rtp + 77175 = 441 * 175 (1.75 sec) for ALAC
/* subtract 44100/4 from sync_rtp */
sync_rtp -= 11025;
uint64_t sync_ntp_remote = raop_ntp_timestamp_to_micro_seconds(sync_ntp_raw, true);
uint64_t sync_ntp_local = raop_ntp_convert_remote_time(raop_rtp->ntp, sync_ntp_remote);
// It's not clear what the additional rtp timestamp indicates
uint32_t next_rtp = byteutils_get_int_be(packet, 16);
raop_rtp_sync_clock(raop_rtp, sync_rtp, sync_ntp_local);
logger_log(raop_rtp->logger, LOGGER_DEBUG, "raop_rtp sync: ntp=%llu, local ntp: %llu, rtp=%u, rtp_next=%u",
sync_ntp_remote, sync_ntp_local, sync_rtp, next_rtp);
raop_rtp_sync_clock(raop_rtp, sync_rtp, sync_ntp_local);
} else {
logger_log(raop_rtp->logger, LOGGER_DEBUG, "raop_rtp unknown packet");
}