mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-03-29 07:58:06 -04:00
modules: align rtp_timestamps for sender
When the driver changes, the clock position can also change and there would be a discont in the rtp_timestamp. This is not usually a problem except in RAOP mode where the base rtp timestamp is negotiated and anything that deviates too much is to be discarded. If we are not using direct_timestamp for the sender, make sure we always keep the rtp_time aligned to avoid this problem. See #5167
This commit is contained in:
parent
f4587ea434
commit
6bf81ebe59
2 changed files with 6 additions and 3 deletions
|
|
@ -546,7 +546,7 @@ static void rtp_audio_flush_packets(struct impl *impl, uint32_t num_packets, uin
|
||||||
else
|
else
|
||||||
header.m = 0;
|
header.m = 0;
|
||||||
|
|
||||||
rtp_timestamp = impl->ts_offset + (set_timestamp ? set_timestamp : timestamp);
|
rtp_timestamp = impl->ts_offset + impl->ts_align + (set_timestamp ? set_timestamp : timestamp);
|
||||||
|
|
||||||
header.sequence_number = htons(impl->seq);
|
header.sequence_number = htons(impl->seq);
|
||||||
header.timestamp = htonl(rtp_timestamp);
|
header.timestamp = htonl(rtp_timestamp);
|
||||||
|
|
@ -705,8 +705,10 @@ static void rtp_audio_process_capture(void *data)
|
||||||
* that resynchronization is needed, then this will be done immediately below. */
|
* that resynchronization is needed, then this will be done immediately below. */
|
||||||
|
|
||||||
if (!impl->have_sync) {
|
if (!impl->have_sync) {
|
||||||
pw_log_info("(re)sync to timestamp:%u seq:%u ts_offset:%u SSRC:%u",
|
if (!impl->direct_timestamp)
|
||||||
actual_timestamp, impl->seq, impl->ts_offset, impl->ssrc);
|
impl->ts_align = actual_timestamp - impl->ring.readindex;
|
||||||
|
pw_log_info("(re)sync to timestamp:%u seq:%u ts_offset:%u ts_align:%u SSRC:%u",
|
||||||
|
actual_timestamp, impl->seq, impl->ts_offset, impl->ts_align, impl->ssrc);
|
||||||
spa_ringbuffer_read_update(&impl->ring, actual_timestamp);
|
spa_ringbuffer_read_update(&impl->ring, actual_timestamp);
|
||||||
spa_ringbuffer_write_update(&impl->ring, actual_timestamp);
|
spa_ringbuffer_write_update(&impl->ring, actual_timestamp);
|
||||||
memset(impl->buffer, 0, BUFFER_SIZE);
|
memset(impl->buffer, 0, BUFFER_SIZE);
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,7 @@ struct impl {
|
||||||
uint32_t mtu;
|
uint32_t mtu;
|
||||||
uint32_t header_size;
|
uint32_t header_size;
|
||||||
uint32_t payload_size;
|
uint32_t payload_size;
|
||||||
|
uint32_t ts_align;
|
||||||
|
|
||||||
struct spa_ringbuffer ring;
|
struct spa_ringbuffer ring;
|
||||||
uint8_t buffer[BUFFER_SIZE];
|
uint8_t buffer[BUFFER_SIZE];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue