summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.ApplicationServices/Utilities
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Utilities')
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs111
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/EnumHelper.cs19
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs2
3 files changed, 47 insertions, 85 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs b/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs
index 8ac89c0ee..641380e9c 100644
--- a/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs
+++ b/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs
@@ -25,7 +25,7 @@ namespace HandBrake.ApplicationServices.Utilities
* TODO:
* - Many of these converters can be ditched at a later point. Should be able to model all this within the enums themsevles.
*
- **/
+ **/
/// <summary>
/// Convert HandBrakes time remaining into a TimeSpan
@@ -160,62 +160,29 @@ namespace HandBrake.ApplicationServices.Utilities
/// </summary>
/// <param name="audioEnc">The Audio Encoder</param>
/// <returns>The GUI representation of that audio encoder</returns>
- public static string GetGUIAudioEncoder(string audioEnc)
- {
- switch (audioEnc)
- {
- case "faac":
- return "AAC (faac)";
- case "lame":
- return "MP3 (lame)";
- case "vorbis":
- return "Vorbis (vorbis)";
- case "ffac3":
- return "AC3 (ffmpeg)";
- case "copy:ac3":
- return "AC3 Passthru";
- case "copy:dts":
- return "DTS Passthru";
- case "copy:dtshd":
- return "MP3 Passthru";
- case "copy:mp3":
- return "AAC Passthru";
- case "copy:aac":
- return "DTS-HD Passthru";
- case "ffaac":
- return "AAC (ffmpeg)";
- case "ffflac":
- return "FLAC (ffmpeg)";
- case "ffflac24":
- return "FLAC (24-bit)";
- case "copy":
- return "Auto Passthru";
- default:
- return "AAC (faac)";
- }
- }
-
- /// <summary>
- /// Get the GUI equiv to a CLI audio encoder
- /// </summary>
- /// <param name="audioEnc">The Audio Encoder</param>
- /// <returns>The GUI representation of that audio encoder</returns>
public static AudioEncoder GetAudioEncoderFromCliString(string audioEnc)
{
switch (audioEnc)
{
case "faac":
- return AudioEncoder.Faac;
case "ffaac":
return AudioEncoder.ffaac;
+ case "fdk_aac":
+ return AudioEncoder.fdkaac;
+ case "fdk_haac":
+ return AudioEncoder.fdkheaac;
+ case "mp3":
case "lame":
return AudioEncoder.Lame;
case "vorbis":
return AudioEncoder.Vorbis;
+ case "ac3":
case "ffac3":
return AudioEncoder.Ac3;
+ case "flac16":
case "ffflac":
return AudioEncoder.ffflac;
+ case "flac24":
case "ffflac24":
return AudioEncoder.ffflac24;
case "copy:ac3":
@@ -231,7 +198,7 @@ namespace HandBrake.ApplicationServices.Utilities
case "copy":
return AudioEncoder.Passthrough;
default:
- return AudioEncoder.Faac;
+ return AudioEncoder.ffaac;
}
}
@@ -245,16 +212,22 @@ namespace HandBrake.ApplicationServices.Utilities
switch (audioEnc)
{
case "AAC (faac)":
- return AudioEncoder.Faac;
+ case "AAC (CoreAudio)":
case "AAC (ffmpeg)":
+ case "AAC (avcodec)":
return AudioEncoder.ffaac;
- case "AAC (CoreAudio)":
- return AudioEncoder.Faac;
+ case "AAC (FDK)":
+ return AudioEncoder.fdkaac;
+ case "HE-AAC (FDK)":
+ 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;
@@ -267,13 +240,15 @@ namespace HandBrake.ApplicationServices.Utilities
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 "Auto Passthru":
return AudioEncoder.Passthrough;
default:
- return AudioEncoder.Faac;
+ return AudioEncoder.ffaac;
}
}
@@ -288,43 +263,12 @@ namespace HandBrake.ApplicationServices.Utilities
/// </returns>
public static string GetCliAudioEncoder(AudioEncoder selectedEncoder)
{
- switch (selectedEncoder)
- {
- case AudioEncoder.Faac:
- return "faac";
- case AudioEncoder.ffaac:
- return "ffaac";
-
- case AudioEncoder.Lame:
- return "lame";
- case AudioEncoder.Vorbis:
- return "vorbis";
- case AudioEncoder.Ac3Passthrough:
- return "copy:ac3";
- case AudioEncoder.DtsPassthrough:
- return "copy:dts";
- case AudioEncoder.DtsHDPassthrough:
- return "copy:dtshd";
- case AudioEncoder.Ac3:
- return "ffac3";
- case AudioEncoder.AacPassthru:
- return "copy:aac";
- case AudioEncoder.Mp3Passthru:
- return "copy:mp3";
- case AudioEncoder.Passthrough:
- return "copy";
- case AudioEncoder.ffflac:
- return "ffflac";
- case AudioEncoder.ffflac24:
- return "ffflac24";
- default:
- return "faac";
- }
+ return EnumHelper<AudioEncoder>.GetShortName(selectedEncoder);
}
#endregion
- #region Video
+ #region Video
/// <summary>
/// Get the Video Encoder for a given string
@@ -339,11 +283,12 @@ namespace HandBrake.ApplicationServices.Utilities
{
switch (encoder)
{
- case "":
case "ffmpeg":
case "ffmpeg4":
+ case "mpeg4":
return VideoEncoder.FFMpeg;
case "ffmpeg2":
+ case "mpeg2":
return VideoEncoder.FFMpeg2;
case "x264":
return VideoEncoder.X264;
@@ -368,9 +313,9 @@ namespace HandBrake.ApplicationServices.Utilities
switch (encoder)
{
case VideoEncoder.FFMpeg:
- return "ffmpeg4";
+ return "mpeg4";
case VideoEncoder.FFMpeg2:
- return "ffmpeg2";
+ return "mpeg2";
case VideoEncoder.X264:
return "x264";
case VideoEncoder.Theora:
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/EnumHelper.cs b/win/CS/HandBrake.ApplicationServices/Utilities/EnumHelper.cs
index c854e5a05..43667557b 100644
--- a/win/CS/HandBrake.ApplicationServices/Utilities/EnumHelper.cs
+++ b/win/CS/HandBrake.ApplicationServices/Utilities/EnumHelper.cs
@@ -17,6 +17,8 @@ namespace HandBrake.ApplicationServices.Utilities
using System.Linq;
using System.Reflection;
+ using HandBrake.Interop.Attributes;
+
/// <summary>
/// Enum Helpers
/// </summary>
@@ -94,6 +96,23 @@ namespace HandBrake.ApplicationServices.Utilities
}
/// <summary>
+ /// The get short name.
+ /// </summary>
+ /// <param name="value">
+ /// The value.
+ /// </param>
+ /// <returns>
+ /// The <see cref="string"/>.
+ /// </returns>
+ public static string GetShortName(T value)
+ {
+ FieldInfo fieldInfo = value.GetType().GetField(value.ToString());
+ ShortName[] attributes = (ShortName[])fieldInfo.GetCustomAttributes(typeof(ShortName), false);
+
+ return (attributes.Length > 0) ? attributes[0].Name : value.ToString();
+ }
+
+ /// <summary>
/// Return a list of all the enum values.
/// </summary>
/// <returns>
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs b/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs
index 356e12c8c..42f075508 100644
--- a/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs
+++ b/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs
@@ -12,11 +12,9 @@ namespace HandBrake.ApplicationServices.Utilities
using System;
using System.Collections.Generic;
using System.Diagnostics;
- using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
- using System.Text.RegularExpressions;
using System.Windows.Forms;
using HandBrake.ApplicationServices.Model;