summaryrefslogtreecommitdiffstats
path: root/win/CS
diff options
context:
space:
mode:
authorsr55 <[email protected]>2020-05-02 13:27:46 +0100
committersr55 <[email protected]>2020-05-02 13:27:46 +0100
commit4330e09c1b0e4784188423d2a17f94c89485610f (patch)
treebf1b1a4f6bb95718c5cd2b3ecf3409f9eeec1fda /win/CS
parentbcf0c6618f509dcf1346ad48e9e74f19aa2c9cd7 (diff)
WinGui: Filter out invalid audio encoder choices on the audio tab to avoid accidental track's being dropped.
Diffstat (limited to 'win/CS')
-rw-r--r--win/CS/HandBrakeWPF/Converters/Audio/AudioEncoderConverter.cs34
-rw-r--r--win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs121
-rw-r--r--win/CS/HandBrakeWPF/Views/AudioView.xaml1
3 files changed, 38 insertions, 118 deletions
diff --git a/win/CS/HandBrakeWPF/Converters/Audio/AudioEncoderConverter.cs b/win/CS/HandBrakeWPF/Converters/Audio/AudioEncoderConverter.cs
index cc317c14c..1e397532a 100644
--- a/win/CS/HandBrakeWPF/Converters/Audio/AudioEncoderConverter.cs
+++ b/win/CS/HandBrakeWPF/Converters/Audio/AudioEncoderConverter.cs
@@ -17,8 +17,11 @@ namespace HandBrakeWPF.Converters.Audio
using System.Windows.Data;
using HandBrake.Interop.Interop;
+ using HandBrake.Interop.Interop.Model.Encoding;
using HandBrake.Interop.Utilities;
+ using HandBrakeWPF.Model.Audio;
+ using HandBrakeWPF.Services.Scan.Model;
using HandBrakeWPF.Utilities;
using AudioEncoder = HandBrakeWPF.Services.Encode.Model.Models.AudioEncoder;
@@ -51,7 +54,7 @@ namespace HandBrakeWPF.Converters.Audio
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
// TODO -> Be smarter and only show the available Passthru options.
- if (values.Count() == 2)
+ if (values.Count() >= 2)
{
List<AudioEncoder> encoders = EnumHelper<AudioEncoder>.GetEnumList().ToList();
EncodeTask task = values[1] as EncodeTask;
@@ -95,6 +98,21 @@ namespace HandBrakeWPF.Converters.Audio
encoders.Add(AudioEncoder.None);
}
+ if (values.Length == 3)
+ {
+ encoders.Remove(AudioEncoder.Passthrough); // Auto passthru doesn't make sense on the main window. instead only show supported passthrus.
+
+ Audio sourceTrack = values[2] as Audio;
+ RemoveIfNotSupported(AudioEncoder.DtsHDPassthrough, sourceTrack, encoders);
+ RemoveIfNotSupported(AudioEncoder.DtsPassthrough, sourceTrack, encoders);
+ RemoveIfNotSupported(AudioEncoder.EAc3Passthrough, sourceTrack, encoders);
+ RemoveIfNotSupported(AudioEncoder.AacPassthru, sourceTrack, encoders);
+ RemoveIfNotSupported(AudioEncoder.Ac3Passthrough, sourceTrack, encoders);
+ RemoveIfNotSupported(AudioEncoder.Mp3Passthru, sourceTrack, encoders);
+ RemoveIfNotSupported(AudioEncoder.TrueHDPassthrough, sourceTrack, encoders);
+ RemoveIfNotSupported(AudioEncoder.FlacPassthru, sourceTrack, encoders);
+ }
+
return EnumHelper<AudioEncoder>.GetEnumDisplayValuesSubset(encoders);
}
@@ -134,5 +152,19 @@ namespace HandBrakeWPF.Converters.Audio
return null;
}
+
+ private void RemoveIfNotSupported(AudioEncoder encoder, Audio sourceTrack, List<AudioEncoder> encoders)
+ {
+ if (sourceTrack == null)
+ {
+ return;
+ }
+
+ HBAudioEncoder encoderInfo = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(encoder));
+ if ((sourceTrack.Codec & encoderInfo.Id) == 0)
+ {
+ encoders.Remove(encoder);
+ }
+ }
}
}
diff --git a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs
index a5111ce6c..b32d3d44c 100644
--- a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs
+++ b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs
@@ -45,10 +45,7 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
private AudioEncoderRateType encoderRateType;
private double? quality;
private string trackName;
-
- /// <summary>
- /// Initializes a new instance of the <see cref = "AudioTrack" /> class.
- /// </summary>
+
public AudioTrack()
{
// Default Values
@@ -70,16 +67,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
this.SetupLimits();
}
- /// <summary>
- /// Initializes a new instance of the <see cref="AudioTrack"/> class.
- /// Copy Constructor
- /// </summary>
- /// <param name="track">
- /// The track.
- /// </param>
- /// <param name="setScannedTrack">
- /// The set Scanned Track.
- /// </param>
public AudioTrack(AudioTrack track, bool setScannedTrack)
{
this.bitrate = track.Bitrate;
@@ -110,19 +97,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
this.SetupLimits();
}
- /// <summary>
- /// Initializes a new instance of the <see cref="AudioTrack"/> class.
- /// Create a track from a behaviour track.
- /// </summary>
- /// <param name="track">
- /// The Behavior track
- /// </param>
- /// <param name="sourceTrack">
- /// The source track we are dealing with.
- /// </param>
- /// <param name="fallback">
- /// An encoder to fall back to.
- /// </param>
public AudioTrack(AudioBehaviourTrack track, Audio sourceTrack, AllowedPassthru fallback, OutputFormat container)
{
AudioEncoder chosenEncoder = track.Encoder;
@@ -186,11 +160,8 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
this.SetupLimits();
}
- #region Track Properties
+ /* Audio Track Properties */
- /// <summary>
- /// Gets or sets Dynamic Range Compression
- /// </summary>
public double DRC
{
get
@@ -208,9 +179,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
}
}
- /// <summary>
- /// Gets or sets the Gain for the audio track
- /// </summary>
public int Gain
{
get
@@ -228,9 +196,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
}
}
- /// <summary>
- /// Gets or sets Audio Mixdown (ShortName)
- /// </summary>
public string MixDown
{
get
@@ -249,9 +214,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
}
}
- /// <summary>
- /// Gets or sets Audio Encoder
- /// </summary>
public AudioEncoder Encoder
{
get
@@ -285,9 +247,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
}
}
- /// <summary>
- /// Gets or sets Audio SampleRate
- /// </summary>
public double SampleRate
{
get
@@ -303,9 +262,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
}
}
- /// <summary>
- /// Gets or sets the encoder rate type.
- /// </summary>
public AudioEncoderRateType EncoderRateType
{
get
@@ -329,9 +285,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
}
}
- /// <summary>
- /// Gets or sets Audio Bitrate
- /// </summary>
public int Bitrate
{
get
@@ -346,9 +299,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
}
}
- /// <summary>
- /// Gets or sets Audio quality
- /// </summary>
public double? Quality
{
get
@@ -363,9 +313,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
}
}
- /// <summary>
- /// Gets or sets the track name.
- /// </summary>
public string TrackName
{
get => this.trackName;
@@ -377,11 +324,8 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
}
}
- #endregion
+ /* UI Only Properties */
- /// <summary>
- /// Gets AudioEncoderDisplayValue.
- /// </summary>
[JsonIgnore]
public string AudioEncoderDisplayValue
{
@@ -391,9 +335,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
}
}
- /// <summary>
- /// Gets the The UI display value for bit rate
- /// </summary>
[JsonIgnore]
public string BitRateDisplayValue
{
@@ -409,10 +350,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
}
}
- /// <summary>
- /// Gets or sets a value indicating whether is default.
- /// TODO - Can this be removed? May have been added as a quick fix for a styling quirk.
- /// </summary>
[JsonIgnore]
public bool IsDefault
{
@@ -426,9 +363,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
}
}
- /// <summary>
- /// Gets or sets the The UI display value for sample rate
- /// </summary>
[JsonIgnore]
public string SampleRateDisplayValue
{
@@ -451,9 +385,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
}
}
- /// <summary>
- /// Gets or sets the Scanned Audio Tracks
- /// </summary>
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public Audio ScannedTrack
{
@@ -474,9 +405,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
}
}
- /// <summary>
- /// Gets the Audio Track Name
- /// </summary>
[JsonIgnore]
public int? Track
{
@@ -491,9 +419,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
}
}
- /// <summary>
- /// Gets a value indicating whether IsPassthru.
- /// </summary>
[JsonIgnore]
public bool IsPassthru
{
@@ -511,9 +436,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
}
}
- /// <summary>
- /// Gets the bitrates.
- /// </summary>
[JsonIgnore]
public IEnumerable<int> Bitrates
{
@@ -523,9 +445,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
}
}
- /// <summary>
- /// Gets the quality compression values.
- /// </summary>
[JsonIgnore]
public IEnumerable<double> EncoderQualityValues
{
@@ -535,9 +454,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
}
}
- /// <summary>
- /// Gets the audio encoder rate types.
- /// </summary>
[JsonIgnore]
public IEnumerable<AudioEncoderRateType> AudioEncoderRateTypes
{
@@ -554,9 +470,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
}
}
- /// <summary>
- /// Gets a value indicating whether can set bitrate.
- /// </summary>
[JsonIgnore]
public bool IsBitrateVisible
{
@@ -571,9 +484,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
}
}
- /// <summary>
- /// Gets a value indicating whether is quality visible.
- /// </summary>
[JsonIgnore]
public bool IsQualityVisible
{
@@ -588,9 +498,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
}
}
- /// <summary>
- /// Gets a value indicating whether is rate type visible.
- /// </summary>
[JsonIgnore]
public bool IsRateTypeVisible
{
@@ -605,9 +512,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
}
}
- /// <summary>
- /// Gets a value indicating whether IsLossless.
- /// </summary>
[JsonIgnore]
public bool IsLossless
{
@@ -617,20 +521,14 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
}
}
- /// <summary>
- /// Gets TrackReference.
- /// </summary>
[JsonIgnore]
public AudioTrack TrackReference
{
get { return this; }
}
- #region Handler Methods
+ /* Helper Methods */
- /// <summary>
- /// The setup limits.
- /// </summary>
private void SetupLimits()
{
this.SetupBitrateLimits();
@@ -638,9 +536,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
this.GetDefaultMixdownIfNull();
}
- /// <summary>
- /// The calculate bitrate limits.
- /// </summary>
private void SetupBitrateLimits()
{
// Base set of bitrates available.
@@ -674,9 +569,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
}
}
- /// <summary>
- /// The setup quality compression limits.
- /// </summary>
private void SetupQualityCompressionLimits()
{
HBAudioEncoder hbAudioEncoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<HandBrakeWPF.Services.Encode.Model.Models.AudioEncoder>.GetShortName(this.Encoder));
@@ -735,9 +627,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
this.NotifyOfPropertyChange(() => this.EncoderQualityValues);
}
- /// <summary>
- /// Set the default mixdown when the mixdown is null or "none"
- /// </summary>
private void GetDefaultMixdownIfNull()
{
if (this.ScannedTrack == null)
@@ -760,8 +649,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
}
}
- #endregion
-
public override string ToString()
{
return string.Format("Audio Track: Title {0}", this.ScannedTrack.ToString());
diff --git a/win/CS/HandBrakeWPF/Views/AudioView.xaml b/win/CS/HandBrakeWPF/Views/AudioView.xaml
index 5349a47b8..9b353585c 100644
--- a/win/CS/HandBrakeWPF/Views/AudioView.xaml
+++ b/win/CS/HandBrakeWPF/Views/AudioView.xaml
@@ -184,6 +184,7 @@
<MultiBinding Converter="{StaticResource audioEncoderConverter}">
<Binding Path="DataContext.AudioEncoders" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UserControl}}" />
<Binding Path="DataContext.Task" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UserControl}}" />
+ <Binding Path="ScannedTrack" />
</MultiBinding>
</ComboBox.ItemsSource>
</ComboBox>