From 1784f2cedd08a44ded356e5065d74ef75c6096b2 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Wed, 28 Jun 2023 16:14:45 +0200 Subject: [PATCH] receiving: pass received frame TS for futher sync --- src/audio/codec.cpp | 1 + src/rtp/audio_decoders.cpp | 4 ++-- src/rtp/video_decoders.cpp | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/audio/codec.cpp b/src/audio/codec.cpp index 253ad17db..1fc1eeba2 100644 --- a/src/audio/codec.cpp +++ b/src/audio/codec.cpp @@ -292,6 +292,7 @@ audio_frame2 audio_codec_decompress(struct audio_codec_state *s, audio_frame2 *f if (out) { if (!out_frame_initialized) { ret.init(frame->get_channel_count(), AC_PCM, out->bps, out->sample_rate); + ret.set_timestamp(frame->get_timestamp()); out_frame_initialized = true; } else { assert(out->bps == ret.get_bps() diff --git a/src/rtp/audio_decoders.cpp b/src/rtp/audio_decoders.cpp index f0ccfe94b..eeb835686 100644 --- a/src/rtp/audio_decoders.cpp +++ b/src/rtp/audio_decoders.cpp @@ -84,12 +84,10 @@ using std::chrono::duration_cast; using std::chrono::seconds; using std::chrono::steady_clock; -using rang::fg; using rang::style; using std::fixed; using std::hex; using std::map; -using std::move; using std::ostringstream; using std::pair; using std::setprecision; @@ -650,6 +648,7 @@ int decode_audio_frame(struct coded_data *cdata, void *pbuf_data, struct pbuf_st get_audio_codec_to_tag(decoder->saved_audio_tag), decoder->saved_desc.bps, decoder->saved_desc.sample_rate); + received_frame.set_timestamp(cdata->data->ts); vector, map>> fec_data; uint32_t fec_params = 0; @@ -841,6 +840,7 @@ int decode_audio_frame(struct coded_data *cdata, void *pbuf_data, struct pbuf_st } } s->buffer.data_len = new_data_len; + s->buffer.timestamp = decompressed.get_timestamp(); decoder->decoded.append(decompressed); diff --git a/src/rtp/video_decoders.cpp b/src/rtp/video_decoders.cpp index 48f1c15f3..cc93e7a69 100644 --- a/src/rtp/video_decoders.cpp +++ b/src/rtp/video_decoders.cpp @@ -441,6 +441,7 @@ static void *fec_thread(void *args) { data->nofec_frame = vf_alloc(data->recv_frame->tile_count); data->nofec_frame->ssrc = data->recv_frame->ssrc; + data->nofec_frame->timestamp = data->recv_frame->timestamp; if (data->recv_frame->fec_params.type != FEC_NONE) { bool buffer_swapped = false; @@ -704,6 +705,7 @@ static void *decompress_thread(void *args) { long long putf_timeout = force_putf_timeout != -1 ? force_putf_timeout : PUTF_NONBLOCK; // originally was BLOCKING when !is_codec_interframe(decoder->received_vid_desc.color_spec) decoder->frame->ssrc = msg->nofec_frame->ssrc; + decoder->frame->timestamp = msg->nofec_frame->timestamp; int ret = display_put_frame(decoder->display, decoder->frame, putf_timeout); msg->is_displayed = ret == 0; @@ -1532,6 +1534,7 @@ int decode_video_frame(struct coded_data *cdata, void *decoder_data, struct pbuf } frame->ssrc = cdata->data->ssrc; + frame->timestamp = cdata->data->ts; if (PT_VIDEO_HAS_FEC(cdata->data->pt)) { const uint32_t *hdr = (uint32_t *)(void *)cdata->data->data; const uint32_t tmp = ntohl(hdr[3]);