|
|
|
@ -1,7 +1,4 @@
|
|
|
|
|
using Emby.Drawing;
|
|
|
|
|
using Emby.Drawing.GDI;
|
|
|
|
|
using Emby.Drawing.ImageMagick;
|
|
|
|
|
using MediaBrowser.Api;
|
|
|
|
|
using MediaBrowser.Api;
|
|
|
|
|
using MediaBrowser.Common;
|
|
|
|
|
using MediaBrowser.Common.Configuration;
|
|
|
|
|
using MediaBrowser.Common.Events;
|
|
|
|
@ -48,19 +45,6 @@ using MediaBrowser.Model.Updates;
|
|
|
|
|
using MediaBrowser.Providers.Chapters;
|
|
|
|
|
using MediaBrowser.Providers.Manager;
|
|
|
|
|
using MediaBrowser.Providers.Subtitles;
|
|
|
|
|
using MediaBrowser.Server.Implementations;
|
|
|
|
|
using MediaBrowser.Server.Implementations.Activity;
|
|
|
|
|
using MediaBrowser.Server.Implementations.Configuration;
|
|
|
|
|
using MediaBrowser.Server.Implementations.Devices;
|
|
|
|
|
using MediaBrowser.Server.Implementations.HttpServer;
|
|
|
|
|
using MediaBrowser.Server.Implementations.IO;
|
|
|
|
|
using MediaBrowser.Server.Implementations.Notifications;
|
|
|
|
|
using MediaBrowser.Server.Implementations.Persistence;
|
|
|
|
|
using MediaBrowser.Server.Implementations.Security;
|
|
|
|
|
using MediaBrowser.Server.Implementations.Social;
|
|
|
|
|
using MediaBrowser.Server.Implementations.Sync;
|
|
|
|
|
using MediaBrowser.Server.Startup.Common.FFMpeg;
|
|
|
|
|
using MediaBrowser.Server.Startup.Common.Migrations;
|
|
|
|
|
using MediaBrowser.WebDashboard.Api;
|
|
|
|
|
using MediaBrowser.XbmcMetadata.Providers;
|
|
|
|
|
using System;
|
|
|
|
@ -72,11 +56,14 @@ using System.Linq;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Net.Sockets;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.Security.Cryptography.X509Certificates;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Emby.Common.Implementations;
|
|
|
|
|
using Emby.Common.Implementations.Archiving;
|
|
|
|
|
using Emby.Common.Implementations.Networking;
|
|
|
|
|
using Emby.Common.Implementations.Reflection;
|
|
|
|
|
using Emby.Common.Implementations.Serialization;
|
|
|
|
|
using Emby.Common.Implementations.TextEncoding;
|
|
|
|
|
using Emby.Common.Implementations.Updates;
|
|
|
|
|
using Emby.Common.Implementations.Xml;
|
|
|
|
@ -95,6 +82,19 @@ using Emby.Dlna.ContentDirectory;
|
|
|
|
|
using Emby.Dlna.Main;
|
|
|
|
|
using Emby.Dlna.MediaReceiverRegistrar;
|
|
|
|
|
using Emby.Dlna.Ssdp;
|
|
|
|
|
using Emby.Server.Core;
|
|
|
|
|
using Emby.Server.Core.Activity;
|
|
|
|
|
using Emby.Server.Core.Configuration;
|
|
|
|
|
using Emby.Server.Core.Data;
|
|
|
|
|
using Emby.Server.Core.Devices;
|
|
|
|
|
using Emby.Server.Core.FFMpeg;
|
|
|
|
|
using Emby.Server.Core.IO;
|
|
|
|
|
using Emby.Server.Core.Localization;
|
|
|
|
|
using Emby.Server.Core.Migrations;
|
|
|
|
|
using Emby.Server.Core.Notifications;
|
|
|
|
|
using Emby.Server.Core.Security;
|
|
|
|
|
using Emby.Server.Core.Social;
|
|
|
|
|
using Emby.Server.Core.Sync;
|
|
|
|
|
using Emby.Server.Implementations.Activity;
|
|
|
|
|
using Emby.Server.Implementations.Channels;
|
|
|
|
|
using Emby.Server.Implementations.Collections;
|
|
|
|
@ -103,6 +103,7 @@ using Emby.Server.Implementations.Devices;
|
|
|
|
|
using Emby.Server.Implementations.Dto;
|
|
|
|
|
using Emby.Server.Implementations.EntryPoints;
|
|
|
|
|
using Emby.Server.Implementations.FileOrganization;
|
|
|
|
|
using Emby.Server.Implementations.HttpServer;
|
|
|
|
|
using Emby.Server.Implementations.HttpServer.Security;
|
|
|
|
|
using Emby.Server.Implementations.Library;
|
|
|
|
|
using Emby.Server.Implementations.LiveTv;
|
|
|
|
@ -130,13 +131,13 @@ using MediaBrowser.Model.Services;
|
|
|
|
|
using MediaBrowser.Model.Social;
|
|
|
|
|
using MediaBrowser.Model.Text;
|
|
|
|
|
using MediaBrowser.Model.Xml;
|
|
|
|
|
using MediaBrowser.Server.Implementations.Archiving;
|
|
|
|
|
using MediaBrowser.Server.Implementations.Serialization;
|
|
|
|
|
using OpenSubtitlesHandler;
|
|
|
|
|
using ServiceStack;
|
|
|
|
|
using SocketHttpListener.Primitives;
|
|
|
|
|
using StringExtensions = MediaBrowser.Controller.Extensions.StringExtensions;
|
|
|
|
|
using Emby.Drawing;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Server.Startup.Common
|
|
|
|
|
namespace Emby.Server.Core
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class CompositionRoot
|
|
|
|
@ -262,6 +263,10 @@ namespace MediaBrowser.Server.Startup.Common
|
|
|
|
|
internal INativeApp NativeApp { get; set; }
|
|
|
|
|
|
|
|
|
|
internal IPowerManagement PowerManagement { get; private set; }
|
|
|
|
|
internal IImageEncoder ImageEncoder { get; private set; }
|
|
|
|
|
|
|
|
|
|
private readonly Action<string, string> _certificateGenerator;
|
|
|
|
|
private readonly Func<string> _defaultUserNameFactory;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initializes a new instance of the <see cref="ApplicationHost" /> class.
|
|
|
|
@ -270,16 +275,33 @@ namespace MediaBrowser.Server.Startup.Common
|
|
|
|
|
ILogManager logManager,
|
|
|
|
|
StartupOptions options,
|
|
|
|
|
IFileSystem fileSystem,
|
|
|
|
|
INativeApp nativeApp,
|
|
|
|
|
INativeApp nativeApp,
|
|
|
|
|
IPowerManagement powerManagement,
|
|
|
|
|
string releaseAssetFilename)
|
|
|
|
|
: base(applicationPaths, logManager, fileSystem)
|
|
|
|
|
string releaseAssetFilename,
|
|
|
|
|
IEnvironmentInfo environmentInfo,
|
|
|
|
|
IImageEncoder imageEncoder,
|
|
|
|
|
ISystemEvents systemEvents,
|
|
|
|
|
IMemoryStreamFactory memoryStreamFactory,
|
|
|
|
|
INetworkManager networkManager,
|
|
|
|
|
Action<string, string> certificateGenerator,
|
|
|
|
|
Func<string> defaultUsernameFactory)
|
|
|
|
|
: base(applicationPaths,
|
|
|
|
|
logManager,
|
|
|
|
|
fileSystem,
|
|
|
|
|
environmentInfo,
|
|
|
|
|
systemEvents,
|
|
|
|
|
memoryStreamFactory,
|
|
|
|
|
networkManager)
|
|
|
|
|
{
|
|
|
|
|
_startupOptions = options;
|
|
|
|
|
_certificateGenerator = certificateGenerator;
|
|
|
|
|
_releaseAssetFilename = releaseAssetFilename;
|
|
|
|
|
_defaultUserNameFactory = defaultUsernameFactory;
|
|
|
|
|
NativeApp = nativeApp;
|
|
|
|
|
PowerManagement = powerManagement;
|
|
|
|
|
|
|
|
|
|
ImageEncoder = imageEncoder;
|
|
|
|
|
|
|
|
|
|
SetBaseExceptionMessage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -292,15 +314,10 @@ namespace MediaBrowser.Server.Startup.Common
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _version ?? (_version = NativeApp.GetType().Assembly.GetName().Version);
|
|
|
|
|
return _version ?? (_version = GetAssembly(NativeApp.GetType()).GetName().Version);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string OperatingSystemDisplayName
|
|
|
|
|
{
|
|
|
|
|
get { return NativeApp.Environment.OperatingSystemVersionString; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool IsRunningAsService
|
|
|
|
|
{
|
|
|
|
|
get { return NativeApp.IsRunningAsService; }
|
|
|
|
@ -311,11 +328,6 @@ namespace MediaBrowser.Server.Startup.Common
|
|
|
|
|
get { return NativeApp.SupportsRunningAsService; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool SupportsLibraryMonitor
|
|
|
|
|
{
|
|
|
|
|
get { return NativeApp.SupportsLibraryMonitor; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the name.
|
|
|
|
|
/// </summary>
|
|
|
|
@ -328,6 +340,11 @@ namespace MediaBrowser.Server.Startup.Common
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Assembly GetAssembly(Type type)
|
|
|
|
|
{
|
|
|
|
|
return type.GetTypeInfo().Assembly;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a value indicating whether this instance can self restart.
|
|
|
|
|
/// </summary>
|
|
|
|
@ -412,21 +429,6 @@ namespace MediaBrowser.Server.Startup.Common
|
|
|
|
|
LogManager.RemoveConsoleOutput();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override IMemoryStreamFactory CreateMemoryStreamProvider()
|
|
|
|
|
{
|
|
|
|
|
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
|
|
|
|
{
|
|
|
|
|
return new RecyclableMemoryStreamProvider();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new MemoryStreamProvider();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override ISystemEvents CreateSystemEvents()
|
|
|
|
|
{
|
|
|
|
|
return new SystemEvents(LogManager.GetLogger("SystemEvents"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override IJsonSerializer CreateJsonSerializer()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
@ -578,11 +580,11 @@ namespace MediaBrowser.Server.Startup.Common
|
|
|
|
|
|
|
|
|
|
UserRepository = await GetUserRepository().ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
var displayPreferencesRepo = new SqliteDisplayPreferencesRepository(LogManager, JsonSerializer, ApplicationPaths, NativeApp.GetDbConnector(), MemoryStreamProvider);
|
|
|
|
|
var displayPreferencesRepo = new SqliteDisplayPreferencesRepository(LogManager, JsonSerializer, ApplicationPaths, NativeApp.GetDbConnector(), MemoryStreamFactory);
|
|
|
|
|
DisplayPreferencesRepository = displayPreferencesRepo;
|
|
|
|
|
RegisterSingleInstance(DisplayPreferencesRepository);
|
|
|
|
|
|
|
|
|
|
var itemRepo = new SqliteItemRepository(ServerConfigurationManager, JsonSerializer, LogManager, NativeApp.GetDbConnector(), MemoryStreamProvider);
|
|
|
|
|
var itemRepo = new SqliteItemRepository(ServerConfigurationManager, JsonSerializer, LogManager, NativeApp.GetDbConnector(), MemoryStreamFactory);
|
|
|
|
|
ItemRepository = itemRepo;
|
|
|
|
|
RegisterSingleInstance(ItemRepository);
|
|
|
|
|
|
|
|
|
@ -595,7 +597,7 @@ namespace MediaBrowser.Server.Startup.Common
|
|
|
|
|
SyncRepository = await GetSyncRepository().ConfigureAwait(false);
|
|
|
|
|
RegisterSingleInstance(SyncRepository);
|
|
|
|
|
|
|
|
|
|
UserManager = new UserManager(LogManager.GetLogger("UserManager"), ServerConfigurationManager, UserRepository, XmlSerializer, NetworkManager, () => ImageProcessor, () => DtoService, () => ConnectManager, this, JsonSerializer, FileSystemManager, CryptographyProvider, Environment.UserName);
|
|
|
|
|
UserManager = new UserManager(LogManager.GetLogger("UserManager"), ServerConfigurationManager, UserRepository, XmlSerializer, NetworkManager, () => ImageProcessor, () => DtoService, () => ConnectManager, this, JsonSerializer, FileSystemManager, CryptographyProvider, _defaultUserNameFactory());
|
|
|
|
|
RegisterSingleInstance(UserManager);
|
|
|
|
|
|
|
|
|
|
LibraryManager = new LibraryManager(Logger, TaskManager, UserManager, ServerConfigurationManager, UserDataManager, () => LibraryMonitor, FileSystemManager, () => ProviderManager, () => UserViewManager);
|
|
|
|
@ -607,17 +609,17 @@ namespace MediaBrowser.Server.Startup.Common
|
|
|
|
|
LibraryMonitor = new LibraryMonitor(LogManager, TaskManager, LibraryManager, ServerConfigurationManager, FileSystemManager, TimerFactory, SystemEvents, EnvironmentInfo);
|
|
|
|
|
RegisterSingleInstance(LibraryMonitor);
|
|
|
|
|
|
|
|
|
|
ProviderManager = new ProviderManager(HttpClient, ServerConfigurationManager, LibraryMonitor, LogManager, FileSystemManager, ApplicationPaths, () => LibraryManager, JsonSerializer, MemoryStreamProvider);
|
|
|
|
|
ProviderManager = new ProviderManager(HttpClient, ServerConfigurationManager, LibraryMonitor, LogManager, FileSystemManager, ApplicationPaths, () => LibraryManager, JsonSerializer, MemoryStreamFactory);
|
|
|
|
|
RegisterSingleInstance(ProviderManager);
|
|
|
|
|
|
|
|
|
|
RegisterSingleInstance<ISearchEngine>(() => new SearchEngine(LogManager, LibraryManager, UserManager));
|
|
|
|
|
|
|
|
|
|
HttpServer = ServerFactory.CreateServer(this, LogManager, ServerConfigurationManager, NetworkManager, MemoryStreamProvider, "Emby", "web/index.html", textEncoding, SocketFactory, CryptographyProvider, JsonSerializer, XmlSerializer);
|
|
|
|
|
HttpServer = HttpServerFactory.CreateServer(this, LogManager, ServerConfigurationManager, NetworkManager, MemoryStreamFactory, "Emby", "web/index.html", textEncoding, SocketFactory, CryptographyProvider, JsonSerializer, XmlSerializer, EnvironmentInfo, Certificate);
|
|
|
|
|
HttpServer.GlobalResponse = LocalizationManager.GetLocalizedString("StartupEmbyServerIsLoading");
|
|
|
|
|
RegisterSingleInstance(HttpServer, false);
|
|
|
|
|
progress.Report(10);
|
|
|
|
|
|
|
|
|
|
ServerManager = new ServerManager(this, JsonSerializer, LogManager.GetLogger("ServerManager"), ServerConfigurationManager, MemoryStreamProvider, textEncoding);
|
|
|
|
|
ServerManager = new ServerManager(this, JsonSerializer, LogManager.GetLogger("ServerManager"), ServerConfigurationManager, MemoryStreamFactory, textEncoding);
|
|
|
|
|
RegisterSingleInstance(ServerManager);
|
|
|
|
|
|
|
|
|
|
var innerProgress = new ActionableProgress<double>();
|
|
|
|
@ -629,7 +631,7 @@ namespace MediaBrowser.Server.Startup.Common
|
|
|
|
|
TVSeriesManager = new TVSeriesManager(UserManager, UserDataManager, LibraryManager, ServerConfigurationManager);
|
|
|
|
|
RegisterSingleInstance(TVSeriesManager);
|
|
|
|
|
|
|
|
|
|
SyncManager = new SyncManager(LibraryManager, SyncRepository, ImageProcessor, LogManager.GetLogger("SyncManager"), UserManager, () => DtoService, this, TVSeriesManager, () => MediaEncoder, FileSystemManager, () => SubtitleEncoder, ServerConfigurationManager, UserDataManager, () => MediaSourceManager, JsonSerializer, TaskManager, MemoryStreamProvider);
|
|
|
|
|
SyncManager = new SyncManager(LibraryManager, SyncRepository, ImageProcessor, LogManager.GetLogger("SyncManager"), UserManager, () => DtoService, this, TVSeriesManager, () => MediaEncoder, FileSystemManager, () => SubtitleEncoder, ServerConfigurationManager, UserDataManager, () => MediaSourceManager, JsonSerializer, TaskManager, MemoryStreamFactory);
|
|
|
|
|
RegisterSingleInstance(SyncManager);
|
|
|
|
|
|
|
|
|
|
DtoService = new DtoService(LogManager.GetLogger("DtoService"), LibraryManager, UserDataManager, ItemRepository, ImageProcessor, ServerConfigurationManager, FileSystemManager, ProviderManager, () => ChannelManager, SyncManager, this, () => DeviceManager, () => MediaSourceManager, () => LiveTvManager);
|
|
|
|
@ -717,7 +719,7 @@ namespace MediaBrowser.Server.Startup.Common
|
|
|
|
|
AuthService = new AuthService(UserManager, authContext, ServerConfigurationManager, ConnectManager, SessionManager, DeviceManager);
|
|
|
|
|
RegisterSingleInstance<IAuthService>(AuthService);
|
|
|
|
|
|
|
|
|
|
SubtitleEncoder = new SubtitleEncoder(LibraryManager, LogManager.GetLogger("SubtitleEncoder"), ApplicationPaths, FileSystemManager, MediaEncoder, JsonSerializer, HttpClient, MediaSourceManager, MemoryStreamProvider, ProcessFactory, textEncoding);
|
|
|
|
|
SubtitleEncoder = new SubtitleEncoder(LibraryManager, LogManager.GetLogger("SubtitleEncoder"), ApplicationPaths, FileSystemManager, MediaEncoder, JsonSerializer, HttpClient, MediaSourceManager, MemoryStreamFactory, ProcessFactory, textEncoding);
|
|
|
|
|
RegisterSingleInstance(SubtitleEncoder);
|
|
|
|
|
|
|
|
|
|
await displayPreferencesRepo.Initialize().ConfigureAwait(false);
|
|
|
|
@ -735,47 +737,42 @@ namespace MediaBrowser.Server.Startup.Common
|
|
|
|
|
await ((UserManager)UserManager).Initialize().ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IImageProcessor GetImageProcessor()
|
|
|
|
|
private ICertificate GetCertificate(string certificateLocation)
|
|
|
|
|
{
|
|
|
|
|
var maxConcurrentImageProcesses = Math.Max(Environment.ProcessorCount, 4);
|
|
|
|
|
|
|
|
|
|
if (_startupOptions.ContainsOption("-imagethreads"))
|
|
|
|
|
if (string.IsNullOrWhiteSpace(certificateLocation))
|
|
|
|
|
{
|
|
|
|
|
int.TryParse(_startupOptions.GetOption("-imagethreads"), NumberStyles.Any, CultureInfo.InvariantCulture, out maxConcurrentImageProcesses);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new ImageProcessor(LogManager.GetLogger("ImageProcessor"), ServerConfigurationManager.ApplicationPaths, FileSystemManager, JsonSerializer, GetImageEncoder(), maxConcurrentImageProcesses, () => LibraryManager);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IImageEncoder GetImageEncoder()
|
|
|
|
|
{
|
|
|
|
|
if (!_startupOptions.ContainsOption("-enablegdi"))
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
X509Certificate2 localCert = new X509Certificate2(certificateLocation);
|
|
|
|
|
//localCert.PrivateKey = PrivateKey.CreateFromFile(pvk_file).RSA;
|
|
|
|
|
if (!localCert.HasPrivateKey)
|
|
|
|
|
{
|
|
|
|
|
return new ImageMagickEncoder(LogManager.GetLogger("ImageMagick"), ApplicationPaths, HttpClient, FileSystemManager, ServerConfigurationManager);
|
|
|
|
|
//throw new FileNotFoundException("Secure requested, no private key included", certificateLocation);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
Logger.Error("Error loading ImageMagick. Will revert to GDI.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return new GDIImageEncoder(FileSystemManager, LogManager.GetLogger("GDI"));
|
|
|
|
|
return new Certificate(localCert);
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Logger.Error("Error loading GDI. Will revert to NullImageEncoder.");
|
|
|
|
|
Logger.ErrorException("Error loading cert from {0}", ex, certificateLocation);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new NullImageEncoder();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override INetworkManager CreateNetworkManager(ILogger logger)
|
|
|
|
|
private IImageProcessor GetImageProcessor()
|
|
|
|
|
{
|
|
|
|
|
return NativeApp.CreateNetworkManager(logger);
|
|
|
|
|
var maxConcurrentImageProcesses = Math.Max(Environment.ProcessorCount, 4);
|
|
|
|
|
|
|
|
|
|
if (_startupOptions.ContainsOption("-imagethreads"))
|
|
|
|
|
{
|
|
|
|
|
int.TryParse(_startupOptions.GetOption("-imagethreads"), NumberStyles.Any, CultureInfo.InvariantCulture, out maxConcurrentImageProcesses);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new ImageProcessor(LogManager.GetLogger("ImageProcessor"), ServerConfigurationManager.ApplicationPaths, FileSystemManager, JsonSerializer, ImageEncoder, maxConcurrentImageProcesses, () => LibraryManager, TimerFactory);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -787,8 +784,8 @@ namespace MediaBrowser.Server.Startup.Common
|
|
|
|
|
string encoderPath = null;
|
|
|
|
|
string probePath = null;
|
|
|
|
|
|
|
|
|
|
var info = await new FFMpegLoader(Logger, ApplicationPaths, HttpClient, ZipClient, FileSystemManager, NativeApp.Environment, NativeApp.GetFfmpegInstallInfo())
|
|
|
|
|
.GetFFMpegInfo(NativeApp.Environment, _startupOptions, progress).ConfigureAwait(false);
|
|
|
|
|
var info = await new FFMpegLoader(Logger, ApplicationPaths, HttpClient, ZipClient, FileSystemManager, NativeApp.GetFfmpegInstallInfo())
|
|
|
|
|
.GetFFMpegInfo(_startupOptions, progress).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
encoderPath = info.EncoderPath;
|
|
|
|
|
probePath = info.ProbePath;
|
|
|
|
@ -809,10 +806,11 @@ namespace MediaBrowser.Server.Startup.Common
|
|
|
|
|
() => SubtitleEncoder,
|
|
|
|
|
() => MediaSourceManager,
|
|
|
|
|
HttpClient,
|
|
|
|
|
ZipClient, MemoryStreamProvider,
|
|
|
|
|
ZipClient,
|
|
|
|
|
MemoryStreamFactory,
|
|
|
|
|
ProcessFactory,
|
|
|
|
|
Environment.Is64BitOperatingSystem ? (Environment.ProcessorCount > 2 ? 14000 : 20000) : 40000,
|
|
|
|
|
Environment.OSVersion.Platform == PlatformID.Win32NT);
|
|
|
|
|
(Environment.ProcessorCount > 2 ? 14000 : 40000),
|
|
|
|
|
EnvironmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.Windows);
|
|
|
|
|
|
|
|
|
|
MediaEncoder = mediaEncoder;
|
|
|
|
|
RegisterSingleInstance(MediaEncoder);
|
|
|
|
@ -824,7 +822,7 @@ namespace MediaBrowser.Server.Startup.Common
|
|
|
|
|
/// <returns>Task{IUserRepository}.</returns>
|
|
|
|
|
private async Task<IUserRepository> GetUserRepository()
|
|
|
|
|
{
|
|
|
|
|
var repo = new SqliteUserRepository(LogManager, ApplicationPaths, JsonSerializer, NativeApp.GetDbConnector(), MemoryStreamProvider);
|
|
|
|
|
var repo = new SqliteUserRepository(LogManager, ApplicationPaths, JsonSerializer, NativeApp.GetDbConnector(), MemoryStreamFactory);
|
|
|
|
|
|
|
|
|
|
await repo.Initialize().ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
@ -968,6 +966,7 @@ namespace MediaBrowser.Server.Startup.Common
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string CertificatePath { get; set; }
|
|
|
|
|
private ICertificate Certificate { get; set; }
|
|
|
|
|
|
|
|
|
|
private IEnumerable<string> GetUrlPrefixes()
|
|
|
|
|
{
|
|
|
|
@ -997,10 +996,11 @@ namespace MediaBrowser.Server.Startup.Common
|
|
|
|
|
private void StartServer()
|
|
|
|
|
{
|
|
|
|
|
CertificatePath = GetCertificatePath(true);
|
|
|
|
|
Certificate = GetCertificate(CertificatePath);
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ServerManager.Start(GetUrlPrefixes(), CertificatePath);
|
|
|
|
|
ServerManager.Start(GetUrlPrefixes());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
@ -1017,7 +1017,7 @@ namespace MediaBrowser.Server.Startup.Common
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ServerManager.Start(GetUrlPrefixes(), CertificatePath);
|
|
|
|
|
ServerManager.Start(GetUrlPrefixes());
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
@ -1047,7 +1047,7 @@ namespace MediaBrowser.Server.Startup.Common
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
NetworkManager.GenerateSelfSignedSslCertificate(certPath, certHost);
|
|
|
|
|
_certificateGenerator(certPath, certHost);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
@ -1158,51 +1158,51 @@ namespace MediaBrowser.Server.Startup.Common
|
|
|
|
|
// This will prevent the .dll file from getting locked, and allow us to replace it when needed
|
|
|
|
|
|
|
|
|
|
// Include composable parts in the Api assembly
|
|
|
|
|
list.Add(typeof(ApiEntryPoint).Assembly);
|
|
|
|
|
list.Add(GetAssembly(typeof(ApiEntryPoint)));
|
|
|
|
|
|
|
|
|
|
// Include composable parts in the Dashboard assembly
|
|
|
|
|
list.Add(typeof(DashboardService).Assembly);
|
|
|
|
|
list.Add(GetAssembly(typeof(DashboardService)));
|
|
|
|
|
|
|
|
|
|
// Include composable parts in the Model assembly
|
|
|
|
|
list.Add(typeof(SystemInfo).Assembly);
|
|
|
|
|
list.Add(GetAssembly(typeof(SystemInfo)));
|
|
|
|
|
|
|
|
|
|
// Include composable parts in the Common assembly
|
|
|
|
|
list.Add(typeof(IApplicationHost).Assembly);
|
|
|
|
|
list.Add(GetAssembly(typeof(IApplicationHost)));
|
|
|
|
|
|
|
|
|
|
// Include composable parts in the Controller assembly
|
|
|
|
|
list.Add(typeof(IServerApplicationHost).Assembly);
|
|
|
|
|
list.Add(GetAssembly(typeof(IServerApplicationHost)));
|
|
|
|
|
|
|
|
|
|
// Include composable parts in the Providers assembly
|
|
|
|
|
list.Add(typeof(ProviderUtils).Assembly);
|
|
|
|
|
list.Add(GetAssembly(typeof(ProviderUtils)));
|
|
|
|
|
|
|
|
|
|
// Include composable parts in the Photos assembly
|
|
|
|
|
list.Add(typeof(PhotoProvider).Assembly);
|
|
|
|
|
list.Add(GetAssembly(typeof(PhotoProvider)));
|
|
|
|
|
|
|
|
|
|
// Common implementations
|
|
|
|
|
list.Add(typeof(TaskManager).Assembly);
|
|
|
|
|
|
|
|
|
|
// MediaBrowser.Server implementations
|
|
|
|
|
list.Add(typeof(ServerApplicationPaths).Assembly);
|
|
|
|
|
list.Add(GetAssembly(typeof(TaskManager)));
|
|
|
|
|
|
|
|
|
|
// Emby.Server implementations
|
|
|
|
|
list.Add(typeof(InstallationManager).Assembly);
|
|
|
|
|
list.Add(GetAssembly(typeof(InstallationManager)));
|
|
|
|
|
|
|
|
|
|
// Emby.Server.Core
|
|
|
|
|
list.Add(GetAssembly(typeof(ServerApplicationPaths)));
|
|
|
|
|
|
|
|
|
|
// MediaEncoding
|
|
|
|
|
list.Add(typeof(MediaEncoder).Assembly);
|
|
|
|
|
list.Add(GetAssembly(typeof(MediaEncoder)));
|
|
|
|
|
|
|
|
|
|
// Dlna
|
|
|
|
|
list.Add(typeof(DlnaEntryPoint).Assembly);
|
|
|
|
|
list.Add(GetAssembly(typeof(DlnaEntryPoint)));
|
|
|
|
|
|
|
|
|
|
// Local metadata
|
|
|
|
|
list.Add(typeof(BoxSetXmlSaver).Assembly);
|
|
|
|
|
list.Add(GetAssembly(typeof(BoxSetXmlSaver)));
|
|
|
|
|
|
|
|
|
|
// Xbmc
|
|
|
|
|
list.Add(typeof(ArtistNfoProvider).Assembly);
|
|
|
|
|
list.Add(GetAssembly(typeof(ArtistNfoProvider)));
|
|
|
|
|
|
|
|
|
|
list.AddRange(NativeApp.GetAssembliesWithParts());
|
|
|
|
|
|
|
|
|
|
// Include composable parts in the running assembly
|
|
|
|
|
list.Add(GetType().Assembly);
|
|
|
|
|
list.Add(GetAssembly(GetType()));
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
@ -1267,7 +1267,7 @@ namespace MediaBrowser.Server.Startup.Common
|
|
|
|
|
HttpServerPortNumber = HttpPort,
|
|
|
|
|
SupportsHttps = SupportsHttps,
|
|
|
|
|
HttpsPortNumber = HttpsPort,
|
|
|
|
|
OperatingSystem = NativeApp.Environment.OperatingSystem.ToString(),
|
|
|
|
|
OperatingSystem = EnvironmentInfo.OperatingSystem.ToString(),
|
|
|
|
|
OperatingSystemDisplayName = OperatingSystemDisplayName,
|
|
|
|
|
CanSelfRestart = CanSelfRestart,
|
|
|
|
|
CanSelfUpdate = CanSelfUpdate,
|
|
|
|
@ -1279,9 +1279,9 @@ namespace MediaBrowser.Server.Startup.Common
|
|
|
|
|
SupportsRunningAsService = SupportsRunningAsService,
|
|
|
|
|
ServerName = FriendlyName,
|
|
|
|
|
LocalAddress = localAddress,
|
|
|
|
|
SupportsLibraryMonitor = SupportsLibraryMonitor,
|
|
|
|
|
SupportsLibraryMonitor = true,
|
|
|
|
|
EncoderLocationType = MediaEncoder.EncoderLocationType,
|
|
|
|
|
SystemArchitecture = NativeApp.Environment.SystemArchitecture,
|
|
|
|
|
SystemArchitecture = EnvironmentInfo.SystemArchitecture,
|
|
|
|
|
SystemUpdateLevel = ConfigurationManager.CommonConfiguration.SystemUpdateLevel,
|
|
|
|
|
PackageName = _startupOptions.GetOption("-package")
|
|
|
|
|
};
|
|
|
|
@ -1297,7 +1297,7 @@ namespace MediaBrowser.Server.Startup.Common
|
|
|
|
|
|
|
|
|
|
public bool SupportsHttps
|
|
|
|
|
{
|
|
|
|
|
get { return !string.IsNullOrWhiteSpace(HttpServer.CertificatePath); }
|
|
|
|
|
get { return Certificate != null; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<string> GetLocalApiUrl()
|