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