Skip to content

Commit

Permalink
Allow an extra packet without dts (for Arlo camera streaming) (#37792)
Browse files Browse the repository at this point in the history
* Allow 1 packet without dts. See twrecked/hass-aarlo#151 .

* Reset boolean once a packet with dts is found.

* Fix no-else-continue lint error.
  • Loading branch information
dermotduffy authored Jul 13, 2020
1 parent d8ec1d3 commit eb6fda8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions homeassistant/components/stream/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,23 @@ 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:
packet = next(container.demux(video_stream))
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():
Expand Down

0 comments on commit eb6fda8

Please sign in to comment.