Compared with d652f15:
- set the SDK release version to 1.0.0 for the new GigabyteLib backend and its required matching driver
- preserve GigabyteLib result codes and event names through the public SDK instead of translating vendor semantics
- expose cached Lib signal, SDI string fields, ErrorCount, and separate video/audio event counters for direct diagnostics
- serialize GigabyteLib capture calls and recover an active stream internally after a video input plugin event
- keep the SDK frame lifetime fence while following the current zero-copy contract without a vendor release call
- separate Sample logging and presentation counters from capture control, and report Lib-owned fields with explicit source names
- remove the manual Open Device control so Start lazily opens the selected device and revalidates VideoSignalLock once per request
- keep format selection side-effect free until Start opens the channel, then apply the selected output depth through GigabyteLib
- update the public API, diagnostics, architecture, error-handling, and build documentation for the simplified ownership model
79 lines
2.6 KiB
C++
79 lines
2.6 KiB
C++
#include "sample_log.h"
|
|
|
|
#include <QCoreApplication>
|
|
#include <QDateTime>
|
|
#include <QDir>
|
|
#include <QStringList>
|
|
|
|
namespace
|
|
{
|
|
QString filePrefix()
|
|
{
|
|
#if GVFG_INTERNAL_DIAGNOSTICS
|
|
return QStringLiteral("gvfg_qt_preview_debug");
|
|
#else
|
|
return QStringLiteral("gvfg_qt_preview");
|
|
#endif
|
|
}
|
|
}
|
|
|
|
SampleLog::SampleLog(QObject *parent) : QObject(parent)
|
|
{
|
|
sessionStamp_ = QDateTime::currentDateTime().toString(QStringLiteral("yyyyMMdd_HHmmss"));
|
|
directoryPath_ = QCoreApplication::applicationDirPath() + QStringLiteral("/logs");
|
|
if (QDir().mkpath(directoryPath_)) openPart();
|
|
else filePath_ = directoryPath_;
|
|
}
|
|
|
|
void SampleLog::append(const QString &message)
|
|
{
|
|
const QString timestamp = QDateTime::currentDateTime().toString(QStringLiteral("HH:mm:ss.zzz"));
|
|
const QStringList lines = message.split(QLatin1Char('\n'));
|
|
for (int i = 0; i < lines.size(); ++i)
|
|
{
|
|
const QString line = QStringLiteral("[%1] %2%3")
|
|
.arg(timestamp, i == 0 ? QString() : QStringLiteral(" "), lines.at(i));
|
|
writeLine(line);
|
|
emit lineReady(line);
|
|
}
|
|
}
|
|
|
|
void SampleLog::appendDiagnostic(const QString &message)
|
|
{
|
|
const QString timestamp = QDateTime::currentDateTime().toString(QStringLiteral("HH:mm:ss.zzz"));
|
|
const QStringList lines = message.split(QLatin1Char('\n'));
|
|
for (int i = 0; i < lines.size(); ++i)
|
|
writeLine(QStringLiteral("[%1] %2%3").arg(
|
|
timestamp, i == 0 ? QStringLiteral("Diagnostic | ") : QStringLiteral(" "), lines.at(i)));
|
|
}
|
|
|
|
bool SampleLog::openPart()
|
|
{
|
|
if (file_.isOpen()) file_.close();
|
|
filePath_ = QStringLiteral("%1/%2_%3_part%4.log")
|
|
.arg(directoryPath_, filePrefix(), sessionStamp_).arg(partIndex_, 2, 10, QLatin1Char('0'));
|
|
file_.setFileName(filePath_);
|
|
if (!file_.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) return false;
|
|
file_.write(QStringLiteral("\n==== %1 session %2 part %3 ====\n")
|
|
.arg(filePrefix(), QDateTime::currentDateTime().toString(QStringLiteral("yyyy-MM-dd HH:mm:ss.zzz")))
|
|
.arg(partIndex_).toUtf8());
|
|
file_.flush();
|
|
return true;
|
|
}
|
|
|
|
void SampleLog::writeLine(const QString &line)
|
|
{
|
|
if (!file_.isOpen()) return;
|
|
if (file_.size() >= kMaxFileBytes)
|
|
{
|
|
file_.write(QStringLiteral("==== log rotated at %1 ====\n")
|
|
.arg(QDateTime::currentDateTime().toString(QStringLiteral("yyyy-MM-dd HH:mm:ss.zzz"))).toUtf8());
|
|
file_.flush();
|
|
++partIndex_;
|
|
if (!openPart()) return;
|
|
}
|
|
file_.write(line.toUtf8());
|
|
file_.write("\n");
|
|
file_.flush();
|
|
}
|