mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-04-20 03:25:03 +00:00
Assign PTS to the right frame
The PTS was read from the socket and set as the current one even before the frame was consumed, so it could be assigned to the previous frame "in advance". Store the PTS for the current frame and the last PTS read from the packet header of the next frame in separate fields. As a side-effect, this fixes the warning on quit: > Application provided invalid, non monotonically increasing dts to > muxer in stream 0: 17164020 >= 17164020
This commit is contained in:
parent
2de0a9ee02
commit
0cb16be9f5
2 changed files with 6 additions and 1 deletions
|
@ -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 half 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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue