summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.Interop/HandBrakeInterop/Model
diff options
context:
space:
mode:
authorsr55 <[email protected]>2014-12-20 13:20:27 +0000
committersr55 <[email protected]>2014-12-20 13:20:27 +0000
commit541c3053f07d7cf9b90f168ee27fa121082d677b (patch)
treec429ab6b19ba9789c695acaeeef2b994673da0ec /win/CS/HandBrake.Interop/HandBrakeInterop/Model
parent494eb256cb625a1620786f32d0e41c904ecf0cbf (diff)
WinGui: Refactor the scan model namespace in preparation for json api impl
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6621 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.Interop/HandBrakeInterop/Model')
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoders.cs4
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/AudioCodec.cs53
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/AudioTrack.cs117
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/Chapter.cs49
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/InputType.cs28
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/Subtitle.cs101
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/SubtitleSource.cs26
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/SubtitleType.cs20
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/Title.cs189
9 files changed, 585 insertions, 2 deletions
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoders.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoders.cs
index 295586c8f..036617ce0 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoders.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoders.cs
@@ -17,9 +17,9 @@ namespace HandBrake.Interop.Model
using HandBrake.Interop.HbLib;
using HandBrake.Interop.Helpers;
using HandBrake.Interop.Model.Encoding;
- using HandBrake.Interop.SourceData;
+ using HandBrake.Interop.Model.Scan;
- /// <summary>
+ /// <summary>
/// The encoders.
/// </summary>
public static class Encoders
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/AudioCodec.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/AudioCodec.cs
new file mode 100644
index 000000000..41b363dac
--- /dev/null
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/AudioCodec.cs
@@ -0,0 +1,53 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="AudioCodec.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>
+// Defines the AudioCodec type.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.Interop.Model.Scan
+{
+ /// <summary>
+ /// The audio codec.
+ /// Only contains 2 real codecs at the moment as those are what we care about. More will be added later.
+ /// </summary>
+ public enum AudioCodec
+ {
+ /// <summary>
+ /// The ac 3.
+ /// </summary>
+ Ac3,
+
+ /// <summary>
+ /// The dts.
+ /// </summary>
+ Dts,
+
+ /// <summary>
+ /// The dts hd.
+ /// </summary>
+ DtsHD,
+
+ /// <summary>
+ /// The mp 3.
+ /// </summary>
+ Mp3,
+
+ /// <summary>
+ /// The aac.
+ /// </summary>
+ Aac,
+
+ /// <summary>
+ /// The other.
+ /// </summary>
+ Other,
+
+ /// <summary>
+ /// The flac.
+ /// </summary>
+ Flac,
+ }
+} \ No newline at end of file
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/AudioTrack.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/AudioTrack.cs
new file mode 100644
index 000000000..2bf275fdd
--- /dev/null
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/AudioTrack.cs
@@ -0,0 +1,117 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="AudioTrack.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>
+// An object represending an AudioTrack associated with a Title, in a DVD
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.Interop.Model.Scan
+{
+ /// <summary>
+ /// An object represending an AudioTrack associated with a Title, in a DVD
+ /// </summary>
+ public class AudioTrack
+ {
+ /// <summary>
+ /// Gets or sets the track number of this Audio Track
+ /// </summary>
+ public int TrackNumber { get; set; }
+
+ /// <summary>
+ /// Gets or sets the audio codec of this Track.
+ /// </summary>
+ public AudioCodec Codec { get; set; }
+
+ /// <summary>
+ /// Gets or sets the audio codec ID for this track.
+ /// </summary>
+ public uint CodecId { get; set; }
+
+ /// <summary>
+ /// Gets or sets the codec parameters for this track.
+ /// </summary>
+ public uint CodecParam { get; set; }
+
+ /// <summary>
+ /// Gets or sets the language (if detected) of this Audio Track
+ /// </summary>
+ public string Language { get; set; }
+
+ /// <summary>
+ /// Gets or sets the language code for this audio track.
+ /// </summary>
+ public string LanguageCode { get; set; }
+
+ /// <summary>
+ /// Gets or sets the description for this audio track.
+ /// </summary>
+ public string Description { get; set; }
+
+ /// <summary>
+ /// Gets or sets the channel layout of this Audio Track.
+ /// </summary>
+ public ulong ChannelLayout { get; set; }
+
+ /// <summary>
+ /// Gets or sets the frequency (in Hz) of this Audio Track
+ /// </summary>
+ public int SampleRate { get; set; }
+
+ /// <summary>
+ /// Gets or sets the bitrate (in bits/sec) of this Audio Track.
+ /// </summary>
+ public int Bitrate { get; set; }
+
+ /// <summary>
+ /// Gets the display string for this audio track.
+ /// </summary>
+ public string Display
+ {
+ get
+ {
+ return this.GetDisplayString(true);
+ }
+ }
+
+ /// <summary>
+ /// Gets the display string for this audio track (not including track number)
+ /// </summary>
+ public string NoTrackDisplay
+ {
+ get
+ {
+ return this.GetDisplayString(false);
+ }
+ }
+
+ /// <summary>
+ /// Override of the ToString method to make this object easier to use in the UI
+ /// </summary>
+ /// <returns>A string formatted as: {track #} {language} ({format}) ({sub-format})</returns>
+ public override string ToString()
+ {
+ return this.GetDisplayString(true);
+ }
+
+ /// <summary>
+ /// The get display string.
+ /// </summary>
+ /// <param name="includeTrackNumber">
+ /// The include track number.
+ /// </param>
+ /// <returns>
+ /// The <see cref="string"/>.
+ /// </returns>
+ private string GetDisplayString(bool includeTrackNumber)
+ {
+ if (includeTrackNumber)
+ {
+ return this.TrackNumber + " " + this.Description;
+ }
+
+ return this.Description;
+ }
+ }
+} \ No newline at end of file
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/Chapter.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/Chapter.cs
new file mode 100644
index 000000000..70e35e6f3
--- /dev/null
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/Chapter.cs
@@ -0,0 +1,49 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="Chapter.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>
+// An object representing a Chapter aosciated with a Title, in a DVD
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.Interop.Model.Scan
+{
+ using System;
+ using System.Globalization;
+
+ /// <summary>
+ /// An object representing a Chapter aosciated with a Title, in a DVD
+ /// </summary>
+ public class Chapter
+ {
+ /// <summary>
+ /// Gets or sets the name.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Gets or sets the number of this Chapter, in regards to its parent Title
+ /// </summary>
+ public int ChapterNumber { get; set; }
+
+ /// <summary>
+ /// Gets or sets the duration of this chapter.
+ /// </summary>
+ public TimeSpan Duration { get; set; }
+
+ /// <summary>
+ /// Gets or sets the duration of this chapter in PTS.
+ /// </summary>
+ public ulong DurationPts { get; set; }
+
+ /// <summary>
+ /// Override of the ToString method to make this object easier to use in the UI
+ /// </summary>
+ /// <returns>A string formatted as: {chapter #}</returns>
+ public override string ToString()
+ {
+ return this.ChapterNumber.ToString(CultureInfo.InvariantCulture);
+ }
+ }
+} \ No newline at end of file
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/InputType.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/InputType.cs
new file mode 100644
index 000000000..e3156ea8e
--- /dev/null
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/InputType.cs
@@ -0,0 +1,28 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="InputType.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>
+// Defines the InputType type.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.Interop.Model.Scan
+{
+ using System.ComponentModel.DataAnnotations;
+
+ /// <summary>
+ /// The input type.
+ /// </summary>
+ public enum InputType
+ {
+ [Display(Name = "File")]
+ Stream,
+
+ [Display(Name = "DVD")]
+ Dvd,
+
+ [Display(Name = "Blu-ray")]
+ Bluray
+ }
+}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/Subtitle.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/Subtitle.cs
new file mode 100644
index 000000000..fda0dbb6c
--- /dev/null
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/Subtitle.cs
@@ -0,0 +1,101 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="Subtitle.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>
+// An object that represents a subtitle associated with a Title, in a DVD
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.Interop.Model.Scan
+{
+ using HandBrake.Interop.HbLib;
+
+ /// <summary>
+ /// An object that represents a subtitle associated with a Title, in a DVD
+ /// </summary>
+ public class Subtitle
+ {
+ /// <summary>
+ /// Gets or sets the track number of this Subtitle
+ /// </summary>
+ public int TrackNumber { get; set; }
+
+ /// <summary>
+ /// Gets or sets the language (if detected) of this Subtitle
+ /// </summary>
+ public string Language { get; set; }
+
+ /// <summary>
+ /// Gets or sets the Langauage Code.
+ /// </summary>
+ public string LanguageCode { get; set; }
+
+ /// <summary>
+ /// Gets or sets the subtitle type.
+ /// </summary>
+ public SubtitleType SubtitleType { get; set; }
+
+ /// <summary>
+ /// Gets or sets the subtitle source.
+ /// </summary>
+ public SubtitleSource SubtitleSource { get; set; }
+
+ /// <summary>
+ /// Gets or sets the subtitle source raw integer.
+ /// </summary>
+ public int SubtitleSourceInt { get; set; }
+
+ /// <summary>
+ /// Gets a value indicating whether the "forced only" flag can be set on this subtitle.
+ /// </summary>
+ public bool CanSetForcedOnly
+ {
+ get
+ {
+ return HBFunctions.hb_subtitle_can_force(this.SubtitleSourceInt) > 0;
+ }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether this subtitle can be burned into the picture.
+ /// </summary>
+ public bool CanBurn
+ {
+ get
+ {
+ return HBFunctions.hb_subtitle_can_burn(this.SubtitleSourceInt) > 0;
+ }
+ }
+
+ /// <summary>
+ /// Returns true if the subtitle can be passed through using the given muxer.
+ /// </summary>
+ /// <param name="muxer">The muxer ID.</param>
+ /// <returns>True if the subtitle can be passed through.</returns>
+ public bool CanPass(int muxer)
+ {
+ return HBFunctions.hb_subtitle_can_pass(this.SubtitleSourceInt, muxer) > 0;
+ }
+
+ /// <summary>
+ /// Override of the ToString method to make this object easier to use in the UI
+ /// </summary>
+ /// <returns>A string formatted as: {track #} {language}</returns>
+ public override string ToString()
+ {
+ return string.Format("{0} {1} ({2})", this.TrackNumber, this.Language, this.SubtitleSource);
+ }
+
+ /// <summary>
+ /// Gets the display.
+ /// </summary>
+ public string Display
+ {
+ get
+ {
+ return this.ToString();
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/SubtitleSource.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/SubtitleSource.cs
new file mode 100644
index 000000000..517025934
--- /dev/null
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/SubtitleSource.cs
@@ -0,0 +1,26 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="SubtitleSource.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>
+// Defines the SubtitleSource type.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.Interop.Model.Scan
+{
+ /// <summary>
+ /// The subtitle source.
+ /// </summary>
+ public enum SubtitleSource
+ {
+ VobSub,
+ SRT,
+ CC608,
+ CC708,
+ UTF8,
+ TX3G,
+ SSA,
+ PGS
+ }
+}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/SubtitleType.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/SubtitleType.cs
new file mode 100644
index 000000000..4486e029d
--- /dev/null
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/SubtitleType.cs
@@ -0,0 +1,20 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="SubtitleType.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>
+// Defines the SubtitleType type.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.Interop.Model.Scan
+{
+ /// <summary>
+ /// The subtitle type.
+ /// </summary>
+ public enum SubtitleType
+ {
+ Picture,
+ Text
+ }
+}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/Title.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/Title.cs
new file mode 100644
index 000000000..fb2a67b64
--- /dev/null
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/Title.cs
@@ -0,0 +1,189 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="Title.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>
+// An object that represents a single Title of a DVD
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.Interop.Model.Scan
+{
+ using System;
+ using System.Collections.Generic;
+
+ using HandBrake.Interop.Model;
+
+ /// <summary>
+ /// An object that represents a single Title of a DVD
+ /// </summary>
+ public class Title
+ {
+ /// <summary>
+ /// The audio tracks.
+ /// </summary>
+ private readonly List<AudioTrack> audioTracks;
+
+ /// <summary>
+ /// The chapters.
+ /// </summary>
+ private readonly List<Chapter> chapters;
+
+ /// <summary>
+ /// The subtitles.
+ /// </summary>
+ private readonly List<Subtitle> subtitles;
+
+ /// <summary>
+ /// Initializes a new instance of the Title class.
+ /// </summary>
+ public Title()
+ {
+ this.audioTracks = new List<AudioTrack>();
+ this.chapters = new List<Chapter>();
+ this.subtitles = new List<Subtitle>();
+ }
+
+ /// <summary>
+ /// Gets or sets the input type of this title.
+ /// </summary>
+ public InputType InputType { get; set; }
+
+ /// <summary>
+ /// Gets a collection of chapters in this Title
+ /// </summary>
+ public List<Chapter> Chapters
+ {
+ get { return this.chapters; }
+ }
+
+ /// <summary>
+ /// Gets a collection of audio tracks associated with this Title
+ /// </summary>
+ public List<AudioTrack> AudioTracks
+ {
+ get { return this.audioTracks; }
+ }
+
+ /// <summary>
+ /// Gets a collection of subtitles associated with this Title
+ /// </summary>
+ public List<Subtitle> Subtitles
+ {
+ get { return this.subtitles; }
+ }
+
+ /// <summary>
+ /// Gets or sets the track number of this Title (1-based).
+ /// </summary>
+ public int TitleNumber { get; set; }
+
+ /// <summary>
+ /// Gets or sets the playlist number this title came from.
+ /// </summary>
+ public int Playlist { get; set; }
+
+ /// <summary>
+ /// Gets or sets the duration of this title.
+ /// </summary>
+ public TimeSpan Duration { get; set; }
+
+ /// <summary>
+ /// Gets or sets the duration of the title in PTS.
+ /// </summary>
+ public ulong DurationPts { get; set; }
+
+ /// <summary>
+ /// Gets or sets the resolution (width/height) of this Title
+ /// </summary>
+ public Size Resolution { get; set; }
+
+ /// <summary>
+ /// Gets or sets the aspect ratio of this Title
+ /// </summary>
+ public decimal AspectRatio { get; set; }
+
+ /// <summary>
+ /// Gets or sets the number of angles on the title.
+ /// </summary>
+ public int AngleCount { get; set; }
+
+ /// <summary>
+ /// Gets or sets the pixel aspect ratio.
+ /// </summary>
+ public Size ParVal { get; set; }
+
+ /// <summary>
+ /// Gets or sets the automatically detected crop region for this Title.
+ /// </summary>
+ public Cropping AutoCropDimensions { get; set; }
+
+ /// <summary>
+ /// Gets or sets the name of the video codec for this title.
+ /// </summary>
+ public string VideoCodecName { get; set; }
+
+ /// <summary>
+ /// Gets or sets the video frame rate for this title.
+ /// </summary>
+ public double Framerate { get; set; }
+
+ /// <summary>
+ /// Gets or sets the video frame rate numerator.
+ /// </summary>
+ public int FramerateNumerator { get; set; }
+
+ /// <summary>
+ /// Gets or sets the video frame rate denominator.
+ /// </summary>
+ public int FramerateDenominator { get; set; }
+
+ /// <summary>
+ /// Gets the total number of frames in this title.
+ /// </summary>
+ public int Frames
+ {
+ get
+ {
+ return (int)Math.Ceiling(this.Duration.TotalSeconds * this.Framerate);
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the path.
+ /// </summary>
+ public string Path { get; set; }
+
+ /// <summary>
+ /// Override of the ToString method to provide an easy way to use this object in the UI
+ /// </summary>
+ /// <returns>A string representing this track in the format: {title #}[ {playlist source}] (00:00:00)</returns>
+ 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);
+ }
+
+ /// <summary>
+ /// Gets the display string for this title.
+ /// </summary>
+ public string Display
+ {
+ get
+ {
+ return this.ToString();
+ }
+ }
+ }
+} \ No newline at end of file