aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller
diff options
context:
space:
mode:
authorMark Monteiro <marknr.monteiro@protonmail.com>2020-04-11 10:00:39 -0400
committerMark Monteiro <marknr.monteiro@protonmail.com>2020-04-11 10:00:39 -0400
commit1e1295bebfb37eb18d3704a903dd3de1d3e602f6 (patch)
tree0c238786e6d833ecc29cf68f06baa6cb5f92cbab /MediaBrowser.Controller
parentf91f2ef328a9d7693956ab33bf5c70be2f1213df (diff)
parent299541f1b26136ef89741f28c7949cda4e5e485f (diff)
Merge remote-tracking branch 'upstream/master' into register-services-correctly
Diffstat (limited to 'MediaBrowser.Controller')
-rw-r--r--MediaBrowser.Controller/Entities/BaseItem.cs44
-rw-r--r--MediaBrowser.Controller/Entities/InternalPeopleQuery.cs2
-rw-r--r--MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs35
-rw-r--r--MediaBrowser.Controller/Persistence/IItemRepository.cs4
4 files changed, 50 insertions, 35 deletions
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs
index 7380e6da1..56a361e0e 100644
--- a/MediaBrowser.Controller/Entities/BaseItem.cs
+++ b/MediaBrowser.Controller/Entities/BaseItem.cs
@@ -1326,8 +1326,9 @@ namespace MediaBrowser.Controller.Entities
}
// Use some hackery to get the extra type based on foldername
- Enum.TryParse(extraFolderName.Replace(" ", ""), true, out ExtraType extraType);
- item.ExtraType = extraType;
+ item.ExtraType = Enum.TryParse(extraFolderName.Replace(" ", string.Empty), true, out ExtraType extraType)
+ ? extraType
+ : Model.Entities.ExtraType.Unknown;
return item;
@@ -2877,14 +2878,29 @@ namespace MediaBrowser.Controller.Entities
/// <value>The remote trailers.</value>
public IReadOnlyList<MediaUrl> RemoteTrailers { get; set; }
+ /// <summary>
+ /// Get all extras associated with this item, sorted by <see cref="SortName"/>.
+ /// </summary>
+ /// <returns>An enumerable containing the items.</returns>
public IEnumerable<BaseItem> GetExtras()
{
- return ExtraIds.Select(LibraryManager.GetItemById).Where(i => i != null).OrderBy(i => i.SortName);
+ return ExtraIds
+ .Select(LibraryManager.GetItemById)
+ .Where(i => i != null)
+ .OrderBy(i => i.SortName);
}
+ /// <summary>
+ /// Get all extras with specific types that are associated with this item.
+ /// </summary>
+ /// <param name="extraTypes">The types of extras to retrieve.</param>
+ /// <returns>An enumerable containing the extras.</returns>
public IEnumerable<BaseItem> GetExtras(IReadOnlyCollection<ExtraType> extraTypes)
{
- return ExtraIds.Select(LibraryManager.GetItemById).Where(i => i?.ExtraType != null && extraTypes.Contains(i.ExtraType.Value));
+ return ExtraIds
+ .Select(LibraryManager.GetItemById)
+ .Where(i => i != null)
+ .Where(i => i.ExtraType.HasValue && extraTypes.Contains(i.ExtraType.Value));
}
public IEnumerable<BaseItem> GetTrailers()
@@ -2895,11 +2911,6 @@ namespace MediaBrowser.Controller.Entities
return Array.Empty<BaseItem>();
}
- public IEnumerable<BaseItem> GetDisplayExtras()
- {
- return GetExtras(DisplayExtraTypes);
- }
-
public virtual bool IsHD => Height >= 720;
public bool IsShortcut { get; set; }
@@ -2917,8 +2928,19 @@ namespace MediaBrowser.Controller.Entities
return RunTimeTicks ?? 0;
}
- // Possible types of extra videos
- public static readonly IReadOnlyCollection<ExtraType> DisplayExtraTypes = new[] { Model.Entities.ExtraType.BehindTheScenes, Model.Entities.ExtraType.Clip, Model.Entities.ExtraType.DeletedScene, Model.Entities.ExtraType.Interview, Model.Entities.ExtraType.Sample, Model.Entities.ExtraType.Scene };
+ /// <summary>
+ /// Extra types that should be counted and displayed as "Special Features" in the UI.
+ /// </summary>
+ public static readonly IReadOnlyCollection<ExtraType> DisplayExtraTypes = new HashSet<ExtraType>
+ {
+ Model.Entities.ExtraType.Unknown,
+ Model.Entities.ExtraType.BehindTheScenes,
+ Model.Entities.ExtraType.Clip,
+ Model.Entities.ExtraType.DeletedScene,
+ Model.Entities.ExtraType.Interview,
+ Model.Entities.ExtraType.Sample,
+ Model.Entities.ExtraType.Scene
+ };
public virtual bool SupportsExternalTransfer => false;
diff --git a/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs b/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs
index dfa581671..011975dd2 100644
--- a/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs
+++ b/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs
@@ -6,7 +6,7 @@ namespace MediaBrowser.Controller.Entities
{
/// <summary>
/// Gets or sets the maximum number of items the query should return.
- /// <summary>
+ /// </summary>
public int Limit { get; set; }
public Guid ItemId { get; set; }
diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
index 42379c73b..6e5fe97e5 100644
--- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
+++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
@@ -1636,7 +1636,7 @@ namespace MediaBrowser.Controller.MediaEncoding
var retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}][sub]overlay{3}\"";
// When the input may or may not be hardware VAAPI decodable
- if (string.Equals(options.HardwareAccelerationType, "vaapi", StringComparison.OrdinalIgnoreCase) && options.EnableHardwareEncoding)
+ if (string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase))
{
/*
[base]: HW scaling video to OutputSize
@@ -1648,7 +1648,8 @@ namespace MediaBrowser.Controller.MediaEncoding
}
// If we're hardware VAAPI decoding and software encoding, download frames from the decoder first
- else if (string.Equals(options.HardwareAccelerationType, "vaapi", StringComparison.OrdinalIgnoreCase) && !options.EnableHardwareEncoding)
+ else if (string.Equals(options.HardwareAccelerationType, "vaapi", StringComparison.OrdinalIgnoreCase)
+ && string.Equals(outputVideoCodec, "libx264", StringComparison.OrdinalIgnoreCase))
{
/*
[base]: SW scaling video to OutputSize
@@ -1996,14 +1997,14 @@ namespace MediaBrowser.Controller.MediaEncoding
var hasTextSubs = state.SubtitleStream != null && state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
// When the input may or may not be hardware VAAPI decodable
- if (string.Equals(options.HardwareAccelerationType, "vaapi", StringComparison.OrdinalIgnoreCase) && options.EnableHardwareEncoding)
+ if (string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase))
{
filters.Add("format=nv12|vaapi");
filters.Add("hwupload");
}
// When the input may or may not be hardware QSV decodable
- else if (string.Equals(options.HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase) && options.EnableHardwareEncoding)
+ else if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase))
{
if (!hasTextSubs)
{
@@ -2013,25 +2014,19 @@ namespace MediaBrowser.Controller.MediaEncoding
}
// If we're hardware VAAPI decoding and software encoding, download frames from the decoder first
-
- else if (string.Equals(options.HardwareAccelerationType, "vaapi", StringComparison.OrdinalIgnoreCase) && !options.EnableHardwareEncoding)
+ else if (string.Equals(options.HardwareAccelerationType, "vaapi", StringComparison.OrdinalIgnoreCase)
+ && string.Equals(outputVideoCodec, "libx264", StringComparison.OrdinalIgnoreCase))
{
var codec = videoStream.Codec.ToLowerInvariant();
var pixelFormat = videoStream.PixelFormat.ToLowerInvariant();
- // Assert 10-bit hardware VAAPI decodable
- if ((pixelFormat ?? string.Empty).IndexOf("p10", StringComparison.OrdinalIgnoreCase) != -1
- && (string.Equals(codec, "hevc", StringComparison.OrdinalIgnoreCase)
- || string.Equals(codec, "h265", StringComparison.OrdinalIgnoreCase)
- || string.Equals(codec, "vp9", StringComparison.OrdinalIgnoreCase)))
- {
- filters.Add("hwdownload");
- filters.Add("format=p010le");
- filters.Add("format=nv12");
- }
-
- // Assert 8-bit hardware VAAPI decodable
- else if ((pixelFormat ?? string.Empty).IndexOf("p10", StringComparison.OrdinalIgnoreCase) == -1)
+ // Assert hardware VAAPI decodable (Except h264 10-bit and higher color depth)
+ // TODO: a propery way to detect hardware capabilities and falling back when transcoding is failed
+ if ((pixelFormat ?? string.Empty).IndexOf("p10", StringComparison.OrdinalIgnoreCase) == -1
+ || ((pixelFormat ?? string.Empty).IndexOf("p10", StringComparison.OrdinalIgnoreCase) != -1
+ && (string.Equals(codec, "hevc", StringComparison.OrdinalIgnoreCase)
+ || string.Equals(codec, "h265", StringComparison.OrdinalIgnoreCase)
+ || string.Equals(codec, "vp9", StringComparison.OrdinalIgnoreCase))))
{
filters.Add("hwdownload");
filters.Add("format=nv12");
@@ -2077,7 +2072,7 @@ namespace MediaBrowser.Controller.MediaEncoding
filters.AddRange(GetScalingFilters(state, inputWidth, inputHeight, threeDFormat, videoDecoder, outputVideoCodec, request.Width, request.Height, request.MaxWidth, request.MaxHeight));
// Add parameters to use VAAPI with burn-in text subttiles (GH issue #642)
- if (string.Equals(options.HardwareAccelerationType, "vaapi", StringComparison.OrdinalIgnoreCase) && options.EnableHardwareEncoding)
+ if (string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase))
{
if (state.SubtitleStream != null
&& state.SubtitleStream.IsTextSubtitleStream
diff --git a/MediaBrowser.Controller/Persistence/IItemRepository.cs b/MediaBrowser.Controller/Persistence/IItemRepository.cs
index eb5a8ded8..75fc43a04 100644
--- a/MediaBrowser.Controller/Persistence/IItemRepository.cs
+++ b/MediaBrowser.Controller/Persistence/IItemRepository.cs
@@ -24,8 +24,7 @@ namespace MediaBrowser.Controller.Persistence
/// Deletes the item.
/// </summary>
/// <param name="id">The identifier.</param>
- /// <param name="cancellationToken">The cancellation token.</param>
- void DeleteItem(Guid id, CancellationToken cancellationToken);
+ void DeleteItem(Guid id);
/// <summary>
/// Saves the items.
@@ -169,4 +168,3 @@ namespace MediaBrowser.Controller.Persistence
List<string> GetAllArtistNames();
}
}
-