// -------------------------------------------------------------------------------------------------------------------- // // This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. // // // An object that represents a single Title of a DVD // // -------------------------------------------------------------------------------------------------------------------- namespace HandBrake.Interop.SourceData { using System; using System.Collections.Generic; using HandBrake.Interop.Model; /// /// An object that represents a single Title of a DVD /// public class Title { private readonly List audioTracks; private readonly List chapters; private readonly List subtitles; /// /// Initializes a new instance of the Title class. /// public Title() { this.audioTracks = new List(); this.chapters = new List(); this.subtitles = new List(); } /// /// Gets or sets the input type of this title. /// public InputType InputType { get; set; } /// /// Gets a collection of chapters in this Title /// public List Chapters { get { return this.chapters; } } /// /// Gets a collection of audio tracks associated with this Title /// public List AudioTracks { get { return this.audioTracks; } } /// /// Gets a collection of subtitles associated with this Title /// public List Subtitles { get { return this.subtitles; } } /// /// Gets or sets the track number of this Title (1-based). /// 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 /// public TimeSpan Duration { get; set; } /// /// Gets or sets the resolution (width/height) of this Title /// public Size Resolution { get; set; } /// /// Gets or sets the aspect ratio of this Title /// public double AspectRatio { get; set; } /// /// Gets or sets the number of angles on the title. /// public int AngleCount { get; set; } /// /// Gets or sets the pixel aspect ratio. /// public Size ParVal { get; set; } /// /// Gets or sets the automatically detected crop region for this Title. /// public Cropping AutoCropDimensions { get; set; } /// /// Gets or sets the name of the video codec for this title. /// public string VideoCodecName { get; set; } /// /// Gets or sets the video frame rate for this title. /// public double Framerate { get; set; } /// /// Gets or sets the video frame rate numerator. /// public int FramerateNumerator { get; set; } /// /// Gets or sets the video frame rate denominator. /// public int FramerateDenominator { get; set; } /// /// Gets the total number of frames in this title. /// public int Frames { get { return (int)Math.Ceiling(((double)this.Duration.TotalSeconds) * this.Framerate); } } /// /// 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 #}[ {playlist source}] (00:00:00) public override string ToString() { 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); } /// /// Gets the display string for this title. /// public string Display { get { return this.ToString(); } } } }