Skip to content

Commit e070554

Browse files
Fix: ts for audio frame matches the RTP ts of the 1st pkt (#1243)
Set timestamp to the RTP timestamp of the first packet of the audio frame (not the last one like currently) in st30 to ensure lipsync. --------- Co-authored-by: Wesierski, Dawid <[email protected]>
1 parent 18cdb7f commit e070554

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/src/st2110/st_header.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,7 @@ struct st_rx_audio_session_impl {
10191019
int st30_pkt_idx; /* pkt index in current frame */
10201020
int latest_seq_id; /* latest seq id */
10211021

1022+
uint32_t first_pkt_rtp_ts; /* rtp time stamp for the first pkt */
10221023
uint32_t tmstamp;
10231024
size_t frame_recv_size;
10241025

lib/src/st2110/st_rx_audio_session.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ static int rx_audio_session_handle_frame_pkt(struct mtl_main_impl* impl,
269269

270270
return -EINVAL;
271271
}
272+
272273
if (ops->ssrc) {
273274
uint32_t ssrc = ntohl(rtp->ssrc);
274275
if (ssrc != ops->ssrc) {
@@ -287,6 +288,10 @@ static int rx_audio_session_handle_frame_pkt(struct mtl_main_impl* impl,
287288
return -EINVAL;
288289
}
289290

291+
if (s->st30_pkt_idx == 0) {
292+
s->first_pkt_rtp_ts = tmstamp;
293+
}
294+
290295
/* set first seq_id - 1 */
291296
if (unlikely(s->latest_seq_id == -1)) s->latest_seq_id = seq_id - 1;
292297
/* drop old packet */
@@ -359,15 +364,15 @@ static int rx_audio_session_handle_frame_pkt(struct mtl_main_impl* impl,
359364
}
360365

361366
meta->tfmt = ST10_TIMESTAMP_FMT_MEDIA_CLK;
362-
meta->timestamp = tmstamp;
367+
meta->timestamp = s->first_pkt_rtp_ts;
363368
meta->fmt = ops->fmt;
364369
meta->sampling = ops->sampling;
365370
meta->channel = ops->channel;
366-
meta->rtp_timestamp = tmstamp;
371+
meta->rtp_timestamp = s->first_pkt_rtp_ts;
367372
meta->frame_recv_size = s->frame_recv_size;
368373

369-
MT_USDT_ST30_RX_FRAME_AVAILABLE(s->mgr->idx, s->idx, frame->idx, frame->addr, tmstamp,
370-
meta->frame_recv_size);
374+
MT_USDT_ST30_RX_FRAME_AVAILABLE(s->mgr->idx, s->idx, frame->idx, frame->addr,
375+
s->first_pkt_rtp_ts, meta->frame_recv_size);
371376
/* check if dump USDT enabled */
372377
if (MT_USDT_ST30_RX_FRAME_DUMP_ENABLED()) {
373378
rx_audio_session_usdt_dump_frame(s, frame);

0 commit comments

Comments
 (0)