mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-28 04:51:54 +00:00
Refactor and add scheduled task
This commit is contained in:
@@ -1,21 +1,36 @@
|
||||
using Jellyfin.MediaEncoding.Hls.Playlist;
|
||||
using System;
|
||||
using Jellyfin.MediaEncoding.Hls.Cache;
|
||||
using Jellyfin.MediaEncoding.Hls.Extractors;
|
||||
using Jellyfin.MediaEncoding.Hls.Playlist;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Jellyfin.MediaEncoding.Hls.Extensions
|
||||
namespace Jellyfin.MediaEncoding.Hls.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// Extensions for the <see cref="IServiceCollection"/> interface.
|
||||
/// </summary>
|
||||
public static class MediaEncodingHlsServiceCollectionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Extensions for the <see cref="IServiceCollection"/> interface.
|
||||
/// Adds the hls playlist generators to the <see cref="IServiceCollection"/>.
|
||||
/// </summary>
|
||||
public static class MediaEncodingHlsServiceCollectionExtensions
|
||||
/// <param name="serviceCollection">An instance of the <see cref="IServiceCollection"/> interface.</param>
|
||||
/// <returns>The updated service collection.</returns>
|
||||
public static IServiceCollection AddHlsPlaylistGenerator(this IServiceCollection serviceCollection)
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds the hls playlist generators to the <see cref="IServiceCollection"/>.
|
||||
/// </summary>
|
||||
/// <param name="serviceCollection">An instance of the <see cref="IServiceCollection"/> interface.</param>
|
||||
/// <returns>The updated service collection.</returns>
|
||||
public static IServiceCollection AddHlsPlaylistGenerator(this IServiceCollection serviceCollection)
|
||||
serviceCollection.AddSingletonWithDecorator(typeof(FfProbeKeyframeExtractor));
|
||||
serviceCollection.AddSingletonWithDecorator(typeof(MatroskaKeyframeExtractor));
|
||||
serviceCollection.AddSingleton<IDynamicHlsPlaylistGenerator, DynamicHlsPlaylistGenerator>();
|
||||
return serviceCollection;
|
||||
}
|
||||
|
||||
private static void AddSingletonWithDecorator(this IServiceCollection serviceCollection, Type type)
|
||||
{
|
||||
serviceCollection.AddSingleton<IKeyframeExtractor>(serviceProvider =>
|
||||
{
|
||||
return serviceCollection.AddSingleton<IDynamicHlsPlaylistGenerator, DynamicHlsPlaylistGenerator>();
|
||||
}
|
||||
var extractor = ActivatorUtilities.CreateInstance(serviceProvider, type);
|
||||
var decorator = ActivatorUtilities.CreateInstance<CacheDecorator>(serviceProvider, extractor);
|
||||
return decorator;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user