summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.ApplicationServices
diff options
context:
space:
mode:
authorsr55 <[email protected]>2012-03-17 18:36:35 +0000
committersr55 <[email protected]>2012-03-17 18:36:35 +0000
commit7686ecbf127a41291a7fe76852f93fe7a6f60fb4 (patch)
treeb77205d3464bc0ae3fb374acbe0acedf72916834 /win/CS/HandBrake.ApplicationServices
parentf87e4ae9727bbb10040e5dd5cd99a6a7f1f4dd1d (diff)
WinGui: (WPF) Wired up the Add Preset window and setup the build scripts to create Alpha Builds for this project.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4508 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices')
-rw-r--r--win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj1
-rw-r--r--win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs45
-rw-r--r--win/CS/HandBrake.ApplicationServices/Model/Preset.cs9
-rw-r--r--win/CS/HandBrake.ApplicationServices/Model/PresetPictureSettingsMode.cs22
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/PresetService.cs10
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs67
6 files changed, 97 insertions, 57 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
index ff6f8cd4b..bebc5c331 100644
--- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
+++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
@@ -114,6 +114,7 @@
<Compile Include="Model\General\UpdateCheckResult.cs" />
<Compile Include="Model\ModelBase.cs" />
<Compile Include="Model\Preset.cs" />
+ <Compile Include="Model\PresetPictureSettingsMode.cs" />
<Compile Include="Model\QueueItemStatus.cs" />
<Compile Include="Model\QueueTask.cs" />
<Compile Include="Model\Encoding\SubtitleType.cs" />
diff --git a/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs b/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs
index 6e2d59667..e1ed6eb62 100644
--- a/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs
+++ b/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs
@@ -91,9 +91,6 @@ namespace HandBrake.ApplicationServices.Model
this.PixelAspectX = task.PixelAspectX;
this.PixelAspectY = task.PixelAspectY;
this.PointToPointMode = task.PointToPointMode;
- this.PresetBuildNumber = task.PresetBuildNumber;
- this.PresetDescription = task.PresetDescription;
- this.PresetName = task.PresetName;
this.Quality = task.Quality;
this.Source = task.Source;
this.StartPoint = task.StartPoint;
@@ -107,10 +104,6 @@ namespace HandBrake.ApplicationServices.Model
this.Title = task.Title;
this.TurboFirstPass = task.TurboFirstPass;
this.TwoPass = task.TwoPass;
- this.Type = task.Type;
- this.UsesMaxPictureSettings = task.UsesMaxPictureSettings;
- this.UsesPictureFilters = task.UsesPictureFilters;
- this.UsesPictureSettings = task.UsesPictureSettings;
this.Verbosity = task.Verbosity;
this.VideoBitrate = task.VideoBitrate;
this.VideoEncoder = task.VideoEncoder;
@@ -437,44 +430,6 @@ namespace HandBrake.ApplicationServices.Model
public int? PreviewDuration { get; set; }
#endregion
- #region Preset Information (TODO This should probably be dropped)
-
- /// <summary>
- /// Gets or sets PresetBuildNumber.
- /// </summary>
- public int PresetBuildNumber { get; set; }
-
- /// <summary>
- /// Gets or sets PresetDescription.
- /// </summary>
- public string PresetDescription { get; set; }
-
- /// <summary>
- /// Gets or sets PresetName.
- /// </summary>
- public string PresetName { get; set; }
-
- /// <summary>
- /// Gets or sets Type.
- /// </summary>
- public string Type { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether UsesMaxPictureSettings.
- /// </summary>
- public bool UsesMaxPictureSettings { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether UsesPictureFilters.
- /// </summary>
- public bool UsesPictureFilters { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether UsesPictureSettings.
- /// </summary>
- public bool UsesPictureSettings { get; set; }
- #endregion
-
#region Helpers
/// <summary>
diff --git a/win/CS/HandBrake.ApplicationServices/Model/Preset.cs b/win/CS/HandBrake.ApplicationServices/Model/Preset.cs
index 2ec668b56..8770e6d03 100644
--- a/win/CS/HandBrake.ApplicationServices/Model/Preset.cs
+++ b/win/CS/HandBrake.ApplicationServices/Model/Preset.cs
@@ -5,6 +5,8 @@
namespace HandBrake.ApplicationServices.Model
{
+ using System;
+
using Encoding;
/// <summary>
@@ -30,6 +32,7 @@ namespace HandBrake.ApplicationServices.Model
/// <summary>
/// Gets or sets a value indicating whether to use picture Settings in presets.
/// </summary>
+ [Obsolete("Don't use this!")]
public bool CropSettings { get; set; }
/// <summary>
@@ -48,6 +51,12 @@ namespace HandBrake.ApplicationServices.Model
public bool UsePictureFilters { get; set; }
/// <summary>
+ /// Gets or sets PictureSettingsMode.
+ /// Source Maximum, Custom or None
+ /// </summary>
+ public PresetPictureSettingsMode PictureSettingsMode { get; set; }
+
+ /// <summary>
/// Gets or sets a value indicating whether this is a built in preset
/// </summary>
public bool IsBuildIn { get; set; }
diff --git a/win/CS/HandBrake.ApplicationServices/Model/PresetPictureSettingsMode.cs b/win/CS/HandBrake.ApplicationServices/Model/PresetPictureSettingsMode.cs
new file mode 100644
index 000000000..fc2798fd1
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/Model/PresetPictureSettingsMode.cs
@@ -0,0 +1,22 @@
+/* PresetPictureSettingsMode.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.ComponentModel.DataAnnotations;
+
+ /// <summary>
+ /// Picture Settings Mode when adding presets
+ /// </summary>
+ public enum PresetPictureSettingsMode
+ {
+ [Display(Name = "None")]
+ None,
+ [Display(Name = "Custom")]
+ Custom,
+ [Display(Name = "Source Maximum")]
+ SourceMaximum,
+ }
+} \ No newline at end of file
diff --git a/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs b/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs
index 33b872796..63d636f5c 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs
@@ -42,9 +42,9 @@ namespace HandBrake.ApplicationServices.Services
private static readonly XmlSerializer Ser = new XmlSerializer(typeof(List<Preset>));
/// <summary>
- /// The User Setting Service
+ /// User Preset Default Catgory Name
/// </summary>
- private IUserSettingService userSettingService = ServiceManager.UserSettingService;
+ public static string UserPresetCatgoryName = "User Presets";
/// <summary>
/// The User Preset file
@@ -61,8 +61,14 @@ namespace HandBrake.ApplicationServices.Services
/// </summary>
private ObservableCollection<Preset> presets = new ObservableCollection<Preset>();
+ /// <summary>
+ /// The User Setting Service
+ /// </summary>
+ private IUserSettingService userSettingService = ServiceManager.UserSettingService;
+
#endregion
+
/// <summary>
/// Initializes a new instance of the <see cref="PresetService"/> class.
/// </summary>
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs
index a018c9900..ccac82893 100644
--- a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs
+++ b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs
@@ -16,6 +16,7 @@ namespace HandBrake.ApplicationServices.Utilities
using HandBrake.ApplicationServices.Functions;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Model.Encoding;
+ using HandBrake.ApplicationServices.Services;
using HandBrake.ApplicationServices.Services.Interfaces;
using HandBrake.Interop.Model.Encoding;
@@ -31,20 +32,43 @@ namespace HandBrake.ApplicationServices.Utilities
#region Import
- public static EncodeTask Import(string filename)
+ public static Preset Import(string filename)
{
+ Preset preset = new Preset();
+
XmlNode root = loadFile(filename);
if (root == null) return null;
// We'll query a query parser object and use it's public var structures to store all the data.
// This will allow the preset loader logic to be used instead of writing custom logic just for this file.
EncodeTask parsed = new EncodeTask();
+ bool useFilters = false;
+ PresetPictureSettingsMode pictureSettingsMode = PresetPictureSettingsMode.None;
string qualityMode = string.Empty;
#region Get a List of Audio Track Objects
- XmlNode audioListDict = root.ChildNodes[2].ChildNodes[0].FirstChild.ChildNodes[13];
+
+ // This is the main <dict> with all the values
+ XmlNode mainDict = root.ChildNodes[2].ChildNodes[0].FirstChild;
+ XmlNode audioListDict = null;
ObservableCollection<AudioTrack> audioTracks = new ObservableCollection<AudioTrack>();
+ // Look for the AudioList key
+ bool found = false;
+ foreach (XmlNode node in mainDict.ChildNodes)
+ {
+ if (found)
+ {
+ audioListDict = node;
+ break;
+ }
+
+ if (node.InnerText == "AudioList")
+ {
+ found = true; // We want the next node, as it is the value object.
+ }
+ }
+
for (int i = 0; i < audioListDict.ChildNodes.Count; i++)
{
XmlNode audioChannel = audioListDict.ChildNodes[i];
@@ -304,25 +328,25 @@ namespace HandBrake.ApplicationServices.Utilities
// Preset Information
case "PresetBuildNumber":
- parsed.PresetBuildNumber = int.Parse(value);
+ preset.Version = value;
break;
case "PresetDescription":
- parsed.PresetDescription = value;
+ preset.Description = value;
break;
case "PresetName":
- parsed.PresetName = value;
+ preset.Name = value;
break;
case "Type":
- parsed.Type = value;
+ //parsed.Type = value; // TODO find out what this is
break;
case "UsesMaxPictureSettings":
- parsed.UsesMaxPictureSettings = value == "1";
+ pictureSettingsMode = PresetPictureSettingsMode.SourceMaximum;
break;
case "UsesPictureFilters":
- parsed.UsesPictureFilters = value == "1";
+ useFilters = value == "1";
break;
case "UsesPictureSettings":
- parsed.UsesPictureSettings = value == "1";
+ pictureSettingsMode = PresetPictureSettingsMode.Custom;
break;
// Allowed Passthru
@@ -357,9 +381,32 @@ namespace HandBrake.ApplicationServices.Utilities
parsed.VideoEncodeRateType = VideoEncodeRateType.ConstantQuality;
break;
}
+
+ // Default filters if we have to
+ if (!useFilters)
+ {
+ parsed.Detelecine = Detelecine.Off;
+ parsed.Denoise = Denoise.Off;
+ parsed.Deinterlace = Deinterlace.Off;
+ parsed.Decomb = Decomb.Off;
+ parsed.Deblock = 0;
+ parsed.Grayscale = false;
+ }
+
+ if (pictureSettingsMode == PresetPictureSettingsMode.SourceMaximum)
+ {
+ parsed.MaxWidth = parsed.Height;
+ parsed.MaxHeight = parsed.Width;
+ }
#endregion
- return parsed;
+
+ preset.Task = parsed;
+ preset.PictureSettingsMode = pictureSettingsMode;
+ preset.UsePictureFilters = useFilters;
+ preset.Category = PresetService.UserPresetCatgoryName;
+
+ return preset;
}
private static XmlNode loadFile(string filename)