Skip to content

Commit

Permalink
Updates to allow compiling against new jobqueue structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
wagnerrp committed May 13, 2011
1 parent b0d7cc5 commit 25b4a38
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 112 deletions.
90 changes: 7 additions & 83 deletions mythtv/programs/mythcommflag/main.cpp
Expand Up @@ -187,61 +187,6 @@ static int BuildVideoMarkup(ProgramInfo *program_info, bool useDB)
return GENERIC_EXIT_OK;
}

static int QueueCommFlagJob(uint chanid, QString starttime)
{
QDateTime recstartts = myth_dt_from_string(starttime);
const ProgramInfo pginfo(chanid, recstartts);

if (!pginfo.GetChanID())
{
if (!quiet)
{
QString tmp = QString(
"Unable to find program info for chanid %1 @ %2")
.arg(chanid).arg(starttime);
cerr << tmp.toLocal8Bit().constData() << endl;
}
return GENERIC_EXIT_NO_RECORDING_DATA;
}

JobInfo job(pginfo, JOB_COMMFLAG);
if (job.isValid())
{
if (!quiet)
{
QString tmp = QString("Job already exists for chanid %1 @ %2")
.arg(chanid).arg(starttime);
cerr << tmp.toLocal8Bit().constData() << endl;
}
return GENERIC_EXIT_DB_ERROR;
}

job = JobInfo(JOB_COMMFLAG, chanid, recstartts, "", "", "", 0, 0,
QDateTime::currentDateTime());
if (job.Queue())
{
if (!quiet)
{
QString tmp = QString("Job Queued for chanid %1 @ %2")
.arg(chanid).arg(starttime);
cerr << tmp.toLocal8Bit().constData() << endl;
}
return GENERIC_EXIT_OK;
}
else
{
if (!quiet)
{
QString tmp = QString("Error queueing job for chanid %1 @ %2")
.arg(chanid).arg(starttime);
cerr << tmp.toLocal8Bit().constData() << endl;
}
return GENERIC_EXIT_DB_ERROR;
}

return GENERIC_EXIT_OK;
}

static int CopySkipListToCutList(QString chanid, QString starttime)
{
frm_dir_map_t cutlist;
Expand Down Expand Up @@ -503,7 +448,7 @@ static void commDetectorStatusUpdate(const QString& status)

if (commjob)
{
VERBOSE(VB_JOBQUEUE, commjob->isValid());
VERBOSE(VB_JOBQUEUE, commjob->isStored());
VERBOSE(VB_JOBQUEUE, commjob->getJobID());
VERBOSE(VB_JOBQUEUE, commjob->getComment());
commjob->saveComment(status);
Expand Down Expand Up @@ -972,7 +917,6 @@ int main(int argc, char *argv[])
time_t time_now;
bool useDB = true;
bool allRecorded = false;
bool queueJobInstead = false;
bool copyToCutlist = false;
bool clearCutlist = false;
bool clearSkiplist = false;
Expand Down Expand Up @@ -1176,10 +1120,6 @@ int main(int argc, char *argv[])
print_verbose_messages = VB_NONE;
verboseString = "";
}
else if (!strcmp(a.argv()[argpos], "--queue"))
{
queueJobInstead = true;
}
else if (!strcmp(a.argv()[argpos], "--sleep"))
{
fullSpeed = false;
Expand Down Expand Up @@ -1281,9 +1221,6 @@ int main(int argc, char *argv[])
"--getcutlist Display the current cutlist\n"
"--getskiplist Display the current Commercial Skip list\n"
"-v or --verbose debug-level Use '-v help' for level info\n"
"--queue Insert flagging job into the JobQueue rather than\n"
" running flagging in the foreground\n"
" WARNING: This option does NOT work with --rebuild\n"
"--quiet Don't display commercial flagging progress\n"
"--very-quiet Only display output\n"
"--all Re-run commercial flagging for all recorded\n"
Expand Down Expand Up @@ -1395,7 +1332,7 @@ int main(int argc, char *argv[])
delete commjob;

commjob = new JobInfo(jobID);
if (!commjob->isValid())
if (!commjob->isStored())
{
cerr << "mythcommflag: ERROR: Unable to find DB info for "
<< "JobQueue ID# " << jobID << endl;
Expand Down Expand Up @@ -1489,10 +1426,7 @@ int main(int argc, char *argv[])
}
else if (chanid && !starttime.isEmpty())
{
if (queueJobInstead)
QueueCommFlagJob(chanid, starttime);
else
result = FlagCommercials(chanid, starttime, outputfilename, useDB);
result = FlagCommercials(chanid, starttime, outputfilename, useDB);
}
else if (!useDB)
{
Expand Down Expand Up @@ -1555,13 +1489,8 @@ int main(int argc, char *argv[])

if ( allRecorded )
{
if (queueJobInstead)
QueueCommFlagJob(chanid, starttime);
else
{
FlagCommercials(chanid, starttime,
outputfilename, useDB);
}
FlagCommercials(chanid, starttime,
outputfilename, useDB);
}
else
{
Expand Down Expand Up @@ -1616,13 +1545,8 @@ int main(int argc, char *argv[])
if ((flagStatus == COMM_FLAG_NOT_FLAGGED) &&
(marksFound == 0))
{
if (queueJobInstead)
QueueCommFlagJob(chanid, starttime);
else
{
FlagCommercials(chanid, starttime,
outputfilename, useDB);
}
FlagCommercials(chanid, starttime,
outputfilename, useDB);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion mythtv/programs/mythjobqueue/jobsocket.cpp
Expand Up @@ -59,7 +59,7 @@ bool JobSocketHandler::HandleQuery(MythSocket *socket, QStringList &commands,
// pull job information
QStringList::const_iterator i = slist.begin();
JobInfoRun tmpjob(++i, slist.end());
if (!tmpjob.isValid())
if (tmpjob.getJobID() == -1)
return handled;

if (command == "RUN")
Expand Down
44 changes: 16 additions & 28 deletions mythtv/programs/mythtranscode/main.cpp
Expand Up @@ -28,7 +28,7 @@ using namespace std;
static void CompleteJob(int jobID, ProgramInfo *pginfo, bool useCutlist,
frm_dir_map_t *deleteMap, int &resultCode);

JobInfo *gJob = new JobInfo(-1);
JobInfo *gJob;
static QString recorderOptions = "";

static void usage(char *progname)
Expand Down Expand Up @@ -103,9 +103,6 @@ static void UpdatePositionMap(frm_pos_map_t &posMap, QString mapfile,
static int BuildKeyframeIndex(MPEG2fixup *m2f, QString &infile,
frm_pos_map_t &posMap, int jobID)
{
if (gJob->queryCmds() == JOB_STOP)
return 0;

gJob->saveComment(QObject::tr("Generating Keyframe Index"));

int err = m2f->BuildKeyframeIndex(infile, posMap);
Expand All @@ -128,14 +125,6 @@ static void UpdateJobQueue(float percent_done)

static int CheckJobQueue()
{
if (!gJob->isValid())
return 0;

if (gJob->getCmds() == JOB_STOP)
{
VERBOSE(VB_IMPORTANT, "Transcoding stopped by JobQueue");
return 1;
}
return 0;
}

Expand Down Expand Up @@ -540,9 +529,8 @@ int main(int argc, char *argv[])

if (jobID != -1)
{
delete gJob;
gJob = new JobInfo(jobID);
if (!gJob->isValid())
if (!gJob)
{
cerr << "mythtranscode: ERROR: Unable to find DB info for "
<< "JobQueue ID# " << jobID << endl;
Expand Down Expand Up @@ -643,7 +631,7 @@ int main(int argc, char *argv[])
if (outfile.isNull() && !build_index)
outfile = infile + ".tmp";

if (gJob->isValid())
if (gJob)
gJob->saveStatus(JOB_RUNNING);

Transcode *transcode = new Transcode(pginfo);
Expand All @@ -657,7 +645,7 @@ int main(int argc, char *argv[])
if (!recorderOptions.isEmpty())
transcode->SetRecorderOptions(recorderOptions);
int result = 0;
if (!mpeg2 && !build_index)
/* if (!mpeg2 && !build_index)
{
result = transcode->TranscodeFile(infile, outfile,
profilename, useCutlist,
Expand All @@ -666,7 +654,7 @@ int main(int argc, char *argv[])
passthru);
if ((result == REENCODE_OK) && gJob)
gJob->saveArgs("RENAME_TO_NUV");
}
}*/

int exitcode = GENERIC_EXIT_OK;
if ((result == REENCODE_MPEG2TRANS) || mpeg2 || build_index)
Expand All @@ -675,7 +663,7 @@ int main(int argc, char *argv[])
int (*check_func)() = NULL;
if (useCutlist && !found_infile)
pginfo->QueryCutList(deleteMap);
if (gJob->isValid())
if (gJob)
{
update_func = &UpdateJobQueue;
check_func = &CheckJobQueue;
Expand Down Expand Up @@ -718,37 +706,37 @@ int main(int argc, char *argv[])

if (result == REENCODE_OK)
{
if (gJob->isValid())
if (gJob)
gJob->saveStatus(JOB_STOPPING);
VERBOSE(VB_GENERAL, QString("%1 %2 done")
.arg(build_index ? "Building Index for" : "Transcoding")
.arg(infile));
}
else if (result == REENCODE_CUTLIST_CHANGE)
{
if (gJob->isValid())
if (gJob)
gJob->saveStatus(JOB_RETRY);
VERBOSE(VB_GENERAL, QString("Transcoding %1 aborted because of "
"cutlist update").arg(infile));
exitcode = GENERIC_EXIT_RESTART;
}
else if (result == REENCODE_STOPPED)
{
if (gJob->isValid())
if (gJob)
gJob->saveStatus(JOB_ABORTING);
VERBOSE(VB_GENERAL, QString("Transcoding %1 stopped because of "
"stop command").arg(infile));
exitcode = GENERIC_EXIT_KILLED;
}
else
{
if (gJob->isValid())
if (gJob)
gJob->saveStatus(JOB_ERRORING);
VERBOSE(VB_GENERAL, QString("Transcoding %1 failed").arg(infile));
exitcode = result;
}

if (gJob->isValid())
if (gJob)
CompleteJob(jobID, pginfo, useCutlist, &deleteMap, exitcode);

transcode->deleteLater();
Expand Down Expand Up @@ -896,7 +884,7 @@ static void CompleteJob(int jobID, ProgramInfo *pginfo, bool useCutlist,
ComputeNewBookmark(ReloadBookmark(pginfo), deleteMap);
pginfo->SaveBookmark(previousBookmark);

const QString jobArgs = gJob->getArgs();
// const QString jobArgs = gJob->getArgs();

const QString tmpfile = filename + ".tmp";
const QByteArray atmpfile = tmpfile.toLocal8Bit();
Expand All @@ -911,15 +899,15 @@ static void CompleteJob(int jobID, ProgramInfo *pginfo, bool useCutlist,
newSize = st.size();

QString cnf = filename;
if ((jobArgs == "RENAME_TO_NUV") &&
/* if ((jobArgs == "RENAME_TO_NUV") &&
(filename.contains(QRegExp("mpg$"))))
{
QString newbase = pginfo->QueryBasename();
cnf.replace(QRegExp("mpg$"), "nuv");
newbase.replace(QRegExp("mpg$"), "nuv");
pginfo->SaveBasename(newbase);
}
}*/

const QString newfile = cnf;
const QByteArray anewfile = newfile.toLocal8Bit();
Expand Down Expand Up @@ -1007,7 +995,7 @@ static void CompleteJob(int jobID, ProgramInfo *pginfo, bool useCutlist,
}

/* Rename all preview thumbnails. */
if (jobArgs == "RENAME_TO_NUV")
/* if (jobArgs == "RENAME_TO_NUV")
{
QFileInfo fInfo(filename);
QString nameFilter = fInfo.fileName() + "*.png";
Expand Down Expand Up @@ -1038,7 +1026,7 @@ static void CompleteJob(int jobID, ProgramInfo *pginfo, bool useCutlist,
if ((oldfileprev != newfileprev) && (checkFile.exists()))
rename(aoldfileprev.constData(), anewfileprev.constData());
}
}
}*/

MSqlQuery query(MSqlQuery::InitCon());

Expand Down

0 comments on commit 25b4a38

Please sign in to comment.