/// Encode Completed Event Args\r
/// </summary>\r
public class EncodeCompletedEventArgs : EventArgs\r
- {\r
- /// <summary>\r
- /// Gets or sets a value indicating whether an error occurred during the encode.\r
- /// </summary>\r
- public bool Error { get; set; }\r
- }\r
+ {\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether an error occurred during the encode.\r
+ /// </summary>\r
+ public bool Error { get; set; }\r
+ }\r
}\r
/// Encode Progress Event Args\r
/// </summary>\r
public class EncodeProgressEventArgs : EventArgs\r
- {\r
- /// <summary>\r
- /// Gets or sets FractionComplete.\r
- /// </summary>\r
+ {\r
+ /// <summary>\r
+ /// Gets or sets FractionComplete.\r
+ /// </summary>\r
public double FractionComplete { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets CurrentFrameRate.\r
- /// </summary>\r
+ /// <summary>\r
+ /// Gets or sets CurrentFrameRate.\r
+ /// </summary>\r
public double CurrentFrameRate { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets AverageFrameRate.\r
- /// </summary>\r
+ /// <summary>\r
+ /// Gets or sets AverageFrameRate.\r
+ /// </summary>\r
public double AverageFrameRate { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets EstimatedTimeLeft.\r
- /// </summary>\r
- public TimeSpan EstimatedTimeLeft { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets EstimatedTimeLeft.\r
+ /// </summary>\r
+ public TimeSpan EstimatedTimeLeft { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the current encoding pass. (-1: subtitle scan, 1: first pass, 2: second pass)\r
- /// </summary>\r
- public int Pass { get; set; }\r
- }\r
+ /// <summary>\r
+ /// Gets or sets the current encoding pass. (-1: subtitle scan, 1: first pass, 2: second pass)\r
+ /// </summary>\r
+ public int Pass { get; set; }\r
+ }\r
}\r
using System;\r
\r
/// <summary>\r
- /// The Message Logged Event Args\r
- /// </summary>\r
- public class MessageLoggedEventArgs : EventArgs\r
- {\r
- /// <summary>\r
- /// Gets or sets Message.\r
- /// </summary>\r
- public string Message { get; set; }\r
- }\r
+ /// The Message Logged Event Args\r
+ /// </summary>\r
+ public class MessageLoggedEventArgs : EventArgs\r
+ {\r
+ /// <summary>\r
+ /// Gets or sets Message.\r
+ /// </summary>\r
+ public string Message { get; set; }\r
+ }\r
}\r
\r
namespace HandBrake.ApplicationServices.Interop.EventArgs\r
{\r
- using System;\r
+ using System;\r
\r
- /// <summary>\r
- /// The Scan Progress Event Args\r
- /// </summary>\r
- public class ScanProgressEventArgs : EventArgs\r
- {\r
- /// <summary>\r
- /// Gets or sets the total progress fraction for the scan.\r
- /// </summary>\r
- public double Progress { get; set; }\r
+ /// <summary>\r
+ /// The Scan Progress Event Args\r
+ /// </summary>\r
+ public class ScanProgressEventArgs : EventArgs\r
+ {\r
+ /// <summary>\r
+ /// Gets or sets the total progress fraction for the scan.\r
+ /// </summary>\r
+ public double Progress { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the current preview being processed on the scan.\r
- /// </summary>\r
- public int CurrentPreview { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets the current preview being processed on the scan.\r
+ /// </summary>\r
+ public int CurrentPreview { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the total number of previews to process.\r
- /// </summary>\r
- public int Previews { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets the total number of previews to process.\r
+ /// </summary>\r
+ public int Previews { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the current title being processed on the scan.\r
- /// </summary>\r
- public int CurrentTitle { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets the current title being processed on the scan.\r
+ /// </summary>\r
+ public int CurrentTitle { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the total number of titles to process.\r
- /// </summary>\r
- public int Titles { get; set; }\r
- }\r
+ /// <summary>\r
+ /// Gets or sets the total number of titles to process.\r
+ /// </summary>\r
+ public int Titles { get; set; }\r
+ }\r
}\r
using HandBrake.ApplicationServices.Interop.Model.Scan;\r
\r
/// <summary>\r
- /// The encoders.\r
- /// </summary>\r
- public static class HandBrakeEncoderHelpers\r
- {\r
- /// <summary>\r
- /// The audio encoders.\r
- /// </summary>\r
- private static List<HBAudioEncoder> audioEncoders;\r
-\r
- /// <summary>\r
- /// The video encoders.\r
- /// </summary>\r
- private static List<HBVideoEncoder> videoEncoders;\r
-\r
- /// <summary>\r
- /// Video framerates in pts.\r
- /// </summary>\r
- private static List<HBRate> videoFramerates; \r
-\r
- /// <summary>\r
- /// List of HandBrake mixdowns.\r
- /// </summary>\r
- private static List<HBMixdown> mixdowns;\r
-\r
- /// <summary>\r
- /// List of HandBrake containers.\r
- /// </summary>\r
- private static List<HBContainer> containers; \r
-\r
- /// <summary>\r
- /// The audio bitrates.\r
- /// </summary>\r
- private static List<int> audioBitrates;\r
-\r
- /// <summary>\r
- /// Audio sample rates in Hz.\r
- /// </summary>\r
- private static List<HBRate> audioSampleRates; \r
-\r
- /// <summary>\r
+ /// The encoders.\r
+ /// </summary>\r
+ public static class HandBrakeEncoderHelpers\r
+ {\r
+ /// <summary>\r
+ /// The audio encoders.\r
+ /// </summary>\r
+ private static List<HBAudioEncoder> audioEncoders;\r
+\r
+ /// <summary>\r
+ /// The video encoders.\r
+ /// </summary>\r
+ private static List<HBVideoEncoder> videoEncoders;\r
+\r
+ /// <summary>\r
+ /// Video framerates in pts.\r
+ /// </summary>\r
+ private static List<HBRate> videoFramerates; \r
+\r
+ /// <summary>\r
+ /// List of HandBrake mixdowns.\r
+ /// </summary>\r
+ private static List<HBMixdown> mixdowns;\r
+\r
+ /// <summary>\r
+ /// List of HandBrake containers.\r
+ /// </summary>\r
+ private static List<HBContainer> containers; \r
+\r
+ /// <summary>\r
+ /// The audio bitrates.\r
+ /// </summary>\r
+ private static List<int> audioBitrates;\r
+\r
+ /// <summary>\r
+ /// Audio sample rates in Hz.\r
+ /// </summary>\r
+ private static List<HBRate> audioSampleRates; \r
+\r
+ /// <summary>\r
/// Initializes static members of the HandBrakeEncoderHelpers class.\r
- /// </summary>\r
+ /// </summary>\r
static HandBrakeEncoderHelpers()\r
- {\r
- HandBrakeUtils.EnsureGlobalInit();\r
- }\r
-\r
- /// <summary>\r
- /// Gets a list of supported audio encoders.\r
- /// </summary>\r
- public static List<HBAudioEncoder> AudioEncoders\r
- {\r
- get\r
- {\r
- if (audioEncoders == null)\r
- {\r
+ {\r
+ HandBrakeUtils.EnsureGlobalInit();\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets a list of supported audio encoders.\r
+ /// </summary>\r
+ public static List<HBAudioEncoder> AudioEncoders\r
+ {\r
+ get\r
+ {\r
+ if (audioEncoders == null)\r
+ {\r
audioEncoders = InteropUtilities.ToListFromIterator<hb_encoder_s, HBAudioEncoder>(HBFunctions.hb_audio_encoder_get_next, HandBrakeUnitConversionHelpers.NativeToAudioEncoder);\r
- }\r
-\r
- return audioEncoders;\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// Gets a list of supported video encoders.\r
- /// </summary>\r
- public static List<HBVideoEncoder> VideoEncoders\r
- {\r
- get\r
- {\r
- if (videoEncoders == null)\r
- {\r
+ }\r
+\r
+ return audioEncoders;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets a list of supported video encoders.\r
+ /// </summary>\r
+ public static List<HBVideoEncoder> VideoEncoders\r
+ {\r
+ get\r
+ {\r
+ if (videoEncoders == null)\r
+ {\r
videoEncoders = InteropUtilities.ToListFromIterator<hb_encoder_s, HBVideoEncoder>(HBFunctions.hb_video_encoder_get_next, HandBrakeUnitConversionHelpers.NativeToVideoEncoder);\r
- }\r
-\r
- return videoEncoders;\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// Gets a list of supported video framerates (in pts).\r
- /// </summary>\r
- public static List<HBRate> VideoFramerates\r
- {\r
- get\r
- {\r
- if (videoFramerates == null)\r
- {\r
+ }\r
+\r
+ return videoEncoders;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets a list of supported video framerates (in pts).\r
+ /// </summary>\r
+ public static List<HBRate> VideoFramerates\r
+ {\r
+ get\r
+ {\r
+ if (videoFramerates == null)\r
+ {\r
videoFramerates = InteropUtilities.ToListFromIterator<hb_rate_s, HBRate>(HBFunctions.hb_video_framerate_get_next, HandBrakeUnitConversionHelpers.NativeToRate);\r
- }\r
-\r
- return videoFramerates;\r
- }\r
- } \r
-\r
- /// <summary>\r
- /// Gets a list of supported mixdowns.\r
- /// </summary>\r
- public static List<HBMixdown> Mixdowns\r
- {\r
- get\r
- {\r
- if (mixdowns == null)\r
- {\r
+ }\r
+\r
+ return videoFramerates;\r
+ }\r
+ } \r
+\r
+ /// <summary>\r
+ /// Gets a list of supported mixdowns.\r
+ /// </summary>\r
+ public static List<HBMixdown> Mixdowns\r
+ {\r
+ get\r
+ {\r
+ if (mixdowns == null)\r
+ {\r
mixdowns = InteropUtilities.ToListFromIterator<hb_mixdown_s, HBMixdown>(HBFunctions.hb_mixdown_get_next, HandBrakeUnitConversionHelpers.NativeToMixdown);\r
- }\r
-\r
- return mixdowns;\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// Gets a list of supported audio bitrates.\r
- /// </summary>\r
- public static List<int> AudioBitrates\r
- {\r
- get\r
- {\r
- if (audioBitrates == null)\r
- {\r
- audioBitrates = InteropUtilities.ToListFromIterator<hb_rate_s, int>(HBFunctions.hb_audio_bitrate_get_next, b => b.rate);\r
- }\r
-\r
- return audioBitrates;\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// Gets a list of supported audio sample rates (in Hz).\r
- /// </summary>\r
- public static List<HBRate> AudioSampleRates\r
- {\r
- get\r
- {\r
- if (audioSampleRates == null)\r
- {\r
+ }\r
+\r
+ return mixdowns;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets a list of supported audio bitrates.\r
+ /// </summary>\r
+ public static List<int> AudioBitrates\r
+ {\r
+ get\r
+ {\r
+ if (audioBitrates == null)\r
+ {\r
+ audioBitrates = InteropUtilities.ToListFromIterator<hb_rate_s, int>(HBFunctions.hb_audio_bitrate_get_next, b => b.rate);\r
+ }\r
+\r
+ return audioBitrates;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets a list of supported audio sample rates (in Hz).\r
+ /// </summary>\r
+ public static List<HBRate> AudioSampleRates\r
+ {\r
+ get\r
+ {\r
+ if (audioSampleRates == null)\r
+ {\r
audioSampleRates = InteropUtilities.ToListFromIterator<hb_rate_s, HBRate>(HBFunctions.hb_audio_samplerate_get_next, HandBrakeUnitConversionHelpers.NativeToRate);\r
- }\r
-\r
- return audioSampleRates;\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// Gets a list of supported containers.\r
- /// </summary>\r
- public static List<HBContainer> Containers\r
- {\r
- get\r
- {\r
- if (containers == null)\r
- {\r
+ }\r
+\r
+ return audioSampleRates;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets a list of supported containers.\r
+ /// </summary>\r
+ public static List<HBContainer> Containers\r
+ {\r
+ get\r
+ {\r
+ if (containers == null)\r
+ {\r
containers = InteropUtilities.ToListFromIterator<hb_container_s, HBContainer>(HBFunctions.hb_container_get_next, HandBrakeUnitConversionHelpers.NativeToContainer);\r
- }\r
-\r
- return containers;\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// Gets a value indicating whether SRT subtitles can be burnt in.\r
- /// </summary>\r
- public static bool CanBurnSrt\r
- {\r
- get\r
- {\r
- return HBFunctions.hb_subtitle_can_burn((int)hb_subtitle_s_subsource.SRTSUB) > 0;\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// Gets the audio encoder with the specified short name.\r
- /// </summary>\r
- /// <param name="shortName">\r
- /// The name of the audio encoder.\r
- /// </param>\r
- /// <returns>\r
- /// The requested audio encoder.\r
- /// </returns>\r
- public static HBAudioEncoder GetAudioEncoder(string shortName)\r
- {\r
- return AudioEncoders.SingleOrDefault(e => e.ShortName == shortName);\r
- }\r
-\r
- /// <summary>\r
- /// Gets the audio encoder with the specified codec ID.\r
- /// </summary>\r
- /// <param name="codecId">\r
- /// The ID of the audio encoder.\r
- /// </param>\r
- /// <returns>\r
- /// The requested audio encoder.\r
- /// </returns>\r
- public static HBAudioEncoder GetAudioEncoder(int codecId)\r
- {\r
- return AudioEncoders.SingleOrDefault(e => e.Id == codecId);\r
- }\r
-\r
- /// <summary>\r
- /// Gets the video encoder with the specified short name.\r
- /// </summary>\r
- /// <param name="shortName">\r
- /// The name of the video encoder.\r
- /// </param>\r
- /// <returns>\r
- /// The requested video encoder.\r
- /// </returns>\r
- public static HBVideoEncoder GetVideoEncoder(string shortName)\r
- {\r
- return VideoEncoders.SingleOrDefault(e => e.ShortName == shortName);\r
- }\r
-\r
- /// <summary>\r
- /// Gets the mixdown with the specified short name.\r
- /// </summary>\r
- /// <param name="shortName">\r
- /// The name of the mixdown.\r
- /// </param>\r
- /// <returns>\r
- /// The requested mixdown.\r
- /// </returns>\r
- public static HBMixdown GetMixdown(string shortName)\r
- {\r
- return Mixdowns.SingleOrDefault(m => m.ShortName == shortName);\r
- }\r
-\r
- /// <summary>\r
- /// Gets the container with the specified short name.\r
- /// </summary>\r
- /// <param name="shortName">\r
- /// The name of the container.\r
- /// </param>\r
- /// <returns>\r
- /// The requested container.\r
- /// </returns>\r
- public static HBContainer GetContainer(string shortName)\r
- {\r
- return Containers.SingleOrDefault(c => c.ShortName == shortName);\r
- }\r
-\r
- /// <summary>\r
- /// Determines if the given encoder is compatible with the given track.\r
- /// </summary>\r
- /// <param name="track">\r
- /// The audio track to examine.\r
- /// </param>\r
- /// <param name="encoder">\r
- /// The encoder to examine.\r
- /// </param>\r
- /// <returns>\r
- /// True if the given encoder is comatible with the given audio track.\r
- /// </returns>\r
- /// <remarks>\r
- /// Only works with passthrough encoders.\r
- /// </remarks>\r
- public static bool AudioEncoderIsCompatible(AudioTrack track, HBAudioEncoder encoder)\r
- {\r
- return (track.CodecId & encoder.Id) > 0;\r
- }\r
-\r
- /// <summary>\r
- /// Determines if the given mixdown supports the given channel layout.\r
- /// </summary>\r
- /// <param name="mixdown">\r
- /// The mixdown to evaluate.\r
- /// </param>\r
- /// <param name="layout">\r
- /// The channel layout to evaluate.\r
- /// </param>\r
- /// <returns>\r
- /// True if the mixdown supports the given channel layout.\r
- /// </returns>\r
- public static bool MixdownHasRemixSupport(HBMixdown mixdown, ulong layout)\r
- {\r
- return HBFunctions.hb_mixdown_has_remix_support(mixdown.Id, layout) > 0;\r
- }\r
-\r
- /// <summary>\r
- /// Determines if the given encoder supports the given mixdown.\r
- /// </summary>\r
- /// <param name="mixdown">\r
- /// The mixdown to evaluate.\r
- /// </param>\r
- /// <param name="encoder">\r
- /// The encoder to evaluate.\r
- /// </param>\r
- /// <returns>\r
- /// True if the encoder supports the mixdown.\r
- /// </returns>\r
- public static bool MixdownHasCodecSupport(HBMixdown mixdown, HBAudioEncoder encoder)\r
- {\r
- return HBFunctions.hb_mixdown_has_codec_support(mixdown.Id, (uint) encoder.Id) > 0;\r
- }\r
-\r
- /// <summary>\r
- /// Determines if DRC can be applied to the given track with the given encoder.\r
- /// </summary>\r
- /// <param name="track">\r
- /// The track to apply DRC to.\r
- /// </param>\r
- /// <param name="encoder">\r
- /// The encoder to use for DRC.\r
- /// </param>\r
- /// <param name="title">\r
- /// The title.\r
- /// </param>\r
- /// <returns>\r
- /// True if DRC can be applied to the track with the given encoder.\r
- /// </returns>\r
- public static bool CanApplyDrc(AudioTrack track, HBAudioEncoder encoder, int title)\r
- {\r
- return HBFunctions.hb_audio_can_apply_drc2(HandBrakeInstanceManager.LastScanHandle, title, track.TrackNumber, encoder.Id) > 0;\r
- }\r
-\r
- /// <summary>\r
- /// Determines if the given input audio codec can be passed through.\r
- /// </summary>\r
- /// <param name="codecId">\r
- /// The input codec to consider.\r
- /// </param>\r
- /// <returns>\r
- /// True if the codec can be passed through.\r
- /// </returns>\r
- public static bool CanPassthroughAudio(int codecId)\r
- {\r
- return (codecId & NativeConstants.HB_ACODEC_PASS_MASK) > 0;\r
- }\r
-\r
- /// <summary>\r
- /// Sanitizes a mixdown given the output codec and input channel layout.\r
- /// </summary>\r
- /// <param name="mixdown">\r
- /// The desired mixdown.\r
- /// </param>\r
- /// <param name="encoder">\r
- /// The output encoder to be used.\r
- /// </param>\r
- /// <param name="layout">\r
- /// The input channel layout.\r
- /// </param>\r
- /// <returns>\r
- /// A sanitized mixdown value.\r
- /// </returns>\r
- public static HBMixdown SanitizeMixdown(HBMixdown mixdown, HBAudioEncoder encoder, ulong layout)\r
- {\r
- int sanitizedMixdown = HBFunctions.hb_mixdown_get_best((uint)encoder.Id, layout, mixdown.Id);\r
- return Mixdowns.Single(m => m.Id == sanitizedMixdown);\r
- }\r
-\r
- /// <summary>\r
- /// Gets the default mixdown for the given audio encoder and channel layout.\r
- /// </summary>\r
- /// <param name="encoder">\r
- /// The output codec to be used.\r
- /// </param>\r
- /// <param name="layout">\r
- /// The input channel layout.\r
- /// </param>\r
- /// <returns>\r
- /// The default mixdown for the given codec and channel layout.\r
- /// </returns>\r
- public static HBMixdown GetDefaultMixdown(HBAudioEncoder encoder, ulong layout)\r
- {\r
- int defaultMixdown = HBFunctions.hb_mixdown_get_default((uint)encoder.Id, layout);\r
- return Mixdowns.Single(m => m.Id == defaultMixdown);\r
- }\r
-\r
- /// <summary>\r
- /// Gets the bitrate limits for the given audio codec, sample rate and mixdown.\r
- /// </summary>\r
- /// <param name="encoder">\r
- /// The audio encoder used.\r
- /// </param>\r
- /// <param name="sampleRate">\r
- /// The sample rate used (Hz).\r
- /// </param>\r
- /// <param name="mixdown">\r
- /// The mixdown used.\r
- /// </param>\r
- /// <returns>\r
- /// Limits on the audio bitrate for the given settings.\r
- /// </returns>\r
- public static BitrateLimits GetBitrateLimits(HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown)\r
- {\r
- int low = 0;\r
- int high = 0;\r
-\r
- HBFunctions.hb_audio_bitrate_get_limits((uint)encoder.Id, sampleRate, mixdown.Id, ref low, ref high);\r
-\r
- return new BitrateLimits { Low = low, High = high };\r
- }\r
-\r
- /// <summary>\r
- /// Gets the video quality limits for the given video codec.\r
- /// </summary>\r
- /// <param name="encoder">\r
- /// The video encoder to check.\r
- /// </param>\r
- /// <returns>\r
- /// Limits on the video quality for the encoder.\r
- /// </returns>\r
- public static VideoQualityLimits GetVideoQualityLimits(HBVideoEncoder encoder)\r
- {\r
- float low = 0;\r
- float high = 0;\r
- float granularity = 0;\r
- int direction = 0;\r
-\r
- HBFunctions.hb_video_quality_get_limits((uint)encoder.Id, ref low, ref high, ref granularity, ref direction);\r
-\r
- return new VideoQualityLimits\r
- {\r
- Low = low, \r
- High = high, \r
- Granularity = granularity, \r
- Ascending = direction == 0\r
- };\r
- }\r
-\r
- /// <summary>\r
- /// Sanitizes an audio bitrate given the output codec, sample rate and mixdown.\r
- /// </summary>\r
- /// <param name="audioBitrate">\r
- /// The desired audio bitrate.\r
- /// </param>\r
- /// <param name="encoder">\r
- /// The output encoder to be used.\r
- /// </param>\r
- /// <param name="sampleRate">\r
- /// The output sample rate to be used.\r
- /// </param>\r
- /// <param name="mixdown">\r
- /// The mixdown to be used.\r
- /// </param>\r
- /// <returns>\r
- /// A sanitized audio bitrate.\r
- /// </returns>\r
- public static int SanitizeAudioBitrate(int audioBitrate, HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown)\r
- {\r
- return HBFunctions.hb_audio_bitrate_get_best((uint)encoder.Id, audioBitrate, sampleRate, mixdown.Id);\r
- }\r
-\r
- /// <summary>\r
- /// Gets the default audio bitrate for the given parameters.\r
- /// </summary>\r
- /// <param name="encoder">\r
- /// The encoder to use.\r
- /// </param>\r
- /// <param name="sampleRate">\r
- /// The sample rate to use.\r
- /// </param>\r
- /// <param name="mixdown">\r
- /// The mixdown to use.\r
- /// </param>\r
- /// <returns>\r
- /// The default bitrate for these parameters.\r
- /// </returns>\r
- public static int GetDefaultBitrate(HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown)\r
- {\r
- return HBFunctions.hb_audio_bitrate_get_default((uint) encoder.Id, sampleRate, mixdown.Id);\r
- }\r
-\r
- /// <summary>\r
- /// Gets limits on audio quality for a given encoder.\r
- /// </summary>\r
- /// <param name="encoderId">\r
- /// The audio encoder ID.\r
- /// </param>\r
- /// <returns>\r
- /// Limits on the audio quality for the given encoder.\r
- /// </returns>\r
- internal static RangeLimits GetAudioQualityLimits(int encoderId)\r
- {\r
- float low = 0, high = 0, granularity = 0;\r
- int direction = 0;\r
- HBFunctions.hb_audio_quality_get_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction);\r
-\r
- return new RangeLimits\r
- {\r
- Low = low, \r
- High = high, \r
- Granularity = granularity, \r
- Ascending = direction == 0\r
- };\r
- }\r
-\r
- /// <summary>\r
- /// Gets limits on audio compression for a given encoder.\r
- /// </summary>\r
- /// <param name="encoderId">\r
- /// The audio encoder ID.\r
- /// </param>\r
- /// <returns>\r
- /// Limits on the audio compression for the given encoder.\r
- /// </returns>\r
- internal static RangeLimits GetAudioCompressionLimits(int encoderId)\r
- {\r
- float low = 0, high = 0, granularity = 0;\r
- int direction = 0;\r
- HBFunctions.hb_audio_compression_get_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction);\r
-\r
- return new RangeLimits\r
- {\r
- Low = low, \r
- High = high, \r
- Granularity = granularity, \r
- Ascending = direction == 0\r
- };\r
- }\r
- }\r
+ }\r
+\r
+ return containers;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets a value indicating whether SRT subtitles can be burnt in.\r
+ /// </summary>\r
+ public static bool CanBurnSrt\r
+ {\r
+ get\r
+ {\r
+ return HBFunctions.hb_subtitle_can_burn((int)hb_subtitle_s_subsource.SRTSUB) > 0;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets the audio encoder with the specified short name.\r
+ /// </summary>\r
+ /// <param name="shortName">\r
+ /// The name of the audio encoder.\r
+ /// </param>\r
+ /// <returns>\r
+ /// The requested audio encoder.\r
+ /// </returns>\r
+ public static HBAudioEncoder GetAudioEncoder(string shortName)\r
+ {\r
+ return AudioEncoders.SingleOrDefault(e => e.ShortName == shortName);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets the audio encoder with the specified codec ID.\r
+ /// </summary>\r
+ /// <param name="codecId">\r
+ /// The ID of the audio encoder.\r
+ /// </param>\r
+ /// <returns>\r
+ /// The requested audio encoder.\r
+ /// </returns>\r
+ public static HBAudioEncoder GetAudioEncoder(int codecId)\r
+ {\r
+ return AudioEncoders.SingleOrDefault(e => e.Id == codecId);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets the video encoder with the specified short name.\r
+ /// </summary>\r
+ /// <param name="shortName">\r
+ /// The name of the video encoder.\r
+ /// </param>\r
+ /// <returns>\r
+ /// The requested video encoder.\r
+ /// </returns>\r
+ public static HBVideoEncoder GetVideoEncoder(string shortName)\r
+ {\r
+ return VideoEncoders.SingleOrDefault(e => e.ShortName == shortName);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets the mixdown with the specified short name.\r
+ /// </summary>\r
+ /// <param name="shortName">\r
+ /// The name of the mixdown.\r
+ /// </param>\r
+ /// <returns>\r
+ /// The requested mixdown.\r
+ /// </returns>\r
+ public static HBMixdown GetMixdown(string shortName)\r
+ {\r
+ return Mixdowns.SingleOrDefault(m => m.ShortName == shortName);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets the container with the specified short name.\r
+ /// </summary>\r
+ /// <param name="shortName">\r
+ /// The name of the container.\r
+ /// </param>\r
+ /// <returns>\r
+ /// The requested container.\r
+ /// </returns>\r
+ public static HBContainer GetContainer(string shortName)\r
+ {\r
+ return Containers.SingleOrDefault(c => c.ShortName == shortName);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Determines if the given encoder is compatible with the given track.\r
+ /// </summary>\r
+ /// <param name="track">\r
+ /// The audio track to examine.\r
+ /// </param>\r
+ /// <param name="encoder">\r
+ /// The encoder to examine.\r
+ /// </param>\r
+ /// <returns>\r
+ /// True if the given encoder is comatible with the given audio track.\r
+ /// </returns>\r
+ /// <remarks>\r
+ /// Only works with passthrough encoders.\r
+ /// </remarks>\r
+ public static bool AudioEncoderIsCompatible(AudioTrack track, HBAudioEncoder encoder)\r
+ {\r
+ return (track.CodecId & encoder.Id) > 0;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Determines if the given mixdown supports the given channel layout.\r
+ /// </summary>\r
+ /// <param name="mixdown">\r
+ /// The mixdown to evaluate.\r
+ /// </param>\r
+ /// <param name="layout">\r
+ /// The channel layout to evaluate.\r
+ /// </param>\r
+ /// <returns>\r
+ /// True if the mixdown supports the given channel layout.\r
+ /// </returns>\r
+ public static bool MixdownHasRemixSupport(HBMixdown mixdown, ulong layout)\r
+ {\r
+ return HBFunctions.hb_mixdown_has_remix_support(mixdown.Id, layout) > 0;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Determines if the given encoder supports the given mixdown.\r
+ /// </summary>\r
+ /// <param name="mixdown">\r
+ /// The mixdown to evaluate.\r
+ /// </param>\r
+ /// <param name="encoder">\r
+ /// The encoder to evaluate.\r
+ /// </param>\r
+ /// <returns>\r
+ /// True if the encoder supports the mixdown.\r
+ /// </returns>\r
+ public static bool MixdownHasCodecSupport(HBMixdown mixdown, HBAudioEncoder encoder)\r
+ {\r
+ return HBFunctions.hb_mixdown_has_codec_support(mixdown.Id, (uint) encoder.Id) > 0;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Determines if DRC can be applied to the given track with the given encoder.\r
+ /// </summary>\r
+ /// <param name="track">\r
+ /// The track to apply DRC to.\r
+ /// </param>\r
+ /// <param name="encoder">\r
+ /// The encoder to use for DRC.\r
+ /// </param>\r
+ /// <param name="title">\r
+ /// The title.\r
+ /// </param>\r
+ /// <returns>\r
+ /// True if DRC can be applied to the track with the given encoder.\r
+ /// </returns>\r
+ public static bool CanApplyDrc(AudioTrack track, HBAudioEncoder encoder, int title)\r
+ {\r
+ return HBFunctions.hb_audio_can_apply_drc2(HandBrakeInstanceManager.LastScanHandle, title, track.TrackNumber, encoder.Id) > 0;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Determines if the given input audio codec can be passed through.\r
+ /// </summary>\r
+ /// <param name="codecId">\r
+ /// The input codec to consider.\r
+ /// </param>\r
+ /// <returns>\r
+ /// True if the codec can be passed through.\r
+ /// </returns>\r
+ public static bool CanPassthroughAudio(int codecId)\r
+ {\r
+ return (codecId & NativeConstants.HB_ACODEC_PASS_MASK) > 0;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Sanitizes a mixdown given the output codec and input channel layout.\r
+ /// </summary>\r
+ /// <param name="mixdown">\r
+ /// The desired mixdown.\r
+ /// </param>\r
+ /// <param name="encoder">\r
+ /// The output encoder to be used.\r
+ /// </param>\r
+ /// <param name="layout">\r
+ /// The input channel layout.\r
+ /// </param>\r
+ /// <returns>\r
+ /// A sanitized mixdown value.\r
+ /// </returns>\r
+ public static HBMixdown SanitizeMixdown(HBMixdown mixdown, HBAudioEncoder encoder, ulong layout)\r
+ {\r
+ int sanitizedMixdown = HBFunctions.hb_mixdown_get_best((uint)encoder.Id, layout, mixdown.Id);\r
+ return Mixdowns.Single(m => m.Id == sanitizedMixdown);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets the default mixdown for the given audio encoder and channel layout.\r
+ /// </summary>\r
+ /// <param name="encoder">\r
+ /// The output codec to be used.\r
+ /// </param>\r
+ /// <param name="layout">\r
+ /// The input channel layout.\r
+ /// </param>\r
+ /// <returns>\r
+ /// The default mixdown for the given codec and channel layout.\r
+ /// </returns>\r
+ public static HBMixdown GetDefaultMixdown(HBAudioEncoder encoder, ulong layout)\r
+ {\r
+ int defaultMixdown = HBFunctions.hb_mixdown_get_default((uint)encoder.Id, layout);\r
+ return Mixdowns.Single(m => m.Id == defaultMixdown);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets the bitrate limits for the given audio codec, sample rate and mixdown.\r
+ /// </summary>\r
+ /// <param name="encoder">\r
+ /// The audio encoder used.\r
+ /// </param>\r
+ /// <param name="sampleRate">\r
+ /// The sample rate used (Hz).\r
+ /// </param>\r
+ /// <param name="mixdown">\r
+ /// The mixdown used.\r
+ /// </param>\r
+ /// <returns>\r
+ /// Limits on the audio bitrate for the given settings.\r
+ /// </returns>\r
+ public static BitrateLimits GetBitrateLimits(HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown)\r
+ {\r
+ int low = 0;\r
+ int high = 0;\r
+\r
+ HBFunctions.hb_audio_bitrate_get_limits((uint)encoder.Id, sampleRate, mixdown.Id, ref low, ref high);\r
+\r
+ return new BitrateLimits { Low = low, High = high };\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets the video quality limits for the given video codec.\r
+ /// </summary>\r
+ /// <param name="encoder">\r
+ /// The video encoder to check.\r
+ /// </param>\r
+ /// <returns>\r
+ /// Limits on the video quality for the encoder.\r
+ /// </returns>\r
+ public static VideoQualityLimits GetVideoQualityLimits(HBVideoEncoder encoder)\r
+ {\r
+ float low = 0;\r
+ float high = 0;\r
+ float granularity = 0;\r
+ int direction = 0;\r
+\r
+ HBFunctions.hb_video_quality_get_limits((uint)encoder.Id, ref low, ref high, ref granularity, ref direction);\r
+\r
+ return new VideoQualityLimits\r
+ {\r
+ Low = low, \r
+ High = high, \r
+ Granularity = granularity, \r
+ Ascending = direction == 0\r
+ };\r
+ }\r
+\r
+ /// <summary>\r
+ /// Sanitizes an audio bitrate given the output codec, sample rate and mixdown.\r
+ /// </summary>\r
+ /// <param name="audioBitrate">\r
+ /// The desired audio bitrate.\r
+ /// </param>\r
+ /// <param name="encoder">\r
+ /// The output encoder to be used.\r
+ /// </param>\r
+ /// <param name="sampleRate">\r
+ /// The output sample rate to be used.\r
+ /// </param>\r
+ /// <param name="mixdown">\r
+ /// The mixdown to be used.\r
+ /// </param>\r
+ /// <returns>\r
+ /// A sanitized audio bitrate.\r
+ /// </returns>\r
+ public static int SanitizeAudioBitrate(int audioBitrate, HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown)\r
+ {\r
+ return HBFunctions.hb_audio_bitrate_get_best((uint)encoder.Id, audioBitrate, sampleRate, mixdown.Id);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets the default audio bitrate for the given parameters.\r
+ /// </summary>\r
+ /// <param name="encoder">\r
+ /// The encoder to use.\r
+ /// </param>\r
+ /// <param name="sampleRate">\r
+ /// The sample rate to use.\r
+ /// </param>\r
+ /// <param name="mixdown">\r
+ /// The mixdown to use.\r
+ /// </param>\r
+ /// <returns>\r
+ /// The default bitrate for these parameters.\r
+ /// </returns>\r
+ public static int GetDefaultBitrate(HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown)\r
+ {\r
+ return HBFunctions.hb_audio_bitrate_get_default((uint) encoder.Id, sampleRate, mixdown.Id);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets limits on audio quality for a given encoder.\r
+ /// </summary>\r
+ /// <param name="encoderId">\r
+ /// The audio encoder ID.\r
+ /// </param>\r
+ /// <returns>\r
+ /// Limits on the audio quality for the given encoder.\r
+ /// </returns>\r
+ internal static RangeLimits GetAudioQualityLimits(int encoderId)\r
+ {\r
+ float low = 0, high = 0, granularity = 0;\r
+ int direction = 0;\r
+ HBFunctions.hb_audio_quality_get_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction);\r
+\r
+ return new RangeLimits\r
+ {\r
+ Low = low, \r
+ High = high, \r
+ Granularity = granularity, \r
+ Ascending = direction == 0\r
+ };\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets limits on audio compression for a given encoder.\r
+ /// </summary>\r
+ /// <param name="encoderId">\r
+ /// The audio encoder ID.\r
+ /// </param>\r
+ /// <returns>\r
+ /// Limits on the audio compression for the given encoder.\r
+ /// </returns>\r
+ internal static RangeLimits GetAudioCompressionLimits(int encoderId)\r
+ {\r
+ float low = 0, high = 0, granularity = 0;\r
+ int direction = 0;\r
+ HBFunctions.hb_audio_compression_get_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction);\r
+\r
+ return new RangeLimits\r
+ {\r
+ Low = low, \r
+ High = high, \r
+ Granularity = granularity, \r
+ Ascending = direction == 0\r
+ };\r
+ }\r
+ }\r
}\r
using HandBrake.ApplicationServices.Interop.Model;\r
\r
/// <summary>\r
- /// Contains utilities for converting language codes.\r
- /// </summary>\r
- public static class Languages\r
- {\r
- /// <summary>\r
- /// The list of all languages.\r
- /// </summary>\r
- private static IList<Language> allLanguages; \r
+ /// Contains utilities for converting language codes.\r
+ /// </summary>\r
+ public static class Languages\r
+ {\r
+ /// <summary>\r
+ /// The list of all languages.\r
+ /// </summary>\r
+ private static IList<Language> allLanguages; \r
\r
- /// <summary>\r
- /// Gets a list of all languages.\r
- /// </summary>\r
- public static IList<Language> AllLanguages\r
- {\r
- get\r
- {\r
- return allLanguages\r
- ?? (allLanguages =\r
+ /// <summary>\r
+ /// Gets a list of all languages.\r
+ /// </summary>\r
+ public static IList<Language> AllLanguages\r
+ {\r
+ get\r
+ {\r
+ return allLanguages\r
+ ?? (allLanguages =\r
InteropUtilities.ToListFromIterator<iso639_lang_t, Language>(HBFunctions.lang_get_next, HandBrakeUnitConversionHelpers.NativeToLanguage));\r
- }\r
- }\r
+ }\r
+ }\r
\r
- /// <summary>\r
- /// Gets the language object for the given code.\r
- /// </summary>\r
- /// <param name="code">The ISO-639-2 code for the language.</param>\r
- /// <returns>Object that describes the language.</returns>\r
- public static Language Get(string code)\r
- {\r
- iso639_lang_t language = InteropUtilities.ToStructureFromPtr<iso639_lang_t>(HBFunctions.lang_for_code2(code));\r
+ /// <summary>\r
+ /// Gets the language object for the given code.\r
+ /// </summary>\r
+ /// <param name="code">The ISO-639-2 code for the language.</param>\r
+ /// <returns>Object that describes the language.</returns>\r
+ public static Language Get(string code)\r
+ {\r
+ iso639_lang_t language = InteropUtilities.ToStructureFromPtr<iso639_lang_t>(HBFunctions.lang_for_code2(code));\r
return HandBrakeUnitConversionHelpers.NativeToLanguage(language);\r
- }\r
- }\r
+ }\r
+ }\r
}\r
using HandBrake.ApplicationServices.Interop.Model.Encoding;\r
\r
/// <summary>\r
- /// Converters for various encoding values.\r
- /// </summary>\r
+ /// Converters for various encoding values.\r
+ /// </summary>\r
public static class HandBrakeUnitConversionHelpers\r
- {\r
- /// <summary>\r
- /// Video Frame Rates\r
- /// </summary>\r
- private static readonly Dictionary<double, int> VideoRates;\r
+ {\r
+ /// <summary>\r
+ /// Video Frame Rates\r
+ /// </summary>\r
+ private static readonly Dictionary<double, int> VideoRates;\r
\r
- /// <summary>\r
+ /// <summary>\r
/// Initializes static members of the HandBrakeUnitConversionHelpers class.\r
- /// </summary>\r
+ /// </summary>\r
static HandBrakeUnitConversionHelpers()\r
- {\r
- HandBrakeUtils.EnsureGlobalInit();\r
+ {\r
+ HandBrakeUtils.EnsureGlobalInit();\r
\r
- VideoRates = new Dictionary<double, int>();\r
+ VideoRates = new Dictionary<double, int>();\r
foreach (var framerate in HandBrakeEncoderHelpers.VideoFramerates)\r
- {\r
- VideoRates.Add(double.Parse(framerate.Name, CultureInfo.InvariantCulture), framerate.Rate);\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// Convert Framerate to Video Rates\r
- /// </summary>\r
- /// <param name="framerate">\r
- /// The framerate.\r
- /// </param>\r
- /// <returns>\r
- /// The vrate if a valid framerate is passed in.\r
- /// </returns>\r
- /// <exception cref="ArgumentException">\r
- /// Thrown when framerate is invalid.\r
- /// </exception>\r
- public static int FramerateToVrate(double framerate)\r
- {\r
- if (!VideoRates.ContainsKey(framerate))\r
- {\r
- throw new ArgumentException("Framerate not recognized.", "framerate");\r
- }\r
-\r
- return VideoRates[framerate];\r
- }\r
-\r
- /// <summary>\r
- /// Converts a native HB encoder structure to an Encoder model.\r
- /// </summary>\r
- /// <param name="encoder">\r
- /// The structure to convert.\r
- /// </param>\r
- /// <returns>\r
- /// The converted model.\r
- /// </returns>\r
- public static HBVideoEncoder NativeToVideoEncoder(hb_encoder_s encoder)\r
- {\r
- return new HBVideoEncoder\r
- {\r
- Id = encoder.codec, \r
- ShortName = encoder.short_name, \r
- DisplayName = encoder.name, \r
- CompatibleContainers = encoder.muxers\r
- };\r
- }\r
-\r
- /// <summary>\r
- /// Converts a native HB encoder structure to an Encoder model.\r
- /// </summary>\r
- /// <param name="encoder">\r
- /// The structure to convert.\r
- /// </param>\r
- /// <returns>\r
- /// The converted model.\r
- /// </returns>\r
- public static HBAudioEncoder NativeToAudioEncoder(hb_encoder_s encoder)\r
- {\r
- var result = new HBAudioEncoder\r
- {\r
- Id = encoder.codec, \r
- ShortName = encoder.short_name, \r
- DisplayName = encoder.name, \r
- CompatibleContainers = encoder.muxers,\r
+ {\r
+ VideoRates.Add(double.Parse(framerate.Name, CultureInfo.InvariantCulture), framerate.Rate);\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Convert Framerate to Video Rates\r
+ /// </summary>\r
+ /// <param name="framerate">\r
+ /// The framerate.\r
+ /// </param>\r
+ /// <returns>\r
+ /// The vrate if a valid framerate is passed in.\r
+ /// </returns>\r
+ /// <exception cref="ArgumentException">\r
+ /// Thrown when framerate is invalid.\r
+ /// </exception>\r
+ public static int FramerateToVrate(double framerate)\r
+ {\r
+ if (!VideoRates.ContainsKey(framerate))\r
+ {\r
+ throw new ArgumentException("Framerate not recognized.", "framerate");\r
+ }\r
+\r
+ return VideoRates[framerate];\r
+ }\r
+\r
+ /// <summary>\r
+ /// Converts a native HB encoder structure to an Encoder model.\r
+ /// </summary>\r
+ /// <param name="encoder">\r
+ /// The structure to convert.\r
+ /// </param>\r
+ /// <returns>\r
+ /// The converted model.\r
+ /// </returns>\r
+ public static HBVideoEncoder NativeToVideoEncoder(hb_encoder_s encoder)\r
+ {\r
+ return new HBVideoEncoder\r
+ {\r
+ Id = encoder.codec, \r
+ ShortName = encoder.short_name, \r
+ DisplayName = encoder.name, \r
+ CompatibleContainers = encoder.muxers\r
+ };\r
+ }\r
+\r
+ /// <summary>\r
+ /// Converts a native HB encoder structure to an Encoder model.\r
+ /// </summary>\r
+ /// <param name="encoder">\r
+ /// The structure to convert.\r
+ /// </param>\r
+ /// <returns>\r
+ /// The converted model.\r
+ /// </returns>\r
+ public static HBAudioEncoder NativeToAudioEncoder(hb_encoder_s encoder)\r
+ {\r
+ var result = new HBAudioEncoder\r
+ {\r
+ Id = encoder.codec, \r
+ ShortName = encoder.short_name, \r
+ DisplayName = encoder.name, \r
+ CompatibleContainers = encoder.muxers,\r
QualityLimits = HandBrakeEncoderHelpers.GetAudioQualityLimits(encoder.codec), \r
- DefaultQuality = HBFunctions.hb_audio_quality_get_default((uint)encoder.codec), \r
- CompressionLimits = HandBrakeEncoderHelpers.GetAudioCompressionLimits(encoder.codec), \r
- DefaultCompression =\r
- HBFunctions.hb_audio_compression_get_default((uint)encoder.codec)\r
- };\r
-\r
- return result;\r
- }\r
-\r
- /// <summary>\r
- /// Converts a native HB rate structure to an HBRate object.\r
- /// </summary>\r
- /// <param name="rate">\r
- /// The structure to convert.\r
- /// </param>\r
- /// <returns>\r
- /// The converted rate object.\r
- /// </returns>\r
- public static HBRate NativeToRate(hb_rate_s rate)\r
- {\r
- return new HBRate\r
- {\r
- Name = rate.name, \r
- Rate = rate.rate\r
- };\r
- }\r
-\r
- /// <summary>\r
- /// Converts a native HB mixdown structure to a Mixdown model.\r
- /// </summary>\r
- /// <param name="mixdown">\r
- /// The structure to convert.\r
- /// </param>\r
- /// <returns>\r
- /// The converted model.\r
- /// </returns>\r
- public static HBMixdown NativeToMixdown(hb_mixdown_s mixdown)\r
- {\r
- return new HBMixdown\r
- {\r
- Id = mixdown.amixdown, \r
- ShortName = mixdown.short_name, \r
- DisplayName = mixdown.name\r
- };\r
- }\r
-\r
- /// <summary>\r
- /// Converts a native HB container structure into an HBContainer object.\r
- /// </summary>\r
- /// <param name="container">\r
- /// The structure to convert.\r
- /// </param>\r
- /// <returns>\r
- /// The converted structure.\r
- /// </returns>\r
- public static HBContainer NativeToContainer(hb_container_s container)\r
- {\r
- return new HBContainer\r
- {\r
- DisplayName = container.name, \r
- ShortName = container.short_name, \r
- DefaultExtension = container.default_extension, \r
- Id = container.format\r
- };\r
- }\r
-\r
- /// <summary>\r
- /// Converts a native language structure to a Language object.\r
- /// </summary>\r
- /// <param name="language">\r
- /// The structure to convert.\r
- /// </param>\r
- /// <returns>\r
- /// The converted structure.\r
- /// </returns>\r
- public static Language NativeToLanguage(iso639_lang_t language)\r
- {\r
- string englishName = InteropUtilities.ToStringFromUtf8Ptr(language.eng_name);\r
- string nativeName = InteropUtilities.ToStringFromUtf8Ptr(language.native_name);\r
- return new Language\r
- {\r
- Code = language.iso639_2, \r
- EnglishName = englishName, \r
- NativeName = nativeName\r
- };\r
- }\r
-\r
- /// <summary>\r
- /// Converts the PTS amount to a TimeSpan. There may be some accuracy loss here.\r
- /// </summary>\r
- /// <param name="pts">\r
- /// The PTS to convert.\r
- /// </param>\r
- /// <returns>\r
- /// The timespan for it.\r
- /// </returns>\r
- public static TimeSpan PtsToTimeSpan(ulong pts)\r
- {\r
- return TimeSpan.FromTicks((long)((pts * 10000000) / 90000));\r
- }\r
-\r
- /// <summary>\r
- /// Converts the PTS amount to seconds.\r
- /// </summary>\r
- /// <param name="pts">\r
- /// The PTS to convert.\r
- /// </param>\r
- /// <returns>\r
- /// The corresponding number of seconds.\r
- /// </returns>\r
- public static double PtsToSeconds(ulong pts)\r
- {\r
- return (double)pts / 90000;\r
- }\r
- }\r
+ DefaultQuality = HBFunctions.hb_audio_quality_get_default((uint)encoder.codec), \r
+ CompressionLimits = HandBrakeEncoderHelpers.GetAudioCompressionLimits(encoder.codec), \r
+ DefaultCompression =\r
+ HBFunctions.hb_audio_compression_get_default((uint)encoder.codec)\r
+ };\r
+\r
+ return result;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Converts a native HB rate structure to an HBRate object.\r
+ /// </summary>\r
+ /// <param name="rate">\r
+ /// The structure to convert.\r
+ /// </param>\r
+ /// <returns>\r
+ /// The converted rate object.\r
+ /// </returns>\r
+ public static HBRate NativeToRate(hb_rate_s rate)\r
+ {\r
+ return new HBRate\r
+ {\r
+ Name = rate.name, \r
+ Rate = rate.rate\r
+ };\r
+ }\r
+\r
+ /// <summary>\r
+ /// Converts a native HB mixdown structure to a Mixdown model.\r
+ /// </summary>\r
+ /// <param name="mixdown">\r
+ /// The structure to convert.\r
+ /// </param>\r
+ /// <returns>\r
+ /// The converted model.\r
+ /// </returns>\r
+ public static HBMixdown NativeToMixdown(hb_mixdown_s mixdown)\r
+ {\r
+ return new HBMixdown\r
+ {\r
+ Id = mixdown.amixdown, \r
+ ShortName = mixdown.short_name, \r
+ DisplayName = mixdown.name\r
+ };\r
+ }\r
+\r
+ /// <summary>\r
+ /// Converts a native HB container structure into an HBContainer object.\r
+ /// </summary>\r
+ /// <param name="container">\r
+ /// The structure to convert.\r
+ /// </param>\r
+ /// <returns>\r
+ /// The converted structure.\r
+ /// </returns>\r
+ public static HBContainer NativeToContainer(hb_container_s container)\r
+ {\r
+ return new HBContainer\r
+ {\r
+ DisplayName = container.name, \r
+ ShortName = container.short_name, \r
+ DefaultExtension = container.default_extension, \r
+ Id = container.format\r
+ };\r
+ }\r
+\r
+ /// <summary>\r
+ /// Converts a native language structure to a Language object.\r
+ /// </summary>\r
+ /// <param name="language">\r
+ /// The structure to convert.\r
+ /// </param>\r
+ /// <returns>\r
+ /// The converted structure.\r
+ /// </returns>\r
+ public static Language NativeToLanguage(iso639_lang_t language)\r
+ {\r
+ string englishName = InteropUtilities.ToStringFromUtf8Ptr(language.eng_name);\r
+ string nativeName = InteropUtilities.ToStringFromUtf8Ptr(language.native_name);\r
+ return new Language\r
+ {\r
+ Code = language.iso639_2, \r
+ EnglishName = englishName, \r
+ NativeName = nativeName\r
+ };\r
+ }\r
+\r
+ /// <summary>\r
+ /// Converts the PTS amount to a TimeSpan. There may be some accuracy loss here.\r
+ /// </summary>\r
+ /// <param name="pts">\r
+ /// The PTS to convert.\r
+ /// </param>\r
+ /// <returns>\r
+ /// The timespan for it.\r
+ /// </returns>\r
+ public static TimeSpan PtsToTimeSpan(ulong pts)\r
+ {\r
+ return TimeSpan.FromTicks((long)((pts * 10000000) / 90000));\r
+ }\r
+\r
+ /// <summary>\r
+ /// Converts the PTS amount to seconds.\r
+ /// </summary>\r
+ /// <param name="pts">\r
+ /// The PTS to convert.\r
+ /// </param>\r
+ /// <returns>\r
+ /// The corresponding number of seconds.\r
+ /// </returns>\r
+ public static double PtsToSeconds(ulong pts)\r
+ {\r
+ return (double)pts / 90000;\r
+ }\r
+ }\r
}\r
if (!string.IsNullOrEmpty(message))\r
{\r
// These errors happen in normal operations. Log them as messages.\r
- if (message == "dvd: ifoOpen failed" || message.Contains("avformat_seek_file failed") || message.Contains("nav_get_title_list"))\r
+ if (message == "dvd: ifoOpen failed" || message.Contains("avformat_seek_file failed") || message.Contains("nav_get_title_list"))\r
{\r
SendMessageEvent(message);\r
return;\r
\r
namespace HandBrake.ApplicationServices.Interop.HbLib\r
{\r
- using System.Runtime.InteropServices;\r
+ using System.Runtime.InteropServices;\r
\r
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]\r
- public delegate void LoggingCallback(string message);\r
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]\r
+ public delegate void LoggingCallback(string message);\r
}\r
\r
namespace HandBrake.ApplicationServices.Interop.HbLib\r
{\r
- using System;\r
- using System.Runtime.InteropServices;\r
+ using System;\r
+ using System.Runtime.InteropServices;\r
\r
- /// <summary>\r
- /// Contains p-invoke function declarations to hblib.\r
- /// </summary>\r
- public static class HBFunctions\r
- {\r
- [DllImport("hb.dll", EntryPoint = "hb_register_logger", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern void hb_register_logger(LoggingCallback callback);\r
+ /// <summary>\r
+ /// Contains p-invoke function declarations to hblib.\r
+ /// </summary>\r
+ public static class HBFunctions\r
+ {\r
+ [DllImport("hb.dll", EntryPoint = "hb_register_logger", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern void hb_register_logger(LoggingCallback callback);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_register_error_handler", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern void hb_register_error_handler(LoggingCallback callback);\r
+ [DllImport("hb.dll", EntryPoint = "hb_register_error_handler", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern void hb_register_error_handler(LoggingCallback callback);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_global_init", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern int hb_global_init();\r
+ [DllImport("hb.dll", EntryPoint = "hb_global_init", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern int hb_global_init();\r
\r
- /// Return Type: hb_handle_t*\r
- ///verbose: int\r
- ///update_check: int\r
- [DllImport("hb.dll", EntryPoint = "hb_init", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern IntPtr hb_init(int verbose, int update_check);\r
+ /// Return Type: hb_handle_t*\r
+ ///verbose: int\r
+ ///update_check: int\r
+ [DllImport("hb.dll", EntryPoint = "hb_init", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern IntPtr hb_init(int verbose, int update_check);\r
\r
\r
- /// Return Type: hb_handle_t*\r
- ///verbose: int\r
- ///update_check: int\r
- [DllImport("hb.dll", EntryPoint = "hb_init_dl", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern IntPtr hb_init_dl(int verbose, int update_check);\r
+ /// Return Type: hb_handle_t*\r
+ ///verbose: int\r
+ ///update_check: int\r
+ [DllImport("hb.dll", EntryPoint = "hb_init_dl", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern IntPtr hb_init_dl(int verbose, int update_check);\r
\r
\r
- /// Return Type: char*\r
- ///param0: hb_handle_t*\r
- [DllImport("hb.dll", EntryPoint = "hb_get_version", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern IntPtr hb_get_version(IntPtr hbHandle);\r
+ /// Return Type: char*\r
+ ///param0: hb_handle_t*\r
+ [DllImport("hb.dll", EntryPoint = "hb_get_version", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern IntPtr hb_get_version(IntPtr hbHandle);\r
\r
\r
- /// Return Type: int\r
- ///param0: hb_handle_t*\r
- [DllImport("hb.dll", EntryPoint = "hb_get_build", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern int hb_get_build(IntPtr hbHandle);\r
+ /// Return Type: int\r
+ ///param0: hb_handle_t*\r
+ [DllImport("hb.dll", EntryPoint = "hb_get_build", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern int hb_get_build(IntPtr hbHandle);\r
\r
\r
- /// Return Type: int\r
- ///h: hb_handle_t*\r
- ///version: char**\r
- [DllImport("hb.dll", EntryPoint = "hb_check_update", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern int hb_check_update(IntPtr handle, ref IntPtr version);\r
+ /// Return Type: int\r
+ ///h: hb_handle_t*\r
+ ///version: char**\r
+ [DllImport("hb.dll", EntryPoint = "hb_check_update", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern int hb_check_update(IntPtr handle, ref IntPtr version);\r
\r
\r
- /// Return Type: char*\r
- ///path: char*\r
- [DllImport("hb.dll", EntryPoint = "hb_dvd_name", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern IntPtr hb_dvd_name(IntPtr path);\r
+ /// Return Type: char*\r
+ ///path: char*\r
+ [DllImport("hb.dll", EntryPoint = "hb_dvd_name", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern IntPtr hb_dvd_name(IntPtr path);\r
\r
\r
- /// Return Type: void\r
- ///enable: int\r
- [DllImport("hb.dll", EntryPoint = "hb_dvd_set_dvdnav", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern void hb_dvd_set_dvdnav(int enable);\r
+ /// Return Type: void\r
+ ///enable: int\r
+ [DllImport("hb.dll", EntryPoint = "hb_dvd_set_dvdnav", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern void hb_dvd_set_dvdnav(int enable);\r
\r
\r
- /// Return Type: void\r
- ///param0: hb_handle_t*\r
- ///path: char*\r
- ///title_index: int\r
- ///preview_count: int\r
- ///store_previews: int\r
- [DllImport("hb.dll", EntryPoint = "hb_scan", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern void hb_scan(IntPtr hbHandle, IntPtr path, int title_index, int preview_count, int store_previews, ulong min_duration);\r
+ /// Return Type: void\r
+ ///param0: hb_handle_t*\r
+ ///path: char*\r
+ ///title_index: int\r
+ ///preview_count: int\r
+ ///store_previews: int\r
+ [DllImport("hb.dll", EntryPoint = "hb_scan", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern void hb_scan(IntPtr hbHandle, IntPtr path, int title_index, int preview_count, int store_previews, ulong min_duration);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_scan_stop", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern void hb_scan_stop(IntPtr hbHandle);\r
+ [DllImport("hb.dll", EntryPoint = "hb_scan_stop", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern void hb_scan_stop(IntPtr hbHandle);\r
\r
- /// Return Type: hb_list_t*\r
- ///param0: hb_handle_t*\r
- [DllImport("hb.dll", EntryPoint = "hb_get_titles", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern IntPtr hb_get_titles(IntPtr hbHandle);\r
+ /// Return Type: hb_list_t*\r
+ ///param0: hb_handle_t*\r
+ [DllImport("hb.dll", EntryPoint = "hb_get_titles", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern IntPtr hb_get_titles(IntPtr hbHandle);\r
\r
[DllImport("hb.dll", EntryPoint = "hb_set_anamorphic_size2", CallingConvention = CallingConvention.Cdecl)]\r
public static extern void hb_set_anamorphic_size2(ref hb_geometry_s sourceGeometry, ref hb_geometry_settings_s uiGeometry, ref hb_geometry_s result);\r
\r
\r
- /// Return Type: int\r
- ///param0: hb_handle_t*\r
- [DllImport("hb.dll", EntryPoint = "hb_count", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern int hb_count(IntPtr hbHandle);\r
+ /// Return Type: int\r
+ ///param0: hb_handle_t*\r
+ [DllImport("hb.dll", EntryPoint = "hb_count", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern int hb_count(IntPtr hbHandle);\r
\r
\r
- /// Return Type: hb_job_t*\r
- ///param0: hb_handle_t*\r
- ///param1: int\r
- [DllImport("hb.dll", EntryPoint = "hb_job", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern IntPtr hb_job(IntPtr hbHandle, int jobIndex);\r
+ /// Return Type: hb_job_t*\r
+ ///param0: hb_handle_t*\r
+ ///param1: int\r
+ [DllImport("hb.dll", EntryPoint = "hb_job", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern IntPtr hb_job(IntPtr hbHandle, int jobIndex);\r
\r
- /// Return Type: void\r
- ///param0: hb_handle_t*\r
- ///param1: hb_job_t*\r
- [DllImport("hb.dll", EntryPoint = "hb_rem", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern void hb_rem(IntPtr hbHandle, IntPtr job);\r
+ /// Return Type: void\r
+ ///param0: hb_handle_t*\r
+ ///param1: hb_job_t*\r
+ [DllImport("hb.dll", EntryPoint = "hb_rem", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern void hb_rem(IntPtr hbHandle, IntPtr job);\r
\r
\r
- /// Return Type: void\r
- ///param0: hb_handle_t*\r
- [DllImport("hb.dll", EntryPoint = "hb_start", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern void hb_start(IntPtr hbHandle);\r
+ /// Return Type: void\r
+ ///param0: hb_handle_t*\r
+ [DllImport("hb.dll", EntryPoint = "hb_start", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern void hb_start(IntPtr hbHandle);\r
\r
\r
- /// Return Type: void\r
- ///param0: hb_handle_t*\r
- [DllImport("hb.dll", EntryPoint = "hb_pause", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern void hb_pause(IntPtr hbHandle);\r
+ /// Return Type: void\r
+ ///param0: hb_handle_t*\r
+ [DllImport("hb.dll", EntryPoint = "hb_pause", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern void hb_pause(IntPtr hbHandle);\r
\r
\r
- /// Return Type: void\r
- ///param0: hb_handle_t*\r
- [DllImport("hb.dll", EntryPoint = "hb_resume", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern void hb_resume(IntPtr hbHandle);\r
+ /// Return Type: void\r
+ ///param0: hb_handle_t*\r
+ [DllImport("hb.dll", EntryPoint = "hb_resume", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern void hb_resume(IntPtr hbHandle);\r
\r
\r
- /// Return Type: void\r
- ///param0: hb_handle_t*\r
- [DllImport("hb.dll", EntryPoint = "hb_stop", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern void hb_stop(IntPtr hbHandle);\r
+ /// Return Type: void\r
+ ///param0: hb_handle_t*\r
+ [DllImport("hb.dll", EntryPoint = "hb_stop", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern void hb_stop(IntPtr hbHandle);\r
\r
\r
- /// Return Type: int\r
- ///param0: hb_handle_t*\r
- [DllImport("hb.dll", EntryPoint = "hb_get_scancount", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern int hb_get_scancount(IntPtr hbHandle);\r
+ /// Return Type: int\r
+ ///param0: hb_handle_t*\r
+ [DllImport("hb.dll", EntryPoint = "hb_get_scancount", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern int hb_get_scancount(IntPtr hbHandle);\r
\r
\r
- /// Return Type: void\r
- ///param0: hb_handle_t**\r
- [DllImport("hb.dll", EntryPoint = "hb_close", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern void hb_close(IntPtr hbHandle);\r
+ /// Return Type: void\r
+ ///param0: hb_handle_t**\r
+ [DllImport("hb.dll", EntryPoint = "hb_close", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern void hb_close(IntPtr hbHandle);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_global_close", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern void hb_global_close();\r
+ [DllImport("hb.dll", EntryPoint = "hb_global_close", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern void hb_global_close();\r
\r
- //hb_list_t * hb_list_init();\r
- [DllImport("hb.dll", EntryPoint = "hb_list_init", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern IntPtr hb_list_init();\r
+ //hb_list_t * hb_list_init();\r
+ [DllImport("hb.dll", EntryPoint = "hb_list_init", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern IntPtr hb_list_init();\r
\r
- //int hb_list_count( const hb_list_t * );\r
- [DllImport("hb.dll", EntryPoint = "hb_list_count", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern int hb_list_count(IntPtr listPtr);\r
+ //int hb_list_count( const hb_list_t * );\r
+ [DllImport("hb.dll", EntryPoint = "hb_list_count", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern int hb_list_count(IntPtr listPtr);\r
\r
- //void hb_list_add( hb_list_t *, void * );\r
- [DllImport("hb.dll", EntryPoint = "hb_list_add", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern void hb_list_add(IntPtr listPtr, IntPtr item);\r
+ //void hb_list_add( hb_list_t *, void * );\r
+ [DllImport("hb.dll", EntryPoint = "hb_list_add", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern void hb_list_add(IntPtr listPtr, IntPtr item);\r
\r
- //void hb_list_insert( hb_list_t * l, int pos, void * p );\r
- [DllImport("hb.dll", EntryPoint = "hb_list_insert", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern void hb_list_insert(IntPtr listPtr, int pos, IntPtr item);\r
+ //void hb_list_insert( hb_list_t * l, int pos, void * p );\r
+ [DllImport("hb.dll", EntryPoint = "hb_list_insert", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern void hb_list_insert(IntPtr listPtr, int pos, IntPtr item);\r
\r
- //void hb_list_rem( hb_list_t *, void * );\r
- [DllImport("hb.dll", EntryPoint = "hb_list_rem", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern void hb_list_rem(IntPtr listPtr, IntPtr item);\r
+ //void hb_list_rem( hb_list_t *, void * );\r
+ [DllImport("hb.dll", EntryPoint = "hb_list_rem", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern void hb_list_rem(IntPtr listPtr, IntPtr item);\r
\r
- //void * hb_list_item( const hb_list_t *, int );\r
- [DllImport("hb.dll", EntryPoint = "hb_list_item", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern IntPtr hb_list_item(IntPtr listPtr, int itemIndex);\r
+ //void * hb_list_item( const hb_list_t *, int );\r
+ [DllImport("hb.dll", EntryPoint = "hb_list_item", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern IntPtr hb_list_item(IntPtr listPtr, int itemIndex);\r
\r
- //void hb_list_close( hb_list_t ** );\r
- [DllImport("hb.dll", EntryPoint = "hb_list_close", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern void hb_list_close(IntPtr listPtrPtr);\r
+ //void hb_list_close( hb_list_t ** );\r
+ [DllImport("hb.dll", EntryPoint = "hb_list_close", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern void hb_list_close(IntPtr listPtrPtr);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_subtitle_can_force", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern int hb_subtitle_can_force(int source);\r
+ [DllImport("hb.dll", EntryPoint = "hb_subtitle_can_force", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern int hb_subtitle_can_force(int source);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_subtitle_can_burn", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern int hb_subtitle_can_burn(int source);\r
+ [DllImport("hb.dll", EntryPoint = "hb_subtitle_can_burn", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern int hb_subtitle_can_burn(int source);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_subtitle_can_pass", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern int hb_subtitle_can_pass(int source, int mux);\r
+ [DllImport("hb.dll", EntryPoint = "hb_subtitle_can_pass", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern int hb_subtitle_can_pass(int source, int mux);\r
\r
\r
// int hb_video_framerate_get_from_name(const char *name)\r
//const char* hb_video_framerate_get_name(int framerate);\r
//const char* hb_video_framerate_sanitize_name(const char *name);\r
\r
- // returns hb_rate_s\r
- [DllImport("hb.dll", EntryPoint = "hb_video_framerate_get_next", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern IntPtr hb_video_framerate_get_next(IntPtr last);\r
+ // returns hb_rate_s\r
+ [DllImport("hb.dll", EntryPoint = "hb_video_framerate_get_next", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern IntPtr hb_video_framerate_get_next(IntPtr last);\r
\r
\r
//int hb_audio_samplerate_get_best(uint32_t codec, int samplerate, int *sr_shift);\r
//int hb_audio_samplerate_get_from_name(const char *name);\r
//const char* hb_audio_samplerate_get_name(int samplerate);\r
\r
- // returns hb_rate_s\r
- [DllImport("hb.dll", EntryPoint = "hb_audio_samplerate_get_next", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern IntPtr hb_audio_samplerate_get_next(IntPtr last);\r
+ // returns hb_rate_s\r
+ [DllImport("hb.dll", EntryPoint = "hb_audio_samplerate_get_next", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern IntPtr hb_audio_samplerate_get_next(IntPtr last);\r
\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_audio_bitrate_get_best", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern int hb_audio_bitrate_get_best(uint codec, int bitrate, int samplerate, int mixdown);\r
+ [DllImport("hb.dll", EntryPoint = "hb_audio_bitrate_get_best", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern int hb_audio_bitrate_get_best(uint codec, int bitrate, int samplerate, int mixdown);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_audio_bitrate_get_default", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern int hb_audio_bitrate_get_default(uint codec, int samplerate, int mixdown);\r
+ [DllImport("hb.dll", EntryPoint = "hb_audio_bitrate_get_default", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern int hb_audio_bitrate_get_default(uint codec, int samplerate, int mixdown);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_audio_bitrate_get_limits", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern int hb_audio_bitrate_get_limits(uint codec, int samplerate, int mixdown, ref int low, ref int high);\r
+ [DllImport("hb.dll", EntryPoint = "hb_audio_bitrate_get_limits", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern int hb_audio_bitrate_get_limits(uint codec, int samplerate, int mixdown, ref int low, ref int high);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_audio_bitrate_get_next", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern IntPtr hb_audio_bitrate_get_next(IntPtr last);\r
+ [DllImport("hb.dll", EntryPoint = "hb_audio_bitrate_get_next", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern IntPtr hb_audio_bitrate_get_next(IntPtr last);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_video_quality_get_limits", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern void hb_video_quality_get_limits(uint codec, ref float low, ref float high, ref float granularity, ref int direction);\r
+ [DllImport("hb.dll", EntryPoint = "hb_video_quality_get_limits", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern void hb_video_quality_get_limits(uint codec, ref float low, ref float high, ref float granularity, ref int direction);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_video_quality_get_name", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern IntPtr hb_video_quality_get_name(uint codec);\r
+ [DllImport("hb.dll", EntryPoint = "hb_video_quality_get_name", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern IntPtr hb_video_quality_get_name(uint codec);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_audio_quality_get_limits", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern void hb_audio_quality_get_limits(uint codec, ref float low, ref float high, ref float granularity, ref int direction);\r
+ [DllImport("hb.dll", EntryPoint = "hb_audio_quality_get_limits", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern void hb_audio_quality_get_limits(uint codec, ref float low, ref float high, ref float granularity, ref int direction);\r
\r
//float hb_audio_quality_get_best(uint32_t codec, float quality);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_audio_quality_get_default", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern float hb_audio_quality_get_default(uint codec);\r
+ [DllImport("hb.dll", EntryPoint = "hb_audio_quality_get_default", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern float hb_audio_quality_get_default(uint codec);\r
\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_audio_compression_get_limits", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern void hb_audio_compression_get_limits(uint codec, ref float low, ref float high, ref float granularity, ref int direction);\r
+ [DllImport("hb.dll", EntryPoint = "hb_audio_compression_get_limits", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern void hb_audio_compression_get_limits(uint codec, ref float low, ref float high, ref float granularity, ref int direction);\r
\r
//float hb_audio_compression_get_best(uint32_t codec, float compression);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_audio_compression_get_default", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern float hb_audio_compression_get_default(uint codec);\r
+ [DllImport("hb.dll", EntryPoint = "hb_audio_compression_get_default", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern float hb_audio_compression_get_default(uint codec);\r
\r
\r
//int hb_audio_dither_get_default();\r
[DllImport("hb.dll", EntryPoint = "hb_audio_can_apply_drc2", CallingConvention = CallingConvention.Cdecl)]\r
public static extern int hb_audio_can_apply_drc2(IntPtr handle, int title_index, int audio_index, int encoder);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_mixdown_is_supported", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern int hb_mixdown_is_supported(int mixdown, uint codec, ulong layout);\r
+ [DllImport("hb.dll", EntryPoint = "hb_mixdown_is_supported", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern int hb_mixdown_is_supported(int mixdown, uint codec, ulong layout);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_mixdown_has_codec_support", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern int hb_mixdown_has_codec_support(int mixdown, uint codec);\r
+ [DllImport("hb.dll", EntryPoint = "hb_mixdown_has_codec_support", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern int hb_mixdown_has_codec_support(int mixdown, uint codec);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_mixdown_has_remix_support", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern int hb_mixdown_has_remix_support(int mixdown, ulong layout);\r
+ [DllImport("hb.dll", EntryPoint = "hb_mixdown_has_remix_support", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern int hb_mixdown_has_remix_support(int mixdown, ulong layout);\r
\r
//int hb_mixdown_get_discrete_channel_count(int mixdown);\r
//int hb_mixdown_get_low_freq_channel_count(int mixdown);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_mixdown_get_best", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern int hb_mixdown_get_best(uint codec, ulong layout, int mixdown);\r
+ [DllImport("hb.dll", EntryPoint = "hb_mixdown_get_best", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern int hb_mixdown_get_best(uint codec, ulong layout, int mixdown);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_mixdown_get_default", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern int hb_mixdown_get_default(uint codec, ulong layout);\r
+ [DllImport("hb.dll", EntryPoint = "hb_mixdown_get_default", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern int hb_mixdown_get_default(uint codec, ulong layout);\r
\r
//int hb_mixdown_get_from_name(const char *name);\r
//const char* hb_mixdown_get_name(int mixdown);\r
//const char* hb_mixdown_get_short_name(int mixdown);\r
//const char* hb_mixdown_sanitize_name(const char *name);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_mixdown_get_next", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern IntPtr hb_mixdown_get_next(IntPtr last);\r
+ [DllImport("hb.dll", EntryPoint = "hb_mixdown_get_next", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern IntPtr hb_mixdown_get_next(IntPtr last);\r
\r
//int hb_video_encoder_get_default(int muxer);\r
//int hb_video_encoder_get_from_name(const char *name);\r
//const char* hb_video_encoder_get_long_name(int encoder);\r
//const char* hb_video_encoder_sanitize_name(const char *name);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_video_encoder_get_next", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern IntPtr hb_video_encoder_get_next(IntPtr last);\r
+ [DllImport("hb.dll", EntryPoint = "hb_video_encoder_get_next", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern IntPtr hb_video_encoder_get_next(IntPtr last);\r
\r
/*\r
* hb_audio_encoder_get_fallback_for_passthru() will sanitize a passthru codec\r
//const char* hb_audio_encoder_get_long_name(int encoder);\r
//const char* hb_audio_encoder_sanitize_name(const char *name);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_audio_encoder_get_next", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern IntPtr hb_audio_encoder_get_next(IntPtr last);\r
+ [DllImport("hb.dll", EntryPoint = "hb_audio_encoder_get_next", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern IntPtr hb_audio_encoder_get_next(IntPtr last);\r
\r
//int hb_container_get_from_name(const char *name);\r
//int hb_container_get_from_extension(const char *extension); // not really a container name\r
//const char* hb_container_get_default_extension(int format);\r
//const char* hb_container_sanitize_name(const char *name);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_container_get_from_name", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern int hb_container_get_from_name([In] [MarshalAs(UnmanagedType.LPStr)] string name);\r
+ [DllImport("hb.dll", EntryPoint = "hb_container_get_from_name", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern int hb_container_get_from_name([In] [MarshalAs(UnmanagedType.LPStr)] string name);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_container_get_next", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern IntPtr hb_container_get_next(IntPtr last);\r
+ [DllImport("hb.dll", EntryPoint = "hb_container_get_next", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern IntPtr hb_container_get_next(IntPtr last);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_video_encoder_get_presets", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern IntPtr hb_video_encoder_get_presets(int encoder);\r
+ [DllImport("hb.dll", EntryPoint = "hb_video_encoder_get_presets", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern IntPtr hb_video_encoder_get_presets(int encoder);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_video_encoder_get_tunes", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern IntPtr hb_video_encoder_get_tunes(int encoder);\r
+ [DllImport("hb.dll", EntryPoint = "hb_video_encoder_get_tunes", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern IntPtr hb_video_encoder_get_tunes(int encoder);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_video_encoder_get_profiles", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern IntPtr hb_video_encoder_get_profiles(int encoder);\r
+ [DllImport("hb.dll", EntryPoint = "hb_video_encoder_get_profiles", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern IntPtr hb_video_encoder_get_profiles(int encoder);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_video_encoder_get_levels", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern IntPtr hb_video_encoder_get_levels(int encoder);\r
+ [DllImport("hb.dll", EntryPoint = "hb_video_encoder_get_levels", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern IntPtr hb_video_encoder_get_levels(int encoder);\r
\r
\r
- [DllImport("hb.dll", EntryPoint = "lang_get_next", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern IntPtr lang_get_next(IntPtr last);\r
+ [DllImport("hb.dll", EntryPoint = "lang_get_next", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern IntPtr lang_get_next(IntPtr last);\r
\r
- [DllImport("hb.dll", EntryPoint = "lang_for_code2", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern IntPtr lang_for_code2([In] [MarshalAs(UnmanagedType.LPStr)] string code2);\r
+ [DllImport("hb.dll", EntryPoint = "lang_for_code2", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern IntPtr lang_for_code2([In] [MarshalAs(UnmanagedType.LPStr)] string code2);\r
\r
\r
- ///hb_title_set_t * hb_get_title_set( hb_handle_t * );\r
- [DllImport("hb.dll", EntryPoint = "hb_get_title_set", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern IntPtr hb_get_title_set(IntPtr hbHandle);\r
+ ///hb_title_set_t * hb_get_title_set( hb_handle_t * );\r
+ [DllImport("hb.dll", EntryPoint = "hb_get_title_set", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern IntPtr hb_get_title_set(IntPtr hbHandle);\r
\r
- ///hb_job_t * hb_job_init_by_index( hb_handle_t *h, int title_index );\r
- [DllImport("hb.dll", EntryPoint = "hb_job_init_by_index", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern IntPtr hb_job_init_by_index(IntPtr hbHandle, int title_index);\r
+ ///hb_job_t * hb_job_init_by_index( hb_handle_t *h, int title_index );\r
+ [DllImport("hb.dll", EntryPoint = "hb_job_init_by_index", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern IntPtr hb_job_init_by_index(IntPtr hbHandle, int title_index);\r
\r
- ///void hb_job_close( hb_job_t ** job );\r
- [DllImport("hb.dll", EntryPoint = "hb_job_close", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern void hb_job_close(IntPtr job);\r
+ ///void hb_job_close( hb_job_t ** job );\r
+ [DllImport("hb.dll", EntryPoint = "hb_job_close", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern void hb_job_close(IntPtr job);\r
\r
- ///void hb_chapter_set_title(hb_chapter_t *chapter, const char *title);\r
- [DllImport("hb.dll", EntryPoint = "hb_chapter_set_title", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern void hb_chapter_set_title(IntPtr chapter, [In] [MarshalAs(UnmanagedType.LPStr)] string title);\r
+ ///void hb_chapter_set_title(hb_chapter_t *chapter, const char *title);\r
+ [DllImport("hb.dll", EntryPoint = "hb_chapter_set_title", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern void hb_chapter_set_title(IntPtr chapter, [In] [MarshalAs(UnmanagedType.LPStr)] string title);\r
\r
- ///void hb_chapter_set_title(hb_chapter_t *chapter, const char *title);\r
- [DllImport("hb.dll", EntryPoint = "hb_chapter_set_title", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern void hb_chapter_set_title__ptr(IntPtr chapter, IntPtr title);\r
+ ///void hb_chapter_set_title(hb_chapter_t *chapter, const char *title);\r
+ [DllImport("hb.dll", EntryPoint = "hb_chapter_set_title", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern void hb_chapter_set_title__ptr(IntPtr chapter, IntPtr title);\r
\r
- /// hb_filter_object_t * hb_filter_init( int filter_id );\r
- [DllImport("hb.dll", EntryPoint = "hb_filter_init", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern IntPtr hb_filter_init(int filter_id);\r
+ /// hb_filter_object_t * hb_filter_init( int filter_id );\r
+ [DllImport("hb.dll", EntryPoint = "hb_filter_init", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern IntPtr hb_filter_init(int filter_id);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_generate_filter_settings", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern IntPtr hb_generate_filter_settings(\r
- int filter_id,\r
- [In] [MarshalAs(UnmanagedType.LPStr)] string preset,\r
- [In] [MarshalAs(UnmanagedType.LPStr)] string tune);\r
+ [DllImport("hb.dll", EntryPoint = "hb_generate_filter_settings", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern IntPtr hb_generate_filter_settings(\r
+ int filter_id,\r
+ [In] [MarshalAs(UnmanagedType.LPStr)] string preset,\r
+ [In] [MarshalAs(UnmanagedType.LPStr)] string tune);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_x264_encopt_name", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern IntPtr hb_x264_encopt_name(IntPtr name);\r
+ [DllImport("hb.dll", EntryPoint = "hb_x264_encopt_name", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern IntPtr hb_x264_encopt_name(IntPtr name);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_check_h264_level", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern int hb_check_h264_level([In] [MarshalAs(UnmanagedType.LPStr)] string level, int width, int height, int fps_num, int fps_den, int interlaced, int fake_interlaced);\r
+ [DllImport("hb.dll", EntryPoint = "hb_check_h264_level", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern int hb_check_h264_level([In] [MarshalAs(UnmanagedType.LPStr)] string level, int width, int height, int fps_num, int fps_den, int interlaced, int fake_interlaced);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_x264_param_unparse", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern IntPtr hb_x264_param_unparse(\r
- [In] [MarshalAs(UnmanagedType.LPStr)] string x264_preset,\r
- [In] [MarshalAs(UnmanagedType.LPStr)] string x264_tune,\r
- [In] [MarshalAs(UnmanagedType.LPStr)] string x264_encopts,\r
- [In] [MarshalAs(UnmanagedType.LPStr)] string x264_profile,\r
- [In] [MarshalAs(UnmanagedType.LPStr)] string h264_level,\r
- int width,\r
- int height);\r
+ [DllImport("hb.dll", EntryPoint = "hb_x264_param_unparse", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern IntPtr hb_x264_param_unparse(\r
+ [In] [MarshalAs(UnmanagedType.LPStr)] string x264_preset,\r
+ [In] [MarshalAs(UnmanagedType.LPStr)] string x264_tune,\r
+ [In] [MarshalAs(UnmanagedType.LPStr)] string x264_encopts,\r
+ [In] [MarshalAs(UnmanagedType.LPStr)] string x264_profile,\r
+ [In] [MarshalAs(UnmanagedType.LPStr)] string h264_level,\r
+ int width,\r
+ int height);\r
\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_get_opencl_env", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern int hb_get_opencl_env();\r
+ [DllImport("hb.dll", EntryPoint = "hb_get_opencl_env", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern int hb_get_opencl_env();\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_qsv_available", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern int hb_qsv_available();\r
- \r
- [DllImport("hb.dll", EntryPoint = "hb_qsv_info_init", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern int hb_qsv_info_init();\r
+ [DllImport("hb.dll", EntryPoint = "hb_qsv_available", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern int hb_qsv_available();\r
+ \r
+ [DllImport("hb.dll", EntryPoint = "hb_qsv_info_init", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern int hb_qsv_info_init();\r
\r
// hb_image_t* hb_get_preview2(hb_handle_t* h, int title_idx, int picture, hb_geometry_settings_t* geo, int deinterlace);\r
[DllImport("hb.dll", EntryPoint = "hb_get_preview2", CallingConvention = CallingConvention.Cdecl)]\r
// char* hb_get_preview_params_json(int title_idx, int preview_idx, int deinterlace, hb_geometry_settings_t *settings)\r
[DllImport("hb.dll", EntryPoint = "hb_get_preview_params_json", CallingConvention = CallingConvention.Cdecl)]\r
public static extern IntPtr hb_get_preview_params_json(int title_idx, int preview_idx, int deinterlace, ref hb_geometry_settings_s settings);\r
- }\r
+ }\r
}\r
\r
namespace HandBrake.ApplicationServices.Interop.HbLib\r
{\r
- public class NativeConstants\r
- {\r
- // Audio encoders\r
- public const uint HB_ACODEC_MASK = 0x00FFFF00;\r
- public const uint HB_ACODEC_LAME = 0x00000200;\r
- public const uint HB_ACODEC_VORBIS = 0x00000400;\r
- public const uint HB_ACODEC_AC3 = 0x00000800;\r
- public const uint HB_ACODEC_LPCM = 0x00001000;\r
- public const uint HB_ACODEC_DCA = 0x00002000;\r
- public const uint HB_ACODEC_CA_AAC = 0x00004000;\r
- public const uint HB_ACODEC_CA_HAAC = 0x00008000;\r
- public const uint HB_ACODEC_FFAAC = 0x00010000;\r
- public const uint HB_ACODEC_FFMPEG = 0x00020000;\r
- public const uint HB_ACODEC_DCA_HD = 0x00040000;\r
- public const uint HB_ACODEC_MP3 = 0x00080000;\r
- public const uint HB_ACODEC_FFFLAC = 0x00100000;\r
- public const uint HB_ACODEC_FFFLAC24 = 0x00200000;\r
- public const uint HB_ACODEC_FDK_AAC = 0x00400000;\r
- public const uint HB_ACODEC_FDK_HAAC = 0x00800000;\r
- public const uint HB_ACODEC_FF_MASK = 0x00FF2800;\r
- public const uint HB_ACODEC_PASS_FLAG = 0x40000000;\r
- public const uint HB_ACODEC_PASS_MASK = (HB_ACODEC_MP3 | HB_ACODEC_FFAAC | HB_ACODEC_DCA_HD | HB_ACODEC_AC3 | HB_ACODEC_DCA);\r
- public const uint HB_ACODEC_AUTO_PASS = (HB_ACODEC_PASS_MASK | HB_ACODEC_PASS_FLAG);\r
- public const uint HB_ACODEC_MP3_PASS = (HB_ACODEC_MP3 | HB_ACODEC_PASS_FLAG);\r
- public const uint HB_ACODEC_AAC_PASS = (HB_ACODEC_FFAAC | HB_ACODEC_PASS_FLAG);\r
- public const uint HB_ACODEC_AC3_PASS = (HB_ACODEC_AC3 | HB_ACODEC_PASS_FLAG);\r
- public const uint HB_ACODEC_DCA_PASS = (HB_ACODEC_DCA | HB_ACODEC_PASS_FLAG);\r
- public const uint HB_ACODEC_DCA_HD_PASS = (HB_ACODEC_DCA_HD | HB_ACODEC_PASS_FLAG);\r
- public const uint HB_ACODEC_ANY = (HB_ACODEC_MASK | HB_ACODEC_PASS_FLAG);\r
+ public class NativeConstants\r
+ {\r
+ // Audio encoders\r
+ public const uint HB_ACODEC_MASK = 0x00FFFF00;\r
+ public const uint HB_ACODEC_LAME = 0x00000200;\r
+ public const uint HB_ACODEC_VORBIS = 0x00000400;\r
+ public const uint HB_ACODEC_AC3 = 0x00000800;\r
+ public const uint HB_ACODEC_LPCM = 0x00001000;\r
+ public const uint HB_ACODEC_DCA = 0x00002000;\r
+ public const uint HB_ACODEC_CA_AAC = 0x00004000;\r
+ public const uint HB_ACODEC_CA_HAAC = 0x00008000;\r
+ public const uint HB_ACODEC_FFAAC = 0x00010000;\r
+ public const uint HB_ACODEC_FFMPEG = 0x00020000;\r
+ public const uint HB_ACODEC_DCA_HD = 0x00040000;\r
+ public const uint HB_ACODEC_MP3 = 0x00080000;\r
+ public const uint HB_ACODEC_FFFLAC = 0x00100000;\r
+ public const uint HB_ACODEC_FFFLAC24 = 0x00200000;\r
+ public const uint HB_ACODEC_FDK_AAC = 0x00400000;\r
+ public const uint HB_ACODEC_FDK_HAAC = 0x00800000;\r
+ public const uint HB_ACODEC_FF_MASK = 0x00FF2800;\r
+ public const uint HB_ACODEC_PASS_FLAG = 0x40000000;\r
+ public const uint HB_ACODEC_PASS_MASK = (HB_ACODEC_MP3 | HB_ACODEC_FFAAC | HB_ACODEC_DCA_HD | HB_ACODEC_AC3 | HB_ACODEC_DCA);\r
+ public const uint HB_ACODEC_AUTO_PASS = (HB_ACODEC_PASS_MASK | HB_ACODEC_PASS_FLAG);\r
+ public const uint HB_ACODEC_MP3_PASS = (HB_ACODEC_MP3 | HB_ACODEC_PASS_FLAG);\r
+ public const uint HB_ACODEC_AAC_PASS = (HB_ACODEC_FFAAC | HB_ACODEC_PASS_FLAG);\r
+ public const uint HB_ACODEC_AC3_PASS = (HB_ACODEC_AC3 | HB_ACODEC_PASS_FLAG);\r
+ public const uint HB_ACODEC_DCA_PASS = (HB_ACODEC_DCA | HB_ACODEC_PASS_FLAG);\r
+ public const uint HB_ACODEC_DCA_HD_PASS = (HB_ACODEC_DCA_HD | HB_ACODEC_PASS_FLAG);\r
+ public const uint HB_ACODEC_ANY = (HB_ACODEC_MASK | HB_ACODEC_PASS_FLAG);\r
\r
- // Encode state\r
- public const int HB_STATE_IDLE = 1;\r
- public const int HB_STATE_SCANNING = 2;\r
- public const int HB_STATE_SCANDONE = 4;\r
- public const int HB_STATE_WORKING = 8;\r
- public const int HB_STATE_PAUSED = 16;\r
- public const int HB_STATE_WORKDONE = 32;\r
- public const int HB_STATE_MUXING = 64;\r
- }\r
+ // Encode state\r
+ public const int HB_STATE_IDLE = 1;\r
+ public const int HB_STATE_SCANNING = 2;\r
+ public const int HB_STATE_SCANDONE = 4;\r
+ public const int HB_STATE_WORKING = 8;\r
+ public const int HB_STATE_PAUSED = 16;\r
+ public const int HB_STATE_WORKDONE = 32;\r
+ public const int HB_STATE_MUXING = 64;\r
+ }\r
}\r
\r
namespace HandBrake.ApplicationServices.Interop.HbLib\r
{\r
- using System.Runtime.InteropServices;\r
+ using System.Runtime.InteropServices;\r
\r
- [StructLayout(LayoutKind.Sequential)]\r
+ [StructLayout(LayoutKind.Sequential)]\r
public struct hb_container_s\r
- {\r
- [MarshalAs(UnmanagedType.LPStr)]\r
- public string name;\r
+ {\r
+ [MarshalAs(UnmanagedType.LPStr)]\r
+ public string name;\r
\r
- [MarshalAs(UnmanagedType.LPStr)]\r
- public string short_name;\r
+ [MarshalAs(UnmanagedType.LPStr)]\r
+ public string short_name;\r
\r
- [MarshalAs(UnmanagedType.LPStr)]\r
- public string long_name;\r
+ [MarshalAs(UnmanagedType.LPStr)]\r
+ public string long_name;\r
\r
- [MarshalAs(UnmanagedType.LPStr)]\r
- public string default_extension;\r
+ [MarshalAs(UnmanagedType.LPStr)]\r
+ public string default_extension;\r
\r
- public int format;\r
- }\r
+ public int format;\r
+ }\r
}\r
\r
namespace HandBrake.ApplicationServices.Interop.HbLib\r
{\r
- using System.Runtime.InteropServices;\r
+ using System.Runtime.InteropServices;\r
\r
- [StructLayout(LayoutKind.Sequential)]\r
+ [StructLayout(LayoutKind.Sequential)]\r
public struct hb_encoder_s\r
- {\r
- [MarshalAs(UnmanagedType.LPStr)]\r
- public string name;\r
+ {\r
+ [MarshalAs(UnmanagedType.LPStr)]\r
+ public string name;\r
\r
- [MarshalAs(UnmanagedType.LPStr)]\r
- public string short_name;\r
+ [MarshalAs(UnmanagedType.LPStr)]\r
+ public string short_name;\r
\r
- [MarshalAs(UnmanagedType.LPStr)]\r
- public string long_name;\r
+ [MarshalAs(UnmanagedType.LPStr)]\r
+ public string long_name;\r
\r
- public int codec;\r
+ public int codec;\r
\r
- public int muxers;\r
- }\r
+ public int muxers;\r
+ }\r
}\r
/// The hb_error_code.\r
/// </summary>\r
internal enum hb_error_code\r
- {\r
- HB_ERROR_NONE = 0,\r
- HB_ERROR_CANCELED,\r
- HB_ERROR_WRONG_INPUT,\r
- HB_ERROR_INIT,\r
- HB_ERROR_UNKNOWN\r
- }\r
+ {\r
+ HB_ERROR_NONE = 0,\r
+ HB_ERROR_CANCELED,\r
+ HB_ERROR_WRONG_INPUT,\r
+ HB_ERROR_INIT,\r
+ HB_ERROR_UNKNOWN\r
+ }\r
}\r
namespace HandBrake.ApplicationServices.Interop.HbLib\r
{\r
internal enum hb_filter_ids\r
- {\r
- HB_FILTER_QSV_PRE = 1, // for QSV - important to have before other filters \r
- // First, filters that may change the framerate (drop or dup frames)\r
- HB_FILTER_DETELECINE,\r
- HB_FILTER_DECOMB,\r
- HB_FILTER_DEINTERLACE,\r
- HB_FILTER_VFR,\r
- // Filters that must operate on the original source image are next\r
- HB_FILTER_DEBLOCK,\r
- HB_FILTER_HQDN3D,\r
- HB_FILTER_NLMEANS,\r
- HB_FILTER_RENDER_SUB,\r
- HB_FILTER_CROP_SCALE,\r
- // Finally filters that don't care what order they are in,\r
- // except that they must be after the above filters\r
- HB_FILTER_ROTATE,\r
- HB_FILTER_QSV_POST, // for QSV - important to have as a last one \r
- HB_FILTER_QSV, // default MSDK VPP filter \r
- }\r
+ {\r
+ HB_FILTER_QSV_PRE = 1, // for QSV - important to have before other filters \r
+ // First, filters that may change the framerate (drop or dup frames)\r
+ HB_FILTER_DETELECINE,\r
+ HB_FILTER_DECOMB,\r
+ HB_FILTER_DEINTERLACE,\r
+ HB_FILTER_VFR,\r
+ // Filters that must operate on the original source image are next\r
+ HB_FILTER_DEBLOCK,\r
+ HB_FILTER_HQDN3D,\r
+ HB_FILTER_NLMEANS,\r
+ HB_FILTER_RENDER_SUB,\r
+ HB_FILTER_CROP_SCALE,\r
+ // Finally filters that don't care what order they are in,\r
+ // except that they must be after the above filters\r
+ HB_FILTER_ROTATE,\r
+ HB_FILTER_QSV_POST, // for QSV - important to have as a last one \r
+ HB_FILTER_QSV, // default MSDK VPP filter \r
+ }\r
}\r
\r
namespace HandBrake.ApplicationServices.Interop.HbLib\r
{\r
- using System.Runtime.InteropServices;\r
+ using System.Runtime.InteropServices;\r
\r
- [StructLayout(LayoutKind.Sequential)]\r
- public struct hb_mixdown_s\r
- {\r
- [MarshalAs(UnmanagedType.LPStr)]\r
- public string name;\r
+ [StructLayout(LayoutKind.Sequential)]\r
+ public struct hb_mixdown_s\r
+ {\r
+ [MarshalAs(UnmanagedType.LPStr)]\r
+ public string name;\r
\r
- /// char*\r
- [MarshalAs(UnmanagedType.LPStr)]\r
- public string short_name;\r
+ /// char*\r
+ [MarshalAs(UnmanagedType.LPStr)]\r
+ public string short_name;\r
\r
- /// int\r
- public int amixdown;\r
- }\r
+ /// int\r
+ public int amixdown;\r
+ }\r
}\r
\r
namespace HandBrake.ApplicationServices.Interop.HbLib\r
{\r
- using System.Runtime.InteropServices;\r
+ using System.Runtime.InteropServices;\r
\r
- [StructLayout(LayoutKind.Sequential)]\r
- public struct hb_rate_s\r
- {\r
- /// char*\r
- [MarshalAs(UnmanagedType.LPStr)]\r
- public string name;\r
+ [StructLayout(LayoutKind.Sequential)]\r
+ public struct hb_rate_s\r
+ {\r
+ /// char*\r
+ [MarshalAs(UnmanagedType.LPStr)]\r
+ public string name;\r
\r
- /// int\r
- public int rate;\r
- }\r
+ /// int\r
+ public int rate;\r
+ }\r
}\r
\r
namespace HandBrake.ApplicationServices.Interop.HbLib\r
{\r
- public enum hb_subtitle_s_subsource\r
- {\r
- VOBSUB,\r
+ public enum hb_subtitle_s_subsource\r
+ {\r
+ VOBSUB,\r
\r
- SRTSUB,\r
+ SRTSUB,\r
\r
- CC608SUB,\r
+ CC608SUB,\r
\r
- CC708SUB,\r
+ CC708SUB,\r
\r
- UTF8SUB,\r
+ UTF8SUB,\r
\r
- TX3GSUB,\r
+ TX3GSUB,\r
\r
- SSASUB,\r
+ SSASUB,\r
\r
- PGSSUB\r
- }\r
+ PGSSUB\r
+ }\r
}\r
\r
namespace HandBrake.ApplicationServices.Interop.HbLib\r
{\r
- using System;\r
- using System.Runtime.InteropServices;\r
+ using System;\r
+ using System.Runtime.InteropServices;\r
\r
- [StructLayout(LayoutKind.Sequential)]\r
- public struct iso639_lang_t\r
- {\r
- public IntPtr eng_name;\r
+ [StructLayout(LayoutKind.Sequential)]\r
+ public struct iso639_lang_t\r
+ {\r
+ public IntPtr eng_name;\r
\r
- public IntPtr native_name;\r
+ public IntPtr native_name;\r
\r
- [MarshalAs(UnmanagedType.LPStr)]\r
- public string iso639_1;\r
+ [MarshalAs(UnmanagedType.LPStr)]\r
+ public string iso639_1;\r
\r
- [MarshalAs(UnmanagedType.LPStr)]\r
- public string iso639_2;\r
+ [MarshalAs(UnmanagedType.LPStr)]\r
+ public string iso639_2;\r
\r
- [MarshalAs(UnmanagedType.LPStr)]\r
- public string iso639_2b;\r
- }\r
+ [MarshalAs(UnmanagedType.LPStr)]\r
+ public string iso639_2b;\r
+ }\r
}\r
using HandBrake.ApplicationServices.Interop.HbLib;\r
\r
/// <summary>\r
- /// Helper utilities for native interop.\r
- /// </summary>\r
- internal static class InteropUtilities\r
- {\r
- /// <summary>\r
- /// Reads the given native structure pointer.\r
- /// </summary>\r
- /// <typeparam name="T">The type to convert the structure to.</typeparam>\r
- /// <param name="structPtr">The pointer to the native structure.</param>\r
- /// <returns>The converted structure.</returns>\r
- public static T ToStructureFromPtr<T>(IntPtr structPtr)\r
- {\r
- return (T)Marshal.PtrToStructure(structPtr, typeof(T));\r
- }\r
-\r
- /// <summary>\r
- /// Reads the given native UTF-8 string.\r
- /// </summary>\r
- /// <param name="stringPtr">The pointer to the string.</param>\r
- /// <returns>The resulting string.</returns>\r
- public static string ToStringFromUtf8Ptr(IntPtr stringPtr)\r
- {\r
- var data = new List<byte>();\r
- var ptr = stringPtr;\r
- var offset = 0;\r
- while (true)\r
- {\r
- byte ch = Marshal.ReadByte(ptr, offset++);\r
- if (ch == 0)\r
- {\r
- break;\r
- }\r
-\r
- data.Add(ch);\r
- }\r
-\r
- return Encoding.UTF8.GetString(data.ToArray());\r
- }\r
-\r
- /// <summary>\r
- /// Creates a pointer to a UTF-8 null-terminated string.\r
- /// </summary>\r
- /// <param name="str">\r
- /// The string to encode.\r
- /// </param>\r
- /// <returns>\r
- /// The <see cref="IntPtr"/>.\r
- /// </returns>\r
- public static IntPtr ToUtf8PtrFromString(string str)\r
- {\r
- byte[] bytes = Encoding.UTF8.GetBytes(str);\r
- IntPtr stringPtr = Marshal.AllocHGlobal(bytes.Length + 1);\r
- var offset = 0;\r
- foreach (byte b in bytes)\r
- {\r
- Marshal.WriteByte(stringPtr, offset, b);\r
- offset++;\r
- }\r
-\r
- Marshal.WriteByte(stringPtr, offset, 0);\r
- return stringPtr;\r
- }\r
-\r
- /// <summary>\r
- /// Converts the given native HandBrake list to a managed list.\r
- /// </summary>\r
- /// <typeparam name="T">The type of structure in the list.</typeparam>\r
- /// <param name="listPtr">The pointer to the native list.</param>\r
- /// <returns>The converted managed list.</returns>\r
- public static List<T> ToListFromHandBrakeList<T>(this IntPtr listPtr)\r
- {\r
- List<T> returnList = new List<T>();\r
- NativeList nativeList = new NativeList(listPtr);\r
-\r
- for (int i = 0; i < nativeList.Count; i++)\r
- {\r
- IntPtr itemPtr = nativeList[i];\r
- returnList.Add(ToStructureFromPtr<T>(itemPtr));\r
- }\r
-\r
- return returnList;\r
- }\r
-\r
- /// <summary>\r
- /// Converts the HB list to a managed list of pointers.\r
- /// </summary>\r
- /// <param name="listPtr">The list to convert.</param>\r
- /// <returns>The managed list of pointers.</returns>\r
- public static List<IntPtr> ToIntPtrList(this IntPtr listPtr)\r
- {\r
- var returnList = new List<IntPtr>();\r
- NativeList nativeList = new NativeList(listPtr);\r
-\r
- for (int i = 0; i < nativeList.Count; i++)\r
- {\r
- IntPtr itemPtr = nativeList[i];\r
- returnList.Add(itemPtr);\r
- }\r
-\r
- return returnList;\r
- }\r
-\r
- /// <summary>\r
- /// Converts the given native array to a managed collection.\r
- /// </summary>\r
- /// <typeparam name="T">The type of item in the list.</typeparam>\r
- /// <param name="arrayPtr">The pointer to the array.</param>\r
- /// <param name="count">The number of items in the array.</param>\r
- /// <returns>The converted collection.</returns>\r
- public static List<T> ToListFromNativeArray<T>(IntPtr arrayPtr, int count)\r
- {\r
- IntPtr currentItem = arrayPtr;\r
-\r
- var result = new List<T>();\r
- for (int i = 0; i < count; i++)\r
- {\r
- T nativeEncoder = ToStructureFromPtr<T>(currentItem);\r
- result.Add(nativeEncoder);\r
-\r
- currentItem = IntPtr.Add(currentItem, Marshal.SizeOf(typeof(T)));\r
- }\r
-\r
- return result;\r
- }\r
-\r
- /// <summary>\r
- /// Takes an array pointer and converts it into a list of strings.\r
- /// </summary>\r
- /// <param name="arrayPtr">A pointer to a raw list of strings.</param>\r
- /// <returns>The list of strings.</returns>\r
- public static List<string> ToStringListFromArrayPtr(IntPtr arrayPtr)\r
- {\r
- if (arrayPtr == IntPtr.Zero)\r
- {\r
- return null;\r
- }\r
-\r
- return ToPtrListFromPtr(arrayPtr).Select(ptr => Marshal.PtrToStringAnsi(ptr)).ToList();\r
- }\r
-\r
- /// <summary>\r
- /// Finds all the pointers starting at the given location and puts them in a list. Stops when it finds zero for a pointer.\r
- /// </summary>\r
- /// <param name="arrayPtr">The address of the list of pointers.</param>\r
- /// <returns>The list of pointers.</returns>\r
- public static List<IntPtr> ToPtrListFromPtr(IntPtr arrayPtr)\r
- {\r
- var result = new List<IntPtr>();\r
- int ptrSize = Marshal.SizeOf(typeof(IntPtr));\r
- IntPtr currentPtr = Marshal.ReadIntPtr(arrayPtr);\r
- for (int i = 0; currentPtr != IntPtr.Zero; i++)\r
- {\r
- result.Add(currentPtr);\r
- currentPtr = Marshal.ReadIntPtr(arrayPtr, (i + 1) * ptrSize);\r
- }\r
-\r
- return result;\r
- }\r
-\r
- /// <summary>\r
- /// Creates a native HandBrake list from the given managed list of pointers.\r
- /// </summary>\r
- /// <param name="list">The managed list to convert.</param>\r
- /// <returns>The converted native list.</returns>\r
- public static NativeList ToHandBrakeListFromPtrList(List<IntPtr> list)\r
- {\r
- NativeList returnList = NativeList.CreateList();\r
-\r
- foreach (IntPtr ptr in list)\r
- {\r
- returnList.Add(ptr);\r
- }\r
-\r
- return returnList;\r
- }\r
-\r
- /// <summary>\r
- /// Creates a native HandBrake list from the given managed list of structures.\r
- /// </summary>\r
- /// <typeparam name="T">The type of structures in the list.</typeparam>\r
- /// <param name="list">The managed list to convert.</param>\r
- /// <returns>The converted native list.</returns>\r
- public static NativeList ToHandBrakeListFromList<T>(List<T> list)\r
- {\r
- NativeList returnList = NativeList.CreateList();\r
- foreach (T item in list)\r
- {\r
- IntPtr itemPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(T)));\r
- returnList.AllocatedMemory.Add(itemPtr);\r
- Marshal.StructureToPtr(item, itemPtr, false);\r
-\r
- returnList.Add(itemPtr);\r
- }\r
-\r
- return returnList;\r
- }\r
-\r
- /// <summary>\r
- /// Reads in a list of objects given an interator and a conversion function.\r
- /// </summary>\r
- /// <typeparam name="T1">The type of the struct given by the iterator.</typeparam>\r
- /// <typeparam name="T2">The object type to convert to.</typeparam>\r
- /// <param name="iterator">The iterator to use to build the list.</param>\r
- /// <param name="converter">The converter to convert from the struct to the object.</param>\r
- /// <returns>The list of objects.</returns>\r
- public static List<T2> ToListFromIterator<T1, T2>(Func<IntPtr, IntPtr> iterator, Func<T1, T2> converter)\r
- {\r
- return ToListFromIterator<T1>(iterator).Select(converter).ToList();\r
- } \r
-\r
- /// <summary>\r
- /// Reads in a list of structs given an iterator.\r
- /// </summary>\r
- /// <typeparam name="T">The type of the struct.</typeparam>\r
- /// <param name="iterator">The iterator to use to build the list.</param>\r
- /// <returns>The list of structs.</returns>\r
- public static List<T> ToListFromIterator<T>(Func<IntPtr, IntPtr> iterator)\r
- {\r
- var structureList = new List<T>();\r
- IntPtr current = IntPtr.Zero;\r
-\r
- current = iterator(current);\r
- while (current != IntPtr.Zero)\r
- {\r
- T encoder = ToStructureFromPtr<T>(current);\r
- structureList.Add(encoder);\r
-\r
- current = iterator(current);\r
- }\r
-\r
- return structureList;\r
- }\r
-\r
- /// <summary>\r
- /// Closes the given job.\r
- /// </summary>\r
- /// <param name="nativeJobPtr">The pointer to the job.</param>\r
- public static void CloseJob(IntPtr nativeJobPtr)\r
- {\r
- // Create a point to the job pointer first.\r
- IntPtr nativeJobPtrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)));\r
-\r
- // Assign the new pointer to the job pointer and tell HB to clean the job up.\r
- Marshal.WriteIntPtr(nativeJobPtrPtr, nativeJobPtr);\r
- HBFunctions.hb_job_close(nativeJobPtrPtr);\r
-\r
- // Free the pointer we used.\r
- Marshal.FreeHGlobal(nativeJobPtrPtr);\r
- }\r
-\r
- /// <summary>\r
- /// Frees all the memory locations in the given list.\r
- /// </summary>\r
- /// <param name="memoryList">The list of memory locations to free.</param>\r
- public static void FreeMemory(List<IntPtr> memoryList)\r
- {\r
- foreach (IntPtr memoryLocation in memoryList)\r
- {\r
- Marshal.FreeHGlobal(memoryLocation);\r
- }\r
- }\r
- }\r
+ /// Helper utilities for native interop.\r
+ /// </summary>\r
+ internal static class InteropUtilities\r
+ {\r
+ /// <summary>\r
+ /// Reads the given native structure pointer.\r
+ /// </summary>\r
+ /// <typeparam name="T">The type to convert the structure to.</typeparam>\r
+ /// <param name="structPtr">The pointer to the native structure.</param>\r
+ /// <returns>The converted structure.</returns>\r
+ public static T ToStructureFromPtr<T>(IntPtr structPtr)\r
+ {\r
+ return (T)Marshal.PtrToStructure(structPtr, typeof(T));\r
+ }\r
+\r
+ /// <summary>\r
+ /// Reads the given native UTF-8 string.\r
+ /// </summary>\r
+ /// <param name="stringPtr">The pointer to the string.</param>\r
+ /// <returns>The resulting string.</returns>\r
+ public static string ToStringFromUtf8Ptr(IntPtr stringPtr)\r
+ {\r
+ var data = new List<byte>();\r
+ var ptr = stringPtr;\r
+ var offset = 0;\r
+ while (true)\r
+ {\r
+ byte ch = Marshal.ReadByte(ptr, offset++);\r
+ if (ch == 0)\r
+ {\r
+ break;\r
+ }\r
+\r
+ data.Add(ch);\r
+ }\r
+\r
+ return Encoding.UTF8.GetString(data.ToArray());\r
+ }\r
+\r
+ /// <summary>\r
+ /// Creates a pointer to a UTF-8 null-terminated string.\r
+ /// </summary>\r
+ /// <param name="str">\r
+ /// The string to encode.\r
+ /// </param>\r
+ /// <returns>\r
+ /// The <see cref="IntPtr"/>.\r
+ /// </returns>\r
+ public static IntPtr ToUtf8PtrFromString(string str)\r
+ {\r
+ byte[] bytes = Encoding.UTF8.GetBytes(str);\r
+ IntPtr stringPtr = Marshal.AllocHGlobal(bytes.Length + 1);\r
+ var offset = 0;\r
+ foreach (byte b in bytes)\r
+ {\r
+ Marshal.WriteByte(stringPtr, offset, b);\r
+ offset++;\r
+ }\r
+\r
+ Marshal.WriteByte(stringPtr, offset, 0);\r
+ return stringPtr;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Converts the given native HandBrake list to a managed list.\r
+ /// </summary>\r
+ /// <typeparam name="T">The type of structure in the list.</typeparam>\r
+ /// <param name="listPtr">The pointer to the native list.</param>\r
+ /// <returns>The converted managed list.</returns>\r
+ public static List<T> ToListFromHandBrakeList<T>(this IntPtr listPtr)\r
+ {\r
+ List<T> returnList = new List<T>();\r
+ NativeList nativeList = new NativeList(listPtr);\r
+\r
+ for (int i = 0; i < nativeList.Count; i++)\r
+ {\r
+ IntPtr itemPtr = nativeList[i];\r
+ returnList.Add(ToStructureFromPtr<T>(itemPtr));\r
+ }\r
+\r
+ return returnList;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Converts the HB list to a managed list of pointers.\r
+ /// </summary>\r
+ /// <param name="listPtr">The list to convert.</param>\r
+ /// <returns>The managed list of pointers.</returns>\r
+ public static List<IntPtr> ToIntPtrList(this IntPtr listPtr)\r
+ {\r
+ var returnList = new List<IntPtr>();\r
+ NativeList nativeList = new NativeList(listPtr);\r
+\r
+ for (int i = 0; i < nativeList.Count; i++)\r
+ {\r
+ IntPtr itemPtr = nativeList[i];\r
+ returnList.Add(itemPtr);\r
+ }\r
+\r
+ return returnList;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Converts the given native array to a managed collection.\r
+ /// </summary>\r
+ /// <typeparam name="T">The type of item in the list.</typeparam>\r
+ /// <param name="arrayPtr">The pointer to the array.</param>\r
+ /// <param name="count">The number of items in the array.</param>\r
+ /// <returns>The converted collection.</returns>\r
+ public static List<T> ToListFromNativeArray<T>(IntPtr arrayPtr, int count)\r
+ {\r
+ IntPtr currentItem = arrayPtr;\r
+\r
+ var result = new List<T>();\r
+ for (int i = 0; i < count; i++)\r
+ {\r
+ T nativeEncoder = ToStructureFromPtr<T>(currentItem);\r
+ result.Add(nativeEncoder);\r
+\r
+ currentItem = IntPtr.Add(currentItem, Marshal.SizeOf(typeof(T)));\r
+ }\r
+\r
+ return result;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Takes an array pointer and converts it into a list of strings.\r
+ /// </summary>\r
+ /// <param name="arrayPtr">A pointer to a raw list of strings.</param>\r
+ /// <returns>The list of strings.</returns>\r
+ public static List<string> ToStringListFromArrayPtr(IntPtr arrayPtr)\r
+ {\r
+ if (arrayPtr == IntPtr.Zero)\r
+ {\r
+ return null;\r
+ }\r
+\r
+ return ToPtrListFromPtr(arrayPtr).Select(ptr => Marshal.PtrToStringAnsi(ptr)).ToList();\r
+ }\r
+\r
+ /// <summary>\r
+ /// Finds all the pointers starting at the given location and puts them in a list. Stops when it finds zero for a pointer.\r
+ /// </summary>\r
+ /// <param name="arrayPtr">The address of the list of pointers.</param>\r
+ /// <returns>The list of pointers.</returns>\r
+ public static List<IntPtr> ToPtrListFromPtr(IntPtr arrayPtr)\r
+ {\r
+ var result = new List<IntPtr>();\r
+ int ptrSize = Marshal.SizeOf(typeof(IntPtr));\r
+ IntPtr currentPtr = Marshal.ReadIntPtr(arrayPtr);\r
+ for (int i = 0; currentPtr != IntPtr.Zero; i++)\r
+ {\r
+ result.Add(currentPtr);\r
+ currentPtr = Marshal.ReadIntPtr(arrayPtr, (i + 1) * ptrSize);\r
+ }\r
+\r
+ return result;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Creates a native HandBrake list from the given managed list of pointers.\r
+ /// </summary>\r
+ /// <param name="list">The managed list to convert.</param>\r
+ /// <returns>The converted native list.</returns>\r
+ public static NativeList ToHandBrakeListFromPtrList(List<IntPtr> list)\r
+ {\r
+ NativeList returnList = NativeList.CreateList();\r
+\r
+ foreach (IntPtr ptr in list)\r
+ {\r
+ returnList.Add(ptr);\r
+ }\r
+\r
+ return returnList;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Creates a native HandBrake list from the given managed list of structures.\r
+ /// </summary>\r
+ /// <typeparam name="T">The type of structures in the list.</typeparam>\r
+ /// <param name="list">The managed list to convert.</param>\r
+ /// <returns>The converted native list.</returns>\r
+ public static NativeList ToHandBrakeListFromList<T>(List<T> list)\r
+ {\r
+ NativeList returnList = NativeList.CreateList();\r
+ foreach (T item in list)\r
+ {\r
+ IntPtr itemPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(T)));\r
+ returnList.AllocatedMemory.Add(itemPtr);\r
+ Marshal.StructureToPtr(item, itemPtr, false);\r
+\r
+ returnList.Add(itemPtr);\r
+ }\r
+\r
+ return returnList;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Reads in a list of objects given an interator and a conversion function.\r
+ /// </summary>\r
+ /// <typeparam name="T1">The type of the struct given by the iterator.</typeparam>\r
+ /// <typeparam name="T2">The object type to convert to.</typeparam>\r
+ /// <param name="iterator">The iterator to use to build the list.</param>\r
+ /// <param name="converter">The converter to convert from the struct to the object.</param>\r
+ /// <returns>The list of objects.</returns>\r
+ public static List<T2> ToListFromIterator<T1, T2>(Func<IntPtr, IntPtr> iterator, Func<T1, T2> converter)\r
+ {\r
+ return ToListFromIterator<T1>(iterator).Select(converter).ToList();\r
+ } \r
+\r
+ /// <summary>\r
+ /// Reads in a list of structs given an iterator.\r
+ /// </summary>\r
+ /// <typeparam name="T">The type of the struct.</typeparam>\r
+ /// <param name="iterator">The iterator to use to build the list.</param>\r
+ /// <returns>The list of structs.</returns>\r
+ public static List<T> ToListFromIterator<T>(Func<IntPtr, IntPtr> iterator)\r
+ {\r
+ var structureList = new List<T>();\r
+ IntPtr current = IntPtr.Zero;\r
+\r
+ current = iterator(current);\r
+ while (current != IntPtr.Zero)\r
+ {\r
+ T encoder = ToStructureFromPtr<T>(current);\r
+ structureList.Add(encoder);\r
+\r
+ current = iterator(current);\r
+ }\r
+\r
+ return structureList;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Closes the given job.\r
+ /// </summary>\r
+ /// <param name="nativeJobPtr">The pointer to the job.</param>\r
+ public static void CloseJob(IntPtr nativeJobPtr)\r
+ {\r
+ // Create a point to the job pointer first.\r
+ IntPtr nativeJobPtrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)));\r
+\r
+ // Assign the new pointer to the job pointer and tell HB to clean the job up.\r
+ Marshal.WriteIntPtr(nativeJobPtrPtr, nativeJobPtr);\r
+ HBFunctions.hb_job_close(nativeJobPtrPtr);\r
+\r
+ // Free the pointer we used.\r
+ Marshal.FreeHGlobal(nativeJobPtrPtr);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Frees all the memory locations in the given list.\r
+ /// </summary>\r
+ /// <param name="memoryList">The list of memory locations to free.</param>\r
+ public static void FreeMemory(List<IntPtr> memoryList)\r
+ {\r
+ foreach (IntPtr memoryLocation in memoryList)\r
+ {\r
+ Marshal.FreeHGlobal(memoryLocation);\r
+ }\r
+ }\r
+ }\r
}\r
using HandBrake.ApplicationServices.Interop.HbLib;\r
\r
/// <summary>\r
- /// Represents a HandBrake style native list.\r
- /// </summary>\r
- internal class NativeList : IDisposable\r
- {\r
- /// <summary>\r
- /// Initializes a new instance of the NativeList class.\r
- /// </summary>\r
- /// <param name="listPtr">The pointer to use for the list.</param>\r
- public NativeList(IntPtr listPtr)\r
- {\r
- this.Ptr = listPtr;\r
- }\r
+ /// Represents a HandBrake style native list.\r
+ /// </summary>\r
+ internal class NativeList : IDisposable\r
+ {\r
+ /// <summary>\r
+ /// Initializes a new instance of the NativeList class.\r
+ /// </summary>\r
+ /// <param name="listPtr">The pointer to use for the list.</param>\r
+ public NativeList(IntPtr listPtr)\r
+ {\r
+ this.Ptr = listPtr;\r
+ }\r
\r
- /// <summary>\r
- /// The list of native memory locations allocated for this list.\r
- /// </summary>\r
- private readonly List<IntPtr> allocatedMemory = new List<IntPtr>();\r
+ /// <summary>\r
+ /// The list of native memory locations allocated for this list.\r
+ /// </summary>\r
+ private readonly List<IntPtr> allocatedMemory = new List<IntPtr>();\r
\r
- /// <summary>\r
- /// Gets the pointer to the native list.\r
- /// </summary>\r
- public IntPtr Ptr { get; private set; }\r
+ /// <summary>\r
+ /// Gets the pointer to the native list.\r
+ /// </summary>\r
+ public IntPtr Ptr { get; private set; }\r
\r
- /// <summary>\r
- /// Gets the number of items in the list.\r
- /// </summary>\r
- public int Count\r
- {\r
- get\r
+ /// <summary>\r
+ /// Gets the number of items in the list.\r
+ /// </summary>\r
+ public int Count\r
+ {\r
+ get\r
{\r
Debug.WriteLine("Got a Zero Pointer in the NativeList");\r
return this.Ptr == IntPtr.Zero ? 0 : HBFunctions.hb_list_count(this.Ptr);\r
- }\r
- }\r
+ }\r
+ }\r
\r
- /// <summary>\r
- /// Gets the list of native memory locations allocated for this list.\r
- /// </summary>\r
- public List<IntPtr> AllocatedMemory\r
- {\r
- get\r
- {\r
- return this.allocatedMemory;\r
- }\r
- }\r
+ /// <summary>\r
+ /// Gets the list of native memory locations allocated for this list.\r
+ /// </summary>\r
+ public List<IntPtr> AllocatedMemory\r
+ {\r
+ get\r
+ {\r
+ return this.allocatedMemory;\r
+ }\r
+ }\r
\r
- /// <summary>\r
- /// Adds an item to the end of the list.\r
- /// </summary>\r
- /// <param name="item">The item to add.</param>\r
- public void Add(IntPtr item)\r
- {\r
- HBFunctions.hb_list_add(this.Ptr, item);\r
- }\r
+ /// <summary>\r
+ /// Adds an item to the end of the list.\r
+ /// </summary>\r
+ /// <param name="item">The item to add.</param>\r
+ public void Add(IntPtr item)\r
+ {\r
+ HBFunctions.hb_list_add(this.Ptr, item);\r
+ }\r
\r
- /// <summary>\r
- /// Inserts an item into the list.\r
- /// </summary>\r
- /// <param name="position">The index to insert the item at.</param>\r
- /// <param name="item">The item to insert.</param>\r
- public void Insert(int position, IntPtr item)\r
- {\r
- HBFunctions.hb_list_insert(this.Ptr, position, item);\r
- }\r
+ /// <summary>\r
+ /// Inserts an item into the list.\r
+ /// </summary>\r
+ /// <param name="position">The index to insert the item at.</param>\r
+ /// <param name="item">The item to insert.</param>\r
+ public void Insert(int position, IntPtr item)\r
+ {\r
+ HBFunctions.hb_list_insert(this.Ptr, position, item);\r
+ }\r
\r
- /// <summary>\r
- /// Removes an item from the list.\r
- /// </summary>\r
- /// <param name="item">The item to remove.</param>\r
- public void Remove(IntPtr item)\r
- {\r
- HBFunctions.hb_list_rem(this.Ptr, item);\r
- }\r
+ /// <summary>\r
+ /// Removes an item from the list.\r
+ /// </summary>\r
+ /// <param name="item">The item to remove.</param>\r
+ public void Remove(IntPtr item)\r
+ {\r
+ HBFunctions.hb_list_rem(this.Ptr, item);\r
+ }\r
\r
- /// <summary>\r
- /// Gets an item out of the list.\r
- /// </summary>\r
- /// <param name="i">Index in the list.</param>\r
- /// <returns>The item at that index in the list.</returns>\r
- public IntPtr this[int i]\r
- {\r
- get\r
- {\r
- return HBFunctions.hb_list_item(this.Ptr, i);\r
- }\r
- }\r
+ /// <summary>\r
+ /// Gets an item out of the list.\r
+ /// </summary>\r
+ /// <param name="i">Index in the list.</param>\r
+ /// <returns>The item at that index in the list.</returns>\r
+ public IntPtr this[int i]\r
+ {\r
+ get\r
+ {\r
+ return HBFunctions.hb_list_item(this.Ptr, i);\r
+ }\r
+ }\r
\r
- /// <summary>\r
- /// Disposes resources associated with this object.\r
- /// </summary>\r
- public void Dispose()\r
- {\r
- IntPtr listPtrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)));\r
- Marshal.WriteIntPtr(listPtrPtr, this.Ptr);\r
- HBFunctions.hb_list_close(listPtrPtr);\r
- Marshal.FreeHGlobal(listPtrPtr);\r
- }\r
+ /// <summary>\r
+ /// Disposes resources associated with this object.\r
+ /// </summary>\r
+ public void Dispose()\r
+ {\r
+ IntPtr listPtrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)));\r
+ Marshal.WriteIntPtr(listPtrPtr, this.Ptr);\r
+ HBFunctions.hb_list_close(listPtrPtr);\r
+ Marshal.FreeHGlobal(listPtrPtr);\r
+ }\r
\r
- /// <summary>\r
- /// Creates a new list in unmanaged memory.\r
- /// </summary>\r
- /// <returns>The created list.</returns>\r
- public static NativeList CreateList()\r
- {\r
- return new NativeList(HBFunctions.hb_list_init());\r
- }\r
- }\r
+ /// <summary>\r
+ /// Creates a new list in unmanaged memory.\r
+ /// </summary>\r
+ /// <returns>The created list.</returns>\r
+ public static NativeList CreateList()\r
+ {\r
+ return new NativeList(HBFunctions.hb_list_init());\r
+ }\r
+ }\r
}\r
/// The utilities.\r
/// </summary>\r
internal static class Utilities\r
- {\r
+ {\r
/// <summary>\r
/// Get the Greatest Common Factor\r
/// </summary>\r
/// The greatest common factor\r
/// </returns>\r
public static int GreatestCommonFactor(int a, int b)\r
- {\r
- if (a == 0)\r
- {\r
- return b;\r
- }\r
+ {\r
+ if (a == 0)\r
+ {\r
+ return b;\r
+ }\r
\r
- if (b == 0)\r
- {\r
- return a;\r
- }\r
+ if (b == 0)\r
+ {\r
+ return a;\r
+ }\r
\r
- if (a > b)\r
- {\r
- return GreatestCommonFactor(a % b, b);\r
- }\r
+ if (a > b)\r
+ {\r
+ return GreatestCommonFactor(a % b, b);\r
+ }\r
\r
return GreatestCommonFactor(a, b % a);\r
- }\r
- }\r
+ }\r
+ }\r
}\r
\r
namespace HandBrake.ApplicationServices.Interop.Model\r
{\r
- /// <summary>\r
- /// Represents bitrate limits as a range.\r
- /// </summary>\r
- public class BitrateLimits\r
- {\r
- /// <summary>\r
- /// The inclusive lower limit for the bitrate.\r
- /// </summary>\r
- public int Low { get; set; }\r
+ /// <summary>\r
+ /// Represents bitrate limits as a range.\r
+ /// </summary>\r
+ public class BitrateLimits\r
+ {\r
+ /// <summary>\r
+ /// The inclusive lower limit for the bitrate.\r
+ /// </summary>\r
+ public int Low { get; set; }\r
\r
- /// <summary>\r
- /// The inclusive upper limit for the bitrate.\r
- /// </summary>\r
- public int High { get; set; }\r
- }\r
+ /// <summary>\r
+ /// The inclusive upper limit for the bitrate.\r
+ /// </summary>\r
+ public int High { get; set; }\r
+ }\r
}\r
/// The Cropping Model\r
/// </summary>\r
public class Cropping\r
- {\r
+ {\r
/// <summary>\r
/// Initializes a new instance of the <see cref="Cropping"/> class. \r
/// </summary>\r
/// A Cloned copy\r
/// </returns>\r
public Cropping Clone()\r
- {\r
- return new Cropping\r
- {\r
- Top = this.Top,\r
- Bottom = this.Bottom,\r
- Left = this.Left,\r
- Right = this.Right\r
- };\r
- }\r
- }\r
+ {\r
+ return new Cropping\r
+ {\r
+ Top = this.Top,\r
+ Bottom = this.Bottom,\r
+ Left = this.Left,\r
+ Right = this.Right\r
+ };\r
+ }\r
+ }\r
}\r
using HandBrake.ApplicationServices.Interop.Model.Encoding;\r
\r
/// <summary>\r
- /// The encode job.\r
- /// </summary>\r
- public class EncodeJob\r
- {\r
- /// <summary>\r
- /// Initializes a new instance of the <see cref="EncodeJob"/> class.\r
- /// </summary>\r
- public EncodeJob()\r
- {\r
+ /// The encode job.\r
+ /// </summary>\r
+ public class EncodeJob\r
+ {\r
+ /// <summary>\r
+ /// Initializes a new instance of the <see cref="EncodeJob"/> class.\r
+ /// </summary>\r
+ public EncodeJob()\r
+ {\r
this.Cropping = new Cropping();\r
- }\r
+ }\r
\r
#region Source\r
\r
#region Public Methods\r
\r
/// <summary>\r
- /// The clone.\r
- /// </summary>\r
- /// <returns>\r
- /// The <see cref="EncodeJob"/>.\r
- /// </returns>\r
- public EncodeJob Clone()\r
- {\r
- var clone = new EncodeJob\r
- {\r
- SourceType = this.SourceType, \r
- SourcePath = this.SourcePath, \r
- Title = this.Title, \r
- Angle = this.Angle, \r
- RangeType = this.RangeType, \r
- ChapterStart = this.ChapterStart, \r
- ChapterEnd = this.ChapterEnd, \r
- SecondsStart = this.SecondsStart, \r
- SecondsEnd = this.SecondsEnd, \r
- FramesStart = this.FramesStart, \r
- FramesEnd = this.FramesEnd, \r
- Subtitles = this.Subtitles, \r
- UseDefaultChapterNames = this.UseDefaultChapterNames, \r
- DxvaDecoding = this.DxvaDecoding, \r
- OutputPath = this.OutputPath, \r
+ /// The clone.\r
+ /// </summary>\r
+ /// <returns>\r
+ /// The <see cref="EncodeJob"/>.\r
+ /// </returns>\r
+ public EncodeJob Clone()\r
+ {\r
+ var clone = new EncodeJob\r
+ {\r
+ SourceType = this.SourceType, \r
+ SourcePath = this.SourcePath, \r
+ Title = this.Title, \r
+ Angle = this.Angle, \r
+ RangeType = this.RangeType, \r
+ ChapterStart = this.ChapterStart, \r
+ ChapterEnd = this.ChapterEnd, \r
+ SecondsStart = this.SecondsStart, \r
+ SecondsEnd = this.SecondsEnd, \r
+ FramesStart = this.FramesStart, \r
+ FramesEnd = this.FramesEnd, \r
+ Subtitles = this.Subtitles, \r
+ UseDefaultChapterNames = this.UseDefaultChapterNames, \r
+ DxvaDecoding = this.DxvaDecoding, \r
+ OutputPath = this.OutputPath, \r
\r
ContainerName = this.ContainerName, \r
PreferredExtension = this.PreferredExtension, \r
\r
AudioEncodings = new List<AudioEncoding>(this.AudioEncodings), \r
AudioEncoderFallback = this.AudioEncoderFallback\r
- };\r
+ };\r
\r
- return clone;\r
- }\r
+ return clone;\r
+ }\r
\r
- #endregion\r
- }\r
+ #endregion\r
+ }\r
}
\ No newline at end of file
\r
namespace HandBrake.ApplicationServices.Interop.Model.Encoding\r
{\r
- using System.ComponentModel.DataAnnotations;\r
+ using System.ComponentModel.DataAnnotations;\r
\r
/// <summary>\r
/// The anamorphic.\r
/// </summary>\r
public enum Anamorphic\r
- {\r
- [Display(Name = "None")]\r
- None = 0,\r
- [Display(Name = "Strict")]\r
- Strict = 1,\r
- [Display(Name = "Loose")]\r
- Loose = 2,\r
- [Display(Name = "Custom")]\r
- Custom = 3\r
- }\r
+ {\r
+ [Display(Name = "None")]\r
+ None = 0,\r
+ [Display(Name = "Strict")]\r
+ Strict = 1,\r
+ [Display(Name = "Loose")]\r
+ Loose = 2,\r
+ [Display(Name = "Custom")]\r
+ Custom = 3\r
+ }\r
}
\ No newline at end of file
/// The audio encode rate type.\r
/// </summary>\r
public enum AudioEncodeRateType\r
- {\r
- Bitrate,\r
- Quality,\r
+ {\r
+ Bitrate,\r
+ Quality,\r
Compression\r
- }\r
+ }\r
}\r
\r
namespace HandBrake.ApplicationServices.Interop.Model.Encoding\r
{\r
- using System;\r
+ using System;\r
\r
- /// <summary>\r
- /// The Audio Encoding Model\r
- /// </summary>\r
- public class AudioEncoding\r
- {\r
- /// <summary>\r
- /// Initializes a new instance of the AudioEncoding class.\r
- /// </summary>\r
- public AudioEncoding()\r
- {\r
- // Initialize to -1 to differentiate a compression of 0 from uninitialized.\r
- this.Compression = -1;\r
- }\r
+ /// <summary>\r
+ /// The Audio Encoding Model\r
+ /// </summary>\r
+ public class AudioEncoding\r
+ {\r
+ /// <summary>\r
+ /// Initializes a new instance of the AudioEncoding class.\r
+ /// </summary>\r
+ public AudioEncoding()\r
+ {\r
+ // Initialize to -1 to differentiate a compression of 0 from uninitialized.\r
+ this.Compression = -1;\r
+ }\r
\r
- /// <summary>\r
- /// Gets or sets the chosen track to apply the encoding to.\r
- /// </summary>\r
- /// <remarks>1-based index. 0 means apply to all tracks.</remarks>\r
- public int InputNumber { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets the chosen track to apply the encoding to.\r
+ /// </summary>\r
+ /// <remarks>1-based index. 0 means apply to all tracks.</remarks>\r
+ public int InputNumber { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the encoder to use.\r
- /// </summary>\r
- public string Encoder { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets the encoder to use.\r
+ /// </summary>\r
+ public string Encoder { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the encode rate type (bitrate or quality).\r
- /// </summary>\r
- public AudioEncodeRateType EncodeRateType { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets the encode rate type (bitrate or quality).\r
+ /// </summary>\r
+ public AudioEncodeRateType EncodeRateType { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the bitrate (in kbps) of this track.\r
- /// </summary>\r
- public int Bitrate { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets the bitrate (in kbps) of this track.\r
+ /// </summary>\r
+ public int Bitrate { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the target audio quality for this track.\r
- /// </summary>\r
- public float Quality { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets the target audio quality for this track.\r
+ /// </summary>\r
+ public float Quality { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the target audio compression for this track.\r
- /// </summary>\r
- public float Compression { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets the target audio compression for this track.\r
+ /// </summary>\r
+ public float Compression { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the mixdown.\r
- /// </summary>\r
- public string Mixdown { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets the mixdown.\r
+ /// </summary>\r
+ public string Mixdown { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the sample rate in Hz.\r
- /// </summary>\r
- public int SampleRateRaw { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets the sample rate in Hz.\r
+ /// </summary>\r
+ public int SampleRateRaw { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets Gain.\r
- /// </summary>\r
- public int Gain { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets Gain.\r
+ /// </summary>\r
+ public int Gain { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets Drc.\r
- /// </summary>\r
- public double Drc { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets Drc.\r
+ /// </summary>\r
+ public double Drc { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets Name.\r
- /// </summary>\r
- public string Name { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets Name.\r
+ /// </summary>\r
+ public string Name { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets a value indicating whether is passthru.\r
- /// </summary>\r
- public bool IsPassthru { get; set; }\r
- }\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether is passthru.\r
+ /// </summary>\r
+ public bool IsPassthru { get; set; }\r
+ }\r
}\r
\r
namespace HandBrake.ApplicationServices.Interop.Model.Encoding\r
{\r
- using System;\r
- using System.ComponentModel.DataAnnotations;\r
+ using System;\r
+ using System.ComponentModel.DataAnnotations;\r
\r
/// <summary>\r
/// The container.\r
/// </summary>\r
[Flags]\r
- public enum Container\r
- {\r
- None = 0x0,\r
+ public enum Container\r
+ {\r
+ None = 0x0,\r
\r
- [Display(Name = "MP4")]\r
- MP4,\r
- [Display(Name = "MKV")]\r
- MKV\r
- }\r
+ [Display(Name = "MP4")]\r
+ MP4,\r
+ [Display(Name = "MKV")]\r
+ MKV\r
+ }\r
}\r
/// The decomb.\r
/// </summary>\r
public enum Decomb\r
- {\r
- Off = 0,\r
- Default = 2,\r
- Fast = 3,\r
- Bob = 4,\r
- Custom = 1\r
- }\r
+ {\r
+ Off = 0,\r
+ Default = 2,\r
+ Fast = 3,\r
+ Bob = 4,\r
+ Custom = 1\r
+ }\r
}\r
/// The deinterlace.\r
/// </summary>\r
public enum Deinterlace\r
- {\r
- Off = 0,\r
- Fast = 2,\r
- Slow = 3,\r
- Slower = 4,\r
- Bob = 5,\r
- Custom = 1\r
- }\r
+ {\r
+ Off = 0,\r
+ Fast = 2,\r
+ Slow = 3,\r
+ Slower = 4,\r
+ Bob = 5,\r
+ Custom = 1\r
+ }\r
}\r
/// The denoise.\r
/// </summary>\r
public enum Denoise\r
- {\r
- Off = 0,\r
+ {\r
+ Off = 0,\r
hqdn3d = 1,\r
- NLMeans = 2,\r
- }\r
+ NLMeans = 2,\r
+ }\r
}\r
/// The detelecine.\r
/// </summary>\r
public enum Detelecine\r
- {\r
- Off = 0,\r
- Default = 2,\r
- Custom = 1\r
- }\r
+ {\r
+ Off = 0,\r
+ Default = 2,\r
+ Custom = 1\r
+ }\r
}\r
\r
namespace HandBrake.ApplicationServices.Interop.Model.Encoding\r
{\r
- /// <summary>\r
- /// Represents a rate in HandBrake: audio sample rate or video framerate.\r
- /// </summary>\r
- public class HBRate\r
- {\r
- /// <summary>\r
- /// Gets or sets the name to use for this rate.\r
- /// </summary>\r
- public string Name { get; set; }\r
+ /// <summary>\r
+ /// Represents a rate in HandBrake: audio sample rate or video framerate.\r
+ /// </summary>\r
+ public class HBRate\r
+ {\r
+ /// <summary>\r
+ /// Gets or sets the name to use for this rate.\r
+ /// </summary>\r
+ public string Name { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the raw rate.\r
- /// </summary>\r
- public int Rate { get; set; }\r
- }\r
+ /// <summary>\r
+ /// Gets or sets the raw rate.\r
+ /// </summary>\r
+ public int Rate { get; set; }\r
+ }\r
}\r
\r
namespace HandBrake.ApplicationServices.Interop.Model.Encoding\r
{\r
- using System.Collections.Generic;\r
+ using System.Collections.Generic;\r
\r
- using HandBrake.ApplicationServices.Interop.HbLib;\r
- using HandBrake.ApplicationServices.Interop.Helpers;\r
+ using HandBrake.ApplicationServices.Interop.HbLib;\r
+ using HandBrake.ApplicationServices.Interop.Helpers;\r
\r
- /// <summary>\r
+ /// <summary>\r
/// The hb video encoder.\r
/// </summary>\r
public class HBVideoEncoder\r
/// </summary>\r
public string ShortName { get; set; }\r
\r
- /// <summary>\r
- /// Gets the list of presets this encoder supports. (null if the encoder doesn't support presets)\r
- /// </summary>\r
- public List<string> Presets\r
- {\r
- get\r
- {\r
- return InteropUtilities.ToStringListFromArrayPtr(HBFunctions.hb_video_encoder_get_presets(this.Id));\r
- }\r
- }\r
+ /// <summary>\r
+ /// Gets the list of presets this encoder supports. (null if the encoder doesn't support presets)\r
+ /// </summary>\r
+ public List<string> Presets\r
+ {\r
+ get\r
+ {\r
+ return InteropUtilities.ToStringListFromArrayPtr(HBFunctions.hb_video_encoder_get_presets(this.Id));\r
+ }\r
+ }\r
\r
- /// <summary>\r
- /// Gets the list of tunes this encoder supports. (null if the encoder doesn't support tunes)\r
- /// </summary>\r
- public List<string> Tunes\r
- {\r
- get\r
- {\r
- return InteropUtilities.ToStringListFromArrayPtr(HBFunctions.hb_video_encoder_get_tunes(this.Id));\r
- }\r
- }\r
+ /// <summary>\r
+ /// Gets the list of tunes this encoder supports. (null if the encoder doesn't support tunes)\r
+ /// </summary>\r
+ public List<string> Tunes\r
+ {\r
+ get\r
+ {\r
+ return InteropUtilities.ToStringListFromArrayPtr(HBFunctions.hb_video_encoder_get_tunes(this.Id));\r
+ }\r
+ }\r
\r
- /// <summary>\r
- /// Gets the list of profiles this encoder supports. (null if the encoder doesn't support profiles)\r
- /// </summary>\r
- public List<string> Profiles\r
- {\r
- get\r
- {\r
- return InteropUtilities.ToStringListFromArrayPtr(HBFunctions.hb_video_encoder_get_profiles(this.Id));\r
- }\r
- }\r
+ /// <summary>\r
+ /// Gets the list of profiles this encoder supports. (null if the encoder doesn't support profiles)\r
+ /// </summary>\r
+ public List<string> Profiles\r
+ {\r
+ get\r
+ {\r
+ return InteropUtilities.ToStringListFromArrayPtr(HBFunctions.hb_video_encoder_get_profiles(this.Id));\r
+ }\r
+ }\r
\r
- /// <summary>\r
- /// Gets the list of levels this encoder supports. (null if the encoder doesn't support levels)\r
- /// </summary>\r
- public List<string> Levels\r
- {\r
- get\r
- {\r
- return InteropUtilities.ToStringListFromArrayPtr(HBFunctions.hb_video_encoder_get_levels(this.Id));\r
- }\r
- } \r
+ /// <summary>\r
+ /// Gets the list of levels this encoder supports. (null if the encoder doesn't support levels)\r
+ /// </summary>\r
+ public List<string> Levels\r
+ {\r
+ get\r
+ {\r
+ return InteropUtilities.ToStringListFromArrayPtr(HBFunctions.hb_video_encoder_get_levels(this.Id));\r
+ }\r
+ } \r
}\r
}
\ No newline at end of file
\r
namespace HandBrake.ApplicationServices.Interop.Model.Encoding\r
{\r
- using System.ComponentModel.DataAnnotations;\r
+ using System.ComponentModel.DataAnnotations;\r
\r
- /// <summary>\r
- /// The Audio Mixdown Enumeration\r
- /// </summary>\r
- public enum Mixdown\r
- {\r
- [Display(Name = "Dolby Pro Logic II")]\r
- DolbyProLogicII = 0,\r
+ /// <summary>\r
+ /// The Audio Mixdown Enumeration\r
+ /// </summary>\r
+ public enum Mixdown\r
+ {\r
+ [Display(Name = "Dolby Pro Logic II")]\r
+ DolbyProLogicII = 0,\r
\r
[Display(Name = "None")]\r
None,\r
\r
- [Display(Name = "Automatic")]\r
- Auto,\r
+ [Display(Name = "Automatic")]\r
+ Auto,\r
\r
- [Display(Name = "Mono")]\r
- Mono,\r
+ [Display(Name = "Mono")]\r
+ Mono,\r
\r
[Display(Name = "Mono (Left Only)")]\r
LeftOnly,\r
[Display(Name = "Mono (Right Only)")]\r
RightOnly,\r
\r
- [Display(Name = "Stereo")]\r
- Stereo,\r
+ [Display(Name = "Stereo")]\r
+ Stereo,\r
\r
- [Display(Name = "Dolby Surround")]\r
- DolbySurround,\r
+ [Display(Name = "Dolby Surround")]\r
+ DolbySurround,\r
\r
- [Display(Name = "5.1 Channels")]\r
- FivePoint1Channels,\r
+ [Display(Name = "5.1 Channels")]\r
+ FivePoint1Channels,\r
\r
[Display(Name = "6.1 Channels")]\r
SixPoint1Channels,\r
\r
[Display(Name = "7.1 (5F/2R/LFE)")]\r
Five_2_LFE,\r
- }\r
+ }\r
}\r
/// The output extension.\r
/// </summary>\r
public enum OutputExtension\r
- {\r
- Mp4,\r
- M4v\r
- }\r
+ {\r
+ Mp4,\r
+ M4v\r
+ }\r
}\r
\r
namespace HandBrake.ApplicationServices.Interop.Model.Encoding\r
{\r
- /// <summary>\r
- /// Possible picture rotations.\r
- /// </summary>\r
- public enum PictureRotation\r
- {\r
- None = 0,\r
- Clockwise90,\r
- Clockwise180,\r
- Clockwise270\r
- }\r
+ /// <summary>\r
+ /// Possible picture rotations.\r
+ /// </summary>\r
+ public enum PictureRotation\r
+ {\r
+ None = 0,\r
+ Clockwise90,\r
+ Clockwise180,\r
+ Clockwise270\r
+ }\r
}\r
\r
namespace HandBrake.ApplicationServices.Interop.Model.Encoding\r
{\r
- /// <summary>\r
- /// Enumeration of rescaling algorithms.\r
- /// </summary>\r
- public enum ScaleMethod\r
- {\r
- /// <summary>\r
- /// Standard software scaling. Highest quality.\r
- /// </summary>\r
- Lanczos = 0,\r
+ /// <summary>\r
+ /// Enumeration of rescaling algorithms.\r
+ /// </summary>\r
+ public enum ScaleMethod\r
+ {\r
+ /// <summary>\r
+ /// Standard software scaling. Highest quality.\r
+ /// </summary>\r
+ Lanczos = 0,\r
\r
- /// <summary>\r
- /// OpenCL-assisted bicubic scaling.\r
- /// </summary>\r
- Bicubic = 1\r
- }\r
+ /// <summary>\r
+ /// OpenCL-assisted bicubic scaling.\r
+ /// </summary>\r
+ Bicubic = 1\r
+ }\r
}\r
/// The video encode rate type.\r
/// </summary>\r
public enum VideoEncodeRateType\r
- {\r
- TargetSize = 0,\r
- AverageBitrate = 1,\r
- ConstantQuality = 2\r
- }\r
+ {\r
+ TargetSize = 0,\r
+ AverageBitrate = 1,\r
+ ConstantQuality = 2\r
+ }\r
}\r
\r
namespace HandBrake.ApplicationServices.Interop.Model.Encoding\r
{\r
- using System.ComponentModel.DataAnnotations;\r
+ using System.ComponentModel.DataAnnotations;\r
\r
- using HandBrake.ApplicationServices.Interop.Attributes;\r
+ using HandBrake.ApplicationServices.Interop.Attributes;\r
\r
/// <summary>\r
/// The video encoder.\r
/// </summary>\r
public enum VideoEncoder\r
- {\r
- [Display(Name = "H.264 (x264)")]\r
+ {\r
+ [Display(Name = "H.264 (x264)")]\r
[ShortName("x264")]\r
- X264 = 0,\r
+ X264 = 0,\r
\r
[Display(Name = "H.264 (Intel QSV)")]\r
[ShortName("qsv_h264")]\r
QuickSync,\r
\r
- [Display(Name = "MPEG-4")]\r
+ [Display(Name = "MPEG-4")]\r
[ShortName("mpeg4")]\r
- FFMpeg,\r
+ FFMpeg,\r
\r
- [Display(Name = "MPEG-2")]\r
+ [Display(Name = "MPEG-2")]\r
[ShortName("mpeg2")]\r
- FFMpeg2,\r
+ FFMpeg2,\r
\r
- [Display(Name = "Theora")]\r
+ [Display(Name = "Theora")]\r
[ShortName("theora")]\r
- Theora,\r
+ Theora,\r
\r
[Display(Name = "H.265 (x265)")]\r
[ShortName("x265")]\r
[Display(Name = "VP8")]\r
[ShortName("vp8")]\r
VP8\r
- }\r
+ }\r
}\r
\r
namespace HandBrake.ApplicationServices.Interop.Model\r
{\r
- /// <summary>\r
- /// Represents a language.\r
- /// </summary>\r
- public class Language\r
- {\r
- /// <summary>\r
- /// Gets or sets the english name of the language.\r
- /// </summary>\r
- public string EnglishName { get; set; }\r
+ /// <summary>\r
+ /// Represents a language.\r
+ /// </summary>\r
+ public class Language\r
+ {\r
+ /// <summary>\r
+ /// Gets or sets the english name of the language.\r
+ /// </summary>\r
+ public string EnglishName { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the native name of the language.\r
- /// </summary>\r
- public string NativeName { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets the native name of the language.\r
+ /// </summary>\r
+ public string NativeName { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the language code.\r
- /// </summary>\r
- public string Code { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets the language code.\r
+ /// </summary>\r
+ public string Code { get; set; }\r
\r
- /// <summary>\r
- /// Gets the display string for the language.\r
- /// </summary>\r
- public string Display\r
- {\r
- get\r
- {\r
- if (!string.IsNullOrEmpty(this.NativeName) && this.NativeName != this.EnglishName)\r
- {\r
- return this.EnglishName + " (" + this.NativeName + ")";\r
- }\r
+ /// <summary>\r
+ /// Gets the display string for the language.\r
+ /// </summary>\r
+ public string Display\r
+ {\r
+ get\r
+ {\r
+ if (!string.IsNullOrEmpty(this.NativeName) && this.NativeName != this.EnglishName)\r
+ {\r
+ return this.EnglishName + " (" + this.NativeName + ")";\r
+ }\r
\r
- return this.EnglishName;\r
- }\r
- }\r
- }\r
+ return this.EnglishName;\r
+ }\r
+ }\r
+ }\r
}\r
namespace HandBrake.ApplicationServices.Interop.Model.Scan\r
{\r
/// <summary>\r
- /// An object represending an AudioTrack associated with a Title, in a DVD\r
- /// </summary>\r
- public class AudioTrack\r
- {\r
- /// <summary>\r
- /// Gets or sets the track number of this Audio Track\r
- /// </summary>\r
- public int TrackNumber { get; set; }\r
+ /// An object represending an AudioTrack associated with a Title, in a DVD\r
+ /// </summary>\r
+ public class AudioTrack\r
+ {\r
+ /// <summary>\r
+ /// Gets or sets the track number of this Audio Track\r
+ /// </summary>\r
+ public int TrackNumber { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the audio codec ID for this track.\r
- /// </summary>\r
- public uint CodecId { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets the audio codec ID for this track.\r
+ /// </summary>\r
+ public uint CodecId { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the language (if detected) of this Audio Track\r
- /// </summary>\r
- public string Language { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets the language (if detected) of this Audio Track\r
+ /// </summary>\r
+ public string Language { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the language code for this audio track.\r
- /// </summary>\r
- public string LanguageCode { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets the language code for this audio track.\r
+ /// </summary>\r
+ public string LanguageCode { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the description for this audio track.\r
- /// </summary>\r
- public string Description { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets the description for this audio track.\r
+ /// </summary>\r
+ public string Description { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the channel layout of this Audio Track.\r
- /// </summary>\r
- public ulong ChannelLayout { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets the channel layout of this Audio Track.\r
+ /// </summary>\r
+ public ulong ChannelLayout { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the frequency (in Hz) of this Audio Track\r
- /// </summary>\r
- public int SampleRate { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets the frequency (in Hz) of this Audio Track\r
+ /// </summary>\r
+ public int SampleRate { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the bitrate (in bits/sec) of this Audio Track.\r
- /// </summary>\r
- public int Bitrate { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets the bitrate (in bits/sec) of this Audio Track.\r
+ /// </summary>\r
+ public int Bitrate { get; set; }\r
\r
- /// <summary>\r
- /// Gets the display string for this audio track.\r
- /// </summary>\r
- public string Display\r
- {\r
- get\r
- {\r
- return this.GetDisplayString(true);\r
- }\r
- }\r
+ /// <summary>\r
+ /// Gets the display string for this audio track.\r
+ /// </summary>\r
+ public string Display\r
+ {\r
+ get\r
+ {\r
+ return this.GetDisplayString(true);\r
+ }\r
+ }\r
\r
- /// <summary>\r
- /// Gets the display string for this audio track (not including track number)\r
- /// </summary>\r
- public string NoTrackDisplay\r
- {\r
- get\r
- {\r
- return this.GetDisplayString(false);\r
- }\r
- }\r
+ /// <summary>\r
+ /// Gets the display string for this audio track (not including track number)\r
+ /// </summary>\r
+ public string NoTrackDisplay\r
+ {\r
+ get\r
+ {\r
+ return this.GetDisplayString(false);\r
+ }\r
+ }\r
\r
- /// <summary>\r
- /// Override of the ToString method to make this object easier to use in the UI\r
- /// </summary>\r
- /// <returns>A string formatted as: {track #} {language} ({format}) ({sub-format})</returns>\r
- public override string ToString()\r
- {\r
- return this.GetDisplayString(true);\r
- }\r
+ /// <summary>\r
+ /// Override of the ToString method to make this object easier to use in the UI\r
+ /// </summary>\r
+ /// <returns>A string formatted as: {track #} {language} ({format}) ({sub-format})</returns>\r
+ public override string ToString()\r
+ {\r
+ return this.GetDisplayString(true);\r
+ }\r
\r
- /// <summary>\r
- /// The get display string.\r
- /// </summary>\r
- /// <param name="includeTrackNumber">\r
- /// The include track number.\r
- /// </param>\r
- /// <returns>\r
- /// The <see cref="string"/>.\r
- /// </returns>\r
- private string GetDisplayString(bool includeTrackNumber)\r
- {\r
- if (includeTrackNumber)\r
- {\r
- return this.TrackNumber + " " + this.Description;\r
- }\r
- \r
+ /// <summary>\r
+ /// The get display string.\r
+ /// </summary>\r
+ /// <param name="includeTrackNumber">\r
+ /// The include track number.\r
+ /// </param>\r
+ /// <returns>\r
+ /// The <see cref="string"/>.\r
+ /// </returns>\r
+ private string GetDisplayString(bool includeTrackNumber)\r
+ {\r
+ if (includeTrackNumber)\r
+ {\r
+ return this.TrackNumber + " " + this.Description;\r
+ }\r
+ \r
return this.Description;\r
- }\r
- }\r
+ }\r
+ }\r
}
\ No newline at end of file
using System.Globalization;\r
\r
/// <summary>\r
- /// An object representing a Chapter aosciated with a Title, in a DVD\r
- /// </summary>\r
- public class Chapter\r
- {\r
+ /// An object representing a Chapter aosciated with a Title, in a DVD\r
+ /// </summary>\r
+ public class Chapter\r
+ {\r
/// <summary>\r
/// Gets or sets the name.\r
/// </summary>\r
public string Name { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the number of this Chapter, in regards to its parent Title\r
- /// </summary>\r
- public int ChapterNumber { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets the number of this Chapter, in regards to its parent Title\r
+ /// </summary>\r
+ public int ChapterNumber { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the duration of this chapter.\r
- /// </summary>\r
- public TimeSpan Duration { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets the duration of this chapter.\r
+ /// </summary>\r
+ public TimeSpan Duration { get; set; }\r
\r
- /// <summary>\r
- /// Override of the ToString method to make this object easier to use in the UI\r
- /// </summary>\r
- /// <returns>A string formatted as: {chapter #}</returns>\r
- public override string ToString()\r
- {\r
- return this.ChapterNumber.ToString(CultureInfo.InvariantCulture);\r
- }\r
- }\r
+ /// <summary>\r
+ /// Override of the ToString method to make this object easier to use in the UI\r
+ /// </summary>\r
+ /// <returns>A string formatted as: {chapter #}</returns>\r
+ public override string ToString()\r
+ {\r
+ return this.ChapterNumber.ToString(CultureInfo.InvariantCulture);\r
+ }\r
+ }\r
}
\ No newline at end of file
/// The input type.\r
/// </summary>\r
public enum InputType\r
- {\r
- [Display(Name = "File")]\r
- Stream,\r
+ {\r
+ [Display(Name = "File")]\r
+ Stream,\r
\r
- [Display(Name = "DVD")]\r
- Dvd,\r
+ [Display(Name = "DVD")]\r
+ Dvd,\r
\r
- [Display(Name = "Blu-ray")]\r
- Bluray,\r
+ [Display(Name = "Blu-ray")]\r
+ Bluray,\r
\r
[Display(Name = "File")]\r
FFStream\r
- }\r
+ }\r
}\r
using HandBrake.ApplicationServices.Interop.HbLib;\r
\r
/// <summary>\r
- /// An object that represents a subtitle associated with a Title, in a DVD\r
- /// </summary>\r
- public class Subtitle\r
- {\r
- /// <summary>\r
- /// Gets or sets the track number of this Subtitle\r
- /// </summary>\r
- public int TrackNumber { get; set; }\r
+ /// An object that represents a subtitle associated with a Title, in a DVD\r
+ /// </summary>\r
+ public class Subtitle\r
+ {\r
+ /// <summary>\r
+ /// Gets or sets the track number of this Subtitle\r
+ /// </summary>\r
+ public int TrackNumber { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the language (if detected) of this Subtitle\r
- /// </summary>\r
- public string Language { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets the language (if detected) of this Subtitle\r
+ /// </summary>\r
+ public string Language { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the Langauage Code.\r
- /// </summary>\r
- public string LanguageCode { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets the Langauage Code.\r
+ /// </summary>\r
+ public string LanguageCode { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the subtitle source.\r
- /// </summary>\r
- public SubtitleSource SubtitleSource { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets the subtitle source.\r
+ /// </summary>\r
+ public SubtitleSource SubtitleSource { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the subtitle source raw integer.\r
- /// </summary>\r
- public int SubtitleSourceInt { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets the subtitle source raw integer.\r
+ /// </summary>\r
+ public int SubtitleSourceInt { get; set; }\r
\r
- /// <summary>\r
- /// Gets a value indicating whether the "forced only" flag can be set on this subtitle.\r
- /// </summary>\r
- public bool CanSetForcedOnly\r
- {\r
- get\r
- {\r
- return HBFunctions.hb_subtitle_can_force(this.SubtitleSourceInt) > 0;\r
- }\r
- }\r
+ /// <summary>\r
+ /// Gets a value indicating whether the "forced only" flag can be set on this subtitle.\r
+ /// </summary>\r
+ public bool CanSetForcedOnly\r
+ {\r
+ get\r
+ {\r
+ return HBFunctions.hb_subtitle_can_force(this.SubtitleSourceInt) > 0;\r
+ }\r
+ }\r
\r
- /// <summary>\r
- /// Gets a value indicating whether this subtitle can be burned into the picture.\r
- /// </summary>\r
- public bool CanBurn\r
- {\r
- get\r
- {\r
- return HBFunctions.hb_subtitle_can_burn(this.SubtitleSourceInt) > 0;\r
- }\r
- }\r
+ /// <summary>\r
+ /// Gets a value indicating whether this subtitle can be burned into the picture.\r
+ /// </summary>\r
+ public bool CanBurn\r
+ {\r
+ get\r
+ {\r
+ return HBFunctions.hb_subtitle_can_burn(this.SubtitleSourceInt) > 0;\r
+ }\r
+ }\r
\r
- /// <summary>\r
- /// Returns true if the subtitle can be passed through using the given muxer.\r
- /// </summary>\r
- /// <param name="muxer">The muxer ID.</param>\r
- /// <returns>True if the subtitle can be passed through.</returns>\r
- public bool CanPass(int muxer)\r
- {\r
- return HBFunctions.hb_subtitle_can_pass(this.SubtitleSourceInt, muxer) > 0;\r
- }\r
+ /// <summary>\r
+ /// Returns true if the subtitle can be passed through using the given muxer.\r
+ /// </summary>\r
+ /// <param name="muxer">The muxer ID.</param>\r
+ /// <returns>True if the subtitle can be passed through.</returns>\r
+ public bool CanPass(int muxer)\r
+ {\r
+ return HBFunctions.hb_subtitle_can_pass(this.SubtitleSourceInt, muxer) > 0;\r
+ }\r
\r
- /// <summary>\r
- /// Override of the ToString method to make this object easier to use in the UI\r
- /// </summary>\r
- /// <returns>A string formatted as: {track #} {language}</returns>\r
- public override string ToString()\r
- {\r
- return string.Format("{0} {1} ({2})", this.TrackNumber, this.Language, this.SubtitleSource);\r
- }\r
+ /// <summary>\r
+ /// Override of the ToString method to make this object easier to use in the UI\r
+ /// </summary>\r
+ /// <returns>A string formatted as: {track #} {language}</returns>\r
+ public override string ToString()\r
+ {\r
+ return string.Format("{0} {1} ({2})", this.TrackNumber, this.Language, this.SubtitleSource);\r
+ }\r
\r
- /// <summary>\r
- /// Gets the display.\r
- /// </summary>\r
- public string Display\r
- {\r
- get\r
- {\r
- return this.ToString();\r
- }\r
- }\r
- }\r
+ /// <summary>\r
+ /// Gets the display.\r
+ /// </summary>\r
+ public string Display\r
+ {\r
+ get\r
+ {\r
+ return this.ToString();\r
+ }\r
+ }\r
+ }\r
}
\ No newline at end of file
/// The subtitle source.\r
/// </summary>\r
public enum SubtitleSource\r
- {\r
- VobSub,\r
- SRT,\r
- CC608,\r
- CC708,\r
- UTF8,\r
- TX3G,\r
- SSA,\r
- PGS\r
- }\r
+ {\r
+ VobSub,\r
+ SRT,\r
+ CC608,\r
+ CC708,\r
+ UTF8,\r
+ TX3G,\r
+ SSA,\r
+ PGS\r
+ }\r
}\r
using HandBrake.ApplicationServices.Interop.Model;\r
\r
/// <summary>\r
- /// An object that represents a single Title of a DVD\r
- /// </summary>\r
- public class Title\r
- {\r
- /// <summary>\r
- /// The audio tracks.\r
- /// </summary>\r
- private readonly List<AudioTrack> audioTracks;\r
-\r
- /// <summary>\r
- /// The chapters.\r
- /// </summary>\r
- private readonly List<Chapter> chapters;\r
-\r
- /// <summary>\r
- /// The subtitles.\r
- /// </summary>\r
- private readonly List<Subtitle> subtitles;\r
- \r
- /// <summary>\r
- /// Initializes a new instance of the Title class.\r
- /// </summary>\r
- public Title()\r
- {\r
- this.audioTracks = new List<AudioTrack>();\r
- this.chapters = new List<Chapter>();\r
- this.subtitles = new List<Subtitle>();\r
- }\r
-\r
- /// <summary>\r
- /// Gets or sets the input type of this title.\r
- /// </summary>\r
- public InputType InputType { get; set; }\r
-\r
- /// <summary>\r
- /// Gets a collection of chapters in this Title\r
- /// </summary>\r
- public List<Chapter> Chapters\r
- {\r
- get { return this.chapters; }\r
- }\r
-\r
- /// <summary>\r
- /// Gets a collection of audio tracks associated with this Title\r
- /// </summary>\r
- public List<AudioTrack> AudioTracks\r
- {\r
- get { return this.audioTracks; }\r
- }\r
-\r
- /// <summary>\r
- /// Gets a collection of subtitles associated with this Title\r
- /// </summary>\r
- public List<Subtitle> Subtitles\r
- {\r
- get { return this.subtitles; }\r
- }\r
-\r
- /// <summary>\r
- /// Gets or sets the track number of this Title (1-based).\r
- /// </summary>\r
- public int TitleNumber { get; set; }\r
-\r
- /// <summary>\r
- /// Gets or sets the playlist number this title came from.\r
- /// </summary>\r
- public int Playlist { get; set; }\r
-\r
- /// <summary>\r
- /// Gets or sets the duration of this title.\r
- /// </summary>\r
- public TimeSpan Duration { get; set; }\r
-\r
- /// <summary>\r
- /// Gets or sets the resolution (width/height) of this Title\r
- /// </summary>\r
- public Size Resolution { get; set; }\r
-\r
- /// <summary>\r
- /// Gets or sets the number of angles on the title.\r
- /// </summary>\r
- public int AngleCount { get; set; }\r
-\r
- /// <summary>\r
- /// Gets or sets the pixel aspect ratio.\r
- /// </summary>\r
- public Size ParVal { get; set; }\r
-\r
- /// <summary>\r
- /// Gets or sets the automatically detected crop region for this Title.\r
- /// </summary>\r
- public Cropping AutoCropDimensions { get; set; }\r
-\r
- /// <summary>\r
- /// Gets or sets the name of the video codec for this title.\r
- /// </summary>\r
- public string VideoCodecName { get; set; }\r
-\r
- /// <summary>\r
- /// Gets or sets the video frame rate for this title.\r
- /// </summary>\r
- public double Framerate { get; set; }\r
-\r
- /// <summary>\r
- /// Gets or sets the video frame rate numerator.\r
- /// </summary>\r
- public int FramerateNumerator { get; set; }\r
-\r
- /// <summary>\r
- /// Gets or sets the video frame rate denominator.\r
- /// </summary>\r
- public int FramerateDenominator { get; set; }\r
-\r
- /// <summary>\r
- /// Gets the total number of frames in this title.\r
- /// </summary>\r
- public int Frames\r
- {\r
- get\r
- {\r
- return (int)Math.Ceiling(this.Duration.TotalSeconds * this.Framerate);\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// Gets or sets the path.\r
- /// </summary>\r
- public string Path { get; set; }\r
-\r
- /// <summary>\r
- /// Override of the ToString method to provide an easy way to use this object in the UI\r
- /// </summary>\r
- /// <returns>A string representing this track in the format: {title #}[ {playlist source}] (00:00:00)</returns>\r
- public override string ToString()\r
- {\r
- string playlistPortion = string.Empty;\r
- if (this.InputType == InputType.Bluray)\r
- {\r
- playlistPortion = string.Format(" {0:d5}.MPLS", this.Playlist);\r
- }\r
-\r
- return string.Format(\r
- "{0}{1} ({2:00}:{3:00}:{4:00})", \r
- this.TitleNumber, \r
- playlistPortion,\r
- this.Duration.Hours,\r
- this.Duration.Minutes, \r
- this.Duration.Seconds);\r
- }\r
-\r
- /// <summary>\r
- /// Gets the display string for this title.\r
- /// </summary>\r
- public string Display\r
- {\r
- get\r
- {\r
- return this.ToString();\r
- }\r
- }\r
+ /// An object that represents a single Title of a DVD\r
+ /// </summary>\r
+ public class Title\r
+ {\r
+ /// <summary>\r
+ /// The audio tracks.\r
+ /// </summary>\r
+ private readonly List<AudioTrack> audioTracks;\r
+\r
+ /// <summary>\r
+ /// The chapters.\r
+ /// </summary>\r
+ private readonly List<Chapter> chapters;\r
+\r
+ /// <summary>\r
+ /// The subtitles.\r
+ /// </summary>\r
+ private readonly List<Subtitle> subtitles;\r
+ \r
+ /// <summary>\r
+ /// Initializes a new instance of the Title class.\r
+ /// </summary>\r
+ public Title()\r
+ {\r
+ this.audioTracks = new List<AudioTrack>();\r
+ this.chapters = new List<Chapter>();\r
+ this.subtitles = new List<Subtitle>();\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets or sets the input type of this title.\r
+ /// </summary>\r
+ public InputType InputType { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets a collection of chapters in this Title\r
+ /// </summary>\r
+ public List<Chapter> Chapters\r
+ {\r
+ get { return this.chapters; }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets a collection of audio tracks associated with this Title\r
+ /// </summary>\r
+ public List<AudioTrack> AudioTracks\r
+ {\r
+ get { return this.audioTracks; }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets a collection of subtitles associated with this Title\r
+ /// </summary>\r
+ public List<Subtitle> Subtitles\r
+ {\r
+ get { return this.subtitles; }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets or sets the track number of this Title (1-based).\r
+ /// </summary>\r
+ public int TitleNumber { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets the playlist number this title came from.\r
+ /// </summary>\r
+ public int Playlist { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets the duration of this title.\r
+ /// </summary>\r
+ public TimeSpan Duration { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets the resolution (width/height) of this Title\r
+ /// </summary>\r
+ public Size Resolution { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets the number of angles on the title.\r
+ /// </summary>\r
+ public int AngleCount { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets the pixel aspect ratio.\r
+ /// </summary>\r
+ public Size ParVal { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets the automatically detected crop region for this Title.\r
+ /// </summary>\r
+ public Cropping AutoCropDimensions { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets the name of the video codec for this title.\r
+ /// </summary>\r
+ public string VideoCodecName { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets the video frame rate for this title.\r
+ /// </summary>\r
+ public double Framerate { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets the video frame rate numerator.\r
+ /// </summary>\r
+ public int FramerateNumerator { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets the video frame rate denominator.\r
+ /// </summary>\r
+ public int FramerateDenominator { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets the total number of frames in this title.\r
+ /// </summary>\r
+ public int Frames\r
+ {\r
+ get\r
+ {\r
+ return (int)Math.Ceiling(this.Duration.TotalSeconds * this.Framerate);\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets or sets the path.\r
+ /// </summary>\r
+ public string Path { get; set; }\r
+\r
+ /// <summary>\r
+ /// Override of the ToString method to provide an easy way to use this object in the UI\r
+ /// </summary>\r
+ /// <returns>A string representing this track in the format: {title #}[ {playlist source}] (00:00:00)</returns>\r
+ public override string ToString()\r
+ {\r
+ string playlistPortion = string.Empty;\r
+ if (this.InputType == InputType.Bluray)\r
+ {\r
+ playlistPortion = string.Format(" {0:d5}.MPLS", this.Playlist);\r
+ }\r
+\r
+ return string.Format(\r
+ "{0}{1} ({2:00}:{3:00}:{4:00})", \r
+ this.TitleNumber, \r
+ playlistPortion,\r
+ this.Duration.Hours,\r
+ this.Duration.Minutes, \r
+ this.Duration.Seconds);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets the display string for this title.\r
+ /// </summary>\r
+ public string Display\r
+ {\r
+ get\r
+ {\r
+ return this.ToString();\r
+ }\r
+ }\r
\r
/// <summary>\r
/// Gets or sets a value indicating whether is main feature.\r
/// </summary>\r
public bool IsMainFeature { get; set; }\r
- }\r
+ }\r
}
\ No newline at end of file
/// </summary>\r
public bool Default { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets a value indicating whether the subtitle track should be burned in.\r
- /// </summary>\r
- public bool BurnedIn { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether the subtitle track should be burned in.\r
+ /// </summary>\r
+ public bool BurnedIn { get; set; }\r
\r
/// <summary>\r
/// Gets or sets the file name.\r
return new SrtSubtitle\r
{\r
Default = this.Default,\r
- BurnedIn = this.BurnedIn,\r
+ BurnedIn = this.BurnedIn,\r
FileName = this.FileName, \r
LanguageCode = this.LanguageCode, \r
CharacterCode = this.CharacterCode, \r
\r
namespace HandBrake.ApplicationServices.Interop.Model\r
{\r
- /// <summary>\r
- /// Represents limits on video quality for a particular encoder.\r
- /// </summary>\r
- public class VideoQualityLimits\r
- {\r
- /// <summary>\r
- /// Gets or sets the inclusive lower limit for the quality.\r
- /// </summary>\r
- public float Low { get; set; }\r
+ /// <summary>\r
+ /// Represents limits on video quality for a particular encoder.\r
+ /// </summary>\r
+ public class VideoQualityLimits\r
+ {\r
+ /// <summary>\r
+ /// Gets or sets the inclusive lower limit for the quality.\r
+ /// </summary>\r
+ public float Low { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the inclusive upper limit for the quality.\r
- /// </summary>\r
- public float High { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets the inclusive upper limit for the quality.\r
+ /// </summary>\r
+ public float High { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets the granularity for the quality.\r
- /// </summary>\r
- public float Granularity { get; set; }\r
+ /// <summary>\r
+ /// Gets or sets the granularity for the quality.\r
+ /// </summary>\r
+ public float Granularity { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets a value indicating whether the quality increases as the number increases.\r
- /// </summary>\r
- public bool Ascending { get; set; }\r
- }\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether the quality increases as the number increases.\r
+ /// </summary>\r
+ public bool Ascending { get; set; }\r
+ }\r
}\r
\r
namespace HandBrake.ApplicationServices.Interop.Model\r
{\r
- using System.ComponentModel.DataAnnotations;\r
+ using System.ComponentModel.DataAnnotations;\r
\r
- /// <summary>\r
- /// The video range type.\r
- /// </summary>\r
- public enum VideoRangeType\r
- {\r
- /// <summary>\r
- /// The entire title.\r
- /// </summary>\r
- [Display(Name = "Preview")]\r
- Preview,\r
+ /// <summary>\r
+ /// The video range type.\r
+ /// </summary>\r
+ public enum VideoRangeType\r
+ {\r
+ /// <summary>\r
+ /// The entire title.\r
+ /// </summary>\r
+ [Display(Name = "Preview")]\r
+ Preview,\r
\r
- /// <summary>\r
- /// A chapter range.\r
- /// </summary>\r
- [Display(Name = "Chapters")]\r
- Chapters, \r
+ /// <summary>\r
+ /// A chapter range.\r
+ /// </summary>\r
+ [Display(Name = "Chapters")]\r
+ Chapters, \r
\r
- /// <summary>\r
- /// A timespan range in seconds.\r
- /// </summary>\r
- [Display(Name = "Seconds")]\r
- Seconds, \r
+ /// <summary>\r
+ /// A timespan range in seconds.\r
+ /// </summary>\r
+ [Display(Name = "Seconds")]\r
+ Seconds, \r
\r
- /// <summary>\r
- /// A frame range.\r
- /// </summary>\r
- [Display(Name = "Frames")]\r
- Frames\r
- }\r
+ /// <summary>\r
+ /// A frame range.\r
+ /// </summary>\r
+ [Display(Name = "Frames")]\r
+ Frames\r
+ }\r
}
\ No newline at end of file