summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.ApplicationServices
diff options
context:
space:
mode:
authorsr55 <[email protected]>2013-06-16 16:00:15 +0000
committersr55 <[email protected]>2013-06-16 16:00:15 +0000
commit9c4ba8930b22f92f0d8b985eb77a96fca4a62d28 (patch)
tree32a7a3ee495ab418936131a157c734052ea0f557 /win/CS/HandBrake.ApplicationServices
parent9dcc30ae3c509b338f2f777089d9c05d294ca4ea (diff)
WiWinGui: Remap the audio and video encoders. Hopefully this should also be backwards compatible with user presets, but it is recommended to re-create any user presets to that the new keys get picked up incase we drop the fallbacks in the future.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5591 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/LibHb/AudioVideoHelpers.cs18
-rw-r--r--win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs6
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Interfaces/IPresetService.cs5
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/PresetService.cs46
-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
8 files changed, 91 insertions, 117 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
index 445b09c36..4888c9e9b 100644
--- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
+++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
@@ -95,6 +95,7 @@
<Compile Include="Isolation\BackgroundServiceConnector.cs" />
<Compile Include="Isolation\IsolatedEncodeService.cs" />
<Compile Include="Isolation\IsolatedScanService.cs" />
+ <Compile Include="LibHb\AudioVideoHelpers.cs" />
<Compile Include="Services\Interfaces\IEncodeServiceWrapper.cs" />
<Compile Include="Services\Interfaces\IHbServiceCallback.cs" />
<Compile Include="Services\Interfaces\IScanServiceWrapper.cs" />
diff --git a/win/CS/HandBrake.ApplicationServices/LibHb/AudioVideoHelpers.cs b/win/CS/HandBrake.ApplicationServices/LibHb/AudioVideoHelpers.cs
new file mode 100644
index 000000000..022d78180
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/LibHb/AudioVideoHelpers.cs
@@ -0,0 +1,18 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="AudioVideoHelpers.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>
+// Defines the AudioVideoHelpers type.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.LibHb
+{
+ /// <summary>
+ /// The audio video helpers.
+ /// </summary>
+ class AudioVideoHelpers
+ {
+ }
+}
diff --git a/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs b/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs
index c8238927f..fcbaddf6f 100644
--- a/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs
+++ b/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs
@@ -75,7 +75,7 @@ namespace HandBrake.ApplicationServices.Model.Encoding
public AudioTrack()
{
// Default Values
- this.Encoder = AudioEncoder.Faac;
+ this.Encoder = AudioEncoder.ffaac;
this.MixDown = Mixdown.DolbyProLogicII;
this.SampleRate = 48;
this.Bitrate = 160;
@@ -341,7 +341,7 @@ namespace HandBrake.ApplicationServices.Model.Encoding
{
get
{
- return this.IsPassthru || this.Encoder == AudioEncoder.ffflac;
+ return this.IsPassthru || this.Encoder == AudioEncoder.ffflac || this.Encoder == AudioEncoder.ffflac24;
}
}
@@ -352,7 +352,7 @@ namespace HandBrake.ApplicationServices.Model.Encoding
{
get
{
- return this.IsPassthru || this.Encoder == AudioEncoder.ffflac;
+ return this.IsPassthru || this.Encoder == AudioEncoder.ffflac || this.Encoder == AudioEncoder.ffflac24;
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IPresetService.cs b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IPresetService.cs
index 63fe25158..83e1206b2 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IPresetService.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IPresetService.cs
@@ -29,6 +29,11 @@ namespace HandBrake.ApplicationServices.Services.Interfaces
Preset DefaultPreset { get; }
/// <summary>
+ /// The load.
+ /// </summary>
+ void Load();
+
+ /// <summary>
/// Add a new preset to the system
/// </summary>
/// <param name="preset">
diff --git a/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs b/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs
index 8f375258c..b0cfc9a74 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs
@@ -38,11 +38,6 @@ namespace HandBrake.ApplicationServices.Services
private static readonly XmlSerializer Ser = new XmlSerializer(typeof(List<Preset>));
/// <summary>
- /// The User Setting Service
- /// </summary>
- private readonly IUserSettingService userSettingService;
-
- /// <summary>
/// User Preset Default Catgory Name
/// </summary>
public static string UserPresetCatgoryName = "User Presets";
@@ -60,30 +55,10 @@ namespace HandBrake.ApplicationServices.Services
/// <summary>
/// A Collection of presets
/// </summary>
- private ObservableCollection<Preset> presets = new ObservableCollection<Preset>();
+ private readonly ObservableCollection<Preset> presets = new ObservableCollection<Preset>();
#endregion
-
- /// <summary>
- /// Initializes a new instance of the <see cref="PresetService"/> class.
- /// </summary>
- /// <param name="userSettingService">
- /// The user Setting Service.
- /// </param>
- public PresetService(IUserSettingService userSettingService)
- {
- this.userSettingService = userSettingService;
-
- // If the preset file doesn't exist. Create it.
- if (!File.Exists(this.builtInPresetFile))
- {
- this.UpdateBuiltInPresets();
- }
-
- this.LoadPresets();
- }
-
/// <summary>
/// Gets a Collection of presets.
/// </summary>
@@ -114,6 +89,20 @@ namespace HandBrake.ApplicationServices.Services
#region Public Methods
/// <summary>
+ /// The load.
+ /// </summary>
+ public void Load()
+ {
+ // If the preset file doesn't exist. Create it.
+ if (!File.Exists(this.builtInPresetFile))
+ {
+ this.UpdateBuiltInPresets();
+ }
+
+ this.LoadPresets();
+ }
+
+ /// <summary>
/// Add a new preset to the system.
/// Performs an Update if it already exists
/// </summary>
@@ -412,7 +401,7 @@ namespace HandBrake.ApplicationServices.Services
// Recover from Error.
if (File.Exists(file))
{
- string disabledFile = file + ".old";
+ string disabledFile = string.Format("{0}.{1}", file, GeneralUtilities.ProcessId);
File.Move(file, disabledFile);
if (File.Exists(file))
{
@@ -455,7 +444,6 @@ namespace HandBrake.ApplicationServices.Services
{
RecoverFromCorruptedPresetFile(this.builtInPresetFile);
this.UpdateBuiltInPresets();
- throw new GeneralApplicationException("HandBrake has detected corruption in the presets file and has attempted to rebuild this file.", "Please restart HandBrake before continuing.", exc);
}
// Load in the users Presets from UserPresets.xml
@@ -476,7 +464,7 @@ namespace HandBrake.ApplicationServices.Services
catch (Exception exc)
{
RecoverFromCorruptedPresetFile(this.userPresetFile);
- throw new GeneralApplicationException("HandBrake has detected corruption in the presets file and has attempted to rebuild this file.", "Please restart HandBrake before continuing.", exc);
+ throw new GeneralApplicationException("HandBrake has detected a problem with your presets.", "Your old presets file has been renamed so that it doesn't get loaded on next launch.", exc);
}
}
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;