From 71b9caea916c1ce50c5792bd756a3fb53919c998 Mon Sep 17 00:00:00 2001 From: Johannes Gotlen Date: Thu, 18 May 2023 11:03:56 -0400 Subject: [PATCH] Added handling for the 'NoMoreData' packet This is returned from QTM when StreamFrames is called and playback or capture is not running. --- qtm/protocol.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/qtm/protocol.py b/qtm/protocol.py index fe1faa6..9f88c0e 100644 --- a/qtm/protocol.py +++ b/qtm/protocol.py @@ -56,9 +56,7 @@ def __init__(self, *, loop=None, on_disconnect=None, on_event=None): QRTPacketType.PacketCommand: self._on_command, QRTPacketType.PacketEvent: self._on_event, QRTPacketType.PacketXML: self._on_xml, - QRTPacketType.PacketNoMoreData: lambda _: LOG.debug( - QRTPacketType.PacketNoMoreData - ), + QRTPacketType.PacketNoMoreData: self._on_no_more_data } self._receiver = Receiver(self._handlers) @@ -151,7 +149,14 @@ def _on_data(self, packet): else: self._deliver_promise(packet) return - + + def _on_no_more_data(self, packet): + if self.on_packet is not None: + if self._start_streaming: + self._deliver_promise(b"Ok") + self._start_streaming = False + return + def _on_event(self, event): LOG.info(event)