Files
pgsql-jellyfin/src/Jellyfin.MediaEncoding.Hls/Extensions/MediaEncodingHlsServiceCollectionExtensions.cs
T
wjones af1152b001 Refactor: standardize namespace and using directive style
Refactored all C# test files to use explicit namespace declarations and moved all using directives inside the namespace block for consistency. Updated assembly info and cache files to reflect the new build. Adjusted MvcTestingAppManifest.json to use fully qualified assembly names. No functional changes; all updates are related to code style, organization, and project metadata.
2026-02-20 16:26:53 -05:00

41 lines
1.7 KiB
C#

// <copyright file="MediaEncodingHlsServiceCollectionExtensions.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
namespace Jellyfin.MediaEncoding.Hls.Extensions;
using System;
using Jellyfin.MediaEncoding.Hls.Cache;
using Jellyfin.MediaEncoding.Hls.Extractors;
using Jellyfin.MediaEncoding.Hls.Playlist;
using Microsoft.Extensions.DependencyInjection;
/// <summary>
/// Extensions for the <see cref="IServiceCollection"/> interface.
/// </summary>
public static class MediaEncodingHlsServiceCollectionExtensions
{
/// <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 =>
{
var extractor = ActivatorUtilities.CreateInstance(serviceProvider, type);
var decorator = ActivatorUtilities.CreateInstance<CacheDecorator>(serviceProvider, extractor);
return decorator;
});
}
}