diff options
author | sr55 <[email protected]> | 2015-04-01 20:08:46 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2015-04-01 20:08:46 +0000 |
commit | 459e06e2e6099a882d0eff225fd36ddce02aab70 (patch) | |
tree | 3dc4e3e8e805012f9b764c777534f01efb8391fd | |
parent | c1fefaee7a3c8d4a35d1224ba19d7a7915e2e075 (diff) |
WinGui: Some initial re-modelling in the JSON folder. Created a "Shared" folder which contains models that are used by anamorphic, encode and scan calls but are not different. Based on a patch by RandomEngy.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7033 b64f7644-9d1e-0410-96f1-a4d463321fa5
18 files changed, 37 insertions, 202 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj index e84331529..6f7ad978c 100644 --- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj +++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj @@ -108,11 +108,8 @@ <Compile Include="Interop\Helpers\Validate.cs" />
<Compile Include="Interop\Interfaces\IHandBrakeInstance.cs" />
<Compile Include="Interop\Json\Anamorphic\AnamorphicGeometry.cs" />
- <Compile Include="Interop\Json\Anamorphic\AnamorphicResult.cs" />
<Compile Include="Interop\Json\Anamorphic\DestSettings.cs" />
- <Compile Include="Interop\Json\Anamorphic\Geometry.cs" />
- <Compile Include="Interop\Json\Anamorphic\PAR.cs" />
- <Compile Include="Interop\Json\Anamorphic\SourceGeometry.cs" />
+ <Compile Include="Interop\Json\Shared\PAR.cs" />
<Compile Include="Interop\Json\Encode\Audio.cs" />
<Compile Include="Interop\Json\Encode\AudioList.cs" />
<Compile Include="Interop\Json\Encode\ChapterList.cs" />
@@ -135,12 +132,10 @@ <Compile Include="Interop\Json\Scan\ChapterList.cs" />
<Compile Include="Interop\Json\Scan\Color.cs" />
<Compile Include="Interop\Json\Scan\Duration.cs" />
- <Compile Include="Interop\Json\Scan\Duration2.cs" />
<Compile Include="Interop\Json\Scan\FrameRate.cs" />
- <Compile Include="Interop\Json\Scan\Geometry.cs" />
+ <Compile Include="Interop\Json\Shared\Geometry.cs" />
<Compile Include="Interop\Json\Scan\JsonScanObject.cs" />
<Compile Include="Interop\Json\Scan\MetaData.cs" />
- <Compile Include="Interop\Json\Scan\PAR.cs" />
<Compile Include="Interop\Json\Scan\SubtitleList.cs" />
<Compile Include="Interop\Json\Scan\TitleList.cs" />
<Compile Include="Interop\Json\State\JsonState.cs" />
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Factories/AnamorphicFactory.cs b/win/CS/HandBrake.ApplicationServices/Interop/Factories/AnamorphicFactory.cs index 2618fc4a8..abaa0fc25 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Factories/AnamorphicFactory.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Factories/AnamorphicFactory.cs @@ -9,18 +9,14 @@ namespace HandBrake.ApplicationServices.Interop.Factories
{
- using System;
using System.Collections.Generic;
- using System.Runtime.InteropServices;
- using HandBrake.ApplicationServices.Interop.HbLib;
using HandBrake.ApplicationServices.Interop.Json.Anamorphic;
+ using HandBrake.ApplicationServices.Interop.Json.Shared;
using HandBrake.ApplicationServices.Interop.Model;
using HandBrake.ApplicationServices.Interop.Model.Encoding;
using HandBrake.ApplicationServices.Services.Encode.Model;
- using Newtonsoft.Json;
-
/// <summary>
/// The anamorphic factory.
/// </summary>
@@ -49,7 +45,7 @@ namespace HandBrake.ApplicationServices.Interop.Factories /// Keep Width or Height. (Not Display Aspect)
/// </param>
/// <returns>
- /// The <see cref="HandBrake.ApplicationServices.Interop.Json.Scan.Geometry"/>.
+ /// The <see cref="Geometry"/>.
/// </returns>
public static Geometry CreateGeometry(EncodeTask job, SourceVideoInfo title, KeepSetting keepWidthOrHeight) // Todo remove the need for these objects. Should use simpler objects.
{
@@ -58,7 +54,7 @@ namespace HandBrake.ApplicationServices.Interop.Factories // Sanatise the Geometry First.
AnamorphicGeometry anamorphicGeometry = new AnamorphicGeometry
{
- SourceGeometry = new SourceGeometry
+ SourceGeometry = new Geometry()
{
Width = title.Resolution.Width,
Height = title.Resolution.Height,
@@ -93,19 +89,7 @@ namespace HandBrake.ApplicationServices.Interop.Factories anamorphicGeometry.DestSettings.Geometry.PAR = new PAR { Num = title.ParVal.Width, Den = title.ParVal.Height };
}
- string encode = JsonConvert.SerializeObject(anamorphicGeometry, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
- IntPtr json = HBFunctions.hb_set_anamorphic_size_json(Marshal.StringToHGlobalAnsi(encode));
- string result = Marshal.PtrToStringAnsi(json);
- AnamorphicResult resultGeometry = JsonConvert.DeserializeObject<AnamorphicResult>(result);
-
- // Setup the Destination Gemotry.
- Geometry geometry = new Geometry
- {
- Width = resultGeometry.Width,
- Height = resultGeometry.Height,
- PAR = resultGeometry.PAR
- };
- return geometry;
+ return HandBrakeUtils.GetAnamorphicSize(anamorphicGeometry);
}
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs index 9c99087f2..dfa33fbd8 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs @@ -28,6 +28,7 @@ namespace HandBrake.ApplicationServices.Interop using HandBrake.ApplicationServices.Interop.Interfaces;
using HandBrake.ApplicationServices.Interop.Json.Encode;
using HandBrake.ApplicationServices.Interop.Json.Scan;
+ using HandBrake.ApplicationServices.Interop.Json.Shared;
using HandBrake.ApplicationServices.Interop.Json.State;
using HandBrake.ApplicationServices.Interop.Model;
using HandBrake.ApplicationServices.Interop.Model.Encoding;
@@ -35,7 +36,6 @@ namespace HandBrake.ApplicationServices.Interop using Newtonsoft.Json;
- using Geometry = HandBrake.ApplicationServices.Interop.Json.Anamorphic.Geometry;
using Size = HandBrake.ApplicationServices.Interop.Model.Size;
/// <summary>
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeUtils.cs b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeUtils.cs index 577fbf0e6..098646ddd 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeUtils.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeUtils.cs @@ -16,6 +16,10 @@ namespace HandBrake.ApplicationServices.Interop using HandBrake.ApplicationServices.Interop.EventArgs;
using HandBrake.ApplicationServices.Interop.HbLib;
+ using HandBrake.ApplicationServices.Interop.Json.Anamorphic;
+ using HandBrake.ApplicationServices.Interop.Json.Shared;
+
+ using Newtonsoft.Json;
/// <summary>
/// HandBrake Interop Utilities
@@ -292,6 +296,19 @@ namespace HandBrake.ApplicationServices.Interop }
/// <summary>
+ /// Gets the final size and PAR of the video, given anamorphic inputs.
+ /// </summary>
+ /// <param name="anamorphicGeometry">Anamorphic inputs.</param>
+ /// <returns>The final size and PAR of the video.</returns>
+ public static Geometry GetAnamorphicSize(AnamorphicGeometry anamorphicGeometry)
+ {
+ string encode = JsonConvert.SerializeObject(anamorphicGeometry, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
+ IntPtr json = HBFunctions.hb_set_anamorphic_size_json(Marshal.StringToHGlobalAnsi(encode));
+ string result = Marshal.PtrToStringAnsi(json);
+ return JsonConvert.DeserializeObject<Geometry>(result);
+ }
+
+ /// <summary>
/// Sends the message logged event to any registered listeners.
/// </summary>
/// <param name="message">
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HbLib/hb_filter_ids.cs b/win/CS/HandBrake.ApplicationServices/Interop/HbLib/hb_filter_ids.cs index 4ae61ad65..6ff3d5bec 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/HbLib/hb_filter_ids.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/HbLib/hb_filter_ids.cs @@ -7,7 +7,7 @@ namespace HandBrake.ApplicationServices.Interop.HbLib
{
- internal enum hb_filter_ids
+ public enum hb_filter_ids
{
HB_FILTER_QSV_PRE = 1, // for QSV - important to have before other filters
// First, filters that may change the framerate (drop or dup frames)
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Anamorphic/AnamorphicGeometry.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Anamorphic/AnamorphicGeometry.cs index fc7319d70..96e257b57 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Anamorphic/AnamorphicGeometry.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Anamorphic/AnamorphicGeometry.cs @@ -9,6 +9,8 @@ namespace HandBrake.ApplicationServices.Interop.Json.Anamorphic
{
+ using HandBrake.ApplicationServices.Interop.Json.Shared;
+
/// <summary>
/// The geometry.
/// </summary>
@@ -22,6 +24,6 @@ namespace HandBrake.ApplicationServices.Interop.Json.Anamorphic /// <summary>
/// Gets or sets the source geometry.
/// </summary>
- public SourceGeometry SourceGeometry { get; set; }
+ public Geometry SourceGeometry { get; set; }
}
}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Anamorphic/AnamorphicResult.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Anamorphic/AnamorphicResult.cs deleted file mode 100644 index d539cb478..000000000 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Anamorphic/AnamorphicResult.cs +++ /dev/null @@ -1,32 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="AnamorphicResult.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>
-// The anamorphic result.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Interop.Json.Anamorphic
-{
- /// <summary>
- /// The anamorphic result.
- /// </summary>
- public class AnamorphicResult
- {
- /// <summary>
- /// Gets or sets the height.
- /// </summary>
- public int Height { get; set; }
-
- /// <summary>
- /// Gets or sets the par.
- /// </summary>
- public PAR PAR { get; set; }
-
- /// <summary>
- /// Gets or sets the width.
- /// </summary>
- public int Width { get; set; }
- }
-}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Anamorphic/DestSettings.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Anamorphic/DestSettings.cs index cc9b9c53d..28971308b 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Anamorphic/DestSettings.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Anamorphic/DestSettings.cs @@ -11,6 +11,8 @@ namespace HandBrake.ApplicationServices.Interop.Json.Anamorphic {
using System.Collections.Generic;
+ using HandBrake.ApplicationServices.Interop.Json.Shared;
+
/// <summary>
/// The dest geometry.
/// </summary>
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Anamorphic/Geometry.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Anamorphic/Geometry.cs deleted file mode 100644 index b70b58f6b..000000000 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Anamorphic/Geometry.cs +++ /dev/null @@ -1,33 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="Geometry.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>
-// The geometry.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Interop.Json.Anamorphic
-{
-
- /// <summary>
- /// The geometry.
- /// </summary>
- public class Geometry
- {
- /// <summary>
- /// Gets or sets the height.
- /// </summary>
- public int Height { get; set; }
-
- /// <summary>
- /// Gets or sets the par.
- /// </summary>
- public PAR PAR { get; set; }
-
- /// <summary>
- /// Gets or sets the width.
- /// </summary>
- public int Width { get; set; }
- }
-}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Anamorphic/SourceGeometry.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Anamorphic/SourceGeometry.cs deleted file mode 100644 index c4ed79041..000000000 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Anamorphic/SourceGeometry.cs +++ /dev/null @@ -1,40 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="SourceGeometry.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>
-// The source geometry.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Interop.Json.Anamorphic
-{
- /// <summary>
- /// The source geometry.
- /// </summary>
- public class SourceGeometry
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="SourceGeometry"/> class.
- /// </summary>
- public SourceGeometry()
- {
- this.PAR = new PAR();
- }
-
- /// <summary>
- /// Gets or sets the height.
- /// </summary>
- public int Height { get; set; }
-
- /// <summary>
- /// Gets or sets the par.
- /// </summary>
- public PAR PAR { get; set; }
-
- /// <summary>
- /// Gets or sets the width.
- /// </summary>
- public int Width { get; set; }
- }
-}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/JsonEncodeObject.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/JsonEncodeObject.cs index 0accd19cf..cb9494c0d 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/JsonEncodeObject.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/JsonEncodeObject.cs @@ -10,6 +10,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Encode
{
using HandBrake.ApplicationServices.Interop.Json.Anamorphic;
+ using HandBrake.ApplicationServices.Interop.Json.Shared;
/// <summary>
/// The root object.
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/ChapterList.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/ChapterList.cs index 01a0068fc..90ec33cc8 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/ChapterList.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/ChapterList.cs @@ -17,7 +17,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan /// <summary>
/// Gets or sets the duration.
/// </summary>
- public Duration2 Duration { get; set; }
+ public Duration Duration { get; set; }
/// <summary>
/// Gets or sets the name.
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/Duration2.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/Duration2.cs deleted file mode 100644 index 3bf6827f5..000000000 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/Duration2.cs +++ /dev/null @@ -1,37 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="Duration2.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>
-// The duration 2.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Interop.Json.Scan
-{
- /// <summary>
- /// The duration 2.
- /// </summary>
- public class Duration2
- {
- /// <summary>
- /// Gets or sets the hours.
- /// </summary>
- public int Hours { get; set; }
-
- /// <summary>
- /// Gets or sets the minutes.
- /// </summary>
- public int Minutes { get; set; }
-
- /// <summary>
- /// Gets or sets the seconds.
- /// </summary>
- public int Seconds { get; set; }
-
- /// <summary>
- /// Gets or sets the ticks.
- /// </summary>
- public int Ticks { get; set; }
- }
-}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/PAR.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/PAR.cs deleted file mode 100644 index 9149604d9..000000000 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/PAR.cs +++ /dev/null @@ -1,27 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="PAR.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>
-// The par.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Interop.Json.Scan
-{
- /// <summary>
- /// The par.
- /// </summary>
- public class PAR
- {
- /// <summary>
- /// Gets or sets the width.
- /// </summary>
- public int Num { get; set; }
-
- /// <summary>
- /// Gets or sets the height.
- /// </summary>
- public int Den { get; set; }
- }
-}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/TitleList.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/TitleList.cs index 731d715c2..451275729 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/TitleList.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/TitleList.cs @@ -11,6 +11,8 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan {
using System.Collections.Generic;
+ using HandBrake.ApplicationServices.Interop.Json.Shared;
+
/// <summary>
/// The title list.
/// </summary>
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/Geometry.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Shared/Geometry.cs index 0f7f35ee8..429deb615 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/Geometry.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Shared/Geometry.cs @@ -7,7 +7,7 @@ // </summary>
// --------------------------------------------------------------------------------------------------------------------
-namespace HandBrake.ApplicationServices.Interop.Json.Scan
+namespace HandBrake.ApplicationServices.Interop.Json.Shared
{
/// <summary>
/// The geometry.
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Anamorphic/PAR.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Shared/PAR.cs index 895666633..503acf2f7 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Anamorphic/PAR.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Shared/PAR.cs @@ -7,7 +7,7 @@ // </summary>
// --------------------------------------------------------------------------------------------------------------------
-namespace HandBrake.ApplicationServices.Interop.Json.Anamorphic
+namespace HandBrake.ApplicationServices.Interop.Json.Shared
{
/// <summary>
/// The par.
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs index 670424127..c3283e275 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs @@ -19,6 +19,7 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories using HandBrake.ApplicationServices.Interop.Helpers;
using HandBrake.ApplicationServices.Interop.Json.Anamorphic;
using HandBrake.ApplicationServices.Interop.Json.Encode;
+ using HandBrake.ApplicationServices.Interop.Json.Shared;
using HandBrake.ApplicationServices.Interop.Model.Encoding;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Services.Encode.Model;
|