mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-05-24 02:02:29 -04:00
Use ActivatorUtilities to construct MediaEncoder and update constructor to inject EncodingHelper correctly
This commit is contained in:
parent
1e1295bebf
commit
17e8813378
@ -88,7 +88,6 @@ 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;
|
||||
@ -106,7 +105,6 @@ using MediaBrowser.WebDashboard.Api;
|
||||
using MediaBrowser.XbmcMetadata.Providers;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.Extensions;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using OperatingSystem = MediaBrowser.Common.System.OperatingSystem;
|
||||
@ -614,17 +612,11 @@ namespace Emby.Server.Implementations
|
||||
serviceCollection.AddTransient(provider => new Lazy<IDtoService>(provider.GetRequiredService<IDtoService>));
|
||||
serviceCollection.AddSingleton<IUserManager, UserManager>();
|
||||
|
||||
// TODO: Add StartupOptions.FFmpegPath to IConfiguration so this doesn't need to be constructed manually
|
||||
// TODO: Refactor to eliminate the circular dependency here so that Lazy<T> isn't required
|
||||
// TODO: Add StartupOptions.FFmpegPath to IConfiguration and remove this custom activation
|
||||
serviceCollection.AddTransient(provider => new Lazy<EncodingHelper>(provider.GetRequiredService<EncodingHelper>));
|
||||
serviceCollection.AddSingleton<IMediaEncoder>(provider =>
|
||||
new MediaBrowser.MediaEncoding.Encoder.MediaEncoder(
|
||||
provider.GetRequiredService<ILogger<MediaBrowser.MediaEncoding.Encoder.MediaEncoder>>(),
|
||||
provider.GetRequiredService<IServerConfigurationManager>(),
|
||||
provider.GetRequiredService<IFileSystem>(),
|
||||
provider.GetRequiredService<IProcessFactory>(),
|
||||
provider.GetRequiredService<ILocalizationManager>(),
|
||||
provider.GetRequiredService<ISubtitleEncoder>,
|
||||
provider.GetRequiredService<IConfiguration>(),
|
||||
_startupOptions.FFmpegPath));
|
||||
ActivatorUtilities.CreateInstance<MediaBrowser.MediaEncoding.Encoder.MediaEncoder>(provider, _startupOptions.FFmpegPath ?? string.Empty));
|
||||
|
||||
// TODO: Refactor to eliminate the circular dependencies here so that Lazy<T> isn't required
|
||||
serviceCollection.AddTransient(provider => new Lazy<ILibraryMonitor>(provider.GetRequiredService<ILibraryMonitor>));
|
||||
|
@ -40,8 +40,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||
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);
|
||||
@ -49,8 +48,6 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||
private readonly object _runningProcessesLock = new object();
|
||||
private readonly List<ProcessWrapper> _runningProcesses = new List<ProcessWrapper>();
|
||||
|
||||
private EncodingHelper _encodingHelper;
|
||||
|
||||
private string _ffmpegPath;
|
||||
private string _ffprobePath;
|
||||
|
||||
@ -60,8 +57,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||
IFileSystem fileSystem,
|
||||
IProcessFactory processFactory,
|
||||
ILocalizationManager localization,
|
||||
Func<ISubtitleEncoder> subtitleEncoder,
|
||||
IConfiguration configuration,
|
||||
Lazy<EncodingHelper> encodingHelperFactory,
|
||||
string startupOptionsFFmpegPath)
|
||||
{
|
||||
_logger = logger;
|
||||
@ -69,15 +65,11 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||
_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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user