bool PreviewGenerator::LocalPreviewRun(void) { programInfo.MarkAsInUse(true, kInUseID); float aspect = 0; int len, width, height, sz; long long captime = captureTime; if (captime < 0) { timeInSeconds = true; captime = (gContext->GetNumSetting("PreviewPixmapOffset", 64) + gContext->GetNumSetting("RecordPreRoll", 0)); } len = width = height = sz = 0; unsigned char *data = (unsigned char*) GetScreenGrab(&programInfo, pathname, captime, timeInSeconds, sz, width, height, aspect); QString outname = CreateAccessibleFilename(pathname, outFileName); int dw = (outSize.width() < 0) ? width : outSize.width(); int dh = (outSize.height() < 0) ? height : outSize.height(); bool ok = SavePreview(outname, data, width, height, aspect, dw, dh); if (data) delete[] data; programInfo.MarkAsInUse(false); return ok; }
bool PreviewGenerator::LocalPreviewRun(void) { programInfo.MarkAsInUse(true, kPreviewGeneratorInUseID); float aspect = 0; int width, height, sz; long long captime = captureTime; QDateTime dt = QDateTime::currentDateTime(); if (captime > 0) LOG(VB_GENERAL, LOG_INFO, "Preview from time spec"); if (captime < 0) { captime = programInfo.QueryBookmark(); if (captime > 0) { timeInSeconds = false; LOG(VB_GENERAL, LOG_INFO, QString("Preview from bookmark (frame %1)").arg(captime)); } else captime = -1; } if (captime < 0) { timeInSeconds = true; int startEarly = 0; int programDuration = 0; int preroll = gCoreContext->GetNumSetting("RecordPreRoll", 0); if (programInfo.GetScheduledStartTime().isValid() && programInfo.GetScheduledEndTime().isValid() && (programInfo.GetScheduledStartTime() != programInfo.GetScheduledEndTime())) { programDuration = programInfo.GetScheduledStartTime() .secsTo(programInfo.GetScheduledEndTime()); } if (programInfo.GetRecordingStartTime().isValid() && programInfo.GetScheduledStartTime().isValid() && (programInfo.GetRecordingStartTime() != programInfo.GetScheduledStartTime())) { startEarly = programInfo.GetRecordingStartTime() .secsTo(programInfo.GetScheduledStartTime()); } if (programDuration > 0) { captime = startEarly + (programDuration / 3); } if (captime < 0) captime = 600; captime += preroll; LOG(VB_GENERAL, LOG_INFO, QString("Preview at calculated offset (%1 seconds)").arg(captime)); } width = height = sz = 0; unsigned char *data = (unsigned char*) GetScreenGrab(programInfo, pathname, captime, timeInSeconds, sz, width, height, aspect); QString outname = CreateAccessibleFilename(pathname, outFileName); int dw = (outSize.width() < 0) ? width : outSize.width(); int dh = (outSize.height() < 0) ? height : outSize.height(); bool ok = SavePreview(outname, data, width, height, aspect, dw, dh); if (ok) { // Backdate file to start of preview time in case a bookmark was made // while we were generating the preview. struct utimbuf times; times.actime = times.modtime = dt.toTime_t(); utime(outname.toLocal8Bit().constData(), ×); } delete[] data; programInfo.MarkAsInUse(false, kPreviewGeneratorInUseID); return ok; }