diff options
Diffstat (limited to 'win')
6 files changed, 98 insertions, 25 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Factories/PlistPresetFactory.cs b/win/CS/HandBrake.ApplicationServices/Factories/PlistPresetFactory.cs index 8f7e84e6c..c50d6443d 100644 --- a/win/CS/HandBrake.ApplicationServices/Factories/PlistPresetFactory.cs +++ b/win/CS/HandBrake.ApplicationServices/Factories/PlistPresetFactory.cs @@ -11,11 +11,14 @@ namespace HandBrake.ApplicationServices.Factories {
using System.Collections.Generic;
using System.Collections.ObjectModel;
+ using System.ComponentModel;
using System.Globalization;
using System.Linq;
using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Model.Audio;
using HandBrake.ApplicationServices.Model.Encoding;
+ using HandBrake.ApplicationServices.Model.Subtitle;
using HandBrake.ApplicationServices.Services;
using HandBrake.ApplicationServices.Utilities;
using HandBrake.Interop.Model.Encoding;
@@ -28,6 +31,20 @@ namespace HandBrake.ApplicationServices.Factories public class PlistPresetFactory
{
/// <summary>
+ /// The lang list.
+ /// </summary>
+ private static IDictionary<string, string> langList;
+
+ /// <summary>
+ /// Initializes static members of the <see cref="PlistPresetFactory"/> class.
+ /// </summary>
+ static PlistPresetFactory()
+ {
+ IDictionary<string, string> langMap = LanguageUtilities.MapLanguages();
+ langList = (from entry in langMap select entry).ToDictionary(pair => pair.Value, pair => pair.Key);
+ }
+
+ /// <summary>
/// The create preset.
/// </summary>
/// <param name="plist">
@@ -38,7 +55,13 @@ namespace HandBrake.ApplicationServices.Factories /// </returns>
public static Preset CreatePreset(PList plist)
{
- Preset preset = new Preset { Task = new EncodeTask(), Category = PresetService.UserPresetCatgoryName };
+ Preset preset = new Preset
+ {
+ Task = new EncodeTask(),
+ Category = PresetService.UserPresetCatgoryName,
+ AudioTrackBehaviours = new AudioBehaviours(),
+ SubtitleTrackBehaviours = new SubtitleBehaviours()
+ };
// Parse the settings out.
foreach (var item in plist)
@@ -256,7 +279,7 @@ namespace HandBrake.ApplicationServices.Factories // Chapter Markers Tab
case "ChapterMarkers":
- preset.Task.IncludeChapterMarkers = kvp.Value == 1;
+ preset.Task.IncludeChapterMarkers = kvp.Value == true;
break;
// Advanced x264 tab
@@ -299,23 +322,55 @@ namespace HandBrake.ApplicationServices.Factories // Allowed Passthru
case "AudioAllowAACPass":
- preset.Task.AllowedPassthruOptions.AudioAllowAACPass = kvp.Value == 1;
+ preset.Task.AllowedPassthruOptions.AudioAllowAACPass = kvp.Value == true;
break;
case "AudioAllowAC3Pass":
- preset.Task.AllowedPassthruOptions.AudioAllowAC3Pass = kvp.Value == 1;
+ preset.Task.AllowedPassthruOptions.AudioAllowAC3Pass = kvp.Value == true;
break;
case "AudioAllowDTSHDPass":
- preset.Task.AllowedPassthruOptions.AudioAllowDTSHDPass = kvp.Value == 1;
+ preset.Task.AllowedPassthruOptions.AudioAllowDTSHDPass = kvp.Value == true;
break;
case "AudioAllowDTSPass":
- preset.Task.AllowedPassthruOptions.AudioAllowDTSPass = kvp.Value == 1;
+ preset.Task.AllowedPassthruOptions.AudioAllowDTSPass = kvp.Value == true;
break;
case "AudioAllowMP3Pass":
- preset.Task.AllowedPassthruOptions.AudioAllowMP3Pass = kvp.Value == 1;
+ preset.Task.AllowedPassthruOptions.AudioAllowMP3Pass = kvp.Value == true;
break;
case "AudioEncoderFallback":
preset.Task.AllowedPassthruOptions.AudioEncoderFallback = EnumHelper<AudioEncoder>.GetValue(kvp.Value);
break;
+
+ // Audio Defaults
+ case "AudioLanguageList":
+ preset.AudioTrackBehaviours.SelectedLangauges = new BindingList<string>(ParseLangaugeCodeList(kvp.Value));
+ break;
+ case "AudioSecondaryEncoderMode":
+ break;
+ case "AudioTrackSelectionBehavior":
+ preset.AudioTrackBehaviours.SelectedBehaviour = kvp.Value == "all"
+ ? AudioBehaviourModes.AllMatching
+ : kvp.Value == "first"
+ ? AudioBehaviourModes.FirstMatch
+ : AudioBehaviourModes.None;
+ break;
+
+ // Subtitle Defaults
+ case "SubtitleAddForeignAudioSearch":
+ preset.SubtitleTrackBehaviours.AddForeignAudioScanTrack = kvp.Value == true;
+ break;
+ case "SubtitleAddCC":
+ preset.SubtitleTrackBehaviours.AddClosedCaptions = kvp.Value == true;
+ break;
+ case "SubtitleLanguageList":
+ preset.SubtitleTrackBehaviours.SelectedLangauges = new BindingList<string>(ParseLangaugeCodeList(kvp.Value));
+ break;
+ case "SubtitleTrackSelectionBehavior":
+ preset.SubtitleTrackBehaviours.SelectedBehaviour = kvp.Value == "all"
+ ? SubtitleBehaviourModes.AllMatching
+ : kvp.Value == "first"
+ ? SubtitleBehaviourModes.FirstMatch
+ : SubtitleBehaviourModes.None;
+ break;
}
}
@@ -334,6 +389,30 @@ namespace HandBrake.ApplicationServices.Factories }
/// <summary>
+ /// The parse langauge code list.
+ /// </summary>
+ /// <param name="languages">
+ /// The languages.
+ /// </param>
+ /// <returns>
+ /// The <see cref="IEnumerable"/>.
+ /// </returns>
+ private static IEnumerable<string> ParseLangaugeCodeList(IEnumerable<object> languages)
+ {
+ List<string> languageCodesList = new List<string>();
+ foreach (var item in languages)
+ {
+ string language;
+ if (langList.TryGetValue(item.ToString(), out language))
+ {
+ languageCodesList.Add(language);
+ }
+ }
+
+ return languageCodesList;
+ }
+
+ /// <summary>
/// Parse an audio track's parameters.
/// </summary>
/// <param name="audioTrack">
@@ -350,7 +429,7 @@ namespace HandBrake.ApplicationServices.Factories switch (item.Key)
{
case "AudioBitrate":
- track.Bitrate = int.Parse(item.Value);
+ track.Bitrate = item.Value;
break;
case "AudioEncoder":
track.Encoder = Converters.GetAudioEncoder(item.Value.Trim());
@@ -359,16 +438,16 @@ namespace HandBrake.ApplicationServices.Factories track.MixDown = Converters.GetAudioMixDown(item.Value.Trim());
break;
case "AudioSamplerate":
- track.SampleRate = item.Value == "Auto" ? 0 : double.Parse(item.Value, CultureInfo.InvariantCulture);
+ track.SampleRate = item.Value == "Auto" ? 0 : double.Parse(item.Value);
break;
case "AudioTrack":
// track.SourceTrack = value; We don't do anything with this one.
break;
case "AudioTrackDRCSlider":
- track.DRC = double.Parse(item.Value.ToString(), CultureInfo.InvariantCulture);
+ track.DRC = item.Value;
break;
case "AudioTrackGainSlider":
- track.Gain = int.Parse(item.Value.ToString(), CultureInfo.InvariantCulture);
+ track.Gain = item.Value;
break;
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs b/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs index 4799fc2e9..9b9027f7a 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs @@ -212,14 +212,16 @@ namespace HandBrake.ApplicationServices.Utilities {
switch (audioEnc)
{
- case "AAC (faac)":
- case "AAC (CoreAudio)":
+ 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":
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs index 327ff8ecc..606136ecd 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs @@ -732,7 +732,7 @@ namespace HandBrakeWPF.Properties { /// <summary>
/// Looks up a localized string similar to The preset you are trying to import is from a different version of HandBrake.
- /// It may not be possible to import or some values may be reset to default as a result.
+ /// It may not be possible to import all the values from this preset.
///
///Do you wish to proceed?.
/// </summary>
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx index 921d898e2..8f433d3cd 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.resx @@ -491,7 +491,7 @@ Your custom presets have not been updated so you may have to re-create these by </data>
<data name="Preset_OldVersion_Message" xml:space="preserve">
<value>The preset you are trying to import is from a different version of HandBrake.
- It may not be possible to import or some values may be reset to default as a result.
+ It may not be possible to import all the values from this preset.
Do you wish to proceed?</value>
</data>
diff --git a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs index cc7570140..b297782f2 100644 --- a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs @@ -355,8 +355,6 @@ namespace HandBrakeWPF.ViewModels #region Implemented Interfaces
- #region ITabInterface
-
/// <summary>
/// Setup this tab for the specified preset.
/// </summary>
@@ -376,9 +374,9 @@ namespace HandBrakeWPF.ViewModels if (preset != null && preset.Task != null)
{
- this.SetupTracks();
-
this.Task.AllowedPassthruOptions = new AllowedPassthru(preset.Task.AllowedPassthruOptions);
+
+ this.SetupTracks();
}
this.NotifyOfPropertyChange(() => this.Task);
@@ -435,8 +433,6 @@ namespace HandBrakeWPF.ViewModels #endregion
- #endregion
-
#region Methods
/// <summary>
diff --git a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs index b279f95c5..0219c49af 100644 --- a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs @@ -494,8 +494,6 @@ namespace HandBrakeWPF.ViewModels #region Implemented Interfaces
- #region ITabInterface
-
/// <summary>
/// Setup this tab for the specified preset.
/// </summary>
@@ -557,8 +555,6 @@ namespace HandBrakeWPF.ViewModels #endregion
- #endregion
-
#region Methods
/// <summary>
|