-from Components.Task import Task, Job, job_manager, DiskspacePrecondition, Condition
+from Components.Task import Task, Job, job_manager, DiskspacePrecondition, Condition, ToolExistsPrecondition
from Screens.MessageBox import MessageBox
class png2yuvTask(Task):
def run(self, callback, task_progress_changed):
Task.run(self, callback, task_progress_changed)
+ self.container.stdoutAvail.get().remove(self.processStdout)
self.container.dumpToFile(self.dumpFile)
def processStderr(self, data):
- print "[png2yuvTask]", data
-
- def processStdout(self, data):
- pass
+ print "[png2yuvTask]", data[:-1]
class mpeg2encTask(Task):
def __init__(self, job, inputfile, outputfile):
self.container.readFromFile(self.inputFile)
def processOutputLine(self, line):
- print "[mpeg2encTask]", line
+ print "[mpeg2encTask]", line[:-1]
class spumuxTask(Task):
def __init__(self, job, xmlfile, inputfile, outputfile):
def run(self, callback, task_progress_changed):
Task.run(self, callback, task_progress_changed)
+ self.container.stdoutAvail.get().remove(self.processStdout)
self.container.dumpToFile(self.dumpFile)
self.container.readFromFile(self.inputFile)
def processStderr(self, data):
- print "[spumuxTask]", data
-
- def processStdout(self, data):
- pass
+ print "[spumuxTask]", data[:-1]
class MakeFifoNode(Task):
def __init__(self, job, number):
self.generated_files.append(file)
def haveProgress(self, progress):
- print "PROGRESS [%s]" % progress
+ #print "PROGRESS [%s]" % progress
MSG_CHECK = "check & synchronize audio file"
MSG_DONE = "done..."
if progress == "preparing collection(s)...":
for f in self.generated_files:
os.remove(f)
+class MplexTaskPostcondition(Condition):
+ def check(self, task):
+ if task.error == task.ERROR_UNDERRUN:
+ return True
+ return task.error is None
+
+ def getErrorMessage(self, task):
+ print "[MplexTaskPostcondition] getErrorMessage", task
+ return {
+ task.ERROR_UNDERRUN: ("Can't multiplex source video!"),
+ task.ERROR_UNKNOWN: ("An unknown error occured!")
+ }[task.error]
+
class MplexTask(Task):
+ ERROR_UNDERRUN, ERROR_UNKNOWN = range(2)
def __init__(self, job, outputfile, inputfiles=None, demux_task=None):
Task.__init__(self, job, "Mux ES into PS")
self.weighting = 500
self.demux_task = demux_task
+ self.postconditions.append(MplexTaskPostcondition())
self.setTool("/usr/bin/mplex")
self.args += ["-f8", "-o", outputfile, "-v1"]
if inputfiles:
self.args += inputfiles
+ def setTool(self, tool):
+ self.cmd = tool
+ self.args = [tool]
+ self.global_preconditions.append(ToolExistsPrecondition())
+ # we don't want the ReturncodePostcondition in this case because for right now we're just gonna ignore the fact that mplex fails with a buffer underrun error on some streams (this always at the very end)
+
def prepare(self):
+ self.error = None
if self.demux_task:
self.args += self.demux_task.generated_files
def processOutputLine(self, line):
- print "[MplexTask] processOutputLine=", line
+ print "[MplexTask] processOutputLine=", line[:-1]
+ if line.startswith("**ERROR:"):
+ if line.find("Frame data under-runs detected") != -1:
+ self.error = self.ERROR_UNDERRUN
+ else:
+ self.error = self.ERROR_UNKNOWN
class RemoveESFiles(Task):
def __init__(self, job, demux_task):
self.menupreview = job.menupreview
def processOutputLine(self, line):
- print "[DVDAuthorTask] processOutputLine=", line
+ print "[DVDAuthorTask] processOutputLine=", line[:-1]
if not self.menupreview and line.startswith("STAT: Processing"):
self.callback(self, [], stay_resident=True)
callback(self, [])
class BurnTaskPostcondition(Condition):
+ RECOVERABLE = True
def check(self, task):
return task.error is None