summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
Diffstat (limited to 'win')
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs75
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs8
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/NativeConstants.cs2
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoders.cs546
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Properties/AssemblyInfo.cs10
5 files changed, 344 insertions, 297 deletions
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs
index efcd257e1..e019e9610 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs
@@ -48,9 +48,14 @@ namespace HandBrake.Interop
private const string TurboX264Opts = "ref=1:subme=2:me=dia:analyse=none:trellis=0:no-fast-pskip=0:8x8dct=0:weightb=0";
/// <summary>
- /// Default value to give as a minimum duration when scanning.
+ /// Lock for creation of handbrake instances;
/// </summary>
- private const ulong DefaultMinDuration = 900000;
+ private static object instanceCreationLock = new object();
+
+ /// <summary>
+ /// True if a handbrake instance has been created.
+ /// </summary>
+ private static bool globalInitialized;
/// <summary>
/// The native handle to the HandBrake instance.
@@ -164,19 +169,19 @@ namespace HandBrake.Interop
}
/// <summary>
- /// Call before app shutdown. Performs global cleanup.
- /// </summary>
- public static void DisposeGlobal()
- {
- HBFunctions.hb_global_close();
- }
-
- /// <summary>
/// Initializes this instance.
/// </summary>
/// <param name="verbosity">The code for the logging verbosity to use.</param>
public void Initialize(int verbosity)
{
+ lock (instanceCreationLock)
+ {
+ if (!globalInitialized)
+ {
+ globalInitialized = true;
+ }
+ }
+
HandBrakeUtils.RegisterLogger();
this.hbHandle = HBFunctions.hb_init(verbosity, update_check: 0);
}
@@ -186,9 +191,15 @@ namespace HandBrake.Interop
/// </summary>
/// <param name="path">The path to the video to scan.</param>
/// <param name="previewCount">The number of preview images to make.</param>
+ /// <param name="minDuration">The minimum duration of a title to show up on the scan.</param>
+ public void StartScan(string path, int previewCount, TimeSpan minDuration)
+ {
+ this.StartScan(path, previewCount, minDuration, 0);
+ }
+
public void StartScan(string path, int previewCount)
{
- this.StartScan(path, previewCount, 0);
+ this.StartScan(path, previewCount, TimeSpan.FromSeconds(10), 0);
}
/// <summary>
@@ -199,17 +210,7 @@ namespace HandBrake.Interop
/// <param name="titleIndex">The title index to scan (1-based, 0 for all titles).</param>
public void StartScan(string path, int previewCount, int titleIndex)
{
- this.previewCount = previewCount;
- HBFunctions.hb_scan(this.hbHandle, path, titleIndex, previewCount, 1, DefaultMinDuration);
- this.scanPollTimer = new System.Timers.Timer();
- this.scanPollTimer.Interval = ScanPollIntervalMs;
-
- // Lambda notation used to make sure we can view any JIT exceptions the method throws
- this.scanPollTimer.Elapsed += (o, e) =>
- {
- this.PollScanProgress();
- };
- this.scanPollTimer.Start();
+ this.StartScan(path, previewCount, TimeSpan.Zero, titleIndex);
}
/// <summary>
@@ -723,6 +724,28 @@ namespace HandBrake.Interop
}
/// <summary>
+ /// Starts a scan of the given path.
+ /// </summary>
+ /// <param name="path">The path of the video to scan.</param>
+ /// <param name="previewCount">The number of previews to make on each title.</param>
+ /// <param name="minDuration">The minimum duration of a title to show up on the scan.</param>
+ /// <param name="titleIndex">The title index to scan (1-based, 0 for all titles).</param>
+ private void StartScan(string path, int previewCount, TimeSpan minDuration, int titleIndex)
+ {
+ this.previewCount = previewCount;
+ HBFunctions.hb_scan(this.hbHandle, path, titleIndex, previewCount, 1, (ulong)(minDuration.TotalSeconds * 90000));
+ this.scanPollTimer = new System.Timers.Timer();
+ this.scanPollTimer.Interval = ScanPollIntervalMs;
+
+ // Lambda notation used to make sure we can view any JIT exceptions the method throws
+ this.scanPollTimer.Elapsed += (o, e) =>
+ {
+ this.PollScanProgress();
+ };
+ this.scanPollTimer.Start();
+ }
+
+ /// <summary>
/// Checks the status of the ongoing scan.
/// </summary>
private void PollScanProgress()
@@ -1183,8 +1206,14 @@ namespace HandBrake.Interop
List<Tuple<AudioEncoding, int>> outputTrackList = this.GetOutputTracks(job, title);
- if (profile.AudioEncoderFallback != null)
+ if (!string.IsNullOrEmpty(profile.AudioEncoderFallback))
{
+ HBAudioEncoder audioEncoder = Encoders.GetAudioEncoder(profile.AudioEncoderFallback);
+ if (audioEncoder == null)
+ {
+ throw new ArgumentException("Unrecognized fallback audio encoder: " + profile.AudioEncoderFallback);
+ }
+
nativeJob.acodec_fallback = Encoders.GetAudioEncoder(profile.AudioEncoderFallback).Id;
}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs
index e0f04c3d9..8bd8125ee 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs
@@ -57,6 +57,14 @@ namespace HandBrake.Interop
}
/// <summary>
+ /// Call before app shutdown. Performs global cleanup.
+ /// </summary>
+ public static void DisposeGlobal()
+ {
+ HBFunctions.hb_global_close();
+ }
+
+ /// <summary>
/// Register the logger.
/// </summary>
public static void RegisterLogger()
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/NativeConstants.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/NativeConstants.cs
index c85390a41..c9f4f9aeb 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/NativeConstants.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/NativeConstants.cs
@@ -46,7 +46,7 @@ namespace HandBrake.Interop.HbLib
public const int HB_AMIXDOWN_A52_FORMAT_MASK = 0x00000FF0;
public const int HB_AMIXDOWN_DISCRETE_CHANNEL_COUNT_MASK = 0x0000000F;
public const int HB_AMIXDOWN_NONE = 0x00000000;
- public const int HB_AMIXDOWN_MONO = 0x01000001;
+ public const int HB_AMIXDOWN_MONO = 0x01000011;
public const int HB_AMIXDOWN_STEREO = 0x02002022;
public const int HB_AMIXDOWN_DOLBY = 0x042070A2;
public const int HB_AMIXDOWN_DOLBYPLII = 0x084094A2;
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoders.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoders.cs
index e13337ea7..5f894dda2 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoders.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoders.cs
@@ -1,268 +1,278 @@
-// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="Encoders.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>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.Interop.Model
-{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.InteropServices;
- using HandBrake.Interop.HbLib;
- using HandBrake.Interop.Model.Encoding;
- using HandBrake.Interop.SourceData;
-
- public static class Encoders
- {
- private static List<HBAudioEncoder> audioEncoders;
- private static List<HBVideoEncoder> videoEncoders;
- private static List<HBMixdown> mixdowns;
- private static List<int> audioBitrates;
-
- /// <summary>
- /// Gets a list of supported audio encoders.
- /// </summary>
- public static List<HBAudioEncoder> AudioEncoders
- {
- get
- {
- if (audioEncoders == null)
- {
- IntPtr encodersPtr = HBFunctions.hb_get_audio_encoders();
- int encoderCount = HBFunctions.hb_get_audio_encoders_count();
-
- audioEncoders = InteropUtilities.ConvertArray<hb_encoder_s>(encodersPtr, encoderCount)
- .Select(Converters.NativeToAudioEncoder)
- .ToList();
- }
-
- return audioEncoders;
- }
- }
-
- /// <summary>
- /// Gets a list of supported video encoders.
- /// </summary>
- public static List<HBVideoEncoder> VideoEncoders
- {
- get
- {
- if (videoEncoders == null)
- {
- IntPtr encodersPtr = HBFunctions.hb_get_video_encoders();
- int encoderCount = HBFunctions.hb_get_video_encoders_count();
-
- videoEncoders = InteropUtilities.ConvertArray<hb_encoder_s>(encodersPtr, encoderCount)
- .Select(Converters.NativeToVideoEncoder)
- .ToList();
- }
-
- return videoEncoders;
- }
- }
-
- /// <summary>
- /// Gets a list of supported mixdowns.
- /// </summary>
- public static List<HBMixdown> Mixdowns
- {
- get
- {
- if (mixdowns == null)
- {
- IntPtr mixdownsPtr = HBFunctions.hb_get_audio_mixdowns();
- int mixdownsCount = HBFunctions.hb_get_audio_mixdowns_count();
-
- mixdowns = InteropUtilities.ConvertArray<hb_mixdown_s>(mixdownsPtr, mixdownsCount)
- .Select(Converters.NativeToMixdown)
- .ToList();
- }
-
- return mixdowns;
- }
- }
-
- /// <summary>
- /// Gets a list of supported audio bitrates.
- /// </summary>
- public static List<int> AudioBitrates
- {
- get
- {
- if (audioBitrates == null)
- {
- IntPtr audioBitratesPtr = HBFunctions.hb_get_audio_bitrates();
- int audioBitratesCount = HBFunctions.hb_get_audio_bitrates_count();
-
- audioBitrates = InteropUtilities.ConvertArray<hb_rate_s>(audioBitratesPtr, audioBitratesCount)
- .Select(b => b.rate)
- .ToList();
- }
-
- return audioBitrates;
- }
- }
-
- /// <summary>
- /// Gets the audio encoder with the specified short name.
- /// </summary>
- /// <param name="shortName">The name of the audio encoder.</param>
- /// <returns>The requested audio encoder.</returns>
- public static HBAudioEncoder GetAudioEncoder(string shortName)
- {
- return AudioEncoders.SingleOrDefault(e => e.ShortName == shortName);
- }
-
- /// <summary>
- /// Gets the mixdown with the specified short name.
- /// </summary>
- /// <param name="shortName">The name of the mixdown.</param>
- /// <returns>The requested mixdown.</returns>
- public static HBMixdown GetMixdown(string shortName)
- {
- return Mixdowns.SingleOrDefault(m => m.ShortName == shortName);
- }
-
- /// <summary>
- /// Determines if the given encoder is compatible with the given track.
- /// </summary>
- /// <param name="track">The audio track to examine.</param>
- /// <param name="encoder">The encoder to examine.</param>
- /// <returns>True if the given encoder is comatible with the given audio track.</returns>
- /// <remarks>Only works with passthrough encoders.</remarks>
- public static bool AudioEncoderIsCompatible(AudioTrack track, HBAudioEncoder encoder)
- {
- return (track.CodecId & encoder.Id) > 0;
- }
-
- /// <summary>
- /// Finds the highest possible mixdown for a given audio encoder.
- /// </summary>
- /// <param name="audioEncoder">The audio encoder in question.</param>
- /// <returns>The highest possible mixdown for that audio encoder.</returns>
- public static int GetMaxMixdownIndex(HBAudioEncoder audioEncoder)
- {
- // To find best case scenario, pass in highest number of channels and 6-channel discrete mixdown.
- int maxMixdownId = HBFunctions.hb_get_best_mixdown((uint)audioEncoder.Id, NativeConstants.HB_INPUT_CH_LAYOUT_3F4R, NativeConstants.HB_AMIXDOWN_6CH);
-
- for (int i = 0; i < Mixdowns.Count; i++)
- {
- if (Mixdowns[i].Id == maxMixdownId)
- {
- return i;
- }
- }
-
- return -1;
- }
-
- /// <summary>
- /// Sanitizes a mixdown given the output codec and input channel layout.
- /// </summary>
- /// <param name="mixdown">The desired mixdown.</param>
- /// <param name="encoder">The output encoder to be used.</param>
- /// <param name="layout">The input channel layout.</param>
- /// <returns>A sanitized mixdown value.</returns>
- public static HBMixdown SanitizeMixdown(HBMixdown mixdown, HBAudioEncoder encoder, int layout)
- {
- int sanitizedMixdown = HBFunctions.hb_get_best_mixdown((uint)encoder.Id, layout, mixdown.Id);
- return Mixdowns.Single(m => m.Id == sanitizedMixdown);
- }
-
- /// <summary>
- /// Gets the default mixdown for the given audio encoder and channel layout.
- /// </summary>
- /// <param name="encoder">The output codec to be used.</param>
- /// <param name="layout">The input channel layout.</param>
- /// <returns>The default mixdown for the given codec and channel layout.</returns>
- public static HBMixdown GetDefaultMixdown(HBAudioEncoder encoder, int layout)
- {
- int defaultMixdown = HBFunctions.hb_get_default_mixdown((uint)encoder.Id, layout);
- return Mixdowns.Single(m => m.Id == defaultMixdown);
- }
-
- /// <summary>
- /// Gets the bitrate limits for the given audio codec, sample rate and mixdown.
- /// </summary>
- /// <param name="encoder">The audio encoder used.</param>
- /// <param name="sampleRate">The sample rate used (Hz).</param>
- /// <param name="mixdown">The mixdown used.</param>
- /// <returns>Limits on the audio bitrate for the given settings.</returns>
- public static BitrateLimits GetBitrateLimits(HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown)
- {
- int low = 0;
- int high = 0;
-
- HBFunctions.hb_get_audio_bitrate_limits((uint)encoder.Id, sampleRate, mixdown.Id, ref low, ref high);
-
- return new BitrateLimits { Low = low, High = high };
- }
-
- /// <summary>
- /// Sanitizes an audio bitrate given the output codec, sample rate and mixdown.
- /// </summary>
- /// <param name="audioBitrate">The desired audio bitrate.</param>
- /// <param name="encoder">The output encoder to be used.</param>
- /// <param name="sampleRate">The output sample rate to be used.</param>
- /// <param name="mixdown">The mixdown to be used.</param>
- /// <returns>A sanitized audio bitrate.</returns>
- public static int SanitizeAudioBitrate(int audioBitrate, HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown)
- {
- return HBFunctions.hb_get_best_audio_bitrate((uint)encoder.Id, audioBitrate, sampleRate, mixdown.Id);
- }
-
- /// <summary>
- /// Gets the default audio bitrate for the given parameters.
- /// </summary>
- /// <param name="encoder">The encoder to use.</param>
- /// <param name="sampleRate">The sample rate to use.</param>
- /// <param name="mixdown">The mixdown to use.</param>
- /// <returns>The default bitrate for these parameters.</returns>
- public static int GetDefaultBitrate(HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown)
- {
- return HBFunctions.hb_get_default_audio_bitrate((uint) encoder.Id, sampleRate, mixdown.Id);
- }
-
- /// <summary>
- /// Gets limits on audio quality for a given encoder.
- /// </summary>
- /// <param name="encoderId">The audio encoder ID.</param>
- /// <returns>Limits on the audio quality for the given encoder.</returns>
- internal static RangeLimits GetAudioQualityLimits(int encoderId)
- {
- float low = 0, high = 0, granularity = 0;
- int direction = 0;
- HBFunctions.hb_get_audio_quality_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction);
-
- return new RangeLimits
- {
- Low = low,
- High = high,
- Granularity = granularity,
- Ascending = direction == 0
- };
- }
-
- /// <summary>
- /// Gets limits on audio compression for a given encoder.
- /// </summary>
- /// <param name="encoderId">The audio encoder ID.</param>
- /// <returns>Limits on the audio compression for the given encoder.</returns>
- internal static RangeLimits GetAudioCompressionLimits(int encoderId)
- {
- float low = 0, high = 0, granularity = 0;
- int direction = 0;
- HBFunctions.hb_get_audio_compression_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction);
-
- return new RangeLimits
- {
- Low = low,
- High = high,
- Granularity = granularity,
- Ascending = direction == 0
- };
- }
- }
-}
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="Encoders.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>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.Interop.Model
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Runtime.InteropServices;
+ using HandBrake.Interop.HbLib;
+ using HandBrake.Interop.Model.Encoding;
+ using HandBrake.Interop.SourceData;
+
+ public static class Encoders
+ {
+ private static List<HBAudioEncoder> audioEncoders;
+ private static List<HBVideoEncoder> videoEncoders;
+ private static List<HBMixdown> mixdowns;
+ private static List<int> audioBitrates;
+
+ /// <summary>
+ /// Gets a list of supported audio encoders.
+ /// </summary>
+ public static List<HBAudioEncoder> AudioEncoders
+ {
+ get
+ {
+ if (audioEncoders == null)
+ {
+ IntPtr encodersPtr = HBFunctions.hb_get_audio_encoders();
+ int encoderCount = HBFunctions.hb_get_audio_encoders_count();
+
+ audioEncoders = InteropUtilities.ConvertArray<hb_encoder_s>(encodersPtr, encoderCount)
+ .Select(Converters.NativeToAudioEncoder)
+ .ToList();
+ }
+
+ return audioEncoders;
+ }
+ }
+
+ /// <summary>
+ /// Gets a list of supported video encoders.
+ /// </summary>
+ public static List<HBVideoEncoder> VideoEncoders
+ {
+ get
+ {
+ if (videoEncoders == null)
+ {
+ IntPtr encodersPtr = HBFunctions.hb_get_video_encoders();
+ int encoderCount = HBFunctions.hb_get_video_encoders_count();
+
+ videoEncoders = InteropUtilities.ConvertArray<hb_encoder_s>(encodersPtr, encoderCount)
+ .Select(Converters.NativeToVideoEncoder)
+ .ToList();
+ }
+
+ return videoEncoders;
+ }
+ }
+
+ /// <summary>
+ /// Gets a list of supported mixdowns.
+ /// </summary>
+ public static List<HBMixdown> Mixdowns
+ {
+ get
+ {
+ if (mixdowns == null)
+ {
+ IntPtr mixdownsPtr = HBFunctions.hb_get_audio_mixdowns();
+ int mixdownsCount = HBFunctions.hb_get_audio_mixdowns_count();
+
+ mixdowns = InteropUtilities.ConvertArray<hb_mixdown_s>(mixdownsPtr, mixdownsCount)
+ .Select(Converters.NativeToMixdown)
+ .ToList();
+ }
+
+ return mixdowns;
+ }
+ }
+
+ /// <summary>
+ /// Gets a list of supported audio bitrates.
+ /// </summary>
+ public static List<int> AudioBitrates
+ {
+ get
+ {
+ if (audioBitrates == null)
+ {
+ IntPtr audioBitratesPtr = HBFunctions.hb_get_audio_bitrates();
+ int audioBitratesCount = HBFunctions.hb_get_audio_bitrates_count();
+
+ audioBitrates = InteropUtilities.ConvertArray<hb_rate_s>(audioBitratesPtr, audioBitratesCount)
+ .Select(b => b.rate)
+ .ToList();
+ }
+
+ return audioBitrates;
+ }
+ }
+
+ /// <summary>
+ /// Gets the audio encoder with the specified short name.
+ /// </summary>
+ /// <param name="shortName">The name of the audio encoder.</param>
+ /// <returns>The requested audio encoder.</returns>
+ public static HBAudioEncoder GetAudioEncoder(string shortName)
+ {
+ return AudioEncoders.SingleOrDefault(e => e.ShortName == shortName);
+ }
+
+ /// <summary>
+ /// Gets the video encoder with the specified short name.
+ /// </summary>
+ /// <param name="shortName">The name of the video encoder.</param>
+ /// <returns>The requested video encoder.</returns>
+ public static HBVideoEncoder GetVideoEncoder(string shortName)
+ {
+ return VideoEncoders.SingleOrDefault(e => e.ShortName == shortName);
+ }
+
+ /// <summary>
+ /// Gets the mixdown with the specified short name.
+ /// </summary>
+ /// <param name="shortName">The name of the mixdown.</param>
+ /// <returns>The requested mixdown.</returns>
+ public static HBMixdown GetMixdown(string shortName)
+ {
+ return Mixdowns.SingleOrDefault(m => m.ShortName == shortName);
+ }
+
+ /// <summary>
+ /// Determines if the given encoder is compatible with the given track.
+ /// </summary>
+ /// <param name="track">The audio track to examine.</param>
+ /// <param name="encoder">The encoder to examine.</param>
+ /// <returns>True if the given encoder is comatible with the given audio track.</returns>
+ /// <remarks>Only works with passthrough encoders.</remarks>
+ public static bool AudioEncoderIsCompatible(AudioTrack track, HBAudioEncoder encoder)
+ {
+ return (track.CodecId & encoder.Id) > 0;
+ }
+
+ /// <summary>
+ /// Finds the highest possible mixdown for a given audio encoder.
+ /// </summary>
+ /// <param name="audioEncoder">The audio encoder in question.</param>
+ /// <returns>The highest possible mixdown for that audio encoder.</returns>
+ public static int GetMaxMixdownIndex(HBAudioEncoder audioEncoder)
+ {
+ // To find best case scenario, pass in highest number of channels and 6-channel discrete mixdown.
+ int maxMixdownId = HBFunctions.hb_get_best_mixdown((uint)audioEncoder.Id, NativeConstants.HB_INPUT_CH_LAYOUT_3F4R | NativeConstants.HB_INPUT_CH_LAYOUT_HAS_LFE, NativeConstants.HB_AMIXDOWN_6CH);
+
+ for (int i = 0; i < Mixdowns.Count; i++)
+ {
+ if (Mixdowns[i].Id == maxMixdownId)
+ {
+ return i;
+ }
+ }
+
+ return -1;
+ }
+
+ /// <summary>
+ /// Sanitizes a mixdown given the output codec and input channel layout.
+ /// </summary>
+ /// <param name="mixdown">The desired mixdown.</param>
+ /// <param name="encoder">The output encoder to be used.</param>
+ /// <param name="layout">The input channel layout.</param>
+ /// <returns>A sanitized mixdown value.</returns>
+ public static HBMixdown SanitizeMixdown(HBMixdown mixdown, HBAudioEncoder encoder, int layout)
+ {
+ int sanitizedMixdown = HBFunctions.hb_get_best_mixdown((uint)encoder.Id, layout, mixdown.Id);
+ return Mixdowns.Single(m => m.Id == sanitizedMixdown);
+ }
+
+ /// <summary>
+ /// Gets the default mixdown for the given audio encoder and channel layout.
+ /// </summary>
+ /// <param name="encoder">The output codec to be used.</param>
+ /// <param name="layout">The input channel layout.</param>
+ /// <returns>The default mixdown for the given codec and channel layout.</returns>
+ public static HBMixdown GetDefaultMixdown(HBAudioEncoder encoder, int layout)
+ {
+ int defaultMixdown = HBFunctions.hb_get_default_mixdown((uint)encoder.Id, layout);
+ return Mixdowns.Single(m => m.Id == defaultMixdown);
+ }
+
+ /// <summary>
+ /// Gets the bitrate limits for the given audio codec, sample rate and mixdown.
+ /// </summary>
+ /// <param name="encoder">The audio encoder used.</param>
+ /// <param name="sampleRate">The sample rate used (Hz).</param>
+ /// <param name="mixdown">The mixdown used.</param>
+ /// <returns>Limits on the audio bitrate for the given settings.</returns>
+ public static BitrateLimits GetBitrateLimits(HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown)
+ {
+ int low = 0;
+ int high = 0;
+
+ HBFunctions.hb_get_audio_bitrate_limits((uint)encoder.Id, sampleRate, mixdown.Id, ref low, ref high);
+
+ return new BitrateLimits { Low = low, High = high };
+ }
+
+ /// <summary>
+ /// Sanitizes an audio bitrate given the output codec, sample rate and mixdown.
+ /// </summary>
+ /// <param name="audioBitrate">The desired audio bitrate.</param>
+ /// <param name="encoder">The output encoder to be used.</param>
+ /// <param name="sampleRate">The output sample rate to be used.</param>
+ /// <param name="mixdown">The mixdown to be used.</param>
+ /// <returns>A sanitized audio bitrate.</returns>
+ public static int SanitizeAudioBitrate(int audioBitrate, HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown)
+ {
+ return HBFunctions.hb_get_best_audio_bitrate((uint)encoder.Id, audioBitrate, sampleRate, mixdown.Id);
+ }
+
+ /// <summary>
+ /// Gets the default audio bitrate for the given parameters.
+ /// </summary>
+ /// <param name="encoder">The encoder to use.</param>
+ /// <param name="sampleRate">The sample rate to use.</param>
+ /// <param name="mixdown">The mixdown to use.</param>
+ /// <returns>The default bitrate for these parameters.</returns>
+ public static int GetDefaultBitrate(HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown)
+ {
+ return HBFunctions.hb_get_default_audio_bitrate((uint) encoder.Id, sampleRate, mixdown.Id);
+ }
+
+ /// <summary>
+ /// Gets limits on audio quality for a given encoder.
+ /// </summary>
+ /// <param name="encoderId">The audio encoder ID.</param>
+ /// <returns>Limits on the audio quality for the given encoder.</returns>
+ internal static RangeLimits GetAudioQualityLimits(int encoderId)
+ {
+ float low = 0, high = 0, granularity = 0;
+ int direction = 0;
+ HBFunctions.hb_get_audio_quality_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction);
+
+ return new RangeLimits
+ {
+ Low = low,
+ High = high,
+ Granularity = granularity,
+ Ascending = direction == 0
+ };
+ }
+
+ /// <summary>
+ /// Gets limits on audio compression for a given encoder.
+ /// </summary>
+ /// <param name="encoderId">The audio encoder ID.</param>
+ /// <returns>Limits on the audio compression for the given encoder.</returns>
+ internal static RangeLimits GetAudioCompressionLimits(int encoderId)
+ {
+ float low = 0, high = 0, granularity = 0;
+ int direction = 0;
+ HBFunctions.hb_get_audio_compression_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction);
+
+ return new RangeLimits
+ {
+ Low = low,
+ High = high,
+ Granularity = granularity,
+ Ascending = direction == 0
+ };
+ }
+ }
+}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Properties/AssemblyInfo.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Properties/AssemblyInfo.cs
index b9f0c721c..fa9e9e063 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/Properties/AssemblyInfo.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Properties/AssemblyInfo.cs
@@ -29,8 +29,8 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.23.0.0")]
-[assembly: AssemblyFileVersion("1.23.0.0")]
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.27.0.0")]
+[assembly: AssemblyFileVersion("1.27.0.0")]