From 2fcd31e9ef0795d6d3a0c0201ba2e7650d0c4909 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 7 Jan 2012 18:55:26 +0000 Subject: WinGui: Control over automatic passthru options on the Audio Panel. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4401 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/CS/Controls/AudioPanel.cs | 136 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 129 insertions(+), 7 deletions(-) (limited to 'win/CS/Controls/AudioPanel.cs') diff --git a/win/CS/Controls/AudioPanel.cs b/win/CS/Controls/AudioPanel.cs index 61b908299..69d4fb065 100644 --- a/win/CS/Controls/AudioPanel.cs +++ b/win/CS/Controls/AudioPanel.cs @@ -78,6 +78,10 @@ namespace Handbrake.Controls drp_audioEncoder.SelectedItem = "AAC (faac)"; drp_audioTrack.DataSource = this.ScannedTracks; + + // Setup Auto-Passthru Settings + this.PassthruSettings = new AllowedPassthru(); + this.SetPassthruSettings(this.PassthruSettings); } /// @@ -105,6 +109,11 @@ namespace Handbrake.Controls } } + /// + /// Gets or sets PassthruSettings. + /// + public AllowedPassthru PassthruSettings { get; set; } + #endregion #region Public Methods @@ -118,6 +127,7 @@ namespace Handbrake.Controls public void SetContainer(string path) { string oldval = drp_audioEncoder.Text; + string fallbackOldVal = drp_passthruFallback.Text; drp_audioEncoder.Items.Clear(); drp_audioEncoder.Items.Add(EnumHelper.GetDisplay(AudioEncoder.Faac)); @@ -130,16 +140,31 @@ namespace Handbrake.Controls drp_audioEncoder.Items.Add(EnumHelper.GetDisplay(AudioEncoder.DtsPassthrough)); drp_audioEncoder.Items.Add(EnumHelper.GetDisplay(AudioEncoder.DtsHDPassthrough)); + drp_passthruFallback.Items.Clear(); + drp_passthruFallback.Items.Add(EnumHelper.GetDisplay(AudioEncoder.Faac)); + drp_passthruFallback.Items.Add(EnumHelper.GetDisplay(AudioEncoder.ffaac)); + drp_passthruFallback.Items.Add(EnumHelper.GetDisplay(AudioEncoder.Lame)); + drp_passthruFallback.Items.Add(EnumHelper.GetDisplay(AudioEncoder.Ac3)); + if (path.Contains("MKV")) { drp_audioEncoder.Items.Add(EnumHelper.GetDisplay(AudioEncoder.Vorbis)); drp_audioEncoder.Items.Add(EnumHelper.GetDisplay(AudioEncoder.ffflac)); + + drp_passthruFallback.Items.Add(EnumHelper.GetDisplay(AudioEncoder.Vorbis)); + drp_passthruFallback.Items.Add(EnumHelper.GetDisplay(AudioEncoder.ffflac)); } + if (!drp_audioEncoder.Items.Contains(oldval)) drp_audioEncoder.SelectedIndex = 0; else drp_audioEncoder.SelectedItem = oldval; + + if (!drp_passthruFallback.Items.Contains(fallbackOldVal)) + drp_passthruFallback.SelectedIndex = 3; + else + drp_passthruFallback.SelectedItem = fallbackOldVal; } /// @@ -154,11 +179,17 @@ namespace Handbrake.Controls /// /// Load an arraylist of AudioTrack items into the list. /// - /// List of audio tracks - public void LoadTracks(ObservableCollection tracks) + /// + /// The preset. + /// + public void LoadTracks(Preset preset) { ClearAudioList(); + ObservableCollection tracks = preset.Task.AudioTracks; + this.PassthruSettings = preset.AudioPassthruSettings ?? new AllowedPassthru(false); + this.SetPassthruSettings(this.PassthruSettings); + if (tracks == null || (drp_audioTrack.SelectedItem != null && drp_audioTrack.SelectedItem.ToString() == AudioHelper.NoneFound.Description)) return; @@ -195,6 +226,10 @@ namespace Handbrake.Controls this.AudioTracks.Clear(); this.ScannedTracks.Clear(); + // Setup the passthru options + this.PassthruSettings = preset.AudioPassthruSettings ?? new AllowedPassthru(false); + this.SetPassthruSettings(this.PassthruSettings); + if (selectedTitle.AudioTracks.Count == 0) { this.ScannedTracks.Add(AudioHelper.NoneFound); @@ -1043,31 +1078,66 @@ namespace Handbrake.Controls /// private AudioEncoder GetCompatiblePassthru(AudioTrack track) { - if (track.ScannedTrack.Format.Contains("AC3")) + if (track.ScannedTrack.Format.Contains("AC3") && this.check_ac3.Checked) { return AudioEncoder.Ac3Passthrough; } - if (track.ScannedTrack.Format.Contains("DTS")) + if (track.ScannedTrack.Format.Contains("DTS") && this.check_dts.Checked) + { + return AudioEncoder.DtsPassthrough; + } + + if (track.ScannedTrack.Format.Contains("DTS-HD") && this.check_dtshd.Checked) { return AudioEncoder.DtsPassthrough; } - if (track.ScannedTrack.Format.Contains("aac")) + if (track.ScannedTrack.Format.Contains("aac") && this.check_aac.Checked) { return AudioEncoder.AacPassthru; } - if (track.ScannedTrack.Format.Contains("mp3")) + if (track.ScannedTrack.Format.Contains("mp3") && this.check_mp3.Checked) { return AudioEncoder.Mp3Passthru; } - return AudioEncoder.Faac; + return EnumHelper.GetValue(drp_passthruFallback.SelectedItem.ToString()); + } + + /// + /// Setup the Passthru Settings Panel + /// + /// + /// The settings. + /// + private void SetPassthruSettings(AllowedPassthru settings) + { + if (settings == null) + { + settings = this.PassthruSettings; + } + + this.check_aac.Checked = settings.AudioAllowAACPass; + this.check_mp3.Checked = settings.AudioAllowMP3Pass; + this.check_ac3.Checked = settings.AudioAllowAC3Pass; + this.check_dts.Checked = settings.AudioAllowDTSPass; + this.check_dtshd.Checked = settings.AudioAllowDTSHDPass; + this.drp_passthruFallback.SelectedItem = EnumHelper.GetDisplay(settings.AudioEncoderFallback); } #endregion + /// + /// Open the Advanced Audio Settings UI + /// + /// + /// The sender. + /// + /// + /// The e. + /// private void btn_AdvancedAudio_Click(object sender, EventArgs e) { if (audioList.SelectedRows.Count == 0) @@ -1084,5 +1154,57 @@ namespace Handbrake.Controls advancedAudio.Show(); } + + /// + /// Handle changes in the Checked Passthru Options + /// + /// + /// The sender. + /// + /// + /// The EventArgs. + /// + private void autoPassthru_CheckedChanged(object sender, EventArgs e) + { + if (sender == this.check_mp3) + { + this.PassthruSettings.AudioAllowMP3Pass = this.check_mp3.Checked; + } + + if (sender == this.check_aac) + { + this.PassthruSettings.AudioAllowAACPass = this.check_aac.Checked; + } + + if (sender == this.check_ac3) + { + this.PassthruSettings.AudioAllowAC3Pass = this.check_ac3.Checked; + } + + if (sender == this.check_dts) + { + this.PassthruSettings.AudioAllowDTSPass = this.check_dts.Checked; + } + + if (sender == this.check_dtshd) + { + this.PassthruSettings.AudioAllowDTSHDPass = this.check_dtshd.Checked; + } + } + + /// + /// Set the fallback encoder + /// + /// + /// The sender. + /// + /// + /// The e. + /// + private void drp_passthruFallback_SelectedIndexChanged(object sender, EventArgs e) + { + this.PassthruSettings.AudioEncoderFallback = + EnumHelper.GetValue(drp_passthruFallback.SelectedItem.ToString()); + } } } \ No newline at end of file -- cgit v1.2.3