예제 #1
0
        /// <summary>
        /// Start a scan for a given source path and title
        /// </summary>
        /// <param name="sourcePath">
        /// Path to the source file
        /// </param>
        /// <param name="title">
        /// the title number to look at
        /// </param>
        /// <param name="previewCount">
        /// The preview Count.
        /// </param>
        private void ScanSource(object sourcePath, int title, int previewCount)
        {
            try
            {
                this.logging.Clear();

                string source = sourcePath.ToString().EndsWith("\\") ? string.Format("\"{0}\\\\\"", sourcePath.ToString().TrimEnd('\\'))
                              : "\"" + sourcePath + "\"";
                currentSourceScanPath = source;

                IsScanning = true;
                if (this.ScanStared != null)
                {
                    this.ScanStared(this, new EventArgs());
                }

                if (title != 0)
                {
                    instance.StartScan(sourcePath.ToString(), previewCount, title);
                }
                else
                {
                    instance.StartScan(sourcePath.ToString(), previewCount);
                }
            }
            catch (Exception exc)
            {
                this.Stop();

                if (this.ScanCompleted != null)
                {
                    this.ScanCompleted(this, new ScanCompletedEventArgs(false, exc, "An Error has occured in ScanService.ScanSource()"));
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Start with a LibHb EncodeJob Object
        /// </summary>
        /// <param name="job">
        /// The job.
        /// </param>
        public void Start(QueueTask job)
        {
            // Setup
            this.startTime      = DateTime.Now;
            this.loggingEnabled = job.Configuration.IsLoggingEnabled;
            this.currentTask    = job;

            // Create a new HandBrake instance
            // Setup the HandBrake Instance
            instance = new HandBrakeInstance();
            instance.Initialize(1);
            instance.EncodeCompleted += this.InstanceEncodeCompleted;
            instance.EncodeProgress  += this.InstanceEncodeProgress;

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

                this.IsEncoding = true;

                // Enable logging if required.
                if (job.Configuration.IsLoggingEnabled)
                {
                    try
                    {
                        this.SetupLogging(job);
                    }
                    catch (Exception)
                    {
                        this.IsEncoding = false;
                        throw;
                    }
                }

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

                // We have to scan the source again but only the title so the HandBrake instance is initialised correctly.
                // Since the UI sends the crop params down, we don't have to do all the previews.
                instance.StartScan(job.Task.Source, 1, job.Task.Title);

                instance.ScanCompleted += delegate
                {
                    ScanCompleted(job, instance);
                };
            }
            catch (Exception exc)
            {
                this.InvokeEncodeCompleted(new EncodeCompletedEventArgs(false, exc, "An Error has occured.", this.currentTask.Task.Destination));
            }
        }
예제 #3
0
        /// <summary>
        /// Start with a LibHb EncodeJob Object
        /// </summary>
        /// <param name="job">
        /// The job.
        /// </param>
        public void Start(QueueTask job)
        {
            // Setup
            this.startTime = DateTime.Now;
            this.loggingEnabled = job.Configuration.IsLoggingEnabled;
            this.currentTask = job;

            // Create a new HandBrake instance
            // Setup the HandBrake Instance
            instance = new HandBrakeInstance();
            instance.Initialize(1);
            instance.EncodeCompleted += this.InstanceEncodeCompleted;
            instance.EncodeProgress += this.InstanceEncodeProgress;

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

                this.IsEncoding = true;

                // Enable logging if required.
                if (job.Configuration.IsLoggingEnabled)
                {
                    try
                    {
                        this.SetupLogging(job);
                    }
                    catch (Exception)
                    {
                        this.IsEncoding = false;
                        throw;
                    }
                }

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

                // We have to scan the source again but only the title so the HandBrake instance is initialised correctly.
                // Since the UI sends the crop params down, we don't have to do all the previews.
                instance.StartScan(job.Task.Source, job.Configuration.PreviewScanCount, job.Task.Title);

                instance.ScanCompleted += delegate
                    {
                        ScanCompleted(job, instance);
                    };
            }
            catch (Exception exc)
            {
                this.InvokeEncodeCompleted(new EncodeCompletedEventArgs(false, exc, "An Error has occured.", this.currentTask.Task.Destination));
            }
        }