summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.ApplicationServices
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices')
-rw-r--r--win/CS/HandBrake.ApplicationServices/Functions/Converters.cs2
-rw-r--r--win/CS/HandBrake.ApplicationServices/Functions/EnumHelper.cs5
-rw-r--r--win/CS/HandBrake.ApplicationServices/Functions/InteropModelCreator.cs79
-rw-r--r--win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj2
-rw-r--r--win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioEncoder.cs48
-rw-r--r--win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs1
-rw-r--r--win/CS/HandBrake.ApplicationServices/Model/Encoding/Mixdown.cs39
-rw-r--r--win/CS/HandBrake.ApplicationServices/Model/QueueTask.cs26
-rw-r--r--win/CS/HandBrake.ApplicationServices/ServiceManager.cs17
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs6
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/LibScan.cs2
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs3
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs2
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs3
14 files changed, 93 insertions, 142 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Functions/Converters.cs b/win/CS/HandBrake.ApplicationServices/Functions/Converters.cs
index ba6331fcf..fac4dd17c 100644
--- a/win/CS/HandBrake.ApplicationServices/Functions/Converters.cs
+++ b/win/CS/HandBrake.ApplicationServices/Functions/Converters.cs
@@ -10,8 +10,6 @@ namespace HandBrake.ApplicationServices.Functions
using HandBrake.Interop.Model.Encoding;
- using AudioEncoder = HandBrake.ApplicationServices.Model.Encoding.AudioEncoder;
- using Mixdown = HandBrake.ApplicationServices.Model.Encoding.Mixdown;
using OutputFormat = HandBrake.ApplicationServices.Model.Encoding.OutputFormat;
/// <summary>
diff --git a/win/CS/HandBrake.ApplicationServices/Functions/EnumHelper.cs b/win/CS/HandBrake.ApplicationServices/Functions/EnumHelper.cs
index 53d7f6069..ad565f0b7 100644
--- a/win/CS/HandBrake.ApplicationServices/Functions/EnumHelper.cs
+++ b/win/CS/HandBrake.ApplicationServices/Functions/EnumHelper.cs
@@ -41,7 +41,7 @@ namespace HandBrake.ApplicationServices.Functions
/// </summary>
/// <param name="value">An Enum with Display Attributes</param>
/// <returns>A string name</returns>
- public static string GetDisplayValue(T value)
+ public static string GetDisplay(T value)
{
FieldInfo fieldInfo = value.GetType().GetField(value.ToString());
DisplayAttribute[] attributes = (DisplayAttribute[])fieldInfo.GetCustomAttributes(typeof(DisplayAttribute), false);
@@ -59,7 +59,8 @@ namespace HandBrake.ApplicationServices.Functions
foreach (T val in Enum.GetValues(typeof(T)))
{
string currDescription = GetDescription(val);
- if (currDescription == description)
+ string currDisplay = GetDisplay(val);
+ if (currDescription == description || currDisplay == description)
{
return val;
}
diff --git a/win/CS/HandBrake.ApplicationServices/Functions/InteropModelCreator.cs b/win/CS/HandBrake.ApplicationServices/Functions/InteropModelCreator.cs
index da7303c01..62fe16120 100644
--- a/win/CS/HandBrake.ApplicationServices/Functions/InteropModelCreator.cs
+++ b/win/CS/HandBrake.ApplicationServices/Functions/InteropModelCreator.cs
@@ -46,12 +46,18 @@ namespace HandBrake.ApplicationServices.Functions
// Which will be converted to this EncodeJob Model.
EncodeJob job = new EncodeJob();
+
+
+
+
+
EncodingProfile profile = new EncodingProfile();
job.EncodingProfile = profile;
profile.Anamorphic = work.Anamorphic;
profile.AudioEncodings = new List<AudioEncoding>();
+ job.ChosenAudioTracks = new List<int>();
foreach (AudioTrack track in work.AudioTracks)
{
AudioEncoding newTrack = new AudioEncoding
@@ -59,16 +65,19 @@ namespace HandBrake.ApplicationServices.Functions
Bitrate = track.Bitrate,
Drc = track.DRC,
Gain = track.Gain,
- //Encoder = track.Encoder,
- // InputNumber = track.Track,
- //Mixdown = track.MixDown,
- //SampleRateRaw = track.SampleRate
+ Encoder = track.Encoder,
+ InputNumber = track.Track.HasValue ? track.Track.Value : 0,
+ Mixdown = track.MixDown,
+ SampleRateRaw = GetSampleRateRaw(track.SampleRate),
};
profile.AudioEncodings.Add(newTrack);
+ if (track.Track != null)
+ {
+ job.ChosenAudioTracks.Add(track.Track.Value);
+ }
}
-
- profile.Cropping = new HandBrake.Interop.Model.Cropping
+ profile.Cropping = new Cropping
{
Top = work.Cropping.Top,
Bottom = work.Cropping.Bottom,
@@ -117,34 +126,17 @@ namespace HandBrake.ApplicationServices.Functions
switch (work.OutputFormat)
{
case OutputFormat.Mp4:
- profile.PreferredExtension = Interop.Model.Encoding.OutputExtension.Mp4;
+ profile.PreferredExtension = OutputExtension.Mp4;
break;
case OutputFormat.M4V:
- profile.PreferredExtension = Interop.Model.Encoding.OutputExtension.M4v;
+ profile.PreferredExtension = OutputExtension.M4v;
break;
}
profile.Quality = work.Quality.HasValue ? work.Quality.Value : 0;
profile.UseDisplayWidth = true;
profile.VideoBitrate = work.VideoBitrate.HasValue ? work.VideoBitrate.Value : 0;
profile.VideoEncodeRateType = work.VideoEncodeRateType;
-
- switch (work.VideoEncoder)
- {
- case VideoEncoder.X264:
- profile.VideoEncoder = Interop.Model.Encoding.VideoEncoder.X264;
- break;
- case VideoEncoder.FFMpeg:
- profile.VideoEncoder = Interop.Model.Encoding.VideoEncoder.FFMpeg;
- break;
- case VideoEncoder.FFMpeg2:
- profile.VideoEncoder = Interop.Model.Encoding.VideoEncoder.FFMpeg; // TODO Fix This.
- break;
- case VideoEncoder.Theora:
- profile.VideoEncoder = Interop.Model.Encoding.VideoEncoder.Theora;
- break;
-
- }
-
+ profile.VideoEncoder = work.VideoEncoder;
profile.Width = work.Width.HasValue ? work.Width.Value : 0;
profile.X264Options = work.AdvancedEncoderOptions;
@@ -162,6 +154,9 @@ namespace HandBrake.ApplicationServices.Functions
job.FramesStart = work.StartPoint;
}
+ job.CustomChapterNames = work.ChapterNames;
+ job.UseDefaultChapterNames = work.IncludeChapterMarkers;
+
job.OutputPath = work.Destination;
switch (work.PointToPointMode)
{
@@ -186,14 +181,38 @@ namespace HandBrake.ApplicationServices.Functions
job.SourcePath = work.Source;
// job.SourceType = work.Type;
job.Title = work.Title;
+
+ // TODO Setup subtitles
job.Subtitles = new Subtitles { SourceSubtitles = new List<SourceSubtitle>(), SrtSubtitles = new List<SrtSubtitle>() };
- foreach (SubtitleTrack track in work.SubtitleTracks)
- {
- // TODO
- }
+ //foreach (SubtitleTrack track in work.SubtitleTracks)
+ //{
+ // // TODO
+ //}
return job;
}
+
+ /// <summary>
+ /// Get the Raw Sample Rate
+ /// </summary>
+ /// <param name="rate">
+ /// The rate.
+ /// </param>
+ /// <returns>
+ /// The Raw sample rate as an int
+ /// </returns>
+ private static int GetSampleRateRaw(double rate)
+ {
+ if (rate == 22.05)
+ return 22050;
+ else if (rate == 24)
+ return 24000;
+ else if (rate == 44.1)
+ return 32000;
+ else if (rate == 48)
+ return 48000;
+ else return 48000;
+ }
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
index f9600e3fd..412719085 100644
--- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
+++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
@@ -96,9 +96,7 @@
<Compile Include="Functions\Win7.cs" />
<Compile Include="Model\DriveInformation.cs" />
<Compile Include="Model\Encoding\AudioTrack.cs" />
- <Compile Include="Model\Encoding\AudioEncoder.cs" />
<Compile Include="Model\Encoding\FramerateMode.cs" />
- <Compile Include="Model\Encoding\Mixdown.cs" />
<Compile Include="Model\Encoding\PointToPointMode.cs" />
<Compile Include="Model\EncodeTask.cs" />
<Compile Include="Model\Encoding\OutputFormat.cs" />
diff --git a/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioEncoder.cs b/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioEncoder.cs
deleted file mode 100644
index 6dfff1076..000000000
--- a/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioEncoder.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-/* AudioEncoder.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.Encoding
-{
- using System.ComponentModel;
-
- using HandBrake.ApplicationServices.Converters;
-
- [TypeConverter(typeof(EnumToDescConveter))]
- public enum AudioEncoder
- {
- [Description("AAC (faac)")]
- Faac = 0,
-
- [Description("AAC (ffmpeg)")]
- ffaac,
-
- [Description("MP3 (lame)")]
- Lame,
-
- [Description("AC3 (ffmpeg)")]
- Ac3,
-
- [Description("Passthru")]
- Passthrough,
-
- [Description("AC3 Passthru")]
- Ac3Passthrough,
-
- [Description("DTS Passthru")]
- DtsPassthrough,
-
- [Description("DTS-HD Passthru")]
- DtsHDPassthrough,
-
- [Description("AAC Passthru")]
- AacPassthru,
-
- [Description("MP3 Passthru")]
- Mp3Passthru,
-
- [Description("Vorbis (vorbis)")]
- Vorbis
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs b/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs
index a6e83735b..6fcc57e2a 100644
--- a/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs
+++ b/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs
@@ -9,6 +9,7 @@ namespace HandBrake.ApplicationServices.Model.Encoding
using System.ComponentModel;
using HandBrake.ApplicationServices.Parsing;
+ using HandBrake.Interop.Model.Encoding;
/// <summary>
/// An Audio Track for the Audio Panel
diff --git a/win/CS/HandBrake.ApplicationServices/Model/Encoding/Mixdown.cs b/win/CS/HandBrake.ApplicationServices/Model/Encoding/Mixdown.cs
deleted file mode 100644
index d2e13e52e..000000000
--- a/win/CS/HandBrake.ApplicationServices/Model/Encoding/Mixdown.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Mixdown.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.Encoding
-{
- using System.ComponentModel;
-
- using HandBrake.ApplicationServices.Converters;
-
- /// <summary>
- /// The Mixdown Mode
- /// </summary>
- [TypeConverter(typeof(EnumToDescConveter))]
- 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,
-
- [Description("Passthru")]
- Passthrough,
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Model/QueueTask.cs b/win/CS/HandBrake.ApplicationServices/Model/QueueTask.cs
index cee9ad36f..245a3171d 100644
--- a/win/CS/HandBrake.ApplicationServices/Model/QueueTask.cs
+++ b/win/CS/HandBrake.ApplicationServices/Model/QueueTask.cs
@@ -5,18 +5,17 @@
namespace HandBrake.ApplicationServices.Model
{
- using System;
+ using HandBrake.ApplicationServices.Utilities;
/// <summary>
/// The QueueTask.
/// </summary>
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>
+ /// The Encode task backing field.
+ /// </summary>
+ private EncodeTask task;
/// <summary>
/// Initializes a new instance of the <see cref="QueueTask"/> class.
@@ -72,9 +71,20 @@ namespace HandBrake.ApplicationServices.Model
public QueueItemStatus Status { get; set; }
/// <summary>
- /// Gets or sets the Encode Task.
+ /// Gets the Encode Task.
/// </summary>
- public EncodeTask Task { get; set; }
+ public EncodeTask Task
+ {
+ get
+ {
+ if (this.task == null)
+ {
+ task = QueryParserUtility.Parse(this.Query);
+ }
+
+ return this.task;
+ }
+ }
/// <summary>
/// Gets a value indicating whether or not this instance is empty.
diff --git a/win/CS/HandBrake.ApplicationServices/ServiceManager.cs b/win/CS/HandBrake.ApplicationServices/ServiceManager.cs
index 06b4422e2..e0ad65ae5 100644
--- a/win/CS/HandBrake.ApplicationServices/ServiceManager.cs
+++ b/win/CS/HandBrake.ApplicationServices/ServiceManager.cs
@@ -2,6 +2,7 @@
{
using HandBrake.ApplicationServices.Services;
using HandBrake.ApplicationServices.Services.Interfaces;
+ using HandBrake.Interop;
/// <summary>
/// Tempory Class which manages services until Windosor is added back into the project to handle it for us.
@@ -14,6 +15,11 @@
private static IUserSettingService userSettingService;
/// <summary>
+ /// The Backing field for HandBrake Instance.
+ /// </summary>
+ private static HandBrakeInstance handBrakeInstance;
+
+ /// <summary>
/// Gets UserSettingService.
/// </summary>
public static IUserSettingService UserSettingService
@@ -23,5 +29,16 @@
return userSettingService ?? (userSettingService = new UserSettingService());
}
}
+
+ /// <summary>
+ /// Gets HandBrakeInstance.
+ /// </summary>
+ public static HandBrakeInstance HandBrakeInstance
+ {
+ get
+ {
+ return handBrakeInstance ?? (handBrakeInstance = new HandBrakeInstance());
+ }
+ }
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs
index 57f4b18fd..99e8be748 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs
@@ -7,8 +7,6 @@ namespace HandBrake.ApplicationServices.Services
{
using System;
using System.Diagnostics;
- using System.Text;
- using System.Threading;
using HandBrake.ApplicationServices.Functions;
using HandBrake.ApplicationServices.Model;
@@ -60,7 +58,7 @@ namespace HandBrake.ApplicationServices.Services
public LibEncode()
{
// Setup the HandBrake Instance
- this.instance = new HandBrakeInstance();
+ this.instance = ServiceManager.HandBrakeInstance;
this.instance.EncodeCompleted += this.InstanceEncodeCompleted;
this.instance.EncodeProgress += this.InstanceEncodeProgress;
@@ -81,8 +79,6 @@ namespace HandBrake.ApplicationServices.Services
/// </param>
public void Start(QueueTask job, bool enableLogging)
{
- throw new NotImplementedException("This Method has not been completed yet");
-
this.startTime = DateTime.Now;
this.loggingEnabled = enableLogging;
diff --git a/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs b/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs
index 33459a0dd..3e2e166ce 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs
@@ -59,7 +59,7 @@ namespace HandBrake.ApplicationServices.Services
{
logging = new StringBuilder();
- instance = new HandBrakeInstance();
+ instance = ServiceManager.HandBrakeInstance;
instance.Initialize(1);
instance.ScanProgress += this.InstanceScanProgress;
instance.ScanCompleted += this.InstanceScanCompleted;
diff --git a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs
index 91667debe..e9342ca4e 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs
@@ -7,6 +7,7 @@ namespace HandBrake.ApplicationServices.Services
{
using System;
using System.Diagnostics;
+ using System.IO;
using System.Windows.Forms;
using HandBrake.ApplicationServices.EventArgs;
@@ -62,7 +63,7 @@ namespace HandBrake.ApplicationServices.Services
/// </param>
public QueueProcessor(int instanceId)
{
- this.EncodeService = new Encode();
+ this.EncodeService = File.Exists("hb.dll") ? (IEncode)new LibEncode() : new Encode();
this.QueueManager = new QueueManager(instanceId);
}
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs
index e0152489f..30b752d7d 100644
--- a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs
+++ b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs
@@ -559,7 +559,7 @@ namespace HandBrake.ApplicationServices.Utilities
// Video Settings
AddEncodeElement(xmlWriter, "VideoAvgBitrate", "string", parsed.VideoBitrate.ToString());
- AddEncodeElement(xmlWriter, "VideoEncoder", "string", EnumHelper<VideoEncoder>.GetDisplayValue(parsed.VideoEncoder));
+ AddEncodeElement(xmlWriter, "VideoEncoder", "string", EnumHelper<VideoEncoder>.GetDisplay(parsed.VideoEncoder));
AddEncodeElement(xmlWriter, "VideoFramerate", "string", parsed.Framerate.ToString());
AddEncodeElement(xmlWriter, "VideFrameratePFR", "integer", parsed.FramerateMode == FramerateMode.PFR ? "1" : "0");
AddEncodeElement(xmlWriter, "VideoGrayScale", "integer", parsed.Grayscale ? "1" : "0");
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs
index bd923ff67..9835603cd 100644
--- a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs
+++ b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs
@@ -15,9 +15,6 @@ namespace HandBrake.ApplicationServices.Utilities
using HandBrake.ApplicationServices.Model.Encoding;
using HandBrake.Interop.Model.Encoding;
- using AudioEncoder = HandBrake.ApplicationServices.Model.Encoding.AudioEncoder;
- using Mixdown = HandBrake.ApplicationServices.Model.Encoding.Mixdown;
-
/*
* TODO:
* 1. Handle Subittles