using HandBrake.ApplicationServices.Parsing;\r
\r
using Presets;\r
- using AudioTrack = Model.AudioTrack;\r
+\r
+ using AudioTrack = HandBrake.ApplicationServices.Model.Encoding.AudioTrack;\r
\r
/// <summary>\r
/// The AudioPanel Control\r
using Functions;\r
\r
using HandBrake.ApplicationServices.Model;\r
+ using HandBrake.ApplicationServices.Model.Encoding;\r
\r
using Model;\r
\r
/// <summary>\r
/// The Subtitle List\r
/// </summary>\r
- private readonly List<SubtitleInfo> subList = new List<SubtitleInfo>();\r
+ private readonly List<SubtitleTrack> subList = new List<SubtitleTrack>();\r
\r
#endregion\r
\r
int srtCount = 0;\r
int subCount = 0;\r
\r
- foreach (SubtitleInfo item in subList)\r
+ foreach (SubtitleTrack item in subList)\r
{\r
string itemToAdd;\r
\r
? srtLangVal + " (" + srtFile + ")"\r
: drp_subtitleTracks.SelectedItem.ToString();\r
\r
- SubtitleInfo track = new SubtitleInfo\r
+ SubtitleTrack track = new SubtitleTrack\r
{\r
Track = trackName,\r
Forced = check_forced.Checked,\r
// Set the dropdown controls based on the selected item in the List.\r
if (lv_subList.Items.Count != 0 && lv_subList.SelectedIndices.Count != 0)\r
{\r
- SubtitleInfo track = subList[lv_subList.SelectedIndices[0]];\r
+ SubtitleTrack track = subList[lv_subList.SelectedIndices[0]];\r
\r
int c = 0;\r
if (lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[0].Text.ToLower().Contains(".srt"))\r
/// <summary>\r
/// The XML Serializer\r
/// </summary>\r
- private static readonly XmlSerializer Ser = new XmlSerializer(typeof(List<Job>));\r
+ private static readonly XmlSerializer Ser = new XmlSerializer(typeof(List<QueueTask>));\r
\r
/// <summary>\r
/// Calculate the duration of the selected title and chapters\r
\r
using (FileStream strm = new FileStream(Path.Combine(file.DirectoryName, file.Name), FileMode.Open, FileAccess.Read))\r
{\r
- List<Job> list = Ser.Deserialize(strm) as List<Job>;\r
+ List<QueueTask> list = Ser.Deserialize(strm) as List<QueueTask>;\r
if (list != null)\r
{\r
if (list.Count != 0)\r
using System.Collections;\r
using System.Globalization;\r
using System.Text.RegularExpressions;\r
+\r
+ using HandBrake.ApplicationServices.Model.Encoding;\r
+\r
using Model;\r
\r
/// <summary>\r
/// <param name="newJob">\r
/// The new job.\r
/// </param>\r
- public QueueProgressEventArgs(Job newJob)\r
+ public QueueProgressEventArgs(QueueTask newJob)\r
{\r
this.NewJob = newJob;\r
}\r
/// <summary>\r
/// Gets or sets the new job which is about to be processed.\r
/// </summary>\r
- public Job NewJob { get; set; }\r
+ public QueueTask NewJob { get; set; }\r
}\r
}\r
/// <returns>\r
/// The create cli log header.\r
/// </returns>\r
- public static string CreateCliLogHeader(Job encJob)\r
+ public static string CreateCliLogHeader(QueueTask encJob)\r
{\r
StringBuilder logHeader = new StringBuilder();\r
\r
</FileUpgradeFlags>\r
<OldToolsVersion>3.5</OldToolsVersion>\r
<UpgradeBackupLocation />\r
+ <TargetFrameworkProfile>\r
+ </TargetFrameworkProfile>\r
</PropertyGroup>\r
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
<DebugSymbols>true</DebugSymbols>\r
<Compile Include="Functions\Win32.cs" />\r
<Compile Include="Functions\Win7.cs" />\r
<Compile Include="Init.cs" />\r
- <Compile Include="Model\Cropping.cs" />\r
- <Compile Include="Model\Job.cs" />\r
- <Compile Include="Model\SubtitleType.cs" />\r
+ <Compile Include="Model\Encoding\Anamorphic.cs" />\r
+ <Compile Include="Model\Encoding\AudioEncoder.cs" />\r
+ <Compile Include="Model\Encoding\AudioTrack.cs" />\r
+ <Compile Include="Model\Encoding\Mixdown.cs" />\r
+ <Compile Include="Model\Encoding\PointToPointMode.cs" />\r
+ <Compile Include="Model\Encoding\Cropping.cs" />\r
+ <Compile Include="Model\EncodeTask.cs" />\r
+ <Compile Include="Model\Encoding\Decomb.cs" />\r
+ <Compile Include="Model\Encoding\Deinterlace.cs" />\r
+ <Compile Include="Model\Encoding\Denoise.cs" />\r
+ <Compile Include="Model\Encoding\Detelecine.cs" />\r
+ <Compile Include="Model\Encoding\OutputFormat.cs" />\r
+ <Compile Include="Model\Encoding\SubtitleTrack.cs" />\r
+ <Compile Include="Model\Encoding\VideoEncoder.cs" />\r
+ <Compile Include="Model\Encoding\VideoEncodeRateType.cs" />\r
+ <Compile Include="Model\QueueTask.cs" />\r
+ <Compile Include="Model\Encoding\SubtitleType.cs" />\r
<Compile Include="Parsing\AudioTrack.cs" />\r
<Compile Include="Parsing\Chapter.cs" />\r
<Compile Include="Parsing\DVD.cs" />\r
<Compile Include="Services\Encode.cs" />\r
<Compile Include="Services\Interfaces\IEncode.cs" />\r
<Compile Include="Services\Interfaces\IQueue.cs" />\r
+ <Compile Include="Services\Interfaces\IQueueManager.cs" />\r
+ <Compile Include="Services\Interfaces\IQueueProcessor.cs" />\r
<Compile Include="Services\Interfaces\IScan.cs" />\r
<Compile Include="Services\Queue.cs" />\r
+ <Compile Include="Services\QueueManager.cs" />\r
+ <Compile Include="Services\QueueProcessor.cs" />\r
<Compile Include="Services\Scan.cs" />\r
</ItemGroup>\r
<ItemGroup>\r
<Name>HandBrake.Framework</Name>\r
</ProjectReference>\r
</ItemGroup>\r
+ <ItemGroup>\r
+ <Folder Include="Model\Interfaces\" />\r
+ </ItemGroup>\r
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
<Import Project="$(ProgramFiles)\MSBuild\Microsoft\StyleCop\v4.4\Microsoft.StyleCop.targets" />\r
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
--- /dev/null
+/* EncodeTask.cs $\r
+ This file is part of the HandBrake source code.\r
+ Homepage: <http://handbrake.fr>.\r
+ It may be used under the terms of the GNU General Public License. */\r
+\r
+namespace HandBrake.ApplicationServices.Model\r
+{\r
+ using System.Collections.Generic;\r
+\r
+ using HandBrake.ApplicationServices.Model.Encoding;\r
+\r
+ /// <summary>\r
+ /// An Encode Task\r
+ /// </summary>\r
+ public class EncodeTask\r
+ {\r
+ #region Source\r
+ /// <summary>\r
+ /// Gets or sets Source.\r
+ /// </summary>\r
+ public string Source { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets Title.\r
+ /// </summary>\r
+ public int Title { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets PointToPointMode.\r
+ /// </summary>\r
+ public PointToPointMode PointToPointMode { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets StartPoint.\r
+ /// </summary>\r
+ public int StartPoint { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets EndPoint.\r
+ /// </summary>\r
+ public int EndPoint { get; set; }\r
+ #endregion\r
+\r
+ #region Destination\r
+\r
+ /// <summary>\r
+ /// Gets or sets Destination.\r
+ /// </summary>\r
+ public string Destination { get; set; }\r
+\r
+ #endregion\r
+\r
+ #region Output Settings\r
+ /// <summary>\r
+ /// Gets or sets OutputFormat.\r
+ /// </summary>\r
+ public OutputFormat OutputFormat { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether LargeFile.\r
+ /// </summary>\r
+ public bool LargeFile { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether Optimize.\r
+ /// </summary>\r
+ public bool OptimizeMP4 { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether IPod5GSupport.\r
+ /// </summary>\r
+ public bool IPod5GSupport { get; set; }\r
+ #endregion\r
+\r
+ #region Picture\r
+\r
+ /// <summary>\r
+ /// Gets or sets Width.\r
+ /// </summary>\r
+ public int Width { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets Height.\r
+ /// </summary>\r
+ public int Height { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets MaxWidth.\r
+ /// </summary>\r
+ public int MaxWidth { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets MaxHeight.\r
+ /// </summary>\r
+ public int MaxHeight { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether CustomCropping.\r
+ /// </summary>\r
+ public bool IsCustomCropping { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets Cropping.\r
+ /// </summary>\r
+ public Cropping Cropping { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets Anamorphic.\r
+ /// </summary>\r
+ public Anamorphic Anamorphic { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets DisplayWidth.\r
+ /// </summary>\r
+ public int DisplayWidth { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether KeepDisplayAspect.\r
+ /// </summary>\r
+ public bool KeepDisplayAspect { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets PixelAspectX.\r
+ /// </summary>\r
+ public int PixelAspectX { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets PixelAspectY.\r
+ /// </summary>\r
+ public int PixelAspectY { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets Modulus.\r
+ /// </summary>\r
+ public int Modulus { get; set; }\r
+ #endregion\r
+\r
+ #region Filters\r
+\r
+ /// <summary>\r
+ /// Gets or sets Deinterlace.\r
+ /// </summary>\r
+ public Deinterlace Deinterlace { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets CustomDeinterlace.\r
+ /// </summary>\r
+ public string CustomDeinterlace { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets Decomb.\r
+ /// </summary>\r
+ public Decomb Decomb { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets CustomDecomb.\r
+ /// </summary>\r
+ public string CustomDecomb { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets Detelecine.\r
+ /// </summary>\r
+ public Detelecine Detelecine { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets CustomDetelecine.\r
+ /// </summary>\r
+ public string CustomDetelecine { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets Denoise.\r
+ /// </summary>\r
+ public Denoise Denoise { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets CustomDenoise.\r
+ /// </summary>\r
+ public string CustomDenoise { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets Deblock.\r
+ /// </summary>\r
+ public int Deblock { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether Grayscale.\r
+ /// </summary>\r
+ public bool Grayscale { get; set; }\r
+ #endregion\r
+\r
+ #region Video\r
+\r
+ /// <summary>\r
+ /// Gets or sets VideoEncodeRateType.\r
+ /// </summary>\r
+ public VideoEncodeRateType VideoEncodeRateType { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets Quality.\r
+ /// </summary>\r
+ public double Quality { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets TargetSize.\r
+ /// </summary>\r
+ public int TargetSize { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets VideoBitrate.\r
+ /// </summary>\r
+ public int VideoBitrate { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether TwoPass.\r
+ /// </summary>\r
+ public bool TwoPass { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether TurboFirstPass.\r
+ /// </summary>\r
+ public bool TurboFirstPass { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets Framerate.\r
+ /// Null = Same as Source\r
+ /// </summary>\r
+ public double? Framerate { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether PeakFramerate.\r
+ /// </summary>\r
+ public bool PeakFramerate { get; set; }\r
+\r
+ #endregion\r
+\r
+ #region Audio\r
+\r
+ /// <summary>\r
+ /// Gets or sets AudioEncodings.\r
+ /// </summary>\r
+ public List<AudioTrack> AudioTracks { get; set; }\r
+ #endregion\r
+\r
+ #region Subtitles\r
+\r
+ /// <summary>\r
+ /// Gets or sets SubtitleTracks.\r
+ /// </summary>\r
+ public List<SubtitleTrack> SubtitleTracks { get; set; }\r
+ #endregion\r
+\r
+ #region Chapters\r
+\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether IncludeChapterMarkers.\r
+ /// </summary>\r
+ public bool IncludeChapterMarkers { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets ChapterMarkersFilePath.\r
+ /// </summary>\r
+ public string ChapterMarkersFilePath { get; set; }\r
+\r
+ #endregion\r
+\r
+ #region Advanced\r
+\r
+ /// <summary>\r
+ /// Gets or sets X264Options.\r
+ /// </summary>\r
+ public string X264Options { get; set; }\r
+ #endregion\r
+ }\r
+}\r
--- /dev/null
+namespace HandBrake.ApplicationServices.Model.Encoding\r
+{\r
+ using System.ComponentModel;\r
+\r
+ /// <summary>\r
+ /// Anamorphic Mode\r
+ /// </summary>\r
+ public enum Anamorphic\r
+ {\r
+ [Description("None")]\r
+ None = 0,\r
+ [Description("Strict")]\r
+ Strict,\r
+ [Description("Loose")]\r
+ Loose,\r
+ [Description("Custom")]\r
+ Custom\r
+ }\r
+}\r
--- /dev/null
+namespace HandBrake.ApplicationServices.Model.Encoding\r
+{\r
+ using System.ComponentModel;\r
+\r
+ public enum AudioEncoder\r
+ {\r
+ [Description("AAC (faac)")]\r
+ Faac = 0,\r
+\r
+ [Description("MP3 (lame)")]\r
+ Lame,\r
+\r
+ [Description("AC3 (ffmpeg)")]\r
+ Ac3,\r
+\r
+ [Description("Passthrough (AC3/DTS)")]\r
+ Passthrough,\r
+\r
+ [Description("Passthrough (AC3)")]\r
+ Ac3Passthrough,\r
+\r
+ [Description("Passthrough (DTS)")]\r
+ DtsPassthrough,\r
+\r
+ [Description("Vorbis (vorbis)")]\r
+ Vorbis\r
+ }\r
+}\r
Homepage: <http://handbrake.fr>.\r
It may be used under the terms of the GNU General Public License. */\r
\r
-namespace Handbrake.Model\r
+namespace HandBrake.ApplicationServices.Model.Encoding\r
{\r
/// <summary>\r
/// An Audio Track for the Audio Panel\r
Homepage: <http://handbrake.fr>.\r
It may be used under the terms of the GNU General Public License. */\r
\r
-namespace HandBrake.ApplicationServices.Model\r
+namespace HandBrake.ApplicationServices.Model.Encoding\r
{\r
/// <summary>\r
/// Cropping T B L R\r
--- /dev/null
+namespace HandBrake.ApplicationServices.Model.Encoding\r
+{\r
+ /// <summary>\r
+ /// Decomb Mode\r
+ /// </summary>\r
+ public enum Decomb\r
+ {\r
+ Off = 0,\r
+ Default,\r
+ Custom\r
+ }\r
+}\r
--- /dev/null
+namespace HandBrake.ApplicationServices.Model.Encoding\r
+{\r
+ public enum Deinterlace\r
+ {\r
+ Off = 0,\r
+ Fast,\r
+ Slow,\r
+ Slower,\r
+ Custom\r
+ }\r
+}\r
--- /dev/null
+namespace HandBrake.ApplicationServices.Model.Encoding\r
+{\r
+ public enum Denoise\r
+ {\r
+ Off = 0,\r
+ Weak,\r
+ Medium,\r
+ Strong,\r
+ Custom\r
+ }\r
+}\r
--- /dev/null
+namespace HandBrake.ApplicationServices.Model.Encoding\r
+{\r
+ public enum Detelecine\r
+ {\r
+ Off = 0,\r
+ Default,\r
+ Custom\r
+ }\r
+}\r
--- /dev/null
+namespace HandBrake.ApplicationServices.Model.Encoding\r
+{\r
+ using System.ComponentModel;\r
+\r
+ /// <summary>\r
+ /// The Mixdown Mode\r
+ /// </summary>\r
+ public enum Mixdown\r
+ {\r
+ [Description("Dolby Pro Logic II")]\r
+ DolbyProLogicII = 0,\r
+\r
+ [Description("Auto")]\r
+ Auto,\r
+\r
+ [Description("Mono")]\r
+ Mono,\r
+\r
+ [Description("Stereo")]\r
+ Stereo,\r
+\r
+ [Description("Dolby Surround")]\r
+ DolbySurround,\r
+\r
+ [Description("6 Channel Discrete")]\r
+ SixChannelDiscrete\r
+ }\r
+}\r
--- /dev/null
+namespace HandBrake.ApplicationServices.Model.Encoding\r
+{\r
+ using System.ComponentModel;\r
+\r
+ /// <summary>\r
+ /// The Output format.\r
+ /// </summary>\r
+ public enum OutputFormat\r
+ {\r
+ [Description("MP4")]\r
+ Mp4,\r
+\r
+ [Description("M4V")]\r
+ M4V,\r
+\r
+ [Description("MKV")]\r
+ Mkv\r
+ }\r
+}\r
--- /dev/null
+namespace HandBrake.ApplicationServices.Model.Encoding\r
+{\r
+ /// <summary>\r
+ /// Point to Point Mode\r
+ /// </summary>\r
+ public enum PointToPointMode\r
+ {\r
+ Chapters = 0,\r
+ Seconds,\r
+ Frames\r
+ }\r
+}\r
Homepage: <http://handbrake.fr>.\r
It may be used under the terms of the GNU General Public License. */\r
\r
-namespace Handbrake.Model\r
+namespace HandBrake.ApplicationServices.Model.Encoding\r
{\r
using System.Windows.Forms;\r
\r
- using HandBrake.ApplicationServices.Model;\r
-\r
/// <summary>\r
/// Subtitle Information\r
/// </summary>\r
- public class SubtitleInfo\r
+ public class SubtitleTrack\r
{\r
/// <summary>\r
- /// Gets or sets the Subtitle Track\r
+ /// Gets or sets Track.\r
/// </summary>\r
public string Track { get; set; }\r
\r
/// <summary>\r
- /// Gets or sets the Forced Subtitle\r
+ /// Gets or sets a value indicating whether Forced.\r
/// </summary>\r
public bool Forced { get; set; }\r
\r
/// <summary>\r
- /// Gets or sets the Burned In Subtitle\r
+ /// Gets or sets a value indicating whether Burned.\r
/// </summary>\r
public bool Burned { get; set; }\r
\r
/// <summary>\r
- /// Gets or sets the Default Subtitle Track\r
+ /// Gets or sets a value indicating whether Default.\r
/// </summary>\r
public bool Default { get; set; }\r
\r
+ #region SRT Specific Options\r
+\r
/// <summary>\r
/// Gets or sets the SRT Language\r
/// </summary>\r
get { return this.SrtFileName != "-"; }\r
}\r
\r
+ #endregion\r
+\r
/// <summary>\r
/// Gets or sets the type of the subtitle\r
/// </summary>\r
Homepage: <http://handbrake.fr>.\r
It may be used under the terms of the GNU General Public License. */\r
\r
-namespace HandBrake.ApplicationServices.Model\r
+namespace HandBrake.ApplicationServices.Model.Encoding\r
{\r
using System.ComponentModel;\r
\r
--- /dev/null
+namespace HandBrake.ApplicationServices.Model.Encoding\r
+{\r
+ public enum VideoEncodeRateType\r
+ {\r
+ TargetSize = 0,\r
+ AverageBitrate,\r
+ ConstantQuality\r
+ }\r
+}\r
--- /dev/null
+namespace HandBrake.ApplicationServices.Model.Encoding\r
+{\r
+ using System.ComponentModel;\r
+\r
+ public enum VideoEncoder\r
+ {\r
+ [Description("H.264 (x264)")]\r
+ X264 = 0,\r
+\r
+ [Description("MPEG-4 (FFMpeg)")]\r
+ FFMpeg,\r
+\r
+ [Description("VP3 (Theora)")]\r
+ Theora\r
+ }\r
+}\r
/// <summary>\r
/// The job.\r
/// </summary>\r
- public class Job\r
+ public class QueueTask\r
{\r
+ /*\r
+ * TODO\r
+ * - Update the Query property to generate the query from the EncodeTask object.\r
+ * - Remove Sourcee, Destination and Title when they are no longer used.\r
+ */\r
+\r
/// <summary>\r
/// Gets or sets the job ID.\r
/// </summary>\r
public int Id { get; set; }\r
\r
/// <summary>\r
- /// Gets or sets the selected Title.\r
+ /// Gets or sets Title.\r
/// </summary>\r
public int Title { get; set; }\r
\r
+ /// <summary>\r
+ /// Gets or sets Source.\r
+ /// </summary>\r
+ public string Source { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets Destination.\r
+ /// </summary>\r
+ public string Destination { get; set; }\r
+\r
/// <summary>\r
/// Gets or sets the query string.\r
/// </summary>\r
public bool CustomQuery { get; set; }\r
\r
/// <summary>\r
- /// Gets or sets the source file of encoding.\r
+ /// Gets or sets the Encode Task.\r
/// </summary>\r
- public string Source { get; set; }\r
-\r
- /// <summary>\r
- /// Gets or sets the destination for the file to be encoded.\r
- /// </summary>\r
- public string Destination { get; set; }\r
+ public EncodeTask Task { get; set; }\r
\r
/// <summary>\r
/// Gets a value indicating whether or not this instance is empty.\r
{\r
get\r
{\r
- return this.Id == 0 && string.IsNullOrEmpty(this.Query) && string.IsNullOrEmpty(this.Source) &&\r
- string.IsNullOrEmpty(this.Destination);\r
+ return this.Id == 0 && string.IsNullOrEmpty(this.Query) && string.IsNullOrEmpty(this.Task.Source) &&\r
+ string.IsNullOrEmpty(this.Task.Destination);\r
}\r
}\r
}\r
using System.Text.RegularExpressions;\r
\r
using HandBrake.ApplicationServices.Functions;\r
- using HandBrake.ApplicationServices.Model;\r
+ using HandBrake.ApplicationServices.Model.Encoding;\r
\r
/// <summary>\r
/// An object that represents a subtitle associated with a Title, in a DVD\r
using System.Text.RegularExpressions;\r
\r
using HandBrake.ApplicationServices.Model;\r
+ using HandBrake.ApplicationServices.Model.Encoding;\r
\r
/// <summary>\r
/// An object that represents a single Title of a DVD\r
/// </param>\r
public void CreatePreviewSample(string query)\r
{\r
- this.Run(new Job { Query = query }, false);\r
+ this.Run(new QueueTask { Query = query }, false);\r
}\r
\r
/// <summary>\r
/// <param name="enableLogging">\r
/// Enable Logging. When Disabled we onlt parse Standard Ouput for progress info. Standard Error log data is ignored.\r
/// </param>\r
- protected void Run(Job encJob, bool enableLogging)\r
+ protected void Run(QueueTask encJob, bool enableLogging)\r
{\r
try\r
{\r
/// <param name="encodeJob">\r
/// The encode Job.\r
/// </param>\r
- private void SetupLogging(Job encodeJob)\r
+ private void SetupLogging(QueueTask encodeJob)\r
{\r
string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";\r
string logFile = Path.Combine(logDir, string.Format("last_encode_log{0}.txt", Init.InstanceId));\r
/// Gets or sets the last encode that was processed.\r
/// </summary>\r
/// <returns></returns> \r
- Job LastEncode { get; set; }\r
+ QueueTask LastEncode { get; set; }\r
\r
/// <summary>\r
/// Gets a value indicating whether Request Pause\r
/// <summary>\r
/// Gets the current state of the encode queue.\r
/// </summary>\r
- ReadOnlyCollection<Job> CurrentQueue { get; }\r
+ ReadOnlyCollection<QueueTask> CurrentQueue { get; }\r
\r
/// <summary>\r
/// Gets the number of items in the queue.\r
/// </summary>\r
/// <param name="index">the job id</param>\r
/// <returns>A job for the given index or blank job object</returns>\r
- Job GetJob(int index);\r
+ QueueTask GetJob(int index);\r
\r
/// <summary>\r
/// Moves an item up one position in the queue.\r
--- /dev/null
+/* IQueueManager.cs $\r
+ This file is part of the HandBrake source code.\r
+ Homepage: <http://handbrake.fr/>.\r
+ It may be used under the terms of the GNU General Public License. */\r
+\r
+namespace HandBrake.ApplicationServices.Services.Interfaces\r
+{\r
+ using System;\r
+ using System.Collections.ObjectModel;\r
+\r
+ using HandBrake.ApplicationServices.Model;\r
+\r
+ /// <summary>\r
+ /// The Queue Manager Interface\r
+ /// </summary>\r
+ public interface IQueueManager\r
+ {\r
+ /// <summary>\r
+ /// Fires when a job is Added, Removed or Re-Ordered.\r
+ /// Should be used for triggering an update of the Queue Window.\r
+ /// </summary>\r
+ event EventHandler QueueChanged;\r
+\r
+ /// <summary>\r
+ /// Gets or sets Last Processed Job.\r
+ /// This is set when the job is poped of the queue by GetNextJobForProcessing();\r
+ /// </summary>\r
+ QueueTask LastProcessedJob { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets The current queue.\r
+ /// </summary>\r
+ ReadOnlyCollection<QueueTask> Queue { get; }\r
+\r
+ /// <summary>\r
+ /// Gets the number of jobs in the queue\r
+ /// </summary>\r
+ int Count { get; }\r
+\r
+ /// <summary>\r
+ /// Add a job to the Queue. \r
+ /// This method is Thread Safe.\r
+ /// </summary>\r
+ /// <param name="job">\r
+ /// The encode Job object.\r
+ /// </param>\r
+ void Add(QueueTask job);\r
+\r
+ /// <summary>\r
+ /// Remove a job from the Queue.\r
+ /// This method is Thread Safe\r
+ /// </summary>\r
+ /// <param name="job">\r
+ /// The job.\r
+ /// </param>\r
+ void Remove(QueueTask job);\r
+\r
+ /// <summary>\r
+ /// Get the first job on the queue for processing.\r
+ /// This also removes the job from the Queue and sets the LastProcessedJob\r
+ /// </summary>\r
+ /// <returns>\r
+ /// An encode Job object.\r
+ /// </returns>\r
+ QueueTask GetNextJobForProcessing();\r
+\r
+ /// <summary>\r
+ /// Moves an item up one position in the queue.\r
+ /// </summary>\r
+ /// <param name="index">The zero-based location of the job in the queue.</param>\r
+ void MoveUp(int index);\r
+\r
+ /// <summary>\r
+ /// Moves an item down one position in the queue.\r
+ /// </summary>\r
+ /// <param name="index">The zero-based location of the job in the queue.</param>\r
+ void MoveDown(int index);\r
+\r
+ /// <summary>\r
+ /// Backup any changes to the queue file\r
+ /// </summary>\r
+ /// <param name="exportPath">\r
+ /// If this is not null or empty, this will be used instead of the standard backup location.\r
+ /// </param>\r
+ void BackupQueue(string exportPath);\r
+\r
+ /// <summary>\r
+ /// Restore a Queue from file or from the queue backup file.\r
+ /// </summary>\r
+ /// <param name="importPath">\r
+ /// The import path. String.Empty or null will result in the default file being loaded.\r
+ /// </param>\r
+ void RestoreQueue(string importPath);\r
+\r
+ /// <summary>\r
+ /// Checks the current queue for an existing instance of the specified destination.\r
+ /// </summary>\r
+ /// <param name="destination">The destination of the encode.</param>\r
+ /// <returns>Whether or not the supplied destination is already in the queue.</returns>\r
+ bool CheckForDestinationPathDuplicates(string destination);\r
+\r
+ /// <summary>\r
+ /// Create a batch script from the queue\r
+ /// </summary>\r
+ /// <param name="path">\r
+ /// The path to the location for the script to be saved.\r
+ /// </param>\r
+ /// <returns>\r
+ /// True if sucessful\r
+ /// </returns>\r
+ bool WriteBatchScriptToFile(string path);\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+namespace HandBrake.ApplicationServices.Services.Interfaces\r
+{\r
+ using System;\r
+\r
+ /// <summary>\r
+ /// The Queue Processor\r
+ /// </summary>\r
+ public interface IQueueProcessor\r
+ {\r
+ /// <summary>\r
+ /// Fires when the Queue has started\r
+ /// </summary>\r
+ event QueueProcessor.QueueProgressStatus JobProcessingStarted;\r
+\r
+ /// <summary>\r
+ /// Fires when a pause to the encode queue has been requested.\r
+ /// </summary>\r
+ event EventHandler QueuePaused;\r
+\r
+ /// <summary>\r
+ /// Fires when the entire encode queue has completed.\r
+ /// </summary>\r
+ event EventHandler QueueCompleted;\r
+\r
+ /// <summary>\r
+ /// Gets the IEncodeService instance.\r
+ /// </summary>\r
+ IEncode EncodeService { get; }\r
+\r
+ /// <summary>\r
+ /// Gets the IQueueManager instance.\r
+ /// </summary>\r
+ IQueueManager QueueManager { get; }\r
+\r
+ /// <summary>\r
+ /// Gets a value indicating whether IsProcessing.\r
+ /// </summary>\r
+ bool IsProcessing { get; }\r
+\r
+ /// <summary>\r
+ /// Starts encoding the first job in the queue and continues encoding until all jobs\r
+ /// have been encoded.\r
+ /// </summary>\r
+ void Start();\r
+\r
+ /// <summary>\r
+ /// Requests a pause of the encode queue.\r
+ /// </summary>\r
+ void Pause();\r
+ }\r
+}
\ No newline at end of file
/// <summary>\r
/// The Queue Job List\r
/// </summary>\r
- private readonly List<Job> queue = new List<Job>();\r
+ private readonly List<QueueTask> queue = new List<QueueTask>();\r
\r
/// <summary>\r
/// An XML Serializer\r
/// Gets or sets the last encode that was processed.\r
/// </summary>\r
/// <returns></returns> \r
- public Job LastEncode { get; set; }\r
+ public QueueTask LastEncode { get; set; }\r
\r
/// <summary>\r
/// Gets a value indicating whether Request Pause\r
/// <summary>\r
/// Gets the current state of the encode queue.\r
/// </summary>\r
- public ReadOnlyCollection<Job> CurrentQueue\r
+ public ReadOnlyCollection<QueueTask> CurrentQueue\r
{\r
get { return this.queue.AsReadOnly(); }\r
}\r
/// Gets and removes the next job in the queue.\r
/// </summary>\r
/// <returns>The job that was removed from the queue.</returns>\r
- private Job GetNextJob()\r
+ private QueueTask GetNextJob()\r
{\r
- Job job = this.queue[0];\r
+ QueueTask job = this.queue[0];\r
this.LastEncode = job;\r
this.Remove(0); // Remove the item which we are about to pass out.\r
\r
/// </param>\r
public void Add(string query, int title, string source, string destination, bool customJob)\r
{\r
- Job newJob = new Job\r
+ QueueTask newJob = new QueueTask\r
{\r
Id = this.nextJobId++,\r
Title = title,\r
/// </summary>\r
/// <param name="index">the job id</param>\r
/// <returns>A job for the given index or blank job object</returns>\r
- public Job GetJob(int index)\r
+ public QueueTask GetJob(int index)\r
{\r
if (this.queue.Count >= (index + 1))\r
return this.queue[index];\r
\r
- return new Job();\r
+ return new QueueTask();\r
}\r
\r
/// <summary>\r
{\r
if (index > 0)\r
{\r
- Job item = queue[index];\r
+ QueueTask item = queue[index];\r
\r
queue.RemoveAt(index);\r
queue.Insert((index - 1), item);\r
{\r
if (index < this.queue.Count - 1)\r
{\r
- Job item = this.queue[index];\r
+ QueueTask item = this.queue[index];\r
\r
this.queue.RemoveAt(index);\r
this.queue.Insert((index + 1), item);\r
using (FileStream strm = new FileStream(tempPath, FileMode.Create, FileAccess.Write))\r
{\r
if (serializer == null)\r
- serializer = new XmlSerializer(typeof(List<Job>));\r
+ serializer = new XmlSerializer(typeof(List<QueueTask>));\r
serializer.Serialize(strm, queue);\r
strm.Close();\r
strm.Dispose();\r
public bool WriteBatchScriptToFile(string file)\r
{\r
string queries = string.Empty;\r
- foreach (Job queueItem in this.queue)\r
+ foreach (QueueTask queueItem in this.queue)\r
{\r
string qItem = queueItem.Query;\r
string fullQuery = '"' + Application.StartupPath + "\\HandBrakeCLI.exe" + '"' + qItem;\r
if (strm.Length != 0)\r
{\r
if (serializer == null)\r
- serializer = new XmlSerializer(typeof(List<Job>));\r
+ serializer = new XmlSerializer(typeof(List<QueueTask>));\r
\r
- List<Job> list = serializer.Deserialize(strm) as List<Job>;\r
+ List<QueueTask> list = serializer.Deserialize(strm) as List<QueueTask>;\r
\r
if (list != null)\r
- foreach (Job item in list)\r
+ foreach (QueueTask item in list)\r
this.queue.Add(item);\r
\r
if (!file.Contains("hb_queue_recovery"))\r
// Run through each item on the queue\r
while (this.Count != 0)\r
{\r
- Job encJob = this.GetNextJob();\r
+ QueueTask encJob = this.GetNextJob();\r
this.SaveQueue(); // Update the queue recovery file\r
\r
Run(encJob, true);\r
Thread.Sleep(2000);\r
}\r
}\r
- this.LastEncode = new Job();\r
+ this.LastEncode = new QueueTask();\r
\r
if (this.QueueCompleted != null)\r
this.QueueCompleted(this, new EventArgs());\r
--- /dev/null
+namespace HandBrake.ApplicationServices.Services\r
+{\r
+ using System;\r
+ using System.Collections.Generic;\r
+ using System.Collections.ObjectModel;\r
+ using System.IO;\r
+ using System.Linq;\r
+ using System.Windows.Forms;\r
+ using System.Xml.Serialization;\r
+\r
+ using HandBrake.ApplicationServices.Model;\r
+ using HandBrake.ApplicationServices.Services.Interfaces;\r
+\r
+ using EventArgs = System.EventArgs;\r
+\r
+ /// <summary>\r
+ /// The Queue Manager.\r
+ /// Thread Safe.\r
+ /// </summary>\r
+ public class QueueManager : IQueueManager\r
+ {\r
+ /*\r
+ * TODO\r
+ * - Multi HandBrake Instance Support for Queue Saving.\r
+ * - Rewrite the batch script generator. \r
+ */\r
+\r
+ #region Private Variables\r
+\r
+ /// <summary>\r
+ /// HandBrakes Queue file with a place holder for an extra string.\r
+ /// Use this with String.Format()\r
+ /// </summary>\r
+ private const string QueueFile = "hb_queue_recovery{0}.xml";\r
+\r
+ /// <summary>\r
+ /// A Lock object to maintain thread safety\r
+ /// </summary>\r
+ static readonly object QueueLock = new object();\r
+\r
+ /// <summary>\r
+ /// The Queue of Job objects\r
+ /// </summary>\r
+ private readonly List<QueueTask> queue = new List<QueueTask>();\r
+\r
+ /// <summary>\r
+ /// The ID of the job last added\r
+ /// </summary>\r
+ private int lastJobId;\r
+\r
+ /// <summary>\r
+ /// The instance Id of this HandBrake instance.\r
+ /// </summary>\r
+ private int instanceId;\r
+\r
+ #endregion\r
+\r
+ /// <summary>\r
+ /// Initializes a new instance of the <see cref="QueueManager"/> class.\r
+ /// </summary>\r
+ /// <param name="instanceId">\r
+ /// The instance Id.\r
+ /// </param>\r
+ public QueueManager(int instanceId)\r
+ {\r
+ this.instanceId = instanceId;\r
+ }\r
+\r
+ #region Events\r
+ /// <summary>\r
+ /// Fires when a job is Added, Removed or Re-Ordered.\r
+ /// Should be used for triggering an update of the Queue Window.\r
+ /// </summary>\r
+ public event EventHandler QueueChanged;\r
+\r
+ /// <summary>\r
+ /// Invoke the Queue Changed Event\r
+ /// </summary>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
+ private void InvokeQueueChanged(EventArgs e)\r
+ {\r
+ try\r
+ {\r
+ this.BackupQueue(string.Empty);\r
+ }\r
+ catch (Exception)\r
+ {\r
+ // Do Nothing.\r
+ }\r
+\r
+ EventHandler handler = this.QueueChanged;\r
+ if (handler != null)\r
+ {\r
+ handler(this, e);\r
+ }\r
+ }\r
+\r
+ #endregion\r
+\r
+ #region Public Properties\r
+\r
+ /// <summary>\r
+ /// Gets or sets Last Processed Job.\r
+ /// This is set when the job is poped of the queue by GetNextJobForProcessing();\r
+ /// </summary>\r
+ public QueueTask LastProcessedJob { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets the number of jobs in the queue;\r
+ /// </summary>\r
+ public int Count\r
+ {\r
+ get\r
+ {\r
+ return this.queue.Count;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets The current queue.\r
+ /// </summary>\r
+ public ReadOnlyCollection<QueueTask> Queue\r
+ {\r
+ get\r
+ {\r
+ return this.queue.AsReadOnly();\r
+ }\r
+ }\r
+\r
+ #endregion\r
+\r
+ #region Public Methods\r
+\r
+ /// <summary>\r
+ /// Add a job to the Queue. \r
+ /// This method is Thread Safe.\r
+ /// </summary>\r
+ /// <param name="job">\r
+ /// The encode Job object.\r
+ /// </param>\r
+ public void Add(QueueTask job)\r
+ {\r
+ lock (QueueLock)\r
+ {\r
+ // Tag the job with an ID\r
+ job.Id = lastJobId++;\r
+ queue.Add(job);\r
+ InvokeQueueChanged(EventArgs.Empty);\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Remove a job from the Queue.\r
+ /// This method is Thread Safe\r
+ /// </summary>\r
+ /// <param name="job">\r
+ /// The job.\r
+ /// </param>\r
+ public void Remove(QueueTask job)\r
+ {\r
+ lock (QueueLock)\r
+ {\r
+ // Tag the job with an ID\r
+ job.Id = lastJobId++;\r
+ queue.Add(job);\r
+ InvokeQueueChanged(EventArgs.Empty);\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Get the first job on the queue for processing.\r
+ /// This also removes the job from the Queue and sets the LastProcessedJob\r
+ /// </summary>\r
+ /// <returns>\r
+ /// An encode Job object.\r
+ /// </returns>\r
+ public QueueTask GetNextJobForProcessing()\r
+ {\r
+ if (this.queue.Count > 0)\r
+ {\r
+ QueueTask job = this.queue[0];\r
+ this.LastProcessedJob = job;\r
+ this.Remove(job); // Remove the item which we are about to pass out.\r
+\r
+ return job; \r
+ }\r
+\r
+ return null;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Moves an item up one position in the queue.\r
+ /// </summary>\r
+ /// <param name="index">The zero-based location of the job in the queue.</param>\r
+ public void MoveUp(int index)\r
+ {\r
+ if (index > 0)\r
+ {\r
+ QueueTask item = queue[index];\r
+\r
+ queue.RemoveAt(index);\r
+ queue.Insert((index - 1), item);\r
+ }\r
+\r
+ this.InvokeQueueChanged(EventArgs.Empty);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Moves an item down one position in the queue.\r
+ /// </summary>\r
+ /// <param name="index">The zero-based location of the job in the queue.</param>\r
+ public void MoveDown(int index)\r
+ {\r
+ if (index < this.queue.Count - 1)\r
+ {\r
+ QueueTask item = this.queue[index];\r
+\r
+ this.queue.RemoveAt(index);\r
+ this.queue.Insert((index + 1), item);\r
+ }\r
+\r
+ this.InvokeQueueChanged(EventArgs.Empty);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Backup any changes to the queue file\r
+ /// </summary>\r
+ /// <param name="exportPath">\r
+ /// If this is not null or empty, this will be used instead of the standard backup location.\r
+ /// </param>\r
+ public void BackupQueue(string exportPath)\r
+ {\r
+ string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\");\r
+ string tempPath = !string.IsNullOrEmpty(exportPath) ? exportPath : appDataPath + string.Format(QueueFile, string.Empty);\r
+\r
+ if (File.Exists(tempPath))\r
+ {\r
+ using (FileStream strm = new FileStream(tempPath, FileMode.Create, FileAccess.Write))\r
+ {\r
+ XmlSerializer serializer = new XmlSerializer(typeof(List<QueueTask>));\r
+ serializer.Serialize(strm, queue);\r
+ strm.Close();\r
+ strm.Dispose();\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Restore a Queue from file or from the queue backup file.\r
+ /// </summary>\r
+ /// <param name="importPath">\r
+ /// The import path. String.Empty or null will result in the default file being loaded.\r
+ /// </param>\r
+ public void RestoreQueue(string importPath)\r
+ {\r
+ string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\");\r
+ string tempPath = !string.IsNullOrEmpty(importPath) ? importPath : (appDataPath + string.Format(QueueFile, string.Empty));\r
+\r
+ if (File.Exists(tempPath))\r
+ {\r
+ using (FileStream strm = new FileStream((!string.IsNullOrEmpty(importPath) ? importPath : tempPath), FileMode.Open, FileAccess.Read))\r
+ {\r
+ if (strm.Length != 0)\r
+ {\r
+ XmlSerializer serializer = new XmlSerializer(typeof(List<QueueTask>));\r
+\r
+ List<QueueTask> list = serializer.Deserialize(strm) as List<QueueTask>;\r
+\r
+ if (list != null)\r
+ foreach (QueueTask item in list)\r
+ this.queue.Add(item);\r
+\r
+ this.InvokeQueueChanged(EventArgs.Empty);\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Checks the current queue for an existing instance of the specified destination.\r
+ /// </summary>\r
+ /// <param name="destination">The destination of the encode.</param>\r
+ /// <returns>Whether or not the supplied destination is already in the queue.</returns>\r
+ public bool CheckForDestinationPathDuplicates(string destination)\r
+ {\r
+ return this.queue.Any(checkItem => checkItem.Task.Destination.Contains(destination.Replace("\\\\", "\\")));\r
+ }\r
+\r
+ /// <summary>\r
+ /// Writes the current state of the queue in the form of a batch (.bat) file.\r
+ /// </summary>\r
+ /// <param name="file">\r
+ /// The location of the file to write the batch file to.\r
+ /// </param>\r
+ /// <returns>\r
+ /// The write batch script to file.\r
+ /// </returns>\r
+ public bool WriteBatchScriptToFile(string file)\r
+ {\r
+ string queries = string.Empty;\r
+ foreach (QueueTask queueItem in this.queue)\r
+ {\r
+ string qItem = queueItem.Query;\r
+ string fullQuery = '"' + Application.StartupPath + "\\HandBrakeCLI.exe" + '"' + qItem;\r
+\r
+ if (queries == string.Empty)\r
+ queries = queries + fullQuery;\r
+ else\r
+ queries = queries + " && " + fullQuery;\r
+ }\r
+ string strCmdLine = queries;\r
+\r
+ if (file != string.Empty)\r
+ {\r
+ try\r
+ {\r
+ // Create a StreamWriter and open the file, Write the batch file query to the file and \r
+ // Close the stream\r
+ using (StreamWriter line = new StreamWriter(file))\r
+ {\r
+ line.WriteLine(strCmdLine);\r
+ }\r
+\r
+ return true;\r
+ }\r
+ catch (Exception exc)\r
+ {\r
+ throw new Exception("Unable to write to the file. Please make sure that the location has the correct permissions for file writing.", exc);\r
+ }\r
+ }\r
+ return false;\r
+ }\r
+\r
+ #endregion\r
+ }\r
+}\r
--- /dev/null
+/* Queue.cs $\r
+ This file is part of the HandBrake source code.\r
+ Homepage: <http://handbrake.fr/>.\r
+ It may be used under the terms of the GNU General Public License. */\r
+\r
+namespace HandBrake.ApplicationServices.Services\r
+{\r
+ using System;\r
+ using System.Collections.Generic;\r
+ using System.Collections.ObjectModel;\r
+ using System.Diagnostics;\r
+ using System.IO;\r
+ using System.Linq;\r
+ using System.Threading;\r
+ using System.Windows.Forms;\r
+ using System.Xml.Serialization;\r
+\r
+ using HandBrake.ApplicationServices.EventArgs;\r
+ using HandBrake.ApplicationServices.Functions;\r
+ using HandBrake.ApplicationServices.Model;\r
+ using HandBrake.ApplicationServices.Services.Interfaces;\r
+\r
+ /// <summary>\r
+ /// The HandBrake Queue\r
+ /// </summary>\r
+ public class QueueProcessor // : IQueueProcessor\r
+ {\r
+ /*\r
+ * TODO\r
+ * - Hook this up when the new encode service is in place\r
+ */\r
+\r
+ /// <summary>\r
+ /// Initializes a new instance of the <see cref="QueueProcessor"/> class.\r
+ /// </summary>\r
+ /// <param name="queueManager">\r
+ /// The queue manager.\r
+ /// </param>\r
+ /// <param name="encodeService">\r
+ /// The encode Service.\r
+ /// </param>\r
+ /// <exception cref="ArgumentNullException">\r
+ /// </exception>\r
+ public QueueProcessor(IQueueManager queueManager, IEncode encodeService)\r
+ {\r
+ //this.QueueManager = queueManager;\r
+ //this.EncodeService = encodeService;\r
+\r
+ //if (this.QueueManager == null)\r
+ //{\r
+ // throw new ArgumentNullException("queueManager");\r
+ //}\r
+\r
+ //if (this.QueueManager == null)\r
+ //{\r
+ // throw new ArgumentNullException("queueManager");\r
+ //}\r
+ }\r
+\r
+ /// <summary>\r
+ /// Initializes a new instance of the <see cref="QueueProcessor"/> class.\r
+ /// This call also initializes the Encode and QueueManager services\r
+ /// </summary>\r
+ /// <param name="instanceId">\r
+ /// The instance id.\r
+ /// </param>\r
+ public QueueProcessor(int instanceId)\r
+ {\r
+ //this.EncodeService = new Encode();\r
+ // this.QueueManager = new QueueManager(instanceId);\r
+ }\r
+\r
+ //#region Events\r
+\r
+ /// <summary>\r
+ /// Queue Progess Status\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The QueueProgressEventArgs.\r
+ /// </param>\r
+ public delegate void QueueProgressStatus(object sender, QueueProgressEventArgs e);\r
+\r
+ ///// <summary>\r
+ ///// Fires when the Queue has started\r
+ ///// </summary>\r
+ //public event QueueProgressStatus JobProcessingStarted;\r
+\r
+ ///// <summary>\r
+ ///// Fires when a pause to the encode queue has been requested.\r
+ ///// </summary>\r
+ //public event EventHandler QueuePaused;\r
+\r
+ ///// <summary>\r
+ ///// Fires when the entire encode queue has completed.\r
+ ///// </summary>\r
+ //public event EventHandler QueueCompleted;\r
+\r
+ ///// <summary>\r
+ ///// Invoke the JobProcessingStarted event\r
+ ///// </summary>\r
+ ///// <param name="e">\r
+ ///// The QueueProgressEventArgs.\r
+ ///// </param>\r
+ //private void InvokeJobProcessingStarted(QueueProgressEventArgs e)\r
+ //{\r
+ // QueueProgressStatus handler = this.JobProcessingStarted;\r
+ // if (handler != null)\r
+ // {\r
+ // handler(this, e);\r
+ // }\r
+ //}\r
+\r
+ ///// <summary>\r
+ ///// Invoke the QueuePaused event\r
+ ///// </summary>\r
+ ///// <param name="e">\r
+ ///// The EventArgs.\r
+ ///// </param>\r
+ //private void InvokeQueuePaused(EventArgs e)\r
+ //{\r
+ // EventHandler handler = this.QueuePaused;\r
+ // if (handler != null)\r
+ // {\r
+ // handler(this, e);\r
+ // }\r
+ //}\r
+\r
+ ///// <summary>\r
+ ///// Invoke the QueueCompleted event.\r
+ ///// </summary>\r
+ ///// <param name="e">\r
+ ///// The EventArgs.\r
+ ///// </param>\r
+ //private void InvokeQueueCompleted(EventArgs e)\r
+ //{\r
+ // this.IsProcessing = false;\r
+\r
+ // EventHandler handler = this.QueueCompleted;\r
+ // if (handler != null)\r
+ // {\r
+ // handler(this, e);\r
+ // }\r
+ //}\r
+\r
+ //#endregion\r
+\r
+ //#region Properties\r
+\r
+ ///// <summary>\r
+ ///// Gets a value indicating whether IsProcessing.\r
+ ///// </summary>\r
+ //public bool IsProcessing { get; private set; }\r
+\r
+ ///// <summary>\r
+ ///// Gets the IEncodeService instance.\r
+ ///// </summary>\r
+ //public IEncode EncodeService { get; private set; }\r
+\r
+ ///// <summary>\r
+ ///// Gets the IQueueManager instance.\r
+ ///// </summary>\r
+ //public IQueueManager QueueManager { get; private set; }\r
+\r
+ //#endregion\r
+\r
+ ///// <summary>\r
+ ///// Starts encoding the first job in the queue and continues encoding until all jobs\r
+ ///// have been encoded.\r
+ ///// </summary>\r
+ //public void Start()\r
+ //{\r
+ // if (IsProcessing)\r
+ // {\r
+ // throw new Exception("Already Processing the Queue");\r
+ // }\r
+\r
+ // IsProcessing = true;\r
+ // this.EncodeService.EncodeCompleted += this.EncodeServiceEncodeCompleted;\r
+ // this.ProcessNextJob();\r
+ //}\r
+\r
+ ///// <summary>\r
+ ///// Requests a pause of the encode queue.\r
+ ///// </summary>\r
+ //public void Pause()\r
+ //{\r
+ // this.EncodeService.EncodeCompleted -= this.EncodeServiceEncodeCompleted; \r
+ // this.InvokeQueuePaused(EventArgs.Empty);\r
+ // this.IsProcessing = false;\r
+ //}\r
+\r
+ ///// <summary>\r
+ ///// After an encode is complete, move onto the next job.\r
+ ///// </summary>\r
+ ///// <param name="sender">\r
+ ///// The sender.\r
+ ///// </param>\r
+ ///// <param name="e">\r
+ ///// The EncodeCompletedEventArgs.\r
+ ///// </param>\r
+ //private void EncodeServiceEncodeCompleted(object sender, EncodeCompletedEventArgs e)\r
+ //{\r
+ // // Growl\r
+ // if (Init.GrowlEncode)\r
+ // GrowlCommunicator.Notify("Encode Completed",\r
+ // "Put down that cocktail...\nyour Handbrake encode is done.");\r
+\r
+ // // Handling Log Data \r
+ // // TODO - Still need to re-write this using CopyLog()\r
+\r
+ // // Move onto the next job.\r
+ // this.ProcessNextJob();\r
+ //}\r
+\r
+ ///// <summary>\r
+ ///// Run through all the jobs on the queue.\r
+ ///// </summary>\r
+ //private void ProcessNextJob()\r
+ //{\r
+ // if (this.EncodeService.IsEncoding)\r
+ // {\r
+ // // We don't want to try start a second encode, so just return out. The event will trigger the next encode automatically.\r
+ // return;\r
+ // }\r
+\r
+ // QueueTask job = this.QueueManager.GetNextJobForProcessing();\r
+ // if (job != null)\r
+ // {\r
+ // this.EncodeService.Start(job, true);\r
+ // this.InvokeJobProcessingStarted(new QueueProgressEventArgs(job));\r
+ // } \r
+ // else\r
+ // {\r
+ // // No more jobs to process, so unsubscribe the event\r
+ // this.EncodeService.EncodeCompleted -= this.EncodeServiceEncodeCompleted;\r
+\r
+ // // Fire the event to tell connected services.\r
+ // this.InvokeQueueCompleted(EventArgs.Empty);\r
+\r
+ // // Run the After encode completeion work\r
+ // Finish();\r
+ // }\r
+ //}\r
+\r
+ ///// <summary>\r
+ ///// Perform an action after an encode. e.g a shutdown, standby, restart etc.\r
+ ///// </summary>\r
+ //private static void Finish()\r
+ //{\r
+ // // Growl\r
+ // if (Init.GrowlQueue)\r
+ // GrowlCommunicator.Notify("Queue Completed", "Put down that cocktail...\nyour Handbrake queue is done.");\r
+\r
+ // // Do something whent he encode ends.\r
+ // switch (Init.CompletionOption)\r
+ // {\r
+ // case "Shutdown":\r
+ // Process.Start("Shutdown", "-s -t 60");\r
+ // break;\r
+ // case "Log Off":\r
+ // Win32.ExitWindowsEx(0, 0);\r
+ // break;\r
+ // case "Suspend":\r
+ // Application.SetSuspendState(PowerState.Suspend, true, true);\r
+ // break;\r
+ // case "Hibernate":\r
+ // Application.SetSuspendState(PowerState.Hibernate, true, true);\r
+ // break;\r
+ // case "Lock System":\r
+ // Win32.LockWorkStation();\r
+ // break;\r
+ // case "Quit HandBrake":\r
+ // Application.Exit();\r
+ // break;\r
+ // default:\r
+ // break;\r
+ // }\r
+ //}\r
+ }\r
+}
\ No newline at end of file
-<?xml version="1.0" encoding="utf-8" ?>\r
+<?xml version="1.0"?>\r
<configuration>\r
<configSections>\r
- <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >\r
- <section name="HandBrake.ApplicationServices.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />\r
+ <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
+ <section name="HandBrake.ApplicationServices.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>\r
</sectionGroup>\r
</configSections>\r
<userSettings>\r
<value>False</value>\r
</setting>\r
<setting name="saveLogPath" serializeAs="String">\r
- <value />\r
+ <value/>\r
</setting>\r
<setting name="saveLogToSpecifiedPath" serializeAs="String">\r
<value>False</value>\r
<value>False</value>\r
</setting>\r
<setting name="CompletionOption" serializeAs="String">\r
- <value />\r
+ <value/>\r
</setting>\r
<setting name="processPriority" serializeAs="String">\r
- <value />\r
+ <value/>\r
</setting>\r
<setting name="showCliForInGuiEncodeStatus" serializeAs="String">\r
<value>False</value>\r
</setting>\r
</HandBrake.ApplicationServices.Properties.Settings>\r
</userSettings>\r
-</configuration>
\ No newline at end of file
+<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>\r
<Abbreviation Text="TX" />\r
<Abbreviation Text="SRT" />\r
<Abbreviation Text="CLI" />\r
+ <Abbreviation Text="MP" />\r
</Naming2>\r
<CustomMemberReorderingPatterns><![CDATA[<?xml version="1.0" encoding="utf-8"?>\r
<Patterns xmlns="urn:shemas-jetbrains-com:member-reordering-patterns">\r
<Compile Include="frmActivityWindow.Designer.cs">\r
<DependentUpon>frmActivityWindow.cs</DependentUpon>\r
</Compile>\r
- <Compile Include="Model\AudioTrack.cs" />\r
<Compile Include="Model\DriveInformation.cs" />\r
<Compile Include="Model\SourceType.cs" />\r
- <Compile Include="Model\Subtitle.cs" />\r
<Compile Include="Presets\PlistPresetHandler.cs" />\r
<Compile Include="Presets\Preset.cs" />\r
<Compile Include="Presets\PresetsHandler.cs" />\r
using System.Windows.Forms;\r
using System.Xml;\r
using Functions;\r
+\r
+ using HandBrake.ApplicationServices.Model.Encoding;\r
+\r
using Model;\r
\r
/// <summary>\r
private DVD currentSource;\r
private IScan SourceScan = new ScanService();\r
private List<DriveInformation> drives;\r
- private Job queueEdit;\r
+ private QueueTask queueEdit;\r
\r
// Delegates **********************************************************\r
private delegate void UpdateWindowHandler();\r
/// <param name="job">\r
/// The job.\r
/// </param>\r
- public void RecievingJob(Job job)\r
+ public void RecievingJob(QueueTask job)\r
{\r
// Reset\r
this.currentlySelectedPreset = null;\r
using Functions;\r
\r
using HandBrake.ApplicationServices.Model;\r
+ using HandBrake.ApplicationServices.Model.Encoding;\r
using HandBrake.ApplicationServices.Services;\r
using HandBrake.ApplicationServices.Services.Interfaces;\r
\r
}\r
\r
list_queue.Items.Clear();\r
- ReadOnlyCollection<Job> theQueue = queue.CurrentQueue;\r
- foreach (Job queueItem in theQueue)\r
+ ReadOnlyCollection<QueueTask> theQueue = queue.CurrentQueue;\r
+ foreach (QueueTask queueItem in theQueue)\r
{\r
string qItem = queueItem.Query;\r
QueryParser parsed = Functions.QueryParser.Parse(qItem);\r