diff options
author | sr55 <[email protected]> | 2012-07-23 16:57:39 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2012-07-23 16:57:39 +0000 |
commit | 6c8108e0760796e153f62de9b08325f433105bff (patch) | |
tree | f584e99a9ace46b1bce9af6f9136f67375cb1226 /win/CS | |
parent | daafb500d527e3e5d1a1790bba6dd287c28eedbb (diff) |
WinGui: Fix up the Audio Passthru selection options.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4872 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS')
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;
/// <summary>
/// Allowed Passthru Options
/// </summary>
public class AllowedPassthru
{
+ #region Constants and Fields
+
+ /// <summary>
+ /// The audio allow aac pass.
+ /// </summary>
+ private bool? audioAllowAACPass;
+
+ /// <summary>
+ /// The audio allow a c 3 pass.
+ /// </summary>
+ private bool? audioAllowAC3Pass;
+
+ /// <summary>
+ /// The audio allow dtshd pass.
+ /// </summary>
+ private bool? audioAllowDTSHDPass;
+
+ /// <summary>
+ /// The audio allow dts pass.
+ /// </summary>
+ private bool? audioAllowDTSPass;
+
+ /// <summary>
+ /// The audio allow m p 3 pass.
+ /// </summary>
+ private bool? audioAllowMP3Pass;
+
+ #endregion
+
+ #region Constructors and Destructors
+
/// <summary>
/// Initializes a new instance of the <see cref="AllowedPassthru"/> class.
/// </summary>
@@ -35,7 +66,7 @@ namespace HandBrake.ApplicationServices.Model.Encoding /// <param name="initialValue">
/// The initial Value.
/// </param>
- 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;
}
- /// <summary>
- /// Gets or sets a value indicating whether IsEnabled.
- /// Temp Measure until forms gui is retired.
- /// </summary>
- public bool IsEnabled { get; set; }
+ #endregion
+
+ #region Properties
/// <summary>
/// Gets or sets a value indicating whether AudioAllowAACPass.
/// </summary>
- public bool AudioAllowAACPass { get; set; }
+ public bool? AudioAllowAACPass
+ {
+ get
+ {
+ return this.audioAllowAACPass ?? true;
+ }
+ set
+ {
+ this.audioAllowAACPass = value;
+ }
+ }
/// <summary>
/// Gets or sets a value indicating whether AudioAllowAC3Pass.
/// </summary>
- public bool AudioAllowAC3Pass { get; set; }
+ public bool? AudioAllowAC3Pass
+ {
+ get
+ {
+ return this.audioAllowAC3Pass ?? true;
+ }
+ set
+ {
+ this.audioAllowAC3Pass = value;
+ }
+ }
/// <summary>
/// Gets or sets a value indicating whether AudioAllowDTSHDPass.
/// </summary>
- public bool AudioAllowDTSHDPass { get; set; }
+ public bool? AudioAllowDTSHDPass
+ {
+ get
+ {
+ return this.audioAllowDTSHDPass ?? true;
+ }
+ set
+ {
+ this.audioAllowDTSHDPass = value;
+ }
+ }
/// <summary>
/// Gets or sets a value indicating whether AudioAllowDTSPass.
/// </summary>
- public bool AudioAllowDTSPass { get; set; }
+ public bool? AudioAllowDTSPass
+ {
+ get
+ {
+ return this.audioAllowDTSPass ?? true;
+ }
+ set
+ {
+ this.audioAllowDTSPass = value;
+ }
+ }
/// <summary>
/// Gets or sets a value indicating whether AudioAllowMP3Pass.
/// </summary>
- public bool AudioAllowMP3Pass { get; set; }
+ public bool? AudioAllowMP3Pass
+ {
+ get
+ {
+ return this.audioAllowMP3Pass ?? true;
+ }
+ set
+ {
+ this.audioAllowMP3Pass = value;
+ }
+ }
/// <summary>
/// Gets or sets AudioEncoderFallback.
/// </summary>
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 @@ -544,6 +544,25 @@ namespace HandBrake.ApplicationServices.Utilities }
/// <summary>
+ /// The get null bool value.
+ /// </summary>
+ /// <param name="value">
+ /// The value.
+ /// </param>
+ /// <returns>
+ /// The System.String.
+ /// </returns>
+ private static string getNullBoolValue(bool? value)
+ {
+ if (!value.HasValue)
+ {
+ return "1";
+ }
+
+ return value.Value ? "1" : "0";
+ }
+
+ /// <summary>
/// Add the encode settings to the preset
/// </summary>
/// <param name="xmlWriter">
@@ -557,11 +576,11 @@ namespace HandBrake.ApplicationServices.Utilities /// </param>
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<AudioEncoder>.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<AudioEncoder>.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<bool>(UserSettingConstants.ShowAdvancedAudioPassthruOpts);
}
/// <summary>
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}}">
- <TextBlock Margin="5,0,5,0" Text="Auto Passthru:" />
+ <TextBlock Margin="5,0,5,0" Text="Auto Passthru:" VerticalAlignment="Center" />
<CheckBox Margin="0,0,5,0"
- Content="MP3"
+ Content="MP3" VerticalAlignment="Center"
IsChecked="{Binding Task.AllowedPassthruOptions.AudioAllowMP3Pass}" />
<CheckBox Margin="0,0,5,0"
- Content="AAC"
+ Content="AAC" VerticalAlignment="Center"
IsChecked="{Binding Task.AllowedPassthruOptions.AudioAllowAACPass}" />
<CheckBox Margin="0,0,5,0"
- Content="AC3"
+ Content="AC3" VerticalAlignment="Center"
IsChecked="{Binding Task.AllowedPassthruOptions.AudioAllowAC3Pass}" />
<CheckBox Margin="0,0,5,0"
- Content="DTS"
+ Content="DTS" VerticalAlignment="Center"
IsChecked="{Binding Task.AllowedPassthruOptions.AudioAllowDTSPass}" />
<CheckBox Margin="0,0,5,0"
- Content="DTSHD"
+ Content="DTSHD" VerticalAlignment="Center"
IsChecked="{Binding Task.AllowedPassthruOptions.AudioAllowDTSHDPass}" />
<TextBlock Margin="5,0,5,0" Text="Fallback:" />
- <ComboBox Grid.Column="3"
- Width="100"
- Height="22"
- Margin="10,0,5,0"
- ItemsSource="{Binding DataContext.AudioEncoders,
- Converter={StaticResource enumComboConverter},
- RelativeSource={RelativeSource FindAncestor,
- AncestorType={x:Type UserControl}}}"
- SelectedItem="{Binding Task.AllowedPassthruOptions.AudioEncoderFallback,
- Converter={StaticResource enumComboConverter}}" />
+
+ <ComboBox Grid.Column="3" VerticalAlignment="Center"
+ Width="100"
+ Height="22"
+ Margin="10,0,5,0">
+ <ComboBox.SelectedItem>
+ <MultiBinding Converter="{StaticResource audioEncoderConverter}">
+ <Binding Path="Task.AllowedPassthruOptions.AudioEncoderFallback" />
+ </MultiBinding>
+ </ComboBox.SelectedItem>
+ <ComboBox.ItemsSource>
+ <MultiBinding Converter="{StaticResource audioEncoderConverter}" ConverterParameter="True">
+ <Binding Path="DataContext.AudioEncoders" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UserControl}}" />
+ <Binding Path="DataContext.Task" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UserControl}}" />
+ </MultiBinding>
+ </ComboBox.ItemsSource>
+ </ComboBox>
+
</StackPanel>
</Grid>
|