diff options
author | sr55 <[email protected]> | 2011-10-30 17:58:53 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2011-10-30 17:58:53 +0000 |
commit | 8b8ebd1f417c6ef65ab431a36fad0bbf0e2daf58 (patch) | |
tree | 37637e767ceac63a4bb48b8a99c17b196128b846 /win/CS/HandBrake.Interop/HandBrakeInterop/Converters.cs | |
parent | 2f0f372b09897e703a8d01fe9774aa59c936a013 (diff) |
Interop: Updates to the Interop Library to use the new methods to get at the Audio/Video encoder information from libhb. Patch by RandomEngy.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4329 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.Interop/HandBrakeInterop/Converters.cs')
-rw-r--r-- | win/CS/HandBrake.Interop/HandBrakeInterop/Converters.cs | 100 |
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 + }; + } + } +} |