aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server/CoreAppHost.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Jellyfin.Server/CoreAppHost.cs')
-rw-r--r--Jellyfin.Server/CoreAppHost.cs42
1 files changed, 36 insertions, 6 deletions
diff --git a/Jellyfin.Server/CoreAppHost.cs b/Jellyfin.Server/CoreAppHost.cs
index ed5968ad6..331a32c73 100644
--- a/Jellyfin.Server/CoreAppHost.cs
+++ b/Jellyfin.Server/CoreAppHost.cs
@@ -1,10 +1,18 @@
+using System;
using System.Collections.Generic;
+using System.IO;
using System.Reflection;
+using Emby.Drawing;
using Emby.Server.Implementations;
+using Jellyfin.Drawing.Skia;
+using Jellyfin.Server.Implementations;
+using Jellyfin.Server.Implementations.Activity;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Drawing;
+using MediaBrowser.Model.Activity;
using MediaBrowser.Model.IO;
-using Microsoft.Extensions.Configuration;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace Jellyfin.Server
@@ -21,27 +29,49 @@ namespace Jellyfin.Server
/// <param name="loggerFactory">The <see cref="ILoggerFactory" /> to be used by the <see cref="CoreAppHost" />.</param>
/// <param name="options">The <see cref="StartupOptions" /> to be used by the <see cref="CoreAppHost" />.</param>
/// <param name="fileSystem">The <see cref="IFileSystem" /> to be used by the <see cref="CoreAppHost" />.</param>
- /// <param name="imageEncoder">The <see cref="IImageEncoder" /> to be used by the <see cref="CoreAppHost" />.</param>
/// <param name="networkManager">The <see cref="INetworkManager" /> to be used by the <see cref="CoreAppHost" />.</param>
public CoreAppHost(
ServerApplicationPaths applicationPaths,
ILoggerFactory loggerFactory,
StartupOptions options,
IFileSystem fileSystem,
- IImageEncoder imageEncoder,
INetworkManager networkManager)
: base(
applicationPaths,
loggerFactory,
options,
fileSystem,
- imageEncoder,
networkManager)
{
}
- /// <inheritdoc />
- public override bool CanSelfRestart => StartupOptions.RestartPath != null;
+ /// <inheritdoc/>
+ protected override void RegisterServices(IServiceCollection serviceCollection)
+ {
+ // Register an image encoder
+ bool useSkiaEncoder = SkiaEncoder.IsNativeLibAvailable();
+ Type imageEncoderType = useSkiaEncoder
+ ? typeof(SkiaEncoder)
+ : typeof(NullImageEncoder);
+ serviceCollection.AddSingleton(typeof(IImageEncoder), imageEncoderType);
+
+ // Log a warning if the Skia encoder could not be used
+ if (!useSkiaEncoder)
+ {
+ Logger.LogWarning($"Skia not available. Will fallback to {nameof(NullImageEncoder)}.");
+ }
+
+ // TODO: Set up scoping and use AddDbContextPool
+ serviceCollection.AddDbContext<JellyfinDb>(
+ options => options.UseSqlite($"Filename={Path.Combine(ApplicationPaths.DataPath, "jellyfin.db")}"),
+ ServiceLifetime.Transient);
+
+ serviceCollection.AddSingleton<JellyfinDbProvider>();
+
+ serviceCollection.AddSingleton<IActivityManager, ActivityManager>();
+
+ base.RegisterServices(serviceCollection);
+ }
/// <inheritdoc />
protected override void RestartInternal() => Program.Restart();