6 changes: 3 additions & 3 deletions mythtv/libs/libmythtv/previewgeneratorqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ class MTV_PUBLIC PreviewGeneratorQueue : public QObject, public MThread
*/
static void GetPreviewImage(const ProgramInfo &pginfo, const QString& token)
{
GetPreviewImage(pginfo, QSize(0,0), "", -1, true, token);
GetPreviewImage(pginfo, QSize(0,0), "", -1s, -1, token);
}
static void GetPreviewImage(const ProgramInfo &pginfo, QSize outputsize,
const QString &outputfile,
long long time, bool in_seconds,
std::chrono::seconds time, long long frame,
const QString& token);
static void AddListener(QObject *listener);
static void RemoveListener(QObject *listener);
Expand All @@ -103,7 +103,7 @@ class MTV_PUBLIC PreviewGeneratorQueue : public QObject, public MThread

QString GeneratePreviewImage(ProgramInfo &pginfo, QSize size,
const QString &outputfile,
long long time, bool in_seconds,
std::chrono::seconds time, long long frame,
const QString& token);

void GetInfo(const QString &key, uint &queue_depth, uint &token_cnt);
Expand Down
38 changes: 30 additions & 8 deletions mythtv/programs/mythbackend/mainserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7367,7 +7367,8 @@ void MainServer::HandleGenPreviewPixmap(QStringList &slist, PlaybackSock *pbs)
}

bool time_fmt_sec = true;
long long time = -1;
std::chrono::seconds time = std::chrono::seconds::max();
long long frame = -1;
QString outputfile;
int width = -1;
int height = -1;
Expand Down Expand Up @@ -7405,7 +7406,12 @@ void MainServer::HandleGenPreviewPixmap(QStringList &slist, PlaybackSock *pbs)
if (it != slist.cend())
(time_fmt_sec = ((*it).toLower() == "s")), ++it;
if (it != slist.cend())
(time = (*it).toLongLong()), ++it;
{
if (time_fmt_sec)
time = std::chrono::seconds((*it).toLongLong()), ++it;
else
frame = (*it).toLongLong(), ++it;
}
if (it != slist.cend())
(outputfile = *it), ++it;
outputfile = (outputfile == "<EMPTY>") ? QString() : outputfile;
Expand All @@ -7424,10 +7430,13 @@ void MainServer::HandleGenPreviewPixmap(QStringList &slist, PlaybackSock *pbs)

if (has_extra_data)
{
auto pos_text = (time != std::chrono::seconds::max())
? QString::number(time.count()) + "s"
: QString::number(frame) + "f";
LOG(VB_PLAYBACK, LOG_INFO, LOC +
QString("HandleGenPreviewPixmap got extra data\n\t\t\t"
"%1%2 %3x%4 '%5'")
.arg(time).arg(time_fmt_sec?"s":"f")
"%1 %2x%3 '%4'")
.arg(pos_text)
.arg(width).arg(height).arg(outputfile));
}

Expand All @@ -7446,8 +7455,16 @@ void MainServer::HandleGenPreviewPixmap(QStringList &slist, PlaybackSock *pbs)
QStringList outputlist;
if (has_extra_data)
{
outputlist = slave->GenPreviewPixmap(
token, &pginfo, time_fmt_sec, time, outputfile, outputsize);
if (time != std::chrono::seconds::max())
{
outputlist = slave->GenPreviewPixmap(
token, &pginfo, time, -1, outputfile, outputsize);
}
else
{
outputlist = slave->GenPreviewPixmap(
token, &pginfo, std::chrono::seconds::max(), frame, outputfile, outputsize);
}
}
else
{
Expand Down Expand Up @@ -7481,8 +7498,13 @@ void MainServer::HandleGenPreviewPixmap(QStringList &slist, PlaybackSock *pbs)

if (has_extra_data)
{
PreviewGeneratorQueue::GetPreviewImage(
pginfo, outputsize, outputfile, time, time_fmt_sec, token);
if (time != std::chrono::seconds::max()) {
PreviewGeneratorQueue::GetPreviewImage(
pginfo, outputsize, outputfile, time, -1, token);
} else {
PreviewGeneratorQueue::GetPreviewImage(
pginfo, outputsize, outputfile, -1s, frame, token);
}
}
else
{
Expand Down
16 changes: 12 additions & 4 deletions mythtv/programs/mythbackend/playbacksock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,16 +284,24 @@ QStringList PlaybackSock::GenPreviewPixmap(const QString &token,

QStringList PlaybackSock::GenPreviewPixmap(const QString &token,
const ProgramInfo *pginfo,
bool time_fmt_sec,
long long time,
std::chrono::seconds time,
long long frame,
const QString &outputFile,
const QSize outputSize)
{
QStringList strlist(QString("QUERY_GENPIXMAP2"));
strlist += token;
pginfo->ToStringList(strlist);
strlist.push_back(time_fmt_sec ? "s" : "f");
strlist.push_back(QString::number(time));
if (time != std::chrono::seconds::max())
{
strlist.push_back("s");
strlist.push_back(QString::number(time.count()));
}
else
{
strlist.push_back("f");
strlist.push_back(QString::number(frame));
}
strlist.push_back((outputFile.isEmpty()) ? "<EMPTY>" : outputFile);
strlist.push_back(QString::number(outputSize.width()));
strlist.push_back(QString::number(outputSize.height()));
Expand Down
4 changes: 2 additions & 2 deletions mythtv/programs/mythbackend/playbacksock.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ class PlaybackSock : public ReferenceCounter
const ProgramInfo *pginfo);
QStringList GenPreviewPixmap(const QString &token,
const ProgramInfo *pginfo,
bool time_fmt_sec,
long long time,
std::chrono::seconds time,
long long frame,
const QString &outputFile,
QSize outputSize);
QDateTime PixmapLastModified(const ProgramInfo *pginfo);
Expand Down
9 changes: 5 additions & 4 deletions mythtv/programs/mythbackend/services/content.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,9 +545,10 @@ QFileInfo Content::GetPreviewImage( int nRecordedId,

QString sPreviewFileName;

if (nSecsIn <= 0)
auto nSecs = std::chrono::seconds(nSecsIn);
if (nSecs <= 0s)
{
nSecsIn = -1;
nSecs = -1s;
sPreviewFileName = QString("%1.png").arg(sFileName);
}
else
Expand All @@ -568,7 +569,7 @@ QFileInfo Content::GetPreviewImage( int nRecordedId,

auto *previewgen = new PreviewGenerator( &pginfo, QString(),
PreviewGenerator::kLocal);
previewgen->SetPreviewTimeAsSeconds( nSecsIn );
previewgen->SetPreviewTimeAsSeconds( nSecs );
previewgen->SetOutputFilename ( sPreviewFileName );

bool ok = previewgen->Run();
Expand Down Expand Up @@ -638,7 +639,7 @@ QFileInfo Content::GetPreviewImage( int nRecordedId,

auto *previewgen = new PreviewGenerator( &pginfo, QString(),
PreviewGenerator::kLocal);
previewgen->SetPreviewTimeAsSeconds( nSecsIn );
previewgen->SetPreviewTimeAsSeconds( nSecs );
previewgen->SetOutputFilename ( sNewFileName );
previewgen->SetOutputSize (QSize(nWidth,nHeight));

Expand Down
6 changes: 3 additions & 3 deletions mythtv/programs/mythpreviewgen/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace
}

int preview_helper(uint chanid, QDateTime starttime,
long long previewFrameNumber, long long previewSeconds,
long long previewFrameNumber, std::chrono::seconds previewSeconds,
const QSize previewSize,
const QString &infile, const QString &outfile)
{
Expand Down Expand Up @@ -117,7 +117,7 @@ int preview_helper(uint chanid, QDateTime starttime,
if (previewFrameNumber >= 0)
previewgen->SetPreviewTimeAsFrameNumber(previewFrameNumber);

if (previewSeconds >= 0)
if (previewSeconds >= 0s)
previewgen->SetPreviewTimeAsSeconds(previewSeconds);

previewgen->SetOutputSize(previewSize);
Expand Down Expand Up @@ -206,7 +206,7 @@ int main(int argc, char **argv)

int ret = preview_helper(
cmdline.toUInt("chanid"), cmdline.toDateTime("starttime"),
cmdline.toLongLong("frame"), cmdline.toLongLong("seconds"),
cmdline.toLongLong("frame"), std::chrono::seconds(cmdline.toLongLong("seconds")),
cmdline.toSize("size"),
cmdline.toString("inputfile"), cmdline.toString("outputfile"));
return ret;
Expand Down