From 0a8dde9d78fc57ef19e53f50405e9a3124802267 Mon Sep 17 00:00:00 2001 From: sr55 Date: Mon, 10 Apr 2017 17:03:32 +0100 Subject: WinGui: Audio Defaults: Improve the Mixdown dropdown. Only show supported mixdowns and automatically select the highest available mixdown if the encoder is limited and doesn't support the current selection. --- .../Model/Audio/AudioBehaviourTrack.cs | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'win/CS/HandBrakeWPF/Model') diff --git a/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviourTrack.cs b/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviourTrack.cs index 78c20d52c..c59b15b8c 100644 --- a/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviourTrack.cs +++ b/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviourTrack.cs @@ -10,6 +10,7 @@ namespace HandBrakeWPF.Model.Audio { using System.Collections.Generic; + using System.ComponentModel; using System.Globalization; using System.Linq; using HandBrake.ApplicationServices.Interop; @@ -35,6 +36,7 @@ namespace HandBrakeWPF.Model.Audio private IEnumerable encoderQualityValues; private AudioEncoderRateType encoderRateType; private double? quality; + private IEnumerable mixdowns; /// /// Initializes a new instance of the class. @@ -48,6 +50,7 @@ namespace HandBrakeWPF.Model.Audio this.Bitrate = 160; this.DRC = 0; this.EncoderRateType = AudioEncoderRateType.Bitrate; + this.SetupLimits(); } @@ -68,6 +71,7 @@ namespace HandBrakeWPF.Model.Audio this.sampleRate = track.SampleRate; this.Quality = track.Quality; this.encoderRateType = track.EncoderRateType; + this.SetupLimits(); } @@ -354,6 +358,15 @@ namespace HandBrakeWPF.Model.Audio } } + [JsonIgnore] + public IEnumerable Mixdowns + { + get + { + return this.mixdowns; + } + } + /// /// Gets the quality compression values. /// @@ -466,6 +479,7 @@ namespace HandBrakeWPF.Model.Audio { this.SetupBitrateLimits(); this.SetupQualityCompressionLimits(); + this.SetupMixdowns(); } /// @@ -565,6 +579,34 @@ namespace HandBrakeWPF.Model.Audio this.NotifyOfPropertyChange(() => this.EncoderQualityValues); } + /// + /// Restrict the available mixdowns to those that the enocder actually supports. + /// + private void SetupMixdowns() + { + this.mixdowns = new BindingList(HandBrakeEncoderHelpers.Mixdowns.ToList()); + + HBAudioEncoder audioEncoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper.GetShortName(this.Encoder)); + + BindingList mixdownList = new BindingList(); + foreach (HBMixdown mixdown in HandBrakeEncoderHelpers.Mixdowns) + { + if (HandBrakeEncoderHelpers.MixdownHasCodecSupport(mixdown, audioEncoder)) + { + mixdownList.Add(mixdown); + } + } + + this.mixdowns = new BindingList(mixdownList); + this.NotifyOfPropertyChange(() => this.Mixdowns); + + // If the mixdown isn't supported, downgrade it to the best available. + if (!this.Mixdowns.Contains(this.MixDown)) + { + this.MixDown = this.Mixdowns.LastOrDefault(); + } + } + /// /// Set the default mixdown when the mixdown is null or "none" /// -- cgit v1.2.3