From ed414885c5411dc7f298700d0c5061385024c503 Mon Sep 17 00:00:00 2001 From: sr55 Date: Fri, 26 Dec 2014 20:58:55 +0000 Subject: WinGui: Adding the JSON models and factories for Encoding and Anamorphic calculation. (Not in use yet) git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6652 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../HandBrakeInterop/Helpers/Validate.cs | 39 ++ .../Json/Anamorphic/AnamorphicGeometry.cs | 27 ++ .../Json/Anamorphic/AnamorphicResult.cs | 32 ++ .../Json/Anamorphic/DestSettings.cs | 64 +++ .../HandBrakeInterop/Json/Anamorphic/Geometry.cs | 33 ++ .../HandBrakeInterop/Json/Anamorphic/PAR.cs | 27 ++ .../Json/Anamorphic/SourceGeometry.cs | 37 ++ .../HandBrakeInterop/Json/Encode/Audio.cs | 34 ++ .../HandBrakeInterop/Json/Encode/AudioList.cs | 72 +++ .../HandBrakeInterop/Json/Encode/ChapterList.cs | 22 + .../HandBrakeInterop/Json/Encode/Destination.cs | 44 ++ .../HandBrakeInterop/Json/Encode/Filter.cs | 29 ++ .../HandBrakeInterop/Json/Encode/FilterList.cs | 27 ++ .../Json/Encode/JsonEncodeObject.cs | 64 +++ .../HandBrakeInterop/Json/Encode/MetaData.cs | 62 +++ .../HandBrakeInterop/Json/Encode/Mp4Options.cs | 27 ++ .../HandBrakeInterop/Json/Encode/Range.cs | 52 +++ .../HandBrakeInterop/Json/Encode/SRT.cs | 32 ++ .../HandBrakeInterop/Json/Encode/Search.cs | 37 ++ .../HandBrakeInterop/Json/Encode/Source.cs | 32 ++ .../HandBrakeInterop/Json/Encode/Subtitle.cs | 29 ++ .../HandBrakeInterop/Json/Encode/SubtitleList.cs | 52 +++ .../HandBrakeInterop/Json/Encode/Video.cs | 72 +++ .../Json/Factories/EncodeFactory.cs | 517 +++++++++++++++++++++ 24 files changed, 1463 insertions(+) create mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/Helpers/Validate.cs create mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/AnamorphicGeometry.cs create mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/AnamorphicResult.cs create mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/DestSettings.cs create mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/Geometry.cs create mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/PAR.cs create mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/SourceGeometry.cs create mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Audio.cs create mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/AudioList.cs create mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/ChapterList.cs create mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Destination.cs create mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Filter.cs create mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/FilterList.cs create mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/JsonEncodeObject.cs create mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/MetaData.cs create mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Mp4Options.cs create mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Range.cs create mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/SRT.cs create mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Search.cs create mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Source.cs create mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Subtitle.cs create mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/SubtitleList.cs create mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Video.cs create mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/EncodeFactory.cs (limited to 'win/CS/HandBrake.Interop') diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Helpers/Validate.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Helpers/Validate.cs new file mode 100644 index 000000000..d3c7d8136 --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Helpers/Validate.cs @@ -0,0 +1,39 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The validate. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Helpers +{ + using System; + + /// + /// The validate. + /// + public class Validate + { + /// + /// The not null. + /// + /// + /// The item. + /// + /// + /// The message. + /// + /// + /// Thrown when the input object is null + /// + public static void NotNull(object item, string message) + { + if (item == null) + { + throw new ArgumentException(message); + } + } + } +} diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/AnamorphicGeometry.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/AnamorphicGeometry.cs new file mode 100644 index 000000000..684eac686 --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/AnamorphicGeometry.cs @@ -0,0 +1,27 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The geometry. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Json.Anamorphic +{ + /// + /// The geometry. + /// + internal class AnamorphicGeometry + { + /// + /// Gets or sets the dest geometry. + /// + public DestSettings DestGeometry { get; set; } + + /// + /// Gets or sets the source geometry. + /// + public SourceGeometry SourceGeometry { get; set; } + } +} \ No newline at end of file diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/AnamorphicResult.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/AnamorphicResult.cs new file mode 100644 index 000000000..42e955443 --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/AnamorphicResult.cs @@ -0,0 +1,32 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The anamorphic result. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Json.Anamorphic +{ + /// + /// The anamorphic result. + /// + internal class AnamorphicResult + { + /// + /// Gets or sets the height. + /// + public int Height { get; set; } + + /// + /// Gets or sets the par. + /// + public PAR PAR { get; set; } + + /// + /// Gets or sets the width. + /// + public int Width { get; set; } + } +} \ No newline at end of file diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/DestSettings.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/DestSettings.cs new file mode 100644 index 000000000..1f4f95542 --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/DestSettings.cs @@ -0,0 +1,64 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The dest geometry. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Json.Anamorphic +{ + using System.Collections.Generic; + + /// + /// The dest geometry. + /// + internal class DestSettings + { + public DestSettings() + { + this.Geometry = new Geometry(); + } + + /// + /// Gets or sets the anamorphic mode. + /// + public int AnamorphicMode { get; set; } + + /// + /// Gets or sets the crop. + /// + public List Crop { get; set; } + + /// + /// Gets or sets the Geometry + /// + public Geometry Geometry { get; set; } + + /// + /// Gets or sets a value indicating whether itu par. + /// + public bool ItuPAR { get; set; } + + /// + /// Gets or sets a value indicating whether keep display aspect. + /// + public bool Keep { get; set; } + + /// + /// Gets or sets the max height. + /// + public int MaxHeight { get; set; } + + /// + /// Gets or sets the max width. + /// + public int MaxWidth { get; set; } + + /// + /// Gets or sets the modulus. + /// + public int Modulus { get; set; } + } +} \ No newline at end of file diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/Geometry.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/Geometry.cs new file mode 100644 index 000000000..add6bc562 --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/Geometry.cs @@ -0,0 +1,33 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The geometry. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Json.Anamorphic +{ + + /// + /// The geometry. + /// + public class Geometry + { + /// + /// Gets or sets the height. + /// + public int Height { get; set; } + + /// + /// Gets or sets the par. + /// + public PAR PAR { get; set; } + + /// + /// Gets or sets the width. + /// + public int Width { get; set; } + } +} \ No newline at end of file diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/PAR.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/PAR.cs new file mode 100644 index 000000000..84680dee6 --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/PAR.cs @@ -0,0 +1,27 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The par. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Json.Anamorphic +{ + /// + /// The par. + /// + public class PAR + { + /// + /// Gets or sets the Number. + /// + public int Num { get; set; } + + /// + /// Gets or sets the Denominator. + /// + public int Den { get; set; } + } +} \ No newline at end of file diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/SourceGeometry.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/SourceGeometry.cs new file mode 100644 index 000000000..983e9f5f8 --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/SourceGeometry.cs @@ -0,0 +1,37 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The source geometry. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Json.Anamorphic +{ + /// + /// The source geometry. + /// + internal class SourceGeometry + { + public SourceGeometry() + { + this.PAR = new PAR(); + } + + /// + /// Gets or sets the height. + /// + public int Height { get; set; } + + /// + /// Gets or sets the par. + /// + public PAR PAR { get; set; } + + /// + /// Gets or sets the width. + /// + public int Width { get; set; } + } +} \ No newline at end of file diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Audio.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Audio.cs new file mode 100644 index 000000000..1f683785f --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Audio.cs @@ -0,0 +1,34 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The audio. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Json.Encode +{ + using System.Collections.Generic; + + /// + /// The audio. + /// + public class Audio + { + /// + /// Gets or sets the audio list. + /// + public List AudioList { get; set; } + + /// + /// Gets or sets the copy mask. + /// + public int CopyMask { get; set; } + + /// + /// Gets or sets the fallback encoder. + /// + public int FallbackEncoder { get; set; } + } +} \ No newline at end of file diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/AudioList.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/AudioList.cs new file mode 100644 index 000000000..8227c2777 --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/AudioList.cs @@ -0,0 +1,72 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The audio list. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Json.Encode +{ + /// + /// The audio list. + /// + public class AudioList + { + /// + /// Gets or sets the bitrate. + /// + public int Bitrate { get; set; } + + /// + /// Gets or sets the compression level. + /// + public double CompressionLevel { get; set; } + + /// + /// Gets or sets the drc. + /// + public double DRC { get; set; } + + /// + /// Gets or sets the encoder. + /// + public int Encoder { get; set; } + + /// + /// Gets or sets the gain. + /// + public double Gain { get; set; } + + /// + /// Gets or sets the mixdown. + /// + public int Mixdown { get; set; } + + /// + /// Gets or sets a value indicating whether normalize mix level. + /// + public bool NormalizeMixLevel { get; set; } + + /// + /// Gets or sets the quality. + /// + public double Quality { get; set; } + + /// + /// Gets or sets the samplerate. + /// + public int Samplerate { get; set; } + + /// + /// Gets or sets the Name of the audio track. + /// + public string Name { get; set; } + + /// + /// Gets or sets the track. + /// + public int Track { get; set; } + } +} \ No newline at end of file diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/ChapterList.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/ChapterList.cs new file mode 100644 index 000000000..abdb570e0 --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/ChapterList.cs @@ -0,0 +1,22 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The chapter list. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Json.Encode +{ + /// + /// The chapter list. + /// + public class ChapterList + { + /// + /// Gets or sets the name. + /// + public string Name { get; set; } + } +} \ No newline at end of file diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Destination.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Destination.cs new file mode 100644 index 000000000..6eb9e0a90 --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Destination.cs @@ -0,0 +1,44 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The destination. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Json.Encode +{ + using System.Collections.Generic; + + /// + /// The destination. + /// + public class Destination + { + /// + /// Gets or sets the chapter list. + /// + public List ChapterList { get; set; } + + /// + /// Gets or sets a value indicating whether chapter markers. + /// + public bool ChapterMarkers { get; set; } + + /// + /// Gets or sets the file. + /// + public string File { get; set; } + + /// + /// Gets or sets the mp 4 options. + /// + public Mp4Options Mp4Options { get; set; } + + /// + /// Gets or sets the mux. + /// + public int Mux { get; set; } + } +} \ No newline at end of file diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Filter.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Filter.cs new file mode 100644 index 000000000..a5097f477 --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Filter.cs @@ -0,0 +1,29 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The filter. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Json.Encode +{ + using System.Collections.Generic; + + /// + /// The filter. + /// + public class Filter + { + /// + /// Gets or sets the filter list. + /// + public List FilterList { get; set; } + + /// + /// Gets or sets a value indicating whether grayscale. + /// + public bool Grayscale { get; set; } + } +} \ No newline at end of file diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/FilterList.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/FilterList.cs new file mode 100644 index 000000000..4a9bc97f4 --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/FilterList.cs @@ -0,0 +1,27 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The filter list. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Json.Encode +{ + /// + /// The filter list. + /// + public class FilterList + { + /// + /// Gets or sets the id. + /// + public int ID { get; set; } + + /// + /// Gets or sets the settings. + /// + public string Settings { get; set; } + } +} \ No newline at end of file diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/JsonEncodeObject.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/JsonEncodeObject.cs new file mode 100644 index 000000000..c5e6c6aa1 --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/JsonEncodeObject.cs @@ -0,0 +1,64 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The root object. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Json.Encode +{ + using HandBrake.Interop.Json.Anamorphic; + + /// + /// The root object. + /// + public class JsonEncodeObject + { + /// + /// Gets or sets the audio. + /// + public Audio Audio { get; set; } + + /// + /// Gets or sets the destination. + /// + public Destination Destination { get; set; } + + /// + /// Gets or sets the filter. + /// + public Filter Filter { get; set; } + + /// + /// Gets or sets the PAR + /// + public PAR PAR { get; set; } + + /// + /// Gets or sets the meta data. + /// + public MetaData MetaData { get; set; } + + /// + /// Gets or sets the sequence id. + /// + public int SequenceID { get; set; } + + /// + /// Gets or sets the source. + /// + public Source Source { get; set; } + + /// + /// Gets or sets the subtitle. + /// + public Subtitle Subtitle { get; set; } + + /// + /// Gets or sets the video. + /// + public Video Video { get; set; } + } +} \ No newline at end of file diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/MetaData.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/MetaData.cs new file mode 100644 index 000000000..0343c9128 --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/MetaData.cs @@ -0,0 +1,62 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The meta data. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Json.Encode +{ + /// + /// The meta data. + /// + public class MetaData + { + /// + /// Gets or sets the album artist. + /// + public string AlbumArtist { get; set; } + + /// + /// Gets or sets the artist. + /// + public string Artist { get; set; } + + /// + /// Gets or sets the comment. + /// + public string Comment { get; set; } + + /// + /// Gets or sets the composer. + /// + public string Composer { get; set; } + + /// + /// Gets or sets the description. + /// + public string Description { get; set; } + + /// + /// Gets or sets the genre. + /// + public string Genre { get; set; } + + /// + /// Gets or sets the long description. + /// + public string LongDescription { get; set; } + + /// + /// Gets or sets the name. + /// + public string Name { get; set; } + + /// + /// Gets or sets the release date. + /// + public string ReleaseDate { get; set; } + } +} \ No newline at end of file diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Mp4Options.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Mp4Options.cs new file mode 100644 index 000000000..e8b10c4c7 --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Mp4Options.cs @@ -0,0 +1,27 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The mp 4 options. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Json.Encode +{ + /// + /// The mp 4 options. + /// + public class Mp4Options + { + /// + /// Gets or sets a value indicating whether ipod atom. + /// + public bool IpodAtom { get; set; } + + /// + /// Gets or sets a value indicating whether mp 4 optimize. + /// + public bool Mp4Optimize { get; set; } + } +} \ No newline at end of file diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Range.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Range.cs new file mode 100644 index 000000000..2d9a45ee1 --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Range.cs @@ -0,0 +1,52 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The range. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Json.Encode +{ + /// + /// The range. + /// + public class Range + { + /// + /// Gets or sets the chapter end. + /// + public int ChapterEnd { get; set; } + + /// + /// Gets or sets the chapter start. + /// + public int ChapterStart { get; set; } + + /// + /// Gets or sets the frame to start. + /// + public int FrameToStart { get; set; } + + /// + /// Gets or sets the frame to stop. + /// + public int FrameToStop { get; set; } + + /// + /// Gets or sets the pts to start. + /// + public int PtsToStart { get; set; } + + /// + /// Gets or sets the pts to stop. + /// + public int PtsToStop { get; set; } + + /// + /// Gets or sets the start at preview. + /// + public int StartAtPreview { get; set; } + } +} \ No newline at end of file diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/SRT.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/SRT.cs new file mode 100644 index 000000000..b7c8f17b2 --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/SRT.cs @@ -0,0 +1,32 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The srt. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Json.Encode +{ + /// + /// The srt. + /// + public class SRT + { + /// + /// Gets or sets the codeset. + /// + public string Codeset { get; set; } + + /// + /// Gets or sets the filename. + /// + public string Filename { get; set; } + + /// + /// Gets or sets the language. + /// + public string Language { get; set; } + } +} \ No newline at end of file diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Search.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Search.cs new file mode 100644 index 000000000..413b8677a --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Search.cs @@ -0,0 +1,37 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The search. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Json.Encode +{ + /// + /// The search. + /// + public class Search + { + /// + /// Gets or sets a value indicating whether burn. + /// + public bool Burn { get; set; } + + /// + /// Gets or sets a value indicating whether default. + /// + public bool Default { get; set; } + + /// + /// Gets or sets a value indicating whether enable. + /// + public bool Enable { get; set; } + + /// + /// Gets or sets a value indicating whether forced. + /// + public bool Forced { get; set; } + } +} \ No newline at end of file diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Source.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Source.cs new file mode 100644 index 000000000..f006d2ba0 --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Source.cs @@ -0,0 +1,32 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The source. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Json.Encode +{ + /// + /// The source. + /// + public class Source + { + /// + /// Gets or sets the angle. + /// + public int Angle { get; set; } + + /// + /// Gets or sets the range. + /// + public Range Range { get; set; } + + /// + /// Gets or sets the title. + /// + public int Title { get; set; } + } +} \ No newline at end of file diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Subtitle.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Subtitle.cs new file mode 100644 index 000000000..c20ab8fb2 --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Subtitle.cs @@ -0,0 +1,29 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The subtitle. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Json.Encode +{ + using System.Collections.Generic; + + /// + /// The subtitle. + /// + public class Subtitle + { + /// + /// Gets or sets the search. + /// + public Search Search { get; set; } + + /// + /// Gets or sets the subtitle list. + /// + public List SubtitleList { get; set; } + } +} \ No newline at end of file diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/SubtitleList.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/SubtitleList.cs new file mode 100644 index 000000000..54ce5e902 --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/SubtitleList.cs @@ -0,0 +1,52 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The subtitle list. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Json.Encode +{ + /// + /// The subtitle list. + /// + public class SubtitleList + { + /// + /// Gets or sets a value indicating whether burn. + /// + public bool Burn { get; set; } + + /// + /// Gets or sets a value indicating whether default. + /// + public bool Default { get; set; } + + /// + /// Gets or sets a value indicating whether force. + /// + public bool Force { get; set; } + + /// + /// Gets or sets the id. + /// + public int ID { get; set; } + + /// + /// Gets or sets the offset. + /// + public int Offset { get; set; } + + /// + /// Gets or sets the track. + /// + public int Track { get; set; } + + /// + /// Gets or sets the srt. + /// + public SRT SRT { get; set; } + } +} \ No newline at end of file diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Video.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Video.cs new file mode 100644 index 000000000..a92253d7b --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Video.cs @@ -0,0 +1,72 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The video. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Json.Encode +{ + /// + /// The video. + /// + public class Video + { + /// + /// Gets or sets the codec. + /// + public int Codec { get; set; } + + /// + /// Gets or sets the level. + /// + public string Level { get; set; } + + /// + /// Gets or sets the bitrate for the encode. + /// + public int Bitrate { get; set; } + + /// + /// Gets or sets the number of passes + /// + public int pass { get; set; } + + /// + /// Gets or sets Turbo First Pass. For x264/5 + /// + public bool Turbo { get; set; } + + /// + /// Gets or sets the Colour Matrix Code + /// + public int ColorMatrixCode { get; set; } + + /// + /// Gets or sets the options. + /// + public string Options { get; set; } + + /// + /// Gets or sets the preset. + /// + public string Preset { get; set; } + + /// + /// Gets or sets the profile. + /// + public string Profile { get; set; } + + /// + /// Gets or sets the quality. + /// + public double Quality { get; set; } + + /// + /// Gets or sets the tune. + /// + public string Tune { get; set; } + } +} \ No newline at end of file diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/EncodeFactory.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/EncodeFactory.cs new file mode 100644 index 000000000..17013ae5b --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/EncodeFactory.cs @@ -0,0 +1,517 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The encode factory. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Json.Factories +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Runtime.InteropServices; + + using HandBrake.Interop.HbLib; + using HandBrake.Interop.Helpers; + using HandBrake.Interop.Json.Anamorphic; + using HandBrake.Interop.Json.Encode; + using HandBrake.Interop.Json.Scan; + using HandBrake.Interop.Model; + using HandBrake.Interop.Model.Encoding; + + using Newtonsoft.Json; + + using AudioList = HandBrake.Interop.Json.Encode.AudioList; + using ChapterList = HandBrake.Interop.Json.Encode.ChapterList; + using MetaData = HandBrake.Interop.Json.Encode.MetaData; + using PAR = HandBrake.Interop.Json.Anamorphic.PAR; + using SubtitleList = HandBrake.Interop.Json.Encode.SubtitleList; + + /// + /// This factory takes the internal EncodeJob object and turns it into a set of JSON models + /// that can be deserialized by libhb. + /// + internal class EncodeFactory + { + + /* + * maxWidth and maxHeight are frontend issues. You pass those into hb_set_anamorphic_size when calculating geometry settings. width and height are given to the CROP_SCALE filter. No need for the frontend to set it in the job. The job will get the final dimensions from the filter settings anyway. + * for example, both crop_scale and rotate filters modify job width and height settings + * + */ + + /// + /// The create. + /// + /// + /// The encode job. + /// + /// + /// The . + /// + internal static JsonEncodeObject Create(EncodeJob job, JsonScanObject scannedSource) + { + JsonEncodeObject encode = new JsonEncodeObject + { + SequenceID = 0, + Audio = CreateAudio(job), + Destination = CreateDestination(job), + Filter = CreateFilter(job), + PAR = CreatePAR(job), + MetaData = CreateMetaData(job), + Source = CreateSource(job), + Subtitle = CreateSubtitle(job), + Video = CreateVideo(job) + }; + + return encode; + } + + /// + /// The create source. + /// + /// + /// The job. + /// + /// + /// The . + /// + private static Source CreateSource(EncodeJob job) + { + Source source = new Source + { + Title = job.Title, + Range = + new Range + { + ChapterEnd = job.ChapterEnd, + ChapterStart = job.ChapterStart, + FrameToStart = job.FramesStart, + FrameToStop = job.FramesEnd, + PtsToStart = (int)(job.SecondsStart * 90000), + PtsToStop = (int)((job.SecondsEnd - job.SecondsStart) * 90000), + }, + Angle = job.Angle + }; + return source; + } + + /// + /// The create destination. + /// + /// + /// The job. + /// + /// + /// The . + /// + private static Destination CreateDestination(EncodeJob job) + { + Destination destination = new Destination + { + File = job.OutputPath, + Mp4Options = + new Mp4Options + { + IpodAtom = job.EncodingProfile.IPod5GSupport, + // LargeFileSize = job.EncodingProfile.LargeFile, + Mp4Optimize = job.EncodingProfile.Optimize + }, + ChapterMarkers = job.EncodingProfile.IncludeChapterMarkers, + Mux = HBFunctions.hb_container_get_from_name(job.EncodingProfile.ContainerName), + ChapterList = new List() + }; + + foreach (string item in job.CustomChapterNames) + { + ChapterList chapter = new ChapterList { Name = item }; + destination.ChapterList.Add(chapter); + } + + return destination; + } + + /// + /// Create the PAR object + /// + /// The Job + /// The produced PAR object. + private static PAR CreatePAR(EncodeJob job) + { + return new PAR {Num = job.EncodingProfile.PixelAspectX, Den = job.EncodingProfile.PixelAspectY} ; + } + + /// + /// The create subtitle. + /// + /// + /// The job. + /// + /// + /// The . + /// + private static Subtitle CreateSubtitle(EncodeJob job) + { + Subtitle subtitle = new Subtitle + { + Search = + new Search + { + Enable = false, + Default = false, + Burn = false, + Forced = false + }, + SubtitleList = new List() + }; + + foreach (SourceSubtitle item in job.Subtitles.SourceSubtitles) + { + SubtitleList track = new SubtitleList + { + Burn = item.BurnedIn, + Default = item.Default, + Force = item.Forced, + ID = item.TrackNumber, + Track = item.TrackNumber + }; + + subtitle.SubtitleList.Add(track); + } + + foreach (SrtSubtitle item in job.Subtitles.SrtSubtitles) + { + SubtitleList track = new SubtitleList + { + Default = item.Default, + Offset = item.Offset, + SRT = + new SRT + { + Filename = item.FileName, + Codeset = item.CharacterCode, + Language = item.LanguageCode + } + }; + + subtitle.SubtitleList.Add(track); + } + + return subtitle; + } + + /// + /// The create video. + /// + /// + /// The job. + /// + /// + /// The . + /// + private static Video CreateVideo(EncodeJob job) + { + Video video = new Video(); + + HBVideoEncoder videoEncoder = Encoders.VideoEncoders.FirstOrDefault(e => e.ShortName == job.EncodingProfile.VideoEncoder); + Validate.NotNull(videoEncoder, "Video encoder " + job.EncodingProfile.VideoEncoder + " not recognized."); + if (videoEncoder != null) + { + video.Codec = videoEncoder.Id; + } + + video.Level = job.EncodingProfile.VideoLevel; + video.Options = job.EncodingProfile.VideoOptions; + video.Preset = job.EncodingProfile.VideoPreset; + video.Profile = job.EncodingProfile.VideoProfile; + video.Quality = job.EncodingProfile.Quality; + if (job.EncodingProfile.VideoTunes != null && job.EncodingProfile.VideoTunes.Count > 0) + { + video.Tune = string.Join(",", job.EncodingProfile.VideoTunes); + } + + return video; + } + + /// + /// The create audio. + /// + /// + /// The job. + /// + /// + /// The . + /// + private static Audio CreateAudio(EncodeJob job) + { + Audio audio = new Audio(); + + if (!string.IsNullOrEmpty(job.EncodingProfile.AudioEncoderFallback)) + { + HBAudioEncoder audioEncoder = Encoders.GetAudioEncoder(job.EncodingProfile.AudioEncoderFallback); + Validate.NotNull(audioEncoder, "Unrecognized fallback audio encoder: " + job.EncodingProfile.AudioEncoderFallback); + audio.FallbackEncoder = audioEncoder.Id; + } + + audio.CopyMask = (int)NativeConstants.HB_ACODEC_ANY; + + audio.AudioList = new List(); + int numTracks = 0; + foreach (AudioEncoding item in job.EncodingProfile.AudioEncodings) + { + HBAudioEncoder encoder = Encoders.GetAudioEncoder(item.Encoder); + Validate.NotNull(encoder, "Unrecognized audio encoder:" + item.Encoder); + + HBMixdown mixdown = Encoders.GetMixdown(item.Mixdown); + Validate.NotNull(mixdown, "Unrecognized audio mixdown:" + item.Mixdown); + + AudioList audioTrack = new AudioList + { + Track = numTracks++, + Bitrate = item.Bitrate, + CompressionLevel = item.Compression, + DRC = item.Drc, + Encoder = encoder.Id, + Gain = item.Gain, + Mixdown = mixdown.Id, + NormalizeMixLevel = false, + Quality = item.Quality, + Samplerate = item.SampleRateRaw + }; + + audio.AudioList.Add(audioTrack); + } + + return audio; + } + + /// + /// The create filter. TODO + /// + /// + /// The job. + /// + /// + /// The . + /// + private static Filter CreateFilter(EncodeJob job) + { + Filter filter = new Filter + { + FilterList = new List(), + Grayscale = job.EncodingProfile.Grayscale + }; + + // Detelecine + if (job.EncodingProfile.Detelecine != Detelecine.Off) + { + FilterList filterItem = new FilterList { ID = (int)hb_filter_ids.HB_FILTER_DETELECINE, Settings = job.EncodingProfile.CustomDetelecine }; + filter.FilterList.Add(filterItem); + } + + // Decomb + if (job.EncodingProfile.Decomb != Decomb.Off) + { + string options = ""; + if (job.EncodingProfile.Decomb == Decomb.Fast) + { + options = "7:2:6:9:1:80"; + } + else if (job.EncodingProfile.Decomb == Decomb.Bob) + { + options = "455"; + } + else + { + options = job.EncodingProfile.CustomDecomb; + } + + FilterList filterItem = new FilterList { ID = (int)hb_filter_ids.HB_FILTER_DECOMB, Settings = options }; + filter.FilterList.Add(filterItem); + } + + // Deinterlace + if (job.EncodingProfile.Deinterlace != Deinterlace.Off) + { + string options = string.Empty; + if (job.EncodingProfile.Deinterlace == Deinterlace.Fast) + { + options = "0"; + } + else if (job.EncodingProfile.Deinterlace == Deinterlace.Slow) + { + options = "1"; + } + else if (job.EncodingProfile.Deinterlace == Deinterlace.Slower) + { + options = "3"; + } + else if (job.EncodingProfile.Deinterlace == Deinterlace.Bob) + { + options = "15"; + } + else + { + options = job.EncodingProfile.CustomDeinterlace; + } + + FilterList filterItem = new FilterList { ID = (int)hb_filter_ids.HB_FILTER_DEINTERLACE, Settings = options }; + filter.FilterList.Add(filterItem); + } + + // VFR / CFR TODO + FilterList framerateShaper = new FilterList { ID = (int)hb_filter_ids.HB_FILTER_VFR, Settings = string.Empty }; + filter.FilterList.Add(framerateShaper); + + // Deblock + if (job.EncodingProfile.Deblock < 5) + { + FilterList filterItem = new FilterList { ID = (int)hb_filter_ids.HB_FILTER_DEBLOCK, Settings = job.EncodingProfile.Deblock.ToString() }; + filter.FilterList.Add(filterItem); + } + + // Denoise + if (job.EncodingProfile.Denoise != Denoise.Off) + { + hb_filter_ids id = job.EncodingProfile.Denoise == Denoise.hqdn3d + ? hb_filter_ids.HB_FILTER_HQDN3D + : hb_filter_ids.HB_FILTER_NLMEANS; + + string settings; + if (job.EncodingProfile.Denoise == Denoise.hqdn3d + && !string.IsNullOrEmpty(job.EncodingProfile.CustomDenoise)) + { + settings = job.EncodingProfile.CustomDenoise; + } + else + { + IntPtr settingsPtr = HBFunctions.hb_generate_filter_settings((int)id, job.EncodingProfile.DenoisePreset, job.EncodingProfile.DenoiseTune); + settings = Marshal.PtrToStringAnsi(settingsPtr); + } + + FilterList filterItem = new FilterList { ID = (int)id, Settings = settings }; + filter.FilterList.Add(filterItem); + } + + // CropScale Filter + FilterList cropScale = new FilterList + { + ID = (int)hb_filter_ids.HB_FILTER_CROP_SCALE, + Settings = + string.Format( + "{0}:{1}:{2}:{3}:{4}:{5}", + job.EncodingProfile.Width, + job.EncodingProfile.Height, + job.EncodingProfile.Cropping.Top, + job.EncodingProfile.Cropping.Bottom, + job.EncodingProfile.Cropping.Left, + job.EncodingProfile.Cropping.Right) + }; + filter.FilterList.Add(cropScale); + + // Rotate + /* TODO NOT SUPPORTED YET. */ + + return filter; + } + + /// + /// The create geometry. + /// + /// + /// The job. + /// + /// + /// The . + /// + private static Json.Anamorphic.Geometry CreateGeometry(EncodeJob job, JsonScanObject scannedSource) + { + TitleList title = scannedSource.TitleList.FirstOrDefault(c => c.Index == job.Title); + + // Sanatise the Geometry First. + AnamorphicGeometry anamorphicGeometry = new AnamorphicGeometry + { + DestGeometry = new DestSettings(), + SourceGeometry = + new SourceGeometry + { + Width = title.Geometry.Width, + Height = title.Geometry.Height, + PAR = new Json.Anamorphic.PAR { Num = title.Geometry.PAR.Num, Den = title.Geometry.PAR.Den } + } + }; + + anamorphicGeometry.DestGeometry.AnamorphicMode = (int)job.EncodingProfile.Anamorphic; + anamorphicGeometry.DestGeometry.Geometry.Width = job.EncodingProfile.Width; + anamorphicGeometry.DestGeometry.Geometry.Height = job.EncodingProfile.Height; + anamorphicGeometry.DestGeometry.Keep = job.EncodingProfile.KeepDisplayAspect; + anamorphicGeometry.DestGeometry.Geometry.PAR = new Json.Anamorphic.PAR { Num = job.EncodingProfile.PixelAspectX, Den = job.EncodingProfile.PixelAspectY }; + anamorphicGeometry.DestGeometry.Crop = new List { job.EncodingProfile.Cropping.Top, job.EncodingProfile.Cropping.Bottom, job.EncodingProfile.Cropping.Left, job.EncodingProfile.Cropping.Right }; + + string encode = JsonConvert.SerializeObject(anamorphicGeometry, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); + IntPtr json = HBFunctions.hb_set_anamorphic_size_json(Marshal.StringToHGlobalAnsi(encode)); + string statusJson = Marshal.PtrToStringAnsi(json); + AnamorphicResult sanatisedGeometry = JsonConvert.DeserializeObject(statusJson); + + // Setup the Destination Gemotry. + Json.Anamorphic.Geometry geometry = new Json.Anamorphic.Geometry(); + geometry.Width = sanatisedGeometry.Width; + geometry.Height = sanatisedGeometry.Height; + geometry.PAR = sanatisedGeometry.PAR; + return geometry; + } + + /// + /// The create meta data. + /// + /// + /// The job. + /// + /// + /// The . + /// + private static MetaData CreateMetaData(EncodeJob job) + { + MetaData metaData = new MetaData(); + return metaData; + } + + + /// + /// Adds a filter to the given filter list. + /// + /// The list to add the filter to. + /// The type of filter. + /// Settings for the filter. + /// The list of allocated memory. + private void AddFilter(List filterList, int filterType, string settings, List allocatedMemory) + { + IntPtr settingsNativeString = Marshal.StringToHGlobalAnsi(settings); + hb_filter_object_s filter = InteropUtilities.ToStructureFromPtr(HBFunctions.hb_filter_init(filterType)); + filter.settings = settingsNativeString; + + allocatedMemory.Add(settingsNativeString); + filterList.Add(filter); + } + + /// + /// Adds a filter to the given filter list with the provided preset and tune. + /// + /// The list to add the filter to. + /// The type of filter. + /// The preset name. + /// The tune name. + private void AddFilterFromPreset(List filterList, int filterType, string preset, string tune) + { + IntPtr settingsPtr = HBFunctions.hb_generate_filter_settings(filterType, preset, tune); + + hb_filter_object_s filter = InteropUtilities.ToStructureFromPtr(HBFunctions.hb_filter_init(filterType)); + filter.settings = settingsPtr; + + filterList.Add(filter); + } + } +} -- cgit v1.2.3