Enable nullable reference types for MediaBrowser.MediaEncoding.Subtitles

This commit is contained in:
Bond_009
2021-05-20 22:10:19 +02:00
parent c6ca722e57
commit 26d7fc8280
18 changed files with 65 additions and 52 deletions

View File

@@ -121,11 +121,11 @@ namespace MediaBrowser.MediaEncoding.Encoder
// When changing this, also change the minimum library versions in _ffmpegMinimumLibraryVersions
public static Version MinVersion { get; } = new Version(4, 0);
public static Version MaxVersion { get; } = null;
public static Version? MaxVersion { get; } = null;
public bool ValidateVersion()
{
string output = null;
string output;
try
{
output = GetProcessOutput(_encoderPath, "-version");
@@ -133,6 +133,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
catch (Exception ex)
{
_logger.LogError(ex, "Error validating encoder");
return false;
}
if (string.IsNullOrWhiteSpace(output))
@@ -207,7 +208,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
/// </summary>
/// <param name="output">The output from "ffmpeg -version".</param>
/// <returns>The FFmpeg version.</returns>
internal Version GetFFmpegVersion(string output)
internal Version? GetFFmpegVersion(string output)
{
// For pre-built binaries the FFmpeg version should be mentioned at the very start of the output
var match = Regex.Match(output, @"^ffmpeg version n?((?:[0-9]+\.?)+)");
@@ -275,7 +276,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
private IEnumerable<string> GetHwaccelTypes()
{
string output = null;
string? output = null;
try
{
output = GetProcessOutput(_encoderPath, "-hwaccels");
@@ -303,7 +304,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
return false;
}
string output = null;
string output;
try
{
output = GetProcessOutput(_encoderPath, "-h filter=" + filter);
@@ -311,6 +312,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
catch (Exception ex)
{
_logger.LogError(ex, "Error detecting the given filter");
return false;
}
if (output.Contains("Filter " + filter, StringComparison.Ordinal))
@@ -331,7 +333,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
private IEnumerable<string> GetCodecs(Codec codec)
{
string codecstr = codec == Codec.Encoder ? "encoders" : "decoders";
string output = null;
string output;
try
{
output = GetProcessOutput(_encoderPath, "-" + codecstr);
@@ -339,6 +341,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
catch (Exception ex)
{
_logger.LogError(ex, "Error detecting available {Codec}", codecstr);
return Enumerable.Empty<string>();
}
if (string.IsNullOrWhiteSpace(output))