// -------------------------------------------------------------------------------------------------------------------- // // This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. // // // Defines the AudioMixdownListConverter type. // // -------------------------------------------------------------------------------------------------------------------- namespace HandBrakeWPF.Converters.Audio { using System; using System.ComponentModel; using System.Globalization; using System.Windows.Data; using HandBrake.ApplicationServices.Interop; using HandBrake.ApplicationServices.Interop.Model.Encoding; using HandBrakeWPF.Services.Encode.Model.Models; using HandBrakeWPF.Utilities; /// /// The audio mixdown converter. /// Returns the list of available mixdowns for the given track and encoder. /// public class AudioMixdownListConverter : IValueConverter { /// /// Converts a value. /// /// /// A converted value. If the method returns null, the valid null value is used. /// /// The value produced by the binding source.The type of the binding target property.The converter parameter to use.The culture to use in the converter. public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { AudioTrack track = value as AudioTrack; if (track != null && track.ScannedTrack != null) { HBAudioEncoder encoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper.GetShortName(track.Encoder)); BindingList mixdowns = new BindingList(); foreach (HBMixdown mixdown in HandBrakeEncoderHelpers.Mixdowns) { if (HandBrakeEncoderHelpers.MixdownIsSupported( mixdown, encoder, track.ScannedTrack.ChannelLayout)) { mixdowns.Add(mixdown); } } return mixdowns; } return value; } /// /// Converts a value. /// /// /// A converted value. If the method returns null, the valid null value is used. /// /// The value that is produced by the binding target.The type to convert to.The converter parameter to use.The culture to use in the converter. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { return value; } } }