|
@@ -1,3 +1,5 @@
|
|
|
|
+#nullable disable
|
|
|
|
+
|
|
#pragma warning disable CS1591
|
|
#pragma warning disable CS1591
|
|
|
|
|
|
using System;
|
|
using System;
|
|
@@ -10,8 +12,6 @@ using System.Net;
|
|
using System.Reflection;
|
|
using System.Reflection;
|
|
using System.Runtime.InteropServices;
|
|
using System.Runtime.InteropServices;
|
|
using System.Security.Cryptography.X509Certificates;
|
|
using System.Security.Cryptography.X509Certificates;
|
|
-using System.Text;
|
|
|
|
-using System.Text.Json;
|
|
|
|
using System.Threading;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
using Emby.Dlna;
|
|
using Emby.Dlna;
|
|
@@ -43,6 +43,7 @@ using Emby.Server.Implementations.Serialization;
|
|
using Emby.Server.Implementations.Session;
|
|
using Emby.Server.Implementations.Session;
|
|
using Emby.Server.Implementations.SyncPlay;
|
|
using Emby.Server.Implementations.SyncPlay;
|
|
using Emby.Server.Implementations.TV;
|
|
using Emby.Server.Implementations.TV;
|
|
|
|
+using Emby.Server.Implementations.Udp;
|
|
using Emby.Server.Implementations.Updates;
|
|
using Emby.Server.Implementations.Updates;
|
|
using Jellyfin.Api.Helpers;
|
|
using Jellyfin.Api.Helpers;
|
|
using Jellyfin.Networking.Configuration;
|
|
using Jellyfin.Networking.Configuration;
|
|
@@ -50,7 +51,6 @@ using Jellyfin.Networking.Manager;
|
|
using MediaBrowser.Common;
|
|
using MediaBrowser.Common;
|
|
using MediaBrowser.Common.Configuration;
|
|
using MediaBrowser.Common.Configuration;
|
|
using MediaBrowser.Common.Events;
|
|
using MediaBrowser.Common.Events;
|
|
-using MediaBrowser.Common.Json;
|
|
|
|
using MediaBrowser.Common.Net;
|
|
using MediaBrowser.Common.Net;
|
|
using MediaBrowser.Common.Plugins;
|
|
using MediaBrowser.Common.Plugins;
|
|
using MediaBrowser.Common.Updates;
|
|
using MediaBrowser.Common.Updates;
|
|
@@ -99,6 +99,7 @@ using MediaBrowser.Providers.Subtitles;
|
|
using MediaBrowser.XbmcMetadata.Providers;
|
|
using MediaBrowser.XbmcMetadata.Providers;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
+using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
using Microsoft.Extensions.Logging;
|
|
using Prometheus.DotNetRuntime;
|
|
using Prometheus.DotNetRuntime;
|
|
@@ -118,6 +119,7 @@ namespace Emby.Server.Implementations
|
|
private static readonly string[] _relevantEnvVarPrefixes = { "JELLYFIN_", "DOTNET_", "ASPNETCORE_" };
|
|
private static readonly string[] _relevantEnvVarPrefixes = { "JELLYFIN_", "DOTNET_", "ASPNETCORE_" };
|
|
|
|
|
|
private readonly IFileSystem _fileSystemManager;
|
|
private readonly IFileSystem _fileSystemManager;
|
|
|
|
+ private readonly IConfiguration _startupConfig;
|
|
private readonly IXmlSerializer _xmlSerializer;
|
|
private readonly IXmlSerializer _xmlSerializer;
|
|
private readonly IStartupOptions _startupOptions;
|
|
private readonly IStartupOptions _startupOptions;
|
|
private readonly IPluginManager _pluginManager;
|
|
private readonly IPluginManager _pluginManager;
|
|
@@ -126,7 +128,6 @@ namespace Emby.Server.Implementations
|
|
private IMediaEncoder _mediaEncoder;
|
|
private IMediaEncoder _mediaEncoder;
|
|
private ISessionManager _sessionManager;
|
|
private ISessionManager _sessionManager;
|
|
private string[] _urlPrefixes;
|
|
private string[] _urlPrefixes;
|
|
- private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.GetOptions();
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Gets a value indicating whether this instance can self restart.
|
|
/// Gets a value indicating whether this instance can self restart.
|
|
@@ -211,7 +212,7 @@ namespace Emby.Server.Implementations
|
|
/// Gets or sets the configuration manager.
|
|
/// Gets or sets the configuration manager.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <value>The configuration manager.</value>
|
|
/// <value>The configuration manager.</value>
|
|
- protected IConfigurationManager ConfigurationManager { get; set; }
|
|
|
|
|
|
+ public ServerConfigurationManager ConfigurationManager { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Gets or sets the service provider.
|
|
/// Gets or sets the service provider.
|
|
@@ -229,10 +230,9 @@ namespace Emby.Server.Implementations
|
|
public int HttpsPort { get; private set; }
|
|
public int HttpsPort { get; private set; }
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// Gets the server configuration manager.
|
|
|
|
|
|
+ /// Gets the value of the PublishedServerUrl setting.
|
|
/// </summary>
|
|
/// </summary>
|
|
- /// <value>The server configuration manager.</value>
|
|
|
|
- public IServerConfigurationManager ServerConfigurationManager => (IServerConfigurationManager)ConfigurationManager;
|
|
|
|
|
|
+ public string PublishedServerUrl => _startupOptions.PublishedServerUrl ?? _startupConfig[UdpServer.AddressOverrideConfigKey];
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="ApplicationHost"/> class.
|
|
/// Initializes a new instance of the <see cref="ApplicationHost"/> class.
|
|
@@ -240,51 +240,37 @@ namespace Emby.Server.Implementations
|
|
/// <param name="applicationPaths">Instance of the <see cref="IServerApplicationPaths"/> interface.</param>
|
|
/// <param name="applicationPaths">Instance of the <see cref="IServerApplicationPaths"/> interface.</param>
|
|
/// <param name="loggerFactory">Instance of the <see cref="ILoggerFactory"/> interface.</param>
|
|
/// <param name="loggerFactory">Instance of the <see cref="ILoggerFactory"/> interface.</param>
|
|
/// <param name="options">Instance of the <see cref="IStartupOptions"/> interface.</param>
|
|
/// <param name="options">Instance of the <see cref="IStartupOptions"/> interface.</param>
|
|
|
|
+ /// <param name="startupConfig">The <see cref="IConfiguration" /> interface.</param>
|
|
/// <param name="fileSystem">Instance of the <see cref="IFileSystem"/> interface.</param>
|
|
/// <param name="fileSystem">Instance of the <see cref="IFileSystem"/> interface.</param>
|
|
/// <param name="serviceCollection">Instance of the <see cref="IServiceCollection"/> interface.</param>
|
|
/// <param name="serviceCollection">Instance of the <see cref="IServiceCollection"/> interface.</param>
|
|
public ApplicationHost(
|
|
public ApplicationHost(
|
|
IServerApplicationPaths applicationPaths,
|
|
IServerApplicationPaths applicationPaths,
|
|
ILoggerFactory loggerFactory,
|
|
ILoggerFactory loggerFactory,
|
|
IStartupOptions options,
|
|
IStartupOptions options,
|
|
|
|
+ IConfiguration startupConfig,
|
|
IFileSystem fileSystem,
|
|
IFileSystem fileSystem,
|
|
IServiceCollection serviceCollection)
|
|
IServiceCollection serviceCollection)
|
|
{
|
|
{
|
|
- _xmlSerializer = new MyXmlSerializer();
|
|
|
|
-
|
|
|
|
- ServiceCollection = serviceCollection;
|
|
|
|
-
|
|
|
|
ApplicationPaths = applicationPaths;
|
|
ApplicationPaths = applicationPaths;
|
|
LoggerFactory = loggerFactory;
|
|
LoggerFactory = loggerFactory;
|
|
|
|
+ _startupOptions = options;
|
|
|
|
+ _startupConfig = startupConfig;
|
|
_fileSystemManager = fileSystem;
|
|
_fileSystemManager = fileSystem;
|
|
-
|
|
|
|
- ConfigurationManager = new ServerConfigurationManager(ApplicationPaths, LoggerFactory, _xmlSerializer, _fileSystemManager);
|
|
|
|
- // Have to migrate settings here as migration subsystem not yet initialised.
|
|
|
|
- MigrateNetworkConfiguration();
|
|
|
|
-
|
|
|
|
- // Have to pre-register the NetworkConfigurationFactory, as the configuration sub-system is not yet initialised.
|
|
|
|
- ConfigurationManager.RegisterConfiguration<NetworkConfigurationFactory>();
|
|
|
|
- NetManager = new NetworkManager((IServerConfigurationManager)ConfigurationManager, LoggerFactory.CreateLogger<NetworkManager>());
|
|
|
|
|
|
+ ServiceCollection = serviceCollection;
|
|
|
|
|
|
Logger = LoggerFactory.CreateLogger<ApplicationHost>();
|
|
Logger = LoggerFactory.CreateLogger<ApplicationHost>();
|
|
-
|
|
|
|
- _startupOptions = options;
|
|
|
|
-
|
|
|
|
- // Initialize runtime stat collection
|
|
|
|
- if (ServerConfigurationManager.Configuration.EnableMetrics)
|
|
|
|
- {
|
|
|
|
- DotNetRuntimeStatsBuilder.Default().StartCollecting();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem));
|
|
fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem));
|
|
|
|
|
|
ApplicationVersion = typeof(ApplicationHost).Assembly.GetName().Version;
|
|
ApplicationVersion = typeof(ApplicationHost).Assembly.GetName().Version;
|
|
ApplicationVersionString = ApplicationVersion.ToString(3);
|
|
ApplicationVersionString = ApplicationVersion.ToString(3);
|
|
ApplicationUserAgent = Name.Replace(' ', '-') + "/" + ApplicationVersionString;
|
|
ApplicationUserAgent = Name.Replace(' ', '-') + "/" + ApplicationVersionString;
|
|
|
|
|
|
|
|
+ _xmlSerializer = new MyXmlSerializer();
|
|
|
|
+ ConfigurationManager = new ServerConfigurationManager(ApplicationPaths, LoggerFactory, _xmlSerializer, _fileSystemManager);
|
|
_pluginManager = new PluginManager(
|
|
_pluginManager = new PluginManager(
|
|
LoggerFactory.CreateLogger<PluginManager>(),
|
|
LoggerFactory.CreateLogger<PluginManager>(),
|
|
this,
|
|
this,
|
|
- ServerConfigurationManager.Configuration,
|
|
|
|
|
|
+ ConfigurationManager.Configuration,
|
|
ApplicationPaths.PluginsPath,
|
|
ApplicationPaths.PluginsPath,
|
|
ApplicationVersion);
|
|
ApplicationVersion);
|
|
}
|
|
}
|
|
@@ -299,9 +285,9 @@ namespace Emby.Server.Implementations
|
|
if (!File.Exists(path))
|
|
if (!File.Exists(path))
|
|
{
|
|
{
|
|
var networkSettings = new NetworkConfiguration();
|
|
var networkSettings = new NetworkConfiguration();
|
|
- ClassMigrationHelper.CopyProperties(ServerConfigurationManager.Configuration, networkSettings);
|
|
|
|
|
|
+ ClassMigrationHelper.CopyProperties(ConfigurationManager.Configuration, networkSettings);
|
|
_xmlSerializer.SerializeToFile(networkSettings, path);
|
|
_xmlSerializer.SerializeToFile(networkSettings, path);
|
|
- Logger?.LogDebug("Successfully migrated network settings.");
|
|
|
|
|
|
+ Logger.LogDebug("Successfully migrated network settings.");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -351,10 +337,7 @@ namespace Emby.Server.Implementations
|
|
{
|
|
{
|
|
get
|
|
get
|
|
{
|
|
{
|
|
- if (_deviceId == null)
|
|
|
|
- {
|
|
|
|
- _deviceId = new DeviceId(ApplicationPaths, LoggerFactory);
|
|
|
|
- }
|
|
|
|
|
|
+ _deviceId ??= new DeviceId(ApplicationPaths, LoggerFactory);
|
|
|
|
|
|
return _deviceId.Value;
|
|
return _deviceId.Value;
|
|
}
|
|
}
|
|
@@ -374,7 +357,7 @@ namespace Emby.Server.Implementations
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Creates an instance of type and resolves all constructor dependencies.
|
|
/// Creates an instance of type and resolves all constructor dependencies.
|
|
/// </summary>
|
|
/// </summary>
|
|
- /// /// <typeparam name="T">The type.</typeparam>
|
|
|
|
|
|
+ /// <typeparam name="T">The type.</typeparam>
|
|
/// <returns>T.</returns>
|
|
/// <returns>T.</returns>
|
|
public T CreateInstance<T>()
|
|
public T CreateInstance<T>()
|
|
=> ActivatorUtilities.CreateInstance<T>(ServiceProvider);
|
|
=> ActivatorUtilities.CreateInstance<T>(ServiceProvider);
|
|
@@ -386,10 +369,7 @@ namespace Emby.Server.Implementations
|
|
/// <returns>System.Object.</returns>
|
|
/// <returns>System.Object.</returns>
|
|
protected object CreateInstanceSafe(Type type)
|
|
protected object CreateInstanceSafe(Type type)
|
|
{
|
|
{
|
|
- if (_creatingInstances == null)
|
|
|
|
- {
|
|
|
|
- _creatingInstances = new List<Type>();
|
|
|
|
- }
|
|
|
|
|
|
+ _creatingInstances ??= new List<Type>();
|
|
|
|
|
|
if (_creatingInstances.IndexOf(type) != -1)
|
|
if (_creatingInstances.IndexOf(type) != -1)
|
|
{
|
|
{
|
|
@@ -460,7 +440,7 @@ namespace Emby.Server.Implementations
|
|
}
|
|
}
|
|
|
|
|
|
/// <inheritdoc />
|
|
/// <inheritdoc />
|
|
- public IReadOnlyCollection<T> GetExports<T>(CreationDelegate defaultFunc, bool manageLifetime = true)
|
|
|
|
|
|
+ public IReadOnlyCollection<T> GetExports<T>(CreationDelegateFactory defaultFunc, bool manageLifetime = true)
|
|
{
|
|
{
|
|
// Convert to list so this isn't executed for each iteration
|
|
// Convert to list so this isn't executed for each iteration
|
|
var parts = GetExportTypes<T>()
|
|
var parts = GetExportTypes<T>()
|
|
@@ -484,8 +464,9 @@ namespace Emby.Server.Implementations
|
|
/// Runs the startup tasks.
|
|
/// Runs the startup tasks.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <returns><see cref="Task" />.</returns>
|
|
/// <returns><see cref="Task" />.</returns>
|
|
- public async Task RunStartupTasksAsync()
|
|
|
|
|
|
+ public async Task RunStartupTasksAsync(CancellationToken cancellationToken)
|
|
{
|
|
{
|
|
|
|
+ cancellationToken.ThrowIfCancellationRequested();
|
|
Logger.LogInformation("Running startup tasks");
|
|
Logger.LogInformation("Running startup tasks");
|
|
|
|
|
|
Resolve<ITaskManager>().AddTasks(GetExports<IScheduledTask>(false));
|
|
Resolve<ITaskManager>().AddTasks(GetExports<IScheduledTask>(false));
|
|
@@ -499,14 +480,21 @@ namespace Emby.Server.Implementations
|
|
|
|
|
|
var entryPoints = GetExports<IServerEntryPoint>();
|
|
var entryPoints = GetExports<IServerEntryPoint>();
|
|
|
|
|
|
|
|
+ cancellationToken.ThrowIfCancellationRequested();
|
|
|
|
+
|
|
var stopWatch = new Stopwatch();
|
|
var stopWatch = new Stopwatch();
|
|
stopWatch.Start();
|
|
stopWatch.Start();
|
|
|
|
+
|
|
await Task.WhenAll(StartEntryPoints(entryPoints, true)).ConfigureAwait(false);
|
|
await Task.WhenAll(StartEntryPoints(entryPoints, true)).ConfigureAwait(false);
|
|
Logger.LogInformation("Executed all pre-startup entry points in {Elapsed:g}", stopWatch.Elapsed);
|
|
Logger.LogInformation("Executed all pre-startup entry points in {Elapsed:g}", stopWatch.Elapsed);
|
|
|
|
|
|
Logger.LogInformation("Core startup complete");
|
|
Logger.LogInformation("Core startup complete");
|
|
CoreStartupHasCompleted = true;
|
|
CoreStartupHasCompleted = true;
|
|
|
|
+
|
|
|
|
+ cancellationToken.ThrowIfCancellationRequested();
|
|
|
|
+
|
|
stopWatch.Restart();
|
|
stopWatch.Restart();
|
|
|
|
+
|
|
await Task.WhenAll(StartEntryPoints(entryPoints, false)).ConfigureAwait(false);
|
|
await Task.WhenAll(StartEntryPoints(entryPoints, false)).ConfigureAwait(false);
|
|
Logger.LogInformation("Executed all post-startup entry points in {Elapsed:g}", stopWatch.Elapsed);
|
|
Logger.LogInformation("Executed all post-startup entry points in {Elapsed:g}", stopWatch.Elapsed);
|
|
stopWatch.Stop();
|
|
stopWatch.Stop();
|
|
@@ -530,7 +518,21 @@ namespace Emby.Server.Implementations
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
public void Init()
|
|
public void Init()
|
|
{
|
|
{
|
|
- var networkConfiguration = ServerConfigurationManager.GetNetworkConfiguration();
|
|
|
|
|
|
+ DiscoverTypes();
|
|
|
|
+
|
|
|
|
+ ConfigurationManager.AddParts(GetExports<IConfigurationFactory>());
|
|
|
|
+
|
|
|
|
+ // Have to migrate settings here as migration subsystem not yet initialised.
|
|
|
|
+ MigrateNetworkConfiguration();
|
|
|
|
+ NetManager = new NetworkManager(ConfigurationManager, LoggerFactory.CreateLogger<NetworkManager>());
|
|
|
|
+
|
|
|
|
+ // Initialize runtime stat collection
|
|
|
|
+ if (ConfigurationManager.Configuration.EnableMetrics)
|
|
|
|
+ {
|
|
|
|
+ DotNetRuntimeStatsBuilder.Default().StartCollecting();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var networkConfiguration = ConfigurationManager.GetNetworkConfiguration();
|
|
HttpPort = networkConfiguration.HttpServerPortNumber;
|
|
HttpPort = networkConfiguration.HttpServerPortNumber;
|
|
HttpsPort = networkConfiguration.HttpsPortNumber;
|
|
HttpsPort = networkConfiguration.HttpsPortNumber;
|
|
|
|
|
|
@@ -548,8 +550,6 @@ namespace Emby.Server.Implementations
|
|
};
|
|
};
|
|
Certificate = GetCertificate(CertificateInfo);
|
|
Certificate = GetCertificate(CertificateInfo);
|
|
|
|
|
|
- DiscoverTypes();
|
|
|
|
-
|
|
|
|
RegisterServices();
|
|
RegisterServices();
|
|
|
|
|
|
_pluginManager.RegisterServices(ServiceCollection);
|
|
_pluginManager.RegisterServices(ServiceCollection);
|
|
@@ -564,7 +564,8 @@ namespace Emby.Server.Implementations
|
|
|
|
|
|
ServiceCollection.AddMemoryCache();
|
|
ServiceCollection.AddMemoryCache();
|
|
|
|
|
|
- ServiceCollection.AddSingleton(ConfigurationManager);
|
|
|
|
|
|
+ ServiceCollection.AddSingleton<IServerConfigurationManager>(ConfigurationManager);
|
|
|
|
+ ServiceCollection.AddSingleton<IConfigurationManager>(ConfigurationManager);
|
|
ServiceCollection.AddSingleton<IApplicationHost>(this);
|
|
ServiceCollection.AddSingleton<IApplicationHost>(this);
|
|
ServiceCollection.AddSingleton<IPluginManager>(_pluginManager);
|
|
ServiceCollection.AddSingleton<IPluginManager>(_pluginManager);
|
|
ServiceCollection.AddSingleton<IApplicationPaths>(ApplicationPaths);
|
|
ServiceCollection.AddSingleton<IApplicationPaths>(ApplicationPaths);
|
|
@@ -591,8 +592,6 @@ namespace Emby.Server.Implementations
|
|
ServiceCollection.AddSingleton<IServerApplicationHost>(this);
|
|
ServiceCollection.AddSingleton<IServerApplicationHost>(this);
|
|
ServiceCollection.AddSingleton<IServerApplicationPaths>(ApplicationPaths);
|
|
ServiceCollection.AddSingleton<IServerApplicationPaths>(ApplicationPaths);
|
|
|
|
|
|
- ServiceCollection.AddSingleton(ServerConfigurationManager);
|
|
|
|
-
|
|
|
|
ServiceCollection.AddSingleton<ILocalizationManager, LocalizationManager>();
|
|
ServiceCollection.AddSingleton<ILocalizationManager, LocalizationManager>();
|
|
|
|
|
|
ServiceCollection.AddSingleton<IBlurayExaminer, BdInfoExaminer>();
|
|
ServiceCollection.AddSingleton<IBlurayExaminer, BdInfoExaminer>();
|
|
@@ -604,12 +603,8 @@ namespace Emby.Server.Implementations
|
|
|
|
|
|
ServiceCollection.AddSingleton<IAuthenticationRepository, AuthenticationRepository>();
|
|
ServiceCollection.AddSingleton<IAuthenticationRepository, AuthenticationRepository>();
|
|
|
|
|
|
- // TODO: Refactor to eliminate the circular dependency here so that Lazy<T> isn't required
|
|
|
|
- ServiceCollection.AddTransient(provider => new Lazy<IDtoService>(provider.GetRequiredService<IDtoService>));
|
|
|
|
-
|
|
|
|
- // TODO: Refactor to eliminate the circular dependency here so that Lazy<T> isn't required
|
|
|
|
- ServiceCollection.AddTransient(provider => new Lazy<EncodingHelper>(provider.GetRequiredService<EncodingHelper>));
|
|
|
|
ServiceCollection.AddSingleton<IMediaEncoder, MediaBrowser.MediaEncoding.Encoder.MediaEncoder>();
|
|
ServiceCollection.AddSingleton<IMediaEncoder, MediaBrowser.MediaEncoding.Encoder.MediaEncoder>();
|
|
|
|
+ ServiceCollection.AddSingleton<EncodingHelper>();
|
|
|
|
|
|
// TODO: Refactor to eliminate the circular dependencies here so that Lazy<T> isn't required
|
|
// TODO: Refactor to eliminate the circular dependencies here so that Lazy<T> isn't required
|
|
ServiceCollection.AddTransient(provider => new Lazy<ILibraryMonitor>(provider.GetRequiredService<ILibraryMonitor>));
|
|
ServiceCollection.AddTransient(provider => new Lazy<ILibraryMonitor>(provider.GetRequiredService<ILibraryMonitor>));
|
|
@@ -674,14 +669,14 @@ namespace Emby.Server.Implementations
|
|
|
|
|
|
ServiceCollection.AddSingleton<ISubtitleEncoder, MediaBrowser.MediaEncoding.Subtitles.SubtitleEncoder>();
|
|
ServiceCollection.AddSingleton<ISubtitleEncoder, MediaBrowser.MediaEncoding.Subtitles.SubtitleEncoder>();
|
|
|
|
|
|
- ServiceCollection.AddSingleton<EncodingHelper>();
|
|
|
|
-
|
|
|
|
ServiceCollection.AddSingleton<IAttachmentExtractor, MediaBrowser.MediaEncoding.Attachments.AttachmentExtractor>();
|
|
ServiceCollection.AddSingleton<IAttachmentExtractor, MediaBrowser.MediaEncoding.Attachments.AttachmentExtractor>();
|
|
|
|
|
|
ServiceCollection.AddSingleton<TranscodingJobHelper>();
|
|
ServiceCollection.AddSingleton<TranscodingJobHelper>();
|
|
ServiceCollection.AddScoped<MediaInfoHelper>();
|
|
ServiceCollection.AddScoped<MediaInfoHelper>();
|
|
ServiceCollection.AddScoped<AudioHelper>();
|
|
ServiceCollection.AddScoped<AudioHelper>();
|
|
ServiceCollection.AddScoped<DynamicHlsHelper>();
|
|
ServiceCollection.AddScoped<DynamicHlsHelper>();
|
|
|
|
+
|
|
|
|
+ ServiceCollection.AddSingleton<IDirectoryService, DirectoryService>();
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -779,7 +774,7 @@ namespace Emby.Server.Implementations
|
|
{
|
|
{
|
|
// For now there's no real way to inject these properly
|
|
// For now there's no real way to inject these properly
|
|
BaseItem.Logger = Resolve<ILogger<BaseItem>>();
|
|
BaseItem.Logger = Resolve<ILogger<BaseItem>>();
|
|
- BaseItem.ConfigurationManager = ServerConfigurationManager;
|
|
|
|
|
|
+ BaseItem.ConfigurationManager = ConfigurationManager;
|
|
BaseItem.LibraryManager = Resolve<ILibraryManager>();
|
|
BaseItem.LibraryManager = Resolve<ILibraryManager>();
|
|
BaseItem.ProviderManager = Resolve<IProviderManager>();
|
|
BaseItem.ProviderManager = Resolve<IProviderManager>();
|
|
BaseItem.LocalizationManager = Resolve<ILocalizationManager>();
|
|
BaseItem.LocalizationManager = Resolve<ILocalizationManager>();
|
|
@@ -801,13 +796,12 @@ namespace Emby.Server.Implementations
|
|
/// </summary>
|
|
/// </summary>
|
|
private void FindParts()
|
|
private void FindParts()
|
|
{
|
|
{
|
|
- if (!ServerConfigurationManager.Configuration.IsPortAuthorized)
|
|
|
|
|
|
+ if (!ConfigurationManager.Configuration.IsPortAuthorized)
|
|
{
|
|
{
|
|
- ServerConfigurationManager.Configuration.IsPortAuthorized = true;
|
|
|
|
|
|
+ ConfigurationManager.Configuration.IsPortAuthorized = true;
|
|
ConfigurationManager.SaveConfiguration();
|
|
ConfigurationManager.SaveConfiguration();
|
|
}
|
|
}
|
|
|
|
|
|
- ConfigurationManager.AddParts(GetExports<IConfigurationFactory>());
|
|
|
|
_pluginManager.CreatePlugins();
|
|
_pluginManager.CreatePlugins();
|
|
|
|
|
|
_urlPrefixes = GetUrlPrefixes().ToArray();
|
|
_urlPrefixes = GetUrlPrefixes().ToArray();
|
|
@@ -911,7 +905,7 @@ namespace Emby.Server.Implementations
|
|
protected void OnConfigurationUpdated(object sender, EventArgs e)
|
|
protected void OnConfigurationUpdated(object sender, EventArgs e)
|
|
{
|
|
{
|
|
var requiresRestart = false;
|
|
var requiresRestart = false;
|
|
- var networkConfiguration = ServerConfigurationManager.GetNetworkConfiguration();
|
|
|
|
|
|
+ var networkConfiguration = ConfigurationManager.GetNetworkConfiguration();
|
|
|
|
|
|
// Don't do anything if these haven't been set yet
|
|
// Don't do anything if these haven't been set yet
|
|
if (HttpPort != 0 && HttpsPort != 0)
|
|
if (HttpPort != 0 && HttpsPort != 0)
|
|
@@ -920,10 +914,10 @@ namespace Emby.Server.Implementations
|
|
if (networkConfiguration.HttpServerPortNumber != HttpPort ||
|
|
if (networkConfiguration.HttpServerPortNumber != HttpPort ||
|
|
networkConfiguration.HttpsPortNumber != HttpsPort)
|
|
networkConfiguration.HttpsPortNumber != HttpsPort)
|
|
{
|
|
{
|
|
- if (ServerConfigurationManager.Configuration.IsPortAuthorized)
|
|
|
|
|
|
+ if (ConfigurationManager.Configuration.IsPortAuthorized)
|
|
{
|
|
{
|
|
- ServerConfigurationManager.Configuration.IsPortAuthorized = false;
|
|
|
|
- ServerConfigurationManager.SaveConfiguration();
|
|
|
|
|
|
+ ConfigurationManager.Configuration.IsPortAuthorized = false;
|
|
|
|
+ ConfigurationManager.SaveConfiguration();
|
|
|
|
|
|
requiresRestart = true;
|
|
requiresRestart = true;
|
|
}
|
|
}
|
|
@@ -1139,16 +1133,16 @@ namespace Emby.Server.Implementations
|
|
}
|
|
}
|
|
|
|
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
- public bool ListenWithHttps => Certificate != null && ServerConfigurationManager.GetNetworkConfiguration().EnableHttps;
|
|
|
|
|
|
+ public bool ListenWithHttps => Certificate != null && ConfigurationManager.GetNetworkConfiguration().EnableHttps;
|
|
|
|
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
public string GetSmartApiUrl(IPAddress ipAddress, int? port = null)
|
|
public string GetSmartApiUrl(IPAddress ipAddress, int? port = null)
|
|
{
|
|
{
|
|
// Published server ends with a /
|
|
// Published server ends with a /
|
|
- if (_startupOptions.PublishedServerUrl != null)
|
|
|
|
|
|
+ if (!string.IsNullOrEmpty(PublishedServerUrl))
|
|
{
|
|
{
|
|
// Published server ends with a '/', so we need to remove it.
|
|
// Published server ends with a '/', so we need to remove it.
|
|
- return _startupOptions.PublishedServerUrl.ToString().Trim('/');
|
|
|
|
|
|
+ return PublishedServerUrl.Trim('/');
|
|
}
|
|
}
|
|
|
|
|
|
string smart = NetManager.GetBindInterface(ipAddress, out port);
|
|
string smart = NetManager.GetBindInterface(ipAddress, out port);
|
|
@@ -1165,10 +1159,10 @@ namespace Emby.Server.Implementations
|
|
public string GetSmartApiUrl(HttpRequest request, int? port = null)
|
|
public string GetSmartApiUrl(HttpRequest request, int? port = null)
|
|
{
|
|
{
|
|
// Published server ends with a /
|
|
// Published server ends with a /
|
|
- if (_startupOptions.PublishedServerUrl != null)
|
|
|
|
|
|
+ if (!string.IsNullOrEmpty(PublishedServerUrl))
|
|
{
|
|
{
|
|
// Published server ends with a '/', so we need to remove it.
|
|
// Published server ends with a '/', so we need to remove it.
|
|
- return _startupOptions.PublishedServerUrl.ToString().Trim('/');
|
|
|
|
|
|
+ return PublishedServerUrl.Trim('/');
|
|
}
|
|
}
|
|
|
|
|
|
string smart = NetManager.GetBindInterface(request, out port);
|
|
string smart = NetManager.GetBindInterface(request, out port);
|
|
@@ -1185,10 +1179,10 @@ namespace Emby.Server.Implementations
|
|
public string GetSmartApiUrl(string hostname, int? port = null)
|
|
public string GetSmartApiUrl(string hostname, int? port = null)
|
|
{
|
|
{
|
|
// Published server ends with a /
|
|
// Published server ends with a /
|
|
- if (_startupOptions.PublishedServerUrl != null)
|
|
|
|
|
|
+ if (!string.IsNullOrEmpty(PublishedServerUrl))
|
|
{
|
|
{
|
|
// Published server ends with a '/', so we need to remove it.
|
|
// Published server ends with a '/', so we need to remove it.
|
|
- return _startupOptions.PublishedServerUrl.ToString().Trim('/');
|
|
|
|
|
|
+ return PublishedServerUrl.Trim('/');
|
|
}
|
|
}
|
|
|
|
|
|
string smart = NetManager.GetBindInterface(hostname, out port);
|
|
string smart = NetManager.GetBindInterface(hostname, out port);
|
|
@@ -1223,14 +1217,14 @@ namespace Emby.Server.Implementations
|
|
Scheme = scheme ?? (ListenWithHttps ? Uri.UriSchemeHttps : Uri.UriSchemeHttp),
|
|
Scheme = scheme ?? (ListenWithHttps ? Uri.UriSchemeHttps : Uri.UriSchemeHttp),
|
|
Host = host,
|
|
Host = host,
|
|
Port = port ?? (ListenWithHttps ? HttpsPort : HttpPort),
|
|
Port = port ?? (ListenWithHttps ? HttpsPort : HttpPort),
|
|
- Path = ServerConfigurationManager.GetNetworkConfiguration().BaseUrl
|
|
|
|
|
|
+ Path = ConfigurationManager.GetNetworkConfiguration().BaseUrl
|
|
}.ToString().TrimEnd('/');
|
|
}.ToString().TrimEnd('/');
|
|
}
|
|
}
|
|
|
|
|
|
public string FriendlyName =>
|
|
public string FriendlyName =>
|
|
- string.IsNullOrEmpty(ServerConfigurationManager.Configuration.ServerName)
|
|
|
|
|
|
+ string.IsNullOrEmpty(ConfigurationManager.Configuration.ServerName)
|
|
? Environment.MachineName
|
|
? Environment.MachineName
|
|
- : ServerConfigurationManager.Configuration.ServerName;
|
|
|
|
|
|
+ : ConfigurationManager.Configuration.ServerName;
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Shuts down.
|
|
/// Shuts down.
|