WinGui: Update the Encode Json Factory to produce human readable Json for audio and...
authorsr55 <sr55.hb@outlook.com>
Sat, 7 Jul 2018 14:20:55 +0000 (15:20 +0100)
committersr55 <sr55.hb@outlook.com>
Sat, 7 Jul 2018 14:20:55 +0000 (15:20 +0100)
win/CS/HandBrake.Interop/Interop/HbLib/NativeConstants.cs
win/CS/HandBrake.Interop/Interop/Json/Encode/Audio.cs
win/CS/HandBrake.Interop/Interop/Json/Encode/AudioTrack.cs
win/CS/HandBrake.Interop/Interop/Json/Encode/Destination.cs
win/CS/HandBrake.Interop/Interop/Json/Encode/Video.cs
win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs
win/CS/HandBrakeWPF/Services/Encode/Model/Models/OutputFormat.cs

index dbf96aeda4313c7fba1dd333e890b3cea5f17e81..3e0e7f012b8d7c1f7ec6babc498d2a9ea34b42c4 100644 (file)
@@ -13,61 +13,20 @@ namespace HandBrake.Interop.Interop.HbLib
     public class NativeConstants
     {
         // Audio encoders
-        public const uint HB_ACODEC_MASK = 0x03FFFF00;
-        public const uint HB_ACODEC_LAME = 0x00000200;
-        public const uint HB_ACODEC_VORBIS = 0x00000400;
         public const uint HB_ACODEC_AC3 = 0x00000800;
-        public const uint HB_ACODEC_LPCM = 0x00001000;
         public const uint HB_ACODEC_DCA = 0x00002000;
-        public const uint HB_ACODEC_CA_AAC = 0x00004000;
-        public const uint HB_ACODEC_CA_HAAC = 0x00008000;
         public const uint HB_ACODEC_FFAAC = 0x00010000;
-        public const uint HB_ACODEC_FFMPEG = 0x00020000;
         public const uint HB_ACODEC_DCA_HD = 0x00040000;
         public const uint HB_ACODEC_MP3 = 0x00080000;
         public const uint HB_ACODEC_FFFLAC = 0x00100000;
-        public const uint HB_ACODEC_FFFLAC24 = 0x00200000;
-        public const uint HB_ACODEC_FDK_AAC = 0x00400000;
-        public const uint HB_ACODEC_FDK_HAAC = 0x00800000;
         public const uint HB_ACODEC_FFEAC3 = 0x01000000;
         public const uint HB_ACODEC_FFTRUEHD = 0x02000000;
-        public const uint HB_ACODEC_FF_MASK = 0x03FF2800;
         public const uint HB_ACODEC_PASS_FLAG = 0x40000000;
         public const uint HB_ACODEC_PASS_MASK = (HB_ACODEC_AC3 | HB_ACODEC_DCA | HB_ACODEC_DCA_HD | HB_ACODEC_FFAAC | HB_ACODEC_FFEAC3 | HB_ACODEC_FFFLAC | HB_ACODEC_MP3 | HB_ACODEC_FFTRUEHD);
-        public const uint HB_ACODEC_AUTO_PASS = (HB_ACODEC_PASS_MASK | HB_ACODEC_PASS_FLAG);
-        public const uint HB_ACODEC_MP3_PASS = (HB_ACODEC_MP3 | HB_ACODEC_PASS_FLAG);
-        public const uint HB_ACODEC_AAC_PASS = (HB_ACODEC_FFAAC | HB_ACODEC_PASS_FLAG);
-        public const uint HB_ACODEC_AC3_PASS = (HB_ACODEC_AC3 | HB_ACODEC_PASS_FLAG);
-        public const uint HB_ACODEC_DCA_PASS = (HB_ACODEC_DCA | HB_ACODEC_PASS_FLAG);
-        public const uint HB_ACODEC_DCA_HD_PASS = (HB_ACODEC_DCA_HD | HB_ACODEC_PASS_FLAG);
-        public const uint HB_ACODEC_EAC3_PASS = (HB_ACODEC_PASS_FLAG | HB_ACODEC_FFEAC3);
-        public const uint HB_ACODEC_FLAC_PASS = (HB_ACODEC_PASS_FLAG | HB_ACODEC_FFFLAC);
-        public const uint HB_ACODEC_ANY = (HB_ACODEC_MASK | HB_ACODEC_PASS_FLAG);
-        public const uint HB_ACODEC_TRUEHD_PASS = (HB_ACODEC_PASS_FLAG | HB_ACODEC_FFTRUEHD);
 
         // VideoEncoders
         public const uint HB_VCODEC_QSV_H264 = 0x0000100;
         public const uint HB_VCODEC_QSV_H265 = 0x0000200;
         public const uint HB_VCODEC_QSV_H265_10BIT = 0x0000400;
-        public const uint HB_VCODEC_QSV_MASK = 0x0000F00;
-
-        public const uint HB_VCODEC_FFMPEG_VCE_H264 = 0x00040000;
-        public const uint HB_VCODEC_FFMPEG_VCE_H265 = 0x00080000;
-        public const uint HB_VCODEC_FFMPEG_MASK = (0x00000F0 | HB_VCODEC_FFMPEG_VCE_H264 | HB_VCODEC_FFMPEG_VCE_H265);
-
-        // Encode state
-        public const int HB_STATE_IDLE = 1;
-        public const int HB_STATE_SCANNING = 2;
-        public const int HB_STATE_SCANDONE = 4;
-        public const int HB_STATE_WORKING = 8;
-        public const int HB_STATE_PAUSED = 16;
-        public const int HB_STATE_WORKDONE = 32;
-        public const int HB_STATE_MUXING = 64;
-        public const int HB_STATE_SEARCHING = 128;
-
-        // Keep aspect ratio values
-        public const int HB_KEEP_WIDTH = 0x01;
-        public const int HB_KEEP_HEIGHT = 0x02;
-        public const int HB_KEEP_DISPLAY_ASPECT = 0x04;
        }
 }
index 924185f50918e3b6eab049a78c1704d91259642a..59ddd0481f5cc28270c205a58f9c27ae1766b589 100644 (file)
@@ -24,11 +24,11 @@ namespace HandBrake.Interop.Interop.Json.Encode
         /// <summary>
         /// Gets or sets the copy mask.
         /// </summary>
-        public uint[] CopyMask { get; set; }
+        public string[] CopyMask { get; set; }
 
         /// <summary>
         /// Gets or sets the fallback encoder.
         /// </summary>
-        public int FallbackEncoder { get; set; }
+        public string FallbackEncoder { get; set; }
     }
 }
\ No newline at end of file
index 64ef94fd7c018958b8d1c589b1dcddda6ef1bde9..51989132aa2d1413d4b14973b3d290d16563d221 100644 (file)
@@ -32,7 +32,7 @@ namespace HandBrake.Interop.Interop.Json.Encode
         /// <summary>
         /// Gets or sets the encoder.
         /// </summary>
-        public int Encoder { get; set; }
+        public string Encoder { get; set; }
 
         /// <summary>
         /// Gets or sets the gain.
index 0d8b2daebc059322cf95c28dea1045bff0fa5151..ab822c33acb058e746c44f5f5aa6fe85ab01e35d 100644 (file)
@@ -44,6 +44,6 @@ namespace HandBrake.Interop.Interop.Json.Encode
         /// <summary>
         /// Gets or sets the mux.
         /// </summary>
-        public int Mux { get; set; }
+        public string Mux { get; set; }
     }
 }
\ No newline at end of file
index f77c0d3350e5979c66d6d587f0abcde6f9d24458..992d677091f493be6c8de2735d79a313e785211a 100644 (file)
@@ -25,7 +25,7 @@ namespace HandBrake.Interop.Interop.Json.Encode
         /// <summary>
         /// Gets or sets the codec.
         /// </summary>
-        public int Encoder { get; set; }
+        public string Encoder { get; set; }
 
         /// <summary>
         /// Gets or sets the level.
index 3e133c5fa3c7a32f86dbeed892330598a80eb701..a6488494149fe5e0cb69477f0deb1b637a779564 100644 (file)
@@ -147,7 +147,7 @@ namespace HandBrakeWPF.Services.Encode.Factories
                 },
                 ChapterMarkers = job.IncludeChapterMarkers,
                 AlignAVStart = job.AlignAVStart,
-                Mux = HBFunctions.hb_container_get_from_name(job.OutputFormat == OutputFormat.Mp4 ? "av_mp4" : "av_mkv"), // TODO tidy up.
+                Mux = EnumHelper<OutputFormat>.GetShortName(job.OutputFormat), 
                 ChapterList = new List<Chapter>()
             };
 
@@ -271,7 +271,7 @@ namespace HandBrakeWPF.Services.Encode.Factories
             Validate.NotNull(videoEncoder, "Video encoder " + job.VideoEncoder + " not recognized.");
             if (videoEncoder != null)
             {
-                video.Encoder = videoEncoder.Id;
+                video.Encoder = videoEncoder.ShortName;
             }
 
             string advancedOptions = job.ShowAdvancedTab ? job.AdvancedEncoderOptions : string.Empty;
@@ -331,19 +331,19 @@ namespace HandBrakeWPF.Services.Encode.Factories
         {
             Audio audio = new Audio();
 
-            List<uint> copyMaskList = new List<uint>();
-            if (job.AllowedPassthruOptions.AudioAllowAACPass) copyMaskList.Add(NativeConstants.HB_ACODEC_AAC_PASS);
-            if (job.AllowedPassthruOptions.AudioAllowAC3Pass) copyMaskList.Add(NativeConstants.HB_ACODEC_AC3_PASS);
-            if (job.AllowedPassthruOptions.AudioAllowDTSHDPass) copyMaskList.Add(NativeConstants.HB_ACODEC_DCA_HD_PASS);
-            if (job.AllowedPassthruOptions.AudioAllowDTSPass) copyMaskList.Add(NativeConstants.HB_ACODEC_DCA_PASS);
-            if (job.AllowedPassthruOptions.AudioAllowEAC3Pass) copyMaskList.Add(NativeConstants.HB_ACODEC_EAC3_PASS);
-            if (job.AllowedPassthruOptions.AudioAllowFlacPass) copyMaskList.Add(NativeConstants.HB_ACODEC_FLAC_PASS);
-            if (job.AllowedPassthruOptions.AudioAllowMP3Pass) copyMaskList.Add(NativeConstants.HB_ACODEC_MP3_PASS);
-            if (job.AllowedPassthruOptions.AudioAllowTrueHDPass) copyMaskList.Add(NativeConstants.HB_ACODEC_TRUEHD_PASS);
+            List<string> copyMaskList = new List<string>();
+            if (job.AllowedPassthruOptions.AudioAllowAACPass) copyMaskList.Add(EnumHelper<AudioEncoder>.GetShortName(AudioEncoder.AacPassthru));
+            if (job.AllowedPassthruOptions.AudioAllowAC3Pass) copyMaskList.Add(EnumHelper<AudioEncoder>.GetShortName(AudioEncoder.Ac3Passthrough));
+            if (job.AllowedPassthruOptions.AudioAllowDTSHDPass) copyMaskList.Add(EnumHelper<AudioEncoder>.GetShortName(AudioEncoder.DtsHDPassthrough));
+            if (job.AllowedPassthruOptions.AudioAllowDTSPass) copyMaskList.Add(EnumHelper<AudioEncoder>.GetShortName(AudioEncoder.DtsPassthrough));
+            if (job.AllowedPassthruOptions.AudioAllowEAC3Pass) copyMaskList.Add(EnumHelper<AudioEncoder>.GetShortName(AudioEncoder.EAc3Passthrough));
+            if (job.AllowedPassthruOptions.AudioAllowFlacPass) copyMaskList.Add(EnumHelper<AudioEncoder>.GetShortName(AudioEncoder.FlacPassthru));
+            if (job.AllowedPassthruOptions.AudioAllowMP3Pass) copyMaskList.Add(EnumHelper<AudioEncoder>.GetShortName(AudioEncoder.Mp3Passthru));
+            if (job.AllowedPassthruOptions.AudioAllowTrueHDPass) copyMaskList.Add(EnumHelper<AudioEncoder>.GetShortName(AudioEncoder.TrueHDPassthrough));
             audio.CopyMask = copyMaskList.ToArray();
 
             HBAudioEncoder audioEncoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(job.AllowedPassthruOptions.AudioEncoderFallback));
-            audio.FallbackEncoder = audioEncoder.Id;
+            audio.FallbackEncoder = audioEncoder.ShortName;
 
             audio.AudioList = new List<HandBrake.Interop.Interop.Json.Encode.AudioTrack>();
             foreach (AudioTrack item in job.AudioTracks)
@@ -365,7 +365,7 @@ namespace HandBrakeWPF.Services.Encode.Factories
                 {
                     Track = (item.Track.HasValue ? item.Track.Value : 0) - 1,
                     DRC = item.DRC,
-                    Encoder = encoder.Id,
+                    Encoder = encoder.ShortName,
                     Gain = item.Gain,
                     Mixdown = mixdown != null ? mixdown.Id : -1,
                     NormalizeMixLevel = false,
index 8c55e45b1daa461ad3773e0280703213b321c3b2..dc4f004803529ef1e6162c8c11c54a6b3463a4c6 100644 (file)
@@ -17,11 +17,11 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
     public enum OutputFormat
     {
         [DisplayName("MP4")]
-        [ShortName("av_mp4")]
+        [ShortName("mp4")]
         Mp4 = 0,
 
         [DisplayName("MKV")]
-        [ShortName("av_mkv")]
+        [ShortName("mkv")]
         Mkv,
     }
 }