From: sr55 <sr55.hb@outlook.com> Date: Mon, 6 Nov 2017 18:46:56 +0000 (+0000) Subject: WinGui: Updates to handle changes to the JSON API. #964 X-Git-Tag: 1.1.0~319 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=84ae3245700be02a5c434ec8c74dab3fa44e2094;p=handbrake WinGui: Updates to handle changes to the JSON API. #964 --- diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj index 909b40798..657f6b7a2 100644 --- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj +++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj @@ -107,6 +107,8 @@ <Compile Include="Interop\Json\Presets\PresetCategory.cs" /> <Compile Include="Interop\Json\Presets\PresetTransportContainer.cs" /> <Compile Include="Interop\Json\Queue\Task.cs" /> + <Compile Include="Interop\Json\Scan\AudioAttributes.cs" /> + <Compile Include="Interop\Json\Scan\SubtitleAttributes.cs" /> <Compile Include="Interop\Json\Shared\PAR.cs" /> <Compile Include="Interop\Json\Encode\Audio.cs" /> <Compile Include="Interop\Json\Encode\AudioTrack.cs" /> @@ -125,6 +127,7 @@ <Compile Include="Interop\Json\Encode\SubtitleTrack.cs" /> <Compile Include="Interop\Json\Encode\Video.cs" /> <Compile Include="Interop\Factories\AnamorphicFactory.cs" /> + <Compile Include="Interop\Json\State\TaskState.cs" /> <Compile Include="Interop\Model\Encoding\CombDetect.cs" /> <Compile Include="Interop\Model\Encoding\DeinterlaceFilter.cs" /> <Compile Include="Interop\Model\Encoding\HBPresetTune.cs" /> diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs index d3830cb36..45b2f8488 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs @@ -483,14 +483,16 @@ namespace HandBrake.ApplicationServices.Interop state = JsonConvert.DeserializeObject<JsonState>(statusJson); } - if (state != null && (state.State == NativeConstants.HB_STATE_SCANNING || state.State == NativeConstants.HB_STATE_SEARCHING)) + TaskState taskState = state != null ? TaskState.FromRepositoryValue(state.State) : null; + + if (taskState != null && (taskState == TaskState.Scanning || taskState == TaskState.Searching)) { if (this.ScanProgress != null && state.Scanning != null) { this.ScanProgress(this, new ScanProgressEventArgs(state.Scanning.Progress, state.Scanning.Preview, state.Scanning.PreviewCount, state.Scanning.Title, state.Scanning.TitleCount)); } } - else if (state != null && state.State == NativeConstants.HB_STATE_SCANDONE) + else if (taskState != null && taskState == TaskState.ScanDone) { this.scanPollTimer.Stop(); @@ -531,17 +533,19 @@ namespace HandBrake.ApplicationServices.Interop JsonState state = JsonConvert.DeserializeObject<JsonState>(statusJson); - if (state != null && (state.State == NativeConstants.HB_STATE_WORKING || state.State == NativeConstants.HB_STATE_MUXING || state.State == NativeConstants.HB_STATE_SEARCHING)) + TaskState taskState = state != null ? TaskState.FromRepositoryValue(state.State) : null; + + if (taskState != null && (taskState == TaskState.Working || taskState == TaskState.Muxing || taskState == TaskState.Searching)) { if (this.EncodeProgress != null) { var progressEventArgs = new EncodeProgressEventArgs(state.Working.Progress, state.Working.Rate, state.Working.RateAvg, new TimeSpan(state.Working.Hours, state.Working.Minutes, state.Working.Seconds), - state.Working.PassID, state.Working.Pass, state.Working.PassCount, state.State == NativeConstants.HB_STATE_MUXING, state.State == NativeConstants.HB_STATE_SEARCHING); + state.Working.PassID, state.Working.Pass, state.Working.PassCount, taskState == TaskState.Muxing, taskState == TaskState.Searching); this.EncodeProgress(this, progressEventArgs); } } - else if (state != null && state.State == NativeConstants.HB_STATE_WORKDONE) + else if (taskState != null && taskState == TaskState.WorkDone) { this.encodePollTimer.Stop(); diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/AudioAttributes.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/AudioAttributes.cs new file mode 100644 index 000000000..b6a29e194 --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/AudioAttributes.cs @@ -0,0 +1,21 @@ +// -------------------------------------------------------------------------------------------------------------------- +// <copyright file="AudioAttributes.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 color. +// </summary> +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.ApplicationServices.Interop.Json.Scan +{ + public class AudioAttributes + { + public bool AltCommentary { get; set; } + public bool Commentary { get; set; } + public bool Default { get; set; } + public bool Normal { get; set; } + public bool Secondary { get; set; } + public bool VisuallyImpaired { get; set; } + } +} diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceAudioTrack.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceAudioTrack.cs index c497df2e6..62335eeff 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceAudioTrack.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceAudioTrack.cs @@ -22,7 +22,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan /// <summary> /// Gets or sets the channel layout. /// </summary> - public long ChannelLayout { get; set; } + public int ChannelLayout { get; set; } /// <summary> /// Gets or sets the description. @@ -48,5 +48,15 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan /// Gets or sets the codec. /// </summary> public int Codec { get; set; } + + public string CodecName { get; set; } + + public long LFECount { get; set; } + + public string ChannelLayoutName { get; set; } + + public int ChannelCount { get; set; } + + public AudioAttributes Attributes { get; set; } } } \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceChapter.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceChapter.cs index fb0d84955..93b5e1ce3 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceChapter.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceChapter.cs @@ -5,23 +5,23 @@ // <summary> // The a chapter from a video source. // </summary> -// -------------------------------------------------------------------------------------------------------------------- - -namespace HandBrake.ApplicationServices.Interop.Json.Scan -{ - /// <summary> - /// The a chapter from a video source. - /// </summary> - public class SourceChapter - { - /// <summary> - /// Gets or sets the duration. - /// </summary> - public Duration Duration { get; set; } - - /// <summary> - /// Gets or sets the name. - /// </summary> - public string Name { get; set; } - } +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.ApplicationServices.Interop.Json.Scan +{ + /// <summary> + /// The a chapter from a video source. + /// </summary> + public class SourceChapter + { + /// <summary> + /// Gets or sets the duration. + /// </summary> + public Duration Duration { get; set; } + + /// <summary> + /// Gets or sets the name. + /// </summary> + public string Name { get; set; } + } } \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceMetadata.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceMetadata.cs index 734dfa29a..f575dc637 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceMetadata.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceMetadata.cs @@ -14,14 +14,5 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan /// </summary> public class SourceMetadata { - public string Artist { get; set; } - public string Description { get; set; } - public string Genre { get; set; } - public string LongDescription { get; set; } - public string Name { get; set; } - public string ReleaseDate { get; set; } - public string Composer { get; set; } - public string AlbumArtist { get; set; } - public string Comment { get; set; } } } \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceSubtitleTrack.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceSubtitleTrack.cs index 3f3594a39..67be629a2 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceSubtitleTrack.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceSubtitleTrack.cs @@ -17,7 +17,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan /// <summary> /// Gets or sets the format. /// </summary> - public int Format { get; set; } + public string Format { get; set; } /// <summary> /// Gets or sets the language. @@ -33,5 +33,12 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan /// Gets or sets the source. /// </summary> public int Source { get; set; } + + public string SourceName { get; set; } + + /// <summary> + /// Gets or sets subtitle attribute information. + /// </summary> + public SubtitleAttributes Attributes { get; set; } } } \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceTitle.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceTitle.cs index 4947bbadb..e8f62c8d0 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceTitle.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceTitle.cs @@ -38,6 +38,11 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan /// </summary> public Color Color { get; set; } + /// <summary> + /// Gets or sets the input file container. + /// </summary> + public string Container { get; set; } + /// <summary> /// Gets or sets the cropping values /// </summary> diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SubtitleAttributes.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SubtitleAttributes.cs new file mode 100644 index 000000000..b22a470be --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SubtitleAttributes.cs @@ -0,0 +1,29 @@ +// -------------------------------------------------------------------------------------------------------------------- +// <copyright file="SubtitleAttributes.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 color. +// </summary> +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.ApplicationServices.Interop.Json.Scan +{ + using Newtonsoft.Json; + + public class SubtitleAttributes + { + [JsonProperty(PropertyName = "4By3")] + public bool FourByThree { get; set; } + public bool Children { get; set; } + public bool ClosedCaption { get; set; } + public bool Commentary { get; set; } + public bool Default { get; set; } + public bool Forced { get; set; } + public bool Large { get; set; } + public bool Letterbox { get; set; } + public bool Normal { get; set; } + public bool PanScan { get; set; } + public bool Wide { get; set; } + } +} diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/State/JsonState.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/State/JsonState.cs index b0817a7d2..2309b0d16 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/State/JsonState.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/State/JsonState.cs @@ -32,6 +32,6 @@ namespace HandBrake.ApplicationServices.Interop.Json.State /// <summary> /// Gets or sets the state. /// </summary> - public int State { get; set; } + public string State { get; set; } } } \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/State/TaskState.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/State/TaskState.cs new file mode 100644 index 000000000..168303e1d --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/State/TaskState.cs @@ -0,0 +1,59 @@ +// -------------------------------------------------------------------------------------------------------------------- +// <copyright file="TaskState.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 status of the current task being processed. +// </summary> +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.ApplicationServices.Interop.Json.State +{ + using System.Collections.Generic; + + public class TaskState + { + public static TaskState Idle = new TaskState("IDLE"); + public static TaskState Scanning = new TaskState("SCANNING"); + public static TaskState ScanDone = new TaskState("SCANDONE"); + public static TaskState Working = new TaskState("WORKING"); + public static TaskState Paused = new TaskState("PAUSED"); + public static TaskState Searching = new TaskState("SEARCHING"); + public static TaskState WorkDone = new TaskState("WORKDONE"); + public static TaskState Muxing = new TaskState("MUXING"); + public static TaskState Unknown = new TaskState("UNKNOWN"); + + private static readonly Dictionary<string, TaskState> taskStates = new Dictionary<string, TaskState>(); + + static TaskState() + { + taskStates.Add("IDLE", Idle); + taskStates.Add("SCANNING", Scanning); + taskStates.Add("SCANDONE", ScanDone); + taskStates.Add("WORKING", Working); + taskStates.Add("PAUSED", Paused); + taskStates.Add("SEARCHING", Searching); + taskStates.Add("WORKDONE", WorkDone); + taskStates.Add("MUXING", Muxing); + taskStates.Add("UNKNOWN", Unknown); + } + + public TaskState(string code) + { + this.Code = code; + } + + public string Code { get; } + + public static TaskState FromRepositoryValue(string code) + { + TaskState state = null; + if (taskStates.TryGetValue(code, out state)) + { + return state; + } + + return null; + } + } +}