From eb6fda83874c6054e9f37a06425c917be31467b4 Mon Sep 17 00:00:00 2001 From: Dermot Duffy Date: Mon, 13 Jul 2020 06:47:33 -0700 Subject: [PATCH] Allow an extra packet without dts (for Arlo camera streaming) (#37792) * Allow 1 packet without dts. See https://github.com/twrecked/hass-aarlo/issues/151 . * Reset boolean once a packet with dts is found. * Fix no-else-continue lint error. --- homeassistant/components/stream/worker.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/stream/worker.py b/homeassistant/components/stream/worker.py index 15c1c3c02ffae..3df7f8fc1517e 100644 --- a/homeassistant/components/stream/worker.py +++ b/homeassistant/components/stream/worker.py @@ -66,6 +66,8 @@ def stream_worker(hass, stream, quit_event): first_pts = 0 # The decoder timestamp of the latest packet we processed last_dts = None + # Keep track of consecutive packets without a dts to detect end of stream. + last_packet_was_without_dts = False while not quit_event.is_set(): try: @@ -73,8 +75,14 @@ def stream_worker(hass, stream, quit_event): if packet.dts is None: if first_packet: continue - # If we get a "flushing" packet, the stream is done - raise StopIteration("No dts in packet") + _LOGGER.error("Stream packet without dts detected, skipping...") + # Allow a single packet without dts before terminating the stream. + if last_packet_was_without_dts: + # If we get a "flushing" packet, the stream is done + raise StopIteration("No dts in consecutive packets") + last_packet_was_without_dts = True + continue + last_packet_was_without_dts = False except (av.AVError, StopIteration) as ex: # End of stream, clear listeners and stop thread for fmt, _ in outputs.items():