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.
pull/42145/head
Dermot Duffy 2020-07-13 06:47:33 -07:00 committed by GitHub
parent d8ec1d36b2
commit eb6fda8387
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -66,6 +66,8 @@ def stream_worker(hass, stream, quit_event):
first_pts = 0 first_pts = 0
# The decoder timestamp of the latest packet we processed # The decoder timestamp of the latest packet we processed
last_dts = None 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(): while not quit_event.is_set():
try: try:
@ -73,8 +75,14 @@ def stream_worker(hass, stream, quit_event):
if packet.dts is None: if packet.dts is None:
if first_packet: if first_packet:
continue continue
_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 # If we get a "flushing" packet, the stream is done
raise StopIteration("No dts in packet") 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: except (av.AVError, StopIteration) as ex:
# End of stream, clear listeners and stop thread # End of stream, clear listeners and stop thread
for fmt, _ in outputs.items(): for fmt, _ in outputs.items():