aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.MediaEncoding
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2022-12-07 16:39:40 +0100
committerGitHub <noreply@github.com>2022-12-07 16:39:40 +0100
commitf3c57e6a0ae015dc51cf548a0380d1bed33959c2 (patch)
tree1052ce5b7646e4fea7b20768213e89c0e38126ec /MediaBrowser.MediaEncoding
parent681be595cea8254cbac5bbb3bdc9083c4780db21 (diff)
parent52194f56b5f07e3ae01e2fb6d121452e37d1e93f (diff)
Merge pull request #8511 from Bond-009/isnull
Diffstat (limited to 'MediaBrowser.MediaEncoding')
-rw-r--r--MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs4
-rw-r--r--MediaBrowser.MediaEncoding/BdInfo/BdInfoDirectoryInfo.cs2
-rw-r--r--MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs4
-rw-r--r--MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs8
-rw-r--r--MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs10
-rw-r--r--MediaBrowser.MediaEncoding/Probing/FFProbeHelpers.cs6
-rw-r--r--MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs52
-rw-r--r--MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs2
8 files changed, 44 insertions, 44 deletions
diff --git a/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs b/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs
index 22abf93ac..0ee2bdd38 100644
--- a/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs
+++ b/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs
@@ -62,14 +62,14 @@ namespace MediaBrowser.MediaEncoding.Attachments
var mediaSources = await _mediaSourceManager.GetPlaybackMediaSources(item, null, true, false, cancellationToken).ConfigureAwait(false);
var mediaSource = mediaSources
.FirstOrDefault(i => string.Equals(i.Id, mediaSourceId, StringComparison.OrdinalIgnoreCase));
- if (mediaSource == null)
+ if (mediaSource is null)
{
throw new ResourceNotFoundException($"MediaSource {mediaSourceId} not found");
}
var mediaAttachment = mediaSource.MediaAttachments
.FirstOrDefault(i => i.Index == attachmentStreamIndex);
- if (mediaAttachment == null)
+ if (mediaAttachment is null)
{
throw new ResourceNotFoundException($"MediaSource {mediaSourceId} has no attachment with stream index {attachmentStreamIndex}");
}
diff --git a/MediaBrowser.MediaEncoding/BdInfo/BdInfoDirectoryInfo.cs b/MediaBrowser.MediaEncoding/BdInfo/BdInfoDirectoryInfo.cs
index 409379c35..7e026b42e 100644
--- a/MediaBrowser.MediaEncoding/BdInfo/BdInfoDirectoryInfo.cs
+++ b/MediaBrowser.MediaEncoding/BdInfo/BdInfoDirectoryInfo.cs
@@ -34,7 +34,7 @@ namespace MediaBrowser.MediaEncoding.BdInfo
get
{
var parentFolder = System.IO.Path.GetDirectoryName(_impl.FullName);
- if (parentFolder != null)
+ if (parentFolder is not null)
{
return new BdInfoDirectoryInfo(_fileSystem, parentFolder);
}
diff --git a/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs b/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs
index 6ebaa4fff..3e53cbf29 100644
--- a/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs
+++ b/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs
@@ -48,7 +48,7 @@ namespace MediaBrowser.MediaEncoding.BdInfo
MediaStreams = Array.Empty<MediaStream>()
};
- if (playlist == null)
+ if (playlist is null)
{
return outputStream;
}
@@ -89,7 +89,7 @@ namespace MediaBrowser.MediaEncoding.BdInfo
outputStream.PlaylistName = playlist.Name;
- if (playlist.StreamClips != null && playlist.StreamClips.Any())
+ if (playlist.StreamClips is not null && playlist.StreamClips.Any())
{
// Get the files in the playlist
outputStream.Files = playlist.StreamClips.Select(i => i.StreamFile.Name).ToArray();
diff --git a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs
index 8c8fc6b0f..8479b7d50 100644
--- a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs
+++ b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs
@@ -188,11 +188,11 @@ namespace MediaBrowser.MediaEncoding.Encoder
// Work out what the version under test is
var version = GetFFmpegVersionInternal(versionOutput);
- _logger.LogInformation("Found ffmpeg version {Version}", version != null ? version.ToString() : "unknown");
+ _logger.LogInformation("Found ffmpeg version {Version}", version is not null ? version.ToString() : "unknown");
- if (version == null)
+ if (version is null)
{
- if (MaxVersion != null) // Version is unknown
+ if (MaxVersion is not null) // Version is unknown
{
if (MinVersion == MaxVersion)
{
@@ -215,7 +215,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
_logger.LogWarning("FFmpeg validation: The minimum recommended version is {MinVersion}", MinVersion);
return false;
}
- else if (MaxVersion != null && version > MaxVersion) // Version is above what we recommend
+ else if (MaxVersion is not null && version > MaxVersion) // Version is above what we recommend
{
_logger.LogWarning("FFmpeg validation: The maximum recommended version is {MaxVersion}", MaxVersion);
return false;
diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
index e50aa679a..addaea33e 100644
--- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
+++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
@@ -157,7 +157,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
_configurationManager.SaveConfiguration("encoding", options);
// Only if mpeg path is set, try and set path to probe
- if (_ffmpegPath != null)
+ if (_ffmpegPath is not null)
{
// Determine a probe path from the mpeg path
_ffprobePath = Regex.Replace(_ffmpegPath, @"[^\/\\]+?(\.[^\/\\\n.]+)?$", @"ffprobe$1");
@@ -531,12 +531,12 @@ namespace MediaBrowser.MediaEncoding.Encoder
throw;
}
- if (result == null || (result.Streams == null && result.Format == null))
+ if (result is null || (result.Streams is null && result.Format is null))
{
throw new FfmpegException("ffprobe failed - streams and format are both null.");
}
- if (result.Streams != null)
+ if (result.Streams is not null)
{
// Normalize aspect ratio if invalid
foreach (var stream in result.Streams)
@@ -660,7 +660,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
var filters = new List<string>();
// deinterlace using bwdif algorithm for video stream.
- if (videoStream != null && videoStream.IsInterlaced)
+ if (videoStream is not null && videoStream.IsInterlaced)
{
filters.Add("bwdif=0:-1:0");
}
@@ -1017,7 +1017,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
{
if (!_disposed)
{
- if (Process != null)
+ if (Process is not null)
{
Process.Exited -= OnProcessExited;
DisposeProcess(Process);
diff --git a/MediaBrowser.MediaEncoding/Probing/FFProbeHelpers.cs b/MediaBrowser.MediaEncoding/Probing/FFProbeHelpers.cs
index 205e84153..1b5b5262a 100644
--- a/MediaBrowser.MediaEncoding/Probing/FFProbeHelpers.cs
+++ b/MediaBrowser.MediaEncoding/Probing/FFProbeHelpers.cs
@@ -17,17 +17,17 @@ namespace MediaBrowser.MediaEncoding.Probing
{
ArgumentNullException.ThrowIfNull(result);
- if (result.Format?.Tags != null)
+ if (result.Format?.Tags is not null)
{
result.Format.Tags = ConvertDictionaryToCaseInsensitive(result.Format.Tags);
}
- if (result.Streams != null)
+ if (result.Streams is not null)
{
// Convert all dictionaries to case insensitive
foreach (var stream in result.Streams)
{
- if (stream.Tags != null)
+ if (stream.Tags is not null)
{
stream.Tags = ConvertDictionaryToCaseInsensitive(stream.Tags);
}
diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
index 417f1520f..7a3462b97 100644
--- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
+++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
@@ -83,16 +83,16 @@ namespace MediaBrowser.MediaEncoding.Probing
var internalStreams = data.Streams ?? Array.Empty<MediaStreamInfo>();
info.MediaStreams = internalStreams.Select(s => GetMediaStream(isAudio, s, data.Format))
- .Where(i => i != null)
+ .Where(i => i is not null)
// Drop subtitle streams if we don't know the codec because it will just cause failures if we don't know how to handle them
.Where(i => i.Type != MediaStreamType.Subtitle || !string.IsNullOrWhiteSpace(i.Codec))
.ToList();
info.MediaAttachments = internalStreams.Select(GetMediaAttachment)
- .Where(i => i != null)
+ .Where(i => i is not null)
.ToList();
- if (data.Format != null)
+ if (data.Format is not null)
{
info.Container = NormalizeFormat(data.Format.FormatName);
@@ -110,7 +110,7 @@ namespace MediaBrowser.MediaEncoding.Probing
var tagStream = data.Streams?.FirstOrDefault(i => string.Equals(i.CodecType, tagStreamType, StringComparison.OrdinalIgnoreCase));
- if (tagStream?.Tags != null)
+ if (tagStream?.Tags is not null)
{
foreach (var (key, value) in tagStream.Tags)
{
@@ -118,7 +118,7 @@ namespace MediaBrowser.MediaEncoding.Probing
}
}
- if (data.Format?.Tags != null)
+ if (data.Format?.Tags is not null)
{
foreach (var (key, value) in data.Format.Tags)
{
@@ -156,7 +156,7 @@ namespace MediaBrowser.MediaEncoding.Probing
else
{
var artist = tags.GetFirstNotNullNorWhiteSpaceValue("artist");
- info.Artists = artist == null
+ info.Artists = artist is null
? Array.Empty<string>()
: SplitDistinctArtists(artist, _nameDelimiters, true).ToArray();
}
@@ -182,7 +182,7 @@ namespace MediaBrowser.MediaEncoding.Probing
FetchStudios(info, tags, "copyright");
var iTunExtc = tags.GetFirstNotNullNorWhiteSpaceValue("iTunEXTC");
- if (iTunExtc != null)
+ if (iTunExtc is not null)
{
var parts = iTunExtc.Split('|', StringSplitOptions.RemoveEmptyEntries);
// Example
@@ -199,19 +199,19 @@ namespace MediaBrowser.MediaEncoding.Probing
}
var iTunXml = tags.GetFirstNotNullNorWhiteSpaceValue("iTunMOVI");
- if (iTunXml != null)
+ if (iTunXml is not null)
{
FetchFromItunesInfo(iTunXml, info);
}
- if (data.Format != null && !string.IsNullOrEmpty(data.Format.Duration))
+ if (data.Format is not null && !string.IsNullOrEmpty(data.Format.Duration))
{
info.RunTimeTicks = TimeSpan.FromSeconds(double.Parse(data.Format.Duration, CultureInfo.InvariantCulture)).Ticks;
}
FetchWtvInfo(info, data);
- if (data.Chapters != null)
+ if (data.Chapters is not null)
{
info.Chapters = data.Chapters.Select(GetChapterInfo).ToArray();
}
@@ -459,7 +459,7 @@ namespace MediaBrowser.MediaEncoding.Probing
using (var subtree = reader.ReadSubtree())
{
var dict = GetNameValuePair(subtree);
- if (dict != null)
+ if (dict is not null)
{
pairs.Add(dict);
}
@@ -614,7 +614,7 @@ namespace MediaBrowser.MediaEncoding.Probing
attachment.CodecTag = streamInfo.CodecTagString;
}
- if (streamInfo.Tags != null)
+ if (streamInfo.Tags is not null)
{
attachment.FileName = GetDictionaryValue(streamInfo.Tags, "filename");
attachment.MimeType = GetDictionaryValue(streamInfo.Tags, "mimetype");
@@ -680,7 +680,7 @@ namespace MediaBrowser.MediaEncoding.Probing
stream.CodecTag = streamInfo.CodecTagString;
}
- if (streamInfo.Tags != null)
+ if (streamInfo.Tags is not null)
{
stream.Language = GetDictionaryValue(streamInfo.Tags, "language");
stream.Comment = GetDictionaryValue(streamInfo.Tags, "comment");
@@ -855,7 +855,7 @@ namespace MediaBrowser.MediaEncoding.Probing
stream.ColorPrimaries = streamInfo.ColorPrimaries;
}
- if (streamInfo.SideDataList != null)
+ if (streamInfo.SideDataList is not null)
{
foreach (var data in streamInfo.SideDataList)
{
@@ -899,7 +899,7 @@ namespace MediaBrowser.MediaEncoding.Probing
// The bitrate info of FLAC musics and some videos is included in formatInfo.
if (bitrate == 0
- && formatInfo != null
+ && formatInfo is not null
&& !string.IsNullOrEmpty(formatInfo.BitRate)
&& (stream.Type == MediaStreamType.Video || (isAudio && stream.Type == MediaStreamType.Audio)))
{
@@ -934,7 +934,7 @@ namespace MediaBrowser.MediaEncoding.Probing
{
var durationInSeconds = GetRuntimeSecondsFromTags(streamInfo);
var bytes = GetNumberOfBytesFromTags(streamInfo);
- if (durationInSeconds != null && bytes != null)
+ if (durationInSeconds is not null && bytes is not null)
{
var bps = Convert.ToInt32(bytes * 8 / durationInSeconds, CultureInfo.InvariantCulture);
if (bps > 0)
@@ -945,7 +945,7 @@ namespace MediaBrowser.MediaEncoding.Probing
}
var disposition = streamInfo.Disposition;
- if (disposition != null)
+ if (disposition is not null)
{
if (disposition.GetValueOrDefault("default") == 1)
{
@@ -989,7 +989,7 @@ namespace MediaBrowser.MediaEncoding.Probing
/// <returns>System.String.</returns>
private string GetDictionaryValue(IReadOnlyDictionary<string, string> tags, string key)
{
- if (tags == null)
+ if (tags is null)
{
return null;
}
@@ -1121,7 +1121,7 @@ namespace MediaBrowser.MediaEncoding.Probing
{
// Get the first info stream
var stream = result.Streams?.FirstOrDefault(s => string.Equals(s.CodecType, "audio", StringComparison.OrdinalIgnoreCase));
- if (stream == null)
+ if (stream is null)
{
return;
}
@@ -1144,7 +1144,7 @@ namespace MediaBrowser.MediaEncoding.Probing
private int? GetBPSFromTags(MediaStreamInfo streamInfo)
{
- if (streamInfo?.Tags == null)
+ if (streamInfo?.Tags is null)
{
return null;
}
@@ -1161,7 +1161,7 @@ namespace MediaBrowser.MediaEncoding.Probing
private double? GetRuntimeSecondsFromTags(MediaStreamInfo streamInfo)
{
- if (streamInfo?.Tags == null)
+ if (streamInfo?.Tags is null)
{
return null;
}
@@ -1177,7 +1177,7 @@ namespace MediaBrowser.MediaEncoding.Probing
private long? GetNumberOfBytesFromTags(MediaStreamInfo streamInfo)
{
- if (streamInfo?.Tags == null)
+ if (streamInfo?.Tags is null)
{
return null;
}
@@ -1195,7 +1195,7 @@ namespace MediaBrowser.MediaEncoding.Probing
private void SetSize(InternalMediaInfoResult data, MediaInfo info)
{
- if (data.Format == null)
+ if (data.Format is null)
{
return;
}
@@ -1294,7 +1294,7 @@ namespace MediaBrowser.MediaEncoding.Probing
// Set album artist
var albumArtist = tags.GetFirstNotNullNorWhiteSpaceValue("albumartist", "album artist", "album_artist");
- audio.AlbumArtists = albumArtist != null
+ audio.AlbumArtists = albumArtist is not null
? SplitDistinctArtists(albumArtist, _nameDelimiters, true).ToArray()
: Array.Empty<string>();
@@ -1489,7 +1489,7 @@ namespace MediaBrowser.MediaEncoding.Probing
{
var info = new ChapterInfo();
- if (chapter.Tags != null && chapter.Tags.TryGetValue("title", out string name))
+ if (chapter.Tags is not null && chapter.Tags.TryGetValue("title", out string name))
{
info.Name = name;
}
@@ -1510,7 +1510,7 @@ namespace MediaBrowser.MediaEncoding.Probing
{
var tags = data.Format?.Tags;
- if (tags == null)
+ if (tags is null)
{
return;
}
diff --git a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs
index 9185faf67..4bc329a8a 100644
--- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs
+++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs
@@ -174,7 +174,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
var result = CharsetDetector.DetectFromStream(stream).Detected;
stream.Position = 0;
- if (result != null)
+ if (result is not null)
{
_logger.LogDebug("charset {CharSet} detected for {Path}", result.EncodingName, fileInfo.Path);