diff options
Diffstat (limited to 'MediaBrowser.Controller')
| -rw-r--r-- | MediaBrowser.Controller/Entities/AggregateFolder.cs | 4 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Audio/MusicArtist.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/BaseItem.cs | 20 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Folder.cs | 10 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/TV/Episode.cs | 10 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/TV/Season.cs | 4 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/UserView.cs | 8 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/UserViewBuilder.cs | 4 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Video.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs | 58 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Playlists/Playlist.cs | 6 |
11 files changed, 70 insertions, 58 deletions
diff --git a/MediaBrowser.Controller/Entities/AggregateFolder.cs b/MediaBrowser.Controller/Entities/AggregateFolder.cs index 9589f5245..77a857b78 100644 --- a/MediaBrowser.Controller/Entities/AggregateFolder.cs +++ b/MediaBrowser.Controller/Entities/AggregateFolder.cs @@ -187,14 +187,14 @@ namespace MediaBrowser.Controller.Entities /// <exception cref="ArgumentNullException">The id is empty.</exception> public BaseItem FindVirtualChild(Guid id) { - if (id.Equals(Guid.Empty)) + if (id.Equals(default)) { throw new ArgumentNullException(nameof(id)); } foreach (var child in _virtualChildren) { - if (child.Id == id) + if (child.Id.Equals(id)) { return child; } diff --git a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs index 11b95b94b..0f2d7e62d 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs @@ -24,7 +24,7 @@ namespace MediaBrowser.Controller.Entities.Audio public class MusicArtist : Folder, IItemByName, IHasMusicGenres, IHasDualAccess, IHasLookupInfo<ArtistInfo> { [JsonIgnore] - public bool IsAccessedByName => ParentId.Equals(Guid.Empty); + public bool IsAccessedByName => ParentId.Equals(default); [JsonIgnore] public override bool IsFolder => !IsAccessedByName; diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index c52732858..d993a15a9 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -231,7 +231,7 @@ namespace MediaBrowser.Controller.Entities { get { - if (!ChannelId.Equals(Guid.Empty)) + if (!ChannelId.Equals(default)) { return SourceType.Channel; } @@ -521,7 +521,7 @@ namespace MediaBrowser.Controller.Entities get { var id = DisplayParentId; - if (id.Equals(Guid.Empty)) + if (id.Equals(default)) { return null; } @@ -737,7 +737,7 @@ namespace MediaBrowser.Controller.Entities public virtual bool StopRefreshIfLocalMetadataFound => true; [JsonIgnore] - protected virtual bool SupportsOwnedItems => !ParentId.Equals(Guid.Empty) && IsFileProtocol; + protected virtual bool SupportsOwnedItems => !ParentId.Equals(default) && IsFileProtocol; [JsonIgnore] public virtual bool SupportsPeople => false; @@ -848,7 +848,7 @@ namespace MediaBrowser.Controller.Entities public BaseItem GetOwner() { var ownerId = OwnerId; - return ownerId.Equals(Guid.Empty) ? null : LibraryManager.GetItemById(ownerId); + return ownerId.Equals(default) ? null : LibraryManager.GetItemById(ownerId); } public bool CanDelete(User user, List<Folder> allCollectionFolders) @@ -984,12 +984,12 @@ namespace MediaBrowser.Controller.Entities public BaseItem GetParent() { var parentId = ParentId; - if (!parentId.Equals(Guid.Empty)) + if (parentId.Equals(default)) { - return LibraryManager.GetItemById(parentId); + return null; } - return null; + return LibraryManager.GetItemById(parentId); } public IEnumerable<BaseItem> GetParents() @@ -1397,7 +1397,7 @@ namespace MediaBrowser.Controller.Entities var tasks = extras.Select(i => { var subOptions = new MetadataRefreshOptions(options); - if (i.OwnerId != ownerId || i.ParentId != Guid.Empty) + if (!i.OwnerId.Equals(ownerId) || !i.ParentId.Equals(default)) { i.OwnerId = ownerId; i.ParentId = Guid.Empty; @@ -1736,7 +1736,7 @@ namespace MediaBrowser.Controller.Entities // First get using the cached Id if (info.ItemId.HasValue) { - if (info.ItemId.Value.Equals(Guid.Empty)) + if (info.ItemId.Value.Equals(default)) { return null; } @@ -2657,7 +2657,7 @@ namespace MediaBrowser.Controller.Entities } /// <inheritdoc /> - public bool Equals(BaseItem other) => Id == other?.Id; + public bool Equals(BaseItem other) => other is not null && other.Id.Equals(Id); /// <inheritdoc /> public override int GetHashCode() => HashCode.Combine(Id); diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index cb5ff6eec..f9450ccb3 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -213,7 +213,7 @@ namespace MediaBrowser.Controller.Entities { item.SetParent(this); - if (item.Id.Equals(Guid.Empty)) + if (item.Id.Equals(default)) { item.Id = LibraryManager.GetNewItemId(item.Path, item.GetType()); } @@ -730,7 +730,9 @@ namespace MediaBrowser.Controller.Entities return PostFilterAndSort(items, query, true); } - if (this is not UserRootFolder && this is not AggregateFolder && query.ParentId == Guid.Empty) + if (this is not UserRootFolder + && this is not AggregateFolder + && query.ParentId.Equals(default)) { query.Parent = this; } @@ -1504,7 +1506,7 @@ namespace MediaBrowser.Controller.Entities { if (i.ItemId.HasValue) { - if (i.ItemId.Value == itemId) + if (i.ItemId.Value.Equals(itemId)) { return true; } @@ -1514,7 +1516,7 @@ namespace MediaBrowser.Controller.Entities var child = GetLinkedChild(i); - if (child != null && child.Id == itemId) + if (child != null && child.Id.Equals(itemId)) { return true; } diff --git a/MediaBrowser.Controller/Entities/TV/Episode.cs b/MediaBrowser.Controller/Entities/TV/Episode.cs index c8a0e21eb..15b721fe6 100644 --- a/MediaBrowser.Controller/Entities/TV/Episode.cs +++ b/MediaBrowser.Controller/Entities/TV/Episode.cs @@ -74,12 +74,12 @@ namespace MediaBrowser.Controller.Entities.TV get { var seriesId = SeriesId; - if (seriesId.Equals(Guid.Empty)) + if (seriesId.Equals(default)) { seriesId = FindSeriesId(); } - return !seriesId.Equals(Guid.Empty) ? (LibraryManager.GetItemById(seriesId) as Series) : null; + return seriesId.Equals(default) ? null : (LibraryManager.GetItemById(seriesId) as Series); } } @@ -89,12 +89,12 @@ namespace MediaBrowser.Controller.Entities.TV get { var seasonId = SeasonId; - if (seasonId.Equals(Guid.Empty)) + if (seasonId.Equals(default)) { seasonId = FindSeasonId(); } - return !seasonId.Equals(Guid.Empty) ? (LibraryManager.GetItemById(seasonId) as Season) : null; + return seasonId.Equals(default) ? null : (LibraryManager.GetItemById(seasonId) as Season); } } @@ -271,7 +271,7 @@ namespace MediaBrowser.Controller.Entities.TV var seasonId = SeasonId; - if (!seasonId.Equals(Guid.Empty) && !list.Contains(seasonId)) + if (!seasonId.Equals(default) && !list.Contains(seasonId)) { list.Add(seasonId); } diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs index 926c7b045..bd8df2fac 100644 --- a/MediaBrowser.Controller/Entities/TV/Season.cs +++ b/MediaBrowser.Controller/Entities/TV/Season.cs @@ -48,12 +48,12 @@ namespace MediaBrowser.Controller.Entities.TV get { var seriesId = SeriesId; - if (seriesId == Guid.Empty) + if (seriesId.Equals(default)) { seriesId = FindSeriesId(); } - return seriesId == Guid.Empty ? null : (LibraryManager.GetItemById(seriesId) as Series); + return seriesId.Equals(default) ? null : (LibraryManager.GetItemById(seriesId) as Series); } } diff --git a/MediaBrowser.Controller/Entities/UserView.cs b/MediaBrowser.Controller/Entities/UserView.cs index 5c9be7337..47432ee93 100644 --- a/MediaBrowser.Controller/Entities/UserView.cs +++ b/MediaBrowser.Controller/Entities/UserView.cs @@ -69,11 +69,11 @@ namespace MediaBrowser.Controller.Entities /// <inheritdoc /> public override IEnumerable<Guid> GetIdsForAncestorQuery() { - if (!DisplayParentId.Equals(Guid.Empty)) + if (!DisplayParentId.Equals(default)) { yield return DisplayParentId; } - else if (!ParentId.Equals(Guid.Empty)) + else if (!ParentId.Equals(default)) { yield return ParentId; } @@ -94,11 +94,11 @@ namespace MediaBrowser.Controller.Entities { var parent = this as Folder; - if (!DisplayParentId.Equals(Guid.Empty)) + if (!DisplayParentId.Equals(default)) { parent = LibraryManager.GetItemById(DisplayParentId) as Folder ?? parent; } - else if (!ParentId.Equals(Guid.Empty)) + else if (!ParentId.Equals(default)) { parent = LibraryManager.GetItemById(ParentId) as Folder ?? parent; } diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index 279206da4..2996104e7 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -988,7 +988,7 @@ namespace MediaBrowser.Controller.Entities public static IEnumerable<BaseItem> FilterForAdjacency(List<BaseItem> list, string adjacentToId) { var adjacentToIdGuid = new Guid(adjacentToId); - var adjacentToItem = list.FirstOrDefault(i => i.Id == adjacentToIdGuid); + var adjacentToItem = list.FirstOrDefault(i => i.Id.Equals(adjacentToIdGuid)); var index = list.IndexOf(adjacentToItem); @@ -1005,7 +1005,7 @@ namespace MediaBrowser.Controller.Entities nextId = list[index + 1].Id; } - return list.Where(i => i.Id == previousId || i.Id == nextId || i.Id == adjacentToIdGuid); + return list.Where(i => i.Id.Equals(previousId) || i.Id.Equals(nextId) || i.Id.Equals(adjacentToIdGuid)); } } } diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index 5ab7808c3..5de2e0f50 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -455,7 +455,7 @@ namespace MediaBrowser.Controller.Entities foreach (var child in LinkedAlternateVersions) { // Reset the cached value - if (child.ItemId.HasValue && child.ItemId.Value.Equals(Guid.Empty)) + if (child.ItemId.HasValue && child.ItemId.Value.Equals(default)) { child.ItemId = null; } diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index b4aff60e1..261ce915f 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -842,8 +842,9 @@ namespace MediaBrowser.Controller.MediaEncoding /// </summary> /// <param name="state">Encoding state.</param> /// <param name="options">Encoding options.</param> + /// <param name="segmentContainer">Segment Container.</param> /// <returns>Input arguments.</returns> - public string GetInputArgument(EncodingJobInfo state, EncodingOptions options) + public string GetInputArgument(EncodingJobInfo state, EncodingOptions options, string segmentContainer) { var arg = new StringBuilder(); var inputVidHwaccelArgs = GetInputVideoHwaccelArgs(state, options); @@ -880,7 +881,7 @@ namespace MediaBrowser.Controller.MediaEncoding } // Also seek the external subtitles stream. - var seekSubParam = GetFastSeekCommandLineParameter(state, options); + var seekSubParam = GetFastSeekCommandLineParameter(state, options, segmentContainer); if (!string.IsNullOrEmpty(seekSubParam)) { arg.Append(' ').Append(seekSubParam); @@ -897,7 +898,7 @@ namespace MediaBrowser.Controller.MediaEncoding if (state.AudioStream != null && state.AudioStream.IsExternal) { // Also seek the external audio stream. - var seekAudioParam = GetFastSeekCommandLineParameter(state, options); + var seekAudioParam = GetFastSeekCommandLineParameter(state, options, segmentContainer); if (!string.IsNullOrEmpty(seekAudioParam)) { arg.Append(' ').Append(seekAudioParam); @@ -2161,9 +2162,10 @@ namespace MediaBrowser.Controller.MediaEncoding /// </summary> /// <param name="state">The state.</param> /// <param name="options">The options.</param> + /// <param name="segmentContainer">Segment Container.</param> /// <returns>System.String.</returns> /// <value>The fast seek command line parameter.</value> - public string GetFastSeekCommandLineParameter(EncodingJobInfo state, EncodingOptions options) + public string GetFastSeekCommandLineParameter(EncodingJobInfo state, EncodingOptions options, string segmentContainer) { var time = state.BaseRequest.StartTimeTicks ?? 0; var seekParam = string.Empty; @@ -2175,11 +2177,14 @@ namespace MediaBrowser.Controller.MediaEncoding if (state.IsVideoRequest) { var outputVideoCodec = GetVideoEncoder(state, options); + var segmentFormat = GetSegmentFileExtension(segmentContainer).TrimStart('.'); // Important: If this is ever re-enabled, make sure not to use it with wtv because it breaks seeking + // Disable -noaccurate_seek on mpegts container due to the timestamps issue on some clients, + // but it's still required for fMP4 container otherwise the audio can't be synced to the video. if (!string.Equals(state.InputContainer, "wtv", StringComparison.OrdinalIgnoreCase) + && !string.Equals(segmentFormat, "ts", StringComparison.OrdinalIgnoreCase) && state.TranscodingType != TranscodingJobType.Progressive - && state.TranscodingType != TranscodingJobType.Hls && !state.EnableBreakOnNonKeyFrames(outputVideoCodec) && (state.BaseRequest.StartTimeTicks ?? 0) > 0) { @@ -2791,16 +2796,15 @@ namespace MediaBrowser.Controller.MediaEncoding var isSwDecoder = string.IsNullOrEmpty(vidDecoder); var isSwEncoder = !vidEncoder.Contains("nvenc", StringComparison.OrdinalIgnoreCase); - // legacy cuvid(resize/deint/sw) pipeline(copy-back) + // legacy cuvid pipeline(copy-back) if ((isSwDecoder && isSwEncoder) || !IsCudaFullSupported() - || !options.EnableEnhancedNvdecDecoder || !_mediaEncoder.SupportsFilter("alphasrc")) { return GetSwVidFilterChain(state, options, vidEncoder); } - // prefered nvdec + cuda filters + nvenc pipeline + // prefered nvdec/cuvid + cuda filters + nvenc pipeline return GetNvidiaVidFiltersPrefered(state, options, vidDecoder, vidEncoder); } @@ -2818,11 +2822,11 @@ namespace MediaBrowser.Controller.MediaEncoding var reqMaxH = state.BaseRequest.MaxHeight; var threeDFormat = state.MediaSource.Video3DFormat; - var isNvdecDecoder = vidDecoder.Contains("cuda", StringComparison.OrdinalIgnoreCase); + var isNvDecoder = vidDecoder.Contains("cuda", StringComparison.OrdinalIgnoreCase); var isNvencEncoder = vidEncoder.Contains("nvenc", StringComparison.OrdinalIgnoreCase); var isSwDecoder = string.IsNullOrEmpty(vidDecoder); var isSwEncoder = !isNvencEncoder; - var isCuInCuOut = isNvdecDecoder && isNvencEncoder; + var isCuInCuOut = isNvDecoder && isNvencEncoder; var doubleRateDeint = options.DeinterlaceDoubleRate && (state.VideoStream?.AverageFrameRate ?? 60) <= 30; var doDeintH264 = state.DeInterlace("h264", true) || state.DeInterlace("avc", true); @@ -2865,7 +2869,7 @@ namespace MediaBrowser.Controller.MediaEncoding } } - if (isNvdecDecoder) + if (isNvDecoder) { // INPUT cuda surface(vram) // hw deint @@ -2890,7 +2894,7 @@ namespace MediaBrowser.Controller.MediaEncoding var memoryOutput = false; var isUploadForOclTonemap = isSwDecoder && doCuTonemap; - if ((isNvdecDecoder && isSwEncoder) || isUploadForOclTonemap) + if ((isNvDecoder && isSwEncoder) || isUploadForOclTonemap) { memoryOutput = true; @@ -4422,10 +4426,18 @@ namespace MediaBrowser.Controller.MediaEncoding // Nvidia cuda if (string.Equals(options.HardwareAccelerationType, "nvenc", StringComparison.OrdinalIgnoreCase)) { - if (options.EnableEnhancedNvdecDecoder && isCudaSupported && isCodecAvailable) + if (isCudaSupported && isCodecAvailable) { - // set -threads 1 to nvdec decoder explicitly since it doesn't implement threading support. - return " -hwaccel cuda" + (outputHwSurface ? " -hwaccel_output_format cuda" : string.Empty) + " -threads 1" + (isAv1 ? " -c:v av1" : string.Empty); + if (options.EnableEnhancedNvdecDecoder) + { + // set -threads 1 to nvdec decoder explicitly since it doesn't implement threading support. + return " -hwaccel cuda" + (outputHwSurface ? " -hwaccel_output_format cuda" : string.Empty) + " -threads 1" + (isAv1 ? " -c:v av1" : string.Empty); + } + else + { + // cuvid decoder doesn't have threading issue. + return " -hwaccel cuda" + (outputHwSurface ? " -hwaccel_output_format cuda" : string.Empty); + } } } @@ -4535,9 +4547,7 @@ namespace MediaBrowser.Controller.MediaEncoding return null; } - var hwSurface = IsCudaFullSupported() - && options.EnableEnhancedNvdecDecoder - && _mediaEncoder.SupportsFilter("alphasrc"); + var hwSurface = IsCudaFullSupported() && _mediaEncoder.SupportsFilter("alphasrc"); var is8bitSwFormatsNvdec = string.Equals("yuv420p", videoStream.PixelFormat, StringComparison.OrdinalIgnoreCase); var is8_10bitSwFormatsNvdec = is8bitSwFormatsNvdec || string.Equals("yuv420p10le", videoStream.PixelFormat, StringComparison.OrdinalIgnoreCase); // TODO: add more 8/10/12bit and 4:4:4 formats for Nvdec after finishing the ffcheck tool @@ -4825,7 +4835,7 @@ namespace MediaBrowser.Controller.MediaEncoding } } - public string GetInputModifier(EncodingJobInfo state, EncodingOptions encodingOptions) + public string GetInputModifier(EncodingJobInfo state, EncodingOptions encodingOptions, string segmentContainer) { var inputModifier = string.Empty; var probeSizeArgument = string.Empty; @@ -4861,7 +4871,7 @@ namespace MediaBrowser.Controller.MediaEncoding inputModifier = inputModifier.Trim(); - inputModifier += " " + GetFastSeekCommandLineParameter(state, encodingOptions); + inputModifier += " " + GetFastSeekCommandLineParameter(state, encodingOptions, segmentContainer); inputModifier = inputModifier.Trim(); if (state.InputProtocol == MediaProtocol.Rtsp) @@ -5168,13 +5178,13 @@ namespace MediaBrowser.Controller.MediaEncoding var threads = GetNumberOfThreads(state, encodingOptions, videoCodec); - var inputModifier = GetInputModifier(state, encodingOptions); + var inputModifier = GetInputModifier(state, encodingOptions, null); return string.Format( CultureInfo.InvariantCulture, "{0} {1}{2} {3} {4} -map_metadata -1 -map_chapters -1 -threads {5} {6}{7}{8} -y \"{9}\"", inputModifier, - GetInputArgument(state, encodingOptions), + GetInputArgument(state, encodingOptions, null), keyFrame, GetMapArgs(state), GetProgressiveVideoArguments(state, encodingOptions, videoCodec, defaultPreset), @@ -5356,13 +5366,13 @@ namespace MediaBrowser.Controller.MediaEncoding var threads = GetNumberOfThreads(state, encodingOptions, null); - var inputModifier = GetInputModifier(state, encodingOptions); + var inputModifier = GetInputModifier(state, encodingOptions, null); return string.Format( CultureInfo.InvariantCulture, "{0} {1}{7}{8} -threads {2}{3} {4} -id3v2_version 3 -write_id3v1 1{6} -y \"{5}\"", inputModifier, - GetInputArgument(state, encodingOptions), + GetInputArgument(state, encodingOptions, null), threads, " -vn", string.Join(' ', audioTranscodeParams), diff --git a/MediaBrowser.Controller/Playlists/Playlist.cs b/MediaBrowser.Controller/Playlists/Playlist.cs index 89f3bdf46..828ecb2c5 100644 --- a/MediaBrowser.Controller/Playlists/Playlist.cs +++ b/MediaBrowser.Controller/Playlists/Playlist.cs @@ -233,7 +233,7 @@ namespace MediaBrowser.Controller.Playlists return base.IsVisible(user); } - if (user.Id == OwnerUserId) + if (user.Id.Equals(OwnerUserId)) { return true; } @@ -244,8 +244,8 @@ namespace MediaBrowser.Controller.Playlists return base.IsVisible(user); } - var userId = user.Id.ToString("N", CultureInfo.InvariantCulture); - return shares.Any(share => string.Equals(share.UserId, userId, StringComparison.OrdinalIgnoreCase)); + var userId = user.Id; + return shares.Any(share => Guid.TryParse(share.UserId, out var id) && id.Equals(userId)); } public override bool IsVisibleStandalone(User user) |
