5#include <QtCore/QFileInfo>
8 std::chrono::milliseconds maxPartDuration)
11 , _maxPartDuration(maxPartDuration)
16 const qsizetype dot = file.lastIndexOf(u
'.');
17 const qsizetype separator = std::max(file.lastIndexOf(u
'/'), file.lastIndexOf(u
'\\'));
18 return (dot > separator) ? (file.left(dot) + tag + file.mid(dot)) : (file + tag);
42 if (file == _openFile) {
43 _closedBytes += QFileInfo(file).size();
50 return _opened && ((now - _partStartedAt) >= _maxPartDuration);
63 return _startedAt ? std::chrono::duration_cast<std::chrono::milliseconds>(now - *_startedAt).count() : -1;
68 return _closedBytes + (_openFile.isEmpty() ? 0 : QFileInfo(_openFile).size());
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.
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.
qint64 bytesWritten() const
For VideoStreamStats::recordingBytes: what the parts' files held when they closed,...
VideoReceiver::FileFormat format() 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.