]> granicus.if.org Git - handbrake/commitdiff
Interop: Added methods to dynamically pull the preset, profile, level and tune values...
authorrandomengy <david.rickard@gmail.com>
Mon, 31 Mar 2014 03:17:42 +0000 (03:17 +0000)
committerrandomengy <david.rickard@gmail.com>
Mon, 31 Mar 2014 03:17:42 +0000 (03:17 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6142 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs
win/CS/HandBrake.Interop/HandBrakeInterop/Converters/Converters.cs
win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs
win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs
win/CS/HandBrake.Interop/HandBrakeInterop/Helpers/InteropUtilities.cs
win/CS/HandBrake.Interop/HandBrakeInterop/Helpers/Languages.cs
win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoders.cs
win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/EncodingProfile.cs
win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/HBVideoEncoder.cs

index 5ff4924ebff542207a19ba2a3a0971f06ca975cb..9e8bc3c32ed0dc24c0fb812ebb94b7c98aeaeecb 100644 (file)
@@ -181,24 +181,30 @@ namespace HandBrake.ApplicationServices.Utilities
             profile.VideoEncodeRateType = work.VideoEncodeRateType;\r
             profile.VideoEncoder = Converters.GetVideoEncoder(work.VideoEncoder);\r
 \r
-            profile.H264Level = work.H264Level;\r
-            profile.X264Profile = work.H264Profile.ToString().ToLower().Replace(" ", string.Empty); // TODO change these away from strings.\r
-            profile.X264Preset = work.X264Preset.ToString().ToLower().Replace(" ", string.Empty);\r
-            profile.X264Tunes = new List<string>();\r
-\r
-            if (work.X264Tune != x264Tune.None)\r
+            if (work.VideoEncoder == VideoEncoder.X264)\r
             {\r
-                profile.X264Tunes.Add(work.X264Tune.ToString().ToLower().Replace(" ", string.Empty));\r
-            }\r
+                profile.VideoPreset = work.X264Preset.ToString().ToLower().Replace(" ", string.Empty);\r
+                profile.VideoTunes = new List<string>();\r
+\r
+                if (work.X264Tune != x264Tune.None)\r
+                {\r
+                    profile.VideoTunes.Add(work.X264Tune.ToString().ToLower().Replace(" ", string.Empty));\r
+                }\r
 \r
-            if (work.FastDecode)\r
+                if (work.FastDecode)\r
+                {\r
+                    profile.VideoTunes.Add("fastdecode");\r
+                }\r
+            }\r
+            else if (work.VideoEncoder == VideoEncoder.X265)\r
             {\r
-                profile.X264Tunes.Add("fastdecode");\r
+                profile.VideoPreset = work.X265Preset.ToString().ToLower().Replace(" ", string.Empty);\r
+                profile.VideoProfile = work.H265Profile.ToString().ToLower().Replace(" ", string.Empty);\r
+                profile.VideoTunes = new List<string>();\r
             }\r
 \r
-            profile.X265Preset = work.X265Preset.ToString().ToLower().Replace(" ", string.Empty);\r
-            profile.X265Profile = work.H265Profile.ToString().ToLower().Replace(" ", string.Empty);\r
-            profile.X265Tunes = new List<string>();\r
+            profile.VideoLevel = work.H264Level;\r
+            profile.VideoProfile = work.H264Profile.ToString().ToLower().Replace(" ", string.Empty); // TODO change these away from strings.\r
 \r
             // Chapter Markers\r
             profile.IncludeChapterMarkers = work.IncludeChapterMarkers;\r
@@ -206,7 +212,7 @@ namespace HandBrake.ApplicationServices.Utilities
             job.UseDefaultChapterNames = work.IncludeChapterMarkers;\r
 \r
             // Advanced Settings\r
-            profile.X264Options = work.AdvancedEncoderOptions;\r
+            profile.VideoOptions = work.AdvancedEncoderOptions;\r
 \r
             // Subtitles\r
             job.Subtitles = new Subtitles { SourceSubtitles = new List<SourceSubtitle>(), SrtSubtitles = new List<SrtSubtitle>() };\r
index a707e0eb52e7bda0ff7014cb964b16c594863dd8..d0468ec272411dcc55bfd42a56265b8ed39a2f49 100644 (file)
@@ -192,8 +192,8 @@ namespace HandBrake.Interop.Converters
                /// <returns>The converted structure.</returns>\r
                public static Language NativeToLanguage(iso639_lang_t language)\r
                {\r
-                       string englishName = InteropUtilities.ReadUtf8Ptr(language.eng_name);\r
-                       string nativeName = InteropUtilities.ReadUtf8Ptr(language.native_name);\r
+                       string englishName = InteropUtilities.ToStringFromUtf8Ptr(language.eng_name);\r
+                       string nativeName = InteropUtilities.ToStringFromUtf8Ptr(language.native_name);\r
                        return new Language\r
                                {\r
                                        Code = language.iso639_2,\r
index 54a2135ee564eb003eadc327b5650e577ec47f4d..e97343852c2030c3eeb94c47024b13334bc3edf4 100644 (file)
@@ -245,7 +245,7 @@ namespace HandBrake.Interop
         {\r
             this.previewCount = previewCount;\r
 \r
-            IntPtr pathPtr = InteropUtilities.CreateUtf8Ptr(path);\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
 \r
@@ -280,7 +280,7 @@ namespace HandBrake.Interop
         public BitmapImage GetPreview(EncodeJob job, int previewNumber)\r
         {\r
             IntPtr nativeJobPtr = HBFunctions.hb_job_init_by_index(this.hbHandle, this.GetTitleIndex(job.Title));\r
-            var nativeJob = InteropUtilities.ReadStructure<hb_job_s>(nativeJobPtr);\r
+            var nativeJob = InteropUtilities.ToStructureFromPtr<hb_job_s>(nativeJobPtr);\r
 \r
             List<IntPtr> allocatedMemory = this.ApplyJob(ref nativeJob, job);\r
 \r
@@ -473,7 +473,7 @@ namespace HandBrake.Interop
             this.currentJob = job;\r
 \r
             IntPtr nativeJobPtr = HBFunctions.hb_job_init_by_index(this.hbHandle, this.GetTitleIndex(job.Title));\r
-            var nativeJob = InteropUtilities.ReadStructure<hb_job_s>(nativeJobPtr);\r
+            var nativeJob = InteropUtilities.ToStructureFromPtr<hb_job_s>(nativeJobPtr);\r
 \r
             this.encodeAllocatedMemory = this.ApplyJob(ref nativeJob, job, preview, previewNumber, previewSeconds, overallSelectedLengthSeconds);\r
 \r
@@ -490,31 +490,31 @@ namespace HandBrake.Interop
                 }\r
             }\r
 \r
-            string x264Options = profile.X264Options ?? string.Empty;\r
-            IntPtr originalX264Options = Marshal.StringToHGlobalAnsi(x264Options);\r
-            this.encodeAllocatedMemory.Add(originalX264Options);\r
+            string videoOptions = profile.VideoOptions ?? string.Empty;\r
+            IntPtr originalVideoOptions = Marshal.StringToHGlobalAnsi(videoOptions);\r
+            this.encodeAllocatedMemory.Add(originalVideoOptions);\r
 \r
-            if (!string.IsNullOrEmpty(profile.X264Profile))\r
+            if (!string.IsNullOrEmpty(profile.VideoProfile))\r
             {\r
-                nativeJob.encoder_profile = Marshal.StringToHGlobalAnsi(profile.X264Profile);\r
+                nativeJob.encoder_profile = Marshal.StringToHGlobalAnsi(profile.VideoProfile);\r
                 this.encodeAllocatedMemory.Add(nativeJob.encoder_profile);\r
             }\r
 \r
-            if (!string.IsNullOrEmpty(profile.X264Preset))\r
+            if (!string.IsNullOrEmpty(profile.VideoPreset))\r
             {\r
-                nativeJob.encoder_preset = Marshal.StringToHGlobalAnsi(profile.X264Preset);\r
+                nativeJob.encoder_preset = Marshal.StringToHGlobalAnsi(profile.VideoPreset);\r
                 this.encodeAllocatedMemory.Add(nativeJob.encoder_preset);\r
             }\r
 \r
-            if (profile.X264Tunes != null && profile.X264Tunes.Count > 0)\r
+            if (profile.VideoTunes != null && profile.VideoTunes.Count > 0)\r
             {\r
-                nativeJob.encoder_tune = Marshal.StringToHGlobalAnsi(string.Join(",", profile.X264Tunes));\r
+                nativeJob.encoder_tune = Marshal.StringToHGlobalAnsi(string.Join(",", profile.VideoTunes));\r
                 this.encodeAllocatedMemory.Add(nativeJob.encoder_tune);\r
             }\r
 \r
-            if (!string.IsNullOrEmpty(job.EncodingProfile.H264Level))\r
+            if (!string.IsNullOrEmpty(job.EncodingProfile.VideoLevel))\r
             {\r
-                nativeJob.encoder_level = Marshal.StringToHGlobalAnsi(job.EncodingProfile.H264Level);\r
+                nativeJob.encoder_level = Marshal.StringToHGlobalAnsi(job.EncodingProfile.VideoLevel);\r
                 this.encodeAllocatedMemory.Add(nativeJob.encoder_level);\r
             }\r
 \r
@@ -535,7 +535,7 @@ namespace HandBrake.Interop
             {\r
                 // First pass. Apply turbo options if needed.\r
                 nativeJob.pass = 1;\r
-                string firstPassAdvancedOptions = x264Options;\r
+                string firstPassAdvancedOptions = videoOptions;\r
                 if (job.EncodingProfile.TurboFirstPass)\r
                 {\r
                     if (firstPassAdvancedOptions == string.Empty)\r
@@ -555,7 +555,7 @@ namespace HandBrake.Interop
 \r
                 // Second pass. Apply normal options.\r
                 nativeJob.pass = 2;\r
-                nativeJob.encoder_options = originalX264Options;\r
+                nativeJob.encoder_options = originalVideoOptions;\r
 \r
                 HBFunctions.hb_add(this.hbHandle, ref nativeJob);\r
             }\r
@@ -563,7 +563,7 @@ namespace HandBrake.Interop
             {\r
                 // One pass job.\r
                 nativeJob.pass = 0;\r
-                nativeJob.encoder_options = originalX264Options;\r
+                nativeJob.encoder_options = originalVideoOptions;\r
 \r
                 HBFunctions.hb_add(this.hbHandle, ref nativeJob);\r
             }\r
@@ -647,7 +647,7 @@ namespace HandBrake.Interop
             }\r
 \r
             IntPtr nativeJobPtr = HBFunctions.hb_job_init_by_index(this.hbHandle, this.GetTitleIndex(title));\r
-            var nativeJob = InteropUtilities.ReadStructure<hb_job_s>(nativeJobPtr);\r
+            var nativeJob = InteropUtilities.ToStructureFromPtr<hb_job_s>(nativeJobPtr);\r
 \r
             List<IntPtr> allocatedMemory = this.ApplyJob(ref nativeJob, job);\r
             InteropUtilities.FreeMemory(allocatedMemory);\r
@@ -825,8 +825,8 @@ namespace HandBrake.Interop
                 this.titles = new List<Title>();\r
 \r
                 IntPtr titleSetPtr = HBFunctions.hb_get_title_set(this.hbHandle);\r
-                hb_title_set_s titleSet = InteropUtilities.ReadStructure<hb_title_set_s>(titleSetPtr);\r
-                this.originalTitles = titleSet.list_title.ToList<hb_title_s>();\r
+                hb_title_set_s titleSet = InteropUtilities.ToStructureFromPtr<hb_title_set_s>(titleSetPtr);\r
+                this.originalTitles = titleSet.list_title.ToListFromHandBrakeList<hb_title_s>();\r
 \r
                 foreach (hb_title_s title in this.originalTitles)\r
                 {\r
@@ -1068,11 +1068,11 @@ namespace HandBrake.Interop
 \r
                             if (string.IsNullOrWhiteSpace(job.CustomChapterNames[i]))\r
                             {\r
-                                chapterNamePtr = InteropUtilities.CreateUtf8Ptr("Chapter " + (i + 1));\r
+                                chapterNamePtr = InteropUtilities.ToUtf8PtrFromString("Chapter " + (i + 1));\r
                             }\r
                             else\r
                             {\r
-                                chapterNamePtr = InteropUtilities.CreateUtf8Ptr(job.CustomChapterNames[i]);\r
+                                chapterNamePtr = InteropUtilities.ToUtf8PtrFromString(job.CustomChapterNames[i]);\r
                             }\r
 \r
                             HBFunctions.hb_chapter_set_title__ptr(nativeChapters[i], chapterNamePtr);\r
@@ -1398,7 +1398,7 @@ namespace HandBrake.Interop
 \r
             // areBframes\r
             // color_matrix\r
-            List<hb_audio_s> titleAudio = originalTitle.list_audio.ToList<hb_audio_s>();\r
+            List<hb_audio_s> titleAudio = originalTitle.list_audio.ToListFromHandBrakeList<hb_audio_s>();\r
 \r
             var audioList = new List<hb_audio_s>();\r
             int numTracks = 0;\r
@@ -1423,7 +1423,7 @@ namespace HandBrake.Interop
                 audioList.Add(this.ConvertAudioBack(outputTrack.Item1, titleAudio[outputTrack.Item2 - 1], numTracks++, allocatedMemory));\r
             }\r
 \r
-            NativeList nativeAudioList = InteropUtilities.ConvertListBack<hb_audio_s>(audioList);\r
+            NativeList nativeAudioList = InteropUtilities.ToHandBrakeListFromList<hb_audio_s>(audioList);\r
             nativeJob.list_audio = nativeAudioList.Ptr;\r
             allocatedMemory.AddRange(nativeAudioList.AllocatedMemory);\r
 \r
@@ -1431,7 +1431,7 @@ namespace HandBrake.Interop
             {\r
                 if (job.Subtitles.SourceSubtitles != null && job.Subtitles.SourceSubtitles.Count > 0)\r
                 {\r
-                    List<hb_subtitle_s> titleSubtitles = originalTitle.list_subtitle.ToList<hb_subtitle_s>();\r
+                    List<hb_subtitle_s> titleSubtitles = originalTitle.list_subtitle.ToListFromHandBrakeList<hb_subtitle_s>();\r
 \r
                     foreach (SourceSubtitle sourceSubtitle in job.Subtitles.SourceSubtitles)\r
                     {\r
@@ -1529,7 +1529,7 @@ namespace HandBrake.Interop
                        }\r
                        else\r
                        {\r
-                               IntPtr outputPathPtr = InteropUtilities.CreateUtf8Ptr(job.OutputPath);\r
+                               IntPtr outputPathPtr = InteropUtilities.ToUtf8PtrFromString(job.OutputPath);\r
                                allocatedMemory.Add(outputPathPtr);\r
                                nativeJob.file = outputPathPtr;\r
                        }\r
@@ -1618,7 +1618,7 @@ namespace HandBrake.Interop
         private void AddFilter(List<hb_filter_object_s> filterList, int filterType, string settings, List<IntPtr> allocatedMemory)\r
         {\r
             IntPtr settingsNativeString = Marshal.StringToHGlobalAnsi(settings);\r
-            hb_filter_object_s filter = InteropUtilities.ReadStructure<hb_filter_object_s>(HBFunctions.hb_filter_init(filterType));\r
+            hb_filter_object_s filter = InteropUtilities.ToStructureFromPtr<hb_filter_object_s>(HBFunctions.hb_filter_init(filterType));\r
             filter.settings = settingsNativeString;\r
 \r
             allocatedMemory.Add(settingsNativeString);\r
@@ -1647,7 +1647,7 @@ namespace HandBrake.Interop
                 filterPtrList.Add(filterPtr);\r
             }\r
 \r
-            NativeList filterListNative = InteropUtilities.CreateIntPtrList(filterPtrList);\r
+            NativeList filterListNative = InteropUtilities.ToHandBrakeListFromPtrList(filterPtrList);\r
             allocatedMemory.AddRange(filterListNative.AllocatedMemory);\r
 \r
             return filterListNative;\r
@@ -1831,7 +1831,7 @@ namespace HandBrake.Interop
             }\r
 \r
             int currentSubtitleTrack = 1;\r
-            List<hb_subtitle_s> subtitleList = title.list_subtitle.ToList<hb_subtitle_s>();\r
+            List<hb_subtitle_s> subtitleList = title.list_subtitle.ToListFromHandBrakeList<hb_subtitle_s>();\r
             foreach (hb_subtitle_s subtitle in subtitleList)\r
             {\r
                 var newSubtitle = new Subtitle\r
@@ -1888,7 +1888,7 @@ namespace HandBrake.Interop
             }\r
 \r
             int currentAudioTrack = 1;\r
-            List<hb_audio_s> audioList = title.list_audio.ToList<hb_audio_s>();\r
+            List<hb_audio_s> audioList = title.list_audio.ToListFromHandBrakeList<hb_audio_s>();\r
             foreach (hb_audio_s audio in audioList)\r
             {\r
                 var newAudio = new AudioTrack\r
@@ -1910,7 +1910,7 @@ namespace HandBrake.Interop
                 currentAudioTrack++;\r
             }\r
 \r
-            List<hb_chapter_s> chapterList = title.list_chapter.ToList<hb_chapter_s>();\r
+            List<hb_chapter_s> chapterList = title.list_chapter.ToListFromHandBrakeList<hb_chapter_s>();\r
             foreach (hb_chapter_s chapter in chapterList)\r
             {\r
                 var newChapter = new Chapter\r
index 0f8d59c86c3362b58fcfcf4e5a7af6995ff7e575..9402d094086f7eb082e365a22ec5f0a49671c9b8 100644 (file)
@@ -373,6 +373,19 @@ namespace HandBrake.Interop.HbLib
                [DllImport("hb.dll", EntryPoint = "hb_container_get_next", CallingConvention = CallingConvention.Cdecl)]\r
                public static extern IntPtr hb_container_get_next(IntPtr last);\r
 \r
+               [DllImport("hb.dll", EntryPoint = "hb_video_encoder_get_presets", CallingConvention = CallingConvention.Cdecl)]\r
+               public static extern IntPtr hb_video_encoder_get_presets(int encoder);\r
+\r
+               [DllImport("hb.dll", EntryPoint = "hb_video_encoder_get_tunes", CallingConvention = CallingConvention.Cdecl)]\r
+               public static extern IntPtr hb_video_encoder_get_tunes(int encoder);\r
+\r
+               [DllImport("hb.dll", EntryPoint = "hb_video_encoder_get_profiles", CallingConvention = CallingConvention.Cdecl)]\r
+               public static extern IntPtr hb_video_encoder_get_profiles(int encoder);\r
+\r
+               [DllImport("hb.dll", EntryPoint = "hb_video_encoder_get_levels", CallingConvention = CallingConvention.Cdecl)]\r
+               public static extern IntPtr hb_video_encoder_get_levels(int encoder);\r
+\r
+\r
                [DllImport("hb.dll", EntryPoint = "lang_get_next", CallingConvention = CallingConvention.Cdecl)]\r
                public static extern IntPtr lang_get_next(IntPtr last);\r
 \r
index 0019aa2d24f1e02928675d1f66d6fe828a3bc53c..6399beee25afe0833b2031fe9228369fd069a082 100644 (file)
@@ -28,7 +28,7 @@ namespace HandBrake.Interop.Helpers
                /// <typeparam name="T">The type to convert the structure to.</typeparam>\r
                /// <param name="structPtr">The pointer to the native structure.</param>\r
                /// <returns>The converted structure.</returns>\r
-               public static T ReadStructure<T>(IntPtr structPtr)\r
+               public static T ToStructureFromPtr<T>(IntPtr structPtr)\r
                {\r
                        return (T)Marshal.PtrToStructure(structPtr, typeof(T));\r
                }\r
@@ -38,7 +38,7 @@ namespace HandBrake.Interop.Helpers
                /// </summary>\r
                /// <param name="stringPtr">The pointer to the string.</param>\r
                /// <returns>The resulting string.</returns>\r
-               public static string ReadUtf8Ptr(IntPtr stringPtr)\r
+               public static string ToStringFromUtf8Ptr(IntPtr stringPtr)\r
                {\r
                        var data = new List<byte>();\r
                        var ptr = stringPtr;\r
@@ -66,7 +66,7 @@ namespace HandBrake.Interop.Helpers
                /// <returns>\r
                /// The <see cref="IntPtr"/>.\r
                /// </returns>\r
-               public static IntPtr CreateUtf8Ptr(string str)\r
+               public static IntPtr ToUtf8PtrFromString(string str)\r
                {\r
                        byte[] bytes = Encoding.UTF8.GetBytes(str);\r
                        IntPtr stringPtr = Marshal.AllocHGlobal(bytes.Length + 1);\r
@@ -87,7 +87,7 @@ namespace HandBrake.Interop.Helpers
                /// <typeparam name="T">The type of structure in the list.</typeparam>\r
                /// <param name="listPtr">The pointer to the native list.</param>\r
                /// <returns>The converted managed list.</returns>\r
-               public static List<T> ToList<T>(this IntPtr listPtr)\r
+               public static List<T> ToListFromHandBrakeList<T>(this IntPtr listPtr)\r
                {\r
                        List<T> returnList = new List<T>();\r
                        NativeList nativeList = new NativeList(listPtr);\r
@@ -95,7 +95,7 @@ namespace HandBrake.Interop.Helpers
                        for (int i = 0; i < nativeList.Count; i++)\r
                        {\r
                                IntPtr itemPtr = nativeList[i];\r
-                               returnList.Add(ReadStructure<T>(itemPtr));\r
+                               returnList.Add(ToStructureFromPtr<T>(itemPtr));\r
                        }\r
 \r
                        return returnList;\r
@@ -127,14 +127,14 @@ namespace HandBrake.Interop.Helpers
                /// <param name="arrayPtr">The pointer to the array.</param>\r
                /// <param name="count">The number of items in the array.</param>\r
                /// <returns>The converted collection.</returns>\r
-               public static IEnumerable<T> ConvertArray<T>(IntPtr arrayPtr, int count)\r
+               public static List<T> ToListFromNativeArray<T>(IntPtr arrayPtr, int count)\r
                {\r
                        IntPtr currentItem = arrayPtr;\r
 \r
                        var result = new List<T>();\r
                        for (int i = 0; i < count; i++)\r
                        {\r
-                               T nativeEncoder = ReadStructure<T>(currentItem);\r
+                               T nativeEncoder = ToStructureFromPtr<T>(currentItem);\r
                                result.Add(nativeEncoder);\r
 \r
                                currentItem = IntPtr.Add(currentItem, Marshal.SizeOf(typeof(T)));\r
@@ -143,12 +143,46 @@ namespace HandBrake.Interop.Helpers
                        return result;\r
                }\r
 \r
+               /// <summary>\r
+               /// Takes an array pointer and converts it into a list of strings.\r
+               /// </summary>\r
+               /// <param name="arrayPtr">A pointer to a raw list of strings.</param>\r
+               /// <returns>The list of strings.</returns>\r
+           public static List<string> ToStringListFromArrayPtr(IntPtr arrayPtr)\r
+               {\r
+                       if (arrayPtr == IntPtr.Zero)\r
+                       {\r
+                               return null;\r
+                       }\r
+\r
+                       return ToPtrListFromPtr(arrayPtr).Select(ptr => Marshal.PtrToStringAnsi(ptr)).ToList();\r
+               }\r
+\r
+           /// <summary>\r
+               /// Finds all the pointers starting at the given location and puts them in a list. Stops when it finds zero for a pointer.\r
+               /// </summary>\r
+               /// <param name="arrayPtr">The address of the list of pointers.</param>\r
+               /// <returns>The list of pointers.</returns>\r
+           public static List<IntPtr> ToPtrListFromPtr(IntPtr arrayPtr)\r
+           {\r
+                   var result = new List<IntPtr>();\r
+                   int ptrSize = Marshal.SizeOf(typeof(IntPtr));\r
+                   IntPtr currentPtr = Marshal.ReadIntPtr(arrayPtr);\r
+                       for (int i = 0; currentPtr != IntPtr.Zero; i++)\r
+                       {\r
+                               result.Add(currentPtr);\r
+                           currentPtr = Marshal.ReadIntPtr(arrayPtr, (i + 1) * ptrSize);\r
+                   }\r
+\r
+                   return result;\r
+           }\r
+\r
                /// <summary>\r
                /// Creates a native HandBrake list from the given managed list of pointers.\r
                /// </summary>\r
                /// <param name="list">The managed list to convert.</param>\r
                /// <returns>The converted native list.</returns>\r
-               public static NativeList CreateIntPtrList(List<IntPtr> list)\r
+               public static NativeList ToHandBrakeListFromPtrList(List<IntPtr> list)\r
                {\r
                        NativeList returnList = NativeList.CreateList();\r
 \r
@@ -166,7 +200,7 @@ namespace HandBrake.Interop.Helpers
                /// <typeparam name="T">The type of structures in the list.</typeparam>\r
                /// <param name="list">The managed list to convert.</param>\r
                /// <returns>The converted native list.</returns>\r
-               public static NativeList ConvertListBack<T>(List<T> list)\r
+               public static NativeList ToHandBrakeListFromList<T>(List<T> list)\r
                {\r
                        NativeList returnList = NativeList.CreateList();\r
                        foreach (T item in list)\r
@@ -189,9 +223,9 @@ namespace HandBrake.Interop.Helpers
                /// <param name="iterator">The iterator to use to build the list.</param>\r
                /// <param name="converter">The converter to convert from the struct to the object.</param>\r
                /// <returns>The list of objects.</returns>\r
-               public static List<T2> GetListFromIterator<T1, T2>(Func<IntPtr, IntPtr> iterator, Func<T1, T2> converter)\r
+               public static List<T2> ToListFromIterator<T1, T2>(Func<IntPtr, IntPtr> iterator, Func<T1, T2> converter)\r
                {\r
-                       return ReadStructureListFromIterator<T1>(iterator).Select(converter).ToList();\r
+                       return ToListFromIterator<T1>(iterator).Select(converter).ToList();\r
                } \r
 \r
                /// <summary>\r
@@ -200,7 +234,7 @@ namespace HandBrake.Interop.Helpers
                /// <typeparam name="T">The type of the struct.</typeparam>\r
                /// <param name="iterator">The iterator to use to build the list.</param>\r
                /// <returns>The list of structs.</returns>\r
-               public static List<T> ReadStructureListFromIterator<T>(Func<IntPtr, IntPtr> iterator)\r
+               public static List<T> ToListFromIterator<T>(Func<IntPtr, IntPtr> iterator)\r
                {\r
                        var structureList = new List<T>();\r
                        IntPtr current = IntPtr.Zero;\r
@@ -208,7 +242,7 @@ namespace HandBrake.Interop.Helpers
                        current = iterator(current);\r
                        while (current != IntPtr.Zero)\r
                        {\r
-                               T encoder = ReadStructure<T>(current);\r
+                               T encoder = ToStructureFromPtr<T>(current);\r
                                structureList.Add(encoder);\r
 \r
                                current = iterator(current);\r
index b89e190eb9d513b6a50d937896122b5599206f6a..7dfe40301a7cd3608b7a00cad8a9255159085c8d 100644 (file)
@@ -33,7 +33,7 @@ namespace HandBrake.Interop.Helpers
                        {\r
                            return allLanguages\r
                                   ?? (allLanguages =\r
-                                      InteropUtilities.GetListFromIterator<iso639_lang_t, Language>(HBFunctions.lang_get_next, Converters.Converters.NativeToLanguage));\r
+                                      InteropUtilities.ToListFromIterator<iso639_lang_t, Language>(HBFunctions.lang_get_next, Converters.Converters.NativeToLanguage));\r
                        }\r
                }\r
 \r
@@ -44,7 +44,7 @@ namespace HandBrake.Interop.Helpers
                /// <returns>Object that describes the language.</returns>\r
                public static Language Get(string code)\r
                {\r
-                       iso639_lang_t language = InteropUtilities.ReadStructure<iso639_lang_t>(HBFunctions.lang_for_code2(code));\r
+                       iso639_lang_t language = InteropUtilities.ToStructureFromPtr<iso639_lang_t>(HBFunctions.lang_for_code2(code));\r
                        return Converters.Converters.NativeToLanguage(language);\r
                }\r
        }\r
index 593c1015fc9735a8e82ec8e47c17ef72f2819e26..ecf1b775a1084d14a5f75e9339ef2ae48b756ce0 100644 (file)
@@ -76,7 +76,7 @@ namespace HandBrake.Interop.Model
                        {\r
                                if (audioEncoders == null)\r
                                {\r
-                                       audioEncoders = InteropUtilities.GetListFromIterator<hb_encoder_s, HBAudioEncoder>(HBFunctions.hb_audio_encoder_get_next, Converters.NativeToAudioEncoder);\r
+                                       audioEncoders = InteropUtilities.ToListFromIterator<hb_encoder_s, HBAudioEncoder>(HBFunctions.hb_audio_encoder_get_next, Converters.NativeToAudioEncoder);\r
                                }\r
 \r
                                return audioEncoders;\r
@@ -92,7 +92,7 @@ namespace HandBrake.Interop.Model
                        {\r
                                if (videoEncoders == null)\r
                                {\r
-                                       videoEncoders = InteropUtilities.GetListFromIterator<hb_encoder_s, HBVideoEncoder>(HBFunctions.hb_video_encoder_get_next, Converters.NativeToVideoEncoder);\r
+                                       videoEncoders = InteropUtilities.ToListFromIterator<hb_encoder_s, HBVideoEncoder>(HBFunctions.hb_video_encoder_get_next, Converters.NativeToVideoEncoder);\r
                                }\r
 \r
                                return videoEncoders;\r
@@ -108,7 +108,7 @@ namespace HandBrake.Interop.Model
                        {\r
                                if (videoFramerates == null)\r
                                {\r
-                                       videoFramerates = InteropUtilities.GetListFromIterator<hb_rate_s, HBRate>(HBFunctions.hb_video_framerate_get_next, Converters.NativeToRate);\r
+                                       videoFramerates = InteropUtilities.ToListFromIterator<hb_rate_s, HBRate>(HBFunctions.hb_video_framerate_get_next, Converters.NativeToRate);\r
                                }\r
 \r
                                return videoFramerates;\r
@@ -124,7 +124,7 @@ namespace HandBrake.Interop.Model
                        {\r
                                if (mixdowns == null)\r
                                {\r
-                                       mixdowns = InteropUtilities.GetListFromIterator<hb_mixdown_s, HBMixdown>(HBFunctions.hb_mixdown_get_next, Converters.NativeToMixdown);\r
+                                       mixdowns = InteropUtilities.ToListFromIterator<hb_mixdown_s, HBMixdown>(HBFunctions.hb_mixdown_get_next, Converters.NativeToMixdown);\r
                                }\r
 \r
                                return mixdowns;\r
@@ -140,7 +140,7 @@ namespace HandBrake.Interop.Model
                        {\r
                                if (audioBitrates == null)\r
                                {\r
-                                       audioBitrates = InteropUtilities.GetListFromIterator<hb_rate_s, int>(HBFunctions.hb_audio_bitrate_get_next, b => b.rate);\r
+                                       audioBitrates = InteropUtilities.ToListFromIterator<hb_rate_s, int>(HBFunctions.hb_audio_bitrate_get_next, b => b.rate);\r
                                }\r
 \r
                                return audioBitrates;\r
@@ -156,7 +156,7 @@ namespace HandBrake.Interop.Model
                        {\r
                                if (audioSampleRates == null)\r
                                {\r
-                                       audioSampleRates = InteropUtilities.GetListFromIterator<hb_rate_s, HBRate>(HBFunctions.hb_audio_samplerate_get_next, Converters.NativeToRate);\r
+                                       audioSampleRates = InteropUtilities.ToListFromIterator<hb_rate_s, HBRate>(HBFunctions.hb_audio_samplerate_get_next, Converters.NativeToRate);\r
                                }\r
 \r
                                return audioSampleRates;\r
@@ -172,7 +172,7 @@ namespace HandBrake.Interop.Model
                        {\r
                                if (containers == null)\r
                                {\r
-                                       containers = InteropUtilities.GetListFromIterator<hb_container_s, HBContainer>(HBFunctions.hb_container_get_next, Converters.NativeToContainer);\r
+                                       containers = InteropUtilities.ToListFromIterator<hb_container_s, HBContainer>(HBFunctions.hb_container_get_next, Converters.NativeToContainer);\r
                                }\r
 \r
                                return containers;\r
index c1947745b71f6321bc34f4ffa6b1db8065a64653..257c324d7a8784acf8e9cf2456abbe860a67a3e2 100644 (file)
@@ -193,60 +193,35 @@ namespace HandBrake.Interop.Model.Encoding
         public string VideoEncoder { get; set; }\r
 \r
         /// <summary>\r
-        /// Gets or sets the x 264 options.\r
+        /// Gets or sets the video encoder options.\r
         /// </summary>\r
-        public string X264Options { get; set; }\r
+        public string VideoOptions { get; set; }\r
 \r
         /// <summary>\r
-        /// Gets or sets the x 264 profile.\r
+        /// Gets or sets the video encoder profile name.\r
         /// </summary>\r
-        public string X264Profile { get; set; }\r
+        public string VideoProfile { get; set; }\r
 \r
         /// <summary>\r
-        /// Gets or sets the x 264 preset.\r
+        /// Gets or sets the video encoder preset name.\r
         /// </summary>\r
-        public string X264Preset { get; set; }\r
+        public string VideoPreset { get; set; }\r
 \r
         /// <summary>\r
-        /// Gets or sets the x 264 tunes.\r
+        /// Gets or sets the video encoder tunes.\r
         /// </summary>\r
-        public List<string> X264Tunes { get; set; }\r
+        public List<string> VideoTunes { get; set; }\r
 \r
-        /// <summary>\r
-        /// Gets or sets the x 265 profile.\r
-        /// </summary>\r
-        public string X265Profile { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the x 265 preset.\r
-        /// </summary>\r
-        public string X265Preset { get; set; }\r
+               /// <summary>\r
+               /// Gets or sets the video encoder level.\r
+               /// </summary>\r
+               public string VideoLevel { get; set; }\r
 \r
         /// <summary>\r
-        /// Gets or sets the x 265 tunes.\r
-        /// </summary>\r
-        public List<string> X265Tunes { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the x 265 level.\r
-        /// </summary>\r
-        public List<string> X265Level { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the qsv preset.\r
-        /// </summary>\r
-        public string QsvPreset { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets a value indicating whether qsv decode.\r
+        /// Gets or sets a value indicating whether to use QSV decoding.\r
         /// </summary>\r
         public bool QsvDecode { get; set; }\r
 \r
-        /// <summary>\r
-        /// Gets or sets the h 264 level.\r
-        /// </summary>\r
-        public string H264Level { get; set; }\r
-\r
         /// <summary>\r
         /// Gets or sets the video encode rate type.\r
         /// </summary>\r
@@ -345,13 +320,12 @@ namespace HandBrake.Interop.Model.Encoding
                 Grayscale = this.Grayscale,\r
 \r
                 VideoEncoder = this.VideoEncoder,\r
-                X264Options = this.X264Options,\r
-                X264Profile = this.X264Profile,\r
-                X264Preset = this.X264Preset,\r
-                X264Tunes = this.X264Tunes,\r
-                QsvPreset = this.QsvPreset,\r
-                QsvDecode = this.QsvDecode,\r
-                H264Level = this.H264Level,\r
+                               VideoOptions = this.VideoOptions,\r
+                VideoProfile = this.VideoProfile,\r
+                VideoPreset = this.VideoPreset,\r
+                VideoTunes = this.VideoTunes,\r
+                               VideoLevel = this.VideoLevel,\r
+                               QsvDecode = this.QsvDecode,\r
                 VideoEncodeRateType = this.VideoEncodeRateType,\r
                 Quality = this.Quality,\r
                 TargetSize = this.TargetSize,\r
index 98bbcc319adbd793875bdcb72ea40b98c4759e83..810994ba817fb4b63595c13585799b3bca143b3a 100644 (file)
@@ -9,13 +9,16 @@
 \r
 namespace HandBrake.Interop.Model.Encoding\r
 {\r
-    /// <summary>\r
+       using System.Collections.Generic;\r
+\r
+       using HandBrake.Interop.HbLib;\r
+       using HandBrake.Interop.Helpers;\r
+\r
+       /// <summary>\r
     /// The hb video encoder.\r
     /// </summary>\r
     public class HBVideoEncoder\r
     {\r
-        #region Public Properties\r
-\r
         /// <summary>\r
         /// Gets or sets the compatible containers.\r
         /// </summary>\r
@@ -36,6 +39,48 @@ namespace HandBrake.Interop.Model.Encoding
         /// </summary>\r
         public string ShortName { get; set; }\r
 \r
-        #endregion\r
+               /// <summary>\r
+               /// Gets the list of presets this encoder supports. (null if the encoder doesn't support presets)\r
+               /// </summary>\r
+               public List<string> Presets\r
+               {\r
+                       get\r
+                       {\r
+                               return InteropUtilities.ToStringListFromArrayPtr(HBFunctions.hb_video_encoder_get_presets(this.Id));\r
+                       }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the list of tunes this encoder supports. (null if the encoder doesn't support tunes)\r
+               /// </summary>\r
+               public List<string> Tunes\r
+               {\r
+                       get\r
+                       {\r
+                               return InteropUtilities.ToStringListFromArrayPtr(HBFunctions.hb_video_encoder_get_tunes(this.Id));\r
+                       }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the list of profiles this encoder supports. (null if the encoder doesn't support profiles)\r
+               /// </summary>\r
+               public List<string> Profiles\r
+               {\r
+                       get\r
+                       {\r
+                               return InteropUtilities.ToStringListFromArrayPtr(HBFunctions.hb_video_encoder_get_profiles(this.Id));\r
+                       }\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the list of levels this encoder supports. (null if the encoder doesn't support levels)\r
+               /// </summary>\r
+               public List<string> Levels\r
+               {\r
+                       get\r
+                       {\r
+                               return InteropUtilities.ToStringListFromArrayPtr(HBFunctions.hb_video_encoder_get_levels(this.Id));\r
+                       }\r
+               } \r
     }\r
 }
\ No newline at end of file