summaryrefslogtreecommitdiff
path: root/DecoderOutputFramer.cpp
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2026-09-26 23:24:28 +0200
committerChristoph Berg <myon@debian.org>2026-09-26 23:24:28 +0200
commit69344560ea394c06ca94acac46a2e4c3e8b7b229 (patch)
treeebc98370a697a9bbd6b973a14fa5113c475c6db7 /DecoderOutputFramer.cpp
parent3e9d10a67671d0bd5c7b8c3ca8088f1818322eff (diff)
parent059831534c7e884f0a607ed86b582fd00d821731 (diff)
Update upstream source from tag 'upstream/3.2.0_rc1+dfsg'
Update to upstream version '3.2.0~rc1+dfsg' with Debian dir dbff457fd2c3616d5c77b863c7bfb2186ed86047
Diffstat (limited to 'DecoderOutputFramer.cpp')
-rw-r--r--DecoderOutputFramer.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/DecoderOutputFramer.cpp b/DecoderOutputFramer.cpp
new file mode 100644
index 00000000..92c9c1e9
--- /dev/null
+++ b/DecoderOutputFramer.cpp
@@ -0,0 +1,52 @@
+#include "DecoderOutputFramer.hpp"
+
+#include <QIODevice>
+
+void DecoderOutputFramer::drain (QIODevice& device,
+ EventHandler const& handler)
+{
+ while (device.canReadLine ())
+ {
+ auto const rawLine = device.readLine ();
+ Event event {EventType::Malformed, generation_, rawLine, {}};
+
+ if (rawLine.startsWith ("<DecodeStarted>"))
+ {
+ qint32 generation {0};
+ if (!generation_ && DecoderIpc::parseStart (rawLine, &generation))
+ {
+ generation_ = generation;
+ event.type = EventType::Started;
+ event.generation = generation;
+ }
+ }
+ else if (rawLine.startsWith ("<DecodeFinished>"))
+ {
+ DecoderIpc::Completion completion {};
+ if (DecoderIpc::parseCompletion (rawLine, &completion)
+ && generation_ == completion.generation)
+ {
+ event.type = EventType::Finished;
+ event.generation = completion.generation;
+ event.completion = completion;
+ generation_ = 0;
+ }
+ }
+ else if (generation_)
+ {
+ event.type = EventType::Record;
+ }
+
+ if (handler) handler (event);
+ }
+}
+
+void DecoderOutputFramer::reset ()
+{
+ generation_ = 0;
+}
+
+qint32 DecoderOutputFramer::currentGeneration () const
+{
+ return generation_;
+}