mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-06-23 15:30:56 -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.Cryptography;
|
||||||
using MediaBrowser.Model.Diagnostics;
|
using MediaBrowser.Model.Diagnostics;
|
||||||
using MediaBrowser.Model.Dlna;
|
using MediaBrowser.Model.Dlna;
|
||||||
using MediaBrowser.Model.Events;
|
|
||||||
using MediaBrowser.Model.Globalization;
|
using MediaBrowser.Model.Globalization;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.MediaInfo;
|
using MediaBrowser.Model.MediaInfo;
|
||||||
@ -106,7 +105,6 @@ using MediaBrowser.WebDashboard.Api;
|
|||||||
using MediaBrowser.XbmcMetadata.Providers;
|
using MediaBrowser.XbmcMetadata.Providers;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Http.Extensions;
|
using Microsoft.AspNetCore.Http.Extensions;
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using OperatingSystem = MediaBrowser.Common.System.OperatingSystem;
|
using OperatingSystem = MediaBrowser.Common.System.OperatingSystem;
|
||||||
@ -614,17 +612,11 @@ namespace Emby.Server.Implementations
|
|||||||
serviceCollection.AddTransient(provider => new Lazy<IDtoService>(provider.GetRequiredService<IDtoService>));
|
serviceCollection.AddTransient(provider => new Lazy<IDtoService>(provider.GetRequiredService<IDtoService>));
|
||||||
serviceCollection.AddSingleton<IUserManager, UserManager>();
|
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 =>
|
serviceCollection.AddSingleton<IMediaEncoder>(provider =>
|
||||||
new MediaBrowser.MediaEncoding.Encoder.MediaEncoder(
|
ActivatorUtilities.CreateInstance<MediaBrowser.MediaEncoding.Encoder.MediaEncoder>(provider, _startupOptions.FFmpegPath ?? string.Empty));
|
||||||
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));
|
|
||||||
|
|
||||||
// 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>));
|
||||||
|
@ -40,8 +40,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
private readonly IProcessFactory _processFactory;
|
private readonly IProcessFactory _processFactory;
|
||||||
private readonly ILocalizationManager _localization;
|
private readonly ILocalizationManager _localization;
|
||||||
private readonly Func<ISubtitleEncoder> _subtitleEncoder;
|
private readonly Lazy<EncodingHelper> _encodingHelperFactory;
|
||||||
private readonly IConfiguration _configuration;
|
|
||||||
private readonly string _startupOptionFFmpegPath;
|
private readonly string _startupOptionFFmpegPath;
|
||||||
|
|
||||||
private readonly SemaphoreSlim _thumbnailResourcePool = new SemaphoreSlim(2, 2);
|
private readonly SemaphoreSlim _thumbnailResourcePool = new SemaphoreSlim(2, 2);
|
||||||
@ -49,8 +48,6 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||||||
private readonly object _runningProcessesLock = new object();
|
private readonly object _runningProcessesLock = new object();
|
||||||
private readonly List<ProcessWrapper> _runningProcesses = new List<ProcessWrapper>();
|
private readonly List<ProcessWrapper> _runningProcesses = new List<ProcessWrapper>();
|
||||||
|
|
||||||
private EncodingHelper _encodingHelper;
|
|
||||||
|
|
||||||
private string _ffmpegPath;
|
private string _ffmpegPath;
|
||||||
private string _ffprobePath;
|
private string _ffprobePath;
|
||||||
|
|
||||||
@ -60,8 +57,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||||||
IFileSystem fileSystem,
|
IFileSystem fileSystem,
|
||||||
IProcessFactory processFactory,
|
IProcessFactory processFactory,
|
||||||
ILocalizationManager localization,
|
ILocalizationManager localization,
|
||||||
Func<ISubtitleEncoder> subtitleEncoder,
|
Lazy<EncodingHelper> encodingHelperFactory,
|
||||||
IConfiguration configuration,
|
|
||||||
string startupOptionsFFmpegPath)
|
string startupOptionsFFmpegPath)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
@ -69,15 +65,11 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
_processFactory = processFactory;
|
_processFactory = processFactory;
|
||||||
_localization = localization;
|
_localization = localization;
|
||||||
|
_encodingHelperFactory = encodingHelperFactory;
|
||||||
_startupOptionFFmpegPath = startupOptionsFFmpegPath;
|
_startupOptionFFmpegPath = startupOptionsFFmpegPath;
|
||||||
_subtitleEncoder = subtitleEncoder;
|
|
||||||
_configuration = configuration;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private EncodingHelper EncodingHelper
|
private EncodingHelper EncodingHelper => _encodingHelperFactory.Value;
|
||||||
=> LazyInitializer.EnsureInitialized(
|
|
||||||
ref _encodingHelper,
|
|
||||||
() => new EncodingHelper(this, _fileSystem, _subtitleEncoder(), _configuration));
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public string EncoderPath => _ffmpegPath;
|
public string EncoderPath => _ffmpegPath;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user