The Free Software Media System - Server Backend & API
Merge branch 'master' into register-services-correctly
Mark Monteiro9728aa8b0abc
diff --cc Emby.Server.Implementations/ApplicationHost.csindex ad0a69b19e,81a80ddb26..03ce9a9a9f--- a/Emby.Server.Implementations/ApplicationHost.cs+++ b/Emby.Server.Implementations/ApplicationHost.cs@@@ -86,8 -85,8 +85,7 @@@ using MediaBrowser.MediaEncoding.BdInfousing MediaBrowser.Model.Activity;using MediaBrowser.Model.Configuration;using MediaBrowser.Model.Cryptography;- using MediaBrowser.Model.Diagnostics;using MediaBrowser.Model.Dlna;-using MediaBrowser.Model.Events;using MediaBrowser.Model.Globalization;using MediaBrowser.Model.IO;using MediaBrowser.Model.MediaInfo;@@@ -552,41 -651,44 +550,39 @@@ namespace Emby.Server.ImplementationserviceCollection.AddSingleton<IApplicationPaths>(ApplicationPaths);- serviceCollection.AddSingleton(JsonSerializer);+ serviceCollection.AddSingleton<IJsonSerializer, JsonSerializer>();- // TODO: Support for injecting ILogger should be deprecated in favour of ILogger<T> and this removed- serviceCollection.AddSingleton<ILogger>(Logger);+ // TODO: Remove support for injecting ILogger completely+ serviceCollection.AddSingleton((provider) =>+ {+ Logger.LogWarning("Injecting ILogger directly is deprecated and should be replaced with ILogger<T>");+ return Logger;+ });- serviceCollection.AddSingleton(FileSystemManager);+ serviceCollection.AddSingleton(_fileSystemManager);serviceCollection.AddSingleton<TvdbClientManager>();- HttpClient = new HttpClientManager.HttpClientManager(- ApplicationPaths,- LoggerFactory.CreateLogger<HttpClientManager.HttpClientManager>(),- FileSystemManager,- () => ApplicationUserAgent);- serviceCollection.AddSingleton(HttpClient);+ serviceCollection.AddSingleton<IHttpClient, HttpClientManager.HttpClientManager>();- serviceCollection.AddSingleton(NetworkManager);+ serviceCollection.AddSingleton(_networkManager);- IsoManager = new IsoManager();- serviceCollection.AddSingleton(IsoManager);+ serviceCollection.AddSingleton<IIsoManager, IsoManager>();- TaskManager = new TaskManager(ApplicationPaths, JsonSerializer, LoggerFactory, FileSystemManager);- serviceCollection.AddSingleton(TaskManager);+ serviceCollection.AddSingleton<ITaskManager, TaskManager>();- serviceCollection.AddSingleton(XmlSerializer);+ serviceCollection.AddSingleton(_xmlSerializer);- serviceCollection.AddSingleton<IProcessFactory, ProcessFactory>();-- serviceCollection.AddSingleton(typeof(IStreamHelper), typeof(StreamHelper));+ serviceCollection.AddSingleton<IStreamHelper, StreamHelper>();- var cryptoProvider = new CryptographyProvider();- serviceCollection.AddSingleton<ICryptoProvider>(cryptoProvider);+ serviceCollection.AddSingleton<ICryptoProvider, CryptographyProvider>();- SocketFactory = new SocketFactory();- serviceCollection.AddSingleton(SocketFactory);+ serviceCollection.AddSingleton<ISocketFactory, SocketFactory>();- serviceCollection.AddSingleton(typeof(IInstallationManager), typeof(InstallationManager));+ serviceCollection.AddSingleton<IInstallationManager, InstallationManager>();- serviceCollection.AddSingleton(typeof(IZipClient), typeof(ZipClient));+ serviceCollection.AddSingleton<IZipClient, ZipClient>();- serviceCollection.AddSingleton(typeof(IHttpResultFactory), typeof(HttpResultFactory));+ serviceCollection.AddSingleton<IHttpResultFactory, HttpResultFactory>();serviceCollection.AddSingleton<IServerApplicationHost>(this);serviceCollection.AddSingleton<IServerApplicationPaths>(ApplicationPaths);diff --cc MediaBrowser.MediaEncoding/Encoder/MediaEncoder.csindex c5bba87802,c2bfac9d63..f4260afbca--- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs+++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs@@@ -38,9 -38,9 +38,8 @@@ namespace MediaBrowser.MediaEncoding.Enprivate readonly ILogger _logger;private readonly IServerConfigurationManager _configurationManager;private readonly IFileSystem _fileSystem;- private readonly IProcessFactory _processFactory;private readonly ILocalizationManager _localization;- private readonly Func<ISubtitleEncoder> _subtitleEncoder;- private readonly IConfiguration _configuration;+ private readonly Lazy<EncodingHelper> _encodingHelperFactory;private readonly string _startupOptionFFmpegPath;private readonly SemaphoreSlim _thumbnailResourcePool = new SemaphoreSlim(2, 2);@@@ -55,21 -57,24 +54,19 @@@ILogger<MediaEncoder> logger,IServerConfigurationManager configurationManager,IFileSystem fileSystem,- IProcessFactory processFactory,ILocalizationManager localization,- Func<ISubtitleEncoder> subtitleEncoder,- IConfiguration configuration,+ Lazy<EncodingHelper> encodingHelperFactory,string startupOptionsFFmpegPath){_logger = logger;_configurationManager = configurationManager;_fileSystem = fileSystem;- _processFactory = processFactory;_localization = localization;+ _encodingHelperFactory = encodingHelperFactory;_startupOptionFFmpegPath = startupOptionsFFmpegPath;- _subtitleEncoder = subtitleEncoder;- _configuration = configuration;}- private EncodingHelper EncodingHelper- => LazyInitializer.EnsureInitialized(- ref _encodingHelper,- () => new EncodingHelper(this, _fileSystem, _subtitleEncoder(), _configuration));+ private EncodingHelper EncodingHelper => _encodingHelperFactory.Value;/// <inheritdoc />public string EncoderPath => _ffmpegPath;