From 900b57a83dfa9a78c3f5a0673f052fff9ba6d302 Mon Sep 17 00:00:00 2001 From: randomengy Date: Sun, 2 Dec 2012 22:40:37 +0000 Subject: Interop: Fixing title number/title index mixup. Adding Playlist to the Title object. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5088 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../HandBrakeInterop/HandBrakeInstance.cs | 36 +++++++++++++++++----- .../HandBrakeInterop/HbLib/hb_title_s.cs | 2 +- .../HandBrakeInterop/Properties/AssemblyInfo.cs | 4 +-- .../HandBrakeInterop/SourceData/Title.cs | 22 +++++++++++-- 4 files changed, 51 insertions(+), 13 deletions(-) (limited to 'win/CS') diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs index a1263a4fb..a2bf8cef9 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs @@ -233,7 +233,7 @@ namespace HandBrake.Interop /// An image with the requested preview. public BitmapImage GetPreview(EncodeJob job, int previewNumber) { - IntPtr nativeJobPtr = HBFunctions.hb_job_init_by_index(this.hbHandle, job.Title); + IntPtr nativeJobPtr = HBFunctions.hb_job_init_by_index(this.hbHandle, this.GetTitleIndex(job.Title)); var nativeJob = InteropUtilities.ReadStructure(nativeJobPtr); List allocatedMemory = this.ApplyJob(ref nativeJob, job); @@ -402,7 +402,7 @@ namespace HandBrake.Interop EncodingProfile profile = job.EncodingProfile; this.currentJob = job; - IntPtr nativeJobPtr = HBFunctions.hb_job_init_by_index(this.hbHandle, job.Title); + IntPtr nativeJobPtr = HBFunctions.hb_job_init_by_index(this.hbHandle, this.GetTitleIndex(job.Title)); var nativeJob = InteropUtilities.ReadStructure(nativeJobPtr); this.encodeAllocatedMemory = this.ApplyJob(ref nativeJob, job, preview, previewNumber, previewSeconds, overallSelectedLengthSeconds); @@ -576,7 +576,7 @@ namespace HandBrake.Interop return; } - IntPtr nativeJobPtr = HBFunctions.hb_job_init_by_index(this.hbHandle, job.Title); + IntPtr nativeJobPtr = HBFunctions.hb_job_init_by_index(this.hbHandle, this.GetTitleIndex(title)); var nativeJob = InteropUtilities.ReadStructure(nativeJobPtr); List allocatedMemory = this.ApplyJob(ref nativeJob, job); @@ -1540,13 +1540,34 @@ namespace HandBrake.Interop } /// - /// Gets the title, given the 1-based index. + /// Gets the title, given the 1-based title number. /// - /// The index of the title (1-based). + /// The number of the title (1-based). /// The requested Title. - private Title GetTitle(int titleIndex) + private Title GetTitle(int titleNumber) + { + return this.Titles.SingleOrDefault(title => title.TitleNumber == titleNumber); + } + + /// + /// Gets the 1-based title index of the given title. + /// + /// The 1-based title title number. + /// The 1-based title index. + private int GetTitleIndex(int titleNumber) + { + Title title = this.GetTitle(titleNumber); + return this.GetTitleIndex(title); + } + + /// + /// Gets the 1-based title index of the given title. + /// + /// The title to look up + /// The 1-based title index of the given title. + private int GetTitleIndex(Title title) { - return this.Titles.SingleOrDefault(title => title.TitleNumber == titleIndex); + return this.Titles.IndexOf(title) + 1; } /// @@ -1657,6 +1678,7 @@ namespace HandBrake.Interop var newTitle = new Title { TitleNumber = title.index, + Playlist = title.playlist, Resolution = new Size(title.width, title.height), ParVal = new Size(title.pixel_aspect_width, title.pixel_aspect_height), Duration = TimeSpan.FromSeconds(title.duration / 90000), diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_title_s.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_title_s.cs index 136c2df74..859719b79 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_title_s.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_title_s.cs @@ -23,7 +23,7 @@ namespace HandBrake.Interop.HbLib /// char[1024] [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)] - public string dvd; + public string path; /// char[1024] [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)] diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Properties/AssemblyInfo.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Properties/AssemblyInfo.cs index 523d7a8dd..3990704fe 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Properties/AssemblyInfo.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.33.0.0")] -[assembly: AssemblyFileVersion("1.33.0.0")] +[assembly: AssemblyVersion("1.35.0.0")] +[assembly: AssemblyFileVersion("1.35.0.0")] diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/Title.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/Title.cs index 06b1acdef..344759c1d 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/Title.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/Title.cs @@ -67,6 +67,11 @@ namespace HandBrake.Interop.SourceData /// public int TitleNumber { get; set; } + /// + /// Gets or sets the playlist number this title came from. + /// + public int Playlist { get; set; } + /// /// Gets or sets the length in time of this Title /// @@ -131,11 +136,22 @@ namespace HandBrake.Interop.SourceData /// /// Override of the ToString method to provide an easy way to use this object in the UI /// - /// A string representing this track in the format: {title #} (00:00:00) + /// A string representing this track in the format: {title #}[ {playlist source}] (00:00:00) public override string ToString() { - return string.Format("{0} ({1:00}:{2:00}:{3:00})", this.TitleNumber, this.Duration.Hours, - this.Duration.Minutes, this.Duration.Seconds); + string playlistPortion = string.Empty; + if (this.InputType == InputType.Bluray) + { + playlistPortion = string.Format(" {0:d5}.MPLS", this.Playlist); + } + + return string.Format( + "{0}{1} ({2:00}:{3:00}:{4:00})", + this.TitleNumber, + playlistPortion, + this.Duration.Hours, + this.Duration.Minutes, + this.Duration.Seconds); } /// -- cgit v1.2.3