From 6c8108e0760796e153f62de9b08325f433105bff Mon Sep 17 00:00:00 2001 From: sr55 Date: Mon, 23 Jul 2012 16:57:39 +0000 Subject: [PATCH] WinGui: Fix up the Audio Passthru selection options. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4872 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../Model/Encoding/AllowedPassthru.cs | 107 +++++++++++++++--- .../Services/PresetService.cs | 2 +- .../Utilities/PlistUtility.cs | 29 ++++- .../Utilities/QueryGeneratorUtility.cs | 26 +++-- .../Converters/Audio/AudioEncoderConverter.cs | 10 ++ .../HandBrakeWPF/ViewModels/AudioViewModel.cs | 3 - win/CS/HandBrakeWPF/Views/AudioView.xaml | 40 ++++--- 7 files changed, 172 insertions(+), 45 deletions(-) diff --git a/win/CS/HandBrake.ApplicationServices/Model/Encoding/AllowedPassthru.cs b/win/CS/HandBrake.ApplicationServices/Model/Encoding/AllowedPassthru.cs index 7b407f297..36c4febab 100644 --- a/win/CS/HandBrake.ApplicationServices/Model/Encoding/AllowedPassthru.cs +++ b/win/CS/HandBrake.ApplicationServices/Model/Encoding/AllowedPassthru.cs @@ -9,13 +9,44 @@ namespace HandBrake.ApplicationServices.Model.Encoding { - using Interop.Model.Encoding; + using HandBrake.Interop.Model.Encoding; /// /// Allowed Passthru Options /// public class AllowedPassthru { + #region Constants and Fields + + /// + /// The audio allow aac pass. + /// + private bool? audioAllowAACPass; + + /// + /// The audio allow a c 3 pass. + /// + private bool? audioAllowAC3Pass; + + /// + /// The audio allow dtshd pass. + /// + private bool? audioAllowDTSHDPass; + + /// + /// The audio allow dts pass. + /// + private bool? audioAllowDTSPass; + + /// + /// The audio allow m p 3 pass. + /// + private bool? audioAllowMP3Pass; + + #endregion + + #region Constructors and Destructors + /// /// Initializes a new instance of the class. /// @@ -35,7 +66,7 @@ namespace HandBrake.ApplicationServices.Model.Encoding /// /// The initial Value. /// - public AllowedPassthru(bool initialValue) + public AllowedPassthru(bool? initialValue) { this.AudioAllowAACPass = initialValue; this.AudioAllowAC3Pass = initialValue; @@ -62,40 +93,90 @@ namespace HandBrake.ApplicationServices.Model.Encoding this.AudioEncoderFallback = initialValue.AudioEncoderFallback; } - /// - /// Gets or sets a value indicating whether IsEnabled. - /// Temp Measure until forms gui is retired. - /// - public bool IsEnabled { get; set; } + #endregion + + #region Properties /// /// Gets or sets a value indicating whether AudioAllowAACPass. /// - public bool AudioAllowAACPass { get; set; } + public bool? AudioAllowAACPass + { + get + { + return this.audioAllowAACPass ?? true; + } + set + { + this.audioAllowAACPass = value; + } + } /// /// Gets or sets a value indicating whether AudioAllowAC3Pass. /// - public bool AudioAllowAC3Pass { get; set; } + public bool? AudioAllowAC3Pass + { + get + { + return this.audioAllowAC3Pass ?? true; + } + set + { + this.audioAllowAC3Pass = value; + } + } /// /// Gets or sets a value indicating whether AudioAllowDTSHDPass. /// - public bool AudioAllowDTSHDPass { get; set; } + public bool? AudioAllowDTSHDPass + { + get + { + return this.audioAllowDTSHDPass ?? true; + } + set + { + this.audioAllowDTSHDPass = value; + } + } /// /// Gets or sets a value indicating whether AudioAllowDTSPass. /// - public bool AudioAllowDTSPass { get; set; } + public bool? AudioAllowDTSPass + { + get + { + return this.audioAllowDTSPass ?? true; + } + set + { + this.audioAllowDTSPass = value; + } + } /// /// Gets or sets a value indicating whether AudioAllowMP3Pass. /// - public bool AudioAllowMP3Pass { get; set; } + public bool? AudioAllowMP3Pass + { + get + { + return this.audioAllowMP3Pass ?? true; + } + set + { + this.audioAllowMP3Pass = value; + } + } /// /// Gets or sets AudioEncoderFallback. /// public AudioEncoder AudioEncoderFallback { get; set; } + + #endregion } -} +} \ 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 2ddd775aa..0b86be749 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs @@ -321,7 +321,7 @@ namespace HandBrake.ApplicationServices.Services Task = QueryParserUtility.Parse(presetName[2]) }; - newPreset.Task.AllowedPassthruOptions = new AllowedPassthru(false); // We don't want to override the built-in preset + newPreset.Task.AllowedPassthruOptions = new AllowedPassthru(true); // We don't want to override the built-in preset if (newPreset.Name == "Normal") { diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs index dcedefad9..871bc5adc 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs @@ -543,6 +543,25 @@ namespace HandBrake.ApplicationServices.Utilities xmlWriter.WriteEndElement(); } + /// + /// The get null bool value. + /// + /// + /// The value. + /// + /// + /// The System.String. + /// + private static string getNullBoolValue(bool? value) + { + if (!value.HasValue) + { + return "1"; + } + + return value.Value ? "1" : "0"; + } + /// /// Add the encode settings to the preset /// @@ -557,11 +576,11 @@ namespace HandBrake.ApplicationServices.Utilities /// private static void AddEncodeSettings(XmlTextWriter xmlWriter, EncodeTask parsed, Preset preset) { - AddEncodeElement(xmlWriter, "AudioAllowAACPass", "integer", parsed.AllowedPassthruOptions.AudioAllowAACPass ? "1" : "0"); - AddEncodeElement(xmlWriter, "AudioAllowAC3Pass", "integer", parsed.AllowedPassthruOptions.AudioAllowAC3Pass ? "1" : "0"); - AddEncodeElement(xmlWriter, "AudioAllowDTSHDPass", "integer", parsed.AllowedPassthruOptions.AudioAllowDTSHDPass ? "1" : "0"); - AddEncodeElement(xmlWriter, "AudioAllowDTSPass", "integer", parsed.AllowedPassthruOptions.AudioAllowDTSPass ? "1" : "0"); - AddEncodeElement(xmlWriter, "AudioAllowMP3Pass", "integer", parsed.AllowedPassthruOptions.AudioAllowMP3Pass ? "1" : "0"); + AddEncodeElement(xmlWriter, "AudioAllowAACPass", "integer", getNullBoolValue(parsed.AllowedPassthruOptions.AudioAllowAACPass)); + AddEncodeElement(xmlWriter, "AudioAllowAC3Pass", "integer", getNullBoolValue(parsed.AllowedPassthruOptions.AudioAllowAC3Pass)); + AddEncodeElement(xmlWriter, "AudioAllowDTSHDPass", "integer", getNullBoolValue(parsed.AllowedPassthruOptions.AudioAllowDTSHDPass)); + AddEncodeElement(xmlWriter, "AudioAllowDTSPass", "integer", getNullBoolValue(parsed.AllowedPassthruOptions.AudioAllowDTSPass)); + AddEncodeElement(xmlWriter, "AudioAllowMP3Pass", "integer", getNullBoolValue(parsed.AllowedPassthruOptions.AudioAllowMP3Pass)); AddEncodeElement(xmlWriter, "AudioEncoderFallback", "string", EnumHelper.GetDisplay(parsed.AllowedPassthruOptions.AudioEncoderFallback)); AddEncodeElement(xmlWriter, "ChapterMarkers", "integer", parsed.IncludeChapterMarkers ? "1" : "0"); diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs index 4b5071984..bacb25de3 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs @@ -646,38 +646,50 @@ namespace HandBrake.ApplicationServices.Utilities query += " --gain " + audioItems; // Passthru Settings - if (task.AllowedPassthruOptions != null && task.AllowedPassthruOptions.IsEnabled) + if (task.AllowedPassthruOptions != null) { string fallbackEncoders = string.Empty; - if (task.AllowedPassthruOptions.AudioAllowAACPass) + if (task.AllowedPassthruOptions.AudioAllowAACPass != null && task.AllowedPassthruOptions.AudioAllowAACPass.Value) { fallbackEncoders += "aac"; } - if (task.AllowedPassthruOptions.AudioAllowAC3Pass) + if (task.AllowedPassthruOptions.AudioAllowAC3Pass != null && task.AllowedPassthruOptions.AudioAllowAC3Pass.Value) { fallbackEncoders += string.IsNullOrEmpty(fallbackEncoders) ? "ac3" : ",ac3"; } - if (task.AllowedPassthruOptions.AudioAllowDTSHDPass) + if (task.AllowedPassthruOptions.AudioAllowDTSHDPass != null && task.AllowedPassthruOptions.AudioAllowDTSHDPass.Value) { fallbackEncoders += string.IsNullOrEmpty(fallbackEncoders) ? "dtshd" : ",dtshd"; } - if (task.AllowedPassthruOptions.AudioAllowDTSPass) + if (task.AllowedPassthruOptions.AudioAllowDTSPass != null && task.AllowedPassthruOptions.AudioAllowDTSPass.Value) { fallbackEncoders += string.IsNullOrEmpty(fallbackEncoders) ? "dts" : ",dts"; } - if (task.AllowedPassthruOptions.AudioAllowMP3Pass) + if (task.AllowedPassthruOptions.AudioAllowMP3Pass != null && task.AllowedPassthruOptions.AudioAllowMP3Pass.Value) { fallbackEncoders += string.IsNullOrEmpty(fallbackEncoders) ? "mp3" : ",mp3"; } if (!string.IsNullOrEmpty(fallbackEncoders)) { - query += string.Format(" --audio-copy-mask {0}", fallbackEncoders); + // Special Case, The CLI alredy defaults to ALL, so if all area selected, then just set copy-mask to none + if (fallbackEncoders == "aac,ac3,dtshd,dts,mp3") + { + query += string.Format(" --audio-copy-mask none"); + } + else + { + query += string.Format(" --audio-copy-mask {0}", fallbackEncoders); + } + } + else + { + query += string.Format(" --audio-copy-mask none"); } query += string.Format(" --audio-fallback {0}", Converters.GetCliAudioEncoder(task.AllowedPassthruOptions.AudioEncoderFallback)); diff --git a/win/CS/HandBrakeWPF/Converters/Audio/AudioEncoderConverter.cs b/win/CS/HandBrakeWPF/Converters/Audio/AudioEncoderConverter.cs index ee975f876..061dbd6e8 100644 --- a/win/CS/HandBrakeWPF/Converters/Audio/AudioEncoderConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/Audio/AudioEncoderConverter.cs @@ -57,6 +57,16 @@ namespace HandBrakeWPF.Converters.Audio encoders.Remove(AudioEncoder.ffflac); } + if (parameter != null && parameter.ToString() == "True") + { + encoders.Remove(AudioEncoder.DtsHDPassthrough); + encoders.Remove(AudioEncoder.DtsPassthrough); + encoders.Remove(AudioEncoder.AacPassthru); + encoders.Remove(AudioEncoder.Ac3Passthrough); + encoders.Remove(AudioEncoder.Mp3Passthru); + encoders.Remove(AudioEncoder.Passthrough); + } + return EnumHelper.GetEnumDisplayValuesSubset(encoders); } diff --git a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs index 5fcfef614..6e1fcd675 100644 --- a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs @@ -179,9 +179,6 @@ namespace HandBrakeWPF.ViewModels this.Task.AllowedPassthruOptions = new AllowedPassthru(preset.Task.AllowedPassthruOptions); } this.NotifyOfPropertyChange(() => this.Task); - - this.Task.AllowedPassthruOptions.IsEnabled = - this.UserSettingService.GetUserSetting(UserSettingConstants.ShowAdvancedAudioPassthruOpts); } /// diff --git a/win/CS/HandBrakeWPF/Views/AudioView.xaml b/win/CS/HandBrakeWPF/Views/AudioView.xaml index 3741e3c07..a7e03d935 100644 --- a/win/CS/HandBrakeWPF/Views/AudioView.xaml +++ b/win/CS/HandBrakeWPF/Views/AudioView.xaml @@ -48,33 +48,41 @@ Orientation="Horizontal" Visibility="{Binding ShowPassthruOptions, Converter={StaticResource boolToVisConverter}}"> - + - + + + + + + + + + + + + + + + -- 2.40.0