summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.ApplicationServices/Services
diff options
context:
space:
mode:
authorsr55 <[email protected]>2014-11-29 18:36:54 +0000
committersr55 <[email protected]>2014-11-29 18:36:54 +0000
commit0e8fddb81113a16689bb5c26a5844cb0c1260cec (patch)
treeeda41ed99656ba86d225ec43802f7891e6d8436a /win/CS/HandBrake.ApplicationServices/Services
parent7c0af498a9d5f7aae1e5c8d06b939c8189edcfbe (diff)
WinGui: Part 1 - Restructuring the AppServices library in preparation for the new JSON API. Taking the opportunity to improve and simplify the API.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6568 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Services')
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs (renamed from win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs)14
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeService.cs (renamed from win/CS/HandBrake.ApplicationServices/Services/Encode.cs)31
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode/EventArgs/EncodeCompletedEventArgs.cs68
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode/EventArgs/EncodeProgressEventArgs.cs63
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode/Interfaces/IEncode.cs (renamed from win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs)4
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode/Interfaces/IEncodeServiceWrapper.cs (renamed from win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncodeServiceWrapper.cs)2
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs (renamed from win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs)25
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Interfaces/IHbServiceCallback.cs2
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Interfaces/IQueueProcessor.cs1
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs2
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Scan/EventArgs/ScanCompletedEventArgs.cs65
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Scan/EventArgs/ScanProgressEventArgs.cs39
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Scan/Interfaces/IScan.cs (renamed from win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs)6
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs (renamed from win/CS/HandBrake.ApplicationServices/Services/LibScan.cs)72
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Audio.cs181
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Chapter.cs70
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Source.cs55
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Subtitle.cs206
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Title.cs145
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/ServerService.cs6
20 files changed, 974 insertions, 83 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs
index d5ee86555..a805a714b 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs
@@ -7,7 +7,7 @@
// </summary>
// --------------------------------------------------------------------------------------------------------------------
-namespace HandBrake.ApplicationServices.Services.Base
+namespace HandBrake.ApplicationServices.Services.Encode
{
using System;
using System.Globalization;
@@ -15,10 +15,10 @@ namespace HandBrake.ApplicationServices.Services.Base
using System.Text;
using System.Text.RegularExpressions;
- using HandBrake.ApplicationServices.EventArgs;
using HandBrake.ApplicationServices.Exceptions;
using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Services.Interfaces;
+ using HandBrake.ApplicationServices.Services.Encode.EventArgs;
+ using HandBrake.ApplicationServices.Services.Encode.Interfaces;
using HandBrake.ApplicationServices.Utilities;
/// <summary>
@@ -56,7 +56,7 @@ namespace HandBrake.ApplicationServices.Services.Base
public EncodeBase()
{
this.logBuffer = new StringBuilder();
- header = GeneralUtilities.CreateCliLogHeader();
+ this.header = GeneralUtilities.CreateCliLogHeader();
this.LogIndex = 0;
}
@@ -158,7 +158,7 @@ namespace HandBrake.ApplicationServices.Services.Base
/// <param name="e">
/// The EventArgs.
/// </param>
- public void InvokeEncodeStarted(EventArgs e)
+ public void InvokeEncodeStarted(System.EventArgs e)
{
EventHandler handler = this.EncodeStarted;
if (handler != null)
@@ -304,7 +304,7 @@ namespace HandBrake.ApplicationServices.Services.Base
/// </param>
protected void SetupLogging(QueueTask encodeQueueTask)
{
- ShutdownFileWriter();
+ this.ShutdownFileWriter();
string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";
string logFile = Path.Combine(logDir, string.Format("last_encode_log{0}.txt", GeneralUtilities.ProcessId));
string logFile2 = Path.Combine(logDir, string.Format("tmp_appReadable_log{0}.txt", GeneralUtilities.ProcessId));
@@ -328,7 +328,7 @@ namespace HandBrake.ApplicationServices.Services.Base
}
this.fileWriter = new StreamWriter(logFile) { AutoFlush = true };
- this.fileWriter.WriteLine(header);
+ this.fileWriter.WriteLine(this.header);
this.fileWriter.WriteLine(string.Format("CLI Query: {0}", query));
this.fileWriter.WriteLine();
}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeService.cs
index 318902c91..dad5b9597 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeService.cs
@@ -1,5 +1,5 @@
// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="Encode.cs" company="HandBrake Project (http://handbrake.fr)">
+// <copyright file="EncodeService.cs" company="HandBrake Project (http://handbrake.fr)">
// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
// </copyright>
// <summary>
@@ -7,24 +7,23 @@
// </summary>
// --------------------------------------------------------------------------------------------------------------------
-namespace HandBrake.ApplicationServices.Services
+namespace HandBrake.ApplicationServices.Services.Encode
{
using System;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
- using HandBrake.ApplicationServices.EventArgs;
using HandBrake.ApplicationServices.Exceptions;
using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Services.Base;
- using HandBrake.ApplicationServices.Services.Interfaces;
+ using HandBrake.ApplicationServices.Services.Encode.EventArgs;
+ using HandBrake.ApplicationServices.Services.Encode.Interfaces;
using HandBrake.ApplicationServices.Utilities;
/// <summary>
/// Class which handles the CLI
/// </summary>
- public class Encode : EncodeBase, IEncode
+ public class EncodeService : EncodeBase, IEncode
{
#region Private Variables
@@ -100,7 +99,7 @@ namespace HandBrake.ApplicationServices.Services
{
try
{
- this.SetupLogging(currentTask);
+ this.SetupLogging(this.currentTask);
}
catch (Exception)
{
@@ -110,7 +109,7 @@ namespace HandBrake.ApplicationServices.Services
}
// Make sure the path exists, attempt to create it if it doesn't
- this.VerifyEncodeDestinationPath(currentTask);
+ this.VerifyEncodeDestinationPath(this.currentTask);
string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");
@@ -143,7 +142,7 @@ namespace HandBrake.ApplicationServices.Services
this.HbProcess.BeginErrorReadLine();
}
- this.HbProcess.OutputDataReceived += HbProcess_OutputDataReceived;
+ this.HbProcess.OutputDataReceived += this.HbProcess_OutputDataReceived;
this.HbProcess.BeginOutputReadLine();
this.processId = this.HbProcess.Id;
@@ -179,7 +178,7 @@ namespace HandBrake.ApplicationServices.Services
}
// Fire the Encode Started Event
- this.InvokeEncodeStarted(EventArgs.Empty);
+ this.InvokeEncodeStarted(System.EventArgs.Empty);
}
catch (Exception exc)
{
@@ -253,9 +252,9 @@ namespace HandBrake.ApplicationServices.Services
/// <param name="e">
/// The EventArgs.
/// </param>
- private void HbProcessExited(object sender, EventArgs e)
+ private void HbProcessExited(object sender, System.EventArgs e)
{
- HbProcess.WaitForExit();
+ this.HbProcess.WaitForExit();
try
{
@@ -289,15 +288,15 @@ namespace HandBrake.ApplicationServices.Services
{
if (!String.IsNullOrEmpty(e.Data))
{
- if (initShutdown && this.LogBuffer.Length < 25000000)
+ if (this.initShutdown && this.LogBuffer.Length < 25000000)
{
- initShutdown = false; // Reset this flag.
+ this.initShutdown = false; // Reset this flag.
}
- if (this.LogBuffer.Length > 25000000 && !initShutdown) // Approx 23.8MB and make sure it's only printed once
+ if (this.LogBuffer.Length > 25000000 && !this.initShutdown) // Approx 23.8MB and make sure it's only printed once
{
this.ProcessLogMessage("ERROR: Initiating automatic shutdown of encode process. The size of the log file indicates that there is an error! ");
- initShutdown = true;
+ this.initShutdown = true;
this.Stop();
}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/EventArgs/EncodeCompletedEventArgs.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/EventArgs/EncodeCompletedEventArgs.cs
new file mode 100644
index 000000000..b77f3097c
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/EventArgs/EncodeCompletedEventArgs.cs
@@ -0,0 +1,68 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="EncodeCompletedEventArgs.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// Encode Progress Event Args
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Services.Encode.EventArgs
+{
+ using System;
+ using System.Runtime.Serialization;
+
+ /// <summary>
+ /// Encode Progress Event Args
+ /// </summary>
+ [DataContract]
+ public class EncodeCompletedEventArgs : EventArgs
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="EncodeCompletedEventArgs"/> class.
+ /// </summary>
+ /// <param name="sucessful">
+ /// The sucessful.
+ /// </param>
+ /// <param name="exception">
+ /// The exception.
+ /// </param>
+ /// <param name="errorInformation">
+ /// The error information.
+ /// </param>
+ /// <param name="filename">
+ /// The filename.
+ /// </param>
+ public EncodeCompletedEventArgs(bool sucessful, Exception exception, string errorInformation, string filename)
+ {
+ this.Successful = sucessful;
+ this.Exception = exception;
+ this.ErrorInformation = errorInformation;
+ this.FileName = filename;
+ }
+
+ /// <summary>
+ /// Gets or sets the file name.
+ /// </summary>
+ [DataMember]
+ public string FileName { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether Successful.
+ /// </summary>
+ [DataMember]
+ public bool Successful { get; set; }
+
+ /// <summary>
+ /// Gets or sets Exception.
+ /// </summary>
+ [DataMember]
+ public Exception Exception { get; set; }
+
+ /// <summary>
+ /// Gets or sets ErrorInformation.
+ /// </summary>
+ [DataMember]
+ public string ErrorInformation { get; set; }
+ }
+}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/EventArgs/EncodeProgressEventArgs.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/EventArgs/EncodeProgressEventArgs.cs
new file mode 100644
index 000000000..1b93434da
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/EventArgs/EncodeProgressEventArgs.cs
@@ -0,0 +1,63 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="EncodeProgressEventArgs.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// Encode Progress Event Args
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Services.Encode.EventArgs
+{
+ using System;
+ using System.Runtime.Serialization;
+
+ /// <summary>
+ /// Encode Progress Event Args
+ /// </summary>
+ [DataContract]
+ public class EncodeProgressEventArgs : EventArgs
+ {
+ /// <summary>
+ /// Gets or sets PercentComplete.
+ /// </summary>
+ [DataMember]
+ public float PercentComplete { get; set; }
+
+ /// <summary>
+ /// Gets or sets CurrentFrameRate.
+ /// </summary>
+ [DataMember]
+ public float CurrentFrameRate { get; set; }
+
+ /// <summary>
+ /// Gets or sets AverageFrameRate.
+ /// </summary>
+ [DataMember]
+ public float AverageFrameRate { get; set; }
+
+ /// <summary>
+ /// Gets or sets EstimatedTimeLeft.
+ /// </summary>
+ [DataMember]
+ public TimeSpan EstimatedTimeLeft { get; set; }
+
+ /// <summary>
+ /// Gets or sets Task.
+ /// </summary>
+ [DataMember]
+ public int Task { get; set; }
+
+ /// <summary>
+ /// Gets or sets TaskCount.
+ /// </summary>
+ [DataMember]
+ public int TaskCount { get; set; }
+
+ /// <summary>
+ /// Gets or sets ElapsedTime.
+ /// </summary>
+ [DataMember]
+ public TimeSpan ElapsedTime { get; set; }
+ }
+}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Interfaces/IEncode.cs
index dec7d25b3..90c42149b 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/Interfaces/IEncode.cs
@@ -7,12 +7,12 @@
// </summary>
// --------------------------------------------------------------------------------------------------------------------
-namespace HandBrake.ApplicationServices.Services.Interfaces
+namespace HandBrake.ApplicationServices.Services.Encode.Interfaces
{
using System;
- using HandBrake.ApplicationServices.EventArgs;
using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Services.Encode.EventArgs;
/// <summary>
/// Encode Progess Status
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncodeServiceWrapper.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Interfaces/IEncodeServiceWrapper.cs
index 95f20e455..6163bcffc 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncodeServiceWrapper.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/Interfaces/IEncodeServiceWrapper.cs
@@ -7,7 +7,7 @@
// </summary>
// --------------------------------------------------------------------------------------------------------------------
-namespace HandBrake.ApplicationServices.Services.Interfaces
+namespace HandBrake.ApplicationServices.Services.Encode.Interfaces
{
/// <summary>
/// EncodeServiceWrapper Interface
diff --git a/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs
index e62c1cc2c..8a046e0af 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs
@@ -7,22 +7,21 @@
// </summary>
// --------------------------------------------------------------------------------------------------------------------
-namespace HandBrake.ApplicationServices.Services
+namespace HandBrake.ApplicationServices.Services.Encode
{
using System;
using System.Diagnostics;
using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Services.Base;
- using HandBrake.ApplicationServices.Services.Interfaces;
+ using HandBrake.ApplicationServices.Services.Encode.Interfaces;
using HandBrake.ApplicationServices.Utilities;
using HandBrake.Interop;
using HandBrake.Interop.EventArgs;
using HandBrake.Interop.Interfaces;
using HandBrake.Interop.Model;
- using EncodeCompletedEventArgs = HandBrake.ApplicationServices.EventArgs.EncodeCompletedEventArgs;
- using EncodeProgressEventArgs = HandBrake.ApplicationServices.EventArgs.EncodeProgressEventArgs;
+ using EncodeCompletedEventArgs = HandBrake.ApplicationServices.Services.Encode.EventArgs.EncodeCompletedEventArgs;
+ using EncodeProgressEventArgs = HandBrake.ApplicationServices.Services.Encode.EventArgs.EncodeProgressEventArgs;
/// <summary>
/// LibHB Implementation of IEncode
@@ -98,10 +97,10 @@ namespace HandBrake.ApplicationServices.Services
// Create a new HandBrake instance
// Setup the HandBrake Instance
- instance = new HandBrakeInstance();
- instance.Initialize(1);
- instance.EncodeCompleted += this.InstanceEncodeCompleted;
- instance.EncodeProgress += this.InstanceEncodeProgress;
+ this.instance = new HandBrakeInstance();
+ this.instance.Initialize(1);
+ this.instance.EncodeCompleted += this.InstanceEncodeCompleted;
+ this.instance.EncodeProgress += this.InstanceEncodeProgress;
try
{
@@ -132,11 +131,11 @@ namespace HandBrake.ApplicationServices.Services
// 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);
+ this.instance.StartScan(job.Task.Source, job.Configuration.PreviewScanCount, job.Task.Title);
- instance.ScanCompleted += delegate
+ this.instance.ScanCompleted += delegate
{
- ScanCompleted(job, instance);
+ this.ScanCompleted(job, this.instance);
};
}
catch (Exception exc)
@@ -211,7 +210,7 @@ namespace HandBrake.ApplicationServices.Services
instance.StartEncode(encodeJob, job.Configuration.PreviewScanCount);
// Fire the Encode Started Event
- this.InvokeEncodeStarted(EventArgs.Empty);
+ this.InvokeEncodeStarted(System.EventArgs.Empty);
// Set the Process Priority
switch (job.Configuration.ProcessPriority)
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IHbServiceCallback.cs b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IHbServiceCallback.cs
index 6f4d9a260..ce95bd8b5 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IHbServiceCallback.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IHbServiceCallback.cs
@@ -11,7 +11,7 @@ namespace HandBrake.ApplicationServices.Services.Interfaces
{
using System.ServiceModel;
- using HandBrake.ApplicationServices.EventArgs;
+ using HandBrake.ApplicationServices.Services.Encode.EventArgs;
/// <summary>
/// HandBrake WCF Service Callbacks
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IQueueProcessor.cs b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IQueueProcessor.cs
index 8fb61109a..7cb0ef7b6 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IQueueProcessor.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IQueueProcessor.cs
@@ -13,6 +13,7 @@ namespace HandBrake.ApplicationServices.Services.Interfaces
using System.ComponentModel;
using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Services.Encode.Interfaces;
/// <summary>
/// The Queue Processor
diff --git a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs
index e74f25391..ab1b4c2cb 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs
@@ -21,6 +21,8 @@ namespace HandBrake.ApplicationServices.Services
using HandBrake.ApplicationServices.EventArgs;
using HandBrake.ApplicationServices.Exceptions;
using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Services.Encode.EventArgs;
+ using HandBrake.ApplicationServices.Services.Encode.Interfaces;
using HandBrake.ApplicationServices.Services.Interfaces;
using HandBrake.ApplicationServices.Utilities;
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/EventArgs/ScanCompletedEventArgs.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/EventArgs/ScanCompletedEventArgs.cs
new file mode 100644
index 000000000..8e54cda12
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/Services/Scan/EventArgs/ScanCompletedEventArgs.cs
@@ -0,0 +1,65 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="ScanCompletedEventArgs.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// Scan Progress Event Args
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Services.Scan.EventArgs
+{
+ using System;
+ using System.Runtime.Serialization;
+
+ /// <summary>
+ /// Scan Progress Event Args
+ /// </summary>
+ [DataContract]
+ public class ScanCompletedEventArgs : EventArgs
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ScanCompletedEventArgs"/> class.
+ /// </summary>
+ /// <param name="cancelled">
+ /// Whether the scan was cancelled.
+ /// </param>
+ /// <param name="exception">
+ /// The exception.
+ /// </param>
+ /// <param name="errorInformation">
+ /// The error information.
+ /// </param>
+ public ScanCompletedEventArgs(bool cancelled, Exception exception, string errorInformation)
+ {
+ this.Successful = !cancelled && exception == null && string.IsNullOrEmpty(errorInformation);
+ this.Cancelled = cancelled;
+ this.Exception = exception;
+ this.ErrorInformation = errorInformation;
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether Successful.
+ /// </summary>
+ [DataMember]
+ public bool Successful { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether Cancelled.
+ /// </summary>
+ [DataMember]
+ public bool Cancelled { get; set; }
+
+ /// <summary>
+ /// Gets or sets Exception.
+ /// </summary>
+ [DataMember]
+ public Exception Exception { get; set; }
+
+ /// <summary>
+ /// Gets or sets ErrorInformation.
+ /// </summary>
+ [DataMember]
+ public string ErrorInformation { get; set; }
+ }
+}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/EventArgs/ScanProgressEventArgs.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/EventArgs/ScanProgressEventArgs.cs
new file mode 100644
index 000000000..9c71cdd0f
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/Services/Scan/EventArgs/ScanProgressEventArgs.cs
@@ -0,0 +1,39 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="ScanProgressEventArgs.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// Scan Progress Event Args
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Services.Scan.EventArgs
+{
+ using System;
+ using System.Runtime.Serialization;
+
+ /// <summary>
+ /// Scan Progress Event Args
+ /// </summary>
+ [DataContract]
+ public class ScanProgressEventArgs : EventArgs
+ {
+ /// <summary>
+ /// Gets or sets the title currently being scanned.
+ /// </summary>
+ [DataMember]
+ public int CurrentTitle { get; set; }
+
+ /// <summary>
+ /// Gets or sets the total number of Titles.
+ /// </summary>
+ [DataMember]
+ public int Titles { get; set; }
+
+ /// <summary>
+ /// Gets or sets the percentage.
+ /// </summary>
+ [DataMember]
+ public decimal Percentage { get; set; }
+ }
+}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/Interfaces/IScan.cs
index 05bc52499..ca0a10ea6 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Scan/Interfaces/IScan.cs
@@ -7,14 +7,14 @@
// </summary>
// --------------------------------------------------------------------------------------------------------------------
-namespace HandBrake.ApplicationServices.Services.Interfaces
+namespace HandBrake.ApplicationServices.Services.Scan.Interfaces
{
using System;
using System.Windows.Media.Imaging;
- using HandBrake.ApplicationServices.EventArgs;
using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Parsing;
+ using HandBrake.ApplicationServices.Services.Scan.EventArgs;
+ using HandBrake.ApplicationServices.Services.Scan.Model;
/// <summary>
/// Encode Progess Status
diff --git a/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs
index 1bcde0aed..e50d5ac1b 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs
@@ -7,19 +7,18 @@
// </summary>
// --------------------------------------------------------------------------------------------------------------------
-namespace HandBrake.ApplicationServices.Services
+namespace HandBrake.ApplicationServices.Services.Scan
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
- using System.Text.RegularExpressions;
using System.Windows.Media.Imaging;
- using HandBrake.ApplicationServices.EventArgs;
using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Parsing;
- using HandBrake.ApplicationServices.Services.Interfaces;
+ using HandBrake.ApplicationServices.Services.Scan.EventArgs;
+ using HandBrake.ApplicationServices.Services.Scan.Interfaces;
+ using HandBrake.ApplicationServices.Services.Scan.Model;
using HandBrake.ApplicationServices.Utilities;
using HandBrake.Interop;
using HandBrake.Interop.EventArgs;
@@ -27,13 +26,12 @@ namespace HandBrake.ApplicationServices.Services
using HandBrake.Interop.Model;
using HandBrake.Interop.SourceData;
- using AudioTrack = HandBrake.ApplicationServices.Parsing.Audio;
- using Chapter = HandBrake.ApplicationServices.Parsing.Chapter;
+ using Chapter = HandBrake.ApplicationServices.Services.Scan.Model.Chapter;
using ScanProgressEventArgs = HandBrake.Interop.EventArgs.ScanProgressEventArgs;
using Size = System.Drawing.Size;
- using Subtitle = HandBrake.ApplicationServices.Parsing.Subtitle;
+ using Subtitle = HandBrake.ApplicationServices.Services.Scan.Model.Subtitle;
using SubtitleType = HandBrake.ApplicationServices.Model.Encoding.SubtitleType;
- using Title = HandBrake.ApplicationServices.Parsing.Title;
+ using Title = HandBrake.ApplicationServices.Services.Scan.Model.Title;
/// <summary>
/// Scan a Source
@@ -101,9 +99,9 @@ namespace HandBrake.ApplicationServices.Services
/// </summary>
public LibScan()
{
- logging = new StringBuilder();
+ this.logging = new StringBuilder();
- header = GeneralUtilities.CreateCliLogHeader();
+ this.header = GeneralUtilities.CreateCliLogHeader();
try
{
@@ -182,13 +180,13 @@ namespace HandBrake.ApplicationServices.Services
public void Scan(string sourcePath, int title, Action<bool> postAction, HBConfiguration configuraiton)
{
// Try to cleanup any previous scan instances.
- if (instance != null)
+ if (this.instance != null)
{
try
{
this.scanLog.Close();
this.scanLog.Dispose();
- instance.Dispose();
+ this.instance.Dispose();
}
catch (Exception)
{
@@ -197,7 +195,7 @@ namespace HandBrake.ApplicationServices.Services
}
// Handle the post scan operation.
- postScanOperation = postAction;
+ this.postScanOperation = postAction;
// Clear down the logging
this.logging.Clear();
@@ -205,9 +203,9 @@ namespace HandBrake.ApplicationServices.Services
try
{
// Make we don't pick up a stale last_scan_log_xyz.txt (and that we have rights to the file)
- if (File.Exists(dvdInfoPath))
+ if (File.Exists(this.dvdInfoPath))
{
- File.Delete(dvdInfoPath);
+ File.Delete(this.dvdInfoPath);
}
}
catch (Exception)
@@ -215,19 +213,19 @@ namespace HandBrake.ApplicationServices.Services
// Do nothing.
}
- if (!Directory.Exists(Path.GetDirectoryName(dvdInfoPath)))
+ if (!Directory.Exists(Path.GetDirectoryName(this.dvdInfoPath)))
{
- Directory.CreateDirectory(Path.GetDirectoryName(dvdInfoPath));
+ Directory.CreateDirectory(Path.GetDirectoryName(this.dvdInfoPath));
}
// Create a new scan log.
- scanLog = new StreamWriter(dvdInfoPath);
+ this.scanLog = new StreamWriter(this.dvdInfoPath);
// Create a new HandBrake Instance.
- instance = new HandBrakeInstance();
- instance.Initialize(1);
- instance.ScanProgress += this.InstanceScanProgress;
- instance.ScanCompleted += this.InstanceScanCompleted;
+ this.instance = new HandBrakeInstance();
+ this.instance.Initialize(1);
+ this.instance.ScanProgress += this.InstanceScanProgress;
+ this.instance.ScanCompleted += this.InstanceScanCompleted;
// Start the scan on a back
this.ScanSource(sourcePath, title, configuraiton.PreviewScanCount, configuraiton);
@@ -238,7 +236,7 @@ namespace HandBrake.ApplicationServices.Services
/// </summary>
public void Stop()
{
- instance.StopScan();
+ this.instance.StopScan();
try
{
@@ -315,11 +313,11 @@ namespace HandBrake.ApplicationServices.Services
string source = sourcePath.ToString().EndsWith("\\") ? string.Format("\"{0}\\\\\"", sourcePath.ToString().TrimEnd('\\'))
: "\"" + sourcePath + "\"";
- currentSourceScanPath = source;
+ this.currentSourceScanPath = source;
- IsScanning = true;
+ this.IsScanning = true;
if (this.ScanStared != null)
- this.ScanStared(this, new EventArgs());
+ this.ScanStared(this, System.EventArgs.Empty);
TimeSpan minDuration =
TimeSpan.FromSeconds(
@@ -350,7 +348,7 @@ namespace HandBrake.ApplicationServices.Services
/// <param name="e">
/// The EventArgs.
/// </param>
- private void InstanceScanCompleted(object sender, EventArgs e)
+ private void InstanceScanCompleted(object sender, System.EventArgs e)
{
// Write the log file out before we start processing incase we crash.
try
@@ -366,20 +364,20 @@ namespace HandBrake.ApplicationServices.Services
}
// TODO -> Might be a better place to fix this.
- string path = currentSourceScanPath;
- if (currentSourceScanPath.Contains("\""))
+ string path = this.currentSourceScanPath;
+ if (this.currentSourceScanPath.Contains("\""))
{
- path = currentSourceScanPath.Trim('\"');
+ path = this.currentSourceScanPath.Trim('\"');
}
// Process into internal structures.
this.SouceData = new Source { Titles = ConvertTitles(this.instance.Titles, this.instance.FeatureTitle), ScanPath = path };
- IsScanning = false;
+ this.IsScanning = false;
- if (postScanOperation != null)
+ if (this.postScanOperation != null)
{
- postScanOperation(true);
+ this.postScanOperation(true);
}
else
{
@@ -400,8 +398,8 @@ namespace HandBrake.ApplicationServices.Services
{
if (this.ScanStatusChanged != null)
{
- ApplicationServices.EventArgs.ScanProgressEventArgs eventArgs =
- new ApplicationServices.EventArgs.ScanProgressEventArgs
+ EventArgs.ScanProgressEventArgs eventArgs =
+ new EventArgs.ScanProgressEventArgs
{
CurrentTitle = e.CurrentTitle,
Titles = e.Titles,
@@ -496,7 +494,7 @@ namespace HandBrake.ApplicationServices.Services
foreach (Interop.SourceData.AudioTrack track in title.AudioTracks)
{
- converted.AudioTracks.Add(new AudioTrack(track.TrackNumber, track.Language, track.LanguageCode, track.Description, string.Empty, track.SampleRate, track.Bitrate));
+ converted.AudioTracks.Add(new Audio(track.TrackNumber, track.Language, track.LanguageCode, track.Description, string.Empty, track.SampleRate, track.Bitrate));
}
foreach (Interop.SourceData.Subtitle track in title.Subtitles)
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Audio.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Audio.cs
new file mode 100644
index 000000000..f8b40a430
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Audio.cs
@@ -0,0 +1,181 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="Audio.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// An object represending an AudioTrack associated with a Title, in a DVD
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Services.Scan.Model
+{
+ using System;
+
+ /// <summary>
+ /// An object represending an AudioTrack associated with a Title, in a DVD
+ /// </summary>
+ [Serializable]
+ public class Audio
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Audio"/> class.
+ /// </summary>
+ public Audio()
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Audio"/> class.
+ /// </summary>
+ /// <param name="trackNumber">
+ /// The track number.
+ /// </param>
+ /// <param name="language">
+ /// The language.
+ /// </param>
+ /// <param name="languageCode">
+ /// The language code.
+ /// </param>
+ /// <param name="description">
+ /// The description.
+ /// </param>
+ /// <param name="format">
+ /// The format.
+ /// </param>
+ /// <param name="sampleRate">
+ /// The sample rate.
+ /// </param>
+ /// <param name="bitrate">
+ /// The bitrate.
+ /// </param>
+ public Audio(int trackNumber, string language, string languageCode, string description, string format, int sampleRate, int bitrate)
+ {
+ this.TrackNumber = trackNumber;
+ this.Language = language;
+ this.LanguageCode = languageCode;
+ this.Description = description;
+ this.Format = format;
+ this.SampleRate = sampleRate;
+ this.Bitrate = bitrate;
+ }
+
+ /// <summary>
+ /// Gets or sets The track number of this Audio Track
+ /// </summary>
+ public int TrackNumber { get; set; }
+
+ /// <summary>
+ /// Gets or sets The language (if detected) of this Audio Track
+ /// </summary>
+ public string Language { get; set; }
+
+ /// <summary>
+ /// Gets or sets LanguageCode.
+ /// </summary>
+ public string LanguageCode { get; set; }
+
+ /// <summary>
+ /// Gets or sets Description.
+ /// </summary>
+ public string Description { get; set; }
+
+ /// <summary>
+ /// Gets or sets The primary format of this Audio Track
+ /// </summary>
+ public string Format { get; set; }
+
+ /// <summary>
+ /// Gets or sets The frequency (in MHz) of this Audio Track
+ /// </summary>
+ public int SampleRate { get; set; }
+
+ /// <summary>
+ /// Gets or sets The bitrate (in kbps) of this Audio Track
+ /// </summary>
+ public int Bitrate { get; set; }
+
+ /// <summary>
+ /// Override of the ToString method to make this object easier to use in the UI
+ /// </summary>
+ /// <returns>A string formatted as: {track #} {language} ({format}) ({sub-format})</returns>
+ public override string ToString()
+ {
+ if (this.Description == "None Found")
+ {
+ return this.Description;
+ }
+
+ return string.Format("{0} {1}", this.TrackNumber, this.Description);
+ }
+
+ /// <summary>
+ /// The equals.
+ /// </summary>
+ /// <param name="other">
+ /// The other.
+ /// </param>
+ /// <returns>
+ /// The System.Boolean.
+ /// </returns>
+ public bool Equals(Audio other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other))
+ {
+ return true;
+ }
+
+ return other.TrackNumber == this.TrackNumber && object.Equals(other.Language, this.Language) && object.Equals(other.LanguageCode, this.LanguageCode) && object.Equals(other.Format, this.Format);
+ }
+
+ /// <summary>
+ /// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.
+ /// </summary>
+ /// <returns>
+ /// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
+ /// </returns>
+ /// <param name="obj">The <see cref="T:System.Object"/> to compare with the current <see cref="T:System.Object"/>. </param><filterpriority>2</filterpriority>
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ if (obj.GetType() != typeof(Audio))
+ {
+ return false;
+ }
+
+ return this.Equals((Audio)obj);
+ }
+
+ /// <summary>
+ /// Serves as a hash function for a particular type.
+ /// </summary>
+ /// <returns>
+ /// A hash code for the current <see cref="T:System.Object"/>.
+ /// </returns>
+ /// <filterpriority>2</filterpriority>
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ int result = this.TrackNumber;
+ result = (result * 397) ^ (this.Language != null ? this.Language.GetHashCode() : 0);
+ result = (result * 397) ^ (this.LanguageCode != null ? this.LanguageCode.GetHashCode() : 0);
+ result = (result * 397) ^ (this.Format != null ? this.Format.GetHashCode() : 0);
+ return result;
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Chapter.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Chapter.cs
new file mode 100644
index 000000000..6bb2a3fcf
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Chapter.cs
@@ -0,0 +1,70 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="Chapter.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// An object representing a Chapter aosciated with a Title, in a DVD
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Services.Scan.Model
+{
+ using System;
+ using System.Globalization;
+
+ /// <summary>
+ /// An object representing a Chapter aosciated with a Title, in a DVD
+ /// </summary>
+ public class Chapter
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Chapter"/> class.
+ /// </summary>
+ public Chapter()
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Chapter"/> class.
+ /// </summary>
+ /// <param name="number">
+ /// The number.
+ /// </param>
+ /// <param name="name">
+ /// The name.
+ /// </param>
+ /// <param name="duration">
+ /// The duration.
+ /// </param>
+ public Chapter(int number, string name, TimeSpan duration)
+ {
+ this.ChapterName = name;
+ this.ChapterNumber = number;
+ this.Duration = duration;
+ }
+
+ /// <summary>
+ /// Gets or sets The number of this Chapter, in regards to it's parent Title
+ /// </summary>
+ public int ChapterNumber { get; set; }
+
+ /// <summary>
+ /// Gets or sets ChapterName.
+ /// </summary>
+ public string ChapterName { get; set; }
+
+ /// <summary>
+ /// Gets or sets The length in time this Chapter spans
+ /// </summary>
+ public TimeSpan Duration { get; set; }
+
+ /// <summary>
+ /// Override of the ToString method to make this object easier to use in the UI
+ /// </summary>
+ /// <returns>A string formatted as: {chapter #}</returns>
+ public override string ToString()
+ {
+ return this.ChapterNumber.ToString(CultureInfo.InvariantCulture);
+ }
+ }
+} \ No newline at end of file
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Source.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Source.cs
new file mode 100644
index 000000000..27c7e938d
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Source.cs
@@ -0,0 +1,55 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="Source.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// An object representing a scanned DVD
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Services.Scan.Model
+{
+ using System.Collections.Generic;
+ using System.Runtime.Serialization;
+
+ /// <summary>
+ /// An object representing a scanned DVD
+ /// </summary>
+ [DataContract]
+ public class Source
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Source"/> class.
+ /// Default constructor for this object
+ /// </summary>
+ public Source()
+ {
+ this.Titles = new List<Title>();
+ }
+
+ /// <summary>
+ /// Gets or sets ScanPath.
+ /// The Path used by the Scan Service.
+ /// </summary>
+ [DataMember]
+ public string ScanPath { get; set; }
+
+ /// <summary>
+ /// Gets or sets Titles. A list of titles from the source
+ /// </summary>
+ [DataMember]
+ public List<Title> Titles { get; set; }
+
+ /// <summary>
+ /// Copy this Source to another Source Model
+ /// </summary>
+ /// <param name="source">
+ /// The source.
+ /// </param>
+ public void CopyTo(Source source)
+ {
+ source.Titles = this.Titles;
+ source.ScanPath = this.ScanPath;
+ }
+ }
+} \ No newline at end of file
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Subtitle.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Subtitle.cs
new file mode 100644
index 000000000..3da9e4a2e
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Subtitle.cs
@@ -0,0 +1,206 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="Subtitle.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// An object that represents a subtitle associated with a Title, in a DVD
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Services.Scan.Model
+{
+ using System;
+ using System.Xml.Serialization;
+
+ using HandBrake.ApplicationServices.Model.Encoding;
+ using HandBrake.ApplicationServices.Utilities;
+
+ /// <summary>
+ /// An object that represents a subtitle associated with a Title, in a DVD
+ /// </summary>
+ public class Subtitle
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Subtitle"/> class.
+ /// </summary>
+ public Subtitle()
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Subtitle"/> class.
+ /// </summary>
+ /// <param name="sourceId">
+ /// The source Id.
+ /// </param>
+ /// <param name="trackNumber">
+ /// The track number.
+ /// </param>
+ /// <param name="language">
+ /// The language.
+ /// </param>
+ /// <param name="languageCode">
+ /// The language code.
+ /// </param>
+ /// <param name="subtitleType">
+ /// The subtitle type.
+ /// </param>
+ /// <param name="canBurn">
+ /// The can Burn.
+ /// </param>
+ /// <param name="canForce">
+ /// The can Force.
+ /// </param>
+ public Subtitle(int sourceId, int trackNumber, string language, string languageCode, SubtitleType subtitleType, bool canBurn, bool canForce)
+ {
+ this.SourceId = sourceId;
+ this.TrackNumber = trackNumber;
+ this.Language = language;
+ this.LanguageCode = languageCode;
+ this.SubtitleType = subtitleType;
+ this.CanBurnIn = canBurn;
+ this.CanForce = canForce;
+ }
+
+ /// <summary>
+ /// Gets or sets the source id.
+ /// </summary>
+ public int SourceId { get; set; }
+
+ /// <summary>
+ /// Gets or sets the track number of this Subtitle
+ /// </summary>
+ public int TrackNumber { get; set; }
+
+ /// <summary>
+ /// Gets or sets the The language (if detected) of this Subtitle
+ /// </summary>
+ public string Language { get; set; }
+
+ /// <summary>
+ /// Gets or sets the Langauage Code
+ /// </summary>
+ public string LanguageCode { get; set; }
+
+ /// <summary>
+ /// Gets the language code clean.
+ /// TODO Remove this after fixing language code.
+ /// </summary>
+ public string LanguageCodeClean
+ {
+ get
+ {
+ if (this.LanguageCode != null)
+ {
+ return this.LanguageCode.Replace("iso639-2: ", string.Empty).Trim();
+ }
+ return string.Empty;
+ }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether can burn in.
+ /// </summary>
+ [XmlIgnore]
+ public bool CanBurnIn { get; private set; }
+
+ /// <summary>
+ /// Gets a value indicating whether can force.
+ /// </summary>
+ [XmlIgnore]
+ public bool CanForce { get; private set; }
+
+ /// <summary>
+ /// Gets or sets the Subtitle Type
+ /// </summary>
+ public SubtitleType SubtitleType { get; set; }
+
+ /// <summary>
+ /// Gets Subtitle Type
+ /// </summary>
+ public string TypeString
+ {
+ get
+ {
+ return EnumHelper<Enum>.GetDescription(this.SubtitleType);
+ }
+ }
+
+ /// <summary>
+ /// Override of the ToString method to make this object easier to use in the UI
+ /// </summary>
+ /// <returns>A string formatted as: {track #} {language}</returns>
+ public override string ToString()
+ {
+ return this.SubtitleType == SubtitleType.ForeignAudioSearch ? "Foreign Audio Scan" : string.Format("{0} {1} ({2})", this.TrackNumber, this.Language, this.TypeString);
+ }
+
+ /// <summary>
+ /// The equals.
+ /// </summary>
+ /// <param name="other">
+ /// The other.
+ /// </param>
+ /// <returns>
+ /// The System.Boolean.
+ /// </returns>
+ public bool Equals(Subtitle other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+ if (ReferenceEquals(this, other))
+ {
+ return true;
+ }
+ return other.TrackNumber == this.TrackNumber && object.Equals(other.Language, this.Language) && object.Equals(other.LanguageCode, this.LanguageCode) && object.Equals(other.SubtitleType, this.SubtitleType);
+ }
+
+ /// <summary>
+ /// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.
+ /// </summary>
+ /// <returns>
+ /// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
+ /// </returns>
+ /// <param name="obj">The <see cref="T:System.Object"/> to compare with the current <see cref="T:System.Object"/>. </param><filterpriority>2</filterpriority>
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ if (obj.GetType() != typeof(Subtitle))
+ {
+ return false;
+ }
+
+ return this.Equals((Subtitle)obj);
+ }
+
+ /// <summary>
+ /// Serves as a hash function for a particular type.
+ /// </summary>
+ /// <returns>
+ /// A hash code for the current <see cref="T:System.Object"/>.
+ /// </returns>
+ /// <filterpriority>2</filterpriority>
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ int result = this.TrackNumber;
+ result = (result * 397) ^ (this.Language != null ? this.Language.GetHashCode() : 0);
+ result = (result * 397) ^ (this.LanguageCode != null ? this.LanguageCode.GetHashCode() : 0);
+ result = (result * 397) ^ this.SubtitleType.GetHashCode();
+ return result;
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Title.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Title.cs
new file mode 100644
index 000000000..ad6b291d1
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Title.cs
@@ -0,0 +1,145 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="Title.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// An object that represents a single Title of a DVD
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Services.Scan.Model
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ using HandBrake.Interop.Model;
+
+ using Size = System.Drawing.Size;
+
+ /// <summary>
+ /// An object that represents a single Title of a DVD
+ /// </summary>
+ public class Title
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Title"/> class.
+ /// </summary>
+ public Title()
+ {
+ this.AudioTracks = new List<Audio>();
+ this.Chapters = new List<Chapter>();
+ this.Subtitles = new List<Subtitle>();
+ }
+
+ #region Properties
+
+ /// <summary>
+ /// Gets or sets a Collection of chapters in this Title
+ /// </summary>
+ public List<Chapter> Chapters { get; set; }
+
+ /// <summary>
+ /// Gets or sets a Collection of audio tracks associated with this Title
+ /// </summary>
+ public List<Audio> AudioTracks { get; set; }
+
+ /// <summary>
+ /// Gets or sets a Collection of subtitles associated with this Title
+ /// </summary>
+ public List<Subtitle> Subtitles { get; set; }
+
+ /// <summary>
+ /// Gets or sets The track number of this Title
+ /// </summary>
+ public int TitleNumber { get; set; }
+
+ /// <summary>
+ /// Gets or sets Playlist.
+ /// </summary>
+ public string Playlist { get; set; }
+
+ /// <summary>
+ /// Gets or sets the length in time of this Title
+ /// </summary>
+ public TimeSpan Duration { get; set; }
+
+ /// <summary>
+ /// Gets or sets the resolution (width/height) of this Title
+ /// </summary>
+ public Size Resolution { get; set; }
+
+ /// <summary>
+ /// Gets or sets the aspect ratio of this Title
+ /// </summary>
+ public double AspectRatio { get; set; }
+
+ /// <summary>
+ /// Gets or sets AngleCount.
+ /// </summary>
+ public int AngleCount { get; set; }
+
+ /// <summary>
+ /// Gets or sets Par Value
+ /// </summary>
+ public Size ParVal { get; set; }
+
+ /// <summary>
+ /// Gets or sets the automatically detected crop region for this Title.
+ /// This is an int array with 4 items in it as so:
+ /// 0: T
+ /// 1: B
+ /// 2: L
+ /// 3: R
+ /// </summary>
+ public Cropping AutoCropDimensions { get; set; }
+
+ /// <summary>
+ /// Gets or sets the FPS of the source.
+ /// </summary>
+ public double Fps { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether this is a MainTitle.
+ /// </summary>
+ public bool MainTitle { get; set; }
+
+ /// <summary>
+ /// Gets or sets the Source Name
+ /// </summary>
+ public string SourceName { get; set; }
+
+ #endregion
+
+ /// <summary>
+ /// Calcuate the Duration
+ /// </summary>
+ /// <param name="startPoint">The Start Point (Chapters)</param>
+ /// <param name="endPoint">The End Point (Chapters)</param>
+ /// <returns>A Timespan</returns>
+ public TimeSpan CalculateDuration(int startPoint, int endPoint)
+ {
+ IEnumerable<Chapter> chapers =
+ this.Chapters.Where(c => c.ChapterNumber >= startPoint && c.ChapterNumber <= endPoint);
+
+ TimeSpan duration = TimeSpan.FromSeconds(0.0);
+ duration = chapers.Aggregate(duration, (current, chapter) => current + chapter.Duration);
+
+ return duration;
+ }
+
+ /// <summary>
+ /// Override of the ToString method to provide an easy way to use this object in the UI
+ /// </summary>
+ /// <returns>A string representing this track in the format: {title #} (00:00:00)</returns>
+ public override string ToString()
+ {
+ if (!string.IsNullOrEmpty(this.Playlist) && !this.Playlist.StartsWith(" "))
+ {
+ this.Playlist = string.Format(" {0}", this.Playlist);
+ }
+
+ return string.Format("{0}{1} ({2:00}:{3:00}:{4:00})", this.TitleNumber, this.Playlist, this.Duration.Hours, this.Duration.Minutes, this.Duration.Seconds);
+ }
+ }
+} \ No newline at end of file
diff --git a/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs b/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs
index 39dc86471..d0f1b6a99 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs
@@ -15,11 +15,11 @@ namespace HandBrake.ApplicationServices.Services
using System.Threading;
using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Services.Encode;
+ using HandBrake.ApplicationServices.Services.Encode.EventArgs;
+ using HandBrake.ApplicationServices.Services.Encode.Interfaces;
using HandBrake.ApplicationServices.Services.Interfaces;
- using EncodeCompletedEventArgs = HandBrake.ApplicationServices.EventArgs.EncodeCompletedEventArgs;
- using EncodeProgressEventArgs = HandBrake.ApplicationServices.EventArgs.EncodeProgressEventArgs;
-
/// <summary>
/// HandBrake WCF Service
/// </summary>