summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.Interop/HandBrakeInterop/Converters.cs
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS/HandBrake.Interop/HandBrakeInterop/Converters.cs')
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Converters.cs100
1 files changed, 89 insertions, 11 deletions
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Converters.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Converters.cs
index aeea2a142..9a4b175e5 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/Converters.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Converters.cs
@@ -4,12 +4,14 @@
// </copyright>
// <summary>
// Defines the Converters type.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.Interop
-{
- using System;
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+using HandBrake.Interop.Model;
+
+namespace HandBrake.Interop
+{
+ using System;
using System.Collections.Generic;
using HandBrake.Interop.HbLib;
@@ -190,8 +192,84 @@ namespace HandBrake.Interop
case NativeConstants.HB_ACODEC_CA_HAAC:
return AudioCodec.Aac;
default:
- return AudioCodec.Other;
- }
- }
- }
-}
+ return AudioCodec.Other;
+ }
+ }
+
+ /// <summary>
+ /// Converts a native HB encoder structure to an Encoder model.
+ /// </summary>
+ /// <param name="encoder">The structure to convert.</param>
+ /// <returns>The converted model.</returns>
+ public static HBVideoEncoder NativeToVideoEncoder(hb_encoder_s encoder)
+ {
+ var result = new HBVideoEncoder
+ {
+ Id = encoder.encoder,
+ ShortName = encoder.short_name,
+ DisplayName = encoder.human_readable_name,
+ CompatibleContainers = Container.None
+ };
+
+ if ((encoder.muxers & NativeConstants.HB_MUX_MKV) > 0)
+ {
+ result.CompatibleContainers = result.CompatibleContainers | Container.Mkv;
+ }
+
+ if ((encoder.muxers & NativeConstants.HB_MUX_MP4) > 0)
+ {
+ result.CompatibleContainers = result.CompatibleContainers | Container.Mp4;
+ }
+
+ return result;
+ }
+
+ /// <summary>
+ /// Converts a native HB encoder structure to an Encoder model.
+ /// </summary>
+ /// <param name="encoder">The structure to convert.</param>
+ /// <returns>The converted model.</returns>
+ public static HBAudioEncoder NativeToAudioEncoder(hb_encoder_s encoder)
+ {
+ var result = new HBAudioEncoder
+ {
+ Id = encoder.encoder,
+ ShortName = encoder.short_name,
+ DisplayName = encoder.human_readable_name,
+ CompatibleContainers = Container.None
+ };
+
+ if ((encoder.muxers & NativeConstants.HB_MUX_MKV) > 0)
+ {
+ result.CompatibleContainers = result.CompatibleContainers | Container.Mkv;
+ }
+
+ if ((encoder.muxers & NativeConstants.HB_MUX_MP4) > 0)
+ {
+ result.CompatibleContainers = result.CompatibleContainers | Container.Mp4;
+ }
+
+ result.QualityLimits = Encoders.GetAudioQualityLimits(encoder.encoder);
+ result.DefaultQuality = HBFunctions.hb_get_default_audio_quality((uint)encoder.encoder);
+ result.CompressionLimits = Encoders.GetAudioCompressionLimits(encoder.encoder);
+ result.DefaultCompression = HBFunctions.hb_get_default_audio_compression((uint) encoder.encoder);
+
+ return result;
+ }
+
+ /// <summary>
+ /// Converts a native HB mixdown structure to a Mixdown model.
+ /// </summary>
+ /// <param name="mixdown">The structure to convert.</param>
+ /// <returns>The converted model.</returns>
+ public static HBMixdown NativeToMixdown(hb_mixdown_s mixdown)
+ {
+ return new HBMixdown
+ {
+ Id = mixdown.amixdown,
+ ShortName = mixdown.short_name,
+ DisplayName = mixdown.human_readable_name
+ };
+ }
+ }
+}