diff options
Diffstat (limited to 'win/C#/Functions')
-rw-r--r-- | win/C#/Functions/Encode.cs | 27 | ||||
-rw-r--r-- | win/C#/Functions/Main.cs | 27 | ||||
-rw-r--r-- | win/C#/Functions/PresetLoader.cs | 67 | ||||
-rw-r--r-- | win/C#/Functions/QueryGenerator.cs | 6 | ||||
-rw-r--r-- | win/C#/Functions/QueryParser.cs | 312 |
5 files changed, 130 insertions, 309 deletions
diff --git a/win/C#/Functions/Encode.cs b/win/C#/Functions/Encode.cs index 1cd3de4ae..6c30828c2 100644 --- a/win/C#/Functions/Encode.cs +++ b/win/C#/Functions/Encode.cs @@ -16,20 +16,18 @@ namespace Handbrake.Functions {
// DLL Imports
[DllImport("user32.dll")]
- public static extern void LockWorkStation();
+ private static extern void LockWorkStation();
[DllImport("user32.dll")]
- public static extern int ExitWindowsEx(int uFlags, int dwReason);
+ private static extern int ExitWindowsEx(int uFlags, int dwReason);
// Declarations
Process hbProc = new Process();
- Boolean encoding;
/// <summary>
/// Execute a HandBrakeCLI process.
/// </summary>
- /// <param name="s"></param>
/// <param name="query">The CLI Query</param>
- public Process runCli(object s, string query)
+ public Process runCli(string query)
{
try
{
@@ -42,7 +40,8 @@ namespace Handbrake.Functions if (Properties.Settings.Default.cli_minimized == "Checked")
cliStart.WindowStyle = ProcessWindowStyle.Minimized;
hbProc = Process.Start(cliStart);
- encoding = true;
+ isEncoding = true;
+ currentQuery = query;
// Set the process Priority
if (hbProc != null)
@@ -80,7 +79,8 @@ namespace Handbrake.Functions /// </summary>
public void afterEncodeAction()
{
- encoding = false;
+ isEncoding = false;
+ currentQuery = String.Empty;
// Do something whent he encode ends.
switch (Properties.Settings.Default.CompletionOption)
{
@@ -132,9 +132,8 @@ namespace Handbrake.Functions /// Save a copy of the log to the users desired location or a default location
/// if this feature is enabled in options.
/// </summary>
- /// <param name="query"></param>
/// <param name="destination"></param>
- public void copyLog(string query, string destination)
+ public void copyLog(string destination)
{
// The user may wish to do something with the log.
if (Properties.Settings.Default.saveLog == "Checked")
@@ -169,10 +168,12 @@ namespace Handbrake.Functions /// <summary>
/// Returns whether HandBrake is currently encoding or not.
/// </summary>
- public Boolean isEncoding
- {
- get { return encoding; }
- }
+ public Boolean isEncoding { get; set; }
+
+ /// <summary>
+ /// Returns the currently encoding query string
+ /// </summary>
+ public String currentQuery { get; set; }
}
}
diff --git a/win/C#/Functions/Main.cs b/win/C#/Functions/Main.cs index 93b29399c..acca7e797 100644 --- a/win/C#/Functions/Main.cs +++ b/win/C#/Functions/Main.cs @@ -1,11 +1,10 @@ -/* Common.cs $
+/* Main.cs $
This file is part of the HandBrake source code.
Homepage: <http://handbrake.fr>.
It may be used under the terms of the GNU General Public License. */
using System;
-using System.Collections;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
@@ -23,7 +22,7 @@ namespace Handbrake.Functions /// <summary>
/// Calculate the duration of the selected title and chapters
/// </summary>
- public TimeSpan calculateDuration(string chapter_start, string chapter_end, Parsing.Title selectedTitle)
+ public static TimeSpan calculateDuration(string chapter_start, string chapter_end, Parsing.Title selectedTitle)
{
TimeSpan Duration = TimeSpan.FromSeconds(0.0);
@@ -62,7 +61,7 @@ namespace Handbrake.Functions /// <param name="right"></param>
/// <param name="selectedTitle"></param>
/// <returns></returns>
- public int cacluateNonAnamorphicHeight(int width, decimal top, decimal bottom, decimal left, decimal right, Parsing.Title selectedTitle)
+ public static int cacluateNonAnamorphicHeight(int width, decimal top, decimal bottom, decimal left, decimal right, Parsing.Title selectedTitle)
{
float aspect = selectedTitle.AspectRatio;
int aw = 0;
@@ -111,7 +110,7 @@ namespace Handbrake.Functions /// <summary>
/// Select the longest title in the DVD title dropdown menu on frmMain
/// </summary>
- public Parsing.Title selectLongestTitle(ComboBox drp_dvdtitle)
+ public static Parsing.Title selectLongestTitle(ComboBox drp_dvdtitle)
{
int current_largest = 0;
Parsing.Title title2Select;
@@ -161,7 +160,7 @@ namespace Handbrake.Functions /// <summary>
/// Set's up the DataGridView on the Chapters tab (frmMain)
/// </summary>
- public DataGridView chapterNaming(DataGridView data_chpt, string chapter_end)
+ public static DataGridView chapterNaming(DataGridView data_chpt, string chapter_end)
{
int i = 0, finish = 0;
@@ -185,7 +184,7 @@ namespace Handbrake.Functions /// Function which generates the filename and path automatically based on
/// the Source Name, DVD title and DVD Chapters
/// </summary>
- public string autoName(ComboBox drp_dvdtitle, string chapter_start, string chatper_end, string source, string dest, int format)
+ public static string autoName(ComboBox drp_dvdtitle, string chapter_start, string chatper_end, string source, string dest, int format)
{
string AutoNamePath = string.Empty;
if (drp_dvdtitle.Text != "Automatic")
@@ -227,7 +226,7 @@ namespace Handbrake.Functions if (!dest.Contains(Path.DirectorySeparatorChar.ToString()))
{
// If there is an auto name path, use it...
- if (Properties.Settings.Default.autoNamePath.Trim() != "" && Properties.Settings.Default.autoNamePath.Trim() != "Click 'Browse' to set the default location")
+ if (Properties.Settings.Default.autoNamePath.Trim() != "" && Properties.Settings.Default.autoNamePath.Trim() != "Click 'Browse' to set the default location")
AutoNamePath = Path.Combine(Properties.Settings.Default.autoNamePath, destination_filename);
else // ...otherwise, output to the source directory
AutoNamePath = null;
@@ -248,7 +247,7 @@ namespace Handbrake.Functions /// </summary>
/// <param name="debug">Turns on debug mode. Don't use on program startup</param>
/// <returns>Boolean True = Update available</returns>
- public Boolean updateCheck(Boolean debug)
+ public static Boolean updateCheck(Boolean debug)
{
try
{
@@ -262,7 +261,7 @@ namespace Handbrake.Functions if (latest == skip)
return false;
-
+
Boolean update = (latest > current);
return update;
}
@@ -278,7 +277,7 @@ namespace Handbrake.Functions /// Get's HandBrakes version data from the CLI.
/// </summary>
/// <returns>Arraylist of Version Data. 0 = hb_version 1 = hb_build</returns>
- public void setCliVersionData()
+ public static void setCliVersionData()
{
String line;
@@ -324,6 +323,10 @@ namespace Handbrake.Functions MessageBox.Show("Unable to retrieve version information from the CLI. \nError:\n" + e);
}
}
+
+ /// <summary>
+ /// Search through the running processes on the system and kill HandBrakeCLI
+ /// </summary>
private static void killCLI()
{
string AppName = "HandBrakeCLI";
@@ -346,7 +349,7 @@ namespace Handbrake.Functions /// If it does, it means the last queue did not complete before HandBrake closed.
/// So, return a boolean if true.
/// </summary>
- public Boolean check_queue_recovery()
+ public static Boolean check_queue_recovery()
{
try
{
diff --git a/win/C#/Functions/PresetLoader.cs b/win/C#/Functions/PresetLoader.cs index 53cc363aa..8fabbe61e 100644 --- a/win/C#/Functions/PresetLoader.cs +++ b/win/C#/Functions/PresetLoader.cs @@ -1,6 +1,5 @@ using System;
using System.Windows.Forms;
-using System.Drawing;
namespace Handbrake.Functions
{
@@ -20,7 +19,7 @@ namespace Handbrake.Functions // Setup the GUI
// ---------------------------
- #region source
+ #region Source
// Reset some vaules to stock first to prevent errors.
mainWindow.check_iPodAtom.CheckState = CheckState.Unchecked;
@@ -36,9 +35,7 @@ namespace Handbrake.Functions #endregion
- #region destination
-
- mainWindow.drp_videoEncoder.Text = presetQuery.VideoEncoder;
+ #region Destination and Output Settings
if (presetQuery.Format != null)
{
@@ -148,6 +145,8 @@ namespace Handbrake.Functions #endregion
#region Video
+ mainWindow.drp_videoEncoder.Text = presetQuery.VideoEncoder;
+
if (presetQuery.AverageVideoBitrate != null)
{
mainWindow.radio_avgBitrate.Checked = true;
@@ -186,7 +185,7 @@ namespace Handbrake.Functions // with a different granularity, so, round and try again.
if (value == 0)
{
- double val = Math.Round(calculated, 0);
+ double val = Math.Round(calculated, 0);
int.TryParse(val.ToString(), out value);
}
@@ -226,51 +225,17 @@ namespace Handbrake.Functions // Clear the audio listing
mainWindow.lv_audioList.Items.Clear();
- // Create a new row for the Audio list based on the currently selected items in the dropdown.
- ListViewItem newTrack;
- if (presetQuery.AudioTrack1 != "None")
- {
- newTrack = new ListViewItem("Automatic");
- newTrack.SubItems.Add(presetQuery.AudioEncoder1);
- newTrack.SubItems.Add(presetQuery.AudioTrackMix1);
- newTrack.SubItems.Add(presetQuery.AudioSamplerate1);
- newTrack.SubItems.Add(presetQuery.AudioBitrate1);
- newTrack.SubItems.Add(presetQuery.DRC1.ToString());
- mainWindow.lv_audioList.Items.Add(newTrack);
- }
-
- if (presetQuery.AudioTrack2 != "None")
- {
- newTrack = new ListViewItem("Automatic");
- newTrack.SubItems.Add(presetQuery.AudioEncoder2);
- newTrack.SubItems.Add(presetQuery.AudioTrackMix2);
- newTrack.SubItems.Add(presetQuery.AudioSamplerate2);
- newTrack.SubItems.Add(presetQuery.AudioBitrate2);
- newTrack.SubItems.Add(presetQuery.DRC2.ToString());
- mainWindow.lv_audioList.Items.Add(newTrack);
- }
-
- if (presetQuery.AudioTrack3 != "None")
- {
- newTrack = new ListViewItem("Automatic");
- newTrack.SubItems.Add(presetQuery.AudioEncoder3);
- newTrack.SubItems.Add(presetQuery.AudioTrackMix3);
- newTrack.SubItems.Add(presetQuery.AudioSamplerate3);
- newTrack.SubItems.Add(presetQuery.AudioBitrate3);
- newTrack.SubItems.Add(presetQuery.DRC3.ToString());
- mainWindow.lv_audioList.Items.Add(newTrack);
- }
-
- if (presetQuery.AudioTrack4 != "None")
- {
- newTrack = new ListViewItem("Automatic");
- newTrack.SubItems.Add(presetQuery.AudioEncoder4);
- newTrack.SubItems.Add(presetQuery.AudioTrackMix4);
- newTrack.SubItems.Add(presetQuery.AudioSamplerate4);
- newTrack.SubItems.Add(presetQuery.AudioBitrate4);
- newTrack.SubItems.Add(presetQuery.DRC4.ToString());
- mainWindow.lv_audioList.Items.Add(newTrack);
- }
+ if (presetQuery.AudioInformation != null)
+ foreach (AudioTrack track in presetQuery.AudioInformation)
+ {
+ ListViewItem newTrack = new ListViewItem("Automatic");
+ newTrack.SubItems.Add(track.Encoder);
+ newTrack.SubItems.Add(track.MixDown);
+ newTrack.SubItems.Add(track.SampleRate);
+ newTrack.SubItems.Add(track.Bitrate);
+ newTrack.SubItems.Add(track.DRC);
+ mainWindow.lv_audioList.Items.Add(newTrack);
+ }
// Subtitle Stuff
mainWindow.drp_subtitle.Text = presetQuery.Subtitles;
diff --git a/win/C#/Functions/QueryGenerator.cs b/win/C#/Functions/QueryGenerator.cs index c3f66fc21..a78ce2dfa 100644 --- a/win/C#/Functions/QueryGenerator.cs +++ b/win/C#/Functions/QueryGenerator.cs @@ -90,7 +90,7 @@ namespace Handbrake.Functions /// </summary>
/// <param name="mainWindow"></param>
/// <returns></returns>
- public string generateTabbedComponentsQuery(frmMain mainWindow)
+ public static string generateTabbedComponentsQuery(frmMain mainWindow)
{
string query = "";
@@ -274,11 +274,11 @@ namespace Handbrake.Functions // Sample Rate (-R)
if (row.SubItems[3].Text != String.Empty)
- samplerates.Add(row.SubItems[3].Text.Replace("Auto", "0"));
+ samplerates.Add(row.SubItems[3].Text.Replace("Auto", "Auto"));
// Audio Bitrate (-B)
if (row.SubItems[4].Text != String.Empty)
- bitrates.Add(row.SubItems[4].Text.Replace("Auto", "0"));
+ bitrates.Add(row.SubItems[4].Text.Replace("Auto", "auto"));
// DRC (-D)
if (row.SubItems[5].Text != String.Empty)
diff --git a/win/C#/Functions/QueryParser.cs b/win/C#/Functions/QueryParser.cs index 2e1f470d3..5557b51be 100644 --- a/win/C#/Functions/QueryParser.cs +++ b/win/C#/Functions/QueryParser.cs @@ -8,6 +8,7 @@ using System; using System.Globalization;
using System.Text.RegularExpressions;
using System.Windows.Forms;
+using System.Collections;
namespace Handbrake.Functions
{
@@ -50,7 +51,7 @@ namespace Handbrake.Functions public string DeInterlace { get; private set; }
public string DeNoise { get; private set; }
public string Decomb { get; private set; }
- #endregion
+ #endregion
#region Video Settings
public string VideoEncoder { get; private set; }
@@ -64,30 +65,7 @@ namespace Handbrake.Functions #endregion
#region Audio Settings
- public string AudioTrack1 { get; private set; }
- public string AudioTrack2 { get; private set; }
- public string AudioTrack3 { get; private set; }
- public string AudioTrack4 { get; private set; }
- public string AudioTrackMix1 { get; private set; }
- public string AudioTrackMix2 { get; private set; }
- public string AudioTrackMix3 { get; private set; }
- public string AudioTrackMix4 { get; private set; }
- public string AudioEncoder1 { get; private set; }
- public string AudioEncoder2 { get; private set; }
- public string AudioEncoder3 { get; private set; }
- public string AudioEncoder4 { get; private set; }
- public string AudioBitrate1 { get; private set; }
- public string AudioBitrate2 { get; private set; }
- public string AudioBitrate3 { get; private set; }
- public string AudioBitrate4 { get; private set; }
- public string AudioSamplerate1 { get; private set; }
- public string AudioSamplerate2 { get; private set; }
- public string AudioSamplerate3 { get; private set; }
- public string AudioSamplerate4 { get; private set; }
- public double DRC1 { get; private set; }
- public double DRC2 { get; private set; }
- public double DRC3 { get; private set; }
- public double DRC4 { get; private set; }
+ public ArrayList AudioInformation { get; private set; }
public string Subtitles { get; private set; }
public Boolean ForcedSubtitles { get; private set; }
#endregion
@@ -103,7 +81,6 @@ namespace Handbrake.Functions #endregion
- // All the Main Window GUI options
/// <summary>
/// Takes in a query which can be in any order and parses it.
/// All varibles are then set so they can be used elsewhere.
@@ -123,7 +100,7 @@ namespace Handbrake.Functions //Source
Match title = Regex.Match(input, @"-t ([0-9]*)");
Match chapters = Regex.Match(input, @"-c ([0-9-]*)");
-
+
//Output Settings
Match format = Regex.Match(input, @"-f ([a-z0-9a-z0-9a-z0-9]*)");
Match grayscale = Regex.Match(input, @" -g");
@@ -160,35 +137,12 @@ namespace Handbrake.Functions //Audio Settings Tab
Match noAudio = Regex.Match(input, @"-a none");
- Match audioTrack1 = Regex.Match(input, @"-a ([0-9]*)");
- Match audioTrack2 = Regex.Match(input, @"-a ([0-9]*),([0-9]*)");
- Match audioTrack3 = Regex.Match(input, @"-a ([0-9]*),([0-9]*),([0-9]*)");
- Match audioTrack4 = Regex.Match(input, @"-a ([0-9]*),([0-9]*),([0-9]*),([0-9]*)");
-
- Match audioTrack1Mix = Regex.Match(input, @"-6 ([0-9a-z]*)");
- Match audioTrack2Mix = Regex.Match(input, @"-6 ([0-9a-z]*),([0-9a-z]*)");
- Match audioTrack3Mix = Regex.Match(input, @"-6 ([0-9a-z]*),([0-9a-z]*),([0-9a-z]*)");
- Match audioTrack4Mix = Regex.Match(input, @"-6 ([0-9a-z]*),([0-9a-z]*),([0-9a-z]*),([0-9a-z]*)");
-
- Match audioEncoder1 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*)");
- Match audioEncoder2 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*),([a-zA-Z0-9+]*)");
- Match audioEncoder3 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*),([a-zA-Z0-9+]*),([a-zA-Z0-9+]*)");
- Match audioEncoder4 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*),([a-zA-Z0-9+]*),([a-zA-Z0-9+]*),([a-zA-Z0-9+]*)");
-
- Match audioBitrate1 = Regex.Match(input, @"-B ([0-9auto]*)");
- Match audioBitrate2 = Regex.Match(input, @"-B ([0-9auto]*),([0-9auto]*)");
- Match audioBitrate3 = Regex.Match(input, @"-B ([0-9auto]*),([0-9auto]*),([0-9auto]*)");
- Match audioBitrate4 = Regex.Match(input, @"-B ([0-9auto]*),([0-9auto]*),([0-9auto]*),([0-9auto]*)");
-
- Match audioSampleRate1 = Regex.Match(input, @"-R ([0-9Auto.]*)");
- Match audioSampleRate2 = Regex.Match(input, @"-R ([0-9Auto.]*),([0-9Auto.]*)");
- Match audioSampleRate3 = Regex.Match(input, @"-R ([0-9Auto.]*),([0-9Auto.]*),([0-9Auto.]*)");
- Match audioSampleRate4 = Regex.Match(input, @"-R ([0-9Auto.]*),([0-9Auto.]*),([0-9Auto.]*),([0-9Auto.]*)");
-
- Match drc1 = Regex.Match(input, @"-D ([0-9.]*)");
- Match drc2 = Regex.Match(input, @"-D ([0-9.]*),([0-9.]*)");
- Match drc3 = Regex.Match(input, @"-D ([0-9.]*),([0-9.]*),([0-9.]*)");
- Match drc4 = Regex.Match(input, @"-D ([0-9.]*),([0-9.]*),([0-9.]*),([0-9.]*)");
+ Match audioTracks = Regex.Match(input, @"-a ([0-9,]*)");
+ Match audioTrackMixes = Regex.Match(input, @"-6 ([0-9a-zA-Z,]*)");
+ Match audioEncoders = Regex.Match(input, @"-E ([a-zA-Z0-9+,]*)");
+ Match audioBitrates = Regex.Match(input, @"-B ([0-9a-zA-Z,]*)"); // Auto = a-z
+ Match audioSampleRates = Regex.Match(input, @"-R ([0-9a-zA-Z.,]*)"); // Auto = a-z
+ Match drcValues = Regex.Match(input, @"-D ([0-9.,]*)");
Match subtitles = Regex.Match(input, @"-s ([0-9a-zA-Z]*)");
Match subScan = Regex.Match(input, @" -U");
@@ -262,7 +216,7 @@ namespace Handbrake.Functions thisQuery.CropLeft = actCropValues[2];
thisQuery.CropRight = actCropValues[3];
}
-
+
thisQuery.Anamorphic = anamorphic.Success;
thisQuery.LooseAnamorphic = lanamorphic.Success;
@@ -336,7 +290,7 @@ namespace Handbrake.Functions thisQuery.Grayscale = grayscale.Success;
thisQuery.TwoPass = twoPass.Success;
thisQuery.TurboFirstPass = turboFirstPass.Success;
-
+
if (videoBitrate.Success)
thisQuery.AverageVideoBitrate = videoBitrate.ToString().Replace("-b ", "");
if (videoFilesize.Success)
@@ -344,194 +298,74 @@ namespace Handbrake.Functions if (videoQuality.Success)
{
- float qConvert = float.Parse(videoQuality.ToString().Replace("-q ", ""), Culture);
+ float qConvert = float.Parse(videoQuality.ToString().Replace("-q ", ""), Culture);
//qConvert = Math.Ceiling(qConvert);
thisQuery.VideoQuality = qConvert;
}
#endregion
#region Audio Tab
-
- // Tracks
- if (noAudio.Success)
- thisQuery.AudioTrack1 = "None";
- else if (audioTrack1.Success)
- thisQuery.AudioTrack1 = "Automatic";
-
- if (audioTrack2.Success)
- {
- string[] audioChan = audioTrack2.ToString().Split(',');
- thisQuery.AudioTrack2 = audioChan[1];
- }
- else
- thisQuery.AudioTrack2 = "None";
-
- if (audioTrack3.Success)
- {
- string[] audioChan = audioTrack3.ToString().Split(',');
- thisQuery.AudioTrack3 = audioChan[2];
- }
- else
- thisQuery.AudioTrack3 = "None";
-
- if (audioTrack4.Success)
- {
- string[] audioChan = audioTrack4.ToString().Split(',');
- thisQuery.AudioTrack4 = audioChan[3];
- }
- else
- thisQuery.AudioTrack4 = "None";
-
-
- // Mixdowns
- thisQuery.AudioTrackMix1 = "Automatic";
- if (audioTrack1Mix.Success)
- thisQuery.AudioTrackMix1 =
- getMixDown(audioTrack1Mix.ToString().Replace("-6 ", "").Replace(" ", ""));
-
- thisQuery.AudioTrackMix2 = "Automatic";
- if (audioTrack2Mix.Success)
- {
- string[] audio2mix = audioTrack2Mix.ToString().Split(',');
- thisQuery.AudioTrackMix2 = getMixDown(audio2mix[1].Trim());
- }
-
- thisQuery.AudioTrackMix3 = "Automatic";
- if (audioTrack3Mix.Success)
- {
- string[] audio3mix = audioTrack3Mix.ToString().Split(',');
- thisQuery.AudioTrackMix3 = getMixDown(audio3mix[2].Trim());
- }
-
- thisQuery.AudioTrackMix4 = "Automatic";
- if (audioTrack4Mix.Success)
- {
- string[] audio4mix = audioTrack4Mix.ToString().Split(',');
- thisQuery.AudioTrackMix4 = getMixDown(audio4mix[3].Trim());
- }
-
-
- // Audio Encoders
- if (audioEncoder1.Success)
- thisQuery.AudioEncoder1 = getAudioEncoder(audioEncoder1.ToString().Replace("-E ", ""));
-
- if (audioEncoder2.Success)
- {
- string[] audio2enc = audioEncoder2.ToString().Split(',');
- thisQuery.AudioEncoder2 = getAudioEncoder(audio2enc[1].Trim());
- }
-
- if (audioEncoder3.Success)
- {
- string[] audio3enc = audioEncoder3.ToString().Split(',');
- thisQuery.AudioEncoder3 = getAudioEncoder(audio3enc[2].Trim());
- }
-
- if (audioEncoder4.Success)
+ // Find out how many tracks we need to add by checking how many encoders or audio tracks are selected.
+ int encoderCount = 0;
+ if (audioEncoders.Success)
{
- string[] audio4enc = audioEncoder4.ToString().Split(',');
- thisQuery.AudioEncoder4 = getAudioEncoder(audio4enc[3].Trim());
+ string[] audioDataCounters = audioEncoders.ToString().Replace("-E ", "").Split(',');
+ encoderCount = audioDataCounters.Length;
}
-
- // Audio Bitrate
- thisQuery.AudioBitrate1 = "";
- if (audioBitrate1.Success)
+ // Get the data from the regular expression results
+ string[] trackData = null;
+ string[] trackMixes = null;
+ string[] trackEncoders = null;
+ string[] trackBitrates = null;
+ string[] trackSamplerates = null;
+ string[] trackDRCvalues = null;
+
+ if (audioTracks.Success)
+ trackData = audioTracks.ToString().Replace("-a ", "").Split(',');
+ if (audioTrackMixes.Success)
+ trackMixes = audioTrackMixes.ToString().Replace("-6 ", "").Split(',');
+ if (audioEncoders.Success)
+ trackEncoders = audioEncoders.ToString().Replace("-E ", "").Split(',');
+ if (audioBitrates.Success)
+ trackBitrates = audioBitrates.ToString().Replace("-B ", "").Split(',');
+ if (audioSampleRates.Success)
+ trackSamplerates = audioSampleRates.ToString().Replace("-R ", "").Split(',');
+ if (drcValues.Success)
+ trackDRCvalues = drcValues.ToString().Replace("-D ", "").Split(',');
+
+ // Create new Audio Track Classes and store them in the ArrayList
+ ArrayList AllAudioTrackInfo = new ArrayList();
+ for (int x = 0; x < encoderCount; x++)
{
- thisQuery.AudioBitrate1 = audioBitrate1.ToString().Replace("-B ", "").Trim();
- if (audioBitrate1.ToString().Replace("-B ", "").Trim() == "0") thisQuery.AudioBitrate1 = "Auto";
- }
+ AudioTrack track = new AudioTrack();
+ if (trackData != null)
+ if (trackData.Length >= (x + 1)) // Audio Track
+ track.Track = trackData[x].Trim();
- thisQuery.AudioBitrate2 = "";
- if (audioBitrate2.Success && audioTrack2.Success)
- {
- string[] audioBitrateSelect = audioBitrate2.ToString().Split(',');
- if (audioBitrateSelect[1].Trim() == "0") audioBitrateSelect[1] = "Auto";
- thisQuery.AudioBitrate2 = audioBitrateSelect[1].Trim();
- }
+ if (trackMixes != null)
+ if (trackMixes.Length >= (x + 1)) // Audio Mix
+ track.MixDown = getMixDown(trackMixes[x].Trim());
- thisQuery.AudioBitrate3 = "";
- if (audioBitrate3.Success && audioTrack3.Success)
- {
- string[] audioBitrateSelect = audioBitrate3.ToString().Split(',');
- if (audioBitrateSelect[2].Trim() == "0") audioBitrateSelect[2] = "Auto";
- thisQuery.AudioBitrate3 = audioBitrateSelect[2].Trim();
- }
+ if (trackEncoders != null)
+ if (trackEncoders.Length >= (x + 1)) // Audio Mix
+ track.Encoder = getAudioEncoder(trackEncoders[x].Trim());
- thisQuery.AudioBitrate4 = "";
- if (audioBitrate4.Success)
- {
- string[] audioBitrateSelect = audioBitrate4.ToString().Split(',');
- if (audioBitrateSelect[3].Trim() == "0") audioBitrateSelect[3] = "Auto";
- thisQuery.AudioBitrate4 = audioBitrateSelect[3].Trim();
- }
+ if (trackBitrates != null)
+ if (trackBitrates.Length >= (x + 1)) // Audio Encoder
+ track.Bitrate = trackBitrates[x].Trim() == "auto" ? "Auto" : trackBitrates[x].Trim();
+ if (trackSamplerates != null)
+ if (trackSamplerates.Length >= (x + 1)) // Audio SampleRate
+ track.SampleRate = trackSamplerates[x].Trim() == "0" ? "Auto" : trackSamplerates[x].Trim();
- // Audio Sample Rate
- // Make sure to change 0 to Auto
- thisQuery.AudioSamplerate1 = "Auto";
- if (audioSampleRate1.Success)
- {
- thisQuery.AudioSamplerate1 = audioSampleRate1.ToString().Replace("-R ", "").Trim();
- if (thisQuery.AudioSamplerate1 == "0") thisQuery.AudioSamplerate1 = "Auto";
- }
+ if (trackDRCvalues != null)
+ if (trackDRCvalues.Length >= (x + 1)) // Audio DRC Values
+ track.DRC = trackDRCvalues[x].Trim();
-
- if (audioSampleRate2.Success)
- {
- string[] audioSRSelect = audioSampleRate2.ToString().Split(',');
- if (audioSRSelect[1] == "0") audioSRSelect[1] = "Auto";
- thisQuery.AudioSamplerate2 = audioSRSelect[1].Trim();
- }
-
- if (audioSampleRate3.Success)
- {
- string[] audioSRSelect = audioSampleRate3.ToString().Split(',');
- if (audioSRSelect[2] == "0") audioSRSelect[2] = "Auto";
- thisQuery.AudioSamplerate3 = audioSRSelect[2].Trim();
- }
-
- if (audioSampleRate4.Success)
- {
- string[] audioSRSelect = audioSampleRate4.ToString().Split(',');
- if (audioSRSelect[3] == "0") audioSRSelect[3] = "Auto";
- thisQuery.AudioSamplerate4 = audioSRSelect[3].Trim();
- }
-
- // DRC
- float drcValue;
-
- thisQuery.DRC1 = 1;
- if (drc1.Success)
- {
- string value = drc1.ToString().Replace("-D ", "");
- float.TryParse(value, out drcValue);
- thisQuery.DRC1 = drcValue;
- }
-
- thisQuery.DRC2 = 1;
- if (drc2.Success)
- {
- string[] drcPoint = drc2.ToString().Split(',');
- float.TryParse(drcPoint[1], out drcValue);
- thisQuery.DRC2 = drcValue;
- }
-
- thisQuery.DRC3 = 1;
- if (drc3.Success)
- {
- string[] drcPoint = drc3.ToString().Split(',');
- float.TryParse(drcPoint[2], out drcValue);
- thisQuery.DRC3 = drcValue;
- }
-
- thisQuery.DRC4 = 1;
- if (drc4.Success)
- {
- string[] drcPoint = drc4.ToString().Split(',');
- float.TryParse(drcPoint[3], out drcValue);
- thisQuery.DRC4 = drcValue;
+ AllAudioTrackInfo.Add(track);
}
+ thisQuery.AudioInformation = AllAudioTrackInfo;
// Subtitle Stuff
if (subtitles.Success)
@@ -540,7 +374,6 @@ namespace Handbrake.Functions thisQuery.Subtitles = subScan.Success ? "Autoselect" : "None";
thisQuery.ForcedSubtitles = forcedSubtitles.Success;
-
#endregion
#region Chapters Tab
@@ -604,4 +437,23 @@ namespace Handbrake.Functions }
}
}
+
+ public class AudioTrack
+ {
+ public AudioTrack()
+ {
+ // Default Values
+ Track = "Automatic";
+ MixDown = "Automatic";
+ SampleRate = "Auto";
+ Bitrate = "Auto";
+ DRC = "1";
+ }
+ public string Track { get; set; }
+ public string MixDown { get; set; }
+ public string Encoder { get; set; }
+ public string Bitrate { get; set; }
+ public string SampleRate { get; set; }
+ public string DRC { get; set; }
+ }
}
\ No newline at end of file |