diff options
author | Scott <[email protected]> | 2015-09-26 21:05:40 +0100 |
---|---|---|
committer | Scott <[email protected]> | 2015-09-26 21:30:32 +0100 |
commit | 1320d77d36f096c7aa5b1697d3aaf9aa35d5e199 (patch) | |
tree | 1a9964eac27b7689b39a2e5adbf019a7295b6a9b /win | |
parent | e703a7961f12a3e02c475754862a1f4a57a04646 (diff) |
App Services Tidyup Contd
Moving all the helper and utility classes to the gui project
Diffstat (limited to 'win')
76 files changed, 628 insertions, 6260 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj index 457f570b7..334414f1f 100644 --- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj +++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj @@ -80,7 +80,6 @@ <Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
- <Compile Include="Converters\EnumToDescConverter.cs" />
<Compile Include="Exceptions\GeneralApplicationException.cs" />
<Compile Include="Attributes\ShortName.cs" />
<Compile Include="Interop\EventArgs\EncodeCompletedEventArgs.cs" />
@@ -183,11 +182,6 @@ <Compile Include="Services\Logging\Model\LogLevel.cs" />
<Compile Include="Services\Logging\Model\LogMessage.cs" />
<Compile Include="Services\Logging\Model\LogMessageType.cs" />
- <Compile Include="Utilities\EnumHelper.cs" />
- <Compile Include="Utilities\Execute.cs" />
- <Compile Include="Utilities\ExtensionMethods.cs" />
- <Compile Include="Utilities\Interfaces\INotifyPropertyChangedEx.cs" />
- <Compile Include="Utilities\PropertyChangedBase.cs" />
<Compile Include="Utilities\SystemInfo.cs" />
<Compile Include="Utilities\VersionHelper.cs" />
<Compile Include="Utilities\Win32.cs" />
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs deleted file mode 100644 index 9a2a7a848..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs +++ /dev/null @@ -1,377 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="EncodeBase.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// A Base Class for the Encode Services.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Encode
-{
- using System;
- using System.Diagnostics;
- using System.IO;
- using System.Text;
-
- using HandBrake.ApplicationServices.Exceptions;
- using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Services.Encode.EventArgs;
- using HandBrake.ApplicationServices.Services.Encode.Interfaces;
- using HandBrake.ApplicationServices.Services.Encode.Model;
- using HandBrake.ApplicationServices.Utilities;
-
- /// <summary>
- /// A Base Class for the Encode Services.
- /// </summary>
- public class EncodeBase
- {
- #region Private Variables
-
- /// <summary>
- /// A Lock for the filewriter
- /// </summary>
- private static readonly object FileWriterLock = new object();
-
- /// <summary>
- /// The Log File Header
- /// </summary>
- private readonly StringBuilder header;
-
- /// <summary>
- /// The Log Buffer
- /// </summary>
- private StringBuilder logBuffer;
-
- /// <summary>
- /// The Log file writer
- /// </summary>
- private StreamWriter fileWriter;
-
- #endregion
-
- /// <summary>
- /// Initializes a new instance of the <see cref="EncodeBase"/> class.
- /// </summary>
- public EncodeBase()
- {
- this.logBuffer = new StringBuilder();
- this.header = GeneralUtilities.CreateLogHeader();
- this.LogIndex = 0;
- }
-
- #region Events
-
- /// <summary>
- /// Fires when a new QueueTask starts
- /// </summary>
- public event EventHandler EncodeStarted;
-
- /// <summary>
- /// Fires when a QueueTask finishes.
- /// </summary>
- public event EncodeCompletedStatus EncodeCompleted;
-
- /// <summary>
- /// Encode process has progressed
- /// </summary>
- public event EncodeProgessStatus EncodeStatusChanged;
-
- #endregion
-
- #region Properties
-
- /// <summary>
- /// Gets or sets a value indicating whether IsEncoding.
- /// </summary>
- public bool IsEncoding { get; protected set; }
-
- /// <summary>
- /// Gets ActivityLog.
- /// </summary>
- public string ActivityLog
- {
- get
- {
- string noLog = "There is no log information to display." + Environment.NewLine + Environment.NewLine
- + "This window will only display logging information after you have started an encode." + Environment.NewLine
- + Environment.NewLine + "You can find previous log files in the log directory or by clicking the 'Open Log Directory' button above.";
-
- return string.IsNullOrEmpty(this.logBuffer.ToString())
- ? noLog
- : this.header + this.logBuffer.ToString();
- }
- }
-
- /// <summary>
- /// Gets the log index.
- /// </summary>
- public int LogIndex { get; private set; }
-
- /// <summary>
- /// Gets LogBuffer.
- /// </summary>
- public StringBuilder LogBuffer
- {
- get
- {
- return this.logBuffer;
- }
- }
-
- #endregion
-
- #region Invoke Events
-
- /// <summary>
- /// Invoke the Encode Status Changed Event.
- /// </summary>
- /// <param name="e">
- /// The EncodeProgressEventArgs.
- /// </param>
- public void InvokeEncodeStatusChanged(EncodeProgressEventArgs e)
- {
- EncodeProgessStatus handler = this.EncodeStatusChanged;
- if (handler != null)
- {
- handler(this, e);
- }
- }
-
- /// <summary>
- /// Invoke the Encode Completed Event
- /// </summary>
- /// <param name="e">
- /// The EncodeCompletedEventArgs.
- /// </param>
- public void InvokeEncodeCompleted(EncodeCompletedEventArgs e)
- {
- EncodeCompletedStatus handler = this.EncodeCompleted;
- if (handler != null)
- {
- handler(this, e);
- }
-
- this.LogIndex = 0; // Reset
- }
-
- /// <summary>
- /// Invoke the Encode Started Event
- /// </summary>
- /// <param name="e">
- /// The EventArgs.
- /// </param>
- public void InvokeEncodeStarted(System.EventArgs e)
- {
- EventHandler handler = this.EncodeStarted;
- if (handler != null)
- {
- handler(this, e);
- }
- }
-
- #endregion
-
- #region Methods
-
- /// <summary>
- /// 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="destination">
- /// The Destination File Path
- /// </param>
- /// <param name="configuration">
- /// The configuration.
- /// </param>
- public void ProcessLogs(string destination, HBConfiguration configuration)
- {
- try
- {
- string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
- "\\HandBrake\\logs";
- string tempLogFile = Path.Combine(logDir, string.Format("last_encode_log{0}.txt", GeneralUtilities.ProcessId));
-
- string encodeDestinationPath = Path.GetDirectoryName(destination);
- string destinationFile = Path.GetFileName(destination);
- string encodeLogFile = destinationFile + " " +
- DateTime.Now.ToString().Replace("/", "-").Replace(":", "-") + ".txt";
-
- // Make sure the log directory exists.
- if (!Directory.Exists(logDir))
- {
- Directory.CreateDirectory(logDir);
- }
-
- // Copy the Log to HandBrakes log folder in the users applciation data folder.
- File.Copy(tempLogFile, Path.Combine(logDir, encodeLogFile));
-
- // Save a copy of the log file in the same location as the enocde.
- if (configuration.SaveLogWithVideo)
- {
- File.Copy(tempLogFile, Path.Combine(encodeDestinationPath, encodeLogFile));
- }
-
- // Save a copy of the log file to a user specified location
- if (Directory.Exists(configuration.SaveLogCopyDirectory) && configuration.SaveLogToCopyDirectory)
- {
- File.Copy(
- tempLogFile, Path.Combine(configuration.SaveLogCopyDirectory, encodeLogFile));
- }
- }
- catch (Exception exc)
- {
- Debug.WriteLine(exc); // This exception doesn't warrent user interaction, but it should be logged
- }
- }
-
- /// <summary>
- /// Setup the logging.
- /// </summary>
- protected void SetupLogging()
- {
- this.ShutdownFileWriter();
- string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";
- string logFile = Path.Combine(logDir, string.Format("last_encode_log{0}.txt", GeneralUtilities.ProcessId));
- string logFile2 = Path.Combine(logDir, string.Format("tmp_appReadable_log{0}.txt", GeneralUtilities.ProcessId));
-
- try
- {
- this.logBuffer = new StringBuilder();
-
- this.logBuffer.AppendLine();
-
- // Clear the current Encode Logs)
- if (File.Exists(logFile))
- {
- File.Delete(logFile);
- }
-
- if (File.Exists(logFile2))
- {
- File.Delete(logFile2);
- }
-
- lock (FileWriterLock)
- {
- this.fileWriter = new StreamWriter(logFile) { AutoFlush = true };
- this.fileWriter.WriteLine(this.header);
- this.fileWriter.WriteLine();
- }
- }
- catch (Exception)
- {
- if (this.fileWriter != null)
- {
- lock (FileWriterLock)
- {
- this.fileWriter.Flush();
- this.fileWriter.Close();
- this.fileWriter.Dispose();
- }
- }
-
- throw;
- }
- }
-
- /// <summary>
- /// The service log message.
- /// </summary>
- /// <param name="message">
- /// The message.
- /// </param>
- protected void ServiceLogMessage(string message)
- {
- this.ProcessLogMessage(string.Format("# {0}", message));
- }
-
- /// <summary>
- /// Process an Incomming Log Message.
- /// </summary>
- /// <param name="message">
- /// The message.
- /// </param>
- protected void ProcessLogMessage(string message)
- {
- if (!string.IsNullOrEmpty(message))
- {
- try
- {
- this.LogIndex = this.LogIndex + 1;
-
- lock (this.LogBuffer)
- {
- this.LogBuffer.AppendLine(message);
- }
-
- lock (FileWriterLock)
- {
- if (this.fileWriter != null && this.fileWriter.BaseStream.CanWrite)
- {
- this.fileWriter.WriteLine(message);
- }
- }
- }
- catch (Exception exc)
- {
- Debug.WriteLine(exc); // This exception doesn't warrent user interaction, but it should be logged
- }
- }
- }
-
- /// <summary>
- /// Shutdown and Dispose of the File Writer.
- /// </summary>
- protected void ShutdownFileWriter()
- {
- try
- {
- lock (FileWriterLock)
- {
- if (this.fileWriter != null)
- {
- this.fileWriter.Flush();
- this.fileWriter.Close();
- this.fileWriter.Dispose();
- }
-
- this.fileWriter = null;
- }
- }
- catch (Exception exc)
- {
- Debug.WriteLine(exc); // This exception doesn't warrent user interaction, but it should be logged
- }
- }
-
- /// <summary>
- /// Verify the Encode Destination path exists and if not, create it.
- /// </summary>
- /// <param name="task">
- /// The task.
- /// </param>
- /// <exception cref="Exception">
- /// If the creation fails, an exception is thrown.
- /// </exception>
- protected void VerifyEncodeDestinationPath(EncodeTask task)
- {
- // Make sure the path exists, attempt to create it if it doesn't
- try
- {
- string path = Directory.GetParent(task.Destination).ToString();
- if (!Directory.Exists(path))
- {
- Directory.CreateDirectory(path);
- }
- }
- catch (Exception exc)
- {
- throw new GeneralApplicationException(
- "Unable to create directory for the encoded output.", "Please verify that you have a valid path.", exc);
- }
- }
-
- #endregion
- }
-}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/EventArgs/EncodeCompletedEventArgs.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/EventArgs/EncodeCompletedEventArgs.cs deleted file mode 100644 index b77f3097c..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/EventArgs/EncodeCompletedEventArgs.cs +++ /dev/null @@ -1,68 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="EncodeCompletedEventArgs.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Encode Progress Event Args
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Encode.EventArgs
-{
- using System;
- using System.Runtime.Serialization;
-
- /// <summary>
- /// Encode Progress Event Args
- /// </summary>
- [DataContract]
- public class EncodeCompletedEventArgs : EventArgs
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="EncodeCompletedEventArgs"/> class.
- /// </summary>
- /// <param name="sucessful">
- /// The sucessful.
- /// </param>
- /// <param name="exception">
- /// The exception.
- /// </param>
- /// <param name="errorInformation">
- /// The error information.
- /// </param>
- /// <param name="filename">
- /// The filename.
- /// </param>
- public EncodeCompletedEventArgs(bool sucessful, Exception exception, string errorInformation, string filename)
- {
- this.Successful = sucessful;
- this.Exception = exception;
- this.ErrorInformation = errorInformation;
- this.FileName = filename;
- }
-
- /// <summary>
- /// Gets or sets the file name.
- /// </summary>
- [DataMember]
- public string FileName { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether Successful.
- /// </summary>
- [DataMember]
- public bool Successful { get; set; }
-
- /// <summary>
- /// Gets or sets Exception.
- /// </summary>
- [DataMember]
- public Exception Exception { get; set; }
-
- /// <summary>
- /// Gets or sets ErrorInformation.
- /// </summary>
- [DataMember]
- public string ErrorInformation { get; set; }
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/EventArgs/EncodeProgressEventArgs.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/EventArgs/EncodeProgressEventArgs.cs deleted file mode 100644 index 87d777525..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/EventArgs/EncodeProgressEventArgs.cs +++ /dev/null @@ -1,63 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="EncodeProgressEventArgs.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Encode Progress Event Args
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Encode.EventArgs
-{
- using System;
- using System.Runtime.Serialization;
-
- /// <summary>
- /// Encode Progress Event Args
- /// </summary>
- [DataContract]
- public class EncodeProgressEventArgs : EventArgs
- {
- /// <summary>
- /// Gets or sets PercentComplete.
- /// </summary>
- [DataMember]
- public double PercentComplete { get; set; }
-
- /// <summary>
- /// Gets or sets CurrentFrameRate.
- /// </summary>
- [DataMember]
- public double CurrentFrameRate { get; set; }
-
- /// <summary>
- /// Gets or sets AverageFrameRate.
- /// </summary>
- [DataMember]
- public double AverageFrameRate { get; set; }
-
- /// <summary>
- /// Gets or sets EstimatedTimeLeft.
- /// </summary>
- [DataMember]
- public TimeSpan EstimatedTimeLeft { get; set; }
-
- /// <summary>
- /// Gets or sets Task.
- /// </summary>
- [DataMember]
- public int Task { get; set; }
-
- /// <summary>
- /// Gets or sets TaskCount.
- /// </summary>
- [DataMember]
- public int TaskCount { get; set; }
-
- /// <summary>
- /// Gets or sets ElapsedTime.
- /// </summary>
- [DataMember]
- public TimeSpan ElapsedTime { get; set; }
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs deleted file mode 100644 index 8d93668bf..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs +++ /dev/null @@ -1,538 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="EncodeFactory.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// The encode factory.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Encode.Factories
-{
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using System.Runtime.InteropServices;
-
- using HandBrake.ApplicationServices.Interop;
- using HandBrake.ApplicationServices.Interop.HbLib;
- using HandBrake.ApplicationServices.Interop.Helpers;
- using HandBrake.ApplicationServices.Interop.Json;
- using HandBrake.ApplicationServices.Interop.Json.Anamorphic;
- using HandBrake.ApplicationServices.Interop.Json.Encode;
- using HandBrake.ApplicationServices.Interop.Json.Shared;
- using HandBrake.ApplicationServices.Interop.Model.Encoding;
- using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Services.Encode.Model;
- using HandBrake.ApplicationServices.Services.Encode.Model.Models;
- using HandBrake.ApplicationServices.Utilities;
-
- using AudioTrack = HandBrake.ApplicationServices.Services.Encode.Model.Models.AudioTrack;
- using Subtitle = HandBrake.ApplicationServices.Interop.Json.Encode.Subtitles;
-
- /// <summary>
- /// This factory takes the internal EncodeJob object and turns it into a set of JSON models
- /// that can be deserialized by libhb.
- /// </summary>
- internal class EncodeFactory
- {
- /*
- * TODO:
- * 1. OpenCL and HWD Support
- * 2. Rotate Support
- */
-
- /// <summary>
- /// The create.
- /// </summary>
- /// <param name="job">
- /// The encode job.
- /// </param>
- /// <param name="configuration">
- /// The configuration.
- /// </param>
- /// <returns>
- /// The <see cref="JsonEncodeObject"/>.
- /// </returns>
- internal static JsonEncodeObject Create(EncodeTask job, HBConfiguration configuration)
- {
- JsonEncodeObject encode = new JsonEncodeObject
- {
- SequenceID = 0,
- Audio = CreateAudio(job),
- Destination = CreateDestination(job),
- Filters = CreateFilters(job),
- PAR = CreatePAR(job),
- Metadata = CreateMetadata(job),
- Source = CreateSource(job, configuration),
- Subtitle = CreateSubtitle(job),
- Video = CreateVideo(job, configuration)
- };
-
- return encode;
- }
-
- /// <summary>
- /// The create source.
- /// </summary>
- /// <param name="job">
- /// The job.
- /// </param>
- /// <param name="configuration">
- /// The configuration.
- /// </param>
- /// <returns>
- /// The <see cref="Source"/>.
- /// </returns>
- private static Source CreateSource(EncodeTask job, HBConfiguration configuration)
- {
- Range range = new Range();
- switch (job.PointToPointMode)
- {
- case PointToPointMode.Chapters:
- range.Type = "chapter";
- range.Start = job.StartPoint;
- range.End = job.EndPoint;
- break;
- case PointToPointMode.Seconds:
- range.Type = "time";
- range.Start = job.StartPoint * 90000;
- range.End = (job.EndPoint - job.StartPoint) * 90000;
- break;
- case PointToPointMode.Frames:
- range.Type = "frame";
- range.Start = job.StartPoint;
- range.End = job.EndPoint;
- break;
- case PointToPointMode.Preview:
- range.Type = "preview";
- range.Start = job.PreviewEncodeStartAt;
- range.SeekPoints = configuration.PreviewScanCount;
- range.End = job.PreviewEncodeDuration * 90000;
- break;
- }
-
- Source source = new Source
- {
- Title = job.Title,
- Range = range,
- Angle = job.Angle,
- Path = job.Source,
- };
- return source;
- }
-
- /// <summary>
- /// The create destination.
- /// </summary>
- /// <param name="job">
- /// The job.
- /// </param>
- /// <returns>
- /// The <see cref="Destination"/>.
- /// </returns>
- private static Destination CreateDestination(EncodeTask job)
- {
- Destination destination = new Destination
- {
- File = job.Destination,
- Mp4Options = new Mp4Options
- {
- IpodAtom = job.IPod5GSupport,
- Mp4Optimize = job.OptimizeMP4
- },
- ChapterMarkers = job.IncludeChapterMarkers,
- Mux = HBFunctions.hb_container_get_from_name(job.OutputFormat == OutputFormat.Mp4 ? "av_mp4" : "av_mkv"), // TODO tidy up.
- ChapterList = new List<Chapter>()
- };
-
- if (job.IncludeChapterMarkers)
- {
- foreach (ChapterMarker item in job.ChapterNames)
- {
- Chapter chapter = new Chapter { Name = item.ChapterName };
- destination.ChapterList.Add(chapter);
- }
- }
-
- return destination;
- }
-
- /// <summary>
- /// Create the PAR object
- /// </summary>
- /// <param name="job">
- /// The Job
- /// </param>
- /// <returns>
- /// The produced PAR object.
- /// </returns>
- private static PAR CreatePAR(EncodeTask job)
- {
- return new PAR { Num = job.PixelAspectX, Den = job.PixelAspectY };
- }
-
- /// <summary>
- /// The create subtitle.
- /// </summary>
- /// <param name="job">
- /// The job.
- /// </param>
- /// <returns>
- /// The <see cref="HandBrake.ApplicationServices.Interop.Json.Encode.Subtitles"/>.
- /// </returns>
- private static Subtitle CreateSubtitle(EncodeTask job)
- {
- Subtitles subtitle = new Subtitles
- {
- Search =
- new SubtitleSearch
- {
- Enable = false,
- Default = false,
- Burn = false,
- Forced = false
- },
- SubtitleList = new List<HandBrake.ApplicationServices.Interop.Json.Encode.SubtitleTrack>()
- };
-
- foreach (HandBrake.ApplicationServices.Services.Encode.Model.Models.SubtitleTrack item in job.SubtitleTracks)
- {
- if (!item.IsSrtSubtitle)
- {
- // Handle Foreign Audio Search
- if (item.SourceTrack.TrackNumber == 0)
- {
- subtitle.Search.Enable = true;
- subtitle.Search.Burn = item.Burned;
- subtitle.Search.Default = item.Default;
- subtitle.Search.Forced = item.Forced;
- }
- else
- {
- HandBrake.ApplicationServices.Interop.Json.Encode.SubtitleTrack track = new HandBrake.ApplicationServices.Interop.Json.Encode.SubtitleTrack
- {
- Burn = item.Burned,
- Default = item.Default,
- Forced = item.Forced,
- ID = item.SourceTrack.TrackNumber,
- Track = (item.SourceTrack.TrackNumber - 1)
- };
-
- subtitle.SubtitleList.Add(track);
- }
- }
- else
- {
- HandBrake.ApplicationServices.Interop.Json.Encode.SubtitleTrack track = new HandBrake.ApplicationServices.Interop.Json.Encode.SubtitleTrack
- {
- Track = -1, // Indicates SRT
- Default = item.Default,
- Offset = item.SrtOffset,
- Burn = item.Burned,
- SRT =
- new SRT
- {
- Filename = item.SrtPath,
- Codeset = item.SrtCharCode,
- Language = item.SrtLang
- }
- };
-
- subtitle.SubtitleList.Add(track);
- }
- }
-
- return subtitle;
- }
-
- /// <summary>
- /// The create video.
- /// </summary>
- /// <param name="job">
- /// The job.
- /// </param>
- /// <param name="configuration">
- /// The configuration.
- /// </param>
- /// <returns>
- /// The <see cref="Video"/>.
- /// </returns>
- private static Video CreateVideo(EncodeTask job, HBConfiguration configuration)
- {
- Video video = new Video();
-
- HBVideoEncoder videoEncoder = HandBrakeEncoderHelpers.VideoEncoders.FirstOrDefault(e => e.ShortName == EnumHelper<VideoEncoder>.GetShortName(job.VideoEncoder));
- Validate.NotNull(videoEncoder, "Video encoder " + job.VideoEncoder + " not recognized.");
- if (videoEncoder != null)
- {
- video.Encoder = videoEncoder.Id;
- }
-
- string advancedOptions = job.ShowAdvancedTab ? job.AdvancedEncoderOptions : string.Empty;
- if (!string.IsNullOrEmpty(advancedOptions))
- {
- video.Options = advancedOptions;
- }
- else
- {
- video.Level = job.VideoLevel != null ? job.VideoLevel.ShortName : null;
- video.Options = job.ExtraAdvancedArguments;
- video.Preset = job.VideoPreset != null ? job.VideoPreset.ShortName : null;
- video.Profile = job.VideoProfile != null ? job.VideoProfile.ShortName : null;
- }
-
- if (job.VideoEncodeRateType == VideoEncodeRateType.ConstantQuality) video.Quality = job.Quality;
- if (job.VideoEncodeRateType == VideoEncodeRateType.AverageBitrate)
- {
- video.Bitrate = job.VideoBitrate;
- video.TwoPass = job.TwoPass;
- video.Turbo = job.TurboFirstPass;
- }
-
- if (job.VideoTunes != null && job.VideoTunes.Count > 0)
- {
- foreach (var item in job.VideoTunes)
- {
- video.Tune += string.IsNullOrEmpty(video.Tune) ? item.ShortName : "," + item.ShortName;
- }
- }
-
- video.OpenCL = configuration.ScalingMode == VideoScaler.BicubicCl;
- video.HWDecode = configuration.EnableDxva;
- video.QSV.Decode = !configuration.DisableQuickSyncDecoding;
-
- return video;
- }
-
- /// <summary>
- /// The create audio.
- /// </summary>
- /// <param name="job">
- /// The job.
- /// </param>
- /// <returns>
- /// The <see cref="Audio"/>.
- /// </returns>
- private static Audio CreateAudio(EncodeTask job)
- {
- Audio audio = new Audio();
-
- List<uint> copyMaskList = new List<uint>();
- if (job.AllowedPassthruOptions.AudioAllowAACPass) copyMaskList.Add(NativeConstants.HB_ACODEC_AAC_PASS);
- if (job.AllowedPassthruOptions.AudioAllowAC3Pass) copyMaskList.Add(NativeConstants.HB_ACODEC_AC3_PASS);
- if (job.AllowedPassthruOptions.AudioAllowDTSHDPass) copyMaskList.Add(NativeConstants.HB_ACODEC_DCA_HD_PASS);
- if (job.AllowedPassthruOptions.AudioAllowDTSPass) copyMaskList.Add(NativeConstants.HB_ACODEC_DCA_PASS);
- if (job.AllowedPassthruOptions.AudioAllowEAC3Pass) copyMaskList.Add(NativeConstants.HB_ACODEC_EAC3_PASS);
- if (job.AllowedPassthruOptions.AudioAllowFlacPass) copyMaskList.Add(NativeConstants.HB_ACODEC_FLAC_PASS);
- if (job.AllowedPassthruOptions.AudioAllowMP3Pass) copyMaskList.Add(NativeConstants.HB_ACODEC_MP3_PASS);
- if (job.AllowedPassthruOptions.AudioAllowTrueHDPass) copyMaskList.Add(NativeConstants.HB_ACODEC_TRUEHD_PASS);
- audio.CopyMask = copyMaskList.ToArray();
-
- HBAudioEncoder audioEncoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(job.AllowedPassthruOptions.AudioEncoderFallback));
- audio.FallbackEncoder = audioEncoder.Id;
-
- audio.AudioList = new List<Interop.Json.Encode.AudioTrack>();
- foreach (AudioTrack item in job.AudioTracks)
- {
- HBAudioEncoder encoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(item.Encoder));
- Validate.NotNull(encoder, "Unrecognized audio encoder:" + item.Encoder);
-
- HBMixdown mixdown = HandBrakeEncoderHelpers.GetMixdown(EnumHelper<Mixdown>.GetShortName(item.MixDown));
- Validate.NotNull(mixdown, "Unrecognized audio mixdown:" + item.MixDown);
-
- HBRate sampleRate = HandBrakeEncoderHelpers.AudioSampleRates.FirstOrDefault(s => s.Name == item.SampleRate.ToString(CultureInfo.InvariantCulture));
-
- HandBrake.ApplicationServices.Interop.Json.Encode.AudioTrack audioTrack = new HandBrake.ApplicationServices.Interop.Json.Encode.AudioTrack
- {
- Track = (item.Track.HasValue ? item.Track.Value : 0) - 1,
- DRC = item.DRC,
- Encoder = encoder.Id,
- Gain = item.Gain,
- Mixdown = mixdown.Id,
- NormalizeMixLevel = false,
- Samplerate = sampleRate != null ? sampleRate.Rate : 0,
- Name = item.TrackName,
- };
-
- if (!item.IsPassthru)
- {
- if (item.EncoderRateType == AudioEncoderRateType.Quality)
- {
- audioTrack.Quality = item.Quality;
- }
-
- if (item.EncoderRateType == AudioEncoderRateType.Bitrate)
- {
- audioTrack.Bitrate = item.Bitrate;
- }
- }
-
- audio.AudioList.Add(audioTrack);
- }
-
- return audio;
- }
-
- /// <summary>
- /// The create filter.
- /// </summary>
- /// <param name="job">
- /// The job.
- /// </param>
- /// <returns>
- /// The <see cref="Filters"/>.
- /// </returns>
- private static Filters CreateFilters(EncodeTask job)
- {
- Filters filter = new Filters
- {
- FilterList = new List<Filter>(),
- Grayscale = job.Grayscale
- };
-
- // Detelecine
- if (job.Detelecine != Detelecine.Off)
- {
- Filter filterItem = new Filter { ID = (int)hb_filter_ids.HB_FILTER_DETELECINE, Settings = job.CustomDetelecine };
- filter.FilterList.Add(filterItem);
- }
-
- // Decomb
- if (job.Decomb != Decomb.Off)
- {
- string options;
- if (job.Decomb == Decomb.Fast)
- {
- options = "7:2:6:9:1:80";
- }
- else if (job.Decomb == Decomb.Bob)
- {
- options = "455";
- }
- else
- {
- options = job.CustomDecomb;
- }
-
- Filter filterItem = new Filter { ID = (int)hb_filter_ids.HB_FILTER_DECOMB, Settings = options };
- filter.FilterList.Add(filterItem);
- }
-
- // Deinterlace
- if (job.Deinterlace != Deinterlace.Off)
- {
- string options;
- if (job.Deinterlace == Deinterlace.Fast)
- {
- options = "0";
- }
- else if (job.Deinterlace == Deinterlace.Slow)
- {
- options = "1";
- }
- else if (job.Deinterlace == Deinterlace.Slower)
- {
- options = "3";
- }
- else if (job.Deinterlace == Deinterlace.Bob)
- {
- options = "15";
- }
- else
- {
- options = job.CustomDeinterlace;
- }
-
- Filter filterItem = new Filter { ID = (int)hb_filter_ids.HB_FILTER_DEINTERLACE, Settings = options };
- filter.FilterList.Add(filterItem);
- }
-
- // VFR / CFR
- int fm = job.FramerateMode == FramerateMode.CFR ? 1 : job.FramerateMode == FramerateMode.PFR ? 2 : 0;
- IntPtr frameratePrt = Marshal.StringToHGlobalAnsi(job.Framerate.ToString()); // TODO check culture
- int vrate = HBFunctions.hb_video_framerate_get_from_name(frameratePrt);
-
- int? num = null;
- int? den = null;
- if (vrate > 0)
- {
- num = 27000000;
- den = vrate;
- }
-
- string framerateString = num.HasValue ? string.Format("{0}:{1}:{2}", fm, num, den) : string.Format("{0}", fm); // filter_cfr, filter_vrate.num, filter_vrate.den
-
- Filter framerateShaper = new Filter { ID = (int)hb_filter_ids.HB_FILTER_VFR, Settings = framerateString };
- filter.FilterList.Add(framerateShaper);
-
- // Deblock
- if (job.Deblock >= 5)
- {
- Filter filterItem = new Filter { ID = (int)hb_filter_ids.HB_FILTER_DEBLOCK, Settings = job.Deblock.ToString() };
- filter.FilterList.Add(filterItem);
- }
-
- // Denoise
- if (job.Denoise != Denoise.Off)
- {
- hb_filter_ids id = job.Denoise == Denoise.hqdn3d
- ? hb_filter_ids.HB_FILTER_HQDN3D
- : hb_filter_ids.HB_FILTER_NLMEANS;
-
- string settings;
- if (!string.IsNullOrEmpty(job.CustomDenoise))
- {
- settings = job.CustomDenoise;
- }
- else
- {
- IntPtr settingsPtr = HBFunctions.hb_generate_filter_settings((int)id, job.DenoisePreset.ToString().ToLower().Replace(" ", string.Empty), job.DenoiseTune.ToString().ToLower().Replace(" ", string.Empty));
- settings = Marshal.PtrToStringAnsi(settingsPtr);
- }
-
- Filter filterItem = new Filter { ID = (int)id, Settings = settings };
- filter.FilterList.Add(filterItem);
- }
-
- // CropScale Filter
- Filter cropScale = new Filter
- {
- ID = (int)hb_filter_ids.HB_FILTER_CROP_SCALE,
- Settings =
- string.Format(
- "{0}:{1}:{2}:{3}:{4}:{5}",
- job.Width,
- job.Height,
- job.Cropping.Top,
- job.Cropping.Bottom,
- job.Cropping.Left,
- job.Cropping.Right)
- };
- filter.FilterList.Add(cropScale);
-
- // Rotate
- /* TODO NOT SUPPORTED YET. */
-
- return filter;
- }
-
- /// <summary>
- /// The create meta data.
- /// </summary>
- /// <param name="job">
- /// The job.
- /// </param>
- /// <returns>
- /// The <see cref="Metadata"/>.
- /// </returns>
- private static Metadata CreateMetadata(EncodeTask job)
- {
- Metadata metaData = new Metadata();
-
- /* TODO NOT SUPPORTED YET. */
- return metaData;
- }
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/VideoLevelFactory.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/VideoLevelFactory.cs deleted file mode 100644 index 375b7be95..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/VideoLevelFactory.cs +++ /dev/null @@ -1,38 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="VideoLevelFactory.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// The video level factory.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Encode.Factories
-{
- /// <summary>
- /// The video tune factory.
- /// </summary>
- public class VideoLevelFactory
- {
- /// <summary>
- /// The get display name for a given short name.
- /// LibHB doesn't currently support this.
- /// </summary>
- /// <param name="shortName">
- /// The short name.
- /// </param>
- /// <returns>
- /// The <see cref="string"/>.
- /// </returns>
- public static string GetDisplayName(string shortName)
- {
- switch (shortName)
- {
- case "auto":
- return "Auto";
- }
-
- return shortName;
- }
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/VideoPresetFactory.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/VideoPresetFactory.cs deleted file mode 100644 index 4239b4c80..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/VideoPresetFactory.cs +++ /dev/null @@ -1,63 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="VideoPresetFactory.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// The video preset factory.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Encode.Factories
-{
- /// <summary>
- /// The video tune factory.
- /// </summary>
- public class VideoPresetFactory
- {
- /// <summary>
- /// The get display name for a given short name.
- /// LibHB doesn't currently support this.
- /// </summary>
- /// <param name="shortName">
- /// The short name.
- /// </param>
- /// <returns>
- /// The <see cref="string"/>.
- /// </returns>
- public static string GetDisplayName(string shortName)
- {
- switch (shortName)
- {
- case "ultrafast":
- return "Ultrafast";
- case "superfast":
- return "Superfast";
- case "veryfast":
- return "Veryfast";
- case "faster":
- return "Faster";
- case "fast":
- return "Fast";
- case "medium":
- return "Medium";
- case "slow":
- return "Slow";
- case "slower":
- return "Slower";
- case "veryslow":
- return "VerySlow";
- case "placebo":
- return "Placebo";
-
- case "balanced":
- return "Balanced";
- case "speed":
- return "Speed";
- case "quality":
- return "Quality";
- }
-
- return shortName;
- }
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/VideoProfileFactory.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/VideoProfileFactory.cs deleted file mode 100644 index e9c1a23f5..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/VideoProfileFactory.cs +++ /dev/null @@ -1,48 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="VideoProfileFactory.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// The video profile factory.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Encode.Factories
-{
- /// <summary>
- /// The video profile factory.
- /// </summary>
- public class VideoProfileFactory
- {
- /// <summary>
- /// The get display name for a given short name.
- /// LibHB doesn't currently support this.
- /// </summary>
- /// <param name="shortName">
- /// The short name.
- /// </param>
- /// <returns>
- /// The <see cref="string"/>.
- /// </returns>
- public static string GetDisplayName(string shortName)
- {
- switch (shortName)
- {
- case "auto":
- return "Auto";
- case "main":
- return "Main";
- case "high":
- return "High";
- case "baseline":
- return "Baseline";
- case "main10":
- return "Main 10";
- case "mainstillpicture":
- return "Main Still Picture";
- }
-
- return shortName;
- }
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/VideoTuneFactory.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/VideoTuneFactory.cs deleted file mode 100644 index b5aef7777..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/VideoTuneFactory.cs +++ /dev/null @@ -1,54 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="VideoTuneFactory.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// The video tune factory.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Encode.Factories
-{
- /// <summary>
- /// The video tune factory.
- /// </summary>
- public class VideoTuneFactory
- {
- /// <summary>
- /// The get display name for a given short name.
- /// LibHB doesn't currently support this.
- /// </summary>
- /// <param name="shortName">
- /// The short name.
- /// </param>
- /// <returns>
- /// The <see cref="string"/>.
- /// </returns>
- public static string GetDisplayName(string shortName)
- {
- switch (shortName)
- {
- case "auto":
- return "Auto";
- case "film":
- return "Film";
- case "animation":
- return "Animation";
- case "grain":
- return "Grain";
- case "stillimage":
- return "Still Image";
- case "psnr":
- return "PSNR";
- case "ssim":
- return "SSIM";
- case "fastdecode":
- return "Fast Decode";
- case "zerolatency":
- return "Zero Latency";
- }
-
- return shortName;
- }
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Interfaces/IEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Interfaces/IEncode.cs deleted file mode 100644 index 60a5744ad..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Interfaces/IEncode.cs +++ /dev/null @@ -1,117 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="IEncode.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Encode Progess Status
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Encode.Interfaces
-{
- using System;
-
- using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Services.Encode.EventArgs;
- using HandBrake.ApplicationServices.Services.Encode.Model;
-
- /// <summary>
- /// Encode Progess Status
- /// </summary>
- /// <param name="sender">
- /// The sender.
- /// </param>
- /// <param name="e">
- /// The EncodeProgressEventArgs.
- /// </param>
- public delegate void EncodeProgessStatus(object sender, EncodeProgressEventArgs e);
-
- /// <summary>
- /// Encode Progess Status
- /// </summary>
- /// <param name="sender">
- /// The sender.
- /// </param>
- /// <param name="e">
- /// The EncodeProgressEventArgs.
- /// </param>
- public delegate void EncodeCompletedStatus(object sender, EncodeCompletedEventArgs e);
-
- /// <summary>
- /// The IEncode Interface
- /// </summary>
- public interface IEncode
- {
- /// <summary>
- /// Fires when a new Job starts
- /// </summary>
- event EventHandler EncodeStarted;
-
- /// <summary>
- /// Fires when a job finishes.
- /// </summary>
- event EncodeCompletedStatus EncodeCompleted;
-
- /// <summary>
- /// Encode process has progressed
- /// </summary>
- event EncodeProgessStatus EncodeStatusChanged;
-
- /// <summary>
- /// Gets a value indicating whether IsEncoding.
- /// </summary>
- bool IsEncoding { get; }
-
- /// <summary>
- /// Gets ActivityLog.
- /// </summary>
- string ActivityLog { get; }
-
- /// <summary>
- /// Gets the log index. The current log row counter.
- /// </summary>
- int LogIndex { get; }
-
- /// <summary>
- /// Gets a value indicating whether is pasued.
- /// </summary>
- bool IsPasued { get; }
-
- /// <summary>
- /// Start with a LibHb EncodeJob Object
- /// </summary>
- /// <param name="job">
- /// The job.
- /// </param>
- /// <param name="configuration">
- /// The configuration.
- /// </param>
- void Start(EncodeTask job, HBConfiguration configuration);
-
- /// <summary>
- /// The pause.
- /// </summary>
- void Pause();
-
- /// <summary>
- /// The resume.
- /// </summary>
- void Resume();
-
- /// <summary>
- /// Kill the process
- /// </summary>
- void Stop();
-
- /// <summary>
- /// Copy the log file to the desired destinations
- /// </summary>
- /// <param name="destination">
- /// The destination.
- /// </param>
- /// <param name="configuration">
- /// The configuration.
- /// </param>
- void ProcessLogs(string destination, HBConfiguration configuration);
- }
-}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs deleted file mode 100644 index 6ad5875cf..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs +++ /dev/null @@ -1,260 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="LibEncode.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// LibHB Implementation of IEncode
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Encode
-{
- using System;
- using System.Diagnostics;
-
- using HandBrake.ApplicationServices.Interop;
- using HandBrake.ApplicationServices.Interop.EventArgs;
- using HandBrake.ApplicationServices.Interop.Interfaces;
- using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Services.Encode.Factories;
- using HandBrake.ApplicationServices.Services.Encode.Interfaces;
- using HandBrake.ApplicationServices.Services.Encode.Model;
-
- /// <summary>
- /// LibHB Implementation of IEncode
- /// </summary>
- public class LibEncode : EncodeBase, IEncode
- {
- #region Private Variables
-
- private static readonly object LogLock = new object();
- private IHandBrakeInstance instance;
- private DateTime startTime;
- private EncodeTask currentTask;
- private HBConfiguration currentConfiguration;
-
- #endregion
-
- /// <summary>
- /// Gets a value indicating whether is pasued.
- /// </summary>
- public bool IsPasued { get; private set; }
-
- /// <summary>
- /// Start with a LibHb EncodeJob Object
- /// </summary>
- /// <param name="task">
- /// The task.
- /// </param>
- /// <param name="configuration">
- /// The configuration.
- /// </param>
- public void Start(EncodeTask task, HBConfiguration configuration)
- {
- try
- {
- // Setup
- this.startTime = DateTime.Now;
- this.currentTask = task;
- this.currentConfiguration = configuration;
-
- // Create a new HandBrake instance
- // Setup the HandBrake Instance
- HandBrakeUtils.MessageLogged += this.HandBrakeInstanceMessageLogged;
- HandBrakeUtils.ErrorLogged += this.HandBrakeInstanceErrorLogged;
- this.instance = HandBrakeInstanceManager.GetEncodeInstance(configuration.Verbosity);
- this.instance.EncodeCompleted += this.InstanceEncodeCompleted;
- this.instance.EncodeProgress += this.InstanceEncodeProgress;
-
- // Sanity Checking and Setup
- if (this.IsEncoding)
- {
- throw new Exception("HandBrake is already encoding.");
- }
-
- this.IsEncoding = true;
- this.SetupLogging();
-
- // Verify the Destination Path Exists, and if not, create it.
- this.VerifyEncodeDestinationPath(task);
-
- ServiceLogMessage("Starting Encode ...");
-
- // Get an EncodeJob object for the Interop Library
- instance.StartEncode(EncodeFactory.Create(task, configuration));
-
- // Fire the Encode Started Event
- this.InvokeEncodeStarted(System.EventArgs.Empty);
-
- // Set the Process Priority
- switch (configuration.ProcessPriority)
- {
- case "Realtime":
- Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime;
- break;
- case "High":
- Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;
- break;
- case "Above Normal":
- Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.AboveNormal;
- break;
- case "Normal":
- Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal;
- break;
- case "Low":
- Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Idle;
- break;
- default:
- Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.BelowNormal;
- break;
- }
- }
- catch (Exception exc)
- {
- this.IsEncoding = false;
-
- ServiceLogMessage("Failed to start encoding ..." + Environment.NewLine + exc);
- this.InvokeEncodeCompleted(new EventArgs.EncodeCompletedEventArgs(false, exc, "Unable to start encoding", task.Source));
- }
- }
-
- /// <summary>
- /// Pause the currently running encode.
- /// </summary>
- public void Pause()
- {
- if (this.instance != null)
- {
- this.instance.PauseEncode();
- ServiceLogMessage("Encode Paused");
- this.IsPasued = true;
- }
- }
-
- /// <summary>
- /// Resume the currently running encode.
- /// </summary>
- public void Resume()
- {
- if (this.instance != null)
- {
- this.instance.ResumeEncode();
- ServiceLogMessage("Encode Resumed");
- this.IsPasued = false;
- }
- }
-
- /// <summary>
- /// Kill the process
- /// </summary>
- public void Stop()
- {
- try
- {
- this.IsEncoding = false;
- if (instance != null)
- {
- this.instance.StopEncode();
- ServiceLogMessage("Encode Stopped");
- }
- }
- catch (Exception exc)
- {
- Debug.WriteLine(exc);
- }
- }
-
- #region HandBrakeInstance Event Handlers.
-
- /// <summary>
- /// Log a message
- /// </summary>
- /// <param name="sender">
- /// The sender.
- /// </param>
- /// <param name="e">
- /// The MessageLoggedEventArgs.
- /// </param>
- private void HandBrakeInstanceErrorLogged(object sender, MessageLoggedEventArgs e)
- {
- lock (LogLock)
- {
- this.ProcessLogMessage(e.Message);
- }
- }
-
- /// <summary>
- /// Log a message
- /// </summary>
- /// <param name="sender">
- /// The sender.
- /// </param>
- /// <param name="e">
- /// The MessageLoggedEventArgs.
- /// </param>
- private void HandBrakeInstanceMessageLogged(object sender, MessageLoggedEventArgs e)
- {
- lock (LogLock)
- {
- this.ProcessLogMessage(e.Message);
- }
- }
-
- /// <summary>
- /// Encode Progress Event Handler
- /// </summary>
- /// <param name="sender">
- /// The sender.
- /// </param>
- /// <param name="e">
- /// The Interop.EncodeProgressEventArgs.
- /// </param>
- private void InstanceEncodeProgress(object sender, EncodeProgressEventArgs e)
- {
- EventArgs.EncodeProgressEventArgs args = new EventArgs.EncodeProgressEventArgs
- {
- AverageFrameRate = e.AverageFrameRate,
- CurrentFrameRate = e.CurrentFrameRate,
- EstimatedTimeLeft = e.EstimatedTimeLeft,
- PercentComplete = e.FractionComplete * 100,
- Task = e.Pass,
- TaskCount = e.PassCount,
- ElapsedTime = DateTime.Now - this.startTime,
- };
-
- this.InvokeEncodeStatusChanged(args);
- }
-
- /// <summary>
- /// Encode Completed Event Handler
- /// </summary>
- /// <param name="sender">
- /// The sender.
- /// </param>
- /// <param name="e">
- /// The e.
- /// </param>
- private void InstanceEncodeCompleted(object sender, EncodeCompletedEventArgs e)
- {
- this.IsEncoding = false;
- ServiceLogMessage("Encode Completed ...");
-
- // Stop Logging.
- HandBrakeUtils.MessageLogged -= this.HandBrakeInstanceMessageLogged;
- HandBrakeUtils.ErrorLogged -= this.HandBrakeInstanceErrorLogged;
-
- // Handling Log Data
- this.ProcessLogs(this.currentTask.Destination, this.currentConfiguration);
-
- // Cleanup
- this.ShutdownFileWriter();
-
- // Raise the Encode Completed EVent.
- this.InvokeEncodeCompleted(
- e.Error
- ? new EventArgs.EncodeCompletedEventArgs(false, null, string.Empty, this.currentTask.Destination)
- : new EventArgs.EncodeCompletedEventArgs(true, null, string.Empty, this.currentTask.Destination));
- }
- #endregion
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/EncodeTask.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/EncodeTask.cs deleted file mode 100644 index 8d34d230b..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/EncodeTask.cs +++ /dev/null @@ -1,543 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="EncodeTask.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// An Encode Task
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Encode.Model
-{
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
-
- using HandBrake.ApplicationServices.Services.Encode.Model.Models;
- using HandBrake.ApplicationServices.Services.Encode.Model.Models.Video;
- using HandBrake.ApplicationServices.Interop.Model;
- using HandBrake.ApplicationServices.Interop.Model.Encoding;
- using HandBrake.ApplicationServices.Utilities;
-
- /// <summary>
- /// An Encode Task
- /// </summary>
- public class EncodeTask : PropertyChangedBase
- {
- #region Private Fields
-
- /// <summary>
- /// The advanced panel enabled.
- /// </summary>
- private bool showAdvancedTab;
-
- #endregion
-
- /// <summary>
- /// Initializes a new instance of the <see cref="EncodeTask"/> class.
- /// </summary>
- public EncodeTask()
- {
- this.Cropping = new Cropping();
- this.AudioTracks = new ObservableCollection<AudioTrack>();
- this.SubtitleTracks = new ObservableCollection<SubtitleTrack>();
- this.ChapterNames = new ObservableCollection<ChapterMarker>();
- this.AllowedPassthruOptions = new AllowedPassthru();
- this.Modulus = 16;
-
- this.VideoTunes = new List<VideoTune>();
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="EncodeTask"/> class.
- /// Copy Constructor
- /// </summary>
- /// <param name="task">
- /// The task.
- /// </param>
- public EncodeTask(EncodeTask task)
- {
- this.AdvancedEncoderOptions = task.AdvancedEncoderOptions;
- this.AllowedPassthruOptions = new AllowedPassthru(task.AllowedPassthruOptions);
- this.Anamorphic = task.Anamorphic;
- this.Angle = task.Angle;
-
- this.AudioTracks = new ObservableCollection<AudioTrack>();
- foreach (AudioTrack track in task.AudioTracks)
- {
- this.AudioTracks.Add(new AudioTrack(track, true));
- }
-
- this.ChapterNames = new ObservableCollection<ChapterMarker>();
- foreach (ChapterMarker track in task.ChapterNames)
- {
- this.ChapterNames.Add(new ChapterMarker(track));
- }
-
- this.ChapterMarkersFilePath = task.ChapterMarkersFilePath;
- this.Cropping = new Cropping(task.Cropping);
- this.CustomDecomb = task.CustomDecomb;
- this.CustomDeinterlace = task.CustomDeinterlace;
- this.CustomDenoise = task.CustomDenoise;
- this.CustomDetelecine = task.CustomDetelecine;
- this.Deblock = task.Deblock;
- this.Decomb = task.Decomb;
- this.Deinterlace = task.Deinterlace;
- this.Denoise = task.Denoise;
- this.DenoisePreset = task.DenoisePreset;
- this.DenoiseTune = task.DenoiseTune;
- this.Destination = task.Destination;
- this.Detelecine = task.Detelecine;
- this.DisplayWidth = task.DisplayWidth;
- this.EndPoint = task.EndPoint;
- this.Framerate = task.Framerate;
- this.FramerateMode = task.FramerateMode;
- this.Grayscale = task.Grayscale;
- this.HasCropping = task.HasCropping;
- this.Height = task.Height;
- this.IncludeChapterMarkers = task.IncludeChapterMarkers;
- this.IPod5GSupport = task.IPod5GSupport;
- this.KeepDisplayAspect = task.KeepDisplayAspect;
- this.MaxHeight = task.MaxHeight;
- this.MaxWidth = task.MaxWidth;
- this.Modulus = task.Modulus;
- this.OptimizeMP4 = task.OptimizeMP4;
- this.OutputFormat = task.OutputFormat;
- this.PixelAspectX = task.PixelAspectX;
- this.PixelAspectY = task.PixelAspectY;
- this.PointToPointMode = task.PointToPointMode;
- this.Quality = task.Quality;
- this.Source = task.Source;
- this.StartPoint = task.StartPoint;
-
- this.SubtitleTracks = new ObservableCollection<SubtitleTrack>();
- foreach (SubtitleTrack subtitleTrack in task.SubtitleTracks)
- {
- this.SubtitleTracks.Add(new SubtitleTrack(subtitleTrack));
- }
-
- this.Title = task.Title;
- this.TurboFirstPass = task.TurboFirstPass;
- this.TwoPass = task.TwoPass;
- this.VideoBitrate = task.VideoBitrate;
- this.VideoEncoder = task.VideoEncoder;
- this.VideoEncodeRateType = task.VideoEncodeRateType;
- this.Width = task.Width;
-
- this.VideoLevel = task.VideoLevel;
- this.VideoProfile = task.VideoProfile;
- this.VideoPreset = task.VideoPreset;
- this.VideoTunes = task.VideoTunes;
- this.ExtraAdvancedArguments = task.ExtraAdvancedArguments;
-
- this.ShowAdvancedTab = task.ShowAdvancedTab;
- }
-
- #region Source
-
- /// <summary>
- /// Gets or sets Source.
- /// </summary>
- public string Source { get; set; }
-
- /// <summary>
- /// Gets or sets Title.
- /// </summary>
- public int Title { get; set; }
-
- /// <summary>
- /// Gets or sets the Angle
- /// </summary>
- public int Angle { get; set; }
-
- /// <summary>
- /// Gets or sets PointToPointMode.
- /// </summary>
- public PointToPointMode PointToPointMode { get; set; }
-
- /// <summary>
- /// Gets or sets StartPoint.
- /// </summary>
- public int StartPoint { get; set; }
-
- /// <summary>
- /// Gets or sets EndPoint.
- /// </summary>
- public int EndPoint { get; set; }
-
- #endregion
-
- #region Destination
-
- /// <summary>
- /// Gets or sets Destination.
- /// </summary>
- public string Destination { get; set; }
-
- #endregion
-
- #region Output Settings
-
- /// <summary>
- /// Gets or sets OutputFormat.
- /// </summary>
- public OutputFormat OutputFormat { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether Optimize.
- /// </summary>
- public bool OptimizeMP4 { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether IPod5GSupport.
- /// </summary>
- public bool IPod5GSupport { get; set; }
-
- #endregion
-
- #region Picture
-
- /// <summary>
- /// Gets or sets Width.
- /// </summary>
- public int? Width { get; set; }
-
- /// <summary>
- /// Gets or sets Height.
- /// </summary>
- public int? Height { get; set; }
-
- /// <summary>
- /// Gets or sets MaxWidth.
- /// </summary>
- public int? MaxWidth { get; set; }
-
- /// <summary>
- /// Gets or sets MaxHeight.
- /// </summary>
- public int? MaxHeight { get; set; }
-
- /// <summary>
- /// Gets or sets Cropping.
- /// </summary>
- public Cropping Cropping { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether HasCropping.
- /// </summary>
- public bool HasCropping { get; set; }
-
- /// <summary>
- /// Gets or sets Anamorphic.
- /// </summary>
- public Anamorphic Anamorphic { get; set; }
-
- /// <summary>
- /// Gets or sets DisplayWidth.
- /// </summary>
- public double? DisplayWidth { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether KeepDisplayAspect.
- /// </summary>
- public bool KeepDisplayAspect { get; set; }
-
- /// <summary>
- /// Gets or sets PixelAspectX.
- /// </summary>
- public int PixelAspectX { get; set; }
-
- /// <summary>
- /// Gets or sets PixelAspectY.
- /// </summary>
- public int PixelAspectY { get; set; }
-
- /// <summary>
- /// Gets or sets Modulus.
- /// </summary>
- public int? Modulus { get; set; }
-
- #endregion
-
- #region Filters
-
- /// <summary>
- /// Gets or sets Deinterlace.
- /// </summary>
- public Deinterlace Deinterlace { get; set; }
-
- /// <summary>
- /// Gets or sets CustomDeinterlace.
- /// </summary>
- public string CustomDeinterlace { get; set; }
-
- /// <summary>
- /// Gets or sets Decomb.
- /// </summary>
- public Decomb Decomb { get; set; }
-
- /// <summary>
- /// Gets or sets CustomDecomb.
- /// </summary>
- public string CustomDecomb { get; set; }
-
- /// <summary>
- /// Gets or sets Detelecine.
- /// </summary>
- public Detelecine Detelecine { get; set; }
-
- /// <summary>
- /// Gets or sets CustomDetelecine.
- /// </summary>
- public string CustomDetelecine { get; set; }
-
- /// <summary>
- /// Gets or sets Denoise.
- /// </summary>
- public Denoise Denoise { get; set; }
-
- /// <summary>
- /// Gets or sets the denoise preset.
- /// </summary>
- public DenoisePreset DenoisePreset { get; set; }
-
- /// <summary>
- /// Gets or sets the denoise tune.
- /// </summary>
- public DenoiseTune DenoiseTune { get; set; }
-
- /// <summary>
- /// Gets or sets CustomDenoise.
- /// </summary>
- public string CustomDenoise { get; set; }
-
- /// <summary>
- /// Gets or sets Deblock.
- /// </summary>
- public int Deblock { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether Grayscale.
- /// </summary>
- public bool Grayscale { get; set; }
-
- #endregion
-
- #region Video
-
- /// <summary>
- /// Gets or sets VideoEncodeRateType.
- /// </summary>
- public VideoEncodeRateType VideoEncodeRateType { get; set; }
-
- /// <summary>
- /// Gets or sets the VideoEncoder
- /// </summary>
- public VideoEncoder VideoEncoder { get; set; }
-
- /// <summary>
- /// Gets or sets the Video Encode Mode
- /// </summary>
- public FramerateMode FramerateMode { get; set; }
-
- /// <summary>
- /// Gets or sets Quality.
- /// </summary>
- public double? Quality { get; set; }
-
- /// <summary>
- /// Gets or sets VideoBitrate.
- /// </summary>
- public int? VideoBitrate { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether TwoPass.
- /// </summary>
- public bool TwoPass { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether TurboFirstPass.
- /// </summary>
- public bool TurboFirstPass { get; set; }
-
- /// <summary>
- /// Gets or sets Framerate.
- /// Null = Same as Source
- /// </summary>
- public double? Framerate { get; set; }
-
- #endregion
-
- #region Audio
-
- /// <summary>
- /// Gets or sets AudioEncodings.
- /// </summary>
- public ObservableCollection<AudioTrack> AudioTracks { get; set; }
-
- /// <summary>
- /// Gets or sets AllowedPassthruOptions.
- /// </summary>
- public AllowedPassthru AllowedPassthruOptions { get; set; }
-
- #endregion
-
- #region Subtitles
-
- /// <summary>
- /// Gets or sets SubtitleTracks.
- /// </summary>
- public ObservableCollection<SubtitleTrack> SubtitleTracks { get; set; }
-
- #endregion
-
- #region Chapters
-
- /// <summary>
- /// Gets or sets a value indicating whether IncludeChapterMarkers.
- /// </summary>
- public bool IncludeChapterMarkers { get; set; }
-
- /// <summary>
- /// Gets or sets ChapterMarkersFilePath.
- /// </summary>
- public string ChapterMarkersFilePath { get; set; }
-
- /// <summary>
- /// Gets or sets ChapterNames.
- /// </summary>
- public ObservableCollection<ChapterMarker> ChapterNames { get; set; }
-
- #endregion
-
- #region Advanced
-
- /// <summary>
- /// Gets or sets AdvancedEncoderOptions.
- /// </summary>
- public string AdvancedEncoderOptions { get; set; }
-
- /// <summary>
- /// Gets or sets the video profile.
- /// </summary>
- public VideoProfile VideoProfile { get; set; }
-
- /// <summary>
- /// Gets or sets the video level.
- /// </summary>
- public VideoLevel VideoLevel { get; set; }
-
- /// <summary>
- /// Gets or sets the video preset.
- /// </summary>
- public VideoPreset VideoPreset { get; set; }
-
- /// <summary>
- /// Gets or sets the video tunes.
- /// </summary>
- public List<VideoTune> VideoTunes { get; set; }
-
- /// <summary>
- /// Gets or sets Extra Advanced Arguments for the Video Tab.
- /// </summary>
- public string ExtraAdvancedArguments { get; set; }
-
- #endregion
-
- #region Preview
-
- /// <summary>
- /// Gets or sets a value indicating whether IsPreviewEncode.
- /// </summary>
- public bool IsPreviewEncode { get; set; }
-
- /// <summary>
- /// Gets or sets PreviewEncodeDuration.
- /// </summary>
- public int? PreviewEncodeDuration { get; set; }
-
- /// <summary>
- /// Gets or sets PreviewEncodeStartAt.
- /// </summary>
- public int? PreviewEncodeStartAt { get; set; }
-
- #endregion
-
- #region Helpers
-
- /// <summary>
- /// Gets a value indicating whether M4v extension is required.
- /// </summary>
- public bool RequiresM4v
- {
- get
- {
- if (this.OutputFormat == OutputFormat.Mp4)
- {
- bool audio =
- this.AudioTracks.Any(
- item =>
- item.Encoder == AudioEncoder.Ac3Passthrough || item.Encoder == AudioEncoder.Ac3
- || item.Encoder == AudioEncoder.DtsPassthrough || item.Encoder == AudioEncoder.Passthrough);
-
- bool subtitles = this.SubtitleTracks.Any(track => track.SubtitleType != SubtitleType.VobSub);
-
- return audio || subtitles;
- }
-
- return false;
- }
- }
-
- /// <summary>
- /// Gets or sets a value indicating whether advanced panel enabled.
- /// </summary>
- public bool ShowAdvancedTab
- {
- get
- {
- return this.showAdvancedTab;
- }
- set
- {
- if (!Equals(value, this.showAdvancedTab))
- {
- this.showAdvancedTab = value;
- this.NotifyOfPropertyChange(() => this.ShowAdvancedTab);
- }
- }
- }
-
- /// <summary>
- /// Gets the picture settings desc.
- /// </summary>
- public string PictureSettingsDesc
- {
- get
- {
- string resolution = string.Empty;
- switch (this.Anamorphic)
- {
- case Anamorphic.Strict:
- resolution = "Anamorphic: Strict";
- break;
- case Anamorphic.Loose:
- resolution = "Anamorphic: Loose, Width: " + this.Width;
- break;
- case Anamorphic.Custom:
- resolution = "Anamorphic: Custom, Resolution: " + this.Width + "x" + this.Height;
- break;
- case Anamorphic.None:
- resolution = "Resolution: " + this.Width + "x" + this.Height;
- break;
- }
-
- return resolution + Environment.NewLine + "Crop Top: " + this.Cropping.Top + ", Botton: " + this.Cropping.Bottom + ", Left: "
- + this.Cropping.Left + ", Right: " + this.Cropping.Right;
- }
- }
-
- #endregion
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AllowedPassthru.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AllowedPassthru.cs deleted file mode 100644 index 796ae3cd6..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AllowedPassthru.cs +++ /dev/null @@ -1,172 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="AllowedPassthru.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Allowed Passthru Options
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
-{
- using System.Collections.Generic;
-
- /// <summary>
- /// Allowed Passthru Options
- /// </summary>
- public class AllowedPassthru
- {
- #region Constructors and Destructors
-
- /// <summary>
- /// Initializes a new instance of the <see cref="AllowedPassthru"/> class.
- /// </summary>
- public AllowedPassthru()
- {
- this.AudioAllowAACPass = true;
- this.AudioAllowAC3Pass = true;
- this.AudioAllowDTSHDPass = true;
- this.AudioAllowDTSPass = true;
- this.AudioAllowMP3Pass = true;
- this.AudioAllowEAC3Pass = true;
- this.AudioAllowTrueHDPass = true;
- this.AudioAllowFlacPass = true;
- this.AudioEncoderFallback = AudioEncoder.Ac3;
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="AllowedPassthru"/> class.
- /// </summary>
- /// <param name="initialValue">
- /// The initial Value.
- /// </param>
- public AllowedPassthru(bool initialValue)
- {
- this.AudioAllowAACPass = initialValue;
- this.AudioAllowAC3Pass = initialValue;
- this.AudioAllowDTSHDPass = initialValue;
- this.AudioAllowDTSPass = initialValue;
- this.AudioAllowMP3Pass = initialValue;
- this.AudioAllowEAC3Pass = initialValue;
- this.AudioAllowTrueHDPass = initialValue;
- this.AudioAllowFlacPass = initialValue;
- this.AudioEncoderFallback = AudioEncoder.Ac3;
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="AllowedPassthru"/> class.
- /// Copy Constructor
- /// </summary>
- /// <param name="initialValue">
- /// The initial value.
- /// </param>
- public AllowedPassthru(AllowedPassthru initialValue)
- {
- this.AudioAllowAACPass = initialValue.AudioAllowAACPass;
- this.AudioAllowAC3Pass = initialValue.AudioAllowAC3Pass;
- this.AudioAllowDTSHDPass = initialValue.AudioAllowDTSHDPass;
- this.AudioAllowDTSPass = initialValue.AudioAllowDTSPass;
- this.AudioAllowMP3Pass = initialValue.AudioAllowMP3Pass;
- this.AudioAllowEAC3Pass = initialValue.AudioAllowEAC3Pass;
- this.AudioAllowTrueHDPass = initialValue.AudioAllowTrueHDPass;
- this.AudioAllowFlacPass = initialValue.AudioAllowFlacPass;
- this.AudioEncoderFallback = initialValue.AudioEncoderFallback;
- }
-
- #endregion
-
- #region Properties
-
- /// <summary>
- /// Gets or sets a value indicating whether AudioAllowAACPass.
- /// </summary>
- public bool AudioAllowAACPass { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether AudioAllowAC3Pass.
- /// </summary>
- public bool AudioAllowAC3Pass { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether AudioAllowDTSHDPass.
- /// </summary>
- public bool AudioAllowDTSHDPass { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether AudioAllowDTSPass.
- /// </summary>
- public bool AudioAllowDTSPass { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether AudioAllowMP3Pass.
- /// </summary>
- public bool AudioAllowMP3Pass { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether audio allow true hd pass.
- /// </summary>
- public bool AudioAllowTrueHDPass { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether audio allow flac pass.
- /// </summary>
- public bool AudioAllowFlacPass { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether audio allow ea c 3 pass.
- /// </summary>
- public bool AudioAllowEAC3Pass { get; set; }
-
- /// <summary>
- /// Gets or sets AudioEncoderFallback.
- /// </summary>
- public AudioEncoder AudioEncoderFallback { get; set; }
-
- /// <summary>
- /// Gets the allowed passthru options.
- /// </summary>
- public IEnumerable<AudioEncoder> AllowedPassthruOptions
- {
- get
- {
- List<AudioEncoder> audioEncoders = new List<AudioEncoder>();
- if (AudioAllowAACPass)
- {
- audioEncoders.Add(AudioEncoder.AacPassthru);
- }
- if (AudioAllowAC3Pass)
- {
- audioEncoders.Add(AudioEncoder.Ac3Passthrough);
- }
- if (AudioAllowDTSHDPass)
- {
- audioEncoders.Add(AudioEncoder.DtsHDPassthrough);
- }
- if (AudioAllowDTSPass)
- {
- audioEncoders.Add(AudioEncoder.DtsPassthrough);
- }
- if (AudioAllowMP3Pass)
- {
- audioEncoders.Add(AudioEncoder.Mp3Passthru);
- }
- if (AudioAllowTrueHDPass)
- {
- audioEncoders.Add(AudioEncoder.TrueHDPassthrough);
- }
- if (AudioAllowFlacPass)
- {
- audioEncoders.Add(AudioEncoder.FlacPassthru);
- }
- if (AudioAllowEAC3Pass)
- {
- audioEncoders.Add(AudioEncoder.EAc3Passthrough);
- }
-
- return audioEncoders;
- }
- }
-
- #endregion
- }
-}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AudioEncoder.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AudioEncoder.cs deleted file mode 100644 index 0b152b656..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AudioEncoder.cs +++ /dev/null @@ -1,89 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="AudioEncoder.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// The audio encoder enumeration
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
-{
- using System.ComponentModel.DataAnnotations;
-
- using HandBrake.ApplicationServices.Attributes;
-
- /// <summary>
- /// The audio encoder.
- /// </summary>
- public enum AudioEncoder
- {
- [Display(Name = "AAC (avcodec)")]
- [ShortName("av_aac")]
- ffaac,
-
- [Display(Name = "AAC (FDK)")]
- [ShortName("fdk_aac")]
- fdkaac,
-
- [Display(Name = "HE-AAC (FDK)")]
- [ShortName("fdk_haac")]
- fdkheaac,
-
- [Display(Name = "MP3")]
- [ShortName("mp3")]
- Lame,
-
- [Display(Name = "AC3")]
- [ShortName("ac3")]
- Ac3,
-
- [Display(Name = "Auto Passthru")]
- [ShortName("copy")]
- Passthrough,
-
- [Display(Name = "AC3 Passthru")]
- [ShortName("copy:ac3")]
- Ac3Passthrough,
-
- [Display(Name = "E-AC3 Passthru")]
- [ShortName("copy:eac3")]
- EAc3Passthrough,
-
- [Display(Name = "DTS Passthru")]
- [ShortName("copy:dts")]
- DtsPassthrough,
-
- [Display(Name = "DTS-HD Passthru")]
- [ShortName("copy:dtshd")]
- DtsHDPassthrough,
-
- [Display(Name = "TrueHD Passthru")]
- [ShortName("copy:truehd")]
- TrueHDPassthrough,
-
- [Display(Name = "AAC Passthru")]
- [ShortName("copy:aac")]
- AacPassthru,
-
- [Display(Name = "MP3 Passthru")]
- [ShortName("copy:mp3")]
- Mp3Passthru,
-
- [Display(Name = "Vorbis")]
- [ShortName("vorbis")]
- Vorbis,
-
- [Display(Name = "FLAC 16-bit")]
- [ShortName("flac16")]
- ffflac,
-
- [Display(Name = "FLAC 24-bit")]
- [ShortName("flac24")]
- ffflac24,
-
- [Display(Name = "FLAC Passthru")]
- [ShortName("copy:flac")]
- FlacPassthru,
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AudioEncoderRateType.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AudioEncoderRateType.cs deleted file mode 100644 index fb245a9b5..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AudioEncoderRateType.cs +++ /dev/null @@ -1,31 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="AudioEncoderRateType.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// The audio encoder rate type.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
-{
- using System.ComponentModel.DataAnnotations;
-
- /// <summary>
- /// The audio encoder rate type.
- /// </summary>
- public enum AudioEncoderRateType
- {
- /// <summary>
- /// The bitrate.
- /// </summary>
- [Display(Name = "Bitrate: ")]
- Bitrate,
-
- /// <summary>
- /// The quality.
- /// </summary>
- [Display(Name = "Quality: ")]
- Quality,
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AudioTrack.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AudioTrack.cs deleted file mode 100644 index d59bf8701..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AudioTrack.cs +++ /dev/null @@ -1,636 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="AudioTrack.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Model of a HandBrake Audio Track and it's associated behaviours.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
-{
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Globalization;
- using System.Linq;
- using System.Runtime.CompilerServices;
-
- using HandBrake.ApplicationServices.Interop;
- using HandBrake.ApplicationServices.Interop.Model;
- using HandBrake.ApplicationServices.Interop.Model.Encoding;
- using HandBrake.ApplicationServices.Services.Scan.Model;
- using HandBrake.ApplicationServices.Utilities;
-
- using Newtonsoft.Json;
-
- /// <summary>
- /// Model of a HandBrake Audio Track and it's associated behaviours.
- /// </summary>
- public class AudioTrack : PropertyChangedBase
- {
- private int bitrate;
- private double drc;
- private AudioEncoder encoder;
- private int gain;
- private Mixdown mixDown;
- private double sampleRate;
- [NonSerialized]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- private Audio scannedTrack;
- private bool isDefault;
- private IEnumerable<int> bitrates;
- private IEnumerable<double> encoderQualityValues;
- private AudioEncoderRateType encoderRateType;
- private double? quality;
-
- /// <summary>
- /// Initializes a new instance of the <see cref = "AudioTrack" /> class.
- /// </summary>
- public AudioTrack()
- {
- // Default Values
- this.Encoder = AudioEncoder.ffaac;
- this.MixDown = Mixdown.DolbyProLogicII;
- this.SampleRate = 48;
- this.Bitrate = 160;
- this.DRC = 0;
- this.ScannedTrack = new Audio();
- this.TrackName = string.Empty;
-
- // Setup Backing Properties
- this.EncoderRateType = AudioEncoderRateType.Bitrate;
- this.SetupLimits();
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="AudioTrack"/> class.
- /// Copy Constructor
- /// </summary>
- /// <param name="track">
- /// The track.
- /// </param>
- /// <param name="setScannedTrack">
- /// The set Scanned Track.
- /// </param>
- public AudioTrack(AudioTrack track, bool setScannedTrack)
- {
- this.bitrate = track.Bitrate;
- this.drc = track.DRC;
- this.encoder = track.Encoder;
- this.gain = track.Gain;
- this.mixDown = track.MixDown;
- this.sampleRate = track.SampleRate;
- if (setScannedTrack)
- {
- this.scannedTrack = track.ScannedTrack ?? new Audio();
- }
- this.TrackName = track.TrackName;
- this.Quality = track.Quality;
-
- // Setup Backing Properties
- this.encoderRateType = track.EncoderRateType;
- this.SetupLimits();
- }
-
- #region Track Properties
-
- /// <summary>
- /// Gets or sets Dynamic Range Compression
- /// </summary>
- public double DRC
- {
- get
- {
- return this.drc;
- }
-
- set
- {
- if (!Equals(value, this.drc))
- {
- this.drc = value;
- this.NotifyOfPropertyChange(() => this.DRC);
- }
- }
- }
-
- /// <summary>
- /// Gets or sets the Gain for the audio track
- /// </summary>
- public int Gain
- {
- get
- {
- return this.gain;
- }
-
- set
- {
- if (!Equals(value, this.gain))
- {
- this.gain = value;
- this.NotifyOfPropertyChange(() => this.Gain);
- }
- }
- }
-
- /// <summary>
- /// Gets or sets Audio Mixdown
- /// </summary>
- public Mixdown MixDown
- {
- get
- {
- return this.mixDown;
- }
-
- set
- {
- this.mixDown = value;
- this.NotifyOfPropertyChange(() => this.MixDown);
- this.SetupLimits();
- this.NotifyOfPropertyChange(() => this.TrackReference);
- }
- }
-
- /// <summary>
- /// Gets or sets Audio Encoder
- /// </summary>
- public AudioEncoder Encoder
- {
- get
- {
- return this.encoder;
- }
-
- set
- {
- this.encoder = value;
- this.NotifyOfPropertyChange(() => this.Encoder);
- this.NotifyOfPropertyChange(() => this.IsPassthru);
- this.NotifyOfPropertyChange(() => this.IsBitrateVisible);
- this.NotifyOfPropertyChange(() => this.IsQualityVisible);
- this.NotifyOfPropertyChange(() => this.IsRateTypeVisible);
- this.SetupLimits();
- this.NotifyOfPropertyChange(() => this.TrackReference);
-
- // Refresh the available encoder rate types.
- this.NotifyOfPropertyChange(() => this.AudioEncoderRateTypes);
- if (!this.AudioEncoderRateTypes.Contains(this.EncoderRateType))
- {
- this.EncoderRateType = AudioEncoderRateType.Bitrate; // Default to bitrate.
- }
- }
- }
-
- /// <summary>
- /// Gets or sets Audio SampleRate
- /// </summary>
- public double SampleRate
- {
- get
- {
- return this.sampleRate;
- }
-
- set
- {
- this.sampleRate = value;
- this.NotifyOfPropertyChange(() => this.SampleRate);
- this.SetupLimits();
- this.NotifyOfPropertyChange(() => this.TrackReference);
- }
- }
-
- /// <summary>
- /// Gets or sets the encoder rate type.
- /// </summary>
- public AudioEncoderRateType EncoderRateType
- {
- get
- {
- return this.encoderRateType;
- }
-
- set
- {
- this.encoderRateType = value;
- this.SetupLimits();
- this.NotifyOfPropertyChange(() => this.EncoderRateType);
- this.NotifyOfPropertyChange(() => this.IsBitrateVisible);
- this.NotifyOfPropertyChange(() => this.IsQualityVisible);
-
- if (!this.Quality.HasValue)
- {
- HBAudioEncoder hbAudioEncoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(this.Encoder));
- this.Quality = HandBrakeEncoderHelpers.GetDefaultQuality(hbAudioEncoder);
- }
- }
- }
-
- /// <summary>
- /// Gets or sets Audio Bitrate
- /// </summary>
- public int Bitrate
- {
- get
- {
- return this.bitrate;
- }
-
- set
- {
- this.bitrate = value;
- this.NotifyOfPropertyChange(() => this.Bitrate);
- }
- }
-
- /// <summary>
- /// Gets or sets Audio quality
- /// </summary>
- public double? Quality
- {
- get
- {
- return this.quality;
- }
-
- set
- {
- this.quality = value;
- this.NotifyOfPropertyChange(() => this.quality);
- }
- }
-
- /// <summary>
- /// Gets or sets the track name.
- /// </summary>
- public string TrackName { get; set; }
- #endregion
-
- /// <summary>
- /// Gets AudioEncoderDisplayValue.
- /// </summary>
- [JsonIgnore]
- public string AudioEncoderDisplayValue
- {
- get
- {
- return EnumHelper<AudioEncoder>.GetDisplay(this.Encoder);
- }
- }
-
- /// <summary>
- /// Gets AudioMixdownDisplayValue.
- /// </summary>
- [JsonIgnore]
- public string AudioMixdownDisplayValue
- {
- get
- {
- return EnumHelper<Mixdown>.GetDisplay(this.MixDown);
- }
- }
-
- /// <summary>
- /// Gets the The UI display value for bit rate
- /// </summary>
- [JsonIgnore]
- public string BitRateDisplayValue
- {
- get
- {
- if (this.Encoder == AudioEncoder.Ac3Passthrough || this.Encoder == AudioEncoder.DtsPassthrough
- || this.Encoder == AudioEncoder.DtsHDPassthrough)
- {
- return "Auto";
- }
-
- return this.Bitrate.ToString();
- }
- }
-
- /// <summary>
- /// Gets or sets a value indicating whether is default.
- /// TODO - Can this be removed? May have been added as a quick fix for a styling quirk.
- /// </summary>
- [JsonIgnore]
- public bool IsDefault
- {
- get
- {
- return this.isDefault;
- }
- set
- {
- this.isDefault = value;
- }
- }
-
- /// <summary>
- /// Gets or sets the The UI display value for sample rate
- /// </summary>
- [JsonIgnore]
- public string SampleRateDisplayValue
- {
- get
- {
- return this.SampleRate == 0 ? "Auto" : this.SampleRate.ToString(CultureInfo.InvariantCulture);
- }
- set
- {
- // TODO change this to be a converted field
- if (string.IsNullOrEmpty(value))
- {
- return;
- }
-
- double samplerate;
- double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out samplerate);
-
- this.SampleRate = samplerate;
- }
- }
-
- /// <summary>
- /// Gets or sets the Scanned Audio Tracks
- /// </summary>
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public Audio ScannedTrack
- {
- get
- {
- return this.scannedTrack;
- }
-
- set
- {
- this.scannedTrack = value;
- this.NotifyOfPropertyChange(() => this.ScannedTrack);
- }
- }
-
- /// <summary>
- /// Gets the Audio Track Name
- /// </summary>
- [JsonIgnore]
- public int? Track
- {
- get
- {
- if (this.ScannedTrack != null)
- {
- return this.ScannedTrack.TrackNumber;
- }
-
- return null;
- }
- }
-
- /// <summary>
- /// Gets a value indicating whether IsPassthru.
- /// </summary>
- [JsonIgnore]
- public bool IsPassthru
- {
- get
- {
- if (this.Encoder == AudioEncoder.Ac3Passthrough || this.Encoder == AudioEncoder.DtsPassthrough
- || this.Encoder == AudioEncoder.DtsHDPassthrough || this.Encoder == AudioEncoder.AacPassthru
- || this.Encoder == AudioEncoder.Mp3Passthru || this.Encoder == AudioEncoder.Passthrough ||
- this.Encoder == AudioEncoder.EAc3Passthrough || this.Encoder == AudioEncoder.TrueHDPassthrough
- || this.Encoder == AudioEncoder.FlacPassthru)
- {
- return true;
- }
- return false;
- }
- }
-
- /// <summary>
- /// Gets the bitrates.
- /// </summary>
- [JsonIgnore]
- public IEnumerable<int> Bitrates
- {
- get
- {
- return this.bitrates;
- }
- }
-
- /// <summary>
- /// Gets the quality compression values.
- /// </summary>
- [JsonIgnore]
- public IEnumerable<double> EncoderQualityValues
- {
- get
- {
- return this.encoderQualityValues;
- }
- }
-
- /// <summary>
- /// Gets the audio encoder rate types.
- /// </summary>
- [JsonIgnore]
- public IEnumerable<AudioEncoderRateType> AudioEncoderRateTypes
- {
- get
- {
- IList<AudioEncoderRateType> types = EnumHelper<AudioEncoderRateType>.GetEnumList().ToList();
- HBAudioEncoder hbaenc = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(this.Encoder));
- if (hbaenc == null || !hbaenc.SupportsQuality)
- {
- types.Remove(AudioEncoderRateType.Quality);
- }
-
- return types;
- }
- }
-
- /// <summary>
- /// Gets a value indicating whether can set bitrate.
- /// </summary>
- [JsonIgnore]
- public bool IsBitrateVisible
- {
- get
- {
- if (this.IsPassthru || this.Encoder == AudioEncoder.ffflac || this.Encoder == AudioEncoder.ffflac24)
- {
- return false;
- }
-
- return Equals(this.EncoderRateType, AudioEncoderRateType.Bitrate);
- }
- }
-
- /// <summary>
- /// Gets a value indicating whether is quality visible.
- /// </summary>
- [JsonIgnore]
- public bool IsQualityVisible
- {
- get
- {
- if (this.IsPassthru || this.Encoder == AudioEncoder.ffflac || this.Encoder == AudioEncoder.ffflac24)
- {
- return false;
- }
-
- return Equals(this.EncoderRateType, AudioEncoderRateType.Quality);
- }
- }
-
- /// <summary>
- /// Gets a value indicating whether is rate type visible.
- /// </summary>
- [JsonIgnore]
- public bool IsRateTypeVisible
- {
- get
- {
- if (this.IsPassthru || this.Encoder == AudioEncoder.ffflac || this.Encoder == AudioEncoder.ffflac24)
- {
- return false;
- }
-
- return true;
- }
- }
-
- /// <summary>
- /// Gets a value indicating whether IsLossless.
- /// </summary>
- [JsonIgnore]
- public bool IsLossless
- {
- get
- {
- return this.IsPassthru || this.Encoder == AudioEncoder.ffflac || this.Encoder == AudioEncoder.ffflac24;
- }
- }
-
- /// <summary>
- /// Gets TrackReference.
- /// </summary>
- [JsonIgnore]
- public AudioTrack TrackReference
- {
- get { return this; }
- }
-
- #region Handler Methods
-
- /// <summary>
- /// The setup limits.
- /// </summary>
- private void SetupLimits()
- {
- this.SetupBitrateLimits();
- this.SetupQualityCompressionLimits();
- }
-
- /// <summary>
- /// The calculate bitrate limits.
- /// </summary>
- private void SetupBitrateLimits()
- {
- // Base set of bitrates available.
- List<int> audioBitrates = HandBrakeEncoderHelpers.AudioBitrates;
-
- // Defaults
- int max = 256;
- int low = 32;
-
- // Based on the users settings, find the high and low bitrates.
- HBAudioEncoder hbaenc = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(this.Encoder));
- HBRate rate = HandBrakeEncoderHelpers.AudioSampleRates.FirstOrDefault(t => t.Name == this.SampleRate.ToString(CultureInfo.InvariantCulture));
- HBMixdown mixdown = HandBrakeEncoderHelpers.GetMixdown(EnumHelper<Mixdown>.GetShortName(this.MixDown));
-
- BitrateLimits limits = HandBrakeEncoderHelpers.GetBitrateLimits(hbaenc, rate != null ? rate.Rate : 48000, mixdown);
- if (limits != null)
- {
- max = limits.High;
- low = limits.Low;
- }
-
- // Return the subset of available bitrates.
- List<int> subsetBitrates = audioBitrates.Where(b => b <= max && b >= low).ToList();
- this.bitrates = subsetBitrates;
- this.NotifyOfPropertyChange(() => this.Bitrates);
-
- // If the subset does not contain the current bitrate, request the default.
- if (!subsetBitrates.Contains(this.Bitrate))
- {
- this.Bitrate = HandBrakeEncoderHelpers.GetDefaultBitrate(hbaenc, rate != null ? rate.Rate : 48000, mixdown);
- }
- }
-
- /// <summary>
- /// The setup quality compression limits.
- /// </summary>
- private void SetupQualityCompressionLimits()
- {
- HBAudioEncoder hbAudioEncoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(this.Encoder));
- if (hbAudioEncoder.SupportsQuality)
- {
- RangeLimits limits = null;
-
- if (hbAudioEncoder.SupportsQuality)
- {
- limits = hbAudioEncoder.QualityLimits;
- }
-
- if (limits != null)
- {
- double value = limits.Ascending ? limits.Low : limits.High;
- List<double> values = new List<double> { value };
-
- if (limits.Ascending)
- {
- while (value < limits.High)
- {
- value += limits.Granularity;
- values.Add(value);
- }
- }
- else
- {
- while (value > limits.Low)
- {
- value -= limits.Granularity;
- values.Add(value);
- }
- }
-
- this.encoderQualityValues = values;
- }
- else
- {
- this.encoderQualityValues = new List<double>();
- }
- }
- else
- {
- this.encoderQualityValues = new List<double>();
- }
-
- // Default the audio quality value if it's out of range.
- if (Equals(this.EncoderRateType, AudioEncoderRateType.Quality))
- {
- if (this.Quality.HasValue && !this.encoderQualityValues.Contains(this.Quality.Value))
- {
- this.Quality = HandBrakeEncoderHelpers.GetDefaultQuality(hbAudioEncoder);
- }
- }
-
- this.NotifyOfPropertyChange(() => this.EncoderQualityValues);
- }
-
- #endregion
- }
-}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/ChapterMarker.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/ChapterMarker.cs deleted file mode 100644 index 6792a1394..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/ChapterMarker.cs +++ /dev/null @@ -1,92 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="ChapterMarker.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// A Movie Chapter
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
-{
- using System;
-
- using HandBrake.ApplicationServices.Utilities;
-
- /// <summary>
- /// A Movie Chapter
- /// </summary>
- public class ChapterMarker : PropertyChangedBase
- {
- /// <summary>
- /// Backing field for chapter name
- /// </summary>
- private string chapterName;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="ChapterMarker"/> class.
- /// </summary>
- public ChapterMarker()
- {
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="ChapterMarker"/> class.
- /// </summary>
- /// <param name="number">
- /// The number.
- /// </param>
- /// <param name="name">
- /// The name.
- /// </param>
- /// <param name="duration">
- /// The duration.
- /// </param>
- public ChapterMarker(int number, string name, TimeSpan duration)
- {
- this.ChapterName = name;
- this.ChapterNumber = number;
- this.Duration = duration;
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="ChapterMarker"/> class.
- /// Copy Constructor
- /// </summary>
- /// <param name="chapter">
- /// The chapter.
- /// </param>
- public ChapterMarker(ChapterMarker chapter)
- {
- this.ChapterName = chapter.ChapterName;
- this.ChapterNumber = chapter.ChapterNumber;
- this.Duration = chapter.Duration;
- }
-
- /// <summary>
- /// Gets or sets The number of this Chapter, in regards to it's parent Title
- /// </summary>
- public int ChapterNumber { get; set; }
-
- /// <summary>
- /// Gets or sets the duration.
- /// </summary>
- public TimeSpan Duration { get; set; }
-
- /// <summary>
- /// Gets or sets ChapterName.
- /// </summary>
- public string ChapterName
- {
- get
- {
- return this.chapterName;
- }
- set
- {
- this.chapterName = value;
- this.NotifyOfPropertyChange(() => this.ChapterName);
- }
- }
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/DenoisePreset.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/DenoisePreset.cs deleted file mode 100644 index 10b28140b..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/DenoisePreset.cs +++ /dev/null @@ -1,45 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="DenoisePreset.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Defines the DenoisePreset type.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
-{
- using System.ComponentModel.DataAnnotations;
-
- using HandBrake.ApplicationServices.Attributes;
-
- /// <summary>
- /// The denoise preset.
- /// </summary>
- public enum DenoisePreset
- {
- [Display(Name = "Weak")]
- [ShortName("weak")]
- Weak = 0,
-
- [Display(Name = "Medium")]
- [ShortName("medium")]
- Medium,
-
- [Display(Name = "Strong")]
- [ShortName("strong")]
- Strong,
-
- [Display(Name = "Custom")]
- [ShortName("custom")]
- Custom,
-
- [Display(Name = "Ultralight")] // NLMeans only
- [ShortName("ultralight")]
- Ultralight,
-
- [Display(Name = "Light")] // NLMeans only
- [ShortName("light")]
- Light,
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/DenoiseTune.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/DenoiseTune.cs deleted file mode 100644 index f58834d81..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/DenoiseTune.cs +++ /dev/null @@ -1,41 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="DenoiseTune.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Defines the DenoiseTune type.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
-{
- using System.ComponentModel.DataAnnotations;
-
- using HandBrake.ApplicationServices.Attributes;
-
- /// <summary>
- /// The denoise tune.
- /// </summary>
- public enum DenoiseTune
- {
- [Display(Name = "None")]
- [ShortName("none")]
- None = 0,
-
- [Display(Name = "Film")]
- [ShortName("film")]
- Film,
-
- [Display(Name = "Grain")]
- [ShortName("grain")]
- Grain,
-
- [Display(Name = "High Motion")]
- [ShortName("highmotion")]
- HighMotion,
-
- [Display(Name = "Animation")]
- [ShortName("animation")]
- Animation,
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/FramerateMode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/FramerateMode.cs deleted file mode 100644 index c61abd40b..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/FramerateMode.cs +++ /dev/null @@ -1,28 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="FramerateMode.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// The Mode of Video Encoding. CFR, VFR, PFR
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
-{
- using HandBrake.ApplicationServices.Attributes;
-
- /// <summary>
- /// The Mode of Video Encoding. CFR, VFR, PFR
- /// </summary>
- public enum FramerateMode
- {
- [ShortName("cfr")]
- CFR = 0,
-
- [ShortName("pfr")]
- PFR,
-
- [ShortName("vfr")]
- VFR
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/OutputFormat.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/OutputFormat.cs deleted file mode 100644 index 8f01b3f6b..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/OutputFormat.cs +++ /dev/null @@ -1,32 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="OutputFormat.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// The Output format.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
-{
- using System.ComponentModel;
- using System.ComponentModel.DataAnnotations;
-
- using HandBrake.ApplicationServices.Attributes;
-
- /// <summary>
- /// The Output format.
- /// </summary>
- public enum OutputFormat
- {
- [Description("MP4")]
- [Display(Name = "MP4")]
- [ShortName("av_mp4")]
- Mp4 = 0,
-
- [Description("MKV")]
- [Display(Name = "MKV")]
- [ShortName("av_mkv")]
- Mkv,
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/PointToPointMode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/PointToPointMode.cs deleted file mode 100644 index 17d2316cb..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/PointToPointMode.cs +++ /dev/null @@ -1,31 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="PointToPointMode.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Point to Point Mode
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
-{
- using System.ComponentModel.DataAnnotations;
-
- /// <summary>
- /// Point to Point Mode
- /// </summary>
- public enum PointToPointMode
- {
- [Display(Name = "Chapters")]
- Chapters = 0,
-
- [Display(Name = "Seconds")]
- Seconds,
-
- [Display(Name = "Frames")]
- Frames,
-
- [Display(Name = "Preview")]
- Preview,
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/SubtitleTrack.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/SubtitleTrack.cs deleted file mode 100644 index a7d11c670..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/SubtitleTrack.cs +++ /dev/null @@ -1,274 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="SubtitleTrack.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Subtitle Information
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
-{
- using System;
-
- using HandBrake.ApplicationServices.Services.Scan.Model;
- using HandBrake.ApplicationServices.Utilities;
-
- /// <summary>
- /// Subtitle Information
- /// </summary>
- public class SubtitleTrack : PropertyChangedBase
- {
- #region Constants and Fields
-
- /// <summary>
- /// The burned in backing field.
- /// </summary>
- private bool burned;
-
- /// <summary>
- /// The is default backing field.
- /// </summary>
- private bool isDefault;
-
- /// <summary>
- /// The source track.
- /// </summary>
- private Subtitle sourceTrack;
-
- /// <summary>
- /// Backing field for the srt file name.
- /// </summary>
- private string srtFileName;
-
- /// <summary>
- /// Backing field for Forced Subs
- /// </summary>
- private bool forced;
-
- #endregion
-
- #region Constructors and Destructors
-
- /// <summary>
- /// Initializes a new instance of the <see cref="SubtitleTrack"/> class.
- /// </summary>
- public SubtitleTrack()
- {
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="SubtitleTrack"/> class.
- /// Copy Constructor
- /// </summary>
- /// <param name="subtitle">
- /// The subtitle.
- /// </param>
- public SubtitleTrack(SubtitleTrack subtitle)
- {
- this.Burned = subtitle.Burned;
- this.Default = subtitle.Default;
- this.Forced = subtitle.Forced;
- this.sourceTrack = subtitle.SourceTrack;
- this.SrtCharCode = subtitle.SrtCharCode;
- this.SrtFileName = subtitle.SrtFileName;
- this.SrtLang = subtitle.SrtLang;
- this.SrtOffset = subtitle.SrtOffset;
- this.SrtPath = subtitle.SrtPath;
- this.SubtitleType = subtitle.SubtitleType;
- this.SourceTrack = subtitle.SourceTrack;
- }
-
- #endregion
-
- #region Properties
-
- /// <summary>
- /// Gets or sets a value indicating whether Burned.
- /// </summary>
- public bool Burned
- {
- get
- {
- return this.burned;
- }
-
- set
- {
- if (!object.Equals(this.burned, value))
- {
- this.burned = value;
- this.NotifyOfPropertyChange(() => this.Burned);
-
- if (value)
- {
- this.Default = false;
- }
- }
- }
- }
-
- /// <summary>
- /// Gets or sets a value indicating whether Default.
- /// </summary>
- public bool Default
- {
- get
- {
- return this.isDefault;
- }
-
- set
- {
- if (!object.Equals(this.isDefault, value))
- {
- this.isDefault = value;
- this.NotifyOfPropertyChange(() => this.Default);
-
- if (value)
- {
- this.Burned = false;
- }
- }
- }
- }
-
- /// <summary>
- /// Gets or sets a value indicating whether Forced.
- /// </summary>
- public bool Forced
- {
- get
- {
- return this.forced;
- }
- set
- {
- this.forced = value;
- this.NotifyOfPropertyChange(() => this.Forced);
- }
- }
-
- /// <summary>
- /// Gets or sets SourceTrack.
- /// </summary>
- public Subtitle SourceTrack
- {
- get
- {
- return this.sourceTrack;
- }
-
- set
- {
- this.sourceTrack = value;
- this.NotifyOfPropertyChange(() => this.SourceTrack);
- if (this.sourceTrack != null)
- {
- this.Track = this.sourceTrack.ToString();
- }
-
- this.NotifyOfPropertyChange(() => this.CanBeBurned);
- this.NotifyOfPropertyChange(() => this.CanBeForced);
- }
- }
-
- /// <summary>
- /// Gets or sets the SRT Character Code
- /// </summary>
- public string SrtCharCode { get; set; }
-
- /// <summary>
- /// Gets or sets the SRT Filename
- /// </summary>
- public string SrtFileName
- {
- get
- {
- return srtFileName;
- }
-
- set
- {
- srtFileName = value;
- this.NotifyOfPropertyChange(() => this.IsSrtSubtitle);
- }
- }
-
- /// <summary>
- /// Gets or sets the SRT Language
- /// </summary>
- public string SrtLang { get; set; }
-
- /// <summary>
- /// Gets or sets the SRT Offset
- /// </summary>
- public int SrtOffset { get; set; }
-
- /// <summary>
- /// Gets or sets the Path to the SRT file
- /// </summary>
- public string SrtPath { get; set; }
-
- /// <summary>
- /// Gets or sets the type of the subtitle
- /// </summary>
- public SubtitleType SubtitleType { get; set; }
-
- /// <summary>
- /// Gets or sets Track.
- /// </summary>
- [Obsolete("Use SourceTrack Instead")]
- public string Track { get; set; }
-
- #endregion
-
- /// <summary>
- /// Gets a value indicating whether CanForced.
- /// </summary>
- public bool CanBeForced
- {
- get
- {
- if (this.SourceTrack != null)
- {
- return this.SourceTrack.CanForce || this.SourceTrack.SubtitleType == SubtitleType.ForeignAudioSearch;
- }
-
- return false;
- }
- }
-
- /// <summary>
- /// Gets a value indicating whether CanBeBurned.
- /// </summary>
- public bool CanBeBurned
- {
- get
- {
- if (this.SourceTrack != null)
- {
- return this.SourceTrack.CanBurnIn || this.SourceTrack.SubtitleType == SubtitleType.ForeignAudioSearch || this.SubtitleType == SubtitleType.SRT;
- }
-
- if (this.SubtitleType == SubtitleType.SRT)
- {
- return true;
- }
-
- return false;
- }
- }
-
- /// <summary>
- /// Gets a value indicating whether this is an SRT subtitle.
- /// </summary>
- public bool IsSrtSubtitle
- {
- get
- {
- return this.SrtFileName != "-" && this.SrtFileName != null;
- }
- }
- }
-}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/SubtitleType.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/SubtitleType.cs deleted file mode 100644 index 1262220e0..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/SubtitleType.cs +++ /dev/null @@ -1,38 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="SubtitleType.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Subtitle Type.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
-{
- using System.ComponentModel;
-
- /// <summary>
- /// Subtitle Type.
- /// </summary>
- public enum SubtitleType
- {
- [Description("SSA")]
- SSA,
- [Description("SRT")]
- SRT,
- [Description("VobSub")]
- VobSub,
- [Description("CC")]
- CC,
- [Description("UTF8")]
- UTF8Sub,
- [Description("TX3G")]
- TX3G,
- [Description("PGS")]
- PGS,
- [Description("Unknown")]
- Unknown,
- [Description("Foreign Audio Search")]
- ForeignAudioSearch, // Special Type for Foreign Audio Search
- }
-}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/Video/VideoLevel.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/Video/VideoLevel.cs deleted file mode 100644 index f2a402c08..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/Video/VideoLevel.cs +++ /dev/null @@ -1,118 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="VideoLevel.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// The video level.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Encode.Model.Models.Video
-{
- using HandBrake.ApplicationServices.Services.Encode.Factories;
-
- /// <summary>
- /// The video level.
- /// </summary>
- public class VideoLevel
- {
- /// <summary>
- /// An internal representation of the Auto Selection.
- /// </summary>
- public static VideoLevel Auto = new VideoLevel("Auto", "auto");
-
- /// <summary>
- /// Initializes a new instance of the <see cref="VideoLevel"/> class.
- /// </summary>
- public VideoLevel()
- {
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="VideoLevel"/> class.
- /// </summary>
- /// <param name="displayName">
- /// The display name.
- /// </param>
- /// <param name="shortName">
- /// The short name.
- /// </param>
- public VideoLevel(string displayName, string shortName)
- {
- this.DisplayName = VideoLevelFactory.GetDisplayName(displayName);
- this.ShortName = shortName;
- }
-
- /// <summary>
- /// Gets or sets the display name.
- /// </summary>
- public string DisplayName { get; set; }
-
- /// <summary>
- /// Gets or sets the short name.
- /// </summary>
- public string ShortName { get; set; }
-
- /// <summary>
- /// The clone.
- /// </summary>
- /// <returns>
- /// The <see cref="VideoProfile"/>.
- /// </returns>
- public VideoLevel Clone()
- {
- return new VideoLevel(this.DisplayName, this.ShortName);
- }
-
- /// <summary>
- /// The equals.
- /// </summary>
- /// <param name="other">
- /// The other.
- /// </param>
- /// <returns>
- /// The <see cref="bool"/>.
- /// </returns>
- protected bool Equals(VideoLevel other)
- {
- return string.Equals(this.ShortName, other.ShortName);
- }
-
- /// <summary>
- /// The equals.
- /// </summary>
- /// <param name="obj">
- /// The obj.
- /// </param>
- /// <returns>
- /// The <see cref="bool"/>.
- /// </returns>
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(null, obj))
- {
- return false;
- }
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
- if (obj.GetType() != this.GetType())
- {
- return false;
- }
- return Equals((VideoLevel)obj);
- }
-
- /// <summary>
- /// The get hash code.
- /// </summary>
- /// <returns>
- /// The <see cref="int"/>.
- /// </returns>
- public override int GetHashCode()
- {
- return (this.ShortName != null ? this.ShortName.GetHashCode() : 0);
- }
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/Video/VideoPreset.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/Video/VideoPreset.cs deleted file mode 100644 index aea598642..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/Video/VideoPreset.cs +++ /dev/null @@ -1,121 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="VideoPreset.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// The video preset.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Encode.Model.Models.Video
-{
- using HandBrake.ApplicationServices.Services.Encode.Factories;
-
- /// <summary>
- /// The video preset.
- /// </summary>
- public class VideoPreset
- {
- /// <summary>
- /// A built-in version of the "None" object.
- /// </summary>
- public static VideoPreset None = new VideoPreset("None", "none");
-
- /// <summary>
- /// Initializes a new instance of the <see cref="VideoPreset"/> class.
- /// </summary>
- public VideoPreset()
- {
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="VideoPreset"/> class.
- /// </summary>
- /// <param name="displayName">
- /// The display name.
- /// </param>
- /// <param name="shortName">
- /// The short name.
- /// </param>
- public VideoPreset(string displayName, string shortName)
- {
- this.DisplayName = VideoPresetFactory.GetDisplayName(displayName);
- this.ShortName = shortName;
- }
-
- /// <summary>
- /// Gets or sets the display name.
- /// </summary>
- public string DisplayName { get; set; }
-
- /// <summary>
- /// Gets or sets the short name.
- /// </summary>
- public string ShortName { get; set; }
-
- /// <summary>
- /// The clone.
- /// </summary>
- /// <returns>
- /// The <see cref="VideoProfile"/>.
- /// </returns>
- public VideoPreset Clone()
- {
- return new VideoPreset(this.DisplayName, this.ShortName);
- }
-
- /// <summary>
- /// The equals.
- /// </summary>
- /// <param name="other">
- /// The other.
- /// </param>
- /// <returns>
- /// The <see cref="bool"/>.
- /// </returns>
- protected bool Equals(VideoPreset other)
- {
- return string.Equals(this.ShortName, other.ShortName);
- }
-
- /// <summary>
- /// The equals.
- /// </summary>
- /// <param name="obj">
- /// The obj.
- /// </param>
- /// <returns>
- /// The <see cref="bool"/>.
- /// </returns>
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(null, obj))
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
- if (obj.GetType() != this.GetType())
- {
- return false;
- }
-
- return this.Equals((VideoPreset)obj);
- }
-
- /// <summary>
- /// The get hash code.
- /// </summary>
- /// <returns>
- /// The <see cref="int"/>.
- /// </returns>
- public override int GetHashCode()
- {
- return (this.ShortName != null ? this.ShortName.GetHashCode() : 0);
- }
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/Video/VideoProfile.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/Video/VideoProfile.cs deleted file mode 100644 index 8c528df2f..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/Video/VideoProfile.cs +++ /dev/null @@ -1,121 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="VideoProfile.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// The video profile.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Encode.Model.Models.Video
-{
- using HandBrake.ApplicationServices.Services.Encode.Factories;
-
- /// <summary>
- /// The video profile.
- /// </summary>
- public class VideoProfile
- {
- /// <summary>
- /// An internal representation of the Auto Selection.
- /// </summary>
- public static VideoProfile Auto = new VideoProfile("Auto", "auto");
-
- /// <summary>
- /// Initializes a new instance of the <see cref="VideoProfile"/> class.
- /// </summary>
- public VideoProfile()
- {
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="VideoProfile"/> class.
- /// </summary>
- /// <param name="displayName">
- /// The display name.
- /// </param>
- /// <param name="shortName">
- /// The short name.
- /// </param>
- public VideoProfile(string displayName, string shortName)
- {
- this.DisplayName = VideoProfileFactory.GetDisplayName(displayName);
- this.ShortName = shortName;
- }
-
- /// <summary>
- /// Gets or sets the display name.
- /// </summary>
- public string DisplayName { get; set; }
-
- /// <summary>
- /// Gets or sets the short name.
- /// </summary>
- public string ShortName { get; set; }
-
- /// <summary>
- /// The clone.
- /// </summary>
- /// <returns>
- /// The <see cref="VideoProfile"/>.
- /// </returns>
- public VideoProfile Clone()
- {
- return new VideoProfile(this.DisplayName, this.ShortName);
- }
-
- /// <summary>
- /// The equals.
- /// </summary>
- /// <param name="other">
- /// The other.
- /// </param>
- /// <returns>
- /// The <see cref="bool"/>.
- /// </returns>
- protected bool Equals(VideoProfile other)
- {
- return string.Equals(this.DisplayName, other.DisplayName) && string.Equals(this.ShortName, other.ShortName);
- }
-
- /// <summary>
- /// The equals.
- /// </summary>
- /// <param name="obj">
- /// The obj.
- /// </param>
- /// <returns>
- /// The <see cref="bool"/>.
- /// </returns>
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(null, obj))
- {
- return false;
- }
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
- if (obj.GetType() != this.GetType())
- {
- return false;
- }
- return Equals((VideoProfile)obj);
- }
-
- /// <summary>
- /// The get hash code.
- /// </summary>
- /// <returns>
- /// The <see cref="int"/>.
- /// </returns>
- public override int GetHashCode()
- {
- unchecked
- {
- return ((this.DisplayName != null ? this.DisplayName.GetHashCode() : 0) * 397) ^ (this.ShortName != null ? this.ShortName.GetHashCode() : 0);
- }
- }
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/Video/VideoTune.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/Video/VideoTune.cs deleted file mode 100644 index b74993307..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/Video/VideoTune.cs +++ /dev/null @@ -1,137 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="VideoTune.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// The video tune.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Encode.Model.Models.Video
-{
- using HandBrake.ApplicationServices.Services.Encode.Factories;
-
- /// <summary>
- /// The video tune.
- /// </summary>
- public class VideoTune
- {
- /// <summary>
- /// Static object to represent "None"
- /// </summary>
- public static VideoTune None = new VideoTune("None", "none");
-
- /// <summary>
- /// Static object to represent "None"
- /// </summary>
- public static VideoTune FastDecode = new VideoTune("Fast Decode", "fastdecode");
-
- /// <summary>
- /// Initializes a new instance of the <see cref="VideoTune"/> class.
- /// </summary>
- public VideoTune()
- {
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="VideoTune"/> class.
- /// </summary>
- /// <param name="displayName">
- /// The display name.
- /// </param>
- /// <param name="shortName">
- /// The short name.
- /// </param>
- public VideoTune(string displayName, string shortName)
- {
- this.DisplayName = VideoTuneFactory.GetDisplayName(displayName);
- this.ShortName = shortName;
- }
-
- /// <summary>
- /// Gets or sets the display name.
- /// </summary>
- public string DisplayName { get; set; }
-
- /// <summary>
- /// Gets or sets the short name.
- /// </summary>
- public string ShortName { get; set; }
-
- /// <summary>
- /// The clone.
- /// </summary>
- /// <returns>
- /// The <see cref="VideoProfile"/>.
- /// </returns>
- public VideoTune Clone()
- {
- return new VideoTune(this.DisplayName, this.ShortName);
- }
-
- /// <summary>
- /// The equals.
- /// </summary>
- /// <param name="other">
- /// The other.
- /// </param>
- /// <returns>
- /// The <see cref="bool"/>.
- /// </returns>
- protected bool Equals(VideoProfile other)
- {
- return string.Equals(this.DisplayName, other.DisplayName) && string.Equals(this.ShortName, other.ShortName);
- }
-
- /// <summary>
- /// The equals.
- /// </summary>
- /// <param name="other">
- /// The other.
- /// </param>
- /// <returns>
- /// The <see cref="bool"/>.
- /// </returns>
- protected bool Equals(VideoTune other)
- {
- return string.Equals(this.ShortName, other.ShortName);
- }
-
- /// <summary>
- /// The equals.
- /// </summary>
- /// <param name="obj">
- /// The obj.
- /// </param>
- /// <returns>
- /// The <see cref="bool"/>.
- /// </returns>
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(null, obj))
- {
- return false;
- }
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
- if (obj.GetType() != this.GetType())
- {
- return false;
- }
- return Equals((VideoTune)obj);
- }
-
- /// <summary>
- /// The get hash code.
- /// </summary>
- /// <returns>
- /// The <see cref="int"/>.
- /// </returns>
- public override int GetHashCode()
- {
- return (this.ShortName != null ? this.ShortName.GetHashCode() : 0);
- }
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/EventArgs/ScanCompletedEventArgs.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/EventArgs/ScanCompletedEventArgs.cs deleted file mode 100644 index c23945dd0..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Scan/EventArgs/ScanCompletedEventArgs.cs +++ /dev/null @@ -1,70 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="ScanCompletedEventArgs.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Scan Progress Event Args
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Scan.EventArgs
-{
- using System;
-
- using HandBrake.ApplicationServices.Services.Scan.Model;
-
- /// <summary>
- /// Scan Progress Event Args
- /// </summary>
- public class ScanCompletedEventArgs : EventArgs
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="ScanCompletedEventArgs"/> class.
- /// </summary>
- /// <param name="cancelled">
- /// Whether the scan was cancelled.
- /// </param>
- /// <param name="exception">
- /// The exception.
- /// </param>
- /// <param name="errorInformation">
- /// The error information.
- /// </param>
- /// <param name="scannedSource">
- /// The scanned Source.
- /// </param>
- public ScanCompletedEventArgs(bool cancelled, Exception exception, string errorInformation, Source scannedSource)
- {
- this.Successful = !cancelled && exception == null && string.IsNullOrEmpty(errorInformation) && scannedSource != null && scannedSource.Titles != null && scannedSource.Titles.Count > 0;
- this.Cancelled = cancelled;
- this.Exception = exception;
- this.ErrorInformation = errorInformation;
- this.ScannedSource = scannedSource;
- }
-
- /// <summary>
- /// Gets a value indicating whether Successful.
- /// </summary>
- public bool Successful { get; private set; }
-
- /// <summary>
- /// Gets a value indicating whether Cancelled.
- /// </summary>
- public bool Cancelled { get; private set; }
-
- /// <summary>
- /// Gets the Exception.
- /// </summary>
- public Exception Exception { get; private set; }
-
- /// <summary>
- /// Gets ErrorInformation.
- /// </summary>
- public string ErrorInformation { get; private set; }
-
- /// <summary>
- /// Gets the scanned source.
- /// </summary>
- public Source ScannedSource { get; private set; }
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/EventArgs/ScanProgressEventArgs.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/EventArgs/ScanProgressEventArgs.cs deleted file mode 100644 index 9c71cdd0f..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Scan/EventArgs/ScanProgressEventArgs.cs +++ /dev/null @@ -1,39 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="ScanProgressEventArgs.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Scan Progress Event Args
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Scan.EventArgs
-{
- using System;
- using System.Runtime.Serialization;
-
- /// <summary>
- /// Scan Progress Event Args
- /// </summary>
- [DataContract]
- public class ScanProgressEventArgs : EventArgs
- {
- /// <summary>
- /// Gets or sets the title currently being scanned.
- /// </summary>
- [DataMember]
- public int CurrentTitle { get; set; }
-
- /// <summary>
- /// Gets or sets the total number of Titles.
- /// </summary>
- [DataMember]
- public int Titles { get; set; }
-
- /// <summary>
- /// Gets or sets the percentage.
- /// </summary>
- [DataMember]
- public decimal Percentage { get; set; }
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/Interfaces/IScan.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/Interfaces/IScan.cs deleted file mode 100644 index 09f52eb66..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Scan/Interfaces/IScan.cs +++ /dev/null @@ -1,112 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="IScan.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Encode Progess Status
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Scan.Interfaces
-{
- using System;
- using System.Windows.Media.Imaging;
-
- using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Services.Encode.Model;
- using HandBrake.ApplicationServices.Services.Scan.EventArgs;
- using HandBrake.ApplicationServices.Services.Scan.Model;
-
- /// <summary>
- /// Encode Progess Status
- /// </summary>
- /// <param name="sender">
- /// The sender.
- /// </param>
- /// <param name="e">
- /// The EncodeProgressEventArgs.
- /// </param>
- public delegate void ScanProgessStatus(object sender, ScanProgressEventArgs e);
-
- /// <summary>
- /// Encode Progess Status
- /// </summary>
- /// <param name="sender">
- /// The sender.
- /// </param>
- /// <param name="e">
- /// The ScanCompletedEventArgs.
- /// </param>
- public delegate void ScanCompletedStatus(object sender, ScanCompletedEventArgs e);
-
- /// <summary>
- /// The IScan Interface
- /// </summary>
- public interface IScan
- {
- /// <summary> - /// Scan has Started - /// </summary> - event EventHandler ScanStarted; - - /// <summary> - /// Scan has completed - /// </summary>
- event ScanCompletedStatus ScanCompleted;
-
- /// <summary>
- /// Scan process has changed to a new title
- /// </summary>
- event ScanProgessStatus ScanStatusChanged;
-
- /// <summary>
- /// Gets a value indicating whether IsScanning.
- /// </summary>
- bool IsScanning { get; }
-
- /// <summary>
- /// Gets ActivityLog.
- /// </summary>
- string ActivityLog { get; }
-
- /// <summary>
- /// Scan a Source Path.
- /// Title 0: scan all
- /// </summary>
- /// <param name="sourcePath">
- /// Path to the file to scan
- /// </param>
- /// <param name="title">
- /// int title number. 0 for scan all
- /// </param>
- /// <param name="postAction">
- /// The post Action.
- /// </param>
- /// <param name="configuration">
- /// The configuraiton.
- /// </param>
- void Scan(string sourcePath, int title, Action<bool, Source> postAction, HBConfiguration configuration);
-
- /// <summary>
- /// Get a Preview image for the current job and preview number.
- /// </summary>
- /// <param name="task">
- /// The task.
- /// </param>
- /// <param name="preview">
- /// The preview.
- /// </param>
- /// <param name="configuration">
- /// The configuration.
- /// </param>
- /// <returns>
- /// The <see cref="BitmapImage"/>.
- /// </returns>
- BitmapImage GetPreview(EncodeTask task, int preview, HBConfiguration configuration);
-
- /// <summary>
- /// Kill the scan
- /// </summary>
- void Stop();
- }
-}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs deleted file mode 100644 index c7a97fa42..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs +++ /dev/null @@ -1,599 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="LibScan.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Scan a Source
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Scan
-{
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.IO;
- using System.Text;
- using System.Windows.Media.Imaging;
-
- using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Services.Encode.Model;
- using HandBrake.ApplicationServices.Services.Scan.EventArgs;
- using HandBrake.ApplicationServices.Services.Scan.Interfaces;
- using HandBrake.ApplicationServices.Services.Scan.Model;
- using HandBrake.ApplicationServices.Utilities;
- using HandBrake.ApplicationServices.Interop;
- using HandBrake.ApplicationServices.Interop.EventArgs;
- using HandBrake.ApplicationServices.Interop.HbLib;
- using HandBrake.ApplicationServices.Interop.Interfaces;
- using HandBrake.ApplicationServices.Interop.Json.Scan;
- using HandBrake.ApplicationServices.Interop.Model;
- using HandBrake.ApplicationServices.Interop.Model.Preview;
-
- using Chapter = HandBrake.ApplicationServices.Services.Scan.Model.Chapter;
- using ScanProgressEventArgs = HandBrake.ApplicationServices.Interop.EventArgs.ScanProgressEventArgs;
- using Subtitle = HandBrake.ApplicationServices.Services.Scan.Model.Subtitle;
- using SubtitleType = HandBrake.ApplicationServices.Services.Encode.Model.Models.SubtitleType;
- using Title = HandBrake.ApplicationServices.Services.Scan.Model.Title;
-
- /// <summary>
- /// Scan a Source
- /// </summary>
- public class LibScan : IScan
- {
- #region Private Variables
-
- /// <summary>
- /// Lock for the log file
- /// </summary>
- static readonly object LogLock = new object();
-
- /// <summary>
- /// Log data from HandBrakeInstance
- /// </summary>
- private readonly StringBuilder logging;
-
- /// <summary>
- /// The Log File Header
- /// </summary>
- private readonly StringBuilder header;
-
- /// <summary>
- /// The Current source scan path.
- /// </summary>
- private string currentSourceScanPath;
-
- /// <summary>
- /// The log dir.
- /// </summary>
- private static string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";
-
- /// <summary>
- /// The dvd info path.
- /// </summary>
- private string dvdInfoPath = Path.Combine(logDir, string.Format("last_scan_log{0}.txt", GeneralUtilities.ProcessId));
-
- /// <summary>
- /// The scan log.
- /// </summary>
- private StreamWriter scanLog;
-
- /// <summary>
- /// LibHB Instance
- /// </summary>
- private IHandBrakeInstance instance;
-
- /// <summary>
- /// The post scan operation.
- /// </summary>
- private Action<bool, Source> postScanOperation;
-
- #endregion
-
- /// <summary>
- /// Initializes a new instance of the <see cref="LibScan"/> class.
- /// </summary>
- public LibScan()
- {
- this.logging = new StringBuilder();
- this.header = GeneralUtilities.CreateLogHeader();
- this.IsScanning = false;
- }
-
- #region Events
-
- /// <summary>
- /// Scan has Started
- /// </summary>
- public event EventHandler ScanStarted;
-
- /// <summary>
- /// Scan has completed
- /// </summary>
- public event ScanCompletedStatus ScanCompleted;
-
- /// <summary>
- /// Encode process has progressed
- /// </summary>
- public event ScanProgessStatus ScanStatusChanged;
-
- #endregion
-
- #region Properties
-
- /// <summary>
- /// Gets a value indicating whether IsScanning.
- /// </summary>
- public bool IsScanning { get; private set; }
-
- /// <summary>
- /// Gets ActivityLog.
- /// </summary>
- public string ActivityLog
- {
- get
- {
- string noLog = "There is no log information to display." + Environment.NewLine + Environment.NewLine
- + "This window will only display logging information after you have scanned a source." + Environment.NewLine
- + Environment.NewLine + "You can find previous log files in the log directory or by clicking the 'Open Log Directory' button above.";
-
- return string.IsNullOrEmpty(this.logging.ToString()) ? noLog : this.header + this.logging.ToString();
- }
- }
-
- #endregion
-
- #region Public Methods
-
- /// <summary>
- /// Scan a Source Path.
- /// Title 0: scan all
- /// </summary>
- /// <param name="sourcePath">
- /// Path to the file to scan
- /// </param>
- /// <param name="title">
- /// int title number. 0 for scan all
- /// </param>
- /// <param name="postAction">
- /// The post Action.
- /// </param>
- /// <param name="configuraiton">
- /// The configuraiton.
- /// </param>
- public void Scan(string sourcePath, int title, Action<bool, Source> postAction, HBConfiguration configuraiton)
- {
- // Try to cleanup any previous scan instances.
- if (this.instance != null)
- {
- try
- {
- lock (LogLock)
- {
- this.scanLog.Close();
- this.scanLog.Dispose();
- this.scanLog = null;
- }
- this.instance.Dispose();
- }
- catch (Exception)
- {
- // Do Nothing
- }
- }
-
- // Handle the post scan operation.
- this.postScanOperation = postAction;
-
- // Clear down the logging
- this.logging.Clear();
-
- try
- {
- // Make we don't pick up a stale last_scan_log_xyz.txt (and that we have rights to the file)
- if (File.Exists(this.dvdInfoPath))
- {
- File.Delete(this.dvdInfoPath);
- }
- }
- catch (Exception exc)
- {
- Debug.WriteLine(exc);
- }
-
- if (!Directory.Exists(Path.GetDirectoryName(this.dvdInfoPath)))
- {
- Directory.CreateDirectory(Path.GetDirectoryName(this.dvdInfoPath));
- }
-
- // Create a new scan log.
- this.scanLog = new StreamWriter(this.dvdInfoPath);
-
- // Create a new HandBrake Instance.
- HandBrakeUtils.MessageLogged += this.HandBrakeInstanceMessageLogged;
- HandBrakeUtils.ErrorLogged += this.HandBrakeInstanceErrorLogged;
- this.instance = HandBrakeInstanceManager.GetScanInstance(configuraiton.Verbosity);
- this.instance.ScanProgress += this.InstanceScanProgress;
- this.instance.ScanCompleted += this.InstanceScanCompleted;
-
- // Start the scan on a back
- this.ScanSource(sourcePath, title, configuraiton.PreviewScanCount, configuraiton);
- }
-
- /// <summary>
- /// Kill the scan
- /// </summary>
- public void Stop()
- {
- try
- {
- ServiceLogMessage("Stopping Scan.");
- this.IsScanning = false;
- this.instance.StopScan();
-
- lock (LogLock)
- {
- if (this.scanLog != null)
- {
- this.scanLog.Close();
- this.scanLog.Dispose();
- this.scanLog = null;
- }
- }
- }
- catch (Exception)
- {
- // Do Nothing.
- }
- }
-
- /// <summary>
- /// Get a Preview image for the current job and preview number.
- /// </summary>
- /// <param name="job">
- /// The job.
- /// </param>
- /// <param name="preview">
- /// The preview.
- /// </param>
- /// <param name="configuraiton">
- /// The configuraiton.
- /// </param>
- /// <returns>
- /// The <see cref="BitmapImage"/>.
- /// </returns>
- public BitmapImage GetPreview(EncodeTask job, int preview, HBConfiguration configuraiton)
- {
- if (this.instance == null)
- {
- return null;
- }
-
- BitmapImage bitmapImage = null;
- try
- {
- PreviewSettings settings = new PreviewSettings
- {
- Cropping = new Cropping(job.Cropping),
- MaxWidth = job.MaxWidth ?? 0,
- MaxHeight = job.MaxHeight ?? 0,
- KeepDisplayAspect = job.KeepDisplayAspect,
- TitleNumber = job.Title,
- Anamorphic = job.Anamorphic,
- Modulus = job.Modulus,
- Width = job.Width ?? 0,
- Height = job.Height ?? 0,
- PixelAspectX = job.PixelAspectX,
- PixelAspectY = job.PixelAspectY
- };
-
- bitmapImage = this.instance.GetPreview(settings, preview);
- }
- catch (AccessViolationException e)
- {
- Console.WriteLine(e);
- }
-
- return bitmapImage;
- }
-
- #endregion
-
- #region Private Methods
-
- /// <summary>
- /// Start a scan for a given source path and title
- /// </summary>
- /// <param name="sourcePath">
- /// Path to the source file
- /// </param>
- /// <param name="title">
- /// the title number to look at
- /// </param>
- /// <param name="previewCount">
- /// The preview Count.
- /// </param>
- /// <param name="configuraiton">
- /// The configuraiton.
- /// </param>
- private void ScanSource(object sourcePath, int title, int previewCount, HBConfiguration configuraiton)
- {
- try
- {
- this.logging.Clear();
-
- string source = sourcePath.ToString().EndsWith("\\") ? string.Format("\"{0}\\\\\"", sourcePath.ToString().TrimEnd('\\'))
- : "\"" + sourcePath + "\"";
- this.currentSourceScanPath = source;
-
- this.IsScanning = true;
-
- TimeSpan minDuration = TimeSpan.FromSeconds(configuraiton.MinScanDuration);
-
- HandBrakeUtils.SetDvdNav(!configuraiton.IsDvdNavDisabled);
-
- this.ServiceLogMessage("Starting Scan ...");
- this.instance.StartScan(sourcePath.ToString(), previewCount, minDuration, title != 0 ? title : 0);
-
- if (this.ScanStarted != null)
- this.ScanStarted(this, System.EventArgs.Empty);
- }
- catch (Exception exc)
- {
- this.ServiceLogMessage("Scan Failed ..." + Environment.NewLine + exc);
- this.Stop();
-
- if (this.ScanCompleted != null)
- this.ScanCompleted(this, new ScanCompletedEventArgs(false, exc, "An Error has occured in ScanService.ScanSource()", null));
- }
- }
-
- #endregion
-
- #region HandBrakeInstance Event Handlers
- /// <summary>
- /// Scan Completed Event Handler
- /// </summary>
- /// <param name="sender">
- /// The sender.
- /// </param>
- /// <param name="e">
- /// The EventArgs.
- /// </param>
- private void InstanceScanCompleted(object sender, System.EventArgs e)
- {
- this.ServiceLogMessage("Scan Finished ...");
-
- // Write the log file out before we start processing incase we crash.
- try
- {
- if (this.scanLog != null)
- {
- this.scanLog.Flush();
- }
- }
- catch (Exception exc)
- {
- Debug.WriteLine(exc);
- }
-
- HandBrakeUtils.MessageLogged -= this.HandBrakeInstanceMessageLogged;
- HandBrakeUtils.ErrorLogged -= this.HandBrakeInstanceErrorLogged;
-
- // TODO -> Might be a better place to fix this.
- string path = this.currentSourceScanPath;
- if (this.currentSourceScanPath.Contains("\""))
- {
- path = this.currentSourceScanPath.Trim('\"');
- }
-
- // Process into internal structures.
- Source sourceData = null;
- if (this.instance != null && this.instance.Titles != null)
- {
- sourceData = new Source { Titles = ConvertTitles(this.instance.Titles), ScanPath = path };
- }
-
- this.IsScanning = false;
-
- if (this.postScanOperation != null)
- {
- try
- {
- this.postScanOperation(true, sourceData);
- }
- catch (Exception exc)
- {
- Debug.WriteLine(exc);
- }
-
- this.postScanOperation = null; // Reset
- }
- else
- {
- if (this.ScanCompleted != null) this.ScanCompleted(this, new ScanCompletedEventArgs(false, null, string.Empty, sourceData));
- }
- }
-
- /// <summary>
- /// Scan Progress Event Handler
- /// </summary>
- /// <param name="sender">
- /// The sender.
- /// </param>
- /// <param name="e">
- /// The EventArgs.
- /// </param>
- private void InstanceScanProgress(object sender, ScanProgressEventArgs e)
- {
- if (this.ScanStatusChanged != null)
- {
- EventArgs.ScanProgressEventArgs eventArgs =
- new EventArgs.ScanProgressEventArgs
- {
- CurrentTitle = e.CurrentTitle,
- Titles = e.Titles,
- Percentage = Math.Round((decimal)e.Progress * 100, 0)
- };
-
- this.ScanStatusChanged(this, eventArgs);
- }
- }
-
- /// <summary>
- /// Log a message
- /// </summary>
- /// <param name="sender">
- /// The sender.
- /// </param>
- /// <param name="e">
- /// The MessageLoggedEventArgs.
- /// </param>
- private void HandBrakeInstanceErrorLogged(object sender, MessageLoggedEventArgs e)
- {
- this.LogMessage(e.Message);
- }
-
- /// <summary>
- /// Log a message
- /// </summary>
- /// <param name="sender">
- /// The sender.
- /// </param>
- /// <param name="e">
- /// The MessageLoggedEventArgs.
- /// </param>
- private void HandBrakeInstanceMessageLogged(object sender, MessageLoggedEventArgs e)
- {
- this.LogMessage(e.Message);
- }
-
- /// <summary>
- /// Convert Interop Title objects to App Services Title object
- /// </summary>
- /// <param name="titles">
- /// The titles.
- /// </param>
- /// <returns>
- /// The convert titles.
- /// </returns>
- internal static List<Title> ConvertTitles(JsonScanObject titles)
- {
- List<Title> titleList = new List<Title>();
- foreach (SourceTitle title in titles.TitleList)
- {
- Title converted = new Title
- {
- TitleNumber = title.Index,
- Duration = new TimeSpan(0, title.Duration.Hours, title.Duration.Minutes, title.Duration.Seconds),
- Resolution = new Size(title.Geometry.Width, title.Geometry.Height),
- AngleCount = title.AngleCount,
- ParVal = new Size(title.Geometry.PAR.Num, title.Geometry.PAR.Den),
- AutoCropDimensions = new Cropping
- {
- Top = title.Crop[0],
- Bottom = title.Crop[1],
- Left = title.Crop[2],
- Right = title.Crop[3]
- },
- Fps = ((double)title.FrameRate.Num) / title.FrameRate.Den,
- SourceName = title.Path,
- MainTitle = titles.MainFeature == title.Index,
- Playlist = title.Type == 1 ? string.Format(" {0:d5}.MPLS", title.Playlist).Trim() : null,
- FramerateNumerator = title.FrameRate.Num,
- FramerateDenominator = title.FrameRate.Den
- };
-
- int currentTrack = 1;
- foreach (SourceChapter chapter in title.ChapterList)
- {
- string chapterName = !string.IsNullOrEmpty(chapter.Name) ? chapter.Name : string.Empty;
- converted.Chapters.Add(new Chapter(currentTrack, chapterName, new TimeSpan(chapter.Duration.Hours, chapter.Duration.Minutes, chapter.Duration.Seconds)));
- currentTrack++;
- }
-
- int currentAudioTrack = 1;
- foreach (SourceAudioTrack track in title.AudioList)
- {
- converted.AudioTracks.Add(new Audio(currentAudioTrack, track.Language, track.LanguageCode, track.Description, string.Empty, track.SampleRate, track.BitRate));
- currentAudioTrack++;
- }
-
- int currentSubtitleTrack = 1;
- foreach (SourceSubtitleTrack track in title.SubtitleList)
- {
- SubtitleType convertedType = new SubtitleType();
-
- switch (track.Source)
- {
- case 0:
- convertedType = SubtitleType.VobSub;
- break;
- case 4:
- convertedType = SubtitleType.UTF8Sub;
- break;
- case 5:
- convertedType = SubtitleType.TX3G;
- break;
- case 6:
- convertedType = SubtitleType.SSA;
- break;
- case 1:
- convertedType = SubtitleType.SRT;
- break;
- case 2:
- convertedType = SubtitleType.CC;
- break;
- case 3:
- convertedType = SubtitleType.CC;
- break;
- case 7:
- convertedType = SubtitleType.PGS;
- break;
- }
-
- bool canBurn = HBFunctions.hb_subtitle_can_burn(track.Source) > 0;
- bool canSetForcedOnly = HBFunctions.hb_subtitle_can_force(track.Source) > 0;
-
- converted.Subtitles.Add(new Subtitle(track.Source, currentSubtitleTrack, track.Language, track.LanguageCode, convertedType, canBurn, canSetForcedOnly));
- currentSubtitleTrack++;
- }
-
- titleList.Add(converted);
- }
-
- return titleList;
- }
-
- /// <summary>
- /// The log message.
- /// </summary>
- /// <param name="message">
- /// The message.
- /// </param>
- private void LogMessage(string message)
- {
- lock (LogLock)
- {
- if (this.scanLog != null)
- {
- this.scanLog.WriteLine(message);
- }
-
- this.logging.AppendLine(message);
- }
- }
-
- /// <summary>
- /// The service log message.
- /// </summary>
- /// <param name="message">
- /// The message.
- /// </param>
- protected void ServiceLogMessage(string message)
- {
- this.LogMessage(string.Format("# {0}", message));
- }
- #endregion
- }
-}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Audio.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Audio.cs deleted file mode 100644 index f8b40a430..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Audio.cs +++ /dev/null @@ -1,181 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="Audio.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// An object represending an AudioTrack associated with a Title, in a DVD
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Scan.Model
-{
- using System;
-
- /// <summary>
- /// An object represending an AudioTrack associated with a Title, in a DVD
- /// </summary>
- [Serializable]
- public class Audio
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="Audio"/> class.
- /// </summary>
- public Audio()
- {
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="Audio"/> class.
- /// </summary>
- /// <param name="trackNumber">
- /// The track number.
- /// </param>
- /// <param name="language">
- /// The language.
- /// </param>
- /// <param name="languageCode">
- /// The language code.
- /// </param>
- /// <param name="description">
- /// The description.
- /// </param>
- /// <param name="format">
- /// The format.
- /// </param>
- /// <param name="sampleRate">
- /// The sample rate.
- /// </param>
- /// <param name="bitrate">
- /// The bitrate.
- /// </param>
- public Audio(int trackNumber, string language, string languageCode, string description, string format, int sampleRate, int bitrate)
- {
- this.TrackNumber = trackNumber;
- this.Language = language;
- this.LanguageCode = languageCode;
- this.Description = description;
- this.Format = format;
- this.SampleRate = sampleRate;
- this.Bitrate = bitrate;
- }
-
- /// <summary>
- /// Gets or sets The track number of this Audio Track
- /// </summary>
- public int TrackNumber { get; set; }
-
- /// <summary>
- /// Gets or sets The language (if detected) of this Audio Track
- /// </summary>
- public string Language { get; set; }
-
- /// <summary>
- /// Gets or sets LanguageCode.
- /// </summary>
- public string LanguageCode { get; set; }
-
- /// <summary>
- /// Gets or sets Description.
- /// </summary>
- public string Description { get; set; }
-
- /// <summary>
- /// Gets or sets The primary format of this Audio Track
- /// </summary>
- public string Format { get; set; }
-
- /// <summary>
- /// Gets or sets The frequency (in MHz) of this Audio Track
- /// </summary>
- public int SampleRate { get; set; }
-
- /// <summary>
- /// Gets or sets The bitrate (in kbps) of this Audio Track
- /// </summary>
- public int Bitrate { get; set; }
-
- /// <summary>
- /// Override of the ToString method to make this object easier to use in the UI
- /// </summary>
- /// <returns>A string formatted as: {track #} {language} ({format}) ({sub-format})</returns>
- public override string ToString()
- {
- if (this.Description == "None Found")
- {
- return this.Description;
- }
-
- return string.Format("{0} {1}", this.TrackNumber, this.Description);
- }
-
- /// <summary>
- /// The equals.
- /// </summary>
- /// <param name="other">
- /// The other.
- /// </param>
- /// <returns>
- /// The System.Boolean.
- /// </returns>
- public bool Equals(Audio other)
- {
- if (ReferenceEquals(null, other))
- {
- return false;
- }
-
- if (ReferenceEquals(this, other))
- {
- return true;
- }
-
- return other.TrackNumber == this.TrackNumber && object.Equals(other.Language, this.Language) && object.Equals(other.LanguageCode, this.LanguageCode) && object.Equals(other.Format, this.Format);
- }
-
- /// <summary>
- /// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.
- /// </summary>
- /// <returns>
- /// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
- /// </returns>
- /// <param name="obj">The <see cref="T:System.Object"/> to compare with the current <see cref="T:System.Object"/>. </param><filterpriority>2</filterpriority>
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(null, obj))
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
- if (obj.GetType() != typeof(Audio))
- {
- return false;
- }
-
- return this.Equals((Audio)obj);
- }
-
- /// <summary>
- /// Serves as a hash function for a particular type.
- /// </summary>
- /// <returns>
- /// A hash code for the current <see cref="T:System.Object"/>.
- /// </returns>
- /// <filterpriority>2</filterpriority>
- public override int GetHashCode()
- {
- unchecked
- {
- int result = this.TrackNumber;
- result = (result * 397) ^ (this.Language != null ? this.Language.GetHashCode() : 0);
- result = (result * 397) ^ (this.LanguageCode != null ? this.LanguageCode.GetHashCode() : 0);
- result = (result * 397) ^ (this.Format != null ? this.Format.GetHashCode() : 0);
- return result;
- }
- }
- }
-}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Chapter.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Chapter.cs deleted file mode 100644 index 6bb2a3fcf..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Chapter.cs +++ /dev/null @@ -1,70 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="Chapter.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// An object representing a Chapter aosciated with a Title, in a DVD
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Scan.Model
-{
- using System;
- using System.Globalization;
-
- /// <summary>
- /// An object representing a Chapter aosciated with a Title, in a DVD
- /// </summary>
- public class Chapter
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="Chapter"/> class.
- /// </summary>
- public Chapter()
- {
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="Chapter"/> class.
- /// </summary>
- /// <param name="number">
- /// The number.
- /// </param>
- /// <param name="name">
- /// The name.
- /// </param>
- /// <param name="duration">
- /// The duration.
- /// </param>
- public Chapter(int number, string name, TimeSpan duration)
- {
- this.ChapterName = name;
- this.ChapterNumber = number;
- this.Duration = duration;
- }
-
- /// <summary>
- /// Gets or sets The number of this Chapter, in regards to it's parent Title
- /// </summary>
- public int ChapterNumber { get; set; }
-
- /// <summary>
- /// Gets or sets ChapterName.
- /// </summary>
- public string ChapterName { get; set; }
-
- /// <summary>
- /// Gets or sets The length in time this Chapter spans
- /// </summary>
- public TimeSpan Duration { get; set; }
-
- /// <summary>
- /// Override of the ToString method to make this object easier to use in the UI
- /// </summary>
- /// <returns>A string formatted as: {chapter #}</returns>
- public override string ToString()
- {
- return this.ChapterNumber.ToString(CultureInfo.InvariantCulture);
- }
- }
-}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Source.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Source.cs deleted file mode 100644 index b1418d543..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Source.cs +++ /dev/null @@ -1,58 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="Source.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// An object representing a scanned DVD
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Scan.Model
-{
- using System;
- using System.Collections.Generic;
- using System.Runtime.Serialization;
- using System.Xml.Serialization;
-
- /// <summary>
- /// An object representing a scanned DVD
- /// </summary>
- [DataContract]
- public class Source
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="Source"/> class.
- /// Default constructor for this object
- /// </summary>
- public Source()
- {
- this.Titles = new List<Title>();
- }
-
- /// <summary>
- /// Gets or sets ScanPath.
- /// The Path used by the Scan Service.
- /// </summary>
- [DataMember]
- public string ScanPath { get; set; }
-
- /// <summary>
- /// Gets or sets Titles. A list of titles from the source
- /// </summary>
- [DataMember]
- [XmlIgnore]
- public List<Title> Titles { get; set; }
-
- /// <summary>
- /// Copy this Source to another Source Model
- /// </summary>
- /// <param name="source">
- /// The source.
- /// </param>
- public void CopyTo(Source source)
- {
- source.Titles = this.Titles;
- source.ScanPath = this.ScanPath;
- }
- }
-}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Subtitle.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Subtitle.cs deleted file mode 100644 index 187ac682a..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Subtitle.cs +++ /dev/null @@ -1,206 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="Subtitle.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// An object that represents a subtitle associated with a Title, in a DVD
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Scan.Model
-{
- using System;
- using System.Xml.Serialization;
-
- using HandBrake.ApplicationServices.Services.Encode.Model.Models;
- using HandBrake.ApplicationServices.Utilities;
-
- /// <summary>
- /// An object that represents a subtitle associated with a Title, in a DVD
- /// </summary>
- public class Subtitle
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="Subtitle"/> class.
- /// </summary>
- public Subtitle()
- {
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="Subtitle"/> class.
- /// </summary>
- /// <param name="sourceId">
- /// The source Id.
- /// </param>
- /// <param name="trackNumber">
- /// The track number.
- /// </param>
- /// <param name="language">
- /// The language.
- /// </param>
- /// <param name="languageCode">
- /// The language code.
- /// </param>
- /// <param name="subtitleType">
- /// The subtitle type.
- /// </param>
- /// <param name="canBurn">
- /// The can Burn.
- /// </param>
- /// <param name="canForce">
- /// The can Force.
- /// </param>
- public Subtitle(int sourceId, int trackNumber, string language, string languageCode, SubtitleType subtitleType, bool canBurn, bool canForce)
- {
- this.SourceId = sourceId;
- this.TrackNumber = trackNumber;
- this.Language = language;
- this.LanguageCode = languageCode;
- this.SubtitleType = subtitleType;
- this.CanBurnIn = canBurn;
- this.CanForce = canForce;
- }
-
- /// <summary>
- /// Gets or sets the source id.
- /// </summary>
- public int SourceId { get; set; }
-
- /// <summary>
- /// Gets or sets the track number of this Subtitle
- /// </summary>
- public int TrackNumber { get; set; }
-
- /// <summary>
- /// Gets or sets the The language (if detected) of this Subtitle
- /// </summary>
- public string Language { get; set; }
-
- /// <summary>
- /// Gets or sets the Langauage Code
- /// </summary>
- public string LanguageCode { get; set; }
-
- /// <summary>
- /// Gets the language code clean.
- /// TODO Remove this after fixing language code.
- /// </summary>
- public string LanguageCodeClean
- {
- get
- {
- if (this.LanguageCode != null)
- {
- return this.LanguageCode.Replace("iso639-2: ", string.Empty).Trim();
- }
- return string.Empty;
- }
- }
-
- /// <summary>
- /// Gets a value indicating whether can burn in.
- /// </summary>
- [XmlIgnore]
- public bool CanBurnIn { get; private set; }
-
- /// <summary>
- /// Gets a value indicating whether can force.
- /// </summary>
- [XmlIgnore]
- public bool CanForce { get; private set; }
-
- /// <summary>
- /// Gets or sets the Subtitle Type
- /// </summary>
- public SubtitleType SubtitleType { get; set; }
-
- /// <summary>
- /// Gets Subtitle Type
- /// </summary>
- public string TypeString
- {
- get
- {
- return EnumHelper<Enum>.GetDescription(this.SubtitleType);
- }
- }
-
- /// <summary>
- /// Override of the ToString method to make this object easier to use in the UI
- /// </summary>
- /// <returns>A string formatted as: {track #} {language}</returns>
- public override string ToString()
- {
- return this.SubtitleType == SubtitleType.ForeignAudioSearch ? "Foreign Audio Scan" : string.Format("{0} {1} ({2})", this.TrackNumber, this.Language, this.TypeString);
- }
-
- /// <summary>
- /// The equals.
- /// </summary>
- /// <param name="other">
- /// The other.
- /// </param>
- /// <returns>
- /// The System.Boolean.
- /// </returns>
- public bool Equals(Subtitle other)
- {
- if (ReferenceEquals(null, other))
- {
- return false;
- }
- if (ReferenceEquals(this, other))
- {
- return true;
- }
- return other.TrackNumber == this.TrackNumber && object.Equals(other.Language, this.Language) && object.Equals(other.LanguageCode, this.LanguageCode) && object.Equals(other.SubtitleType, this.SubtitleType);
- }
-
- /// <summary>
- /// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.
- /// </summary>
- /// <returns>
- /// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
- /// </returns>
- /// <param name="obj">The <see cref="T:System.Object"/> to compare with the current <see cref="T:System.Object"/>. </param><filterpriority>2</filterpriority>
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(null, obj))
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
- if (obj.GetType() != typeof(Subtitle))
- {
- return false;
- }
-
- return this.Equals((Subtitle)obj);
- }
-
- /// <summary>
- /// Serves as a hash function for a particular type.
- /// </summary>
- /// <returns>
- /// A hash code for the current <see cref="T:System.Object"/>.
- /// </returns>
- /// <filterpriority>2</filterpriority>
- public override int GetHashCode()
- {
- unchecked
- {
- int result = this.TrackNumber;
- result = (result * 397) ^ (this.Language != null ? this.Language.GetHashCode() : 0);
- result = (result * 397) ^ (this.LanguageCode != null ? this.LanguageCode.GetHashCode() : 0);
- result = (result * 397) ^ this.SubtitleType.GetHashCode();
- return result;
- }
- }
- }
-}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Title.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Title.cs deleted file mode 100644 index 3b6061f77..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Title.cs +++ /dev/null @@ -1,159 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="Title.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// An object that represents a single Title of a DVD
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Scan.Model
-{
- using System;
- using System.Collections.Generic;
- using System.Linq;
-
- using HandBrake.ApplicationServices.Interop.Model;
-
- /// <summary>
- /// An object that represents a single Title of a DVD
- /// </summary>
- public class Title
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="Title"/> class.
- /// </summary>
- public Title()
- {
- this.AudioTracks = new List<Audio>();
- this.Chapters = new List<Chapter>();
- this.Subtitles = new List<Subtitle>();
- }
-
- #region Properties
-
- /// <summary>
- /// Gets or sets a Collection of chapters in this Title
- /// </summary>
- public List<Chapter> Chapters { get; set; }
-
- /// <summary>
- /// Gets or sets a Collection of audio tracks associated with this Title
- /// </summary>
- public List<Audio> AudioTracks { get; set; }
-
- /// <summary>
- /// Gets or sets a Collection of subtitles associated with this Title
- /// </summary>
- public List<Subtitle> Subtitles { get; set; }
-
- /// <summary>
- /// Gets or sets The track number of this Title
- /// </summary>
- public int TitleNumber { get; set; }
-
- /// <summary>
- /// Gets or sets the type.
- /// HB_DVD_TYPE, HB_BD_TYPE, HB_STREAM_TYPE, HB_FF_STREAM_TYPE
- /// </summary>
- public int Type { get; set; }
-
- /// <summary>
- /// Gets or sets Playlist.
- /// </summary>
- public string Playlist { get; set; }
-
- /// <summary>
- /// Gets or sets the length in time of this Title
- /// </summary>
- public TimeSpan Duration { get; set; }
-
- /// <summary>
- /// Gets or sets the resolution (width/height) of this Title
- /// </summary>
- public Size Resolution { get; set; }
-
- /// <summary>
- /// Gets or sets the aspect ratio of this Title
- /// </summary>
- public decimal AspectRatio { get; set; }
-
- /// <summary>
- /// Gets or sets AngleCount.
- /// </summary>
- public int AngleCount { get; set; }
-
- /// <summary>
- /// Gets or sets Par Value
- /// </summary>
- public Size ParVal { get; set; }
-
- /// <summary>
- /// Gets or sets the automatically detected crop region for this Title.
- /// This is an int array with 4 items in it as so:
- /// 0: T
- /// 1: B
- /// 2: L
- /// 3: R
- /// </summary>
- public Cropping AutoCropDimensions { get; set; }
-
- /// <summary>
- /// Gets or sets the FPS of the source.
- /// </summary>
- public double Fps { get; set; }
-
- /// <summary>
- /// Gets or sets the video frame rate numerator.
- /// </summary>
- public int FramerateNumerator { get; set; }
-
- /// <summary>
- /// Gets or sets the video frame rate denominator.
- /// </summary>
- public int FramerateDenominator { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether this is a MainTitle.
- /// </summary>
- public bool MainTitle { get; set; }
-
- /// <summary>
- /// Gets or sets the Source Name
- /// </summary>
- public string SourceName { get; set; }
-
- #endregion
-
- /// <summary>
- /// Calcuate the Duration
- /// </summary>
- /// <param name="startPoint">The Start Point (Chapters)</param>
- /// <param name="endPoint">The End Point (Chapters)</param>
- /// <returns>A Timespan</returns>
- public TimeSpan CalculateDuration(int startPoint, int endPoint)
- {
- IEnumerable<Chapter> chapers =
- this.Chapters.Where(c => c.ChapterNumber >= startPoint && c.ChapterNumber <= endPoint);
-
- TimeSpan duration = TimeSpan.FromSeconds(0.0);
- duration = chapers.Aggregate(duration, (current, chapter) => current + chapter.Duration);
-
- return duration;
- }
-
- /// <summary>
- /// Override of the ToString method to provide an easy way to use this object in the UI
- /// </summary>
- /// <returns>A string representing this track in the format: {title #} (00:00:00)</returns>
- public override string ToString()
- {
- if (!string.IsNullOrEmpty(this.Playlist) && !this.Playlist.StartsWith(" "))
- {
- this.Playlist = string.Format(" {0}", this.Playlist);
- }
-
- return string.Format("{0}{1} ({2:00}:{3:00}:{4:00})", this.TitleNumber, this.Playlist, this.Duration.Hours, this.Duration.Minutes, this.Duration.Seconds);
- }
- }
-}
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Converters/Audio/AudioBehaviourConverter.cs b/win/CS/HandBrakeWPF/Converters/Audio/AudioBehaviourConverter.cs index 7763a49d1..667e372b7 100644 --- a/win/CS/HandBrakeWPF/Converters/Audio/AudioBehaviourConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/Audio/AudioBehaviourConverter.cs @@ -18,6 +18,7 @@ namespace HandBrakeWPF.Converters.Audio using HandBrake.ApplicationServices.Utilities;
using HandBrakeWPF.Model.Audio;
+ using HandBrakeWPF.Utilities;
/// <summary>
/// Audio Behaviour Converter
diff --git a/win/CS/HandBrakeWPF/Converters/Audio/AudioEncoderConverter.cs b/win/CS/HandBrakeWPF/Converters/Audio/AudioEncoderConverter.cs index e9bb60fce..06a079f8f 100644 --- a/win/CS/HandBrakeWPF/Converters/Audio/AudioEncoderConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/Audio/AudioEncoderConverter.cs @@ -18,6 +18,8 @@ namespace HandBrakeWPF.Converters.Audio using HandBrake.ApplicationServices.Utilities;
+ using HandBrakeWPF.Utilities;
+
using AudioEncoder = HandBrakeWPF.Services.Encode.Model.Models.AudioEncoder;
using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask;
using OutputFormat = HandBrakeWPF.Services.Encode.Model.Models.OutputFormat;
diff --git a/win/CS/HandBrakeWPF/Converters/Audio/AudioQueueDisplayConverter.cs b/win/CS/HandBrakeWPF/Converters/Audio/AudioQueueDisplayConverter.cs index d3072e131..512fa0774 100644 --- a/win/CS/HandBrakeWPF/Converters/Audio/AudioQueueDisplayConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/Audio/AudioQueueDisplayConverter.cs @@ -17,6 +17,8 @@ namespace HandBrakeWPF.Converters.Audio using HandBrake.ApplicationServices.Utilities;
+ using HandBrakeWPF.Utilities;
+
using AudioEncoder = HandBrakeWPF.Services.Encode.Model.Models.AudioEncoder;
using AudioTrack = HandBrakeWPF.Services.Encode.Model.Models.AudioTrack;
diff --git a/win/CS/HandBrakeWPF/Converters/Audio/AudioRateTypeConverter.cs b/win/CS/HandBrakeWPF/Converters/Audio/AudioRateTypeConverter.cs index b7e9cd392..9808cbb58 100644 --- a/win/CS/HandBrakeWPF/Converters/Audio/AudioRateTypeConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/Audio/AudioRateTypeConverter.cs @@ -16,6 +16,8 @@ namespace HandBrakeWPF.Converters.Audio using HandBrake.ApplicationServices.Utilities;
+ using HandBrakeWPF.Utilities;
+
using AudioEncoderRateType = HandBrakeWPF.Services.Encode.Model.Models.AudioEncoderRateType;
/// <summary>
diff --git a/win/CS/HandBrakeWPF/Converters/Audio/AudioTrackDefaultBehaviourConverter.cs b/win/CS/HandBrakeWPF/Converters/Audio/AudioTrackDefaultBehaviourConverter.cs index 2c779bbce..297488b65 100644 --- a/win/CS/HandBrakeWPF/Converters/Audio/AudioTrackDefaultBehaviourConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/Audio/AudioTrackDefaultBehaviourConverter.cs @@ -18,6 +18,7 @@ namespace HandBrakeWPF.Converters.Audio using HandBrake.ApplicationServices.Utilities;
using HandBrakeWPF.Model.Audio;
+ using HandBrakeWPF.Utilities;
/// <summary>
/// Audio Behaviour Converter
diff --git a/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs b/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs index 2c9f8bd90..2f92db92c 100644 --- a/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs @@ -18,6 +18,9 @@ namespace HandBrakeWPF.Converters using HandBrake.ApplicationServices.Utilities;
using HandBrake.ApplicationServices.Interop.Model.Encoding;
+ using HandBrakeWPF.Services.Queue.Model;
+ using HandBrakeWPF.Utilities;
+
using OutputFormat = HandBrakeWPF.Services.Encode.Model.Models.OutputFormat;
using PresetPictureSettingsMode = HandBrakeWPF.Model.Picture.PresetPictureSettingsMode;
diff --git a/win/CS/HandBrake.ApplicationServices/Converters/EnumToDescConverter.cs b/win/CS/HandBrakeWPF/Converters/EnumToDescConverter.cs index d53905361..43c175e20 100644 --- a/win/CS/HandBrake.ApplicationServices/Converters/EnumToDescConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/EnumToDescConverter.cs @@ -1,60 +1,62 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="EnumToDescConverter.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Enum to Description Converter
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Converters
-{
- using System;
- using System.ComponentModel;
-
- using HandBrake.ApplicationServices.Utilities;
-
- /// <summary>
- /// Enum to Description Converter
- /// </summary>
- public class EnumToDescConverter : EnumConverter
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="EnumToDescConverter"/> class.
- /// </summary>
- /// <param name="type">
- /// The type.
- /// </param>
- public EnumToDescConverter(Type type)
- : base(type)
- {
- }
-
- /// <summary>
- /// Convert To an Object.
- /// </summary>
- /// <param name="context">
- /// The context.
- /// </param>
- /// <param name="culture">
- /// The culture.
- /// </param>
- /// <param name="value">
- /// The value.
- /// </param>
- /// <param name="destinationType">
- /// The destination type.
- /// </param>
- /// <returns>
- /// The Enum Object
- /// </returns>
- public override object ConvertTo(
- ITypeDescriptorContext context,
- System.Globalization.CultureInfo culture,
- object value,
- Type destinationType)
- {
- return EnumHelper<Enum>.GetDescription((Enum)value);
- }
- }
-}
+// -------------------------------------------------------------------------------------------------------------------- +// <copyright file="EnumToDescConverter.cs" company="HandBrake Project (http://handbrake.fr)"> +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// </copyright> +// <summary> +// Enum to Description Converter +// </summary> +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.ApplicationServices.Converters +{ + using System; + using System.ComponentModel; + + using HandBrake.ApplicationServices.Utilities; + + using HandBrakeWPF.Utilities; + + /// <summary> + /// Enum to Description Converter + /// </summary> + public class EnumToDescConverter : EnumConverter + { + /// <summary> + /// Initializes a new instance of the <see cref="EnumToDescConverter"/> class. + /// </summary> + /// <param name="type"> + /// The type. + /// </param> + public EnumToDescConverter(Type type) + : base(type) + { + } + + /// <summary> + /// Convert To an Object. + /// </summary> + /// <param name="context"> + /// The context. + /// </param> + /// <param name="culture"> + /// The culture. + /// </param> + /// <param name="value"> + /// The value. + /// </param> + /// <param name="destinationType"> + /// The destination type. + /// </param> + /// <returns> + /// The Enum Object + /// </returns> + public override object ConvertTo( + ITypeDescriptorContext context, + System.Globalization.CultureInfo culture, + object value, + Type destinationType) + { + return EnumHelper<Enum>.GetDescription((Enum)value); + } + } +} diff --git a/win/CS/HandBrakeWPF/Converters/Options/OptionsTabNameConverter.cs b/win/CS/HandBrakeWPF/Converters/Options/OptionsTabNameConverter.cs index beddd18be..b60e626f6 100644 --- a/win/CS/HandBrakeWPF/Converters/Options/OptionsTabNameConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/Options/OptionsTabNameConverter.cs @@ -16,6 +16,7 @@ namespace HandBrakeWPF.Converters.Options using HandBrake.ApplicationServices.Utilities;
using HandBrakeWPF.Model;
+ using HandBrakeWPF.Utilities;
/// <summary>
/// A Converter to get the Display Name of each options tab.
diff --git a/win/CS/HandBrakeWPF/Converters/QueueStatusToVisibilityConverter.cs b/win/CS/HandBrakeWPF/Converters/QueueStatusToVisibilityConverter.cs index 68503b741..4392c162b 100644 --- a/win/CS/HandBrakeWPF/Converters/QueueStatusToVisibilityConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/QueueStatusToVisibilityConverter.cs @@ -16,6 +16,8 @@ namespace HandBrakeWPF.Converters using HandBrake.ApplicationServices.Model;
+ using HandBrakeWPF.Services.Queue.Model;
+
/// <summary>
/// Boolean to Visibility Converter
/// </summary>
diff --git a/win/CS/HandBrakeWPF/Converters/Subtitles/SubtitleBehaviourConverter.cs b/win/CS/HandBrakeWPF/Converters/Subtitles/SubtitleBehaviourConverter.cs index e9acbe728..e488d71e8 100644 --- a/win/CS/HandBrakeWPF/Converters/Subtitles/SubtitleBehaviourConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/Subtitles/SubtitleBehaviourConverter.cs @@ -18,6 +18,7 @@ namespace HandBrakeWPF.Converters.Subtitles using HandBrake.ApplicationServices.Utilities;
using HandBrakeWPF.Model.Subtitles;
+ using HandBrakeWPF.Utilities;
/// <summary>
/// Subtitle Behaviour Converter
diff --git a/win/CS/HandBrakeWPF/Converters/Subtitles/SubtitleBurnInBehaviourConverter.cs b/win/CS/HandBrakeWPF/Converters/Subtitles/SubtitleBurnInBehaviourConverter.cs index 76be941bc..af706b4c0 100644 --- a/win/CS/HandBrakeWPF/Converters/Subtitles/SubtitleBurnInBehaviourConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/Subtitles/SubtitleBurnInBehaviourConverter.cs @@ -18,6 +18,7 @@ namespace HandBrakeWPF.Converters.Subtitles using HandBrake.ApplicationServices.Utilities;
using HandBrakeWPF.Model.Subtitles;
+ using HandBrakeWPF.Utilities;
/// <summary>
/// Subtitle Behaviour Converter
diff --git a/win/CS/HandBrakeWPF/Converters/Video/ScalingConverter.cs b/win/CS/HandBrakeWPF/Converters/Video/ScalingConverter.cs index d7f7779d5..442d525fe 100644 --- a/win/CS/HandBrakeWPF/Converters/Video/ScalingConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/Video/ScalingConverter.cs @@ -17,6 +17,7 @@ namespace HandBrakeWPF.Converters.Video using HandBrake.ApplicationServices.Utilities;
using HandBrakeWPF.Model;
+ using HandBrakeWPF.Utilities;
/// <summary>
/// Video Scaling Converter
diff --git a/win/CS/HandBrakeWPF/Converters/Video/VideoEncoderConverter.cs b/win/CS/HandBrakeWPF/Converters/Video/VideoEncoderConverter.cs index a0aba003f..eb0a9c22a 100644 --- a/win/CS/HandBrakeWPF/Converters/Video/VideoEncoderConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/Video/VideoEncoderConverter.cs @@ -18,6 +18,8 @@ namespace HandBrakeWPF.Converters.Video using HandBrake.ApplicationServices.Utilities;
using HandBrake.ApplicationServices.Interop.Model.Encoding;
+ using HandBrakeWPF.Utilities;
+
using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask;
using OutputFormat = HandBrakeWPF.Services.Encode.Model.Models.OutputFormat;
diff --git a/win/CS/HandBrakeWPF/Converters/Video/VideoOptionsTooltipConverter.cs b/win/CS/HandBrakeWPF/Converters/Video/VideoOptionsTooltipConverter.cs index edf14d6ee..3937cc373 100644 --- a/win/CS/HandBrakeWPF/Converters/Video/VideoOptionsTooltipConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/Video/VideoOptionsTooltipConverter.cs @@ -16,6 +16,8 @@ namespace HandBrakeWPF.Converters.Video using HandBrake.ApplicationServices.Utilities;
using HandBrake.ApplicationServices.Interop.Model.Encoding;
+ using HandBrakeWPF.Utilities;
+
using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask;
/// <summary>
diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index 980adffa2..d47736b6c 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -144,6 +144,7 @@ <Compile Include="Converters\Audio\AudioRateTypeConverter.cs" />
<Compile Include="Converters\Audio\AudioTrackDefaultBehaviourConverter.cs" />
<Compile Include="Converters\Audio\AudioBehaviourConverter.cs" />
+ <Compile Include="Converters\EnumToDescConverter.cs" />
<Compile Include="Converters\Filters\DenoisePresetConverter.cs" />
<Compile Include="Converters\Subtitles\SubtitleBurnInBehaviourConverter.cs" />
<Compile Include="Converters\Subtitles\SubtitleBehaviourConverter.cs" />
@@ -226,7 +227,12 @@ <Compile Include="Utilities\DelayedActionProcessor.cs" />
<Compile Include="Utilities\DPIAwareness.cs" />
<Compile Include="Utilities\DriveUtilities.cs" />
+ <Compile Include="Utilities\EnumHelper.cs" />
+ <Compile Include="Utilities\Execute.cs" />
+ <Compile Include="Utilities\ExtensionMethods.cs" />
<Compile Include="Utilities\HandBrakeApp.cs" />
+ <Compile Include="Utilities\Interfaces\INotifyPropertyChangedEx.cs" />
+ <Compile Include="Utilities\PropertyChangedBase.cs" />
<Compile Include="Utilities\Win7.cs" />
<Compile Include="ViewModels\CountdownAlertViewModel.cs" />
<Compile Include="ViewModels\Interfaces\ICountdownAlertViewModel.cs" />
diff --git a/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviours.cs b/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviours.cs index 8d49f5ab7..e88f1ade6 100644 --- a/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviours.cs +++ b/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviours.cs @@ -12,7 +12,7 @@ namespace HandBrakeWPF.Model.Audio using System.ComponentModel;
using System.Linq;
- using HandBrake.ApplicationServices.Utilities;
+ using HandBrakeWPF.Utilities;
/// <summary>
/// Audio Behaviours
diff --git a/win/CS/HandBrakeWPF/Model/Subtitles/SubtitleBehaviours.cs b/win/CS/HandBrakeWPF/Model/Subtitles/SubtitleBehaviours.cs index e31ad2042..8859b1c01 100644 --- a/win/CS/HandBrakeWPF/Model/Subtitles/SubtitleBehaviours.cs +++ b/win/CS/HandBrakeWPF/Model/Subtitles/SubtitleBehaviours.cs @@ -12,7 +12,7 @@ namespace HandBrakeWPF.Model.Subtitles using System.ComponentModel;
using System.Linq;
- using HandBrake.ApplicationServices.Utilities;
+ using HandBrakeWPF.Utilities;
/// <summary>
/// A class to track the behaviours of audio track selection
diff --git a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs index 8c60024f6..bf456c859 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs @@ -24,6 +24,8 @@ namespace HandBrakeWPF.Services.Encode.Factories using HandBrake.ApplicationServices.Model; using HandBrake.ApplicationServices.Utilities; + using HandBrakeWPF.Utilities; + using AudioEncoder = HandBrakeWPF.Services.Encode.Model.Models.AudioEncoder; using AudioEncoderRateType = HandBrakeWPF.Services.Encode.Model.Models.AudioEncoderRateType; using AudioTrack = HandBrakeWPF.Services.Encode.Model.Models.AudioTrack; diff --git a/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs b/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs index e40def17f..f4d5a988e 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs @@ -16,7 +16,8 @@ namespace HandBrakeWPF.Services.Encode.Model using HandBrake.ApplicationServices.Interop.Model; using HandBrake.ApplicationServices.Interop.Model.Encoding; - using HandBrake.ApplicationServices.Utilities; + + using HandBrakeWPF.Utilities; using AllowedPassthru = HandBrakeWPF.Services.Encode.Model.Models.AllowedPassthru; using AudioEncoder = HandBrakeWPF.Services.Encode.Model.Models.AudioEncoder; diff --git a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs index c435e88ec..dea5f41e6 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs @@ -21,6 +21,7 @@ namespace HandBrakeWPF.Services.Encode.Model.Models using HandBrake.ApplicationServices.Utilities; using HandBrakeWPF.Services.Scan.Model; + using HandBrakeWPF.Utilities; using Newtonsoft.Json; diff --git a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/ChapterMarker.cs b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/ChapterMarker.cs index da6979a4a..e2fdb25e3 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/ChapterMarker.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/ChapterMarker.cs @@ -11,7 +11,7 @@ namespace HandBrakeWPF.Services.Encode.Model.Models { using System; - using HandBrake.ApplicationServices.Utilities; + using HandBrakeWPF.Utilities; /// <summary> /// A Movie Chapter diff --git a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/SubtitleTrack.cs b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/SubtitleTrack.cs index 9f2ea9ded..b4cb45d61 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/SubtitleTrack.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/SubtitleTrack.cs @@ -11,9 +11,8 @@ namespace HandBrakeWPF.Services.Encode.Model.Models { using System; - using HandBrake.ApplicationServices.Utilities; - using HandBrakeWPF.Services.Scan.Model; + using HandBrakeWPF.Utilities; /// <summary> /// Subtitle Information diff --git a/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs b/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs index 4be9cc038..b19cd9df3 100644 --- a/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs +++ b/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs @@ -24,6 +24,7 @@ namespace HandBrakeWPF.Services.Presets.Factories using HandBrakeWPF.Model.Picture;
using HandBrakeWPF.Model.Subtitles;
using HandBrakeWPF.Services.Presets.Model;
+ using HandBrakeWPF.Utilities;
using AudioEncoder = HandBrakeWPF.Services.Encode.Model.Models.AudioEncoder;
using AudioTrack = HandBrakeWPF.Services.Encode.Model.Models.AudioTrack;
diff --git a/win/CS/HandBrakeWPF/Services/Presets/Model/Preset.cs b/win/CS/HandBrakeWPF/Services/Presets/Model/Preset.cs index 113e02e38..78ed92090 100644 --- a/win/CS/HandBrakeWPF/Services/Presets/Model/Preset.cs +++ b/win/CS/HandBrakeWPF/Services/Presets/Model/Preset.cs @@ -11,6 +11,7 @@ namespace HandBrakeWPF.Services.Presets.Model {
using HandBrakeWPF.Model.Audio;
using HandBrakeWPF.Model.Subtitles;
+ using HandBrakeWPF.Utilities;
using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask;
using PresetPictureSettingsMode = HandBrakeWPF.Model.Picture.PresetPictureSettingsMode;
@@ -23,7 +24,7 @@ namespace HandBrakeWPF.Services.Presets.Model /// https://github.com/Caliburn-Micro/Caliburn.Micro/issues/89
/// https://github.com/Caliburn-Micro/Caliburn.Micro/issues/96
/// </remarks>
- public class Preset : HandBrake.ApplicationServices.Utilities.PropertyChangedBase // Delibery not
+ public class Preset : PropertyChangedBase // Delibery not
{
#region Constants and Fields
diff --git a/win/CS/HandBrakeWPF/Services/Queue/Model/QueueItemStatus.cs b/win/CS/HandBrakeWPF/Services/Queue/Model/QueueItemStatus.cs index c60945abd..92eab43e1 100644 --- a/win/CS/HandBrakeWPF/Services/Queue/Model/QueueItemStatus.cs +++ b/win/CS/HandBrakeWPF/Services/Queue/Model/QueueItemStatus.cs @@ -7,7 +7,7 @@ // </summary>
// --------------------------------------------------------------------------------------------------------------------
-namespace HandBrake.ApplicationServices.Model
+namespace HandBrakeWPF.Services.Queue.Model
{
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
diff --git a/win/CS/HandBrakeWPF/Services/Queue/Model/QueueTask.cs b/win/CS/HandBrakeWPF/Services/Queue/Model/QueueTask.cs index 79de64c24..572300dd6 100644 --- a/win/CS/HandBrakeWPF/Services/Queue/Model/QueueTask.cs +++ b/win/CS/HandBrakeWPF/Services/Queue/Model/QueueTask.cs @@ -10,7 +10,8 @@ namespace HandBrakeWPF.Services.Queue.Model
{
using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Utilities;
+
+ using HandBrakeWPF.Utilities;
using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask;
diff --git a/win/CS/HandBrakeWPF/Services/Scan/Model/Subtitle.cs b/win/CS/HandBrakeWPF/Services/Scan/Model/Subtitle.cs index 920ef711e..3cca29ab7 100644 --- a/win/CS/HandBrakeWPF/Services/Scan/Model/Subtitle.cs +++ b/win/CS/HandBrakeWPF/Services/Scan/Model/Subtitle.cs @@ -15,6 +15,7 @@ namespace HandBrakeWPF.Services.Scan.Model using HandBrake.ApplicationServices.Utilities; using HandBrakeWPF.Services.Encode.Model.Models; + using HandBrakeWPF.Utilities; /// <summary> /// An object that represents a subtitle associated with a Title, in a DVD diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/EnumHelper.cs b/win/CS/HandBrakeWPF/Utilities/EnumHelper.cs index 0de767b85..29202efe6 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/EnumHelper.cs +++ b/win/CS/HandBrakeWPF/Utilities/EnumHelper.cs @@ -1,160 +1,160 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="EnumHelper.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Enum Helpers
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Utilities
-{
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.ComponentModel;
- using System.ComponentModel.DataAnnotations;
- using System.Diagnostics;
- using System.Linq;
- using System.Reflection;
-
- using HandBrake.ApplicationServices.Attributes;
-
- /// <summary>
- /// Enum Helpers
- /// </summary>
- /// <typeparam name="T">
- /// The Type Parameter
- /// </typeparam>
- public class EnumHelper<T>
- {
- /// <summary>
- /// Get the description of an Enum
- /// </summary>
- /// <param name="value">
- /// The value.
- /// </param>
- /// <returns>
- /// The Description string
- /// </returns>
- public static string GetDescription(T value)
- {
- FieldInfo fieldInfo = value.GetType().GetField(value.ToString());
- DescriptionAttribute[] attributes =
- (DescriptionAttribute[])fieldInfo.GetCustomAttributes(
- typeof(DescriptionAttribute), false);
- return (attributes.Length > 0) ? attributes[0].Description : value.ToString();
- }
-
- /// <summary>
- /// Get the Display Value of the Enum Model
- /// </summary>
- /// <param name="value">An Enum with Display Attributes</param>
- /// <returns>A string name</returns>
- public static string GetDisplay(T value)
- {
- FieldInfo fieldInfo = value.GetType().GetField(value.ToString());
- DisplayAttribute[] attributes = (DisplayAttribute[])fieldInfo.GetCustomAttributes(typeof(DisplayAttribute), false);
-
- return (attributes.Length > 0) ? attributes[0].Name : value.ToString();
- }
-
- /// <summary>
- /// Get the Enumeration for a given Enum Description
- /// </summary>
- /// <param name="description">The String description</param>
- /// <returns>The Enum Value</returns>
- public static T GetValue(string description)
- {
- return GetValue(description, false);
- }
-
- /// <summary>
- /// Get the Enumeration for a given Enum Description
- /// </summary>
- /// <param name="description">The String description</param>
- /// <param name="insensitiveCase">Turn of sensitivity to cases.</param>
- /// <returns>The Enum Value</returns>
- public static T GetValue(string description, bool insensitiveCase)
- {
- foreach (T val in Enum.GetValues(typeof(T)))
- {
- string currDescription = GetDescription(val);
- string currDisplay = GetDisplay(val);
- string shortName = GetShortName(val);
- if (currDescription == description || currDisplay == description || shortName == description)
- {
- return val;
- }
-
- if (insensitiveCase && (currDescription.ToLower() == description.ToLower() || currDisplay.ToLower() == description.ToLower() || shortName.ToLower() == description.ToLower()))
- {
- return val;
- }
- }
-
- Debug.WriteLine("EnumHelper.GetValue: The Description for the enum was not recognized: " + description);
-
- return default(T);
- }
-
- /// <summary>
- /// The get short name.
- /// </summary>
- /// <param name="value">
- /// The value.
- /// </param>
- /// <returns>
- /// The <see cref="string"/>.
- /// </returns>
- public static string GetShortName(T value)
- {
- FieldInfo fieldInfo = value.GetType().GetField(value.ToString());
- ShortName[] attributes = (ShortName[])fieldInfo.GetCustomAttributes(typeof(ShortName), false);
-
- return (attributes.Length > 0) ? attributes[0].Name : value.ToString();
- }
-
- /// <summary>
- /// Return a list of all the enum values.
- /// </summary>
- /// <returns>
- /// An Enum Oject List
- /// </returns>
- public static IEnumerable<T> GetEnumList()
- {
- return Enum.GetValues(typeof(T)).Cast<T>().ToList();
- }
-
- /// <summary>
- /// Get a list of string names for each enum value.
- /// </summary>
- /// <param name="enumType">
- /// The enum type.
- /// </param>
- /// <returns>
- /// A collection of strings that represent all the enum values
- /// </returns>
- public static IEnumerable<string> GetEnumDisplayValues(Type enumType)
- {
- var strings = new Collection<string>();
- foreach (T e in Enum.GetValues(enumType))
- strings.Add(GetDisplay(e));
- return strings;
- }
-
- /// <summary>
- /// Get a list of string names for each enum value passed in.
- /// </summary>
- /// <param name="items">
- /// The items.
- /// </param>
- /// <returns>
- /// A collection of strings that represent all the enum values
- /// </returns>
- public static IEnumerable<string> GetEnumDisplayValuesSubset(IEnumerable<T> items)
- {
- return items.Select(GetDisplay).ToList();
- }
- }
-}
+// -------------------------------------------------------------------------------------------------------------------- +// <copyright file="EnumHelper.cs" company="HandBrake Project (http://handbrake.fr)"> +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// </copyright> +// <summary> +// Enum Helpers +// </summary> +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.Utilities +{ + using System; + using System.Collections.Generic; + using System.Collections.ObjectModel; + using System.ComponentModel; + using System.ComponentModel.DataAnnotations; + using System.Diagnostics; + using System.Linq; + using System.Reflection; + + using HandBrake.ApplicationServices.Attributes; + + /// <summary> + /// Enum Helpers + /// </summary> + /// <typeparam name="T"> + /// The Type Parameter + /// </typeparam> + public class EnumHelper<T> + { + /// <summary> + /// Get the description of an Enum + /// </summary> + /// <param name="value"> + /// The value. + /// </param> + /// <returns> + /// The Description string + /// </returns> + public static string GetDescription(T value) + { + FieldInfo fieldInfo = value.GetType().GetField(value.ToString()); + DescriptionAttribute[] attributes = + (DescriptionAttribute[])fieldInfo.GetCustomAttributes( + typeof(DescriptionAttribute), false); + return (attributes.Length > 0) ? attributes[0].Description : value.ToString(); + } + + /// <summary> + /// Get the Display Value of the Enum Model + /// </summary> + /// <param name="value">An Enum with Display Attributes</param> + /// <returns>A string name</returns> + public static string GetDisplay(T value) + { + FieldInfo fieldInfo = value.GetType().GetField(value.ToString()); + DisplayAttribute[] attributes = (DisplayAttribute[])fieldInfo.GetCustomAttributes(typeof(DisplayAttribute), false); + + return (attributes.Length > 0) ? attributes[0].Name : value.ToString(); + } + + /// <summary> + /// Get the Enumeration for a given Enum Description + /// </summary> + /// <param name="description">The String description</param> + /// <returns>The Enum Value</returns> + public static T GetValue(string description) + { + return GetValue(description, false); + } + + /// <summary> + /// Get the Enumeration for a given Enum Description + /// </summary> + /// <param name="description">The String description</param> + /// <param name="insensitiveCase">Turn of sensitivity to cases.</param> + /// <returns>The Enum Value</returns> + public static T GetValue(string description, bool insensitiveCase) + { + foreach (T val in Enum.GetValues(typeof(T))) + { + string currDescription = GetDescription(val); + string currDisplay = GetDisplay(val); + string shortName = GetShortName(val); + if (currDescription == description || currDisplay == description || shortName == description) + { + return val; + } + + if (insensitiveCase && (currDescription.ToLower() == description.ToLower() || currDisplay.ToLower() == description.ToLower() || shortName.ToLower() == description.ToLower())) + { + return val; + } + } + + Debug.WriteLine("EnumHelper.GetValue: The Description for the enum was not recognized: " + description); + + return default(T); + } + + /// <summary> + /// The get short name. + /// </summary> + /// <param name="value"> + /// The value. + /// </param> + /// <returns> + /// The <see cref="string"/>. + /// </returns> + public static string GetShortName(T value) + { + FieldInfo fieldInfo = value.GetType().GetField(value.ToString()); + ShortName[] attributes = (ShortName[])fieldInfo.GetCustomAttributes(typeof(ShortName), false); + + return (attributes.Length > 0) ? attributes[0].Name : value.ToString(); + } + + /// <summary> + /// Return a list of all the enum values. + /// </summary> + /// <returns> + /// An Enum Oject List + /// </returns> + public static IEnumerable<T> GetEnumList() + { + return Enum.GetValues(typeof(T)).Cast<T>().ToList(); + } + + /// <summary> + /// Get a list of string names for each enum value. + /// </summary> + /// <param name="enumType"> + /// The enum type. + /// </param> + /// <returns> + /// A collection of strings that represent all the enum values + /// </returns> + public static IEnumerable<string> GetEnumDisplayValues(Type enumType) + { + var strings = new Collection<string>(); + foreach (T e in Enum.GetValues(enumType)) + strings.Add(GetDisplay(e)); + return strings; + } + + /// <summary> + /// Get a list of string names for each enum value passed in. + /// </summary> + /// <param name="items"> + /// The items. + /// </param> + /// <returns> + /// A collection of strings that represent all the enum values + /// </returns> + public static IEnumerable<string> GetEnumDisplayValuesSubset(IEnumerable<T> items) + { + return items.Select(GetDisplay).ToList(); + } + } +} diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/Execute.cs b/win/CS/HandBrakeWPF/Utilities/Execute.cs index c98140977..34fdf3a44 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/Execute.cs +++ b/win/CS/HandBrakeWPF/Utilities/Execute.cs @@ -1,153 +1,153 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright company="HandBrake Project (http://handbrake.fr)" file="Execute.cs">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Enables easy marshalling of code to the UI thread.
-// Borrowed from Caliburn Micro.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Utilities
-{
- using System;
- using System.ComponentModel;
- using System.Diagnostics;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Threading;
-
- /// <summary>
- /// Enables easy marshalling of code to the UI thread.
- /// </summary>
- public static class Execute
- {
- private static System.Action<System.Action> executor = (System.Action<System.Action>)(action => action());
- private static Dispatcher dispatcher;
- private static bool? inDesignMode;
-
- /// <summary>
- /// Gets a value indicating whether or not the framework is in design-time mode.
- /// </summary>
- public static bool InDesignMode
- {
- get
- {
- if (!Execute.inDesignMode.HasValue)
- {
- Execute.inDesignMode = new bool?((bool)DependencyPropertyDescriptor.FromProperty(DesignerProperties.IsInDesignModeProperty, typeof(FrameworkElement)).Metadata.DefaultValue);
- if (!Execute.inDesignMode.GetValueOrDefault(false) && Process.GetCurrentProcess().ProcessName.StartsWith("devenv", StringComparison.Ordinal))
- Execute.inDesignMode = new bool?(true);
- }
- return Execute.inDesignMode.GetValueOrDefault(false);
- }
- }
-
- /// <summary>
- /// Initializes the framework using the current dispatcher.
- /// </summary>
- public static void InitializeWithDispatcher()
- {
- Execute.dispatcher = Dispatcher.CurrentDispatcher;
- Execute.executor = (System.Action<System.Action>)null;
- }
-
- /// <summary>
- /// Resets the executor to use a non-dispatcher-based action executor.
- /// </summary>
- public static void ResetWithoutDispatcher()
- {
- executor = (System.Action<System.Action>)(action => action());
- dispatcher = (Dispatcher)null;
- }
-
- /// <summary>
- /// Sets a custom UI thread marshaller.
- /// </summary>
- /// <param name="marshaller">The marshaller.</param>
- [Obsolete]
- public static void SetUIThreadMarshaller(System.Action<System.Action> marshaller)
- {
- Execute.executor = marshaller;
- Execute.dispatcher = (Dispatcher)null;
- }
-
- /// <summary>
- /// The validate dispatcher.
- /// </summary>
- /// <exception cref="InvalidOperationException">
- /// Not initialized with dispatcher.
- /// </exception>
- private static void ValidateDispatcher()
- {
- if (Execute.dispatcher == null)
- throw new InvalidOperationException("Not initialized with dispatcher.");
- }
-
- /// <summary>
- /// Executes the action on the UI thread asynchronously.
- /// </summary>
- /// <param name="action">The action to execute.</param>
- public static void BeginOnUIThread(this System.Action action)
- {
- Execute.ValidateDispatcher();
- Execute.dispatcher.BeginInvoke((Delegate)action);
- }
-
- /// <summary>
- /// Executes the action on the UI thread asynchronously.
- /// </summary>
- /// <param name="action">
- /// The action to execute.
- /// </param>
- /// <returns>
- /// The <see cref="Task"/>.
- /// </returns>
- public static Task OnUIThreadAsync(this System.Action action)
- {
- Execute.ValidateDispatcher();
- TaskCompletionSource<object> taskSource = new TaskCompletionSource<object>();
- System.Action action1 = (System.Action)(() =>
- {
- try
- {
- action();
- taskSource.SetResult((object)null);
- }
- catch (Exception ex)
- {
- taskSource.SetException(ex);
- }
- });
- Execute.dispatcher.BeginInvoke((Delegate)action1);
- return (Task)taskSource.Task;
- }
-
- /// <summary>
- /// The check access.
- /// </summary>
- /// <returns>
- /// The <see cref="bool"/>.
- /// </returns>
- private static bool CheckAccess()
- {
- if (Execute.dispatcher != null)
- return Execute.dispatcher.CheckAccess();
- return true;
- }
-
- /// <summary>
- /// Executes the action on the UI thread.
- /// </summary>
- /// <param name="action">The action to execute.</param>
- public static void OnUIThread(this System.Action action)
- {
- if (Execute.executor != null)
- Execute.executor(action);
- else if (Execute.CheckAccess())
- action();
- else
- Execute.OnUIThreadAsync(action).Wait();
- }
- }
-}
+// -------------------------------------------------------------------------------------------------------------------- +// <copyright company="HandBrake Project (http://handbrake.fr)" file="Execute.cs"> +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// </copyright> +// <summary> +// Enables easy marshalling of code to the UI thread. +// Borrowed from Caliburn Micro. +// </summary> +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.Utilities +{ + using System; + using System.ComponentModel; + using System.Diagnostics; + using System.Threading.Tasks; + using System.Windows; + using System.Windows.Threading; + + /// <summary> + /// Enables easy marshalling of code to the UI thread. + /// </summary> + public static class Execute + { + private static System.Action<System.Action> executor = (System.Action<System.Action>)(action => action()); + private static Dispatcher dispatcher; + private static bool? inDesignMode; + + /// <summary> + /// Gets a value indicating whether or not the framework is in design-time mode. + /// </summary> + public static bool InDesignMode + { + get + { + if (!Execute.inDesignMode.HasValue) + { + Execute.inDesignMode = new bool?((bool)DependencyPropertyDescriptor.FromProperty(DesignerProperties.IsInDesignModeProperty, typeof(FrameworkElement)).Metadata.DefaultValue); + if (!Execute.inDesignMode.GetValueOrDefault(false) && Process.GetCurrentProcess().ProcessName.StartsWith("devenv", StringComparison.Ordinal)) + Execute.inDesignMode = new bool?(true); + } + return Execute.inDesignMode.GetValueOrDefault(false); + } + } + + /// <summary> + /// Initializes the framework using the current dispatcher. + /// </summary> + public static void InitializeWithDispatcher() + { + Execute.dispatcher = Dispatcher.CurrentDispatcher; + Execute.executor = (System.Action<System.Action>)null; + } + + /// <summary> + /// Resets the executor to use a non-dispatcher-based action executor. + /// </summary> + public static void ResetWithoutDispatcher() + { + executor = (System.Action<System.Action>)(action => action()); + dispatcher = (Dispatcher)null; + } + + /// <summary> + /// Sets a custom UI thread marshaller. + /// </summary> + /// <param name="marshaller">The marshaller.</param> + [Obsolete] + public static void SetUIThreadMarshaller(System.Action<System.Action> marshaller) + { + Execute.executor = marshaller; + Execute.dispatcher = (Dispatcher)null; + } + + /// <summary> + /// The validate dispatcher. + /// </summary> + /// <exception cref="InvalidOperationException"> + /// Not initialized with dispatcher. + /// </exception> + private static void ValidateDispatcher() + { + if (Execute.dispatcher == null) + throw new InvalidOperationException("Not initialized with dispatcher."); + } + + /// <summary> + /// Executes the action on the UI thread asynchronously. + /// </summary> + /// <param name="action">The action to execute.</param> + public static void BeginOnUIThread(this System.Action action) + { + Execute.ValidateDispatcher(); + Execute.dispatcher.BeginInvoke((Delegate)action); + } + + /// <summary> + /// Executes the action on the UI thread asynchronously. + /// </summary> + /// <param name="action"> + /// The action to execute. + /// </param> + /// <returns> + /// The <see cref="Task"/>. + /// </returns> + public static Task OnUIThreadAsync(this System.Action action) + { + Execute.ValidateDispatcher(); + TaskCompletionSource<object> taskSource = new TaskCompletionSource<object>(); + System.Action action1 = (System.Action)(() => + { + try + { + action(); + taskSource.SetResult((object)null); + } + catch (Exception ex) + { + taskSource.SetException(ex); + } + }); + Execute.dispatcher.BeginInvoke((Delegate)action1); + return (Task)taskSource.Task; + } + + /// <summary> + /// The check access. + /// </summary> + /// <returns> + /// The <see cref="bool"/>. + /// </returns> + private static bool CheckAccess() + { + if (Execute.dispatcher != null) + return Execute.dispatcher.CheckAccess(); + return true; + } + + /// <summary> + /// Executes the action on the UI thread. + /// </summary> + /// <param name="action">The action to execute.</param> + public static void OnUIThread(this System.Action action) + { + if (Execute.executor != null) + Execute.executor(action); + else if (Execute.CheckAccess()) + action(); + else + Execute.OnUIThreadAsync(action).Wait(); + } + } +} diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/ExtensionMethods.cs b/win/CS/HandBrakeWPF/Utilities/ExtensionMethods.cs index 9966002c7..f25b8be8e 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/ExtensionMethods.cs +++ b/win/CS/HandBrakeWPF/Utilities/ExtensionMethods.cs @@ -1,45 +1,45 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="ExtensionMethods.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// The extension methods.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Utilities
-{
- using System.Linq.Expressions;
- using System.Reflection;
-
- /// <summary>
- /// The extension methods.
- /// </summary>
- public static class ExtensionMethods
- {
- /// <summary>
- /// Converts an expression into a <see cref="MemberInfo"/>.
- /// </summary>
- /// <param name="expression">
- /// The expression to convert.
- /// </param>
- /// <returns>
- /// The member info.
- /// </returns>
- public static MemberInfo GetMemberInfo(this Expression expression)
- {
- var lambda = (LambdaExpression)expression;
-
- MemberExpression memberExpression;
- if (lambda.Body is UnaryExpression)
- {
- var unaryExpression = (UnaryExpression)lambda.Body;
- memberExpression = (MemberExpression)unaryExpression.Operand;
- }
- else
- memberExpression = (MemberExpression)lambda.Body;
-
- return memberExpression.Member;
- }
- }
-}
+// -------------------------------------------------------------------------------------------------------------------- +// <copyright file="ExtensionMethods.cs" company="HandBrake Project (http://handbrake.fr)"> +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// </copyright> +// <summary> +// The extension methods. +// </summary> +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.Utilities +{ + using System.Linq.Expressions; + using System.Reflection; + + /// <summary> + /// The extension methods. + /// </summary> + public static class ExtensionMethods + { + /// <summary> + /// Converts an expression into a <see cref="MemberInfo"/>. + /// </summary> + /// <param name="expression"> + /// The expression to convert. + /// </param> + /// <returns> + /// The member info. + /// </returns> + public static MemberInfo GetMemberInfo(this Expression expression) + { + var lambda = (LambdaExpression)expression; + + MemberExpression memberExpression; + if (lambda.Body is UnaryExpression) + { + var unaryExpression = (UnaryExpression)lambda.Body; + memberExpression = (MemberExpression)unaryExpression.Operand; + } + else + memberExpression = (MemberExpression)lambda.Body; + + return memberExpression.Member; + } + } +} diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/Interfaces/INotifyPropertyChangedEx.cs b/win/CS/HandBrakeWPF/Utilities/Interfaces/INotifyPropertyChangedEx.cs index add37626b..0030ee7b7 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/Interfaces/INotifyPropertyChangedEx.cs +++ b/win/CS/HandBrakeWPF/Utilities/Interfaces/INotifyPropertyChangedEx.cs @@ -1,37 +1,37 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="INotifyPropertyChangedEx.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Extends <see cref="T:System.ComponentModel.INotifyPropertyChanged" /> such that the change event can be raised by external parties.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Utilities.Interfaces
-{
- using System.ComponentModel;
-
- /// <summary>
- /// Extends <see cref="T:System.ComponentModel.INotifyPropertyChanged"/> such that the change event can be raised by external parties.
- /// </summary>
- public interface INotifyPropertyChangedEx : INotifyPropertyChanged
- {
- /// <summary>
- /// Enables/Disables property change notification.
- /// </summary>
- bool IsNotifying { get; set; }
-
- /// <summary>
- /// Notifies subscribers of the property change.
- /// </summary>
- /// <param name="propertyName">
- /// Name of the property.
- /// </param>
- void NotifyOfPropertyChange(string propertyName);
-
- /// <summary>
- /// Raises a change notification indicating that all bindings should be refreshed.
- /// </summary>
- void Refresh();
- }
-}
+// -------------------------------------------------------------------------------------------------------------------- +// <copyright file="INotifyPropertyChangedEx.cs" company="HandBrake Project (http://handbrake.fr)"> +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// </copyright> +// <summary> +// Extends <see cref="T:System.ComponentModel.INotifyPropertyChanged" /> such that the change event can be raised by external parties. +// </summary> +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.Utilities.Interfaces +{ + using System.ComponentModel; + + /// <summary> + /// Extends <see cref="T:System.ComponentModel.INotifyPropertyChanged"/> such that the change event can be raised by external parties. + /// </summary> + public interface INotifyPropertyChangedEx : INotifyPropertyChanged + { + /// <summary> + /// Enables/Disables property change notification. + /// </summary> + bool IsNotifying { get; set; } + + /// <summary> + /// Notifies subscribers of the property change. + /// </summary> + /// <param name="propertyName"> + /// Name of the property. + /// </param> + void NotifyOfPropertyChange(string propertyName); + + /// <summary> + /// Raises a change notification indicating that all bindings should be refreshed. + /// </summary> + void Refresh(); + } +} diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/PropertyChangedBase.cs b/win/CS/HandBrakeWPF/Utilities/PropertyChangedBase.cs index 071243621..ae3a401b2 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/PropertyChangedBase.cs +++ b/win/CS/HandBrakeWPF/Utilities/PropertyChangedBase.cs @@ -1,121 +1,121 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright company="HandBrake Project (http://handbrake.fr)" file="PropertyChangedBase.cs">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// A base class that implements the infrastructure for property change notification and automatically performs UI thread marshalling.
-// Borrowed from Caliburn Micro
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Utilities
-{
- using System;
- using System.ComponentModel;
- using System.Linq.Expressions;
- using System.Runtime.Serialization;
-
- using HandBrake.ApplicationServices.Utilities.Interfaces;
-
- /// <summary>
- /// A base class that implements the infrastructure for property change notification and automatically performs UI thread marshalling.
- /// </summary>
- [Serializable]
- public class PropertyChangedBase : INotifyPropertyChangedEx, INotifyPropertyChanged
- {
- [NonSerialized]
- private bool isNotifying;
-
- /// <summary>
- /// Gets or sets a value indicating whether the Enables/Disables property change notification.
- /// </summary>
- [Browsable(false)]
- public bool IsNotifying
- {
- get
- {
- return this.isNotifying;
- }
- set
- {
- this.isNotifying = value;
- }
- }
-
- /// <summary>
- /// Occurs when a property value changes.
- /// </summary>
- public event PropertyChangedEventHandler PropertyChanged = (param0, param1) => { };
-
- /// <summary>
- /// Initializes a new instance of the <see cref="PropertyChangedBase"/> class.
- /// Creates an instance of <see cref="T:HandBrake.ApplicationServices.Utilities.PropertyChangedBase"/>.
- /// </summary>
- public PropertyChangedBase()
- {
- this.IsNotifying = true;
- }
-
- /// <summary>
- /// Raises a change notification indicating that all bindings should be refreshed.
- /// </summary>
- public void Refresh()
- {
- this.NotifyOfPropertyChange(string.Empty);
- }
-
- /// <summary>
- /// Notifies subscribers of the property change.
- /// </summary>
- /// <param name="propertyName">Name of the property.</param>
- public virtual void NotifyOfPropertyChange(string propertyName)
- {
- if (!this.IsNotifying)
- return;
- Execute.OnUIThread((System.Action)(() => this.OnPropertyChanged(new PropertyChangedEventArgs(propertyName))));
- }
-
- /// <summary>
- /// Notifies subscribers of the property change.
- /// </summary>
- /// <typeparam name="TProperty">The type of the property.</typeparam><param name="property">The property expression.</param>
- public void NotifyOfPropertyChange<TProperty>(Expression<Func<TProperty>> property)
- {
- this.NotifyOfPropertyChange(ExtensionMethods.GetMemberInfo((Expression)property).Name);
- }
-
- /// <summary>
- /// Raises the <see cref="E:PropertyChanged"/> event directly.
- /// </summary>
- /// <param name="e">The <see cref="T:System.ComponentModel.PropertyChangedEventArgs"/> instance containing the event data.</param>
- [EditorBrowsable(EditorBrowsableState.Never)]
- protected void OnPropertyChanged(PropertyChangedEventArgs e)
- {
- PropertyChangedEventHandler changedEventHandler = this.PropertyChanged;
- if (changedEventHandler == null)
- return;
- changedEventHandler((object)this, e);
- }
-
- /// <summary>
- /// Called when the object is deserialized.
- /// </summary>
- /// <param name="c">The streaming context.</param>
- [OnDeserialized]
- public void OnDeserialized(StreamingContext c)
- {
- this.IsNotifying = true;
- }
-
- /// <summary>
- /// Used to indicate whether or not the IsNotifying property is serialized to Xml.
- /// </summary>
- /// <returns>
- /// Whether or not to serialize the IsNotifying property. The default is false.
- /// </returns>
- public virtual bool ShouldSerializeIsNotifying()
- {
- return false;
- }
- }
-}
+// -------------------------------------------------------------------------------------------------------------------- +// <copyright company="HandBrake Project (http://handbrake.fr)" file="PropertyChangedBase.cs"> +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// </copyright> +// <summary> +// A base class that implements the infrastructure for property change notification and automatically performs UI thread marshalling. +// Borrowed from Caliburn Micro +// </summary> +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.Utilities +{ + using System; + using System.ComponentModel; + using System.Linq.Expressions; + using System.Runtime.Serialization; + + using INotifyPropertyChangedEx = HandBrakeWPF.Utilities.Interfaces.INotifyPropertyChangedEx; + + /// <summary> + /// A base class that implements the infrastructure for property change notification and automatically performs UI thread marshalling. + /// </summary> + [Serializable] + public class PropertyChangedBase : INotifyPropertyChangedEx, INotifyPropertyChanged + { + [NonSerialized] + private bool isNotifying; + + /// <summary> + /// Gets or sets a value indicating whether the Enables/Disables property change notification. + /// </summary> + [Browsable(false)] + public bool IsNotifying + { + get + { + return this.isNotifying; + } + set + { + this.isNotifying = value; + } + } + + /// <summary> + /// Occurs when a property value changes. + /// </summary> + public event PropertyChangedEventHandler PropertyChanged = (param0, param1) => { }; + + /// <summary> + /// Initializes a new instance of the <see cref="PropertyChangedBase"/> class. + /// Creates an instance of <see cref="T:HandBrakeWPF.Utilities.PropertyChangedBase"/>. + /// </summary> + public PropertyChangedBase() + { + this.IsNotifying = true; + } + + /// <summary> + /// Raises a change notification indicating that all bindings should be refreshed. + /// </summary> + public void Refresh() + { + this.NotifyOfPropertyChange(string.Empty); + } + + /// <summary> + /// Notifies subscribers of the property change. + /// </summary> + /// <param name="propertyName">Name of the property.</param> + public virtual void NotifyOfPropertyChange(string propertyName) + { + if (!this.IsNotifying) + return; + Execute.OnUIThread((System.Action)(() => this.OnPropertyChanged(new PropertyChangedEventArgs(propertyName)))); + } + + /// <summary> + /// Notifies subscribers of the property change. + /// </summary> + /// <typeparam name="TProperty">The type of the property.</typeparam><param name="property">The property expression.</param> + public void NotifyOfPropertyChange<TProperty>(Expression<Func<TProperty>> property) + { + this.NotifyOfPropertyChange(ExtensionMethods.GetMemberInfo((Expression)property).Name); + } + + /// <summary> + /// Raises the <see cref="E:PropertyChanged"/> event directly. + /// </summary> + /// <param name="e">The <see cref="T:System.ComponentModel.PropertyChangedEventArgs"/> instance containing the event data.</param> + [EditorBrowsable(EditorBrowsableState.Never)] + protected void OnPropertyChanged(PropertyChangedEventArgs e) + { + PropertyChangedEventHandler changedEventHandler = this.PropertyChanged; + if (changedEventHandler == null) + return; + changedEventHandler((object)this, e); + } + + /// <summary> + /// Called when the object is deserialized. + /// </summary> + /// <param name="c">The streaming context.</param> + [OnDeserialized] + public void OnDeserialized(StreamingContext c) + { + this.IsNotifying = true; + } + + /// <summary> + /// Used to indicate whether or not the IsNotifying property is serialized to Xml. + /// </summary> + /// <returns> + /// Whether or not to serialize the IsNotifying property. The default is false. + /// </returns> + public virtual bool ShouldSerializeIsNotifying() + { + return false; + } + } +} diff --git a/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs index 6ef7f01f5..2d8a7bd68 100644 --- a/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs @@ -23,6 +23,7 @@ namespace HandBrakeWPF.ViewModels using HandBrakeWPF.Services.Presets.Interfaces;
using HandBrakeWPF.Services.Presets.Model;
using HandBrakeWPF.Services.Scan.Model;
+ using HandBrakeWPF.Utilities;
using HandBrakeWPF.ViewModels.Interfaces;
using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask;
diff --git a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs index d732b0cd6..0966b18fd 100644 --- a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs @@ -25,6 +25,7 @@ namespace HandBrakeWPF.ViewModels using HandBrakeWPF.Services.Interfaces;
using HandBrakeWPF.Services.Presets.Model;
using HandBrakeWPF.Services.Scan.Model;
+ using HandBrakeWPF.Utilities;
using HandBrakeWPF.ViewModels.Interfaces;
using AllowedPassthru = HandBrakeWPF.Services.Encode.Model.Models.AllowedPassthru;
diff --git a/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs index 07906b204..8810c65d9 100644 --- a/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs @@ -20,6 +20,7 @@ namespace HandBrakeWPF.ViewModels using HandBrakeWPF.Services.Interfaces;
using HandBrakeWPF.Services.Presets.Model;
using HandBrakeWPF.Services.Scan.Model;
+ using HandBrakeWPF.Utilities;
using HandBrakeWPF.ViewModels.Interfaces;
using DenoisePreset = HandBrakeWPF.Services.Encode.Model.Models.DenoisePreset;
diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs index 04c2df797..b581bdfcd 100644 --- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs @@ -25,6 +25,7 @@ namespace HandBrakeWPF.ViewModels using HandBrakeWPF.Model;
using HandBrakeWPF.Properties;
using HandBrakeWPF.Services.Interfaces;
+ using HandBrakeWPF.Utilities;
using HandBrakeWPF.ViewModels.Interfaces;
using Ookii.Dialogs.Wpf;
diff --git a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs index c2fefd4f6..73df64ddd 100644 --- a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs @@ -20,6 +20,7 @@ namespace HandBrakeWPF.ViewModels using HandBrakeWPF.Properties;
using HandBrakeWPF.Services.Presets.Model;
using HandBrakeWPF.Services.Scan.Model;
+ using HandBrakeWPF.Utilities;
using HandBrakeWPF.ViewModels.Interfaces;
using Microsoft.Win32;
diff --git a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs index 0b263e3fa..eb3ee984e 100644 --- a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs @@ -26,6 +26,7 @@ namespace HandBrakeWPF.ViewModels using HandBrakeWPF.Services.Interfaces;
using HandBrakeWPF.Services.Presets.Model;
using HandBrakeWPF.Services.Scan.Model;
+ using HandBrakeWPF.Utilities;
using HandBrakeWPF.ViewModels.Interfaces;
using Clipboard = System.Windows.Clipboard;
diff --git a/win/CS/HandBrakeWPF/Views/ShellView.xaml.cs b/win/CS/HandBrakeWPF/Views/ShellView.xaml.cs index 4071eeb3c..cd8dfea5a 100644 --- a/win/CS/HandBrakeWPF/Views/ShellView.xaml.cs +++ b/win/CS/HandBrakeWPF/Views/ShellView.xaml.cs @@ -26,6 +26,7 @@ namespace HandBrakeWPF.Views using HandBrakeWPF.ViewModels.Interfaces;
using Application = System.Windows.Application;
+ using Execute = Caliburn.Micro.Execute;
/// <summary>
/// Interaction logic for ShellView.xaml
|