]> granicus.if.org Git - handbrake/commitdiff
Interop: Fixing title number/title index mixup. Adding Playlist to the Title object.
authorrandomengy <david.rickard@gmail.com>
Sun, 2 Dec 2012 22:40:37 +0000 (22:40 +0000)
committerrandomengy <david.rickard@gmail.com>
Sun, 2 Dec 2012 22:40:37 +0000 (22:40 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5088 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs
win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_title_s.cs
win/CS/HandBrake.Interop/HandBrakeInterop/Properties/AssemblyInfo.cs
win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/Title.cs

index a1263a4fbd13878adad337aee63c0619ad708897..a2bf8cef97f2bca29e463fe2bb54006704e1ad2c 100644 (file)
@@ -233,7 +233,7 @@ namespace HandBrake.Interop
                /// <returns>An image with the requested preview.</returns>\r
                public BitmapImage GetPreview(EncodeJob job, int previewNumber)\r
                {\r
-                       IntPtr nativeJobPtr = HBFunctions.hb_job_init_by_index(this.hbHandle, job.Title);\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
 \r
                        List<IntPtr> allocatedMemory = this.ApplyJob(ref nativeJob, job);\r
@@ -402,7 +402,7 @@ namespace HandBrake.Interop
                        EncodingProfile profile = job.EncodingProfile;\r
                        this.currentJob = job;\r
 \r
-                       IntPtr nativeJobPtr = HBFunctions.hb_job_init_by_index(this.hbHandle, job.Title);\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
 \r
                        this.encodeAllocatedMemory = this.ApplyJob(ref nativeJob, job, preview, previewNumber, previewSeconds, overallSelectedLengthSeconds);\r
@@ -576,7 +576,7 @@ namespace HandBrake.Interop
                                return;\r
                        }\r
 \r
-                       IntPtr nativeJobPtr = HBFunctions.hb_job_init_by_index(this.hbHandle, job.Title);\r
+                       IntPtr nativeJobPtr = HBFunctions.hb_job_init_by_index(this.hbHandle, this.GetTitleIndex(title));\r
                        var nativeJob = InteropUtilities.ReadStructure<hb_job_s>(nativeJobPtr);\r
 \r
                        List<IntPtr> allocatedMemory = this.ApplyJob(ref nativeJob, job);\r
@@ -1540,13 +1540,34 @@ namespace HandBrake.Interop
                }\r
 \r
                /// <summary>\r
-               /// Gets the title, given the 1-based index.\r
+               /// Gets the title, given the 1-based title number.\r
                /// </summary>\r
-               /// <param name="titleIndex">The index of the title (1-based).</param>\r
+               /// <param name="titleNumber">The number of the title (1-based).</param>\r
                /// <returns>The requested Title.</returns>\r
-               private Title GetTitle(int titleIndex)\r
+               private Title GetTitle(int titleNumber)\r
+               {\r
+                       return this.Titles.SingleOrDefault(title => title.TitleNumber == titleNumber);\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the 1-based title index of the given title.\r
+               /// </summary>\r
+               /// <param name="titleNumber">The 1-based title title number.</param>\r
+               /// <returns>The 1-based title index.</returns>\r
+               private int GetTitleIndex(int titleNumber)\r
+               {\r
+                       Title title = this.GetTitle(titleNumber);\r
+                       return this.GetTitleIndex(title);\r
+               }\r
+\r
+               /// <summary>\r
+               /// Gets the 1-based title index of the given title.\r
+               /// </summary>\r
+               /// <param name="title">The title to look up</param>\r
+               /// <returns>The 1-based title index of the given title.</returns>\r
+               private int GetTitleIndex(Title title)\r
                {\r
-                       return this.Titles.SingleOrDefault(title => title.TitleNumber == titleIndex);\r
+                       return this.Titles.IndexOf(title) + 1;\r
                }\r
 \r
                /// <summary>\r
@@ -1657,6 +1678,7 @@ namespace HandBrake.Interop
                        var newTitle = new Title\r
                        {\r
                                TitleNumber = title.index,\r
+                               Playlist = title.playlist,\r
                                Resolution = new Size(title.width, title.height),\r
                                ParVal = new Size(title.pixel_aspect_width, title.pixel_aspect_height),\r
                                Duration = TimeSpan.FromSeconds(title.duration / 90000),\r
index 136c2df7477710ae01bf74d23d525605a4737053..859719b7911c1c735d99537d11941b0e36d3b78d 100644 (file)
@@ -23,7 +23,7 @@ namespace HandBrake.Interop.HbLib
 \r
                /// char[1024]\r
                [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]\r
-               public string dvd;\r
+               public string path;\r
 \r
                /// char[1024]\r
                [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]\r
index 523d7a8ddb50c90fa9ad5bcf5b7aba473530601f..3990704fe00916ec74174fb6f3d5bf2148c773e4 100644 (file)
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
 // You can specify all the values or you can default the Build and Revision Numbers \r
 // by using the '*' as shown below:\r
 // [assembly: AssemblyVersion("1.0.*")]\r
-[assembly: AssemblyVersion("1.33.0.0")]\r
-[assembly: AssemblyFileVersion("1.33.0.0")]\r
+[assembly: AssemblyVersion("1.35.0.0")]\r
+[assembly: AssemblyFileVersion("1.35.0.0")]\r
index 06b1acdefa17c3ea717d3f2d85ed365f1f5da365..344759c1d9df8518fc30dcfb03f0757e9b261b8a 100644 (file)
@@ -67,6 +67,11 @@ namespace HandBrake.Interop.SourceData
                /// </summary>\r
                public int TitleNumber { get; set; }\r
 \r
+               /// <summary>\r
+               /// Gets or sets the playlist number this title came from.\r
+               /// </summary>\r
+               public int Playlist { get; set; }\r
+\r
                /// <summary>\r
                /// Gets or sets the length in time of this Title\r
                /// </summary>\r
@@ -131,11 +136,22 @@ namespace HandBrake.Interop.SourceData
                /// <summary>\r
                /// Override of the ToString method to provide an easy way to use this object in the UI\r
                /// </summary>\r
-               /// <returns>A string representing this track in the format: {title #} (00:00:00)</returns>\r
+               /// <returns>A string representing this track in the format: {title #}[ {playlist source}] (00:00:00)</returns>\r
                public override string ToString()\r
                {\r
-                       return string.Format("{0} ({1:00}:{2:00}:{3:00})", this.TitleNumber, this.Duration.Hours,\r
-                                                                this.Duration.Minutes, this.Duration.Seconds);\r
+                       string playlistPortion = string.Empty;\r
+                       if (this.InputType == InputType.Bluray)\r
+                       {\r
+                               playlistPortion = string.Format(" {0:d5}.MPLS", this.Playlist);\r
+                       }\r
+\r
+                       return string.Format(\r
+                               "{0}{1} ({2:00}:{3:00}:{4:00})", \r
+                               this.TitleNumber, \r
+                               playlistPortion,\r
+                               this.Duration.Hours,\r
+                               this.Duration.Minutes, \r
+                               this.Duration.Seconds);\r
                }\r
 \r
                /// <summary>\r