< Summary - Jellyfin

Information
Class: Jellyfin.MediaEncoding.Hls.Extensions.MediaEncodingHlsServiceCollectionExtensions
Assembly: Jellyfin.MediaEncoding.Hls
File(s): /srv/git/jellyfin/src/Jellyfin.MediaEncoding.Hls/Extensions/MediaEncodingHlsServiceCollectionExtensions.cs
Line coverage
100%
Covered lines: 14
Uncovered lines: 0
Coverable lines: 14
Total lines: 36
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
AddHlsPlaylistGenerator(...)100%11100%
AddSingletonWithDecorator(...)100%11100%

File(s)

/srv/git/jellyfin/src/Jellyfin.MediaEncoding.Hls/Extensions/MediaEncodingHlsServiceCollectionExtensions.cs

#LineLine coverage
 1using System;
 2using Jellyfin.MediaEncoding.Hls.Cache;
 3using Jellyfin.MediaEncoding.Hls.Extractors;
 4using Jellyfin.MediaEncoding.Hls.Playlist;
 5using Microsoft.Extensions.DependencyInjection;
 6
 7namespace Jellyfin.MediaEncoding.Hls.Extensions;
 8
 9/// <summary>
 10/// Extensions for the <see cref="IServiceCollection"/> interface.
 11/// </summary>
 12public static class MediaEncodingHlsServiceCollectionExtensions
 13{
 14    /// <summary>
 15    /// Adds the hls playlist generators to the <see cref="IServiceCollection"/>.
 16    /// </summary>
 17    /// <param name="serviceCollection">An instance of the <see cref="IServiceCollection"/> interface.</param>
 18    /// <returns>The updated service collection.</returns>
 19    public static IServiceCollection AddHlsPlaylistGenerator(this IServiceCollection serviceCollection)
 2220    {
 2221        serviceCollection.AddSingletonWithDecorator(typeof(FfProbeKeyframeExtractor));
 2222        serviceCollection.AddSingletonWithDecorator(typeof(MatroskaKeyframeExtractor));
 2223        serviceCollection.AddSingleton<IDynamicHlsPlaylistGenerator, DynamicHlsPlaylistGenerator>();
 2224        return serviceCollection;
 2225    }
 26
 27    private static void AddSingletonWithDecorator(this IServiceCollection serviceCollection, Type type)
 4428    {
 4429        serviceCollection.AddSingleton<IKeyframeExtractor>(serviceProvider =>
 4430        {
 4431            var extractor = ActivatorUtilities.CreateInstance(serviceProvider, type);
 4432            var decorator = ActivatorUtilities.CreateInstance<CacheDecorator>(serviceProvider, extractor);
 4433            return decorator;
 4434        });
 4435    }
 36}