Ejemplo n.º 1
0
        /// <summary>
        /// The scan completed.
        /// </summary>
        /// <param name="job">
        /// The job.
        /// </param>
        /// <param name="instance">
        /// The instance.
        /// </param>
        private void ScanCompleted(QueueTask job, IHandBrakeInstance instance)
        {
            // Get an EncodeJob object for the Interop Library
            EncodeJob encodeJob = InteropModelCreator.GetEncodeJob(job);

            // Start the Encode
            instance.StartEncode(encodeJob);

            // Fire the Encode Started Event
            this.InvokeEncodeStarted(EventArgs.Empty);

            // Set the Process Priority
            switch (job.Configuration.ProcessPriority)
            {
            case "Realtime":
                Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime;
                break;

            case "High":
                Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;
                break;

            case "Above Normal":
                Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.AboveNormal;
                break;

            case "Normal":
                Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal;
                break;

            case "Low":
                Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Idle;
                break;

            default:
                Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.BelowNormal;
                break;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The scan completed.
        /// </summary>
        /// <param name="job">
        /// The job.
        /// </param>
        /// <param name="instance">
        /// The instance.
        /// </param>
        private void ScanCompleted(QueueTask job, IHandBrakeInstance instance)
        {
            // Get an EncodeJob object for the Interop Library
            EncodeJob encodeJob = InteropModelCreator.GetEncodeJob(job);

            // Start the Encode
            instance.StartEncode(encodeJob, job.Configuration.PreviewScanCount);

            // Fire the Encode Started Event
            this.InvokeEncodeStarted(EventArgs.Empty);

            // Set the Process Priority
            switch (job.Configuration.ProcessPriority)
            {
                case "Realtime":
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime;
                    break;
                case "High":
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;
                    break;
                case "Above Normal":
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.AboveNormal;
                    break;
                case "Normal":
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal;
                    break;
                case "Low":
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Idle;
                    break;
                default:
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.BelowNormal;
                    break;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Start with a LibHb EncodeJob Object
        /// </summary>
        /// <param name="task">
        /// The task.
        /// </param>
        /// <param name="configuration">
        /// The configuration.
        /// </param>
        public void Start(EncodeTask task, HBConfiguration configuration)
        {
            try
            {
                // Setup
                this.startTime = DateTime.Now;
                this.currentTask = task;
                this.currentConfiguration = configuration;

                // Create a new HandBrake instance
                // Setup the HandBrake Instance
                HandBrakeUtils.MessageLogged += this.HandBrakeInstanceMessageLogged;
                HandBrakeUtils.ErrorLogged += this.HandBrakeInstanceErrorLogged;
                this.instance = HandBrakeInstanceManager.GetEncodeInstance(configuration.Verbosity);
                this.instance.EncodeCompleted += this.InstanceEncodeCompleted;
                this.instance.EncodeProgress += this.InstanceEncodeProgress;

                // Sanity Checking and Setup
                if (this.IsEncoding)
                {
                    throw new Exception("HandBrake is already encoding.");
                }

                this.IsEncoding = true;
                this.SetupLogging();

                // Verify the Destination Path Exists, and if not, create it.
                this.VerifyEncodeDestinationPath(task);

                ServiceLogMessage("Starting Encode ...");

                // Get an EncodeJob object for the Interop Library
                instance.StartEncode(EncodeFactory.Create(task, configuration));

                // Fire the Encode Started Event
                this.InvokeEncodeStarted(System.EventArgs.Empty);

                // Set the Process Priority
                switch (configuration.ProcessPriority)
                {
                    case "Realtime":
                        Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime;
                        break;
                    case "High":
                        Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;
                        break;
                    case "Above Normal":
                        Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.AboveNormal;
                        break;
                    case "Normal":
                        Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal;
                        break;
                    case "Low":
                        Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Idle;
                        break;
                    default:
                        Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.BelowNormal;
                        break;
                }
            }
            catch (Exception exc)
            {
                this.IsEncoding = false;

                ServiceLogMessage("Failed to start encoding ..." + Environment.NewLine + exc);
                this.InvokeEncodeCompleted(new EventArgs.EncodeCompletedEventArgs(false, exc, "Unable to start encoding", task.Source));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// The scan completed.
        /// </summary>
        /// <param name="job">
        /// The job.
        /// </param>
        /// <param name="instance">
        /// The instance.
        /// </param>
        private void ScanCompleted(QueueTask job, IHandBrakeInstance instance)
        {
            ServiceLogMessage("Scan Completed. Setting up the job for encoding ...");

            // Get an EncodeJob object for the Interop Library
            EncodeJob encodeJob = InteropModelCreator.GetEncodeJob(job);

            // Start the Encode
            Title title = this.scannedSource.Titles.FirstOrDefault(t => t.TitleNumber == job.Task.Title);

            if (title == null)
            {
                ServiceLogMessage("Title not found.");
                throw new Exception("Unable to get title for encoding. Encode Failed.");
            }

            Interop.Model.Scan.Title scannedTitle = new Interop.Model.Scan.Title
            {
                Resolution           = new Size(title.Resolution.Width, title.Resolution.Height),
                ParVal               = new Size(title.ParVal.Width, title.ParVal.Height),
                FramerateDenominator = title.FramerateDenominator,
                FramerateNumerator   = title.FramerateNumerator,
            };

            // TODO fix this tempory hack to pass in the required title information into the factory.
            try
            {
                ServiceLogMessage("Starting Encode ...");
                instance.StartEncode(encodeJob, scannedTitle);
            }
            catch (Exception exc)
            {
                ServiceLogMessage("Failed to start encoding ..." + Environment.NewLine + exc);
                this.InvokeEncodeCompleted(new EventArgs.EncodeCompletedEventArgs(false, exc, "Unable to start encoding", job.Task.Source));
            }

            // Fire the Encode Started Event
            this.InvokeEncodeStarted(System.EventArgs.Empty);

            // Set the Process Priority
            switch (job.Configuration.ProcessPriority)
            {
            case "Realtime":
                Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime;
                break;

            case "High":
                Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;
                break;

            case "Above Normal":
                Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.AboveNormal;
                break;

            case "Normal":
                Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal;
                break;

            case "Low":
                Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Idle;
                break;

            default:
                Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.BelowNormal;
                break;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Start with a LibHb EncodeJob Object
        /// </summary>
        /// <param name="task">
        /// The task.
        /// </param>
        /// <param name="configuration">
        /// The configuration.
        /// </param>
        public void Start(EncodeTask task, HBConfiguration configuration)
        {
            try
            {
                // Setup
                this.startTime            = DateTime.Now;
                this.currentTask          = task;
                this.currentConfiguration = configuration;

                // Create a new HandBrake instance
                // Setup the HandBrake Instance
                HandBrakeUtils.MessageLogged += this.HandBrakeInstanceMessageLogged;
                HandBrakeUtils.ErrorLogged   += this.HandBrakeInstanceErrorLogged;
                this.instance = HandBrakeInstanceManager.GetEncodeInstance(configuration.Verbosity);
                this.instance.EncodeCompleted += this.InstanceEncodeCompleted;
                this.instance.EncodeProgress  += this.InstanceEncodeProgress;

                // Sanity Checking and Setup
                if (this.IsEncoding)
                {
                    throw new Exception("HandBrake is already encoding.");
                }

                this.IsEncoding = true;
                this.SetupLogging();

                // Verify the Destination Path Exists, and if not, create it.
                this.VerifyEncodeDestinationPath(task);

                ServiceLogMessage("Starting Encode ...");

                // Get an EncodeJob object for the Interop Library
                instance.StartEncode(EncodeFactory.Create(task, configuration));

                // Fire the Encode Started Event
                this.InvokeEncodeStarted(System.EventArgs.Empty);

                // Set the Process Priority
                switch (configuration.ProcessPriority)
                {
                case "Realtime":
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime;
                    break;

                case "High":
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;
                    break;

                case "Above Normal":
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.AboveNormal;
                    break;

                case "Normal":
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal;
                    break;

                case "Low":
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Idle;
                    break;

                default:
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.BelowNormal;
                    break;
                }
            }
            catch (Exception exc)
            {
                this.IsEncoding = false;

                ServiceLogMessage("Failed to start encoding ..." + Environment.NewLine + exc);
                this.InvokeEncodeCompleted(new EventArgs.EncodeCompletedEventArgs(false, exc, "Unable to start encoding", task.Source));
            }
        }