mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-03 14:28:46 +01:00
extracted more interfaces
This commit is contained in:
@@ -541,7 +541,7 @@ namespace MediaBrowser.Controller.Drawing
|
||||
/// <param name="imageType">Type of the image.</param>
|
||||
/// <returns>Guid.</returns>
|
||||
/// <exception cref="System.ArgumentNullException">item</exception>
|
||||
public Guid GetImageCacheTag(string originalImagePath, DateTime dateModified, IEnumerable<BaseImageEnhancer> imageEnhancers, BaseItem item, ImageType imageType)
|
||||
public Guid GetImageCacheTag(string originalImagePath, DateTime dateModified, IEnumerable<IImageEnhancer> imageEnhancers, BaseItem item, ImageType imageType)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
@@ -574,7 +574,7 @@ namespace MediaBrowser.Controller.Drawing
|
||||
/// <param name="imageType">Type of the image.</param>
|
||||
/// <param name="imageIndex">Index of the image.</param>
|
||||
/// <returns>Task{EnhancedImage}.</returns>
|
||||
private async Task<Image> ExecuteImageEnhancers(IEnumerable<BaseImageEnhancer> imageEnhancers, Image originalImage, BaseItem item, ImageType imageType, int imageIndex)
|
||||
private async Task<Image> ExecuteImageEnhancers(IEnumerable<IImageEnhancer> imageEnhancers, Image originalImage, BaseItem item, ImageType imageType, int imageIndex)
|
||||
{
|
||||
var result = originalImage;
|
||||
|
||||
|
||||
@@ -217,8 +217,7 @@ namespace MediaBrowser.Controller
|
||||
/// Image processors are specialized metadata providers that run after the normal ones
|
||||
/// </summary>
|
||||
/// <value>The image enhancers.</value>
|
||||
[ImportMany(typeof(BaseImageEnhancer))]
|
||||
public BaseImageEnhancer[] ImageEnhancers { get; private set; }
|
||||
public IEnumerable<IImageEnhancer> ImageEnhancers { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of currently registered entity resolvers
|
||||
@@ -387,6 +386,7 @@ namespace MediaBrowser.Controller
|
||||
WeatherProviders = GetExports<IWeatherProvider>(allTypes);
|
||||
IntroProviders = GetExports<IIntroProvider>(allTypes);
|
||||
PluginConfigurationPages = GetExports<IPluginConfigurationPage>(allTypes);
|
||||
ImageEnhancers = GetExports<IImageEnhancer>(allTypes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -138,7 +138,7 @@
|
||||
<Compile Include="Plugins\IPluginConfigurationPage.cs" />
|
||||
<Compile Include="Plugins\PluginSecurityManager.cs" />
|
||||
<Compile Include="Providers\FanartBaseProvider.cs" />
|
||||
<Compile Include="Providers\BaseImageEnhancer.cs" />
|
||||
<Compile Include="Providers\IImageEnhancer.cs" />
|
||||
<Compile Include="Providers\ImagesByNameProvider.cs" />
|
||||
<Compile Include="Providers\MediaInfo\BaseFFMpegImageProvider.cs" />
|
||||
<Compile Include="Providers\MediaInfo\BaseFFMpegProvider.cs" />
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Drawing;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Controller.Providers
|
||||
{
|
||||
/// <summary>
|
||||
/// Class BaseImageEnhancer
|
||||
/// </summary>
|
||||
public abstract class BaseImageEnhancer : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Return true only if the given image for the given item will be enhanced by this enhancer.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="imageType">Type of the image.</param>
|
||||
/// <returns><c>true</c> if this enhancer will enhance the supplied image for the supplied item, <c>false</c> otherwise</returns>
|
||||
public abstract bool Supports(BaseItem item, ImageType imageType);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the priority or order in which this enhancer should be run.
|
||||
/// </summary>
|
||||
/// <value>The priority.</value>
|
||||
public abstract MetadataProviderPriority Priority { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Return the date of the last configuration change affecting the provided baseitem and image type
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="imageType">Type of the image.</param>
|
||||
/// <returns>Date of last config change</returns>
|
||||
public virtual DateTime LastConfigurationChange(BaseItem item, ImageType imageType)
|
||||
{
|
||||
return DateTime.MinValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases unmanaged and - optionally - managed resources.
|
||||
/// </summary>
|
||||
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
||||
protected virtual void Dispose(bool dispose)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the size of the enhanced image.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="imageType">Type of the image.</param>
|
||||
/// <param name="imageIndex">Index of the image.</param>
|
||||
/// <param name="originalImageSize">Size of the original image.</param>
|
||||
/// <returns>ImageSize.</returns>
|
||||
public virtual ImageSize GetEnhancedImageSize(BaseItem item, ImageType imageType, int imageIndex, ImageSize originalImageSize)
|
||||
{
|
||||
return originalImageSize;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enhances the supplied image and returns it
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="originalImage">The original image.</param>
|
||||
/// <param name="imageType">Type of the image.</param>
|
||||
/// <param name="imageIndex">Index of the image.</param>
|
||||
/// <returns>Task{System.Drawing.Image}.</returns>
|
||||
protected abstract Task<Image> EnhanceImageAsyncInternal(BaseItem item, Image originalImage, ImageType imageType, int imageIndex);
|
||||
|
||||
/// <summary>
|
||||
/// Enhances the image async.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="originalImage">The original image.</param>
|
||||
/// <param name="imageType">Type of the image.</param>
|
||||
/// <param name="imageIndex">Index of the image.</param>
|
||||
/// <returns>Task{Image}.</returns>
|
||||
/// <exception cref="System.ArgumentNullException"></exception>
|
||||
public Task<Image> EnhanceImageAsync(BaseItem item, Image originalImage, ImageType imageType, int imageIndex)
|
||||
{
|
||||
if (item == null || originalImage == null)
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
}
|
||||
|
||||
return EnhanceImageAsyncInternal(item, originalImage, imageType, imageIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
55
MediaBrowser.Controller/Providers/IImageEnhancer.cs
Normal file
55
MediaBrowser.Controller/Providers/IImageEnhancer.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Drawing;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Controller.Providers
|
||||
{
|
||||
public interface IImageEnhancer
|
||||
{
|
||||
/// <summary>
|
||||
/// Return true only if the given image for the given item will be enhanced by this enhancer.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="imageType">Type of the image.</param>
|
||||
/// <returns><c>true</c> if this enhancer will enhance the supplied image for the supplied item, <c>false</c> otherwise</returns>
|
||||
bool Supports(BaseItem item, ImageType imageType);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the priority or order in which this enhancer should be run.
|
||||
/// </summary>
|
||||
/// <value>The priority.</value>
|
||||
MetadataProviderPriority Priority { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Return the date of the last configuration change affecting the provided baseitem and image type
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="imageType">Type of the image.</param>
|
||||
/// <returns>Date of last config change</returns>
|
||||
DateTime LastConfigurationChange(BaseItem item, ImageType imageType);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the size of the enhanced image.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="imageType">Type of the image.</param>
|
||||
/// <param name="imageIndex">Index of the image.</param>
|
||||
/// <param name="originalImageSize">Size of the original image.</param>
|
||||
/// <returns>ImageSize.</returns>
|
||||
ImageSize GetEnhancedImageSize(BaseItem item, ImageType imageType, int imageIndex, ImageSize originalImageSize);
|
||||
|
||||
/// <summary>
|
||||
/// Enhances the image async.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="originalImage">The original image.</param>
|
||||
/// <param name="imageType">Type of the image.</param>
|
||||
/// <param name="imageIndex">Index of the image.</param>
|
||||
/// <returns>Task{Image}.</returns>
|
||||
/// <exception cref="System.ArgumentNullException"></exception>
|
||||
Task<Image> EnhanceImageAsync(BaseItem item, Image originalImage, ImageType imageType, int imageIndex);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user