mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-21 17:44:43 +01:00
Merge remote-tracking branch 'upstream/master' into fmp4-hls
This commit is contained in:
86
MediaBrowser.Controller/BaseItemManager/BaseItemManager.cs
Normal file
86
MediaBrowser.Controller/BaseItemManager/BaseItemManager.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using MediaBrowser.Controller.Channels;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
|
||||
namespace MediaBrowser.Controller.BaseItemManager
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public class BaseItemManager : IBaseItemManager
|
||||
{
|
||||
private readonly IServerConfigurationManager _serverConfigurationManager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BaseItemManager"/> class.
|
||||
/// </summary>
|
||||
/// <param name="serverConfigurationManager">Instance of the <see cref="IServerConfigurationManager"/> interface.</param>
|
||||
public BaseItemManager(IServerConfigurationManager serverConfigurationManager)
|
||||
{
|
||||
_serverConfigurationManager = serverConfigurationManager;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsMetadataFetcherEnabled(BaseItem baseItem, LibraryOptions libraryOptions, string name)
|
||||
{
|
||||
if (baseItem is Channel)
|
||||
{
|
||||
// Hack alert.
|
||||
return true;
|
||||
}
|
||||
|
||||
if (baseItem.SourceType == SourceType.Channel)
|
||||
{
|
||||
// Hack alert.
|
||||
return !baseItem.EnableMediaSourceDisplay;
|
||||
}
|
||||
|
||||
var typeOptions = libraryOptions.GetTypeOptions(GetType().Name);
|
||||
if (typeOptions != null)
|
||||
{
|
||||
return typeOptions.ImageFetchers.Contains(name, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
if (!libraryOptions.EnableInternetProviders)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var itemConfig = _serverConfigurationManager.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, GetType().Name, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
return itemConfig == null || !itemConfig.DisabledImageFetchers.Contains(name, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsImageFetcherEnabled(BaseItem baseItem, LibraryOptions libraryOptions, string name)
|
||||
{
|
||||
if (baseItem is Channel)
|
||||
{
|
||||
// Hack alert.
|
||||
return true;
|
||||
}
|
||||
|
||||
if (baseItem.SourceType == SourceType.Channel)
|
||||
{
|
||||
// Hack alert.
|
||||
return !baseItem.EnableMediaSourceDisplay;
|
||||
}
|
||||
|
||||
var typeOptions = libraryOptions.GetTypeOptions(GetType().Name);
|
||||
if (typeOptions != null)
|
||||
{
|
||||
return typeOptions.ImageFetchers.Contains(name, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
if (!libraryOptions.EnableInternetProviders)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var itemConfig = _serverConfigurationManager.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, GetType().Name, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
return itemConfig == null || !itemConfig.DisabledImageFetchers.Contains(name, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
}
|
||||
29
MediaBrowser.Controller/BaseItemManager/IBaseItemManager.cs
Normal file
29
MediaBrowser.Controller/BaseItemManager/IBaseItemManager.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
|
||||
namespace MediaBrowser.Controller.BaseItemManager
|
||||
{
|
||||
/// <summary>
|
||||
/// The <c>BaseItem</c> manager.
|
||||
/// </summary>
|
||||
public interface IBaseItemManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Is metadata fetcher enabled.
|
||||
/// </summary>
|
||||
/// <param name="baseItem">The base item.</param>
|
||||
/// <param name="libraryOptions">The library options.</param>
|
||||
/// <param name="name">The metadata fetcher name.</param>
|
||||
/// <returns><c>true</c> if metadata fetcher is enabled, else false.</returns>
|
||||
bool IsMetadataFetcherEnabled(BaseItem baseItem, LibraryOptions libraryOptions, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Is image fetcher enabled.
|
||||
/// </summary>
|
||||
/// <param name="baseItem">The base item.</param>
|
||||
/// <param name="libraryOptions">The library options.</param>
|
||||
/// <param name="name">The image fetcher name.</param>
|
||||
/// <returns><c>true</c> if image fetcher is enabled, else false.</returns>
|
||||
bool IsImageFetcherEnabled(BaseItem baseItem, LibraryOptions libraryOptions, string name);
|
||||
}
|
||||
}
|
||||
@@ -463,60 +463,6 @@ namespace MediaBrowser.Controller.Entities
|
||||
[JsonIgnore]
|
||||
public string PrimaryImagePath => this.GetImagePath(ImageType.Primary);
|
||||
|
||||
public bool IsMetadataFetcherEnabled(LibraryOptions libraryOptions, string name)
|
||||
{
|
||||
if (SourceType == SourceType.Channel)
|
||||
{
|
||||
// hack alert
|
||||
return !EnableMediaSourceDisplay;
|
||||
}
|
||||
|
||||
var typeOptions = libraryOptions.GetTypeOptions(GetType().Name);
|
||||
if (typeOptions != null)
|
||||
{
|
||||
return typeOptions.MetadataFetchers.Contains(name, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
if (!libraryOptions.EnableInternetProviders)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var itemConfig = ConfigurationManager.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, GetType().Name, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
return itemConfig == null || !itemConfig.DisabledMetadataFetchers.Contains(name, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public bool IsImageFetcherEnabled(LibraryOptions libraryOptions, string name)
|
||||
{
|
||||
if (this is Channel)
|
||||
{
|
||||
// hack alert
|
||||
return true;
|
||||
}
|
||||
|
||||
if (SourceType == SourceType.Channel)
|
||||
{
|
||||
// hack alert
|
||||
return !EnableMediaSourceDisplay;
|
||||
}
|
||||
|
||||
var typeOptions = libraryOptions.GetTypeOptions(GetType().Name);
|
||||
if (typeOptions != null)
|
||||
{
|
||||
return typeOptions.ImageFetchers.Contains(name, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
if (!libraryOptions.EnableInternetProviders)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var itemConfig = ConfigurationManager.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, GetType().Name, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
return itemConfig == null || !itemConfig.DisabledImageFetchers.Contains(name, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public virtual bool CanDelete()
|
||||
{
|
||||
if (SourceType == SourceType.Channel)
|
||||
@@ -2611,7 +2557,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
if (!AllowsMultipleImages(type))
|
||||
{
|
||||
throw new ArgumentException("The change index operation is only applicable to backdrops and screenshots");
|
||||
throw new ArgumentException("The change index operation is only applicable to backdrops and screen shots");
|
||||
}
|
||||
|
||||
var info1 = GetImageInfo(type, index1);
|
||||
|
||||
@@ -212,7 +212,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
|
||||
/// <summary>
|
||||
/// Loads our children. Validation will occur externally.
|
||||
/// We want this sychronous.
|
||||
/// We want this synchronous.
|
||||
/// </summary>
|
||||
protected virtual List<BaseItem> LoadChildren()
|
||||
{
|
||||
|
||||
@@ -248,7 +248,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
return null;
|
||||
}
|
||||
|
||||
// Seeing reported failures here, not sure yet if this is related to specfying input format
|
||||
// Seeing reported failures here, not sure yet if this is related to specifying input format
|
||||
if (string.Equals(container, "m4v", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return null;
|
||||
@@ -2519,7 +2519,8 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
/// <summary>
|
||||
/// Gets the number of threads.
|
||||
/// </summary>
|
||||
public int GetNumberOfThreads(EncodingJobInfo state, EncodingOptions encodingOptions, string outputVideoCodec)
|
||||
#nullable enable
|
||||
public static int GetNumberOfThreads(EncodingJobInfo? state, EncodingOptions encodingOptions, string? outputVideoCodec)
|
||||
{
|
||||
if (string.Equals(outputVideoCodec, "libvpx", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
@@ -2529,17 +2530,21 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
return Math.Max(Environment.ProcessorCount - 1, 1);
|
||||
}
|
||||
|
||||
var threads = state.BaseRequest.CpuCoreLimit ?? encodingOptions.EncodingThreadCount;
|
||||
var threads = state?.BaseRequest.CpuCoreLimit ?? encodingOptions.EncodingThreadCount;
|
||||
|
||||
// Automatic
|
||||
if (threads <= 0 || threads >= Environment.ProcessorCount)
|
||||
if (threads <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (threads >= Environment.ProcessorCount)
|
||||
{
|
||||
return Environment.ProcessorCount;
|
||||
}
|
||||
|
||||
return threads;
|
||||
}
|
||||
|
||||
#nullable disable
|
||||
public void TryStreamCopy(EncodingJobInfo state)
|
||||
{
|
||||
if (state.VideoStream != null && CanStreamCopyVideo(state, state.VideoStream))
|
||||
@@ -2983,7 +2988,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
var videoType = state.MediaSource.VideoType ?? VideoType.VideoFile;
|
||||
// Only use alternative encoders for video files.
|
||||
// When using concat with folder rips, if the mfx session fails to initialize, ffmpeg will be stuck retrying and will not exit gracefully
|
||||
// Since transcoding of folder rips is expiremental anyway, it's not worth adding additional variables such as this.
|
||||
// Since transcoding of folder rips is experimental anyway, it's not worth adding additional variables such as this.
|
||||
if (videoType != VideoType.VideoFile)
|
||||
{
|
||||
return null;
|
||||
|
||||
@@ -409,7 +409,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
{
|
||||
// Don't exceed what the encoder supports
|
||||
// Seeing issues of attempting to encode to 88200
|
||||
return Math.Min(44100, BaseRequest.AudioSampleRate.Value);
|
||||
return BaseRequest.AudioSampleRate.Value;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user