mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 06:58:56 +00:00
mpegtsbase: Refactor scan loop
Avoids ending up leaking packets when we got one and res was different from GST_FLOW_OK. It also looks more comprehensible
This commit is contained in:
parent
e4b7967c9d
commit
db0633918a
1 changed files with 12 additions and 5 deletions
|
@ -1262,11 +1262,16 @@ mpegts_base_chain (GstPad * pad, GstBuffer * buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
mpegts_packetizer_push (base->packetizer, buf);
|
mpegts_packetizer_push (base->packetizer, buf);
|
||||||
while (((pret =
|
|
||||||
mpegts_packetizer_next_packet (base->packetizer,
|
while (res == GST_FLOW_OK) {
|
||||||
&packet)) != PACKET_NEED_MORE) && res == GST_FLOW_OK) {
|
pret = mpegts_packetizer_next_packet (base->packetizer, &packet);
|
||||||
|
|
||||||
|
/* If we don't have enough data, return */
|
||||||
|
if (G_UNLIKELY (pret == PACKET_NEED_MORE))
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* bad header, skip the packet */
|
||||||
if (G_UNLIKELY (pret == PACKET_BAD))
|
if (G_UNLIKELY (pret == PACKET_BAD))
|
||||||
/* bad header, skip the packet */
|
|
||||||
goto next;
|
goto next;
|
||||||
|
|
||||||
GST_DEBUG ("Got packet (buffer:%p)", packet.buffer);
|
GST_DEBUG ("Got packet (buffer:%p)", packet.buffer);
|
||||||
|
@ -1292,13 +1297,15 @@ mpegts_base_chain (GstPad * pad, GstBuffer * buf)
|
||||||
/* bad PSI table */
|
/* bad PSI table */
|
||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we need to push section packet downstream */
|
/* we need to push section packet downstream */
|
||||||
res = mpegts_base_push (base, &packet, §ion);
|
res = mpegts_base_push (base, &packet, §ion);
|
||||||
} else if (MPEGTS_BIT_IS_SET (base->is_pes, packet.pid)) {
|
} else if (MPEGTS_BIT_IS_SET (base->is_pes, packet.pid)) {
|
||||||
/* push the packet downstream */
|
/* push the packet downstream */
|
||||||
res = mpegts_base_push (base, &packet, NULL);
|
res = mpegts_base_push (base, &packet, NULL);
|
||||||
} else
|
} else {
|
||||||
gst_buffer_unref (packet.buffer);
|
gst_buffer_unref (packet.buffer);
|
||||||
|
}
|
||||||
|
|
||||||
next:
|
next:
|
||||||
mpegts_packetizer_clear_packet (base->packetizer, &packet);
|
mpegts_packetizer_clear_packet (base->packetizer, &packet);
|
||||||
|
|
Loading…
Reference in a new issue