From a18db8b3651e2d0dada4f131f8fb9ae2c3069f38 Mon Sep 17 00:00:00 2001 From: Scott Date: Sat, 26 Sep 2015 21:58:03 +0100 Subject: AppServices Tidyup Contd Made most of the exposed objects immutable. --- .../Interop/HandBrakeEncoderHelpers.cs | 26 ++------- .../Interop/HandBrakeUnitConversionHelpers.cs | 58 ++++++-------------- .../Interop/Model/BitrateLimits.cs | 23 ++++++-- .../Interop/Model/Encoding/HBAudioEncoder.cs | 63 +++++++++++++++++----- .../Interop/Model/Encoding/HBContainer.cs | 39 +++++++++++--- .../Interop/Model/Encoding/HBMixdown.cs | 33 ++++++++---- .../Interop/Model/Encoding/HBRate.cs | 23 ++++++-- .../Interop/Model/Encoding/HBVideoEncoder.cs | 39 +++++++++++--- .../Interop/Model/Language.cs | 31 ++++++++--- .../Interop/Model/RangeLimits.cs | 39 +++++++++++--- .../Interop/Model/Size.cs | 8 +-- .../Interop/Model/SourceVideoInfo.cs | 8 +-- .../Interop/Model/VideoQualityLimits.cs | 39 +++++++++++--- 13 files changed, 289 insertions(+), 140 deletions(-) (limited to 'win') diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeEncoderHelpers.cs b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeEncoderHelpers.cs index cddfd3634..67f1c5483 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeEncoderHelpers.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeEncoderHelpers.cs @@ -486,7 +486,7 @@ namespace HandBrake.ApplicationServices.Interop HBFunctions.hb_audio_bitrate_get_limits((uint)encoder.Id, sampleRate, mixdown.Id, ref low, ref high); - return new BitrateLimits { Low = low, High = high }; + return new BitrateLimits(low, high); } /// @@ -507,13 +507,7 @@ namespace HandBrake.ApplicationServices.Interop HBFunctions.hb_video_quality_get_limits((uint)encoder.Id, ref low, ref high, ref granularity, ref direction); - return new VideoQualityLimits - { - Low = low, - High = high, - Granularity = granularity, - Ascending = direction == 0 - }; + return new VideoQualityLimits(low, high, granularity, direction == 0); } /// @@ -574,13 +568,7 @@ namespace HandBrake.ApplicationServices.Interop int direction = 0; HBFunctions.hb_audio_quality_get_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction); - return new RangeLimits - { - Low = low, - High = high, - Granularity = granularity, - Ascending = direction == 0 - }; + return new RangeLimits(direction == 0, granularity, high, low); } /// @@ -598,13 +586,7 @@ namespace HandBrake.ApplicationServices.Interop int direction = 0; HBFunctions.hb_audio_compression_get_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction); - return new RangeLimits - { - Low = low, - High = high, - Granularity = granularity, - Ascending = direction == 0 - }; + return new RangeLimits(direction == 0, granularity, high, low); } /// diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeUnitConversionHelpers.cs b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeUnitConversionHelpers.cs index 7b981b7af..2f01e1825 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeUnitConversionHelpers.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeUnitConversionHelpers.cs @@ -75,13 +75,7 @@ namespace HandBrake.ApplicationServices.Interop /// internal static HBVideoEncoder NativeToVideoEncoder(hb_encoder_s encoder) { - return new HBVideoEncoder - { - Id = encoder.codec, - ShortName = encoder.short_name, - DisplayName = encoder.name, - CompatibleContainers = encoder.muxers - }; + return new HBVideoEncoder(encoder.muxers, encoder.name, encoder.codec, encoder.short_name); } /// @@ -95,18 +89,16 @@ namespace HandBrake.ApplicationServices.Interop /// internal static HBAudioEncoder NativeToAudioEncoder(hb_encoder_s encoder) { - var result = new HBAudioEncoder - { - Id = encoder.codec, - ShortName = encoder.short_name, - DisplayName = encoder.name, - CompatibleContainers = encoder.muxers, - QualityLimits = HandBrakeEncoderHelpers.GetAudioQualityLimits(encoder.codec), - DefaultQuality = HBFunctions.hb_audio_quality_get_default((uint)encoder.codec), - CompressionLimits = HandBrakeEncoderHelpers.GetAudioCompressionLimits(encoder.codec), - DefaultCompression = - HBFunctions.hb_audio_compression_get_default((uint)encoder.codec) - }; + var result = new HBAudioEncoder( + encoder.muxers, + HandBrakeEncoderHelpers.GetAudioCompressionLimits(encoder.codec), + HBFunctions.hb_audio_compression_get_default((uint)encoder.codec), + HBFunctions.hb_audio_quality_get_default((uint)encoder.codec), + encoder.name, + encoder.codec, + HandBrakeEncoderHelpers.GetAudioQualityLimits(encoder.codec), + encoder.short_name + ); return result; } @@ -122,11 +114,7 @@ namespace HandBrake.ApplicationServices.Interop /// internal static HBRate NativeToRate(hb_rate_s rate) { - return new HBRate - { - Name = rate.name, - Rate = rate.rate - }; + return new HBRate(rate.name, rate.rate); } /// @@ -140,12 +128,7 @@ namespace HandBrake.ApplicationServices.Interop /// internal static HBMixdown NativeToMixdown(hb_mixdown_s mixdown) { - return new HBMixdown - { - Id = mixdown.amixdown, - ShortName = mixdown.short_name, - DisplayName = mixdown.name - }; + return new HBMixdown(mixdown.name, mixdown.amixdown, mixdown.short_name); } /// @@ -159,13 +142,7 @@ namespace HandBrake.ApplicationServices.Interop /// internal static HBContainer NativeToContainer(hb_container_s container) { - return new HBContainer - { - DisplayName = container.name, - ShortName = container.short_name, - DefaultExtension = container.default_extension, - Id = container.format - }; + return new HBContainer(container.default_extension, container.name, container.format, container.short_name); } /// @@ -181,12 +158,7 @@ namespace HandBrake.ApplicationServices.Interop { string englishName = InteropUtilities.ToStringFromUtf8Ptr(language.eng_name); string nativeName = InteropUtilities.ToStringFromUtf8Ptr(language.native_name); - return new Language - { - Code = language.iso639_2, - EnglishName = englishName, - NativeName = nativeName - }; + return new Language(englishName, nativeName, language.iso639_2); } /// diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/BitrateLimits.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/BitrateLimits.cs index 62ff64200..533c73a5b 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Model/BitrateLimits.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Model/BitrateLimits.cs @@ -15,13 +15,28 @@ namespace HandBrake.ApplicationServices.Interop.Model public class BitrateLimits { /// - /// Gets or sets the inclusive lower limit for the bitrate. + /// Initializes a new instance of the class. /// - public int Low { get; set; } + /// + /// The low. + /// + /// + /// The high. + /// + public BitrateLimits(int low, int high) + { + this.Low = low; + this.High = high; + } /// - /// Gets or sets the inclusive upper limit for the bitrate. + /// Gets the inclusive lower limit for the bitrate. /// - public int High { get; set; } + public int Low { get; private set; } + + /// + /// Gets the inclusive upper limit for the bitrate. + /// + public int High { get; private set; } } } diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/HBAudioEncoder.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/HBAudioEncoder.cs index 5bef508f8..2d2e5b26d 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/HBAudioEncoder.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/HBAudioEncoder.cs @@ -17,34 +17,73 @@ namespace HandBrake.ApplicationServices.Interop.Model.Encoding public class HBAudioEncoder { /// - /// Gets or sets the compatible containers. + /// Initializes a new instance of the class. /// - public int CompatibleContainers { get; set; } + /// + /// The compatible containers. + /// + /// + /// The compression limits. + /// + /// + /// The default compression. + /// + /// + /// The default quality. + /// + /// + /// The display name. + /// + /// + /// The id. + /// + /// + /// The quality limits. + /// + /// + /// The short name. + /// + public HBAudioEncoder(int compatibleContainers, RangeLimits compressionLimits, float defaultCompression, float defaultQuality, string displayName, int id, RangeLimits qualityLimits, string shortName) + { + this.CompatibleContainers = compatibleContainers; + this.CompressionLimits = compressionLimits; + this.DefaultCompression = defaultCompression; + this.DefaultQuality = defaultQuality; + this.DisplayName = displayName; + this.Id = id; + this.QualityLimits = qualityLimits; + this.ShortName = shortName; + } + + /// + /// Gets the compatible containers. + /// + public int CompatibleContainers { get; private set; } /// - /// Gets or sets the compression limits. + /// Gets the compression limits. /// - public RangeLimits CompressionLimits { get; set; } + public RangeLimits CompressionLimits { get; private set; } /// - /// Gets or sets the default compression. + /// Gets the default compression. /// - public float DefaultCompression { get; set; } + public float DefaultCompression { get; private set; } /// - /// Gets or sets the default quality. + /// Gets the default quality. /// - public float DefaultQuality { get; set; } + public float DefaultQuality { get; private set; } /// - /// Gets or sets the display name. + /// Gets the display name. /// - public string DisplayName { get; set; } + public string DisplayName { get; private set; } /// - /// Gets or sets the id. + /// Gets the id. /// - public int Id { get; set; } + public int Id { get; private set; } /// /// Gets a value indicating whether the encoder is passthrough. diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/HBContainer.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/HBContainer.cs index 2a91c4e70..832d3513d 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/HBContainer.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/HBContainer.cs @@ -15,23 +15,46 @@ namespace HandBrake.ApplicationServices.Interop.Model.Encoding public class HBContainer { /// - /// Gets or sets the default extension. + /// Initializes a new instance of the class. /// - public string DefaultExtension { get; set; } + /// + /// The default extension. + /// + /// + /// The display name. + /// + /// + /// The id. + /// + /// + /// The short name. + /// + public HBContainer(string defaultExtension, string displayName, int id, string shortName) + { + this.DefaultExtension = defaultExtension; + this.DisplayName = displayName; + this.Id = id; + this.ShortName = shortName; + } /// - /// Gets or sets the display name. + /// Gets the default extension. /// - public string DisplayName { get; set; } + public string DefaultExtension { get; private set; } /// - /// Gets or sets the id. + /// Gets the display name. /// - public int Id { get; set; } + public string DisplayName { get; private set; } /// - /// Gets or sets the short name. + /// Gets the id. /// - public string ShortName { get; set; } + public int Id { get; private set; } + + /// + /// Gets the short name. + /// + public string ShortName { get; private set; } } } \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/HBMixdown.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/HBMixdown.cs index 18e7288e7..04927b9dd 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/HBMixdown.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/HBMixdown.cs @@ -14,23 +14,38 @@ namespace HandBrake.ApplicationServices.Interop.Model.Encoding /// public class HBMixdown { - #region Public Properties - /// - /// Gets or sets the display name. + /// Initializes a new instance of the class. /// - public string DisplayName { get; set; } + /// + /// The display name. + /// + /// + /// The id. + /// + /// + /// The short name. + /// + public HBMixdown(string displayName, int id, string shortName) + { + this.DisplayName = displayName; + this.Id = id; + this.ShortName = shortName; + } /// - /// Gets or sets the id. + /// Gets the display name. /// - public int Id { get; set; } + public string DisplayName { get; private set; } /// - /// Gets or sets the short name. + /// Gets the id. /// - public string ShortName { get; set; } + public int Id { get; private set; } - #endregion + /// + /// Gets the short name. + /// + public string ShortName { get; private set; } } } \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/HBRate.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/HBRate.cs index e3315878d..d3287cddb 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/HBRate.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/HBRate.cs @@ -15,13 +15,28 @@ namespace HandBrake.ApplicationServices.Interop.Model.Encoding public class HBRate { /// - /// Gets or sets the name to use for this rate. + /// Initializes a new instance of the class. /// - public string Name { get; set; } + /// + /// The name. + /// + /// + /// The rate. + /// + public HBRate(string name, int rate) + { + this.Name = name; + this.Rate = rate; + } /// - /// Gets or sets the raw rate. + /// Gets the name to use for this rate. /// - public int Rate { get; set; } + public string Name { get; private set; } + + /// + /// Gets the raw rate. + /// + public int Rate { get; private set; } } } diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/HBVideoEncoder.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/HBVideoEncoder.cs index a764f76b3..a1e60b2de 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/HBVideoEncoder.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/HBVideoEncoder.cs @@ -20,24 +20,47 @@ namespace HandBrake.ApplicationServices.Interop.Model.Encoding public class HBVideoEncoder { /// - /// Gets or sets the compatible containers. + /// Initializes a new instance of the class. /// - public int CompatibleContainers { get; set; } + /// + /// The compatible containers. + /// + /// + /// The display name. + /// + /// + /// The id. + /// + /// + /// The short name. + /// + public HBVideoEncoder(int compatibleContainers, string displayName, int id, string shortName) + { + this.CompatibleContainers = compatibleContainers; + this.DisplayName = displayName; + this.Id = id; + this.ShortName = shortName; + } + + /// + /// Gets the compatible containers. + /// + public int CompatibleContainers { get; private set; } /// - /// Gets or sets the display name. + /// Gets the display name. /// - public string DisplayName { get; set; } + public string DisplayName { get; private set; } /// - /// Gets or sets the id. + /// Gets the id. /// - public int Id { get; set; } + public int Id { get; private set; } /// - /// Gets or sets the short name. + /// Gets the short name. /// - public string ShortName { get; set; } + public string ShortName { get; private set; } /// /// Gets the list of presets this encoder supports. (null if the encoder doesn't support presets) diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/Language.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/Language.cs index 89e997ef8..a110f2590 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Model/Language.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Model/Language.cs @@ -15,19 +15,38 @@ namespace HandBrake.ApplicationServices.Interop.Model public class Language { /// - /// Gets or sets the english name of the language. + /// Initializes a new instance of the class. /// - public string EnglishName { get; set; } + /// + /// The english name. + /// + /// + /// The native name. + /// + /// + /// The code. + /// + public Language(string englishName, string nativeName, string code) + { + this.EnglishName = englishName; + this.NativeName = nativeName; + this.Code = code; + } + + /// + /// Gets the english name of the language. + /// + public string EnglishName { get; private set; } /// - /// Gets or sets the native name of the language. + /// Gets the native name of the language. /// - public string NativeName { get; set; } + public string NativeName { get; private set; } /// - /// Gets or sets the language code. + /// Gets the language code. /// - public string Code { get; set; } + public string Code { get; private set; } /// /// Gets the display string for the language. diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/RangeLimits.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/RangeLimits.cs index e10e16a71..b25c610dd 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Model/RangeLimits.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Model/RangeLimits.cs @@ -15,23 +15,46 @@ namespace HandBrake.ApplicationServices.Interop.Model public class RangeLimits { /// - /// Gets or sets a value indicating whether ascending. + /// Initializes a new instance of the class. /// - public bool Ascending { get; set; } + /// + /// The ascending. + /// + /// + /// The granularity. + /// + /// + /// The high. + /// + /// + /// The low. + /// + public RangeLimits(bool @ascending, float granularity, float high, float low) + { + this.Ascending = @ascending; + this.Granularity = granularity; + this.High = high; + this.Low = low; + } /// - /// Gets or sets the granularity. + /// Gets a value indicating whether ascending. /// - public float Granularity { get; set; } + public bool Ascending { get; private set; } /// - /// Gets or sets the high. + /// Gets the granularity. /// - public float High { get; set; } + public float Granularity { get; private set; } /// - /// Gets or sets the low. + /// Gets the high. /// - public float Low { get; set; } + public float High { get; private set; } + + /// + /// Gets the low. + /// + public float Low { get; private set; } } } \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/Size.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/Size.cs index e6752042c..4a4e09d34 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Model/Size.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Model/Size.cs @@ -30,14 +30,14 @@ namespace HandBrake.ApplicationServices.Interop.Model } /// - /// Gets or sets the height. + /// Gets the height. /// - public int Height { get; set; } + public int Height { get; private set; } /// - /// Gets or sets the width. + /// Gets the width. /// - public int Width { get; set; } + public int Width { get; private set; } /// /// Gets a value indicating whether is empty. diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/SourceVideoInfo.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/SourceVideoInfo.cs index 31b94ae10..4a0ffd2ec 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Model/SourceVideoInfo.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Model/SourceVideoInfo.cs @@ -30,13 +30,13 @@ namespace HandBrake.ApplicationServices.Interop.Model } /// - /// Gets or sets the resolution (width/height) of this Title + /// Gets the resolution (width/height) of this Title /// - public Size Resolution { get; set; } + public Size Resolution { get; private set; } /// - /// Gets or sets the pixel aspect ratio. + /// Gets the pixel aspect ratio. /// - public Size ParVal { get; set; } + public Size ParVal { get; private set; } } } diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/VideoQualityLimits.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/VideoQualityLimits.cs index bd9c1f5d4..19a0755af 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Model/VideoQualityLimits.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Model/VideoQualityLimits.cs @@ -15,23 +15,46 @@ namespace HandBrake.ApplicationServices.Interop.Model public class VideoQualityLimits { /// - /// Gets or sets the inclusive lower limit for the quality. + /// Initializes a new instance of the class. /// - public float Low { get; set; } + /// + /// The low. + /// + /// + /// The high. + /// + /// + /// The granularity. + /// + /// + /// The ascending. + /// + public VideoQualityLimits(float low, float high, float granularity, bool @ascending) + { + this.Low = low; + this.High = high; + this.Granularity = granularity; + this.Ascending = @ascending; + } /// - /// Gets or sets the inclusive upper limit for the quality. + /// Gets the inclusive lower limit for the quality. /// - public float High { get; set; } + public float Low { get; private set; } /// - /// Gets or sets the granularity for the quality. + /// Gets the inclusive upper limit for the quality. /// - public float Granularity { get; set; } + public float High { get; private set; } /// - /// Gets or sets a value indicating whether the quality increases as the number increases. + /// Gets the granularity for the quality. /// - public bool Ascending { get; set; } + public float Granularity { get; private set; } + + /// + /// Gets a value indicating whether the quality increases as the number increases. + /// + public bool Ascending { get; private set; } } } -- cgit v1.2.3