Exemple #1
0
        public virtual bool setup(Job job, out string error)
        {
            if (!(job is VideoJob))
            {
                throw new Exception("Setup was called on a non-video job");
            }
            VideoJob vJob = (VideoJob)job;

            if (vJob.Settings is x264Settings)
            {
                encoder = new x264Encoder(settings.X264Path);
            }
            else if (vJob.Settings is xvidSettings)
            {
                encoder = new XviDEncoder(settings.XviDEncrawPath);
            }
            else
            {
                encoder = new mencoderEncoder(settings.MencoderPath);
            }
            error = null;
            return(encoder.setup(job, out error));
        }
        /// <summary>
        /// starts the job provided as parameters
        /// </summary>
        /// <param name="job">the Job object containing all the parameters</param>
        /// <returns>success / failure indicator</returns>
        private bool startEncoding(TaggedJob job)
        {
            try
            {
                log = mainForm.Log.Info(string.Format("Log for {0} ({1}, {2} -> {3})", job.Name, job.Job.EncodingMode, job.InputFileName, job.OutputFileName));
                log.LogEvent("Started handling job");
                log.Expand();

                status = JobWorkerStatus.Running;
                //Check to see if output file already exists before encoding.
                if (File.Exists(job.Job.Output) && !mainForm.DialogManager.overwriteJobOutput(job.Job.Output))
                {
                    throw new JobStartException("File exists and the user doesn't want to overwrite", ExceptionType.UserSkip);
                }

                // Get IJobProcessor
                currentProcessor = getProcessor(job.Job);
                if (currentProcessor == null)
                {
                    throw new JobStartException("No processor could be found", ExceptionType.Error);
                }


                // Preprocess
                preprocessJob(job.Job);

                // Setup
                try
                {
                    currentProcessor.setup(job.Job, new StatusUpdate(job.Name), log);
                }
                catch (JobRunException e)
                {
                    throw new JobStartException("Calling setup of processor failed with error '" + e.Message + "'", ExceptionType.Error);
                }

                // Do JobControl setup
                currentProcessor.StatusUpdate += new JobProcessingStatusUpdateCallback(UpdateGUIStatus);

                // Progress window
                pw.setPriority(mainForm.Settings.DefaultPriority);
                if (mainForm.Settings.OpenProgressWindow && mainForm.Visible)
                {
                    this.ShowProcessWindow();
                }

                job.Status  = JobStatus.PROCESSING;
                job.Start   = DateTime.Now;
                status      = JobWorkerStatus.Running;
                pauseStatus = PauseState.Encoding;
                currentJob  = job;

                // Start
                try
                {
                    currentProcessor.start();
                }
                catch (JobRunException e)
                {
                    throw new JobStartException("starting encoder failed with error '" + e.Message + "'", ExceptionType.Error);
                }

                log.LogEvent("Encoding started");
                refreshAll();
                return(true);
            }
            catch (JobStartException e)
            {
                mainForm.Log.LogValue("Error starting job", e);
                if (e.type == ExceptionType.Error)
                {
                    job.Status = JobStatus.ERROR;
                }
                else // ExceptionType.UserSkip
                {
                    job.Status = JobStatus.SKIP;
                }
                currentProcessor = null;
                currentJob       = null;
                status           = JobWorkerStatus.Idle;
                pauseStatus      = PauseState.NotEncoding;
                refreshAll();
                return(false);
            }
        }
        /// <summary>
        /// starts the job provided as parameters
        /// </summary>
        /// <param name="job">the Job object containing all the parameters</param>
        /// <returns>success / failure indicator</returns>
        private bool startEncoding(TaggedJob job)
        {
            try
            {
                status = JobWorkerStatus.Running;
                //Check to see if output file already exists before encoding.
                if (File.Exists(job.Job.Output) && !mainForm.DialogManager.overwriteJobOutput(job.Job.Output))
                {
                    throw new JobStartException("File exists and the user doesn't want to overwrite", ExceptionType.UserSkip);
                }

                // Get IJobProcessor
                currentProcessor = getProcessor(job.Job);
                if (currentProcessor == null)
                {
                    throw new JobStartException("No processor could be found", ExceptionType.Error);
                }

                addToLog("\r\n\r\n------------------------------------------------------\r\n\r\n");
                addToLog("Starting job " + job.Name + " at " + DateTime.Now.ToLongTimeString() + "\r\n");

                // Preprocess
                preprocessJob(job.Job);

                // Setup
                try
                {
                    currentProcessor.setup(job.Job, new StatusUpdate(job.Name));
                }
                catch (JobRunException e)
                {
                    throw new JobStartException("Calling setup of processor failed with error '" + e.Message + "'", ExceptionType.Error);
                }

                // Do JobControl setup
                //addToLog("encoder commandline:\r\n" + job.Commandline + "\r\n");
                currentProcessor.StatusUpdate += new JobProcessingStatusUpdateCallback(UpdateGUIStatus);

                // Progress window
                pw.setPriority(mainForm.Settings.DefaultPriority);
                if (mainForm.Settings.OpenProgressWindow && mainForm.Visible)
                {
                    this.ShowProcessWindow();
                }

                job.Status  = JobStatus.PROCESSING;
                job.Start   = DateTime.Now;
                status      = JobWorkerStatus.Running;
                pauseStatus = PauseState.Encoding;
                currentJob  = job;

                // Start
                try
                {
                    currentProcessor.start();
                }
                catch (JobRunException e)
                {
                    throw new JobStartException("starting encoder failed with error '" + e.Message + "'", ExceptionType.Error);
                }

                addToLog("successfully started encoding\r\n");
                refreshAll();
                return(true);
            }
            catch (JobStartException e)
            {
                addToLog("Job not started. Reason: " + e.Message + "\r\n");
                if (e.type == ExceptionType.Error)
                {
                    job.Status = JobStatus.ERROR;
                }
                else // ExceptionType.UserSkip
                {
                    job.Status = JobStatus.SKIP;
                }
                currentProcessor = null;
                currentJob       = null;
                status           = JobWorkerStatus.Idle;
                pauseStatus      = PauseState.NotEncoding;
                refreshAll();
                return(false);
            }
        }
Exemple #4
0
        /// <summary>
        /// starts the job provided as parameters
        /// </summary>
        /// <param name="job">the Job object containing all the parameters</param>
        /// <returns>success / failure indicator</returns>
        private bool startEncoding(Job job)
        {
            Debug.Assert(status == JobWorkerStatus.Idle);

            try
            {
                //Check to see if output file already exists before encoding.
                if (File.Exists(job.Output) && !mainForm.DialogManager.overwriteJobOutput(job.Output))
                    throw new JobStartException("File exists and the user doesn't want to overwrite", ExceptionType.UserSkip);

                // Get IJobProcessor
                currentProcessor = getProcessor(job);
                if (currentProcessor == null)
                    throw new JobStartException("No processor could be found", ExceptionType.Error);

                addToLog("\r\n\r\n------------------------------------------------------\r\n\r\n");
                addToLog("Starting job " + job.Name + " at " + DateTime.Now.ToLongTimeString() + "\r\n");

                // Preprocess
                preprocessJob(job);

                // Setup
                try
                {
                    currentProcessor.setup(job);
                }
                catch (JobRunException e)
                {
                    throw new JobStartException("Calling setup of processor failed with error '" + e.Message + "'", ExceptionType.Error);
                }

                // Do JobControl setup
                addToLog("encoder commandline:\r\n" + job.Commandline + "\r\n");
                currentProcessor.StatusUpdate += new JobProcessingStatusUpdateCallback(UpdateGUIStatus);

                // Progress window
                pw = new ProgressWindow(job.JobType);
                pw.WindowClosed += new WindowClosedCallback(pw_WindowClosed);
                pw.Abort += new AbortCallback(pw_Abort);
                pw.setPriority(job.Priority);
                pw.PriorityChanged += new PriorityChangedCallback(pw_PriorityChanged);
                if (mainForm.Settings.OpenProgressWindow && mainForm.Visible)
                    pw.Show();

                job.Status = JobStatus.PROCESSING;
                job.Start = DateTime.Now;
                status = JobWorkerStatus.Running;
                pauseStatus = PauseState.Encoding;
                currentJob = job;

                // Start
                try
                {
                    currentProcessor.start();
                }
                catch (JobRunException e)
                {
                    throw new JobStartException("starting encoder failed with error '" + e.Message +"'", ExceptionType.Error);
                }

                addToLog("successfully started encoding\r\n");

                refreshAll();
                return true;
            }
            catch (JobStartException e)
            {
                addToLog("Job not started. Reason: " + e.Message + "\r\n");
                if (e.type == ExceptionType.Error)
                    job.Status = JobStatus.ERROR;
                else // ExceptionType.UserSkip
                    job.Status = JobStatus.SKIP;
                currentProcessor = null;
                currentJob = null;
                status = JobWorkerStatus.Idle;
                pauseStatus = PauseState.NotEncoding;
                refreshAll();
                return false;
            }
        }
Exemple #5
0
        /// <summary>
        /// starts the job provided as parameters
        /// </summary>
        /// <param name="job">the Job object containing all the parameters</param>
        /// <returns>success / failure indicator</returns>
        private bool StartEncoding(TaggedJob job)
        {
            try
            {
                log = mainForm.Log.Info(string.Format("Log for {0} ({1}, {2} -> {3})", job.Name, job.Job.EncodingMode, job.InputFileName, job.OutputFileName));
                log.LogEvent("Started handling job");
                log.Expand();

                //Check to see if output file already exists before encoding.
                if (File.Exists(job.Job.Output) &&
                    (!Path.GetExtension(job.Job.Output).Equals(".lwi") && !Path.GetExtension(job.Job.Output).Equals(".ffindex") &&
                     !Path.GetExtension(job.Job.Output).Equals(".d2v") &&
                     !Path.GetExtension(job.Job.Output).Equals(".dgi")) && !mainForm.DialogManager.overwriteJobOutput(job.Job.Output))
                {
                    throw new JobStartException("File exists and the user doesn't want to overwrite", ExceptionType.UserSkip);
                }

                // Get IJobProcessor
                currentProcessor = GetProcessor(job.Job);
                if (currentProcessor == null)
                {
                    throw new JobStartException("No processor could be found", ExceptionType.Error);
                }

                // Preprocess
                PreprocessJob(job.Job);

                // Setup
                try
                {
                    currentProcessor.setup(job.Job, new StatusUpdate(job.Name), log);
                }
                catch (JobRunException e)
                {
                    throw new JobStartException("Calling setup of processor failed with error '" + e.Message + "'", ExceptionType.Error);
                }

                if (currentProcessor == null)
                {
                    throw new JobStartException("starting job failed", ExceptionType.Error);
                }

                // Do JobControl setup
                currentProcessor.StatusUpdate += new JobProcessingStatusUpdateCallback(UpdateGUIStatus);

                // Progress window
                WorkerPriority.GetJobPriority(job.Job, out WorkerPriorityType oPriority, out bool lowIOPriority);
                pw.setPriority(oPriority);
                if (mainForm.Settings.OpenProgressWindow && mainForm.Visible)
                {
                    this.ShowProcessWindow();
                }

                job.Start  = DateTime.Now;
                currentJob = job;

                // Start
                try
                {
                    currentProcessor.start();
                }
                catch (JobRunException e)
                {
                    throw new JobStartException("starting job failed with error '" + e.Message + "'", ExceptionType.Error);
                }

                RefreshAll();
                MeGUI.core.util.WindowUtil.PreventSystemPowerdown();
                return(true);
            }
            catch (JobStartException e)
            {
                this.HideProcessWindow();
                log.LogValue("Error starting job", e);
                if (e.type == ExceptionType.Error)
                {
                    job.Status = JobStatus.ERROR;
                }
                else // ExceptionType.UserSkip
                {
                    job.Status = JobStatus.SKIP;
                }
                currentProcessor = null;
                currentJob       = null;
                RefreshAll();
                return(false);
            }
        }