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/HandBrake.ApplicationServices.csproj2
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/HandBrakePresetService.cs22
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/HbLib/HbFunctions.cs6
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/Json/Presets/PresetTransportContainer.cs41
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs4
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs231
6 files changed, 69 insertions, 237 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
index 524729f20..1a080047f 100644
--- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
+++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
@@ -114,6 +114,7 @@
<Compile Include="Interop\Json\Presets\AudioList.cs" />
<Compile Include="Interop\Json\Presets\HBPreset.cs" />
<Compile Include="Interop\Json\Presets\PresetCategory.cs" />
+ <Compile Include="Interop\Json\Presets\PresetTransportContainer.cs" />
<Compile Include="Interop\Json\Shared\PAR.cs" />
<Compile Include="Interop\Json\Encode\Audio.cs" />
<Compile Include="Interop\Json\Encode\AudioTrack.cs" />
@@ -193,7 +194,6 @@
<Compile Include="Services\Logging\Model\LogMessageType.cs" />
<Compile Include="Services\Scan\EventArgs\ScanCompletedEventArgs.cs" />
<Compile Include="Services\Scan\EventArgs\ScanProgressEventArgs.cs" />
- <Compile Include="Utilities\Converters.cs" />
<Compile Include="Utilities\EnumHelper.cs" />
<Compile Include="Utilities\Execute.cs" />
<Compile Include="Utilities\ExtensionMethods.cs" />
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakePresetService.cs b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakePresetService.cs
index e2610905d..8d4f34e9e 100644
--- a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakePresetService.cs
+++ b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakePresetService.cs
@@ -14,6 +14,7 @@ namespace HandBrake.ApplicationServices.Interop
using System.Runtime.InteropServices;
using HandBrake.ApplicationServices.Interop.HbLib;
+ using HandBrake.ApplicationServices.Interop.Helpers;
using HandBrake.ApplicationServices.Interop.Json.Presets;
using HandBrake.ApplicationServices.Services.Logging;
using HandBrake.ApplicationServices.Services.Logging.Model;
@@ -43,5 +44,26 @@ namespace HandBrake.ApplicationServices.Interop
return presetList;
}
+
+ /// <summary>
+ /// The get preset from file.
+ /// </summary>
+ /// <param name="filename">
+ /// The filename.
+ /// </param>
+ /// <returns>
+ /// The <see cref="PresetCategory"/>.
+ /// </returns>
+ public static PresetTransportContainer GetPresetFromFile(string filename)
+ {
+ IntPtr presetStringPointer = HBFunctions.hb_presets_read_file_json(InteropUtilities.ToUtf8PtrFromString(filename));
+ string presetJson = Marshal.PtrToStringAnsi(presetStringPointer);
+
+ LogHelper.LogMessage(new LogMessage(presetJson, LogMessageType.libhb, LogLevel.debug));
+
+ PresetTransportContainer preset = JsonConvert.DeserializeObject<PresetTransportContainer>(presetJson);
+
+ return preset;
+ }
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HbLib/HbFunctions.cs b/win/CS/HandBrake.ApplicationServices/Interop/HbLib/HbFunctions.cs
index 1b68df438..d8d8289f1 100644
--- a/win/CS/HandBrake.ApplicationServices/Interop/HbLib/HbFunctions.cs
+++ b/win/CS/HandBrake.ApplicationServices/Interop/HbLib/HbFunctions.cs
@@ -440,8 +440,8 @@ namespace HandBrake.ApplicationServices.Interop.HbLib
[DllImport("hb.dll", EntryPoint = "hb_presets_builtin_get_json", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_presets_builtin_get_json();
- // hb_value_t * hb_plist_parse_file(const char *filename);
- [DllImport("hb.dll", EntryPoint = "hb_plist_parse_file", CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr hb_plist_parse_file(IntPtr filename);
+ // char * hb_presets_read_file_json(const char *filename);
+ [DllImport("hb.dll", EntryPoint = "hb_presets_read_file_json", CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr hb_presets_read_file_json(IntPtr filename);
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Presets/PresetTransportContainer.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Presets/PresetTransportContainer.cs
new file mode 100644
index 000000000..8f1dd9e78
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Presets/PresetTransportContainer.cs
@@ -0,0 +1,41 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="PresetTransportContainer.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// The preset transport container.
+// This is a model for importing the JSON / Plist presets into the GUI.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Interop.Json.Presets
+{
+ using System.Collections.Generic;
+
+ /// <summary>
+ /// The preset transport container.
+ /// This is a model for importing the JSON / Plist presets into the GUI.
+ /// </summary>
+ public class PresetTransportContainer
+ {
+ /// <summary>
+ /// Gets or sets the children array.
+ /// </summary>
+ public List<HBPreset> PresetList { get; set; }
+
+ /// <summary>
+ /// Gets or sets the version major.
+ /// </summary>
+ public string VersionMajor { get; set; }
+
+ /// <summary>
+ /// Gets or sets the version micro.
+ /// </summary>
+ public string VersionMicro { get; set; }
+
+ /// <summary>
+ /// Gets or sets the version minor.
+ /// </summary>
+ public string VersionMinor { get; set; }
+ }
+}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs
index e133492ff..8d93668bf 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs
@@ -263,7 +263,7 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories
{
Video video = new Video();
- HBVideoEncoder videoEncoder = HandBrakeEncoderHelpers.VideoEncoders.FirstOrDefault(e => e.ShortName == ApplicationServices.Utilities.Converters.GetVideoEncoder(job.VideoEncoder));
+ HBVideoEncoder videoEncoder = HandBrakeEncoderHelpers.VideoEncoders.FirstOrDefault(e => e.ShortName == EnumHelper<VideoEncoder>.GetShortName(job.VideoEncoder));
Validate.NotNull(videoEncoder, "Video encoder " + job.VideoEncoder + " not recognized.");
if (videoEncoder != null)
{
@@ -336,7 +336,7 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories
audio.AudioList = new List<Interop.Json.Encode.AudioTrack>();
foreach (AudioTrack item in job.AudioTracks)
{
- HBAudioEncoder encoder = HandBrakeEncoderHelpers.GetAudioEncoder(ApplicationServices.Utilities.Converters.GetCliAudioEncoder(item.Encoder));
+ HBAudioEncoder encoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(item.Encoder));
Validate.NotNull(encoder, "Unrecognized audio encoder:" + item.Encoder);
HBMixdown mixdown = HandBrakeEncoderHelpers.GetMixdown(EnumHelper<Mixdown>.GetShortName(item.MixDown));
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs b/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs
deleted file mode 100644
index dd38fb286..000000000
--- a/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs
+++ /dev/null
@@ -1,231 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="Converters.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// A class to convert various things to native C# objects
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Utilities
-{
- using System;
-
- using HandBrake.ApplicationServices.Interop.Model.Encoding;
- using HandBrake.ApplicationServices.Services.Encode.Model.Models;
-
- /// <summary>
- /// A class to convert various things to native C# objects
- /// </summary>
- public class Converters
- {
- /**
- * TODO:
- * - Many of these converters can be ditched at a later point. Should be able to model all this within the enums themsevles.
- *
- **/
-
- #region Audio
-
- /// <summary>
- /// Get the GUI equiv to a CLI mixdown
- /// </summary>
- /// <param name="mixdown">
- /// The Audio Mixdown
- /// </param>
- /// <returns>
- /// The GUI representation of the mixdown
- /// </returns>
- [Obsolete("Use EnumHelper instead")]
- public static Mixdown GetAudioMixDown(string mixdown)
- {
- switch (mixdown.Trim())
- {
- case "Mono":
- return Mixdown.Mono;
- case "Stereo":
- return Mixdown.Stereo;
- case "Dolby Surround":
- return Mixdown.DolbySurround;
- case "Dolby Pro Logic II":
- return Mixdown.DolbyProLogicII;
- case "5.1 Channels":
- return Mixdown.FivePoint1Channels;
- case "6.1 Channels":
- return Mixdown.SixPoint1Channels;
- case "7.1 Channels":
- return Mixdown.SevenPoint1Channels;
- case "7.1 (5F/2R/LFE)":
- return Mixdown.Five_2_LFE;
- case "None":
- case "Passthru":
- return Mixdown.None;
- default:
- return Mixdown.Auto;
- }
- }
-
- /// <summary>
- /// Get the GUI equiv to a GUI audio encoder string
- /// </summary>
- /// <param name="audioEnc">
- /// The Audio Encoder
- /// </param>
- /// <returns>
- /// The GUI representation of that audio encoder
- /// </returns>
- [Obsolete("Use EnumHelper instead")]
- public static AudioEncoder GetAudioEncoder(string audioEnc)
- {
- switch (audioEnc)
- {
- case "AAC (faac)":
- case "AAC (ffmpeg)":
- case "AAC (avcodec)":
- return AudioEncoder.ffaac;
- case "AAC (FDK)":
- case "AAC (CoreAudio)":
- return AudioEncoder.fdkaac;
- case "HE-AAC (FDK)":
- case "HE-AAC (CoreAudio)":
- case "HE-AAC":
- return AudioEncoder.fdkheaac;
- case "MP3 (lame)":
- case "MP3":
- return AudioEncoder.Lame;
- case "Vorbis (vorbis)":
- case "Vorbis":
- return AudioEncoder.Vorbis;
- case "AC3 (ffmpeg)":
- case "AC3":
- return AudioEncoder.Ac3;
- case "AC3 Passthru":
- return AudioEncoder.Ac3Passthrough;
- case "DTS Passthru":
- return AudioEncoder.DtsPassthrough;
- case "DTS-HD Passthru":
- return AudioEncoder.DtsHDPassthrough;
- case "AAC Passthru":
- return AudioEncoder.AacPassthru;
- case "MP3 Passthru":
- return AudioEncoder.Mp3Passthru;
- case "FLAC (ffmpeg)":
- case "FLAC 16-bit":
- return AudioEncoder.ffflac;
- case "FLAC (24-bit)":
- case "FLAC 24-bit":
- return AudioEncoder.ffflac24;
- case "TrueHD Passthru":
- return AudioEncoder.TrueHDPassthrough;
- case "E-AC3 Passthru":
- return AudioEncoder.EAc3Passthrough;
- case "FLAC Passthru":
- return AudioEncoder.FlacPassthru;
- case "Auto Passthru":
- return AudioEncoder.Passthrough;
- default:
- return AudioEncoder.ffaac;
- }
- }
-
- /// <summary>
- /// Get the CLI Audio Encoder name
- /// </summary>
- /// <param name="selectedEncoder">
- /// String The GUI Encode name
- /// </param>
- /// <returns>
- /// String CLI encoder name
- /// </returns>
- public static string GetCliAudioEncoder(AudioEncoder selectedEncoder)
- {
- return EnumHelper<AudioEncoder>.GetShortName(selectedEncoder);
- }
-
- #endregion
-
- #region Video
-
- /// <summary>
- /// Get the Video Encoder for a given string
- /// </summary>
- /// <param name="encoder">
- /// The encoder name
- /// </param>
- /// <returns>
- /// VideoEncoder enum object
- /// </returns>
- public static string GetVideoEncoder(VideoEncoder encoder)
- {
- switch (encoder)
- {
- case VideoEncoder.FFMpeg:
- return "mpeg4";
- case VideoEncoder.FFMpeg2:
- return "mpeg2";
- case VideoEncoder.X264:
- return "x264";
- case VideoEncoder.QuickSync:
- return "qsv_h264";
- case VideoEncoder.Theora:
- return "theora";
- case VideoEncoder.X265:
- return "x265";
- case VideoEncoder.VP8:
- return "VP8";
- default:
- return "x264";
- }
- }
-
- #endregion
-
- #region File Format
-
- /// <summary>
- /// Get the OutputFormat Enum for a given string
- /// </summary>
- /// <param name="format">
- /// OutputFormat as a string
- /// </param>
- /// <returns>
- /// An OutputFormat Enum
- /// </returns>
- public static OutputFormat GetFileFormat(string format)
- {
- switch (format.ToLower())
- {
- default:
- return OutputFormat.Mp4;
- case "m4v":
- return OutputFormat.Mp4;
- case "mkv":
- return OutputFormat.Mkv;
- }
- }
-
- /// <summary>
- /// Get the OutputFormat Enum for a given string
- /// </summary>
- /// <param name="format">
- /// OutputFormat as a string
- /// </param>
- /// <returns>
- /// An OutputFormat Enum
- /// </returns>
- public static string GetFileFormat(OutputFormat format)
- {
- switch (format)
- {
- default:
- return "mp4";
- case OutputFormat.Mp4:
- return "m4v";
- case OutputFormat.Mkv:
- return "mkv";
- }
- }
-
- #endregion
- }
-}