]> granicus.if.org Git - handbrake/commitdiff
WinGui: Some Model Re-factoring by RandomEngy
authorsr55 <sr55.hb@outlook.com>
Sun, 3 May 2015 17:18:59 +0000 (17:18 +0000)
committersr55 <sr55.hb@outlook.com>
Sun, 3 May 2015 17:18:59 +0000 (17:18 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7151 b64f7644-9d1e-0410-96f1-a4d463321fa5

25 files changed:
win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
win/CS/HandBrake.ApplicationServices/Interop/Factories/AnamorphicFactory.cs
win/CS/HandBrake.ApplicationServices/Interop/HandBrakeEncoderHelpers.cs
win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs
win/CS/HandBrake.ApplicationServices/Interop/HandBrakeUtils.cs
win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Audio.cs
win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/AudioTrack.cs [moved from win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/AudioList.cs with 90% similarity]
win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Chapter.cs [moved from win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/ChapterList.cs with 76% similarity]
win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Destination.cs
win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/JsonEncodeObject.cs
win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/MetaData.cs
win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/SubtitleTrack.cs [moved from win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/SubtitleList.cs with 84% similarity]
win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Subtitles.cs
win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceAudioTrack.cs [moved from win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/AudioTrack.cs with 85% similarity]
win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceChapter.cs [moved from win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/ChapterTrack.cs with 77% similarity]
win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceMetadata.cs [moved from win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/MetaData.cs with 81% similarity]
win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceSubtitleTrack.cs [moved from win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SubtitleTrack.cs with 87% similarity]
win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceTitle.cs
win/CS/HandBrake.ApplicationServices/Interop/Model/Preview/PreviewSettings.cs
win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs
win/CS/HandBrake.ApplicationServices/Services/Scan/Interfaces/IScan.cs
win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs
win/CS/HandBrakeWPF/Commands/CancelScanCommand.cs
win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs
win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs

index c3995689cf5d314404b937bdb53e3bfb60d23f83..bb6fef13676e2442b43fa42f3032a560dea1e91a 100644 (file)
     <Compile Include="Interop\Interfaces\IHandBrakeInstance.cs" />\r
     <Compile Include="Interop\Json\Anamorphic\AnamorphicGeometry.cs" />\r
     <Compile Include="Interop\Json\Anamorphic\DestSettings.cs" />\r
-    <Compile Include="Interop\Json\Encode\QSV.cs" />\r
-    <Compile Include="Interop\Json\Shared\PAR.cs" />\r
-    <Compile Include="Interop\Json\Encode\Audio.cs" />\r
-    <Compile Include="Interop\Json\Encode\AudioList.cs" />\r
-    <Compile Include="Interop\Json\Encode\ChapterList.cs" />\r
-    <Compile Include="Interop\Json\Encode\Destination.cs" />\r
-    <Compile Include="Interop\Json\Encode\Filters.cs" />\r
-    <Compile Include="Interop\Json\Encode\Filter.cs" />\r
-    <Compile Include="Interop\Json\Encode\JsonEncodeObject.cs" />\r
-    <Compile Include="Interop\Json\Encode\MetaData.cs" />\r
-    <Compile Include="Interop\Json\Encode\Mp4Options.cs" />\r
-    <Compile Include="Interop\Json\Encode\Range.cs" />\r
-    <Compile Include="Interop\Json\Encode\SubtitleSearch.cs" />\r
-    <Compile Include="Interop\Json\Encode\Source.cs" />\r
-    <Compile Include="Interop\Json\Encode\SRT.cs" />\r
-    <Compile Include="Interop\Json\Encode\Subtitles.cs" />\r
-    <Compile Include="Interop\Json\Encode\SubtitleList.cs" />\r
-    <Compile Include="Interop\Json\Encode\Video.cs" />\r
-    <Compile Include="Interop\Factories\AnamorphicFactory.cs" />\r
-    <Compile Include="Services\Encode\Factories\EncodeFactory.cs" />\r
-    <Compile Include="Interop\Json\Scan\AudioTrack.cs" />\r
-    <Compile Include="Interop\Json\Scan\ChapterTrack.cs" />\r
-    <Compile Include="Interop\Json\Scan\Color.cs" />\r
-    <Compile Include="Interop\Json\Scan\Duration.cs" />\r
-    <Compile Include="Interop\Json\Scan\FrameRate.cs" />\r
-    <Compile Include="Interop\Json\Shared\Geometry.cs" />\r
-    <Compile Include="Interop\Json\Scan\JsonScanObject.cs" />\r
-    <Compile Include="Interop\Json\Scan\MetaData.cs" />\r
-    <Compile Include="Interop\Json\Scan\SubtitleTrack.cs" />\r
-    <Compile Include="Interop\Json\Scan\SourceTitle.cs" />\r
-    <Compile Include="Interop\Json\State\JsonState.cs" />\r
-    <Compile Include="Interop\Json\State\Scanning.cs" />\r
+    <Compile Include="Interop\Json\Encode\QSV.cs" />
+    <Compile Include="Interop\Json\Shared\PAR.cs" />
+    <Compile Include="Interop\Json\Encode\Audio.cs" />
+    <Compile Include="Interop\Json\Encode\AudioTrack.cs" />
+    <Compile Include="Interop\Json\Encode\Chapter.cs" />
+    <Compile Include="Interop\Json\Encode\Destination.cs" />
+    <Compile Include="Interop\Json\Encode\Filters.cs" />
+    <Compile Include="Interop\Json\Encode\Filter.cs" />
+    <Compile Include="Interop\Json\Encode\JsonEncodeObject.cs" />
+    <Compile Include="Interop\Json\Encode\Metadata.cs" />
+    <Compile Include="Interop\Json\Encode\Mp4Options.cs" />
+    <Compile Include="Interop\Json\Encode\Range.cs" />
+    <Compile Include="Interop\Json\Encode\SubtitleSearch.cs" />
+    <Compile Include="Interop\Json\Encode\Source.cs" />
+    <Compile Include="Interop\Json\Encode\SRT.cs" />
+    <Compile Include="Interop\Json\Encode\Subtitles.cs" />
+    <Compile Include="Interop\Json\Encode\SubtitleTrack.cs" />
+    <Compile Include="Interop\Json\Encode\Video.cs" />
+    <Compile Include="Interop\Factories\AnamorphicFactory.cs" />
+    <Compile Include="Services\Encode\Factories\EncodeFactory.cs" />
+    <Compile Include="Interop\Json\Scan\SourceAudioTrack.cs" />
+    <Compile Include="Interop\Json\Scan\SourceChapter.cs" />
+    <Compile Include="Interop\Json\Scan\Color.cs" />
+    <Compile Include="Interop\Json\Scan\Duration.cs" />
+    <Compile Include="Interop\Json\Scan\FrameRate.cs" />
+    <Compile Include="Interop\Json\Shared\Geometry.cs" />
+    <Compile Include="Interop\Json\Scan\JsonScanObject.cs" />
+    <Compile Include="Interop\Json\Scan\SourceMetadata.cs" />
+    <Compile Include="Interop\Json\Scan\SourceSubtitleTrack.cs" />
+    <Compile Include="Interop\Json\Scan\SourceTitle.cs" />
+    <Compile Include="Interop\Json\State\JsonState.cs" />
+    <Compile Include="Interop\Json\State\Scanning.cs" />
     <Compile Include="Interop\Json\State\WorkDone.cs" />\r
     <Compile Include="Interop\Json\State\Working.cs" />\r
     <Compile Include="Interop\Model\BitrateLimits.cs" />\r
index abaa0fc25ca1b23606687817ca006e863e13cd35..7417233296efd5b57f81ae597d9402e9e32b87ed 100644 (file)
@@ -15,6 +15,7 @@ namespace HandBrake.ApplicationServices.Interop.Factories
     using HandBrake.ApplicationServices.Interop.Json.Shared;\r
     using HandBrake.ApplicationServices.Interop.Model;\r
     using HandBrake.ApplicationServices.Interop.Model.Encoding;\r
+    using HandBrake.ApplicationServices.Interop.Model.Preview;\r
     using HandBrake.ApplicationServices.Services.Encode.Model;\r
 \r
     /// <summary>\r
@@ -51,10 +52,10 @@ namespace HandBrake.ApplicationServices.Interop.Factories
         {\r
             int settingMode = (int)keepWidthOrHeight + (job.KeepDisplayAspect ? 0x04 : 0);\r
 \r
-            // Sanatise the Geometry First.\r
+            // Sanitize the Geometry First.\r
             AnamorphicGeometry anamorphicGeometry = new AnamorphicGeometry\r
             {\r
-                SourceGeometry = new Geometry()\r
+                SourceGeometry = new Geometry\r
                                  {\r
                                     Width = title.Resolution.Width,\r
                                     Height = title.Resolution.Height,\r
@@ -91,5 +92,58 @@ namespace HandBrake.ApplicationServices.Interop.Factories
 \r
             return HandBrakeUtils.GetAnamorphicSize(anamorphicGeometry);\r
         }\r
+\r
+        /// <summary>\r
+        /// Finds output geometry for the given preview settings and title.\r
+        /// </summary>\r
+        /// <param name="settings">The preview settings.</param>\r
+        /// <param name="title">Information on the title to consider.</param>\r
+        /// <returns></returns>\r
+        public static Geometry CreateGeometry(PreviewSettings settings, SourceVideoInfo title)\r
+        {\r
+            int settingMode = settings.KeepDisplayAspect ? 0x04 : 0;\r
+\r
+            // Sanitize the Geometry First.\r
+            AnamorphicGeometry anamorphicGeometry = new AnamorphicGeometry\r
+            {\r
+                SourceGeometry = new Geometry\r
+                {\r
+                    Width = title.Resolution.Width,\r
+                    Height = title.Resolution.Height,\r
+                    PAR = new PAR { Num = title.ParVal.Width, Den = title.ParVal.Height }\r
+                },\r
+                DestSettings = new DestSettings\r
+                {\r
+                    AnamorphicMode = (int)settings.Anamorphic,\r
+                    Geometry =\r
+                    {\r
+                        Width = settings.Width,\r
+                        Height = settings.Height,\r
+                        PAR = new PAR\r
+                        {\r
+                            Num = settings.Anamorphic != Anamorphic.Custom ? title.ParVal.Width : settings.PixelAspectX,\r
+                            Den = settings.Anamorphic != Anamorphic.Custom ? title.ParVal.Height : settings.PixelAspectY,\r
+                        }\r
+                    },\r
+                    Keep = settingMode,\r
+                    Crop = new List<int> { settings.Cropping.Top, settings.Cropping.Bottom, settings.Cropping.Left, settings.Cropping.Right },\r
+                    Modulus = settings.Modulus ?? 16,\r
+                    MaxWidth = settings.MaxWidth,\r
+                    MaxHeight = settings.MaxHeight,\r
+                    ItuPAR = false\r
+                }\r
+            };\r
+\r
+            if (settings.Anamorphic == Anamorphic.Custom)\r
+            {\r
+                anamorphicGeometry.DestSettings.Geometry.PAR = new PAR { Num = settings.PixelAspectX, Den = settings.PixelAspectY };\r
+            }\r
+            else\r
+            {\r
+                anamorphicGeometry.DestSettings.Geometry.PAR = new PAR { Num = title.ParVal.Width, Den = title.ParVal.Height };\r
+            }\r
+\r
+            return HandBrakeUtils.GetAnamorphicSize(anamorphicGeometry);\r
+        }\r
     }\r
 }\r
index 714de654732781533b37e03207fcc7fb38756585..69075a7f930184774d8b8cc50b9f0425b4f64f54 100644 (file)
@@ -33,33 +33,33 @@ namespace HandBrake.ApplicationServices.Interop
         /// </summary>\r
         private static List<HBVideoEncoder> videoEncoders;\r
 \r
-        /// <summary>\r
-        /// Video framerates in pts.\r
-        /// </summary>\r
-        private static List<HBRate> videoFramerates; \r
-\r
-        /// <summary>\r
-        /// List of HandBrake mixdowns.\r
+        /// <summary>
+        /// Video framerates in pts.
+        /// </summary>
+        private static List<HBRate> videoFramerates;
+
+        /// <summary>
+        /// List of HandBrake mixdowns.
         /// </summary>\r
         private static List<HBMixdown> mixdowns;\r
 \r
-        /// <summary>\r
-        /// List of HandBrake containers.\r
-        /// </summary>\r
-        private static List<HBContainer> containers; \r
-\r
-        /// <summary>\r
-        /// The audio bitrates.\r
+        /// <summary>
+        /// List of HandBrake containers.
+        /// </summary>
+        private static List<HBContainer> containers;
+
+        /// <summary>
+        /// The audio bitrates.
         /// </summary>\r
         private static List<int> audioBitrates;\r
 \r
-        /// <summary>\r
-        /// Audio sample rates in Hz.\r
-        /// </summary>\r
-        private static List<HBRate> audioSampleRates; \r
-\r
-        /// <summary>\r
-        /// Initializes static members of the HandBrakeEncoderHelpers class.\r
+        /// <summary>
+        /// Audio sample rates in Hz.
+        /// </summary>
+        private static List<HBRate> audioSampleRates;
+
+        /// <summary>
+        /// Initializes static members of the HandBrakeEncoderHelpers class.
         /// </summary>\r
         static HandBrakeEncoderHelpers()\r
         {\r
@@ -109,13 +109,13 @@ namespace HandBrake.ApplicationServices.Interop
                 {\r
                     videoFramerates = InteropUtilities.ToListFromIterator<hb_rate_s, HBRate>(HBFunctions.hb_video_framerate_get_next, HandBrakeUnitConversionHelpers.NativeToRate);\r
                 }\r
-\r
-                return videoFramerates;\r
-            }\r
-        } \r
-\r
-        /// <summary>\r
-        /// Gets a list of supported mixdowns.\r
+
+                return videoFramerates;
+            }
+        }
+
+        /// <summary>
+        /// Gets a list of supported mixdowns.
         /// </summary>\r
         public static List<HBMixdown> Mixdowns\r
         {\r
@@ -257,12 +257,73 @@ namespace HandBrake.ApplicationServices.Interop
         public static HBContainer GetContainer(string shortName)\r
         {\r
             return Containers.SingleOrDefault(c => c.ShortName == shortName);\r
-        }\r
-\r
-        /// <summary>\r
-        /// Determines if the given encoder is compatible with the given track.\r
-        /// </summary>\r
-        /// <param name="codecId">\r
+        }
+
+        /// <summary>
+        /// Returns true if the subtitle source type can be set to forced only.
+        /// </summary>
+        /// <param name="source">The subtitle source type (SSA, VobSub, etc)</param>
+        /// <returns>True if the subtitle source type can be set to forced only.</returns>
+        public static bool SubtitleCanSetForcedOnly(int source)
+        {
+            return HBFunctions.hb_subtitle_can_force(source) > 0;
+        }
+
+        /// <summary>
+        /// Returns true if the subtitle source type can be burned in.
+        /// </summary>
+        /// <param name="source">The subtitle source type (SSA, VobSub, etc)</param>
+        /// <returns>True if the subtitle source type can be burned in.</returns>
+        public static bool SubtitleCanBurn(int source)
+        {
+            return HBFunctions.hb_subtitle_can_burn(source) > 0;
+        }
+
+        /// <summary>
+        /// Returns true if the subtitle type can be passed through using the given muxer.
+        /// </summary>
+        /// <param name="subtitleSourceType">The subtitle source type (SSA, VobSub, etc)</param>
+        /// <param name="muxer">The ID of the muxer.</param>
+        /// <returns>True if the subtitle type can be passed through with the given muxer.</returns>
+        public static bool SubtitleCanPassthrough(int subtitleSourceType, int muxer)
+        {
+            return HBFunctions.hb_subtitle_can_pass(subtitleSourceType, muxer) > 0;
+        }
+
+        /// <summary>
+        /// Gets the subtitle source type's name.
+        /// </summary>
+        /// <param name="source">The subtitle source type (SSA, VobSub, etc).</param>
+        /// <returns>The name of the subtitle source.</returns>
+        public static string GetSubtitleSourceName(int source)
+        {
+            switch ((hb_subtitle_s_subsource)source)
+            {
+                case hb_subtitle_s_subsource.CC608SUB:
+                    return "CC608";
+                case hb_subtitle_s_subsource.CC708SUB:
+                    return "CC708";
+                case hb_subtitle_s_subsource.SRTSUB:
+                    return "SRT";
+                case hb_subtitle_s_subsource.SSASUB:
+                    return "SSA";
+                case hb_subtitle_s_subsource.TX3GSUB:
+                    return "TX3G";
+                case hb_subtitle_s_subsource.UTF8SUB:
+                    return "UTF8";
+                case hb_subtitle_s_subsource.VOBSUB:
+                    return "VobSub";
+                case hb_subtitle_s_subsource.PGSSUB:
+                    return "PGS";
+                default:
+                    return string.Empty;
+            }
+        }
+
+        /// <summary>
+        /// Determines if the given encoder is compatible with the given track.
+        /// </summary>
+        /// <param name="codecId">
         /// The codec Id.\r
         /// </param>\r
         /// <param name="encoder">\r
@@ -307,13 +368,13 @@ namespace HandBrake.ApplicationServices.Interop
         /// </param>\r
         /// <returns>\r
         /// True if the encoder supports the mixdown.\r
-        /// </returns>\r
-        public static bool MixdownHasCodecSupport(HBMixdown mixdown, HBAudioEncoder encoder)\r
-        {\r
-            return HBFunctions.hb_mixdown_has_codec_support(mixdown.Id, (uint) encoder.Id) > 0;\r
-        }\r
-\r
-        /// <summary>\r
+        /// </returns>
+        public static bool MixdownHasCodecSupport(HBMixdown mixdown, HBAudioEncoder encoder)
+        {
+            return HBFunctions.hb_mixdown_has_codec_support(mixdown.Id, (uint)encoder.Id) > 0;
+        }
+
+        /// <summary>
         /// Determines if DRC can be applied to the given track with the given encoder.\r
         /// </summary>\r
         /// <param name="trackNumber">\r
@@ -428,15 +489,15 @@ namespace HandBrake.ApplicationServices.Interop
             int direction = 0;\r
 \r
             HBFunctions.hb_video_quality_get_limits((uint)encoder.Id, ref low, ref high, ref granularity, ref direction);\r
-\r
-            return new VideoQualityLimits\r
-                {\r
-                    Low = low, \r
-                    High = high, \r
-                    Granularity = granularity, \r
-                    Ascending = direction == 0\r
-                };\r
-        }\r
+
+            return new VideoQualityLimits
+                {
+                    Low = low,
+                    High = high,
+                    Granularity = granularity,
+                    Ascending = direction == 0
+                };
+        }
 \r
         /// <summary>\r
         /// Sanitizes an audio bitrate given the output codec, sample rate and mixdown.\r
@@ -475,13 +536,13 @@ namespace HandBrake.ApplicationServices.Interop
         /// </param>\r
         /// <returns>\r
         /// The default bitrate for these parameters.\r
-        /// </returns>\r
-        public static int GetDefaultBitrate(HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown)\r
-        {\r
-            return HBFunctions.hb_audio_bitrate_get_default((uint) encoder.Id, sampleRate, mixdown.Id);\r
-        }\r
-\r
-        /// <summary>\r
+        /// </returns>
+        public static int GetDefaultBitrate(HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown)
+        {
+            return HBFunctions.hb_audio_bitrate_get_default((uint)encoder.Id, sampleRate, mixdown.Id);
+        }
+
+        /// <summary>
         /// Gets limits on audio quality for a given encoder.\r
         /// </summary>\r
         /// <param name="encoderId">\r
@@ -495,15 +556,15 @@ namespace HandBrake.ApplicationServices.Interop
             float low = 0, high = 0, granularity = 0;\r
             int direction = 0;\r
             HBFunctions.hb_audio_quality_get_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction);\r
-\r
-            return new RangeLimits\r
-            {\r
-                Low = low, \r
-                High = high, \r
-                Granularity = granularity, \r
-                Ascending = direction == 0\r
-            };\r
-        }\r
+
+            return new RangeLimits
+            {
+                Low = low,
+                High = high,
+                Granularity = granularity,
+                Ascending = direction == 0
+            };
+        }
 \r
         /// <summary>\r
         /// Gets limits on audio compression for a given encoder.\r
@@ -519,14 +580,14 @@ namespace HandBrake.ApplicationServices.Interop
             float low = 0, high = 0, granularity = 0;\r
             int direction = 0;\r
             HBFunctions.hb_audio_compression_get_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction);\r
-\r
-            return new RangeLimits\r
-            {\r
-                Low = low, \r
-                High = high, \r
-                Granularity = granularity, \r
-                Ascending = direction == 0\r
-            };\r
-        }\r
+
+            return new RangeLimits
+            {
+                Low = low,
+                High = high,
+                Granularity = granularity,
+                Ascending = direction == 0
+            };
+        }
     }\r
 }\r
index 9e89190cd00b61d77cdeb826957071b1efd17c52..8aafbc02db3417e23f4d4ba9354e304d1d97b4ac 100644 (file)
@@ -60,6 +60,11 @@ namespace HandBrake.ApplicationServices.Interop
         /// </summary>\r
         private IntPtr hbHandle;\r
 \r
+        /// <summary>\r
+        /// The number of previews created during scan.\r
+        /// </summary>\r
+        private int previewCount;\r
+\r
         /// <summary>\r
         /// The timer to poll for scan status.\r
         /// </summary>\r
@@ -120,7 +125,18 @@ namespace HandBrake.ApplicationServices.Interop
         {\r
             get\r
             {\r
-                return this.Handle;\r
+                return this.hbHandle;\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Gets the number of previews created during scan.\r
+        /// </summary>\r
+        public int PreviewCount\r
+        {\r
+            get\r
+            {\r
+                return this.previewCount;\r
             }\r
         }\r
 \r
@@ -200,6 +216,8 @@ namespace HandBrake.ApplicationServices.Interop
         /// </param>\r
         public void StartScan(string path, int previewCount, TimeSpan minDuration, int titleIndex)\r
         {\r
+            this.previewCount = previewCount;\r
+\r
             IntPtr pathPtr = InteropUtilities.ToUtf8PtrFromString(path);\r
             HBFunctions.hb_scan(this.hbHandle, pathPtr, titleIndex, previewCount, 1, (ulong)(minDuration.TotalSeconds * 90000));\r
             Marshal.FreeHGlobal(pathPtr);\r
@@ -237,7 +255,7 @@ namespace HandBrake.ApplicationServices.Interop
         /// <remarks>\r
         /// Only incorporates sizing and aspect ratio into preview image.\r
         /// </remarks>\r
-        /// <param name="job">\r
+        /// <param name="settings">\r
         /// The encode job to preview.\r
         /// </param>\r
         /// <param name="previewNumber">\r
@@ -247,41 +265,46 @@ namespace HandBrake.ApplicationServices.Interop
         /// An image with the requested preview.\r
         /// </returns>\r
         [HandleProcessCorruptedStateExceptions]\r
-        public BitmapImage GetPreview(PreviewSettings job, int previewNumber)\r
+        public BitmapImage GetPreview(PreviewSettings settings, int previewNumber)\r
         {\r
-            SourceTitle title = this.Titles.TitleList.FirstOrDefault(t => t.Index == job.Title);\r
+            SourceTitle title = this.Titles.TitleList.FirstOrDefault(t => t.Index == settings.TitleNumber);\r
             Validate.NotNull(title, "GetPreview: Title should not have been null. This is probably a bug.");\r
 \r
-            // Creat the Expected Output Geometry details for libhb.\r
+            // Create the Expected Output Geometry details for libhb.\r
             hb_geometry_settings_s uiGeometry = new hb_geometry_settings_s\r
             {\r
-                crop = new[] { job.Cropping.Top, job.Cropping.Bottom, job.Cropping.Left, job.Cropping.Right }, \r
+                crop = new[] { settings.Cropping.Top, settings.Cropping.Bottom, settings.Cropping.Left, settings.Cropping.Right }, \r
                 itu_par = 0, \r
-                keep = (int)AnamorphicFactory.KeepSetting.HB_KEEP_WIDTH + (job.KeepDisplayAspect ? 0x04 : 0), // TODO Keep Width?\r
-                maxWidth = job.MaxWidth ?? 0\r
-                maxHeight = job.MaxHeight ?? 0\r
-                mode = (int)(hb_anamorphic_mode_t)job.Anamorphic, \r
-                modulus = job.Modulus ?? 16, \r
+                keep = settings.KeepDisplayAspect ? 0x04 : 0,\r
+                maxWidth = settings.MaxWidth\r
+                maxHeight = settings.MaxHeight\r
+                mode = (int)(hb_anamorphic_mode_t)settings.Anamorphic, \r
+                modulus = settings.Modulus ?? 16, \r
                 geometry = new hb_geometry_s\r
                 {\r
-                    height = job.Height ?? 0\r
-                    width = job.Width ?? 0\r
-                    par = job.Anamorphic != Anamorphic.Custom\r
+                    height = settings.Height\r
+                    width = settings.Width\r
+                    par = settings.Anamorphic != Anamorphic.Custom\r
                         ? new hb_rational_t { den = title.Geometry.PAR.Den, num = title.Geometry.PAR.Num }\r
-                        : new hb_rational_t { den = job.PixelAspectY, num = job.PixelAspectX }\r
+                        : new hb_rational_t { den = settings.PixelAspectY, num = settings.PixelAspectX }\r
                 }\r
             };\r
 \r
-            // Sanatise the input.\r
-            Geometry resultGeometry = AnamorphicFactory.CreateGeometry(job, new SourceVideoInfo(new Size(title.Geometry.Width, title.Geometry.Height), new Size(title.Geometry.PAR.Num, title.Geometry.PAR.Den)), AnamorphicFactory.KeepSetting.HB_KEEP_WIDTH); // TODO this keep isn't right.\r
-            int width = resultGeometry.Width * resultGeometry.PAR.Num / resultGeometry.PAR.Den;\r
+            // Sanitize the input.\r
+            Geometry resultGeometry = AnamorphicFactory.CreateGeometry(\r
+                settings,\r
+                new SourceVideoInfo(\r
+                    new Size(title.Geometry.Width, title.Geometry.Height),\r
+                    new Size(title.Geometry.PAR.Num, title.Geometry.PAR.Den)));\r
+            int width = resultGeometry.Width;\r
             int height = resultGeometry.Height;\r
-            uiGeometry.geometry.height = resultGeometry.Height; // Prased the height now.\r
-            int outputWidth = width;\r
-            int outputHeight = height;\r
-           \r
+            uiGeometry.geometry.width = width;\r
+            uiGeometry.geometry.height = height;\r
+            uiGeometry.geometry.par.num = settings.PixelAspectX;\r
+            uiGeometry.geometry.par.den = settings.PixelAspectY;\r
+\r
             // Fetch the image data from LibHb\r
-            IntPtr resultingImageStuct = HBFunctions.hb_get_preview2(this.hbHandle, job.Title, previewNumber, ref uiGeometry, 0);\r
+            IntPtr resultingImageStuct = HBFunctions.hb_get_preview2(this.hbHandle, settings.TitleNumber, previewNumber, ref uiGeometry, 0);\r
             hb_image_s image = InteropUtilities.ToStructureFromPtr<hb_image_s>(resultingImageStuct);\r
 \r
             // Copy the filled image buffer to a managed array.\r
@@ -292,8 +315,8 @@ namespace HandBrake.ApplicationServices.Interop
             byte[] managedBuffer = new byte[imageBufferSize];\r
             Marshal.Copy(image.plane[0].data, managedBuffer, 0, imageBufferSize);\r
 \r
-            var bitmap = new Bitmap(outputWidth, outputHeight);\r
-            BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, outputWidth, outputHeight), ImageLockMode.WriteOnly, PixelFormat.Format32bppRgb);\r
+            var bitmap = new Bitmap(width, height);\r
+            BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, PixelFormat.Format32bppRgb);\r
 \r
             IntPtr ptr = bitmapData.Scan0; // Pointer to the first pixel.\r
             for (int i = 0; i < image.height; i++)\r
@@ -301,7 +324,7 @@ namespace HandBrake.ApplicationServices.Interop
                 try\r
                 {\r
                     Marshal.Copy(managedBuffer, i * stride_width, ptr, stride_width);\r
-                    ptr = IntPtr.Add(ptr, outputWidth * 4);\r
+                    ptr = IntPtr.Add(ptr, width * 4);\r
                 }\r
                 catch (Exception exc)\r
                 {\r
@@ -340,6 +363,18 @@ namespace HandBrake.ApplicationServices.Interop
             }\r
         }\r
 \r
+        /// <summary>\r
+        /// Determines if DRC can be applied to the given track with the given encoder.\r
+        /// </summary>\r
+        /// <param name="trackNumber">The track Number.</param>\r
+        /// <param name="encoder">The encoder to use for DRC.</param>\r
+        /// <param name="title">The title.</param>\r
+        /// <returns>True if DRC can be applied to the track with the given encoder.</returns>\r
+        public bool CanApplyDrc(int trackNumber, HBAudioEncoder encoder, int title)\r
+        {\r
+            return HBFunctions.hb_audio_can_apply_drc2(this.hbHandle, title, trackNumber, encoder.Id) > 0;\r
+        }\r
+\r
         /// <summary>\r
         /// Starts an encode with the given job.\r
         /// </summary>\r
@@ -355,7 +390,6 @@ namespace HandBrake.ApplicationServices.Interop
             };\r
 \r
             string encode = JsonConvert.SerializeObject(encodeObject, Formatting.Indented, settings);\r
-            LogHelper.LogMessage(new LogMessage(encode, LogMessageType.encodeJson, LogLevel.debug));\r
             HBFunctions.hb_add_json(this.hbHandle, InteropUtilities.ToUtf8PtrFromString(encode));\r
             HBFunctions.hb_start(this.hbHandle);\r
 \r
@@ -431,6 +465,17 @@ namespace HandBrake.ApplicationServices.Interop
             GC.SuppressFinalize(this);\r
         }\r
 \r
+        /// <summary>\r
+        /// Gets a value indicating whether the object is disposed.\r
+        /// </summary>\r
+        public bool IsDisposed\r
+        {\r
+            get\r
+            {\r
+                return this.disposed;\r
+            }\r
+        }\r
+\r
         /// <summary>\r
         /// Frees any resources associated with this object.\r
         /// </summary>\r
index 7a00bb8e9dfb1cc63e8939aa828cdb1c6066e83d..aad5df21c5f13522f4afdd2357fe89f0796b902a 100644 (file)
@@ -20,23 +20,18 @@ namespace HandBrake.ApplicationServices.Interop
     using HandBrake.ApplicationServices.Interop.Json.Shared;\r
     using HandBrake.ApplicationServices.Services.Logging;\r
     using HandBrake.ApplicationServices.Services.Logging.Model;\r
-\r
-    using Newtonsoft.Json;\r
-\r
-    /// <summary>\r
-    /// HandBrake Interop Utilities\r
-    /// </summary>\r
-    public static class HandBrakeUtils\r
-    {\r
-        /// <summary>\r
-        /// Estimated overhead in bytes for each frame in output container.\r
-        /// </summary>\r
-        internal const int ContainerOverheadPerFrame = 6;\r
-\r
-        /// <summary>\r
-        /// The callback for log messages from HandBrake.\r
-        /// </summary>\r
-        private static LoggingCallback loggingCallback;\r
+
+    using Newtonsoft.Json;
+
+       /// <summary>
+    /// HandBrake Interop Utilities
+    /// </summary>
+    public static class HandBrakeUtils
+    {
+        /// <summary>
+        /// The callback for log messages from HandBrake.
+        /// </summary>
+        private static LoggingCallback loggingCallback;
 \r
         /// <summary>\r
         /// The callback for error messages from HandBrake.\r
@@ -294,25 +289,25 @@ namespace HandBrake.ApplicationServices.Interop
 \r
             string x264Settings = Marshal.PtrToStringAnsi(ptr);\r
 \r
-            return x264Settings;\r
-        }\r
-\r
-        /// <summary>\r
-        /// Gets the final size and PAR of the video, given anamorphic inputs.\r
-        /// </summary>\r
-        /// <param name="anamorphicGeometry">Anamorphic inputs.</param>\r
-        /// <returns>The final size and PAR of the video.</returns>\r
-        public static Geometry GetAnamorphicSize(AnamorphicGeometry anamorphicGeometry)\r
-        {\r
-            string encode = JsonConvert.SerializeObject(anamorphicGeometry, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });\r
-            LogHelper.LogMessage(new LogMessage(encode, LogMessageType.encodeJson, LogLevel.debug));\r
-            IntPtr json = HBFunctions.hb_set_anamorphic_size_json(Marshal.StringToHGlobalAnsi(encode));\r
-            string result = Marshal.PtrToStringAnsi(json);\r
-            return JsonConvert.DeserializeObject<Geometry>(result);\r
-        }\r
-\r
-        /// <summary>\r
-        /// Sends the message logged event to any registered listeners.\r
+            return x264Settings;
+        }
+
+               /// <summary>
+               /// Gets the final size and PAR of the video, given anamorphic inputs.
+               /// </summary>
+               /// <param name="anamorphicGeometry">Anamorphic inputs.</param>
+               /// <returns>The final size and PAR of the video.</returns>
+               public static Geometry GetAnamorphicSize(AnamorphicGeometry anamorphicGeometry)
+               {
+                       string encode = JsonConvert.SerializeObject(anamorphicGeometry, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
+                       LogHelper.LogMessage(new LogMessage(encode, LogMessageType.encodeJson, LogLevel.debug));
+                       IntPtr json = HBFunctions.hb_set_anamorphic_size_json(Marshal.StringToHGlobalAnsi(encode));
+                       string result = Marshal.PtrToStringAnsi(json);
+                       return JsonConvert.DeserializeObject<Geometry>(result);
+               }
+
+        /// <summary>
+        /// Sends the message logged event to any registered listeners.
         /// </summary>\r
         /// <param name="message">\r
         /// The message to send.\r
index 2661a8f17e6f50031de6e303c40ac356140d0283..4e4b61d6b9460d1eaea09fcb81a4c15ab45c4550 100644 (file)
@@ -19,7 +19,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Encode
         /// <summary>\r
         /// Gets or sets the audio list.\r
         /// </summary>\r
-        public List<AudioList> AudioList { get; set; }\r
+        public List<AudioTrack> AudioList { get; set; }\r
 \r
         /// <summary>\r
         /// Gets or sets the copy mask.\r
similarity index 90%
rename from win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/AudioList.cs
rename to win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/AudioTrack.cs
index 2f79ec7e66e9343dd9bfc442b8701c8c534fe9c8..0c628fbb0a6fa0e250cfd2e4c46dfa57f54e3046 100644 (file)
@@ -1,77 +1,77 @@
 ï»¿// --------------------------------------------------------------------------------------------------------------------\r
-// <copyright file="AudioList.cs" company="HandBrake Project (http://handbrake.fr)">\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
-//   The audio list.\r
+//   Represents an audio track to encode.\r
 // </summary>\r
-// --------------------------------------------------------------------------------------------------------------------\r
-\r
-namespace HandBrake.ApplicationServices.Interop.Json.Encode\r
-{\r
-    /// <summary>\r
-    /// The audio list.\r
-    /// </summary>\r
-    public class AudioList\r
-    {\r
-        /// <summary>\r
-        /// Gets or sets the bitrate.\r
-        /// </summary>\r
-        public int? Bitrate { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the compression level.\r
-        /// </summary>\r
-        public double? CompressionLevel { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the drc.\r
-        /// </summary>\r
-        public double DRC { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the encoder.\r
-        /// </summary>\r
-        public int Encoder { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the gain.\r
-        /// </summary>\r
-        public double Gain { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the mixdown.\r
-        /// </summary>\r
-        public int Mixdown { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets a value indicating whether normalize mix level.\r
-        /// </summary>\r
-        public bool NormalizeMixLevel { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the quality.\r
-        /// </summary>\r
-        public double? Quality { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the samplerate.\r
-        /// </summary>\r
-        public int Samplerate { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the Name of the audio track.\r
-        /// </summary>\r
-        public string Name { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the track.\r
-        /// </summary>\r
-        public int Track { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the dither method.\r
-        /// </summary>\r
-        public int DitherMethod { get; set; }\r
-    }\r
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Interop.Json.Encode
+{
+    /// <summary>
+    /// Represents an audio track to encode.
+    /// </summary>
+    public class AudioTrack
+    {
+        /// <summary>
+        /// Gets or sets the bitrate.
+        /// </summary>
+        public int? Bitrate { get; set; }
+
+        /// <summary>
+        /// Gets or sets the compression level.
+        /// </summary>
+        public double? CompressionLevel { get; set; }
+
+        /// <summary>
+        /// Gets or sets the drc.
+        /// </summary>
+        public double DRC { get; set; }
+
+        /// <summary>
+        /// Gets or sets the encoder.
+        /// </summary>
+        public int Encoder { get; set; }
+
+        /// <summary>
+        /// Gets or sets the gain.
+        /// </summary>
+        public double Gain { get; set; }
+
+        /// <summary>
+        /// Gets or sets the mixdown.
+        /// </summary>
+        public int Mixdown { get; set; }
+
+        /// <summary>
+        /// Gets or sets a value indicating whether normalize mix level.
+        /// </summary>
+        public bool NormalizeMixLevel { get; set; }
+
+        /// <summary>
+        /// Gets or sets the quality.
+        /// </summary>
+        public double? Quality { get; set; }
+
+        /// <summary>
+        /// Gets or sets the samplerate.
+        /// </summary>
+        public int Samplerate { get; set; }
+
+        /// <summary>
+        /// Gets or sets the Name of the audio track.
+        /// </summary>
+        public string Name { get; set; }
+
+        /// <summary>
+        /// Gets or sets the track.
+        /// </summary>
+        public int Track { get; set; }
+
+        /// <summary>
+        /// Gets or sets the dither method.
+        /// </summary>
+        public int DitherMethod { get; set; }
+    }
 }
\ No newline at end of file
similarity index 76%
rename from win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/ChapterList.cs
rename to win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Chapter.cs
index d581465106217fd93cd8b9a32f8024cf0e4af697..567d0e7a3804214f3ea478bde70809a3d7e8b70f 100644 (file)
@@ -1,22 +1,22 @@
 ï»¿// --------------------------------------------------------------------------------------------------------------------\r
-// <copyright file="ChapterList.cs" company="HandBrake Project (http://handbrake.fr)">\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
-//   The chapter list.\r
+//   Represents a chapter to encode.\r
 // </summary>\r
-// --------------------------------------------------------------------------------------------------------------------\r
-\r
-namespace HandBrake.ApplicationServices.Interop.Json.Encode\r
-{\r
-    /// <summary>\r
-    /// The chapter list.\r
-    /// </summary>\r
-    public class ChapterList\r
-    {\r
-        /// <summary>\r
-        /// Gets or sets the name.\r
-        /// </summary>\r
-        public string Name { get; set; }\r
-    }\r
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Interop.Json.Encode
+{
+    /// <summary>
+    /// Represents a chapter to encode.
+    /// </summary>
+    public class Chapter
+    {
+        /// <summary>
+        /// Gets or sets the name.
+        /// </summary>
+        public string Name { get; set; }
+    }
 }
\ No newline at end of file
index 42b3eaa400f93d4a7c949acee1decb9af5c866b4..9d22fb98a9f512a2a959cc5ee619e8cfbdaf9307 100644 (file)
@@ -19,7 +19,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Encode
         /// <summary>\r
         /// Gets or sets the chapter list.\r
         /// </summary>\r
-        public List<ChapterList> ChapterList { get; set; }\r
+        public List<Chapter> ChapterList { get; set; }\r
 \r
         /// <summary>\r
         /// Gets or sets a value indicating whether chapter markers.\r
index 9de1b83411eb8d028f2e068f8c021e1b363e4730..68baffcb4860cb52b0c8e6cf9a0a0cf49fc09101 100644 (file)
@@ -39,7 +39,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Encode
         /// <summary>\r
         /// Gets or sets the meta data.\r
         /// </summary>\r
-        public MetaData Metadata { get; set; }\r
+        public Metadata Metadata { get; set; }\r
 \r
         /// <summary>\r
         /// Gets or sets the sequence id.\r
index 86f06b8cbfd67fd9541cca3ec0b7fbe8ec1348ab..d840d5d7f03787ec99c8543dc9d11209559cfe32 100644 (file)
@@ -12,7 +12,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Encode
     /// <summary>\r
     ///     The meta data.\r
     /// </summary>\r
-    public class MetaData\r
+    public class Metadata\r
     {\r
         /// <summary>\r
         ///     Gets or sets the album artist.\r
similarity index 84%
rename from win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/SubtitleList.cs
rename to win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/SubtitleTrack.cs
index 71814c9e1cc5c8b1fcfb09b7f08d2bc39cfa23de..3a8aedec7f57261f3d18f18c90139b98d152766c 100644 (file)
@@ -1,52 +1,49 @@
-// --------------------------------------------------------------------------------------------------------------------\r
-// <copyright file="SubtitleList.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 subtitle list.\r
-// </summary>\r
-// --------------------------------------------------------------------------------------------------------------------\r
-\r
-namespace HandBrake.ApplicationServices.Interop.Json.Encode\r
-{\r
-    /// <summary>\r
-    /// The subtitle list.\r
-    /// </summary>\r
-    public class SubtitleList\r
-    {\r
-        /// <summary>\r
-        /// Gets or sets a value indicating whether burn.\r
-        /// </summary>\r
-        public bool Burn { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets a value indicating whether default.\r
-        /// </summary>\r
-        public bool Default { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets a value indicating whether force.\r
-        /// </summary>\r
-        public bool Forced { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the id.\r
-        /// </summary>\r
-        public int ID { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the offset.\r
-        /// </summary>\r
-        public int Offset { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the track.\r
-        /// </summary>\r
-        public int Track { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the srt.\r
-        /// </summary>\r
-        public SRT SRT { get; set; }\r
-    }\r
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="SubtitleTrack.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>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Interop.Json.Encode
+{
+    /// <summary>
+    /// Represents a subtitle track to encode.
+    /// </summary>
+    public class SubtitleTrack
+    {
+        /// <summary>
+        /// Gets or sets a value indicating whether burn.
+        /// </summary>
+        public bool Burn { get; set; }
+
+        /// <summary>
+        /// Gets or sets a value indicating whether default.
+        /// </summary>
+        public bool Default { get; set; }
+
+        /// <summary>
+        /// Gets or sets a value indicating whether force.
+        /// </summary>
+        public bool Forced { get; set; }
+
+        /// <summary>
+        /// Gets or sets the id.
+        /// </summary>
+        public int ID { get; set; }
+
+        /// <summary>
+        /// Gets or sets the offset.
+        /// </summary>
+        public int Offset { get; set; }
+
+        /// <summary>
+        /// Gets or sets the track.
+        /// </summary>
+        public int Track { get; set; }
+
+        /// <summary>
+        /// Gets or sets the srt.
+        /// </summary>
+        public SRT SRT { get; set; }
+    }
 }
\ No newline at end of file
index 5d38ba51dcb1b783cb0fea3eb9c06a2712fb3541..13439eaa7a47d5549057fcf77ad9c7d7abda5450 100644 (file)
@@ -21,9 +21,9 @@ namespace HandBrake.ApplicationServices.Interop.Json.Encode
         /// </summary>\r
         public SubtitleSearch Search { get; set; }\r
 \r
-        /// <summary>\r
-        /// Gets or sets the subtitle list.\r
-        /// </summary>\r
-        public List<SubtitleList> SubtitleList { get; set; }\r
-    }\r
+        /// <summary>
+        /// Gets or sets the subtitle list.
+        /// </summary>
+        public List<SubtitleTrack> SubtitleList { get; set; }
+    }
 }
\ No newline at end of file
similarity index 85%
rename from win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/AudioTrack.cs
rename to win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceAudioTrack.cs
index b0491c7340887fe4781fdadf7f45f4dffd761c51..091f9a4f81f717943167d5a106706308a5a32fbe 100644 (file)
@@ -1,52 +1,49 @@
-// --------------------------------------------------------------------------------------------------------------------\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
-//   The audio list.\r
-// </summary>\r
-// --------------------------------------------------------------------------------------------------------------------\r
-\r
-namespace HandBrake.ApplicationServices.Interop.Json.Scan\r
-{\r
-    /// <summary>\r
-    /// The audio list.\r
-    /// </summary>\r
-    public class AudioTrack\r
-    {\r
-        /// <summary>\r
-        /// Gets or sets the bit rate.\r
-        /// </summary>\r
-        public int BitRate { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the channel layout.\r
-        /// </summary>\r
-        public int ChannelLayout { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the description.\r
-        /// </summary>\r
-        public string Description { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the language.\r
-        /// </summary>\r
-        public string Language { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the language code.\r
-        /// </summary>\r
-        public string LanguageCode { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the sample rate.\r
-        /// </summary>\r
-        public int SampleRate { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the codec.\r
-        /// </summary>\r
-        public int Codec { get; set; }\r
-    }\r
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="SourceAudioTrack.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>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Interop.Json.Scan
+{
+    /// <summary>
+    /// An audio track from the source video.
+    /// </summary>
+    public class SourceAudioTrack
+    {
+        /// <summary>
+        /// Gets or sets the bit rate.
+        /// </summary>
+        public int BitRate { get; set; }
+
+        /// <summary>
+        /// Gets or sets the channel layout.
+        /// </summary>
+        public int ChannelLayout { get; set; }
+
+        /// <summary>
+        /// Gets or sets the description.
+        /// </summary>
+        public string Description { get; set; }
+
+        /// <summary>
+        /// Gets or sets the language.
+        /// </summary>
+        public string Language { get; set; }
+
+        /// <summary>
+        /// Gets or sets the language code.
+        /// </summary>
+        public string LanguageCode { get; set; }
+
+        /// <summary>
+        /// Gets or sets the sample rate.
+        /// </summary>
+        public int SampleRate { get; set; }
+
+        /// <summary>
+        /// Gets or sets the codec.
+        /// </summary>
+        public int Codec { get; set; }
+    }
 }
\ No newline at end of file
similarity index 77%
rename from win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/ChapterTrack.cs
rename to win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceChapter.cs
index dc50f2dc8ca308155d089685d4fc9d8655b838f1..fce479ff122dff955057897b62d6fa85e424defb 100644 (file)
@@ -1,27 +1,24 @@
-// --------------------------------------------------------------------------------------------------------------------\r
-// <copyright file="ChapterTrack.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 chapter list.\r
-// </summary>\r
-// --------------------------------------------------------------------------------------------------------------------\r
-\r
-namespace HandBrake.ApplicationServices.Interop.Json.Scan\r
-{\r
-    /// <summary>\r
-    /// The chapter list.\r
-    /// </summary>\r
-    public class ChapterTrack\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
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="SourceChapter.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>
+// --------------------------------------------------------------------------------------------------------------------
+
+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
similarity index 81%
rename from win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/MetaData.cs
rename to win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceMetadata.cs
index ecd26bd8f25a452df6c816807b5fcf58afaa5cc8..f575dc637ea94c050eca327c3ccb391ee10219c4 100644 (file)
@@ -1,18 +1,18 @@
-// --------------------------------------------------------------------------------------------------------------------\r
-// <copyright file="MetaData.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 meta data.\r
-// </summary>\r
-// --------------------------------------------------------------------------------------------------------------------\r
-\r
-namespace HandBrake.ApplicationServices.Interop.Json.Scan\r
-{\r
-    /// <summary>\r
-    /// The meta data.\r
-    /// </summary>\r
-    public class MetaData\r
-    {\r
-    }\r
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="SourceMetadata.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 meta data.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Interop.Json.Scan
+{
+    /// <summary>
+    /// The meta data.
+    /// </summary>
+    public class SourceMetadata
+    {
+    }
 }
\ No newline at end of file
similarity index 87%
rename from win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SubtitleTrack.cs
rename to win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceSubtitleTrack.cs
index 247801468460c236a701cceefe34218eabdf7806..3f3594a393f882d976e7fa144cbcc0ec998f9cb8 100644 (file)
@@ -1,37 +1,37 @@
-// --------------------------------------------------------------------------------------------------------------------\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
-//   The subtitle list.\r
-// </summary>\r
-// --------------------------------------------------------------------------------------------------------------------\r
-\r
-namespace HandBrake.ApplicationServices.Interop.Json.Scan\r
-{\r
-    /// <summary>\r
-    /// The subtitle list.\r
-    /// </summary>\r
-    public class SubtitleTrack\r
-    {\r
-        /// <summary>\r
-        /// Gets or sets the format.\r
-        /// </summary>\r
-        public int Format { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the language.\r
-        /// </summary>\r
-        public string Language { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the language code.\r
-        /// </summary>\r
-        public string LanguageCode { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the source.\r
-        /// </summary>\r
-        public int Source { get; set; }\r
-    }\r
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="SourceSubtitleTrack.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 subtitle list.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Interop.Json.Scan
+{
+    /// <summary>
+    /// The subtitle list.
+    /// </summary>
+    public class SourceSubtitleTrack
+    {
+        /// <summary>
+        /// Gets or sets the format.
+        /// </summary>
+        public int Format { get; set; }
+
+        /// <summary>
+        /// Gets or sets the language.
+        /// </summary>
+        public string Language { get; set; }
+
+        /// <summary>
+        /// Gets or sets the language code.
+        /// </summary>
+        public string LanguageCode { get; set; }
+
+        /// <summary>
+        /// Gets or sets the source.
+        /// </summary>
+        public int Source { get; set; }
+    }
 }
\ No newline at end of file
index f70a155841fb26de49c26f384fdfe173ded2ff9a..4947bbadba3299707bac90515c7d47a94c5c4ab1 100644 (file)
@@ -23,18 +23,18 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan
         /// </summary>\r
         public int AngleCount { get; set; }\r
 \r
-        /// <summary>\r
-        /// Gets or sets the audio list.\r
-        /// </summary>\r
-        public List<AudioTrack> AudioList { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the chapter list.\r
-        /// </summary>\r
-        public List<ChapterTrack> ChapterList { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the color.\r
+        /// <summary>
+        /// Gets or sets the audio list.
+        /// </summary>
+        public List<SourceAudioTrack> AudioList { get; set; }
+
+        /// <summary>
+        /// Gets or sets the chapter list.
+        /// </summary>
+        public List<SourceChapter> ChapterList { get; set; }
+
+        /// <summary>
+        /// Gets or sets the color.
         /// </summary>\r
         public Color Color { get; set; }\r
 \r
@@ -68,13 +68,13 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan
         /// </summary>\r
         public bool InterlaceDetected { get; set; }\r
 \r
-        /// <summary>\r
-        /// Gets or sets the meta data.\r
-        /// </summary>\r
-        public MetaData MetaData { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the name.\r
+        /// <summary>
+        /// Gets or sets the meta data.
+        /// </summary>
+        public SourceMetadata MetaData { get; set; }
+
+        /// <summary>
+        /// Gets or sets the name.
         /// </summary>\r
         public string Name { get; set; }\r
 \r
@@ -88,13 +88,13 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan
         /// </summary>\r
         public int Playlist { get; set; }\r
 \r
-        /// <summary>\r
-        /// Gets or sets the subtitle list.\r
-        /// </summary>\r
-        public List<SubtitleTrack> SubtitleList { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the type.\r
+        /// <summary>
+        /// Gets or sets the subtitle list.
+        /// </summary>
+        public List<SourceSubtitleTrack> SubtitleList { get; set; }
+
+        /// <summary>
+        /// Gets or sets the type.
         ///  HB_DVD_TYPE = 0, HB_BD_TYPE, HB_STREAM_TYPE, HB_FF_STREAM_TYPE\r
         /// </summary>\r
         public int Type { get; set; }\r
index e2a07d1ccf75609e2b3d5cce9bee33303bab917b..af1a166ce9c6bb36a65733bb550d3d35c031f169 100644 (file)
@@ -6,27 +6,52 @@
 //   The preview settings.\r
 // </summary>\r
 // --------------------------------------------------------------------------------------------------------------------\r
-\r
-namespace HandBrake.ApplicationServices.Interop.Model.Preview\r
-{\r
-    using HandBrake.ApplicationServices.Services.Encode.Model;\r
-\r
-    /// <summary>\r
-    /// The preview settings.\r
-    /// </summary>\r
-    public class PreviewSettings : EncodeTask\r
-    {\r
-        /// <summary>\r
-        /// Initializes a new instance of the <see cref="PreviewSettings"/> class.\r
-        /// </summary>\r
-        /// <param name="task">\r
-        /// The task.\r
-        /// </param>\r
-        public PreviewSettings(EncodeTask task)\r
-            : base(task)\r
-        {\r
-        }\r
-\r
-        // TODO flesh this out into a proper model.\r
-    }\r
-}\r
+
+namespace HandBrake.ApplicationServices.Interop.Model.Preview
+{
+    using HandBrake.ApplicationServices.Interop.Model.Encoding;
+    using HandBrake.ApplicationServices.Services.Encode.Model;
+
+    /// <summary>
+    /// The preview settings.
+    /// </summary>
+    public class PreviewSettings
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="PreviewSettings"/> class.
+        /// </summary>
+        public PreviewSettings()
+        {
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="PreviewSettings"/> class.
+        /// </summary>
+        /// <param name="task">The task.</param>
+        public PreviewSettings(EncodeTask task)
+        {
+        }
+
+        public Cropping Cropping { get; set; }
+
+        public int MaxWidth { get; set; }
+
+        public int MaxHeight { get; set; }
+
+        public bool KeepDisplayAspect { get; set; }
+
+        public int TitleNumber { get; set; }
+
+        public Anamorphic Anamorphic { get; set; }
+
+        public int? Modulus { get; set; }
+
+        public int Width { get; set; }
+
+        public int Height { get; set; }
+
+        public int PixelAspectX { get; set; }
+
+        public int PixelAspectY { get; set; }
+    }
+}
index 875cdc9388144ab17b77d67de11a76089dd74540..54b80b28caa13673555c2b96094af763ce742906 100644 (file)
@@ -14,20 +14,24 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories
     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.Encode;\r
-    using HandBrake.ApplicationServices.Interop.Json.Shared;\r
-    using HandBrake.ApplicationServices.Interop.Model.Encoding;\r
+    using HandBrake.ApplicationServices.Interop;
+    using HandBrake.ApplicationServices.Interop.HbLib;
+    using HandBrake.ApplicationServices.Interop.Helpers;
+    using HandBrake.ApplicationServices.Interop.Json;
+    using HandBrake.ApplicationServices.Interop.Json.Anamorphic;
+    using HandBrake.ApplicationServices.Interop.Json.Encode;
+    using HandBrake.ApplicationServices.Interop.Json.Shared;
+    using HandBrake.ApplicationServices.Interop.Model.Encoding;
     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
-\r
-    /// <summary>\r
-    /// This factory takes the internal EncodeJob object and turns it into a set of JSON models\r
+    using HandBrake.ApplicationServices.Services.Encode.Model.Models;
+    using HandBrake.ApplicationServices.Utilities;
+
+    using AudioTrack = HandBrake.ApplicationServices.Services.Encode.Model.Models.AudioTrack;
+    using Subtitle = HandBrake.ApplicationServices.Interop.Json.Encode.Subtitles;
+
+    /// <summary>
+    /// This factory takes the internal EncodeJob object and turns it into a set of JSON models
     /// that can be deserialized by libhb.\r
     /// </summary>\r
     internal class EncodeFactory\r
@@ -47,23 +51,23 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories
         /// <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 = CreateFilter(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
+        /// <returns>
+        /// The <see cref="JsonEncodeObject"/>.
+        /// </returns>
+        internal static 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)
+                };
 \r
             return encode;\r
         }\r
@@ -84,36 +88,36 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories
         {\r
             Range range = new Range();\r
             switch (job.PointToPointMode)\r
-            {\r
-                case PointToPointMode.Chapters:\r
-                    range.Type = "chapter";\r
-                    range.End = job.EndPoint;\r
-                    range.Start = job.StartPoint;\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
+            {
+                case PointToPointMode.Chapters:
+                    range.Type = "chapter";
+                    range.Start = job.StartPoint;
+                    range.End = job.EndPoint;
+                    break;
+                case PointToPointMode.Seconds:
+                    range.Type = "time";
+                    range.Start = job.StartPoint * 90000;
+                    range.End = (job.EndPoint - job.StartPoint) * 90000;
+                    break;
+                case PointToPointMode.Frames:
+                    range.Type = "frame";
+                    range.Start = job.StartPoint;
+                    range.End = job.EndPoint;
+                    break;
+                case PointToPointMode.Preview:
+                    range.Type = "preview";
+                    range.Start = job.PreviewEncodeStartAt;
+                    range.SeekPoints = configuration.PreviewScanCount;
+                    range.End = job.PreviewEncodeDuration * 90000;
+                    break;
+            }
+
+            Source source = new Source
+            {
+                Title = job.Title,
+                Range = range,
+                Angle = job.Angle,
+                Path = job.Source,
             };\r
             return source;\r
         }\r
@@ -128,28 +132,28 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories
         /// 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<ChapterList>()\r
-            };\r
-\r
-            if (job.IncludeChapterMarkers)\r
-            {\r
-                foreach (ChapterMarker item in job.ChapterNames)\r
-                {\r
-                    ChapterList chapter = new ChapterList { Name = item.ChapterName };\r
-                    destination.ChapterList.Add(chapter);\r
-                }\r
-            }\r
+        {
+            Destination destination = new Destination
+            {
+                File = job.Destination,
+                Mp4Options = new Mp4Options
+                                 {
+                                     IpodAtom = job.IPod5GSupport,
+                                     Mp4Optimize = job.OptimizeMP4
+                                 },
+                ChapterMarkers = job.IncludeChapterMarkers,
+                Mux = HBFunctions.hb_container_get_from_name(job.OutputFormat == OutputFormat.Mp4 ? "av_mp4" : "av_mkv"), // TODO tidy up.
+                ChapterList = new List<Chapter>()
+            };
+
+            if (job.IncludeChapterMarkers)
+            {
+                foreach (ChapterMarker item in job.ChapterNames)
+                {
+                    Chapter chapter = new Chapter { Name = item.ChapterName };
+                    destination.ChapterList.Add(chapter);
+                }
+            }
 \r
             return destination;\r
         }\r
@@ -174,28 +178,28 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories
         /// <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 Subtitles 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<SubtitleList>()\r
-                };\r
-\r
-            foreach (SubtitleTrack item in job.SubtitleTracks)\r
-            {\r
-                if (!item.IsSrtSubtitle)\r
-                {\r
+        /// <returns>
+        /// The <see cref="HandBrake.ApplicationServices.Interop.Json.Encode.Subtitles"/>.
+        /// </returns>
+        private static Subtitle CreateSubtitle(EncodeTask job)
+        {
+            Subtitles subtitle = new Subtitles
+                {
+                    Search =
+                        new SubtitleSearch
+                            {
+                                Enable = false,
+                                Default = false,
+                                Burn = false,
+                                Forced = false
+                            },
+                    SubtitleList = new List<HandBrake.ApplicationServices.Interop.Json.Encode.SubtitleTrack>()
+                };
+
+            foreach (HandBrake.ApplicationServices.Services.Encode.Model.Models.SubtitleTrack item in job.SubtitleTracks)
+            {
+                if (!item.IsSrtSubtitle)
+                {
                     // Handle Foreign Audio Search\r
                     if (item.SourceTrack.TrackNumber == 0)\r
                     {\r
@@ -203,19 +207,27 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories
                         subtitle.Search.Burn = item.Burned;\r
                         subtitle.Search.Default = item.Default;\r
                         subtitle.Search.Forced = item.Forced;\r
-                    }\r
-                    else\r
-                    {\r
-                        SubtitleList track = new SubtitleList { Burn = item.Burned, Default = item.Default, Forced = item.Forced, ID = item.SourceTrack.TrackNumber, Track = (item.SourceTrack.TrackNumber - 1) };\r
-                        subtitle.SubtitleList.Add(track);\r
-                    }\r
-                }\r
-                else\r
-                {\r
-                    SubtitleList track = new SubtitleList\r
-                    {\r
-                        Track = -1, // Indicates SRT\r
-                        Default = item.Default,\r
+                    }
+                    else
+                    {
+                        HandBrake.ApplicationServices.Interop.Json.Encode.SubtitleTrack track = new HandBrake.ApplicationServices.Interop.Json.Encode.SubtitleTrack
+                        {
+                            Burn = item.Burned,
+                            Default = item.Default,
+                            Forced = item.Forced,
+                            ID = item.SourceTrack.TrackNumber,
+                            Track = (item.SourceTrack.TrackNumber - 1)
+                        };
+
+                        subtitle.SubtitleList.Add(track);
+                    }
+                }
+                else
+                {
+                    HandBrake.ApplicationServices.Interop.Json.Encode.SubtitleTrack track = new HandBrake.ApplicationServices.Interop.Json.Encode.SubtitleTrack
+                    {
+                        Track = -1, // Indicates SRT
+                        Default = item.Default,
                         Offset = item.SrtOffset,\r
                         Burn = item.Burned,\r
                         SRT =\r
@@ -225,13 +237,13 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories
                                 Codeset = item.SrtCharCode,\r
                                 Language = item.SrtLang\r
                             }\r
-                    };\r
-\r
-                    subtitle.SubtitleList.Add(track);\r
-                }     \r
-            }\r
-\r
-            return subtitle;\r
+                    };
+
+                    subtitle.SubtitleList.Add(track);
+                }
+            }
+
+            return subtitle;
         }\r
 \r
         /// <summary>\r
@@ -303,42 +315,42 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories
         /// 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
+        {
+            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);\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<AudioList>();\r
-            foreach (AudioTrack item in job.AudioTracks)\r
-            {\r
-                HBAudioEncoder encoder = HandBrakeEncoderHelpers.GetAudioEncoder(ApplicationServices.Utilities.Converters.GetCliAudioEncoder(item.Encoder) );\r
-                Validate.NotNull(encoder, "Unrecognized audio encoder:" + item.Encoder);\r
-\r
-                HBMixdown mixdown = HandBrakeEncoderHelpers.GetMixdown(ApplicationServices.Utilities.Converters.GetCliMixDown(item.MixDown));\r
-                Validate.NotNull(mixdown, "Unrecognized audio mixdown:" + ApplicationServices.Utilities.Converters.GetCliMixDown(item.MixDown));\r
-\r
-                AudioList audioTrack = new AudioList\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 = GetSampleRateRaw(item.SampleRate),\r
-                        Name = item.TrackName,\r
+            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);
+            audio.CopyMask = copyMaskList.ToArray();
+
+            HBAudioEncoder audioEncoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(job.AllowedPassthruOptions.AudioEncoderFallback));
+            audio.FallbackEncoder = audioEncoder.Id;
+
+            audio.AudioList = new List<Interop.Json.Encode.AudioTrack>();
+            foreach (AudioTrack item in job.AudioTracks)
+            {
+                HBAudioEncoder encoder = HandBrakeEncoderHelpers.GetAudioEncoder(ApplicationServices.Utilities.Converters.GetCliAudioEncoder(item.Encoder));
+                Validate.NotNull(encoder, "Unrecognized audio encoder:" + item.Encoder);
+
+                HBMixdown mixdown = HandBrakeEncoderHelpers.GetMixdown(ApplicationServices.Utilities.Converters.GetCliMixDown(item.MixDown));
+                Validate.NotNull(mixdown, "Unrecognized audio mixdown:" + ApplicationServices.Utilities.Converters.GetCliMixDown(item.MixDown));
+
+                HandBrake.ApplicationServices.Interop.Json.Encode.AudioTrack audioTrack = new HandBrake.ApplicationServices.Interop.Json.Encode.AudioTrack
+                    {
+                        Track = (item.Track.HasValue ? item.Track.Value : 0) - 1,
+                        DRC = item.DRC,
+                        Encoder = encoder.Id,
+                        Gain = item.Gain,
+                        Mixdown = mixdown.Id,
+                        NormalizeMixLevel = false,
+                        Samplerate = GetSampleRateRaw(item.SampleRate),
+                        Name = item.TrackName,
                     };\r
 \r
                 if (!item.IsPassthru)\r
@@ -352,15 +364,15 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories
                     //if (item.EncodeRateType == AudioEncodeRateType.Compression)\r
                     //{\r
                     //    audioTrack.CompressionLevel = item.Compression;\r
-                    //}\r
-\r
-                    //if (item.EncodeRateType == AudioEncodeRateType.Bitrate)\r
-                   // {\r
-                        audioTrack.Bitrate = item.Bitrate;\r
-                   // }\r
-                }\r
-\r
-                audio.AudioList.Add(audioTrack);\r
+                    //}
+
+                    //if (item.EncodeRateType == AudioEncodeRateType.Bitrate)
+                    // {
+                    audioTrack.Bitrate = item.Bitrate;
+                    // }
+                }
+
+                audio.AudioList.Add(audioTrack);
             }\r
 \r
             return audio;\r
@@ -394,17 +406,17 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories
         /// <param name="job">\r
         /// The job.\r
         /// </param>\r
-        /// <returns>\r
-        /// The <see cref="Filters"/>.\r
-        /// </returns>\r
-        private static Filters CreateFilter(EncodeTask job)\r
-        {\r
-            Filters filter = new Filters\r
-                            {\r
-                                FilterList = new List<Filter>(), \r
-                                Grayscale = job.Grayscale\r
-                            };\r
-\r
+        /// <returns>
+        /// The <see cref="Filters"/>.
+        /// </returns>
+        private static Filters CreateFilters(EncodeTask job)
+        {
+            Filters filter = new Filters
+                            {
+                                FilterList = new List<Filter>(),
+                                Grayscale = job.Grayscale
+                            };
+
             // Detelecine\r
             if (job.Detelecine != Detelecine.Off)\r
             {\r
@@ -509,21 +521,21 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories
                 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
+            // CropScale Filter
+            Filter cropScale = new Filter
+            {
+                ID = (int)hb_filter_ids.HB_FILTER_CROP_SCALE,
+                Settings =
+                    string.Format(
+                        "{0}:{1}:{2}:{3}:{4}:{5}",
+                        job.Width,
+                        job.Height,
+                        job.Cropping.Top,
+                        job.Cropping.Bottom,
+                        job.Cropping.Left,
+                        job.Cropping.Right)
+            };
+            filter.FilterList.Add(cropScale);
 \r
             // Rotate\r
             /* TODO  NOT SUPPORTED YET. */\r
@@ -535,17 +547,17 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories
         /// The create meta data.\r
         /// </summary>\r
         /// <param name="job">\r
-        /// The job.\r
-        /// </param>\r
-        /// <returns>\r
-        /// The <see cref="Interop.Json.Encode.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
+        /// The job.
+        /// </param>
+        /// <returns>
+        /// The <see cref="Metadata"/>.
+        /// </returns>
+        private static Metadata CreateMetadata(EncodeTask job)
+        {
+            Metadata metaData = new Metadata();
+
+            /* TODO  NOT SUPPORTED YET. */
+            return metaData;
         }\r
     }\r
 }\r
index 0d4c6b3c2d8f18618c0f110b351713b5bc493fce..09f52eb66b2db92565b593dd4654bc90b01eb996 100644 (file)
@@ -44,13 +44,13 @@ namespace HandBrake.ApplicationServices.Services.Scan.Interfaces
     /// </summary>\r
     public interface IScan\r
     {\r
-        /// <summary>\r
-        /// Scan has Started\r
-        /// </summary>\r
-        event EventHandler ScanStared;\r
-\r
-        /// <summary>\r
-        /// Scan has completed\r
+        /// <summary>
+        /// Scan has Started
+        /// </summary>
+        event EventHandler ScanStarted;
+
+        /// <summary>
+        /// Scan has completed
         /// </summary>\r
         event ScanCompletedStatus ScanCompleted;\r
 \r
index 6e16fa93784f5e570158425ad14085733bef6a93..5eab755203f77249143c705389c02cbe58275ac9 100644 (file)
@@ -102,13 +102,13 @@ namespace HandBrake.ApplicationServices.Services.Scan
 \r
         #region Events\r
 \r
-        /// <summary>\r
-        /// Scan has Started\r
-        /// </summary>\r
-        public event EventHandler ScanStared;\r
-\r
-        /// <summary>\r
-        /// Scan has completed\r
+        /// <summary>
+        /// Scan has Started
+        /// </summary>
+        public event EventHandler ScanStarted;
+
+        /// <summary>
+        /// Scan has completed
         /// </summary>\r
         public event ScanCompletedStatus ScanCompleted;\r
 \r
@@ -318,14 +318,14 @@ namespace HandBrake.ApplicationServices.Services.Scan
 \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.ScanStared != null)\r
-                    this.ScanStared(this, System.EventArgs.Empty);\r
-            }\r
-            catch (Exception exc)\r
-            {\r
+                this.ServiceLogMessage("Starting Scan ...");
+                this.instance.StartScan(sourcePath.ToString(), previewCount, minDuration, title != 0 ? title : 0);
+
+                if (this.ScanStarted != null)
+                    this.ScanStarted(this, System.EventArgs.Empty);
+            }
+            catch (Exception exc)
+            {
                 this.ServiceLogMessage("Scan Failed ..." + Environment.NewLine + exc);\r
                 this.Stop();\r
 \r
@@ -488,28 +488,28 @@ namespace HandBrake.ApplicationServices.Services.Scan
                         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 (ChapterTrack 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
+                    };
+
+                int currentTrack = 1;
+                foreach (SourceChapter chapter in title.ChapterList)
+                {
+                    string chapterName = !string.IsNullOrEmpty(chapter.Name) ? chapter.Name : string.Empty;
+                    converted.Chapters.Add(new Chapter(currentTrack, chapterName, new TimeSpan(chapter.Duration.Hours, chapter.Duration.Minutes, chapter.Duration.Seconds)));
                     currentTrack++;\r
-                }\r
-\r
-                int currentAudioTrack = 1;\r
-                foreach (AudioTrack 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 (SubtitleTrack track in title.SubtitleList)\r
-                {\r
-                    SubtitleType convertedType = new SubtitleType();\r
-\r
+                }
+
+                int currentAudioTrack = 1;
+                foreach (SourceAudioTrack track in title.AudioList)
+                {
+                    converted.AudioTracks.Add(new Audio(currentAudioTrack, track.Language, track.LanguageCode, track.Description, string.Empty, track.SampleRate, track.BitRate));
+                    currentAudioTrack++;
+                }
+
+                int currentSubtitleTrack = 1;
+                foreach (SourceSubtitleTrack track in title.SubtitleList)
+                {
+                    SubtitleType convertedType = new SubtitleType();
+
                     switch (track.Source)\r
                     {\r
                         case 0:\r
index adc18ff2dc374a43fc56f19d934fdc398f78f602..4bf88f35a0b778e93e79b742a235c6635a39eb16 100644 (file)
@@ -31,13 +31,13 @@ namespace HandBrakeWPF.Commands
         /// <param name="ssw">\r
         /// The scan service wrapper.\r
         /// </param>\r
-        public CancelScanCommand(IScan ssw)\r
-        {\r
-            this.scanServiceWrapper = ssw;\r
-            this.scanServiceWrapper.ScanStared += this.ScanServiceWrapperScanStared;\r
-            this.scanServiceWrapper.ScanCompleted += this.ScanServiceWrapperScanCompleted;\r
-        }\r
-\r
+        public CancelScanCommand(IScan ssw)
+        {
+            this.scanServiceWrapper = ssw;
+            this.scanServiceWrapper.ScanStarted += this.ScanServiceWrapperScanStared;
+            this.scanServiceWrapper.ScanCompleted += this.ScanServiceWrapperScanCompleted;
+        }
+
         /// <summary>\r
         /// The scan service Scan Completed Event Handler.\r
         /// Fires CanExecuteChanged\r
index 008d70dcb5b3373b6e7aeee0e64296b9303ff77e..d369728a7e47d25d40798ee8ea584205f19aba4f 100644 (file)
@@ -129,13 +129,13 @@ namespace HandBrakeWPF.ViewModels
         protected override void OnActivate()\r
         {\r
             this.scanService.ScanCompleted += ScanServiceScanCompleted;\r
-            this.encodeService.EncodeCompleted += EncodeServiceEncodeCompleted;\r
-            this.encodeService.EncodeStatusChanged += this.EncodeServiceEncodeStatusChanged;\r
-            this.scanService.ScanStatusChanged += this.ScanServiceScanStatusChanged;\r
-            this.scanService.ScanStared += this.scanService_ScanStared;\r
-            this.encodeService.EncodeStarted += this.encodeService_EncodeStarted;\r
-            base.OnActivate();\r
-\r
+            this.encodeService.EncodeCompleted += EncodeServiceEncodeCompleted;
+            this.encodeService.EncodeStatusChanged += this.EncodeServiceEncodeStatusChanged;
+            this.scanService.ScanStatusChanged += this.ScanServiceScanStatusChanged;
+            this.scanService.ScanStarted += this.scanService_ScanStared;
+            this.encodeService.EncodeStarted += this.encodeService_EncodeStarted;
+            base.OnActivate();
+
             this.NotifyOfPropertyChange(() => this.ScanLog);\r
             this.NotifyOfPropertyChange(() => this.EncodeLog);\r
         }\r
@@ -182,13 +182,13 @@ namespace HandBrakeWPF.ViewModels
         protected override void OnDeactivate(bool close)\r
         {\r
             this.scanService.ScanCompleted -= ScanServiceScanCompleted;\r
-            this.encodeService.EncodeCompleted -= EncodeServiceEncodeCompleted;\r
-            this.encodeService.EncodeStatusChanged -= this.EncodeServiceEncodeStatusChanged;\r
-            this.scanService.ScanStatusChanged -= this.ScanServiceScanStatusChanged;\r
-            this.scanService.ScanStared -= this.scanService_ScanStared;\r
-            this.encodeService.EncodeStarted -= this.encodeService_EncodeStarted;\r
-\r
-            base.OnDeactivate(close);\r
+            this.encodeService.EncodeCompleted -= EncodeServiceEncodeCompleted;
+            this.encodeService.EncodeStatusChanged -= this.EncodeServiceEncodeStatusChanged;
+            this.scanService.ScanStatusChanged -= this.ScanServiceScanStatusChanged;
+            this.scanService.ScanStarted -= this.scanService_ScanStared;
+            this.encodeService.EncodeStarted -= this.encodeService_EncodeStarted;
+
+            base.OnDeactivate(close);
         }\r
 \r
         /// <summary>\r
index 2dc7064099c0b2ab99c08cb239cb079cfd61a215..e4d20d0536b8c39d369c2e0ca28f5042b00ddef5 100644 (file)
@@ -260,13 +260,13 @@ namespace HandBrakeWPF.ViewModels
             this.CurrentTask = new EncodeTask();\r
             this.CurrentTask.PropertyChanged += this.CurrentTask_PropertyChanged;\r
             this.ScannedSource = new Source();\r
-            this.HasSource = false;\r
-\r
-            // Setup Events\r
-            this.scanService.ScanStared += this.ScanStared;\r
-            this.scanService.ScanCompleted += this.ScanCompleted;\r
-            this.scanService.ScanStatusChanged += this.ScanStatusChanged;\r
-            this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted;\r
+            this.HasSource = false;
+
+            // Setup Events
+            this.scanService.ScanStarted += this.ScanStared;
+            this.scanService.ScanCompleted += this.ScanCompleted;
+            this.scanService.ScanStatusChanged += this.ScanStatusChanged;
+            this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted;
             this.queueProcessor.QueueCompleted += this.QueueCompleted;\r
             this.queueProcessor.QueueChanged += this.QueueChanged;\r
             this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;\r
@@ -1220,13 +1220,13 @@ namespace HandBrakeWPF.ViewModels
         public void Shutdown()\r
         {\r
             // Shutdown Service\r
-            this.encodeService.Stop();\r
-\r
-            // Unsubscribe from Events.\r
-            this.scanService.ScanStared -= this.ScanStared;\r
-            this.scanService.ScanCompleted -= this.ScanCompleted;\r
-            this.scanService.ScanStatusChanged -= this.ScanStatusChanged;\r
-\r
+            this.encodeService.Stop();
+
+            // Unsubscribe from Events.
+            this.scanService.ScanStarted -= this.ScanStared;
+            this.scanService.ScanCompleted -= this.ScanCompleted;
+            this.scanService.ScanStatusChanged -= this.ScanStatusChanged;
+
             this.queueProcessor.QueueCompleted -= this.QueueCompleted;\r
             this.queueProcessor.QueueChanged -= this.QueueChanged;\r
             this.queueProcessor.JobProcessingStarted -= this.QueueProcessorJobProcessingStarted;\r