]> granicus.if.org Git - handbrake/commitdiff
WinGui: Control over automatic passthru options on the Audio Panel.
authorsr55 <sr55.hb@outlook.com>
Sat, 7 Jan 2012 18:55:26 +0000 (18:55 +0000)
committersr55 <sr55.hb@outlook.com>
Sat, 7 Jan 2012 18:55:26 +0000 (18:55 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4401 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/Controls/AudioPanel.Designer.cs
win/CS/Controls/AudioPanel.cs
win/CS/Controls/AudioPanel.resx
win/CS/Functions/PresetLoader.cs
win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
win/CS/HandBrake.ApplicationServices/Model/Encoding/AllowedPassthru.cs [new file with mode: 0644]
win/CS/HandBrake.ApplicationServices/Model/Preset.cs
win/CS/HandBrake.ApplicationServices/Services/PresetService.cs
win/CS/frmAddPreset.cs
win/CS/frmMain.cs

index 4498f650bcc42e9ea642d6b6d06c5011e410ddfb..69c990dee4d2f4196edf329ea225576932764540 100644 (file)
@@ -59,6 +59,7 @@ namespace Handbrake.Controls
             this.DRC = new System.Windows.Forms.DataGridViewTextBoxColumn();\r
             this.Gain = new System.Windows.Forms.DataGridViewTextBoxColumn();\r
             this.ToolTips = new System.Windows.Forms.ToolTip(this.components);\r
+            this.drp_passthruFallback = new System.Windows.Forms.ComboBox();\r
             this.btn_AdvancedAudio = new System.Windows.Forms.Button();\r
             this.btn_addAudioTrack = new wyDay.Controls.SplitButton();\r
             this.AddTrackMenu = new System.Windows.Forms.ContextMenuStrip(this.components);\r
@@ -66,10 +67,18 @@ namespace Handbrake.Controls
             this.btn_RemoveTrack = new wyDay.Controls.SplitButton();\r
             this.RemoveTrackMenu = new System.Windows.Forms.ContextMenuStrip(this.components);\r
             this.mnu_ClearAll = new System.Windows.Forms.ToolStripMenuItem();\r
+            this.groupBox1 = new System.Windows.Forms.GroupBox();\r
+            this.label1 = new System.Windows.Forms.Label();\r
+            this.check_dtshd = new System.Windows.Forms.CheckBox();\r
+            this.check_dts = new System.Windows.Forms.CheckBox();\r
+            this.check_ac3 = new System.Windows.Forms.CheckBox();\r
+            this.check_aac = new System.Windows.Forms.CheckBox();\r
+            this.check_mp3 = new System.Windows.Forms.CheckBox();\r
             this.audioMenu.SuspendLayout();\r
             ((System.ComponentModel.ISupportInitialize)(this.audioList)).BeginInit();\r
             this.AddTrackMenu.SuspendLayout();\r
             this.RemoveTrackMenu.SuspendLayout();\r
+            this.groupBox1.SuspendLayout();\r
             this.SuspendLayout();\r
             // \r
             // audioMenu\r
@@ -337,6 +346,22 @@ namespace Handbrake.Controls
             this.Gain.ReadOnly = true;\r
             this.Gain.Width = 60;\r
             // \r
+            // ToolTips\r
+            // \r
+            this.ToolTips.AutomaticDelay = 1500;\r
+            // \r
+            // drp_passthruFallback\r
+            // \r
+            this.drp_passthruFallback.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drp_passthruFallback.Font = new System.Drawing.Font("Tahoma", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.drp_passthruFallback.FormattingEnabled = true;\r
+            this.drp_passthruFallback.Location = new System.Drawing.Point(327, 15);\r
+            this.drp_passthruFallback.Name = "drp_passthruFallback";\r
+            this.drp_passthruFallback.Size = new System.Drawing.Size(111, 19);\r
+            this.drp_passthruFallback.TabIndex = 75;\r
+            this.ToolTips.SetToolTip(this.drp_passthruFallback, "The Audio Encoder that will be used, if there is no suitable passthru option.");\r
+            this.drp_passthruFallback.SelectedIndexChanged += new System.EventHandler(this.drp_passthruFallback_SelectedIndexChanged);\r
+            // \r
             // btn_AdvancedAudio\r
             // \r
             this.btn_AdvancedAudio.BackColor = System.Drawing.Color.Transparent;\r
@@ -409,10 +434,104 @@ namespace Handbrake.Controls
             this.mnu_ClearAll.Text = "Clear All";\r
             this.mnu_ClearAll.Click += new System.EventHandler(this.Mnu_clear_all_click);\r
             // \r
+            // groupBox1\r
+            // \r
+            this.groupBox1.Controls.Add(this.label1);\r
+            this.groupBox1.Controls.Add(this.drp_passthruFallback);\r
+            this.groupBox1.Controls.Add(this.check_dtshd);\r
+            this.groupBox1.Controls.Add(this.check_dts);\r
+            this.groupBox1.Controls.Add(this.check_ac3);\r
+            this.groupBox1.Controls.Add(this.check_aac);\r
+            this.groupBox1.Controls.Add(this.check_mp3);\r
+            this.groupBox1.Font = new System.Drawing.Font("Tahoma", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.groupBox1.Location = new System.Drawing.Point(256, 19);\r
+            this.groupBox1.Name = "groupBox1";\r
+            this.groupBox1.Size = new System.Drawing.Size(445, 40);\r
+            this.groupBox1.TabIndex = 74;\r
+            this.groupBox1.TabStop = false;\r
+            this.groupBox1.Text = "Auto Passthru";\r
+            this.ToolTips.SetToolTip(this.groupBox1, resources.GetString("groupBox1.ToolTip"));\r
+            // \r
+            // label1\r
+            // \r
+            this.label1.AutoSize = true;\r
+            this.label1.Font = new System.Drawing.Font("Tahoma", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label1.Location = new System.Drawing.Point(279, 18);\r
+            this.label1.Name = "label1";\r
+            this.label1.Size = new System.Drawing.Size(42, 11);\r
+            this.label1.TabIndex = 76;\r
+            this.label1.Text = "Fallback:";\r
+            // \r
+            // check_dtshd\r
+            // \r
+            this.check_dtshd.AutoSize = true;\r
+            this.check_dtshd.Font = new System.Drawing.Font("Tahoma", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.check_dtshd.Location = new System.Drawing.Point(214, 17);\r
+            this.check_dtshd.Name = "check_dtshd";\r
+            this.check_dtshd.Size = new System.Drawing.Size(60, 15);\r
+            this.check_dtshd.TabIndex = 4;\r
+            this.check_dtshd.Text = "DTS-HD";\r
+            this.ToolTips.SetToolTip(this.check_dtshd, "Allow DTS-HD Passthru");\r
+            this.check_dtshd.UseVisualStyleBackColor = true;\r
+            this.check_dtshd.CheckedChanged += new System.EventHandler(this.autoPassthru_CheckedChanged);\r
+            // \r
+            // check_dts\r
+            // \r
+            this.check_dts.AutoSize = true;\r
+            this.check_dts.Font = new System.Drawing.Font("Tahoma", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.check_dts.Location = new System.Drawing.Point(163, 17);\r
+            this.check_dts.Name = "check_dts";\r
+            this.check_dts.Size = new System.Drawing.Size(43, 15);\r
+            this.check_dts.TabIndex = 3;\r
+            this.check_dts.Text = "DTS";\r
+            this.ToolTips.SetToolTip(this.check_dts, "Allow DTS Passthru");\r
+            this.check_dts.UseVisualStyleBackColor = true;\r
+            this.check_dts.CheckedChanged += new System.EventHandler(this.autoPassthru_CheckedChanged);\r
+            // \r
+            // check_ac3\r
+            // \r
+            this.check_ac3.AutoSize = true;\r
+            this.check_ac3.Font = new System.Drawing.Font("Tahoma", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.check_ac3.Location = new System.Drawing.Point(111, 17);\r
+            this.check_ac3.Name = "check_ac3";\r
+            this.check_ac3.Size = new System.Drawing.Size(43, 15);\r
+            this.check_ac3.TabIndex = 2;\r
+            this.check_ac3.Text = "AC3";\r
+            this.ToolTips.SetToolTip(this.check_ac3, "Allow AC3 Passthru");\r
+            this.check_ac3.UseVisualStyleBackColor = true;\r
+            this.check_ac3.CheckedChanged += new System.EventHandler(this.autoPassthru_CheckedChanged);\r
+            // \r
+            // check_aac\r
+            // \r
+            this.check_aac.AutoSize = true;\r
+            this.check_aac.Font = new System.Drawing.Font("Tahoma", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.check_aac.Location = new System.Drawing.Point(58, 17);\r
+            this.check_aac.Name = "check_aac";\r
+            this.check_aac.Size = new System.Drawing.Size(45, 15);\r
+            this.check_aac.TabIndex = 1;\r
+            this.check_aac.Text = "AAC";\r
+            this.ToolTips.SetToolTip(this.check_aac, "Allow AAC Passthru");\r
+            this.check_aac.UseVisualStyleBackColor = true;\r
+            this.check_aac.CheckedChanged += new System.EventHandler(this.autoPassthru_CheckedChanged);\r
+            // \r
+            // check_mp3\r
+            // \r
+            this.check_mp3.AutoSize = true;\r
+            this.check_mp3.Font = new System.Drawing.Font("Tahoma", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.check_mp3.Location = new System.Drawing.Point(6, 17);\r
+            this.check_mp3.Name = "check_mp3";\r
+            this.check_mp3.Size = new System.Drawing.Size(43, 15);\r
+            this.check_mp3.TabIndex = 0;\r
+            this.check_mp3.Text = "MP3";\r
+            this.ToolTips.SetToolTip(this.check_mp3, "Allow MP3 Passthru");\r
+            this.check_mp3.UseVisualStyleBackColor = true;\r
+            this.check_mp3.CheckedChanged += new System.EventHandler(this.autoPassthru_CheckedChanged);\r
+            // \r
             // AudioPanel\r
             // \r
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;\r
             this.BackColor = System.Drawing.Color.Transparent;\r
+            this.Controls.Add(this.groupBox1);\r
             this.Controls.Add(this.drp_audioTrack);\r
             this.Controls.Add(this.btn_AdvancedAudio);\r
             this.Controls.Add(this.drp_audioSample);\r
@@ -430,6 +549,8 @@ namespace Handbrake.Controls
             ((System.ComponentModel.ISupportInitialize)(this.audioList)).EndInit();\r
             this.AddTrackMenu.ResumeLayout(false);\r
             this.RemoveTrackMenu.ResumeLayout(false);\r
+            this.groupBox1.ResumeLayout(false);\r
+            this.groupBox1.PerformLayout();\r
             this.ResumeLayout(false);\r
             this.PerformLayout();\r
 \r
@@ -467,5 +588,13 @@ namespace Handbrake.Controls
         private System.Windows.Forms.DataGridViewTextBoxColumn Bitrate;\r
         private System.Windows.Forms.DataGridViewTextBoxColumn DRC;\r
         private System.Windows.Forms.DataGridViewTextBoxColumn Gain;\r
+        private System.Windows.Forms.GroupBox groupBox1;\r
+        private System.Windows.Forms.CheckBox check_dtshd;\r
+        private System.Windows.Forms.CheckBox check_dts;\r
+        private System.Windows.Forms.CheckBox check_ac3;\r
+        private System.Windows.Forms.CheckBox check_aac;\r
+        private System.Windows.Forms.CheckBox check_mp3;\r
+        private System.Windows.Forms.Label label1;\r
+        internal System.Windows.Forms.ComboBox drp_passthruFallback;\r
     }\r
 }\r
index 61b908299e846f47cf9196ab64b224ac91e61d7a..69d4fb065a4749d5ab82b149e0b97ae5fd44437e 100644 (file)
@@ -78,6 +78,10 @@ namespace Handbrake.Controls
             drp_audioEncoder.SelectedItem = "AAC (faac)";\r
 \r
             drp_audioTrack.DataSource = this.ScannedTracks;\r
+\r
+            // Setup Auto-Passthru Settings\r
+            this.PassthruSettings = new AllowedPassthru();\r
+            this.SetPassthruSettings(this.PassthruSettings);\r
         }\r
 \r
         /// <summary>\r
@@ -105,6 +109,11 @@ namespace Handbrake.Controls
             }\r
         }\r
 \r
+        /// <summary>\r
+        /// Gets or sets PassthruSettings.\r
+        /// </summary>\r
+        public AllowedPassthru PassthruSettings { get; set; }\r
+\r
         #endregion\r
 \r
         #region Public Methods\r
@@ -118,6 +127,7 @@ namespace Handbrake.Controls
         public void SetContainer(string path)\r
         {\r
             string oldval = drp_audioEncoder.Text;\r
+            string fallbackOldVal = drp_passthruFallback.Text;\r
 \r
             drp_audioEncoder.Items.Clear();\r
             drp_audioEncoder.Items.Add(EnumHelper<AudioEncoder>.GetDisplay(AudioEncoder.Faac));\r
@@ -130,16 +140,31 @@ namespace Handbrake.Controls
             drp_audioEncoder.Items.Add(EnumHelper<AudioEncoder>.GetDisplay(AudioEncoder.DtsPassthrough));\r
             drp_audioEncoder.Items.Add(EnumHelper<AudioEncoder>.GetDisplay(AudioEncoder.DtsHDPassthrough));\r
 \r
+            drp_passthruFallback.Items.Clear();\r
+            drp_passthruFallback.Items.Add(EnumHelper<AudioEncoder>.GetDisplay(AudioEncoder.Faac));\r
+            drp_passthruFallback.Items.Add(EnumHelper<AudioEncoder>.GetDisplay(AudioEncoder.ffaac));\r
+            drp_passthruFallback.Items.Add(EnumHelper<AudioEncoder>.GetDisplay(AudioEncoder.Lame));\r
+            drp_passthruFallback.Items.Add(EnumHelper<AudioEncoder>.GetDisplay(AudioEncoder.Ac3));\r
+\r
             if (path.Contains("MKV"))\r
             {\r
                 drp_audioEncoder.Items.Add(EnumHelper<AudioEncoder>.GetDisplay(AudioEncoder.Vorbis));\r
                 drp_audioEncoder.Items.Add(EnumHelper<AudioEncoder>.GetDisplay(AudioEncoder.ffflac));\r
+\r
+                drp_passthruFallback.Items.Add(EnumHelper<AudioEncoder>.GetDisplay(AudioEncoder.Vorbis));\r
+                drp_passthruFallback.Items.Add(EnumHelper<AudioEncoder>.GetDisplay(AudioEncoder.ffflac));\r
             }\r
 \r
+\r
             if (!drp_audioEncoder.Items.Contains(oldval))\r
                 drp_audioEncoder.SelectedIndex = 0;\r
             else\r
                 drp_audioEncoder.SelectedItem = oldval;\r
+\r
+            if (!drp_passthruFallback.Items.Contains(fallbackOldVal))\r
+                drp_passthruFallback.SelectedIndex = 3;\r
+            else\r
+                drp_passthruFallback.SelectedItem = fallbackOldVal;\r
         }\r
 \r
         /// <summary>\r
@@ -154,11 +179,17 @@ namespace Handbrake.Controls
         /// <summary>\r
         /// Load an arraylist of AudioTrack items into the list.\r
         /// </summary>\r
-        /// <param name="tracks">List of audio tracks</param>\r
-        public void LoadTracks(ObservableCollection<AudioTrack> tracks)\r
+        /// <param name="preset">\r
+        /// The preset.\r
+        /// </param>\r
+        public void LoadTracks(Preset preset)\r
         {\r
             ClearAudioList();\r
 \r
+            ObservableCollection<AudioTrack> tracks = preset.Task.AudioTracks;\r
+            this.PassthruSettings = preset.AudioPassthruSettings ?? new AllowedPassthru(false);\r
+            this.SetPassthruSettings(this.PassthruSettings);\r
+\r
             if (tracks == null || (drp_audioTrack.SelectedItem != null && drp_audioTrack.SelectedItem.ToString() == AudioHelper.NoneFound.Description))\r
                 return;\r
 \r
@@ -195,6 +226,10 @@ namespace Handbrake.Controls
             this.AudioTracks.Clear();\r
             this.ScannedTracks.Clear();\r
 \r
+            // Setup the passthru options\r
+            this.PassthruSettings = preset.AudioPassthruSettings ?? new AllowedPassthru(false);\r
+            this.SetPassthruSettings(this.PassthruSettings);\r
+\r
             if (selectedTitle.AudioTracks.Count == 0)\r
             {    \r
                 this.ScannedTracks.Add(AudioHelper.NoneFound);\r
@@ -1043,31 +1078,66 @@ namespace Handbrake.Controls
         /// </returns>\r
         private AudioEncoder GetCompatiblePassthru(AudioTrack track)\r
         {\r
-            if (track.ScannedTrack.Format.Contains("AC3"))\r
+            if (track.ScannedTrack.Format.Contains("AC3") &&  this.check_ac3.Checked)\r
             {\r
                 return AudioEncoder.Ac3Passthrough;\r
             }\r
 \r
-            if (track.ScannedTrack.Format.Contains("DTS"))\r
+            if (track.ScannedTrack.Format.Contains("DTS") && this.check_dts.Checked)\r
+            {\r
+                return AudioEncoder.DtsPassthrough;\r
+            }\r
+\r
+            if (track.ScannedTrack.Format.Contains("DTS-HD") && this.check_dtshd.Checked)\r
             {\r
                 return AudioEncoder.DtsPassthrough;\r
             }\r
 \r
-            if (track.ScannedTrack.Format.Contains("aac"))\r
+            if (track.ScannedTrack.Format.Contains("aac") && this.check_aac.Checked)\r
             {\r
                 return AudioEncoder.AacPassthru;\r
             }\r
 \r
-            if (track.ScannedTrack.Format.Contains("mp3"))\r
+            if (track.ScannedTrack.Format.Contains("mp3") && this.check_mp3.Checked)\r
             {\r
                 return AudioEncoder.Mp3Passthru;\r
             }\r
 \r
-            return AudioEncoder.Faac;\r
+            return EnumHelper<AudioEncoder>.GetValue(drp_passthruFallback.SelectedItem.ToString()); \r
+        }\r
+\r
+        /// <summary>\r
+        /// Setup the Passthru Settings Panel\r
+        /// </summary>\r
+        /// <param name="settings">\r
+        /// The settings.\r
+        /// </param>\r
+        private void SetPassthruSettings(AllowedPassthru settings)\r
+        {\r
+            if (settings == null)\r
+            {\r
+                settings = this.PassthruSettings;\r
+            }\r
+\r
+            this.check_aac.Checked = settings.AudioAllowAACPass;\r
+            this.check_mp3.Checked = settings.AudioAllowMP3Pass;\r
+            this.check_ac3.Checked = settings.AudioAllowAC3Pass;\r
+            this.check_dts.Checked = settings.AudioAllowDTSPass;\r
+            this.check_dtshd.Checked = settings.AudioAllowDTSHDPass;\r
+            this.drp_passthruFallback.SelectedItem = EnumHelper<AudioEncoder>.GetDisplay(settings.AudioEncoderFallback); \r
         }\r
 \r
         #endregion\r
 \r
+        /// <summary>\r
+        /// Open the Advanced Audio Settings UI\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void btn_AdvancedAudio_Click(object sender, EventArgs e)\r
         {\r
             if (audioList.SelectedRows.Count == 0)\r
@@ -1084,5 +1154,57 @@ namespace Handbrake.Controls
 \r
             advancedAudio.Show();\r
         }\r
+\r
+        /// <summary>\r
+        /// Handle changes in the Checked Passthru Options\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The EventArgs.\r
+        /// </param>\r
+        private void autoPassthru_CheckedChanged(object sender, EventArgs e)\r
+        {\r
+            if (sender == this.check_mp3)\r
+            {\r
+                this.PassthruSettings.AudioAllowMP3Pass = this.check_mp3.Checked;\r
+            }\r
+\r
+            if (sender == this.check_aac)\r
+            {\r
+                this.PassthruSettings.AudioAllowAACPass = this.check_aac.Checked;\r
+            }\r
+\r
+            if (sender == this.check_ac3)\r
+            {\r
+                this.PassthruSettings.AudioAllowAC3Pass = this.check_ac3.Checked;\r
+            }\r
+\r
+            if (sender == this.check_dts)\r
+            {\r
+                this.PassthruSettings.AudioAllowDTSPass = this.check_dts.Checked;\r
+            }\r
+\r
+            if (sender == this.check_dtshd)\r
+            {\r
+                this.PassthruSettings.AudioAllowDTSHDPass = this.check_dtshd.Checked;\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Set the fallback encoder\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
+        private void drp_passthruFallback_SelectedIndexChanged(object sender, EventArgs e)\r
+        {\r
+            this.PassthruSettings.AudioEncoderFallback =\r
+                EnumHelper<AudioEncoder>.GetValue(drp_passthruFallback.SelectedItem.ToString());\r
+        }\r
     }\r
 }
\ No newline at end of file
index 25b4515c94607d7e572122e4a7c5bbb43c6b8433..2bb8ba78041b1825985b6d23a2ee4fcb2b3c5f0d 100644 (file)
@@ -161,4 +161,15 @@ and alter its settings after adding them.</value>
   <metadata name="RemoveTrackMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
     <value>561, 16</value>\r
   </metadata>\r
+  <data name="groupBox1.ToolTip" xml:space="preserve">\r
+    <value>Controls the behaviour of the Audio Codec dropdown when passthru options are selected.\r
+\r
+When an incorrect passthru option is selected, it will try to fall back to the correct one if the\r
+format checkbox in the "Auto Passthru" section is checked.\r
+\r
+If there is no suitable passthru option, it will use the "Fallkback" encoder.\r
+\r
+These settings are global to all Audio Tracks.\r
+These settings are stored in the presets.</value>\r
+  </data>\r
 </root>
\ No newline at end of file
index de405821006e6fe09b90b26ad578dc3ac23ad1ab..5da368ac1360e0805aabbac8d52f49054f10f769 100644 (file)
@@ -37,10 +37,10 @@ namespace Handbrake.Functions
         /// The encode task.\r
         /// </param>\r
         public static void LoadPreset(frmMain mainWindow, EncodeTask encodeTask)\r
-         {\r
-             Preset preset = new Preset { Name = "Unknown", Task = encodeTask };\r
-             LoadPreset(mainWindow, preset);\r
-         }\r
+        {\r
+            Preset preset = new Preset { Name = "Unknown", Task = encodeTask };\r
+            LoadPreset(mainWindow, preset);\r
+        }\r
 \r
         /// <summary>\r
         /// This function takes in a Query which has been parsed by QueryParser and\r
@@ -52,10 +52,14 @@ namespace Handbrake.Functions
         /// <param name="preset">\r
         /// The preset.\r
         /// </param>\r
-         public static void LoadPreset(frmMain mainWindow, Preset preset)\r
+        public static void LoadPreset(frmMain mainWindow, Preset preset)\r
         {\r
             // Send the query from the file to the Query Parser class\r
             EncodeTask presetQuery = preset.Task ?? QueryParserUtility.Parse(preset.Query);\r
+            if (preset.Task == null)\r
+            {\r
+                preset.Task = presetQuery;\r
+            }\r
 \r
             #region Source\r
 \r
@@ -165,9 +169,9 @@ namespace Handbrake.Functions
                 mainWindow.PictureSettings.text_height.Value = presetQuery.MaxHeight.Value;\r
             }\r
 \r
-           mainWindow.PictureSettings.PresetMaximumResolution = new Size(\r
-                    presetQuery.MaxWidth.HasValue ? presetQuery.MaxWidth.Value : 0,\r
-                    presetQuery.MaxHeight.HasValue ? presetQuery.MaxHeight.Value : 0);\r
+            mainWindow.PictureSettings.PresetMaximumResolution = new Size(\r
+                     presetQuery.MaxWidth.HasValue ? presetQuery.MaxWidth.Value : 0,\r
+                     presetQuery.MaxHeight.HasValue ? presetQuery.MaxHeight.Value : 0);\r
 \r
             // Case where both height and max height are 0 - For built-in presets\r
             if (presetQuery.MaxHeight == 0 && presetQuery.Height == 0)\r
@@ -242,7 +246,7 @@ namespace Handbrake.Functions
                 mainWindow.text_bitrate.Text = presetQuery.VideoBitrate.ToString();\r
                 mainWindow.check_2PassEncode.CheckState = presetQuery.TwoPass ? CheckState.Checked : CheckState.Unchecked;\r
                 mainWindow.check_turbo.CheckState = presetQuery.TurboFirstPass ? CheckState.Checked : CheckState.Unchecked;\r
-            }              \r
+            }\r
 \r
             if (presetQuery.Framerate != null)\r
             {\r
@@ -289,7 +293,7 @@ namespace Handbrake.Functions
 \r
             #region Audio\r
 \r
-            mainWindow.AudioSettings.LoadTracks(presetQuery.AudioTracks);\r
+            mainWindow.AudioSettings.LoadTracks(preset);\r
 \r
             #endregion\r
 \r
index a4b34ba80d94707fc00093bcee0b2c93d099561a..2cb6ab738e3acee9197834a755cb09a73692bf7c 100644 (file)
     <Compile Include="Functions\Win32.cs" />\r
     <Compile Include="Functions\Win7.cs" />\r
     <Compile Include="Model\DriveInformation.cs" />\r
+    <Compile Include="Model\Encoding\AllowedPassthru.cs" />\r
     <Compile Include="Model\Encoding\AudioTrack.cs" />\r
     <Compile Include="Model\Encoding\ChapterMarker.cs" />\r
     <Compile Include="Model\Encoding\FramerateMode.cs" />\r
diff --git a/win/CS/HandBrake.ApplicationServices/Model/Encoding/AllowedPassthru.cs b/win/CS/HandBrake.ApplicationServices/Model/Encoding/AllowedPassthru.cs
new file mode 100644 (file)
index 0000000..748cfbd
--- /dev/null
@@ -0,0 +1,74 @@
+/*  AllowedPassthru.cs $\r
+    This file is part of the HandBrake source code.\r
+    Homepage: <http://handbrake.fr>.\r
+    It may be used under the terms of the GNU General Public License. */\r
+\r
+namespace HandBrake.ApplicationServices.Model.Encoding\r
+{\r
+    using Interop.Model.Encoding;\r
+\r
+    /// <summary>\r
+    /// Allowed Passthru Options\r
+    /// </summary>\r
+    public class AllowedPassthru\r
+    {\r
+        /// <summary>\r
+        /// Initializes a new instance of the <see cref="AllowedPassthru"/> class. \r
+        /// </summary>\r
+        public AllowedPassthru()\r
+        {\r
+            this.AudioAllowAACPass = true;\r
+            this.AudioAllowAC3Pass = true;\r
+            this.AudioAllowDTSHDPass = true;\r
+            this.AudioAllowDTSPass = true;\r
+            this.AudioAllowMP3Pass = true;\r
+            this.AudioEncoderFallback = AudioEncoder.Ac3;\r
+        }\r
+\r
+        /// <summary>\r
+        /// Initializes a new instance of the <see cref="AllowedPassthru"/> class. \r
+        /// </summary>\r
+        /// <param name="initialValue">\r
+        /// The initial Value.\r
+        /// </param>\r
+        public AllowedPassthru(bool initialValue)\r
+        {\r
+            this.AudioAllowAACPass = initialValue;\r
+            this.AudioAllowAC3Pass = initialValue;\r
+            this.AudioAllowDTSHDPass = initialValue;\r
+            this.AudioAllowDTSPass = initialValue;\r
+            this.AudioAllowMP3Pass = initialValue;\r
+            this.AudioEncoderFallback = AudioEncoder.Ac3;\r
+        }\r
+\r
+        /// <summary>\r
+        /// Gets or sets a value indicating whether AudioAllowAACPass.\r
+        /// </summary>\r
+        public bool AudioAllowAACPass { get; set; }\r
+\r
+        /// <summary>\r
+        /// Gets or sets a value indicating whether AudioAllowAC3Pass.\r
+        /// </summary>\r
+        public bool AudioAllowAC3Pass { get; set; }\r
+\r
+        /// <summary>\r
+        /// Gets or sets a value indicating whether AudioAllowDTSHDPass.\r
+        /// </summary>\r
+        public bool AudioAllowDTSHDPass { get; set; }\r
+\r
+        /// <summary>\r
+        /// Gets or sets a value indicating whether AudioAllowDTSPass.\r
+        /// </summary>\r
+        public bool AudioAllowDTSPass { get; set; }\r
+\r
+        /// <summary>\r
+        /// Gets or sets a value indicating whether AudioAllowMP3Pass.\r
+        /// </summary>\r
+        public bool AudioAllowMP3Pass { get; set; }\r
+\r
+        /// <summary>\r
+        /// Gets or sets AudioEncoderFallback.\r
+        /// </summary>\r
+        public AudioEncoder AudioEncoderFallback { get; set; }\r
+    }\r
+}\r
index a3bd673f3e8016bb558d9b204e57dd4dec9e63f4..2ec668b56d3a6fc24f48e41a0e787d0e4c95b257 100644 (file)
@@ -5,6 +5,8 @@
 \r
 namespace HandBrake.ApplicationServices.Model\r
 {\r
+    using Encoding;\r
+\r
     /// <summary>\r
     /// A Preset for encoding with.\r
     /// </summary>\r
@@ -60,6 +62,11 @@ namespace HandBrake.ApplicationServices.Model
         /// </summary>\r
         public EncodeTask Task { get; set; }\r
 \r
+        /// <summary>\r
+        /// Gets or sets AudioPassthruSettings.\r
+        /// </summary>\r
+        public AllowedPassthru AudioPassthruSettings { get; set; }\r
+\r
         /// <summary>\r
         ///  Override the ToString Method\r
         /// </summary>\r
index 30487f15c746dc1d6f199a38cb681da5e9c664e1..5672838e8ecdddefd50d29b12ea1fb76006574b8 100644 (file)
@@ -3,6 +3,9 @@
     Homepage: <http://handbrake.fr>.\r
     It may be used under the terms of the GNU General Public License. */\r
 \r
+using HandBrake.ApplicationServices.Model.Encoding;\r
+using HandBrake.ApplicationServices.Utilities;\r
+\r
 namespace HandBrake.ApplicationServices.Services\r
 {\r
     using System;\r
@@ -290,11 +293,7 @@ namespace HandBrake.ApplicationServices.Services
                             Regex r = new Regex("(:  )"); // Split on hyphens. \r
                             string[] presetName = r.Split(line);\r
 \r
-                            bool pic = false;\r
-                            if (presetName[2].Contains("crop"))\r
-                            {\r
-                                pic = true;\r
-                            }\r
+                            bool pic = presetName[2].Contains("crop");\r
 \r
                             Preset newPreset = new Preset\r
                                 {\r
@@ -304,9 +303,12 @@ namespace HandBrake.ApplicationServices.Services
                                     Version = this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.HandBrakeVersion),\r
                                     CropSettings = pic,\r
                                     Description = string.Empty, // Maybe one day we will populate this.\r
-                                    IsBuildIn = true\r
+                                    IsBuildIn = true,\r
+                                    Task = QueryParserUtility.Parse(presetName[2])\r
                                 };\r
 \r
+                            newPreset.AudioPassthruSettings = new AllowedPassthru(false); // We don't want to override the built-in preset\r
+                            \r
                             if (newPreset.Name == "Normal")\r
                             {\r
                                 newPreset.IsDefault = true;\r
index 67bfcaf5f207a2556dbcd2a6d0235a4f06583736..da3b1baf4e91eab50f3a6fce3a1f4f425632477d 100644 (file)
@@ -87,7 +87,8 @@ namespace Handbrake
                     Name = this.txt_preset_name.Text,\r
                     Query = query,\r
                     CropSettings = pictureSettingsMode != QueryPictureSettingsMode.None,\r
-                    Description = string.Empty\r
+                    Description = string.Empty,\r
+                    AudioPassthruSettings = mainWindow.AudioSettings.PassthruSettings          \r
                 };\r
 \r
             if (presetCode.Add(preset))\r
index a8780aa85ff5379955c989d489f5ccfa1b804b7b..a3e86799750e6e424e59b2f93a63911665a3e94c 100644 (file)
@@ -3,6 +3,8 @@
     Homepage: <http://handbrake.fr/>.\r
     It may be used under the terms of the GNU General Public License. */\r
 \r
+using HandBrake.ApplicationServices.Model.Encoding;\r
+\r
 namespace Handbrake\r
 {\r
     using System;\r
@@ -861,7 +863,9 @@ namespace Handbrake
                             {\r
                                 Name = parsed.PresetName,\r
                                 Query = QueryGenerator.GenerateFullQuery(this).Query,\r
-                                CropSettings = parsed.UsesPictureSettings\r
+                                CropSettings = parsed.UsesPictureSettings,\r
+                                Task = parsed,\r
+                                AudioPassthruSettings = new AllowedPassthru(false), // TODO at a future point, support this.\r
                             };\r
 \r
                         presetHandler.Update(preset);\r
@@ -870,11 +874,13 @@ namespace Handbrake
                 else\r
                 {\r
                    \r
-                    Preset preset = new Preset\r
+                    Preset preset = new Preset \r
                     {\r
                         Name = parsed.PresetName,\r
                         Query = QueryGenerator.GenerateFullQuery(this).Query,\r
                         CropSettings = parsed.UsesPictureSettings,\r
+                        Task = parsed,\r
+                        AudioPassthruSettings = new AllowedPassthru(false), // TODO at a future point, support this.\r
                     };\r
                     \r
                     if (presetHandler.Add(preset))\r
@@ -2220,7 +2226,8 @@ namespace Handbrake
 \r
                         // Now load the preset\r
                         PresetLoader.LoadPreset(this, preset);\r
-                        this.AudioSettings.LoadTracks(queueEdit.Task.AudioTracks);\r
+                        preset.Task = queueEdit.Task;\r
+                        this.AudioSettings.LoadTracks(preset);\r
 \r
                         // Set the destination path);\r
                         this.text_destination.Text = queueEdit.Destination;\r