tsdemux: correctly determine expected PES packet payload size

Avoids consistently failing to detect that a packet is complete, which
would then only be pushed upon the start of a next packet, which leads
to quite a delay in case of a sparse (subtitle) stream.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=666674
This commit is contained in:
Mark Nauwelaerts 2012-07-11 20:34:05 +02:00
parent 4374a90553
commit 006fe188e7

View file

@ -1300,7 +1300,8 @@ gst_ts_demux_parse_pes_header (GstTSDemux * demux, TSDemuxStream * stream,
/* Remove PES headers */
GST_DEBUG ("Moving data forward by %d bytes (packet_size:%d, have:%d)",
header.header_size, header.packet_length, length);
stream->expected_size = header.packet_length;
g_assert (header.packet_length >= header.header_size);
stream->expected_size = header.packet_length - header.header_size;
data += header.header_size;
length -= header.header_size;
@ -1582,8 +1583,10 @@ gst_ts_demux_handle_packet (GstTSDemux * demux, TSDemuxStream * stream,
GST_DEBUG ("current_size:%d, expected_size:%d",
stream->current_size, stream->expected_size);
/* Finally check if the data we queued completes a packet */
if (stream->expected_size && stream->current_size == stream->expected_size)
if (stream->expected_size && stream->current_size == stream->expected_size) {
GST_LOG ("pushing complete packet");
res = gst_ts_demux_push_pending_data (demux, stream);
}
}
return res;