mirror of https://github.com/jellyfin/jellyfin.git
Fix all warnings in MediaBrowser.MediaEncoding (#9073)
This commit is contained in:
parent
515e69dcf7
commit
81c8890b6d
|
@ -498,11 +498,12 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||||
|
|
||||||
_logger.LogInformation("Starting {ProcessFileName} with args {ProcessArgs}", _ffprobePath, args);
|
_logger.LogInformation("Starting {ProcessFileName} with args {ProcessArgs}", _ffprobePath, args);
|
||||||
|
|
||||||
|
var memoryStream = new MemoryStream();
|
||||||
|
await using (memoryStream.ConfigureAwait(false))
|
||||||
using (var processWrapper = new ProcessWrapper(process, this))
|
using (var processWrapper = new ProcessWrapper(process, this))
|
||||||
{
|
{
|
||||||
await using var memoryStream = new MemoryStream();
|
|
||||||
StartProcess(processWrapper);
|
StartProcess(processWrapper);
|
||||||
await process.StandardOutput.BaseStream.CopyToAsync(memoryStream, cancellationToken);
|
await process.StandardOutput.BaseStream.CopyToAsync(memoryStream, cancellationToken).ConfigureAwait(false);
|
||||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||||
InternalMediaInfoResult result;
|
InternalMediaInfoResult result;
|
||||||
try
|
try
|
||||||
|
|
|
@ -11,10 +11,6 @@
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
|
||||||
<CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="..\SharedVersion.cs" />
|
<Compile Include="..\SharedVersion.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -226,7 +226,13 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||||
await ExtractTextSubtitle(mediaSource, subtitleStream, outputCodec, outputPath, cancellationToken)
|
await ExtractTextSubtitle(mediaSource, subtitleStream, outputCodec, outputPath, cancellationToken)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
return new SubtitleInfo(outputPath, MediaProtocol.File, outputFormat, false);
|
return new SubtitleInfo()
|
||||||
|
{
|
||||||
|
Path = outputPath,
|
||||||
|
Protocol = MediaProtocol.File,
|
||||||
|
Format = outputFormat,
|
||||||
|
IsExternal = false
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentFormat = (Path.GetExtension(subtitleStream.Path) ?? subtitleStream.Codec)
|
var currentFormat = (Path.GetExtension(subtitleStream.Path) ?? subtitleStream.Codec)
|
||||||
|
@ -240,11 +246,23 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||||
|
|
||||||
await ConvertTextSubtitleToSrt(subtitleStream, mediaSource, outputPath, cancellationToken).ConfigureAwait(false);
|
await ConvertTextSubtitleToSrt(subtitleStream, mediaSource, outputPath, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
return new SubtitleInfo(outputPath, MediaProtocol.File, "srt", true);
|
return new SubtitleInfo()
|
||||||
|
{
|
||||||
|
Path = outputPath,
|
||||||
|
Protocol = MediaProtocol.File,
|
||||||
|
Format = "srt",
|
||||||
|
IsExternal = true
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// It's possible that the subtitleStream and mediaSource don't share the same protocol (e.g. .STRM file with local subs)
|
// It's possible that the subtitleStream and mediaSource don't share the same protocol (e.g. .STRM file with local subs)
|
||||||
return new SubtitleInfo(subtitleStream.Path, _mediaSourceManager.GetPathProtocol(subtitleStream.Path), currentFormat, true);
|
return new SubtitleInfo()
|
||||||
|
{
|
||||||
|
Path = subtitleStream.Path,
|
||||||
|
Protocol = _mediaSourceManager.GetPathProtocol(subtitleStream.Path),
|
||||||
|
Format = currentFormat,
|
||||||
|
IsExternal = true
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool TryGetWriter(string format, [NotNullWhen(true)] out ISubtitleWriter? value)
|
private bool TryGetWriter(string format, [NotNullWhen(true)] out ISubtitleWriter? value)
|
||||||
|
@ -728,23 +746,17 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly struct SubtitleInfo
|
#pragma warning disable CA1034 // Nested types should not be visible
|
||||||
|
// Only public for the unit tests
|
||||||
|
public readonly record struct SubtitleInfo
|
||||||
{
|
{
|
||||||
public SubtitleInfo(string path, MediaProtocol protocol, string format, bool isExternal)
|
public string Path { get; init; }
|
||||||
{
|
|
||||||
Path = path;
|
|
||||||
Protocol = protocol;
|
|
||||||
Format = format;
|
|
||||||
IsExternal = isExternal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Path { get; }
|
public MediaProtocol Protocol { get; init; }
|
||||||
|
|
||||||
public MediaProtocol Protocol { get; }
|
public string Format { get; init; }
|
||||||
|
|
||||||
public string Format { get; }
|
public bool IsExternal { get; init; }
|
||||||
|
|
||||||
public bool IsExternal { get; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,13 @@ namespace Jellyfin.MediaEncoding.Subtitles.Tests
|
||||||
Path = "/media/sub.ass",
|
Path = "/media/sub.ass",
|
||||||
IsExternal = true
|
IsExternal = true
|
||||||
},
|
},
|
||||||
new SubtitleEncoder.SubtitleInfo("/media/sub.ass", MediaProtocol.File, "ass", true));
|
new SubtitleEncoder.SubtitleInfo()
|
||||||
|
{
|
||||||
|
Path = "/media/sub.ass",
|
||||||
|
Protocol = MediaProtocol.File,
|
||||||
|
Format = "ass",
|
||||||
|
IsExternal = true
|
||||||
|
});
|
||||||
|
|
||||||
data.Add(
|
data.Add(
|
||||||
new MediaSourceInfo()
|
new MediaSourceInfo()
|
||||||
|
@ -38,7 +44,13 @@ namespace Jellyfin.MediaEncoding.Subtitles.Tests
|
||||||
Path = "/media/sub.ssa",
|
Path = "/media/sub.ssa",
|
||||||
IsExternal = true
|
IsExternal = true
|
||||||
},
|
},
|
||||||
new SubtitleEncoder.SubtitleInfo("/media/sub.ssa", MediaProtocol.File, "ssa", true));
|
new SubtitleEncoder.SubtitleInfo()
|
||||||
|
{
|
||||||
|
Path = "/media/sub.ssa",
|
||||||
|
Protocol = MediaProtocol.File,
|
||||||
|
Format = "ssa",
|
||||||
|
IsExternal = true
|
||||||
|
});
|
||||||
|
|
||||||
data.Add(
|
data.Add(
|
||||||
new MediaSourceInfo()
|
new MediaSourceInfo()
|
||||||
|
@ -50,7 +62,13 @@ namespace Jellyfin.MediaEncoding.Subtitles.Tests
|
||||||
Path = "/media/sub.srt",
|
Path = "/media/sub.srt",
|
||||||
IsExternal = true
|
IsExternal = true
|
||||||
},
|
},
|
||||||
new SubtitleEncoder.SubtitleInfo("/media/sub.srt", MediaProtocol.File, "srt", true));
|
new SubtitleEncoder.SubtitleInfo()
|
||||||
|
{
|
||||||
|
Path = "/media/sub.srt",
|
||||||
|
Protocol = MediaProtocol.File,
|
||||||
|
Format = "srt",
|
||||||
|
IsExternal = true
|
||||||
|
});
|
||||||
|
|
||||||
data.Add(
|
data.Add(
|
||||||
new MediaSourceInfo()
|
new MediaSourceInfo()
|
||||||
|
@ -62,14 +80,20 @@ namespace Jellyfin.MediaEncoding.Subtitles.Tests
|
||||||
Path = "/media/sub.ass",
|
Path = "/media/sub.ass",
|
||||||
IsExternal = true
|
IsExternal = true
|
||||||
},
|
},
|
||||||
new SubtitleEncoder.SubtitleInfo("/media/sub.ass", MediaProtocol.File, "ass", true));
|
new SubtitleEncoder.SubtitleInfo()
|
||||||
|
{
|
||||||
|
Path = "/media/sub.ass",
|
||||||
|
Protocol = MediaProtocol.File,
|
||||||
|
Format = "ass",
|
||||||
|
IsExternal = true
|
||||||
|
});
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
[MemberData(nameof(GetReadableFile_Valid_TestData))]
|
[MemberData(nameof(GetReadableFile_Valid_TestData))]
|
||||||
internal async Task GetReadableFile_Valid_Success(MediaSourceInfo mediaSource, MediaStream subtitleStream, SubtitleEncoder.SubtitleInfo subtitleInfo)
|
public async Task GetReadableFile_Valid_Success(MediaSourceInfo mediaSource, MediaStream subtitleStream, SubtitleEncoder.SubtitleInfo subtitleInfo)
|
||||||
{
|
{
|
||||||
var fixture = new Fixture().Customize(new AutoMoqCustomization { ConfigureMembers = true });
|
var fixture = new Fixture().Customize(new AutoMoqCustomization { ConfigureMembers = true });
|
||||||
var subtitleEncoder = fixture.Create<SubtitleEncoder>();
|
var subtitleEncoder = fixture.Create<SubtitleEncoder>();
|
||||||
|
|
Loading…
Reference in New Issue