mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Fixed video packet assembling.
Video should look better now.
This commit is contained in:
parent
36851e7b38
commit
12f396fcc2
|
@ -637,7 +637,10 @@ void queue_message(RTPSession *session, RTPMessage *msg)
|
||||||
if (packet_size < VIDEOFRAME_HEADER_SIZE)
|
if (packet_size < VIDEOFRAME_HEADER_SIZE)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
if (packet[0] > cs->frameid_in || (msg->header->timestamp > cs->last_timestamp)) { /* New frame */
|
uint8_t diff = packet[0] - cs->frameid_in;
|
||||||
|
|
||||||
|
if (diff != 0) {
|
||||||
|
if (diff < 225) { /* New frame */
|
||||||
/* Flush last frames' data and get ready for this frame */
|
/* Flush last frames' data and get ready for this frame */
|
||||||
Payload *p = malloc(sizeof(Payload) + cs->frame_size);
|
Payload *p = malloc(sizeof(Payload) + cs->frame_size);
|
||||||
|
|
||||||
|
@ -666,18 +669,31 @@ void queue_message(RTPSession *session, RTPMessage *msg)
|
||||||
memset(cs->frame_buf, 0, cs->frame_size);
|
memset(cs->frame_buf, 0, cs->frame_size);
|
||||||
cs->frame_size = 0;
|
cs->frame_size = 0;
|
||||||
|
|
||||||
} else if (packet[0] < cs->frameid_in) { /* Old frame; drop */
|
} else { /* Old frame; drop */
|
||||||
LOGGER_DEBUG("Old packet: %u", packet[0]);
|
LOGGER_DEBUG("Old packet: %u", packet[0]);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t piece_number = packet[1];
|
||||||
|
|
||||||
|
uint32_t length_before_piece = ((piece_number - 1) * cs->video_frame_piece_size);
|
||||||
|
uint32_t framebuf_new_length = length_before_piece + (packet_size - VIDEOFRAME_HEADER_SIZE);
|
||||||
|
|
||||||
|
if (framebuf_new_length > cs->max_video_frame_size) {
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
/* Otherwise it's part of the frame so just process */
|
/* Otherwise it's part of the frame so just process */
|
||||||
/* LOGGER_DEBUG("Video Packet: %u %u", packet[0], packet[1]); */
|
/* LOGGER_DEBUG("Video Packet: %u %u", packet[0], packet[1]); */
|
||||||
memcpy(cs->frame_buf + cs->frame_size,
|
|
||||||
|
memcpy(cs->frame_buf + length_before_piece,
|
||||||
packet + VIDEOFRAME_HEADER_SIZE,
|
packet + VIDEOFRAME_HEADER_SIZE,
|
||||||
packet_size - VIDEOFRAME_HEADER_SIZE);
|
packet_size - VIDEOFRAME_HEADER_SIZE);
|
||||||
|
|
||||||
cs->frame_size += packet_size - VIDEOFRAME_HEADER_SIZE;
|
if (framebuf_new_length > cs->frame_size) {
|
||||||
|
cs->frame_size = framebuf_new_length;
|
||||||
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
rtp_free_msg(NULL, msg);
|
rtp_free_msg(NULL, msg);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user