diff options
Diffstat (limited to 'win')
-rw-r--r-- | win/CS/Controls/Filters.cs | 115 | ||||
-rw-r--r-- | win/CS/Controls/Subtitles.cs | 12 | ||||
-rw-r--r-- | win/CS/Functions/QueryGenerator.cs | 209 | ||||
-rw-r--r-- | win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs | 10 | ||||
-rw-r--r-- | win/CS/HandBrake.ApplicationServices/Model/Preset.cs | 5 | ||||
-rw-r--r-- | win/CS/HandBrake.ApplicationServices/Model/QueueTask.cs | 22 | ||||
-rw-r--r-- | win/CS/frmMain.cs | 48 |
7 files changed, 359 insertions, 62 deletions
diff --git a/win/CS/Controls/Filters.cs b/win/CS/Controls/Filters.cs index e4c9bf226..698077f35 100644 --- a/win/CS/Controls/Filters.cs +++ b/win/CS/Controls/Filters.cs @@ -8,6 +8,7 @@ namespace Handbrake.Controls using System;
using System.Windows.Forms;
+ using HandBrake.ApplicationServices.Functions;
using HandBrake.ApplicationServices.Model.Encoding;
using HandBrake.Interop.Model.Encoding;
@@ -34,6 +35,120 @@ namespace Handbrake.Controls drop_detelecine.SelectedIndex = 0;
}
+ #region Properties
+
+ /// <summary>
+ /// Gets Decomb.
+ /// </summary>
+ public Decomb Decomb
+ {
+ get
+ {
+ return EnumHelper<Decomb>.GetValue(drop_decomb.Text);
+ }
+ }
+
+ /// <summary>
+ /// Gets CustomDecombValue.
+ /// </summary>
+ public string CustomDecombValue
+ {
+ get
+ {
+ return text_customDC.Text;
+ }
+ }
+
+ /// <summary>
+ /// Gets Deinterlace.
+ /// </summary>
+ public Deinterlace Deinterlace
+ {
+ get
+ {
+ return EnumHelper<Deinterlace>.GetValue(drop_deinterlace.Text);
+ }
+ }
+
+ /// <summary>
+ /// Gets CustomDeInterlaceValue.
+ /// </summary>
+ public string CustomDeInterlaceValue
+ {
+ get
+ {
+ return text_customDI.Text;
+ }
+ }
+
+ /// <summary>
+ /// Gets Detelecine.
+ /// </summary>
+ public Detelecine Detelecine
+ {
+ get
+ {
+ return EnumHelper<Detelecine>.GetValue(drop_detelecine.Text);
+ }
+ }
+
+ /// <summary>
+ /// Gets CustomDeTelecineValue.
+ /// </summary>
+ public string CustomDeTelecineValue
+ {
+ get
+ {
+ return text_customDT.Text;
+ }
+ }
+
+ /// <summary>
+ /// Gets Denoise.
+ /// </summary>
+ public Denoise Denoise
+ {
+ get
+ {
+ return EnumHelper<Denoise>.GetValue(drop_denoise.Text);
+ }
+ }
+
+ /// <summary>
+ /// Gets CustomDenoiseValue.
+ /// </summary>
+ public string CustomDenoiseValue
+ {
+ get
+ {
+ return text_customDN.Text;
+ }
+ }
+
+ /// <summary>
+ /// Gets Deblock.
+ /// </summary>
+ public int Deblock
+ {
+ get
+ {
+ return slider_deblock.Value;
+ }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether GrayScale.
+ /// </summary>
+ public bool GrayScale
+ {
+ get
+ {
+ return check_grayscale.Checked;
+ }
+ }
+
+ #endregion
+
/// <summary>
/// Gets the CLI query for the query generator.
/// </summary>
diff --git a/win/CS/Controls/Subtitles.cs b/win/CS/Controls/Subtitles.cs index 35b05aa26..654c99fdc 100644 --- a/win/CS/Controls/Subtitles.cs +++ b/win/CS/Controls/Subtitles.cs @@ -9,6 +9,7 @@ namespace Handbrake.Controls using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
+ using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Windows.Forms;
@@ -62,6 +63,17 @@ namespace Handbrake.Controls srt_lang.SelectedIndex = 40;
}
+ /// <summary>
+ /// Gets SubtitlesList.
+ /// </summary>
+ public List<SubtitleTrack> SubtitlesList
+ {
+ get
+ {
+ return subList;
+ }
+ }
+
#region Public Methods
/// <summary>
/// Gets the CLI Query for this panel
diff --git a/win/CS/Functions/QueryGenerator.cs b/win/CS/Functions/QueryGenerator.cs index 881188da7..ac5947ba6 100644 --- a/win/CS/Functions/QueryGenerator.cs +++ b/win/CS/Functions/QueryGenerator.cs @@ -14,12 +14,16 @@ namespace Handbrake.Functions using HandBrake.ApplicationServices;
using HandBrake.ApplicationServices.Functions;
+ using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Model.Encoding;
using HandBrake.ApplicationServices.Services;
using HandBrake.ApplicationServices.Services.Interfaces;
+ using HandBrake.Interop.Model;
+ using HandBrake.Interop.Model.Encoding;
using Handbrake.Model;
+ using OutputFormat = HandBrake.ApplicationServices.Model.Encoding.OutputFormat;
using UserSettingConstants = Handbrake.UserSettingConstants;
/// <summary>
@@ -56,17 +60,34 @@ namespace Handbrake.Functions return query;
}
- public static string GenerateFullQuery(frmMain mainWindow)
+ public static QueueTask GenerateFullQuery(frmMain mainWindow)
{
+ // Create the CLI Query
string query = string.Empty;
-
query += SourceQuery(mainWindow, mainWindow.drop_mode.SelectedIndex, 0, null);
-
query += DestinationQuery(mainWindow, QueryEncodeMode.Standard);
-
query += GenerateTabbedComponentsQuery(mainWindow, true, QueryPictureSettingsMode.UserInterfaceSettings, 0, 0);
- return query;
+ // Create the Queue Task and setup the EncodeTask model object.
+ Preset preset = mainWindow.treeView_presets.SelectedNode.Tag as Preset;
+ bool isCustom = true;
+ if (preset != null && preset.IsBuildIn)
+ {
+ isCustom = false;
+ }
+
+ EncodeTask task = CreateEncodeTaskObject(mainWindow);
+ QueueTask queueTask = new QueueTask(query)
+ {
+ Source = task.Source,
+ Destination = task.Destination,
+ Title = mainWindow.GetTitle(),
+ CustomQuery = (mainWindow.rtf_query.Text != string.Empty) || isCustom,
+ Task = task,
+ Query = query,
+ };
+
+ return queueTask;
}
#region Individual Query Sections
@@ -527,6 +548,184 @@ namespace Handbrake.Functions #endregion
+ #region EncodeTask
+
+ /// <summary>
+ /// Create the EncodeTask model from the currently selected control options.
+ /// </summary>
+ /// <param name="frmMain">
+ /// The frm main.
+ /// </param>
+ /// <returns>
+ /// An EncodeTask Object
+ /// </returns>
+ private static EncodeTask CreateEncodeTaskObject(frmMain frmMain)
+ {
+ EncodeTask task = new EncodeTask();
+
+ // Source, Destination and Output Settings
+ task.Destination = frmMain.text_destination.Text;
+ string sourcePath = frmMain.selectedTitle != null && File.Exists(frmMain.selectedTitle.SourceName)
+ ? frmMain.selectedTitle.SourceName.Trim()
+ : frmMain.sourcePath;
+ if (!string.IsNullOrEmpty(sourcePath) && sourcePath.Trim() != "Select \"Source\" to continue")
+ {
+ task.Source = sourcePath;
+ }
+
+ if (frmMain.drp_dvdtitle.Text != string.Empty)
+ {
+ string[] titleInfo = frmMain.drp_dvdtitle.Text.Split(' ');
+ int title;
+ int.TryParse(titleInfo[0], out title);
+ task.Title = title;
+ }
+
+
+ int start, end, angle;
+ int.TryParse(frmMain.drop_chapterStart.Text, out start);
+ int.TryParse(frmMain.drop_chapterFinish.Text, out end);
+ int.TryParse(frmMain.drop_angle.Text, out angle);
+ task.StartPoint = start;
+ task.EndPoint = end;
+ task.Angle = angle;
+
+ switch (frmMain.drop_mode.SelectedIndex)
+ {
+ case 0: // Chapters
+ task.PointToPointMode = PointToPointMode.Chapters;
+ break;
+ case 1: // Seconds
+ task.PointToPointMode = PointToPointMode.Seconds;
+ break;
+ case 2: // Frames
+ task.PointToPointMode = PointToPointMode.Frames;
+ break;
+ default:
+ break;
+ }
+
+ task.OutputFormat = EnumHelper<OutputFormat>.GetValue(frmMain.drop_format.Text.Replace(" File", string.Empty).Trim());
+ task.LargeFile = frmMain.check_largeFile.Checked;
+ task.IPod5GSupport = frmMain.check_largeFile.Checked;
+ task.OptimizeMP4 = frmMain.check_optimiseMP4.Checked;
+
+ // Picture Settings
+ int width, height;
+ int.TryParse(frmMain.PictureSettings.crop_top.Text, out width);
+ int.TryParse(frmMain.PictureSettings.crop_top.Text, out height);
+ task.Width = width;
+ task.Height = height;
+ int top, bottom, left, right;
+ int.TryParse(frmMain.PictureSettings.crop_top.Text, out top);
+ int.TryParse(frmMain.PictureSettings.crop_top.Text, out bottom);
+ int.TryParse(frmMain.PictureSettings.crop_top.Text, out left);
+ int.TryParse(frmMain.PictureSettings.crop_top.Text, out right);
+ task.Cropping = new Cropping(top, bottom, left, right);
+
+ int modulus, displayWidth, parX, parY;
+ int.TryParse(frmMain.PictureSettings.drp_modulus.SelectedItem.ToString(), out modulus);
+ int.TryParse(frmMain.PictureSettings.updownDisplayWidth.Text, out displayWidth);
+ int.TryParse(frmMain.PictureSettings.updownParWidth.Text, out parX);
+ int.TryParse(frmMain.PictureSettings.updownParHeight.Text, out parY);
+ switch (frmMain.PictureSettings.drp_anamorphic.SelectedIndex)
+ {
+ case 0:
+ task.Anamorphic = Anamorphic.None;
+ task.Modulus = modulus;
+ break;
+ case 1:
+ task.Anamorphic = Anamorphic.Strict;
+ break;
+ case 2:
+ task.Anamorphic = Anamorphic.Loose;
+ task.Modulus = modulus;
+ break;
+ case 3:
+ task.Anamorphic = Anamorphic.Custom;
+ task.Modulus = modulus;
+ task.DisplayWidth = displayWidth;
+ task.KeepDisplayAspect = frmMain.PictureSettings.check_KeepAR.Checked;
+ task.PixelAspectX = parX;
+ task.PixelAspectY = parY;
+ break;
+ }
+
+ // Filter Settings
+ task.Deblock = frmMain.Filters.Deblock;
+ task.Decomb = frmMain.Filters.Decomb;
+ task.CustomDecomb = frmMain.Filters.CustomDecombValue;
+ task.Deinterlace = frmMain.Filters.Deinterlace;
+ task.CustomDeinterlace = frmMain.Filters.CustomDeInterlaceValue;
+ task.Deblock = frmMain.Filters.Deblock;
+ task.Denoise = frmMain.Filters.Denoise;
+ task.CustomDenoise = frmMain.Filters.CustomDenoiseValue;
+ task.Detelecine = frmMain.Filters.Detelecine;
+ task.CustomDetelecine = frmMain.Filters.CustomDeTelecineValue;
+ task.Grayscale = frmMain.Filters.GrayScale;
+
+ // Video Settings
+ task.VideoEncoder = EnumHelper<VideoEncoder>.GetValue(frmMain.drp_videoEncoder.Text);
+ int videoBitrate;
+ int.TryParse(frmMain.text_bitrate.Text, out videoBitrate);
+ task.VideoBitrate = videoBitrate;
+ task.VideoEncodeRateType = frmMain.radio_cq.Checked
+ ? VideoEncodeRateType.ConstantQuality
+ : VideoEncodeRateType.AverageBitrate;
+ task.TwoPass = frmMain.check_2PassEncode.Checked;
+ task.TurboFirstPass = frmMain.check_turbo.Checked;
+ double framerate;
+ double.TryParse(frmMain.drp_videoFramerate.Text, out framerate);
+ task.Framerate = framerate;
+ task.FramerateMode = frmMain.drp_videoFramerate.SelectedIndex == 0
+ ? (frmMain.radio_constantFramerate.Checked ? FramerateMode.CFR : FramerateMode.VFR)
+ : (frmMain.radio_constantFramerate.Checked ? FramerateMode.CFR : FramerateMode.PFR);
+
+ if (frmMain.radio_cq.Checked)
+ {
+ double cqStep = UserSettingService.GetUserSetting<double>(ASUserSettingConstants.X264Step);
+ switch (frmMain.drp_videoEncoder.Text)
+ {
+ case "MPEG-4 (FFmpeg)":
+ case "MPEG-2 (FFmpeg)":
+ task.Quality = 31 - (frmMain.slider_videoQuality.Value - 1);
+ break;
+ case "H.264 (x264)":
+ double value = 51 - (frmMain.slider_videoQuality.Value * cqStep);
+ task.Quality = Math.Round(value, 2);
+ break;
+ case "VP3 (Theora)":
+ task.Quality = frmMain.slider_videoQuality.Value;
+ break;
+ }
+ }
+
+ // Audio
+ task.AudioTracks = new List<AudioTrack>(frmMain.AudioSettings.AudioTracks);
+
+ // Subtitles
+ task.SubtitleTracks = new List<SubtitleTrack>(frmMain.Subtitles.SubtitlesList);
+
+ // Chapters
+ task.IncludeChapterMarkers = frmMain.Check_ChapterMarkers.Checked;
+ task.ChapterNames = new List<string>();
+ foreach (DataGridViewRow row in frmMain.data_chpt.Rows)
+ {
+ task.ChapterNames.Add(row.Cells[1].Value.ToString());
+ }
+
+ // Advanced Options
+ task.AdvancedEncoderOptions = X264Query(frmMain).Replace("-x", string.Empty).Trim();
+
+ // Extra Settings
+ task.Verbosity = UserSettingService.GetUserSetting<int>(ASUserSettingConstants.Verbosity);
+ task.DisableLibDvdNav = UserSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableLibDvdNav);
+
+ return task;
+ }
+
+ #endregion
+
#region Helpers
/// <summary>
diff --git a/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs b/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs index bcc07d55f..ce46132af 100644 --- a/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs +++ b/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs @@ -293,6 +293,16 @@ namespace HandBrake.ApplicationServices.Model /// </summary>
public string AdvancedEncoderOptions { get; set; }
+ /// <summary>
+ /// Gets or sets Verbosity.
+ /// </summary>
+ public int Verbosity { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether disableLibDvdNav.
+ /// </summary>
+ public bool DisableLibDvdNav { get; set; }
+
#endregion
#region Preset Information (TODO This should probably be dropped)
diff --git a/win/CS/HandBrake.ApplicationServices/Model/Preset.cs b/win/CS/HandBrake.ApplicationServices/Model/Preset.cs index e20ad2dee..ede38b26f 100644 --- a/win/CS/HandBrake.ApplicationServices/Model/Preset.cs +++ b/win/CS/HandBrake.ApplicationServices/Model/Preset.cs @@ -31,11 +31,6 @@ namespace HandBrake.ApplicationServices.Model public bool CropSettings { get; set; }
/// <summary>
- /// Gets or sets the Settings for this encode/preset. Can be used in place of Query property.
- /// </summary>
- public EncodeTask EncodeSettings { get; set; }
-
- /// <summary>
/// Gets or sets The version number which associates this preset with a HB build
/// </summary>
public string Version { get; set; }
diff --git a/win/CS/HandBrake.ApplicationServices/Model/QueueTask.cs b/win/CS/HandBrake.ApplicationServices/Model/QueueTask.cs index 245a3171d..8c2425ee7 100644 --- a/win/CS/HandBrake.ApplicationServices/Model/QueueTask.cs +++ b/win/CS/HandBrake.ApplicationServices/Model/QueueTask.cs @@ -5,19 +5,12 @@ namespace HandBrake.ApplicationServices.Model
{
- using HandBrake.ApplicationServices.Utilities;
-
/// <summary>
/// The QueueTask.
/// </summary>
public class QueueTask
{
/// <summary>
- /// The Encode task backing field.
- /// </summary>
- private EncodeTask task;
-
- /// <summary>
/// Initializes a new instance of the <see cref="QueueTask"/> class.
/// </summary>
public QueueTask()
@@ -71,20 +64,9 @@ namespace HandBrake.ApplicationServices.Model public QueueItemStatus Status { get; set; }
/// <summary>
- /// Gets the Encode Task.
+ /// Gets or sets the Encode Task.
/// </summary>
- public EncodeTask Task
- {
- get
- {
- if (this.task == null)
- {
- task = QueryParserUtility.Parse(this.Query);
- }
-
- return this.task;
- }
- }
+ public EncodeTask Task { get; set; }
/// <summary>
/// Gets a value indicating whether or not this instance is empty.
diff --git a/win/CS/frmMain.cs b/win/CS/frmMain.cs index 9a2baa5d1..63623343d 100644 --- a/win/CS/frmMain.cs +++ b/win/CS/frmMain.cs @@ -21,6 +21,7 @@ namespace Handbrake using HandBrake.ApplicationServices;
using HandBrake.ApplicationServices.EventArgs;
+ using HandBrake.ApplicationServices.Model.Encoding;
using HandBrake.ApplicationServices.Model.General;
using HandBrake.ApplicationServices.Utilities;
using HandBrake.ApplicationServices.Functions;
@@ -845,7 +846,7 @@ namespace Handbrake Preset preset = new Preset
{
Name = parsed.PresetName,
- Query = QueryGenerator.GenerateFullQuery(this),
+ Query = QueryGenerator.GenerateFullQuery(this).Query,
CropSettings = parsed.UsesPictureSettings
};
@@ -860,7 +861,7 @@ namespace Handbrake Preset preset = new Preset
{
Name = parsed.PresetName,
- Query = QueryGenerator.GenerateFullQuery(this),
+ Query = QueryGenerator.GenerateFullQuery(this).Query,
CropSettings = parsed.UsesPictureSettings,
};
PresetLoader.LoadPreset(this, preset);
@@ -982,18 +983,17 @@ namespace Handbrake // If we have a custom query, then we'll want to figure out what the new source and destination is, otherwise we'll just use the gui components.
string jobSourcePath = !string.IsNullOrEmpty(rtf_query.Text) ? Main.GetSourceFromQuery(rtf_query.Text) : sourcePath;
string jobDestination = !string.IsNullOrEmpty(rtf_query.Text) ? Main.GetDestinationFromQuery(rtf_query.Text) : text_destination.Text;
+ QueueTask task = QueryGenerator.GenerateFullQuery(this);
if (this.queueProcessor.QueueManager.Count != 0 || (!string.IsNullOrEmpty(jobSourcePath) && !string.IsNullOrEmpty(jobDestination)))
{
- string generatedQuery = QueryGenerator.GenerateFullQuery(this);
string specifiedQuery = rtf_query.Text != string.Empty
? rtf_query.Text
- : QueryGenerator.GenerateFullQuery(this);
- string query = string.Empty;
+ : task.Query;
// Check to make sure the generated query matches the GUI settings
if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.PromptOnUnmatchingQueries) && !string.IsNullOrEmpty(specifiedQuery) &&
- generatedQuery != specifiedQuery)
+ task.Query != specifiedQuery)
{
DialogResult result = MessageBox.Show("The query under the \"Query Editor\" tab " +
"does not match the current GUI settings.\n\nBecause the manual query takes " +
@@ -1009,12 +1009,12 @@ namespace Handbrake {
case DialogResult.Yes:
// Replace the manual query with the generated one
- query = generatedQuery;
- rtf_query.Text = generatedQuery;
+
+ rtf_query.Text = task.Query;
break;
case DialogResult.No:
// Use the manual query
- query = specifiedQuery;
+ task.Query = specifiedQuery;
break;
case DialogResult.Cancel:
// Don't start the encode
@@ -1023,7 +1023,7 @@ namespace Handbrake }
else
{
- query = specifiedQuery;
+ task.Query = specifiedQuery;
}
DialogResult overwrite = DialogResult.Yes;
@@ -1038,16 +1038,10 @@ namespace Handbrake if (overwrite == DialogResult.Yes)
{
- QueueTask task = new QueueTask(query)
- {
- Title = this.GetTitle(),
- Source = jobSourcePath,
- Destination = jobDestination,
- CustomQuery = (this.rtf_query.Text != string.Empty)
- };
+
if (this.queueProcessor.QueueManager.Count == 0)
- this.queueProcessor.QueueManager.Add(task);
+ this.queueProcessor.QueueManager.Add(QueryGenerator.GenerateFullQuery(this));
queueWindow.SetQueue();
if (this.queueProcessor.QueueManager.Count > 1)
@@ -1202,10 +1196,6 @@ namespace Handbrake private bool AddItemToQueue(bool showError)
{
- string query = QueryGenerator.GenerateFullQuery(this);
- if (!string.IsNullOrEmpty(rtf_query.Text))
- query = rtf_query.Text;
-
// If we have a custom query, then we'll want to figure out what the new source and destination is, otherwise we'll just use the gui components.
string jobSourcePath = !string.IsNullOrEmpty(rtf_query.Text) ? Main.GetSourceFromQuery(rtf_query.Text) : sourcePath;
string jobDestination = !string.IsNullOrEmpty(rtf_query.Text) ? Main.GetDestinationFromQuery(rtf_query.Text) : text_destination.Text;
@@ -1242,14 +1232,8 @@ namespace Handbrake }
// Add the job.
- QueueTask task = new QueueTask(query)
- {
- Title = this.GetTitle(),
- Source = jobSourcePath,
- Destination = jobDestination,
- CustomQuery = (this.rtf_query.Text != string.Empty)
- };
- this.queueProcessor.QueueManager.Add(task);
+
+ this.queueProcessor.QueueManager.Add(QueryGenerator.GenerateFullQuery(this));
lbl_encode.Text = this.queueProcessor.QueueManager.Count + " encode(s) pending in the queue";
@@ -2083,7 +2067,7 @@ namespace Handbrake // Query Editor Tab
private void btn_generate_Query_Click(object sender, EventArgs e)
{
- rtf_query.Text = QueryGenerator.GenerateFullQuery(this);
+ rtf_query.Text = QueryGenerator.GenerateFullQuery(this).Query;
}
private void btn_clear_Click(object sender, EventArgs e)
@@ -2540,7 +2524,7 @@ namespace Handbrake /// <returns>
/// The title.
/// </returns>
- private int GetTitle()
+ public int GetTitle()
{
int title = 0;
if (drp_dvdtitle.SelectedItem != null)
|