diff options
author | sr55 <[email protected]> | 2020-07-31 21:49:24 +0100 |
---|---|---|
committer | sr55 <[email protected]> | 2020-07-31 21:49:24 +0100 |
commit | d13644e79b5e6688a46773d1d7fd6e936f8ca9a4 (patch) | |
tree | 54c82e1e74ca976aa4fa1b58ee9c1bad729e753d /win/CS/HandBrakeWPF/Services | |
parent | c4842f3d09637f2f868dd08192dc8c72ff11e16b (diff) |
WinGui: Update the UI to allow passthru of metadata to be disabled. This utilises the change 2677f9fe9e91f9dfeccaf8c265615a703e20efa5
This is a new preference in Preferences -> Output Files -> Metadata
There is no change to the previous metadata passthru behaviour. It's simply now possible to turn it off.
Diffstat (limited to 'win/CS/HandBrakeWPF/Services')
5 files changed, 77 insertions, 182 deletions
diff --git a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs index 120326a6e..6621d3f82 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs @@ -24,7 +24,7 @@ namespace HandBrakeWPF.Services.Encode.Factories using HandBrake.Interop.Model; using HandBrakeWPF.Helpers; - using HandBrakeWPF.Model.Filters; + using HandBrakeWPF.Services.Interfaces; using HandBrakeWPF.Utilities; using Newtonsoft.Json.Linq; @@ -48,57 +48,35 @@ namespace HandBrakeWPF.Services.Encode.Factories /// </summary> internal class EncodeTaskFactory { - // TODO make this non-static - private static IHbFunctions hbFunctions; - - /// <summary> - /// The create. - /// </summary> - /// <param name="job"> - /// The encode job. - /// </param> - /// <param name="configuration"> - /// The configuration. - /// </param> - /// <param name="hbFunctionsWrapper"> - /// An instance of IHbFunctions - /// </param> - /// <returns> - /// The <see cref="JsonEncodeObject"/>. - /// </returns> - internal static JsonEncodeObject Create(EncodeTask job, HBConfiguration configuration, IHbFunctions hbFunctionsWrapper) + private readonly IUserSettingService userSettingService; + private IHbFunctions hbFunctions; + + public EncodeTaskFactory(IUserSettingService userSettingService, IHbFunctions hbFunctionsWrapper) { - hbFunctions = hbFunctionsWrapper; + this.userSettingService = userSettingService; + + this.hbFunctions = hbFunctionsWrapper; + } + internal JsonEncodeObject Create(EncodeTask job, HBConfiguration configuration) + { JsonEncodeObject encode = new JsonEncodeObject - { - SequenceID = 0, - Audio = CreateAudio(job), - Destination = CreateDestination(job), - Filters = CreateFilters(job), - PAR = CreatePAR(job), - Metadata = CreateMetadata(job), - Source = CreateSource(job, configuration), - Subtitle = CreateSubtitle(job), - Video = CreateVideo(job, configuration) - }; + { + SequenceID = 0, + Audio = CreateAudio(job), + Destination = CreateDestination(job), + Filters = CreateFilters(job), + PAR = CreatePAR(job), + Metadata = CreateMetadata(job), + Source = CreateSource(job, configuration), + Subtitle = CreateSubtitle(job), + Video = CreateVideo(job, configuration) + }; return encode; } - /// <summary> - /// The create source. - /// </summary> - /// <param name="job"> - /// The job. - /// </param> - /// <param name="configuration"> - /// The configuration. - /// </param> - /// <returns> - /// The <see cref="Source"/>. - /// </returns> - private static Source CreateSource(EncodeTask job, HBConfiguration configuration) + private Source CreateSource(EncodeTask job, HBConfiguration configuration) { Range range = new Range(); switch (job.PointToPointMode) @@ -135,17 +113,8 @@ namespace HandBrakeWPF.Services.Encode.Factories }; return source; } - - /// <summary> - /// The create destination. - /// </summary> - /// <param name="job"> - /// The job. - /// </param> - /// <returns> - /// The <see cref="Destination"/>. - /// </returns> - private static Destination CreateDestination(EncodeTask job) + + private Destination CreateDestination(EncodeTask job) { Destination destination = new Destination { @@ -173,30 +142,12 @@ namespace HandBrakeWPF.Services.Encode.Factories return destination; } - /// <summary> - /// Create the PAR object - /// </summary> - /// <param name="job"> - /// The Job - /// </param> - /// <returns> - /// The produced PAR object. - /// </returns> - private static PAR CreatePAR(EncodeTask job) + private PAR CreatePAR(EncodeTask job) { return new PAR { Num = job.PixelAspectX, Den = job.PixelAspectY }; } - /// <summary> - /// The create subtitle. - /// </summary> - /// <param name="job"> - /// The job. - /// </param> - /// <returns> - /// The <see cref="HandBrake.Interop.Interop.Json.Encode.Subtitles"/>. - /// </returns> - private static Subtitle CreateSubtitle(EncodeTask job) + private Subtitle CreateSubtitle(EncodeTask job) { Subtitles subtitle = new Subtitles { @@ -264,19 +215,7 @@ namespace HandBrakeWPF.Services.Encode.Factories return subtitle; } - /// <summary> - /// The create video. - /// </summary> - /// <param name="job"> - /// The job. - /// </param> - /// <param name="configuration"> - /// The configuration. - /// </param> - /// <returns> - /// The <see cref="Video"/>. - /// </returns> - private static Video CreateVideo(EncodeTask job, HBConfiguration configuration) + private Video CreateVideo(EncodeTask job, HBConfiguration configuration) { Video video = new Video(); @@ -336,16 +275,7 @@ namespace HandBrakeWPF.Services.Encode.Factories return video; } - /// <summary> - /// The create audio. - /// </summary> - /// <param name="job"> - /// The job. - /// </param> - /// <returns> - /// The <see cref="Audio"/>. - /// </returns> - private static Audio CreateAudio(EncodeTask job) + private Audio CreateAudio(EncodeTask job) { Audio audio = new Audio(); @@ -412,16 +342,7 @@ namespace HandBrakeWPF.Services.Encode.Factories return audio; } - /// <summary> - /// The create filter. - /// </summary> - /// <param name="job"> - /// The job. - /// </param> - /// <returns> - /// The <see cref="Filters"/>. - /// </returns> - private static Filters CreateFilters(EncodeTask job) + private Filters CreateFilters(EncodeTask job) { Filters filter = new Filters { @@ -634,34 +555,30 @@ namespace HandBrakeWPF.Services.Encode.Factories return filter; } - /// <summary> - /// The create meta data. - /// </summary> - /// <param name="job"> - /// The job. - /// </param> - /// <returns> - /// The <see cref="Metadata"/>. - /// </returns> - private static Metadata CreateMetadata(EncodeTask job) + private Metadata CreateMetadata(EncodeTask job) { - Metadata metaData = new Metadata(); - - if (job.MetaData != null) + if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.MetadataPassthru)) { - metaData.Artist = job.MetaData.Artist; - metaData.Album = job.MetaData.Album; - metaData.AlbumArtist = job.MetaData.AlbumArtist; - metaData.Comment = job.MetaData.Comment; - metaData.Composer = job.MetaData.Composer; - metaData.Description = job.MetaData.Description; - metaData.Genre = job.MetaData.Genre; - metaData.LongDescription = job.MetaData.LongDescription; - metaData.Name = job.MetaData.Name; - metaData.ReleaseDate = job.MetaData.ReleaseDate; + if (job.MetaData != null && job.MetaData.IsMetadataSet) + { + Metadata metaData = new Metadata(); + metaData.Artist = job.MetaData.Artist; + metaData.Album = job.MetaData.Album; + metaData.AlbumArtist = job.MetaData.AlbumArtist; + metaData.Comment = job.MetaData.Comment; + metaData.Composer = job.MetaData.Composer; + metaData.Description = job.MetaData.Description; + metaData.Genre = job.MetaData.Genre; + metaData.LongDescription = job.MetaData.LongDescription; + metaData.Name = job.MetaData.Name; + metaData.ReleaseDate = job.MetaData.ReleaseDate; + return metaData; + } + + return null; // Null will allow Libhb to find and passthru any metadata it supports. } - return metaData; + return new Metadata(); // Empty Metatdata will not pass through to the destination. } } } diff --git a/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs b/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs index f30300f9d..a383a0b14 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs @@ -40,7 +40,9 @@ namespace HandBrakeWPF.Services.Encode private readonly IUserSettingService userSettingService; private readonly ILogInstanceManager logInstanceManager; private readonly IHbFunctionsProvider hbFunctionsProvider; + private readonly IPortService portService; private readonly object portLock = new object(); + private readonly EncodeTaskFactory encodeTaskFactory; private IEncodeInstance instance; private DateTime startTime; private EncodeTask currentTask; @@ -49,8 +51,6 @@ namespace HandBrakeWPF.Services.Encode private bool isLoggingInitialised; private int encodeCounter; - private readonly IPortService portService; - public LibEncode(IHbFunctionsProvider hbFunctionsProvider, IUserSettingService userSettingService, ILogInstanceManager logInstanceManager, int encodeCounter, IPortService portService) : base(userSettingService) { this.userSettingService = userSettingService; @@ -58,6 +58,7 @@ namespace HandBrakeWPF.Services.Encode this.hbFunctionsProvider = hbFunctionsProvider; this.encodeCounter = encodeCounter; this.portService = portService; + this.encodeTaskFactory = new EncodeTaskFactory(this.userSettingService, hbFunctionsProvider.GetHbFunctionsWrapper()); } public bool IsPasued { get; private set; } @@ -127,10 +128,7 @@ namespace HandBrakeWPF.Services.Encode this.VerifyEncodeDestinationPath(task); // Get an EncodeJob object for the Interop Library - JsonEncodeObject work = EncodeTaskFactory.Create( - task, - configuration, - hbFunctionsProvider.GetHbFunctionsWrapper()); + JsonEncodeObject work = encodeTaskFactory.Create(task, configuration); this.instance.StartEncode(work); } diff --git a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/MetaData.cs b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/MetaData.cs index 02dc02ffb..dfc6d432b 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/MetaData.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/MetaData.cs @@ -11,24 +11,12 @@ namespace HandBrakeWPF.Services.Encode.Model.Models { using HandBrakeWPF.Services.Scan.Model; - /// <summary> - /// The meta data. - /// </summary> public class MetaData { - /// <summary> - /// Initializes a new instance of the <see cref="MetaData"/> class. - /// </summary> public MetaData() { } - /// <summary> - /// Initializes a new instance of the <see cref="MetaData"/> class. - /// </summary> - /// <param name="metadata"> - /// The metadata. - /// </param> public MetaData(MetaData metadata) { if (metadata != null) @@ -63,54 +51,40 @@ namespace HandBrakeWPF.Services.Encode.Model.Models } } - /// <summary> - /// Gets or sets the album artist. - /// </summary> public string AlbumArtist { get; set; } - /// <summary> - /// Gets or sets the album. - /// </summary> public string Album { get; set; } - /// <summary> - /// Gets or sets the artist. - /// </summary> public string Artist { get; set; } - /// <summary> - /// Gets or sets the comment. - /// </summary> public string Comment { get; set; } - /// <summary> - /// Gets or sets the composer. - /// </summary> public string Composer { get; set; } - /// <summary> - /// Gets or sets the description. - /// </summary> public string Description { get; set; } - /// <summary> - /// Gets or sets the genre. - /// </summary> public string Genre { get; set; } - /// <summary> - /// Gets or sets the long description. - /// </summary> public string LongDescription { get; set; } - /// <summary> - /// Gets or sets the name. - /// </summary> public string Name { get; set; } - /// <summary> - /// Gets or sets the release date. - /// </summary> public string ReleaseDate { get; set; } + + public bool IsMetadataSet + { + get + { + return !string.IsNullOrEmpty(AlbumArtist) || !string.IsNullOrEmpty(Album) + || !string.IsNullOrEmpty(Artist) + || !string.IsNullOrEmpty(Comment) + || !string.IsNullOrEmpty(Composer) + || !string.IsNullOrEmpty(Description) + || !string.IsNullOrEmpty(Genre) + || !string.IsNullOrEmpty(LongDescription) + || !string.IsNullOrEmpty(Name) + || !string.IsNullOrEmpty(ReleaseDate); + } + } } } diff --git a/win/CS/HandBrakeWPF/Services/Queue/QueueService.cs b/win/CS/HandBrakeWPF/Services/Queue/QueueService.cs index 666a3b15e..56fa7ca88 100644 --- a/win/CS/HandBrakeWPF/Services/Queue/QueueService.cs +++ b/win/CS/HandBrakeWPF/Services/Queue/QueueService.cs @@ -69,6 +69,8 @@ namespace HandBrakeWPF.Services.Queue private int jobIdCounter = 0; private bool processIsolationEnabled; + private EncodeTaskFactory encodeTaskFactory; + public QueueService(IUserSettingService userSettingService, ILog logService, IErrorService errorService, ILogInstanceManager logInstanceManager, IHbFunctionsProvider hbFunctionsProvider, IPortService portService) { this.userSettingService = userSettingService; @@ -83,6 +85,8 @@ namespace HandBrakeWPF.Services.Queue this.allowedInstances = this.userSettingService.GetUserSetting<int>(UserSettingConstants.SimultaneousEncodes); this.processIsolationEnabled = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ProcessIsolationEnabled); + + this.encodeTaskFactory = new EncodeTaskFactory(this.userSettingService, hbFunctionsProvider.GetHbFunctionsWrapper()); } public event EventHandler<QueueProgressEventArgs> JobProcessingStarted; @@ -688,7 +692,7 @@ namespace HandBrakeWPF.Services.Queue List<Task> queueJobs = new List<Task>(); foreach (var item in tasks) { - Task task = new Task { Job = EncodeTaskFactory.Create(item, configuration, hbFunctions) }; + Task task = new Task { Job = this.encodeTaskFactory.Create(item, configuration) }; queueJobs.Add(task); } diff --git a/win/CS/HandBrakeWPF/Services/UserSettingService.cs b/win/CS/HandBrakeWPF/Services/UserSettingService.cs index 674073f6c..27c3f0796 100644 --- a/win/CS/HandBrakeWPF/Services/UserSettingService.cs +++ b/win/CS/HandBrakeWPF/Services/UserSettingService.cs @@ -329,6 +329,8 @@ namespace HandBrakeWPF.Services // Misc
defaults.Add(UserSettingConstants.ScalingMode, 0);
defaults.Add(UserSettingConstants.ForcePresetReset, 3);
+ defaults.Add(UserSettingConstants.MetadataPassthru, true);
+
return defaults;
}
|