]> granicus.if.org Git - handbrake/commitdiff
WinGui: Updates to handle changes to the JSON API. #964
authorsr55 <sr55.hb@outlook.com>
Mon, 6 Nov 2017 18:46:56 +0000 (18:46 +0000)
committersr55 <sr55.hb@outlook.com>
Mon, 6 Nov 2017 19:08:08 +0000 (19:08 +0000)
win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs
win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/AudioAttributes.cs [new file with mode: 0644]
win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceAudioTrack.cs
win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceChapter.cs
win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceMetadata.cs
win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceSubtitleTrack.cs
win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceTitle.cs
win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SubtitleAttributes.cs [new file with mode: 0644]
win/CS/HandBrake.ApplicationServices/Interop/Json/State/JsonState.cs
win/CS/HandBrake.ApplicationServices/Interop/Json/State/TaskState.cs [new file with mode: 0644]

index 909b4079820248166a3971ca68abf3d3e72c2f58..657f6b7a2dbb383031eb4cd8a3bcfa82ddfdb0b5 100644 (file)
     <Compile Include="Interop\Json\Presets\PresetCategory.cs" />\r
     <Compile Include="Interop\Json\Presets\PresetTransportContainer.cs" />\r
     <Compile Include="Interop\Json\Queue\Task.cs" />\r
+    <Compile Include="Interop\Json\Scan\AudioAttributes.cs" />\r
+    <Compile Include="Interop\Json\Scan\SubtitleAttributes.cs" />\r
     <Compile Include="Interop\Json\Shared\PAR.cs" />\r
     <Compile Include="Interop\Json\Encode\Audio.cs" />\r
     <Compile Include="Interop\Json\Encode\AudioTrack.cs" />\r
     <Compile Include="Interop\Json\Encode\SubtitleTrack.cs" />\r
     <Compile Include="Interop\Json\Encode\Video.cs" />\r
     <Compile Include="Interop\Factories\AnamorphicFactory.cs" />\r
+    <Compile Include="Interop\Json\State\TaskState.cs" />\r
     <Compile Include="Interop\Model\Encoding\CombDetect.cs" />\r
     <Compile Include="Interop\Model\Encoding\DeinterlaceFilter.cs" />\r
     <Compile Include="Interop\Model\Encoding\HBPresetTune.cs" />\r
index d3830cb36d5093d774f8bc7a5a15f6a4930b0b1a..45b2f84882aa281260c9ea651077f40ac8caf7c9 100644 (file)
@@ -483,14 +483,16 @@ namespace HandBrake.ApplicationServices.Interop
                 state = JsonConvert.DeserializeObject<JsonState>(statusJson);\r
             }\r
 \r
-            if (state != null && (state.State == NativeConstants.HB_STATE_SCANNING || state.State == NativeConstants.HB_STATE_SEARCHING))\r
+            TaskState taskState = state != null ? TaskState.FromRepositoryValue(state.State) : null;\r
+\r
+            if (taskState != null && (taskState == TaskState.Scanning || taskState == TaskState.Searching))\r
             {\r
                 if (this.ScanProgress != null && state.Scanning != null)\r
                 {\r
                     this.ScanProgress(this, new ScanProgressEventArgs(state.Scanning.Progress, state.Scanning.Preview, state.Scanning.PreviewCount, state.Scanning.Title, state.Scanning.TitleCount));\r
                 }\r
             }\r
-            else if (state != null && state.State == NativeConstants.HB_STATE_SCANDONE)\r
+            else if (taskState != null && taskState == TaskState.ScanDone)\r
             {\r
                 this.scanPollTimer.Stop();\r
 \r
@@ -531,17 +533,19 @@ namespace HandBrake.ApplicationServices.Interop
 \r
             JsonState state = JsonConvert.DeserializeObject<JsonState>(statusJson);\r
 \r
-            if (state != null && (state.State == NativeConstants.HB_STATE_WORKING || state.State == NativeConstants.HB_STATE_MUXING || state.State == NativeConstants.HB_STATE_SEARCHING))\r
+            TaskState taskState = state != null ? TaskState.FromRepositoryValue(state.State) : null;\r
+\r
+            if (taskState != null && (taskState == TaskState.Working || taskState == TaskState.Muxing || taskState == TaskState.Searching))\r
             {\r
                 if (this.EncodeProgress != null)\r
                 {\r
                     var progressEventArgs = new EncodeProgressEventArgs(state.Working.Progress, state.Working.Rate, state.Working.RateAvg, new TimeSpan(state.Working.Hours, state.Working.Minutes, state.Working.Seconds),\r
-                        state.Working.PassID, state.Working.Pass, state.Working.PassCount, state.State == NativeConstants.HB_STATE_MUXING, state.State == NativeConstants.HB_STATE_SEARCHING);\r
+                        state.Working.PassID, state.Working.Pass, state.Working.PassCount, taskState == TaskState.Muxing, taskState == TaskState.Searching);\r
 \r
                     this.EncodeProgress(this, progressEventArgs);\r
                 }\r
             }\r
-            else if (state != null && state.State == NativeConstants.HB_STATE_WORKDONE)\r
+            else if (taskState != null && taskState == TaskState.WorkDone)\r
             {\r
                 this.encodePollTimer.Stop();\r
 \r
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 (file)
index 0000000..b6a29e1
--- /dev/null
@@ -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; }
+    }
+}
index c497df2e682704f0473c4a48cb25e4784c5306f5..62335eeff1fdf7e49febcfe729afa739e7b82a51 100644 (file)
@@ -22,7 +22,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan
         /// <summary>\r
         /// Gets or sets the channel layout.\r
         /// </summary>\r
-        public long ChannelLayout { get; set; }\r
+        public int ChannelLayout { get; set; }\r
 \r
         /// <summary>\r
         /// Gets or sets the description.\r
@@ -48,5 +48,15 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan
         /// Gets or sets the codec.\r
         /// </summary>\r
         public int Codec { get; set; }\r
+\r
+        public string CodecName { get; set; }\r
+\r
+        public long LFECount { get; set; }\r
+\r
+        public string ChannelLayoutName { get; set; }\r
+\r
+        public int ChannelCount { get; set; }\r
+\r
+        public AudioAttributes Attributes { get; set; }\r
     }\r
 }
\ No newline at end of file
index fb0d8495541a3c9d10f0fe329863d1dec92c7f60..93b5e1ce352849c5558b9f5fcccb464bbb6c59d3 100644 (file)
@@ -5,23 +5,23 @@
 // <summary>\r
 //   The a chapter from a video source.\r
 // </summary>\r
-// --------------------------------------------------------------------------------------------------------------------
-
-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; }
-    }
+// --------------------------------------------------------------------------------------------------------------------\r
+\r
+namespace HandBrake.ApplicationServices.Interop.Json.Scan\r
+{\r
+    /// <summary>\r
+    /// The a chapter from a video source.\r
+    /// </summary>\r
+    public class SourceChapter\r
+    {\r
+        /// <summary>\r
+        /// Gets or sets the duration.\r
+        /// </summary>\r
+        public Duration Duration { get; set; }\r
+\r
+        /// <summary>\r
+        /// Gets or sets the name.\r
+        /// </summary>\r
+        public string Name { get; set; }\r
+    }\r
 }
\ No newline at end of file
index 734dfa29aa587403adc3df7e70c76912dce20785..f575dc637ea94c050eca327c3ccb391ee10219c4 100644 (file)
@@ -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
index 3f3594a393f882d976e7fa144cbcc0ec998f9cb8..67be629a2218e2efa391e138b7c35729aeaac091 100644 (file)
@@ -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
index 4947bbadba3299707bac90515c7d47a94c5c4ab1..e8f62c8d0a865c516f4dfed26480e526b9e453e7 100644 (file)
@@ -38,6 +38,11 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan
         /// </summary>\r
         public Color Color { get; set; }\r
 \r
+        /// <summary>\r
+        /// Gets or sets the input file container.\r
+        /// </summary>\r
+        public string Container { get; set; }\r
+\r
         /// <summary>\r
         /// Gets or sets the cropping values\r
         /// </summary>\r
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 (file)
index 0000000..b22a470
--- /dev/null
@@ -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; }
+    }
+}
index b0817a7d201f07567bb9bfe149cb2d5c34c3987a..2309b0d16d24520b82c5cdd2d022d0dd9f422aa0 100644 (file)
@@ -32,6 +32,6 @@ namespace HandBrake.ApplicationServices.Interop.Json.State
         /// <summary>\r
         /// Gets or sets the state.\r
         /// </summary>\r
-        public int State { get; set; }\r
+        public string State { get; set; }\r
     }\r
 }
\ 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 (file)
index 0000000..168303e
--- /dev/null
@@ -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;
+        }
+    }
+}