aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Model
diff options
context:
space:
mode:
authorTim Eisele <Shadowghost@users.noreply.github.com>2024-09-09 16:43:37 +0200
committerGitHub <noreply@github.com>2024-09-09 08:43:37 -0600
commit0d85af019c6ebc855ab2d8e689abe72b995225b4 (patch)
tree466daf3cd9b8f37307b4104cd272afc9806d92c6 /MediaBrowser.Model
parent54f663b0f3c4a9cc5a4f44d1afcb6e1de03c0503 (diff)
Use enums for encoding options (#12561)
Diffstat (limited to 'MediaBrowser.Model')
-rw-r--r--MediaBrowser.Model/Configuration/EncodingOptions.cs26
-rw-r--r--MediaBrowser.Model/Entities/DeinterlaceMethod.cs19
-rw-r--r--MediaBrowser.Model/Entities/EncoderPreset.cs64
-rw-r--r--MediaBrowser.Model/Entities/HardwareAccelerationType.cs49
-rw-r--r--MediaBrowser.Model/Entities/TonemappingAlgorithm.cs49
-rw-r--r--MediaBrowser.Model/Entities/TonemappingMode.cs34
-rw-r--r--MediaBrowser.Model/Entities/TonemappingRange.cs24
-rw-r--r--MediaBrowser.Model/Session/HardwareEncodingType.cs43
-rw-r--r--MediaBrowser.Model/Session/TranscodingInfo.cs78
9 files changed, 313 insertions, 73 deletions
diff --git a/MediaBrowser.Model/Configuration/EncodingOptions.cs b/MediaBrowser.Model/Configuration/EncodingOptions.cs
index 4c5213d4e..d67a2479f 100644
--- a/MediaBrowser.Model/Configuration/EncodingOptions.cs
+++ b/MediaBrowser.Model/Configuration/EncodingOptions.cs
@@ -1,3 +1,5 @@
+#pragma warning disable CA1819 // XML serialization handles collections improperly, so we need to use arrays
+
#nullable disable
using MediaBrowser.Model.Entities;
@@ -30,9 +32,9 @@ public class EncodingOptions
EnableTonemapping = false;
EnableVppTonemapping = false;
EnableVideoToolboxTonemapping = false;
- TonemappingAlgorithm = "bt2390";
- TonemappingMode = "auto";
- TonemappingRange = "auto";
+ TonemappingAlgorithm = TonemappingAlgorithm.bt2390;
+ TonemappingMode = TonemappingMode.auto;
+ TonemappingRange = TonemappingRange.auto;
TonemappingDesat = 0;
TonemappingPeak = 100;
TonemappingParam = 0;
@@ -41,7 +43,7 @@ public class EncodingOptions
H264Crf = 23;
H265Crf = 28;
DeinterlaceDoubleRate = false;
- DeinterlaceMethod = "yadif";
+ DeinterlaceMethod = DeinterlaceMethod.yadif;
EnableDecodingColorDepth10Hevc = true;
EnableDecodingColorDepth10Vp9 = true;
// Enhanced Nvdec or system native decoder is required for DoVi to SDR tone-mapping.
@@ -53,8 +55,8 @@ public class EncodingOptions
AllowHevcEncoding = false;
AllowAv1Encoding = false;
EnableSubtitleExtraction = true;
- AllowOnDemandMetadataBasedKeyframeExtractionForExtensions = new[] { "mkv" };
- HardwareDecodingCodecs = new string[] { "h264", "vc1" };
+ AllowOnDemandMetadataBasedKeyframeExtractionForExtensions = ["mkv"];
+ HardwareDecodingCodecs = ["h264", "vc1"];
}
/// <summary>
@@ -120,7 +122,7 @@ public class EncodingOptions
/// <summary>
/// Gets or sets the hardware acceleration type.
/// </summary>
- public string HardwareAccelerationType { get; set; }
+ public HardwareAccelerationType HardwareAccelerationType { get; set; }
/// <summary>
/// Gets or sets the FFmpeg path as set by the user via the UI.
@@ -160,17 +162,17 @@ public class EncodingOptions
/// <summary>
/// Gets or sets the tone-mapping algorithm.
/// </summary>
- public string TonemappingAlgorithm { get; set; }
+ public TonemappingAlgorithm TonemappingAlgorithm { get; set; }
/// <summary>
/// Gets or sets the tone-mapping mode.
/// </summary>
- public string TonemappingMode { get; set; }
+ public TonemappingMode TonemappingMode { get; set; }
/// <summary>
/// Gets or sets the tone-mapping range.
/// </summary>
- public string TonemappingRange { get; set; }
+ public TonemappingRange TonemappingRange { get; set; }
/// <summary>
/// Gets or sets the tone-mapping desaturation.
@@ -210,7 +212,7 @@ public class EncodingOptions
/// <summary>
/// Gets or sets the encoder preset.
/// </summary>
- public string EncoderPreset { get; set; }
+ public EncoderPreset? EncoderPreset { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the framerate is doubled when deinterlacing.
@@ -220,7 +222,7 @@ public class EncodingOptions
/// <summary>
/// Gets or sets the deinterlace method.
/// </summary>
- public string DeinterlaceMethod { get; set; }
+ public DeinterlaceMethod DeinterlaceMethod { get; set; }
/// <summary>
/// Gets or sets a value indicating whether 10bit HEVC decoding is enabled.
diff --git a/MediaBrowser.Model/Entities/DeinterlaceMethod.cs b/MediaBrowser.Model/Entities/DeinterlaceMethod.cs
new file mode 100644
index 000000000..d05aac433
--- /dev/null
+++ b/MediaBrowser.Model/Entities/DeinterlaceMethod.cs
@@ -0,0 +1,19 @@
+#pragma warning disable SA1300 // Lowercase required for backwards compat.
+
+namespace MediaBrowser.Model.Entities;
+
+/// <summary>
+/// Enum containing deinterlace methods.
+/// </summary>
+public enum DeinterlaceMethod
+{
+ /// <summary>
+ /// YADIF.
+ /// </summary>
+ yadif = 0,
+
+ /// <summary>
+ /// BWDIF.
+ /// </summary>
+ bwdif = 1
+}
diff --git a/MediaBrowser.Model/Entities/EncoderPreset.cs b/MediaBrowser.Model/Entities/EncoderPreset.cs
new file mode 100644
index 000000000..74c071433
--- /dev/null
+++ b/MediaBrowser.Model/Entities/EncoderPreset.cs
@@ -0,0 +1,64 @@
+#pragma warning disable SA1300 // Lowercase required for backwards compat.
+
+namespace MediaBrowser.Model.Entities;
+
+/// <summary>
+/// Enum containing encoder presets.
+/// </summary>
+public enum EncoderPreset
+{
+ /// <summary>
+ /// Auto preset.
+ /// </summary>
+ auto = 0,
+
+ /// <summary>
+ /// Placebo preset.
+ /// </summary>
+ placebo = 1,
+
+ /// <summary>
+ /// Veryslow preset.
+ /// </summary>
+ veryslow = 2,
+
+ /// <summary>
+ /// Slower preset.
+ /// </summary>
+ slower = 3,
+
+ /// <summary>
+ /// Slow preset.
+ /// </summary>
+ slow = 4,
+
+ /// <summary>
+ /// Medium preset.
+ /// </summary>
+ medium = 5,
+
+ /// <summary>
+ /// Fast preset.
+ /// </summary>
+ fast = 6,
+
+ /// <summary>
+ /// Faster preset.
+ /// </summary>
+ faster = 7,
+
+ /// <summary>
+ /// Veryfast preset.
+ /// </summary>
+ veryfast = 8,
+
+ /// <summary>
+ /// Superfast preset.
+ /// </summary>
+ superfast = 9,
+
+ /// <summary>
+ /// Ultrafast preset.
+ /// </summary>
+ ultrafast = 10
+}
diff --git a/MediaBrowser.Model/Entities/HardwareAccelerationType.cs b/MediaBrowser.Model/Entities/HardwareAccelerationType.cs
new file mode 100644
index 000000000..198a2e00f
--- /dev/null
+++ b/MediaBrowser.Model/Entities/HardwareAccelerationType.cs
@@ -0,0 +1,49 @@
+#pragma warning disable SA1300 // Lowercase required for backwards compat.
+
+namespace MediaBrowser.Model.Entities;
+
+/// <summary>
+/// Enum containing hardware acceleration types.
+/// </summary>
+public enum HardwareAccelerationType
+{
+ /// <summary>
+ /// Software accelleration.
+ /// </summary>
+ none = 0,
+
+ /// <summary>
+ /// AMD AMF.
+ /// </summary>
+ amf = 1,
+
+ /// <summary>
+ /// Intel Quick Sync Video.
+ /// </summary>
+ qsv = 2,
+
+ /// <summary>
+ /// NVIDIA NVENC.
+ /// </summary>
+ nvenc = 3,
+
+ /// <summary>
+ /// Video4Linux2 V4L2M2M.
+ /// </summary>
+ v4l2m2m = 4,
+
+ /// <summary>
+ /// Video Acceleration API (VAAPI).
+ /// </summary>
+ vaapi = 5,
+
+ /// <summary>
+ /// Video ToolBox.
+ /// </summary>
+ videotoolbox = 6,
+
+ /// <summary>
+ /// Rockchip Media Process Platform (RKMPP).
+ /// </summary>
+ rkmpp = 7
+}
diff --git a/MediaBrowser.Model/Entities/TonemappingAlgorithm.cs b/MediaBrowser.Model/Entities/TonemappingAlgorithm.cs
new file mode 100644
index 000000000..488006e0b
--- /dev/null
+++ b/MediaBrowser.Model/Entities/TonemappingAlgorithm.cs
@@ -0,0 +1,49 @@
+#pragma warning disable SA1300 // Lowercase required for backwards compat.
+
+namespace MediaBrowser.Model.Entities;
+
+/// <summary>
+/// Enum containing tonemapping algorithms.
+/// </summary>
+public enum TonemappingAlgorithm
+{
+ /// <summary>
+ /// None.
+ /// </summary>
+ none = 0,
+
+ /// <summary>
+ /// Clip.
+ /// </summary>
+ clip = 1,
+
+ /// <summary>
+ /// Linear.
+ /// </summary>
+ linear = 2,
+
+ /// <summary>
+ /// Gamma.
+ /// </summary>
+ gamma = 3,
+
+ /// <summary>
+ /// Reinhard.
+ /// </summary>
+ reinhard = 4,
+
+ /// <summary>
+ /// Hable.
+ /// </summary>
+ hable = 5,
+
+ /// <summary>
+ /// Mobius.
+ /// </summary>
+ mobius = 6,
+
+ /// <summary>
+ /// BT2390.
+ /// </summary>
+ bt2390 = 7
+}
diff --git a/MediaBrowser.Model/Entities/TonemappingMode.cs b/MediaBrowser.Model/Entities/TonemappingMode.cs
new file mode 100644
index 000000000..e10a0b4ad
--- /dev/null
+++ b/MediaBrowser.Model/Entities/TonemappingMode.cs
@@ -0,0 +1,34 @@
+#pragma warning disable SA1300 // Lowercase required for backwards compat.
+
+namespace MediaBrowser.Model.Entities;
+
+/// <summary>
+/// Enum containing tonemapping modes.
+/// </summary>
+public enum TonemappingMode
+{
+ /// <summary>
+ /// Auto.
+ /// </summary>
+ auto = 0,
+
+ /// <summary>
+ /// Max.
+ /// </summary>
+ max = 1,
+
+ /// <summary>
+ /// RGB.
+ /// </summary>
+ rgb = 2,
+
+ /// <summary>
+ /// Lum.
+ /// </summary>
+ lum = 3,
+
+ /// <summary>
+ /// ITP.
+ /// </summary>
+ itp = 4
+}
diff --git a/MediaBrowser.Model/Entities/TonemappingRange.cs b/MediaBrowser.Model/Entities/TonemappingRange.cs
new file mode 100644
index 000000000..b1446b81c
--- /dev/null
+++ b/MediaBrowser.Model/Entities/TonemappingRange.cs
@@ -0,0 +1,24 @@
+#pragma warning disable SA1300 // Lowercase required for backwards compat.
+
+namespace MediaBrowser.Model.Entities;
+
+/// <summary>
+/// Enum containing tonemapping ranges.
+/// </summary>
+public enum TonemappingRange
+{
+ /// <summary>
+ /// Auto.
+ /// </summary>
+ auto = 0,
+
+ /// <summary>
+ /// TV.
+ /// </summary>
+ tv = 1,
+
+ /// <summary>
+ /// PC.
+ /// </summary>
+ pc = 2
+}
diff --git a/MediaBrowser.Model/Session/HardwareEncodingType.cs b/MediaBrowser.Model/Session/HardwareEncodingType.cs
deleted file mode 100644
index cf424fef5..000000000
--- a/MediaBrowser.Model/Session/HardwareEncodingType.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-namespace MediaBrowser.Model.Session
-{
- /// <summary>
- /// Enum HardwareEncodingType.
- /// </summary>
- public enum HardwareEncodingType
- {
- /// <summary>
- /// AMD AMF.
- /// </summary>
- AMF = 0,
-
- /// <summary>
- /// Intel Quick Sync Video.
- /// </summary>
- QSV = 1,
-
- /// <summary>
- /// NVIDIA NVENC.
- /// </summary>
- NVENC = 2,
-
- /// <summary>
- /// Video4Linux2 V4L2.
- /// </summary>
- V4L2M2M = 3,
-
- /// <summary>
- /// Video Acceleration API (VAAPI).
- /// </summary>
- VAAPI = 4,
-
- /// <summary>
- /// Video ToolBox.
- /// </summary>
- VideoToolBox = 5,
-
- /// <summary>
- /// Rockchip Media Process Platform (RKMPP).
- /// </summary>
- RKMPP = 6
- }
-}
diff --git a/MediaBrowser.Model/Session/TranscodingInfo.cs b/MediaBrowser.Model/Session/TranscodingInfo.cs
index 000cbd4c5..ae25267ac 100644
--- a/MediaBrowser.Model/Session/TranscodingInfo.cs
+++ b/MediaBrowser.Model/Session/TranscodingInfo.cs
@@ -1,34 +1,76 @@
#nullable disable
-#pragma warning disable CS1591
-namespace MediaBrowser.Model.Session
+using MediaBrowser.Model.Entities;
+
+namespace MediaBrowser.Model.Session;
+
+/// <summary>
+/// Class holding information on a runnning transcode.
+/// </summary>
+public class TranscodingInfo
{
- public class TranscodingInfo
- {
- public string AudioCodec { get; set; }
+ /// <summary>
+ /// Gets or sets the thread count used for encoding.
+ /// </summary>
+ public string AudioCodec { get; set; }
- public string VideoCodec { get; set; }
+ /// <summary>
+ /// Gets or sets the thread count used for encoding.
+ /// </summary>
+ public string VideoCodec { get; set; }
- public string Container { get; set; }
+ /// <summary>
+ /// Gets or sets the thread count used for encoding.
+ /// </summary>
+ public string Container { get; set; }
- public bool IsVideoDirect { get; set; }
+ /// <summary>
+ /// Gets or sets a value indicating whether the video is passed through.
+ /// </summary>
+ public bool IsVideoDirect { get; set; }
- public bool IsAudioDirect { get; set; }
+ /// <summary>
+ /// Gets or sets a value indicating whether the audio is passed through.
+ /// </summary>
+ public bool IsAudioDirect { get; set; }
- public int? Bitrate { get; set; }
+ /// <summary>
+ /// Gets or sets the bitrate.
+ /// </summary>
+ public int? Bitrate { get; set; }
- public float? Framerate { get; set; }
+ /// <summary>
+ /// Gets or sets the framerate.
+ /// </summary>
+ public float? Framerate { get; set; }
- public double? CompletionPercentage { get; set; }
+ /// <summary>
+ /// Gets or sets the completion percentage.
+ /// </summary>
+ public double? CompletionPercentage { get; set; }
- public int? Width { get; set; }
+ /// <summary>
+ /// Gets or sets the video width.
+ /// </summary>
+ public int? Width { get; set; }
- public int? Height { get; set; }
+ /// <summary>
+ /// Gets or sets the video height.
+ /// </summary>
+ public int? Height { get; set; }
- public int? AudioChannels { get; set; }
+ /// <summary>
+ /// Gets or sets the audio channels.
+ /// </summary>
+ public int? AudioChannels { get; set; }
- public HardwareEncodingType? HardwareAccelerationType { get; set; }
+ /// <summary>
+ /// Gets or sets the hardware acceleration type.
+ /// </summary>
+ public HardwareAccelerationType? HardwareAccelerationType { get; set; }
- public TranscodeReason TranscodeReasons { get; set; }
- }
+ /// <summary>
+ /// Gets or sets the transcode reasons.
+ /// </summary>
+ public TranscodeReason TranscodeReasons { get; set; }
}