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