diff --git a/app/src/decoder.c b/app/src/decoder.c index ad7fede8..83583cc3 100644 --- a/app/src/decoder.c +++ b/app/src/decoder.c @@ -40,12 +40,16 @@ static int read_packet(void *opaque, uint8_t *buf, int buf_size) { remaining = decoder->remaining; if (remaining == 0) { + // the previous PTS read is now for the current frame + decoder->pts = decoder->next_pts; + // FIXME what if only part of the header is available? ret = net_recv(decoder->video_socket, header, HEADER_SIZE); if (ret <= 0) return ret; - decoder->pts = from_be(header, 8); + // read the PTS for the next frame + decoder->next_pts = from_be(header, 8); decoder->buffer_info_flags = from_be(header + 8, 4); remaining = from_be(header + 12, 4); } diff --git a/app/src/decoder.h b/app/src/decoder.h index fa1200b4..b502b625 100644 --- a/app/src/decoder.h +++ b/app/src/decoder.h @@ -15,6 +15,7 @@ struct decoder { SDL_Thread *thread; SDL_mutex *mutex; struct recorder *recorder; + uint64_t next_pts; uint64_t pts; uint32_t buffer_info_flags; int remaining;