QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
RecordingPlan.h
Go to the documentation of this file.
1#pragma once
2
3#include <chrono>
4#include <optional>
5
6#include <QtCore/QString>
7
8#include "VideoReceiver.h"
9
17{
18public:
19 using Clock = std::chrono::steady_clock;
20
23 static constexpr std::chrono::minutes kMaxPartDuration{60};
24
26 std::chrono::milliseconds maxPartDuration = kMaxPartDuration);
27
29 static QString insertBeforeExtension(const QString& file, const QString& tag);
31 static QString partFile(const QString& file, int part);
32
33 VideoReceiver::FileFormat format() const { return _format; }
34
35 int part() const { return _part; }
36
38 QString currentFile() const { return partFile(_file, _part); }
39
41 bool opened() const { return _opened; }
42
44 bool onFileOpened(const QString& file, Clock::time_point now = Clock::now());
46 void onFileClosed(const QString& file);
48 bool partDue(Clock::time_point now = Clock::now()) const;
51 void nextPart();
52
54 qint64 recordingMs(Clock::time_point now = Clock::now()) const;
56 qint64 bytesWritten() const;
57
58private:
59 QString _file;
61 std::chrono::milliseconds _maxPartDuration;
62 int _part = 1;
63 bool _opened = false;
64 std::optional<Clock::time_point> _startedAt;
66 Clock::time_point _partStartedAt;
68 QString _openFile;
69 qint64 _closedBytes = 0;
70};
static QString partFile(const QString &file, int part)
"<base>_part<part>.<ext>" for file "<base>.<ext>"; file itself for part 1.
bool onFileOpened(const QString &file, Clock::time_point now=Clock::now())
file got its first frame at now. False, changing nothing, unless it is the current part's file.
RecordingPlan(const QString &file, VideoReceiver::FileFormat format, std::chrono::milliseconds maxPartDuration=kMaxPartDuration)
qint64 recordingMs(Clock::time_point now=Clock::now()) const
For VideoStreamStats::recordingMs: since the first part got its first frame; -1 before.
std::chrono::steady_clock Clock
bool partDue(Clock::time_point now=Clock::now()) const
The current part has recorded for its maximum duration by now.
QString currentFile() const
The file the current part records to.
static QString insertBeforeExtension(const QString &file, const QString &tag)
"<base><tag>.<ext>" for file "<base>.<ext>", and "<file><tag>" for one without an extension.
bool opened() const
The current part got a frame.
static constexpr std::chrono::minutes kMaxPartDuration
qint64 bytesWritten() const
For VideoStreamStats::recordingBytes: what the parts' files held when they closed,...
VideoReceiver::FileFormat format() const
int part() const
void onFileClosed(const QString &file)
file is closed. Counts for the one that opened last only: a file of an earlier recording can close la...
FileFormat
Values are persisted by VideoSettings::recordingFormat.