소스 검색

Register and construct IMediaSourceManager correctly

Mark Monteiro 5 년 전
부모
커밋
573da63d41
2개의 변경된 파일15개의 추가작업 그리고 18개의 파일을 삭제
  1. 4 7
      Emby.Server.Implementations/ApplicationHost.cs
  2. 11 11
      Emby.Server.Implementations/Library/MediaSourceManager.cs

+ 4 - 7
Emby.Server.Implementations/ApplicationHost.cs

@@ -288,8 +288,6 @@ namespace Emby.Server.Implementations
 
 
         private ITVSeriesManager TVSeriesManager { get; set; }
         private ITVSeriesManager TVSeriesManager { get; set; }
 
 
-        private IMediaSourceManager MediaSourceManager { get; set; }
-
         /// <summary>
         /// <summary>
         /// Gets the installation manager.
         /// Gets the installation manager.
         /// </summary>
         /// </summary>
@@ -740,14 +738,13 @@ namespace Emby.Server.Implementations
             DeviceManager = new DeviceManager(AuthenticationRepository, JsonSerializer, LibraryManager, LocalizationManager, UserManager, FileSystemManager, LibraryMonitor, ServerConfigurationManager);
             DeviceManager = new DeviceManager(AuthenticationRepository, JsonSerializer, LibraryManager, LocalizationManager, UserManager, FileSystemManager, LibraryMonitor, ServerConfigurationManager);
             serviceCollection.AddSingleton(DeviceManager);
             serviceCollection.AddSingleton(DeviceManager);
 
 
-            MediaSourceManager = new MediaSourceManager(ItemRepository, ApplicationPaths, LocalizationManager, UserManager, LibraryManager, LoggerFactory, JsonSerializer, FileSystemManager, UserDataManager, () => MediaEncoder);
-            serviceCollection.AddSingleton(MediaSourceManager);
+            serviceCollection.AddSingleton<IMediaSourceManager, MediaSourceManager>();
 
 
             serviceCollection.AddSingleton<ISubtitleManager, SubtitleManager>();
             serviceCollection.AddSingleton<ISubtitleManager, SubtitleManager>();
 
 
             serviceCollection.AddSingleton<IProviderManager, ProviderManager>();
             serviceCollection.AddSingleton<IProviderManager, ProviderManager>();
 
 
-            // TODO: Refactor to eliminate circular dependency here so Lazy<> isn't required
+            // TODO: Refactor to eliminate the circular dependency here so that Lazy<T> isn't required
             serviceCollection.AddTransient(provider => new Lazy<ILiveTvManager>(provider.GetRequiredService<ILiveTvManager>));
             serviceCollection.AddTransient(provider => new Lazy<ILiveTvManager>(provider.GetRequiredService<ILiveTvManager>));
             serviceCollection.AddSingleton<IDtoService, DtoService>();
             serviceCollection.AddSingleton<IDtoService, DtoService>();
 
 
@@ -926,7 +923,7 @@ namespace Emby.Server.Implementations
             Folder.UserViewManager = Resolve<IUserViewManager>();
             Folder.UserViewManager = Resolve<IUserViewManager>();
             UserView.TVSeriesManager = TVSeriesManager;
             UserView.TVSeriesManager = TVSeriesManager;
             UserView.CollectionManager = Resolve<ICollectionManager>();
             UserView.CollectionManager = Resolve<ICollectionManager>();
-            BaseItem.MediaSourceManager = MediaSourceManager;
+            BaseItem.MediaSourceManager = Resolve<IMediaSourceManager>();
             CollectionFolder.XmlSerializer = XmlSerializer;
             CollectionFolder.XmlSerializer = XmlSerializer;
             CollectionFolder.JsonSerializer = JsonSerializer;
             CollectionFolder.JsonSerializer = JsonSerializer;
             CollectionFolder.ApplicationHost = this;
             CollectionFolder.ApplicationHost = this;
@@ -1010,7 +1007,7 @@ namespace Emby.Server.Implementations
 
 
             Resolve<IChannelManager>().AddParts(GetExports<IChannel>());
             Resolve<IChannelManager>().AddParts(GetExports<IChannel>());
 
 
-            MediaSourceManager.AddParts(GetExports<IMediaSourceProvider>());
+            Resolve<IMediaSourceManager>().AddParts(GetExports<IMediaSourceProvider>());
 
 
             Resolve<INotificationManager>().AddParts(GetExports<INotificationService>(), GetExports<INotificationTypeFactory>());
             Resolve<INotificationManager>().AddParts(GetExports<INotificationService>(), GetExports<INotificationTypeFactory>());
             UserManager.AddParts(GetExports<IAuthenticationProvider>(), GetExports<IPasswordResetProvider>());
             UserManager.AddParts(GetExports<IAuthenticationProvider>(), GetExports<IPasswordResetProvider>());

+ 11 - 11
Emby.Server.Implementations/Library/MediaSourceManager.cs

@@ -33,13 +33,13 @@ namespace Emby.Server.Implementations.Library
         private readonly ILibraryManager _libraryManager;
         private readonly ILibraryManager _libraryManager;
         private readonly IJsonSerializer _jsonSerializer;
         private readonly IJsonSerializer _jsonSerializer;
         private readonly IFileSystem _fileSystem;
         private readonly IFileSystem _fileSystem;
-
-        private IMediaSourceProvider[] _providers;
         private readonly ILogger _logger;
         private readonly ILogger _logger;
         private readonly IUserDataManager _userDataManager;
         private readonly IUserDataManager _userDataManager;
-        private readonly Func<IMediaEncoder> _mediaEncoder;
-        private ILocalizationManager _localizationManager;
-        private IApplicationPaths _appPaths;
+        private readonly IMediaEncoder _mediaEncoder;
+        private readonly ILocalizationManager _localizationManager;
+        private readonly IApplicationPaths _appPaths;
+
+        private IMediaSourceProvider[] _providers;
 
 
         public MediaSourceManager(
         public MediaSourceManager(
             IItemRepository itemRepo,
             IItemRepository itemRepo,
@@ -47,16 +47,16 @@ namespace Emby.Server.Implementations.Library
             ILocalizationManager localizationManager,
             ILocalizationManager localizationManager,
             IUserManager userManager,
             IUserManager userManager,
             ILibraryManager libraryManager,
             ILibraryManager libraryManager,
-            ILoggerFactory loggerFactory,
+            ILogger<MediaSourceManager> logger,
             IJsonSerializer jsonSerializer,
             IJsonSerializer jsonSerializer,
             IFileSystem fileSystem,
             IFileSystem fileSystem,
             IUserDataManager userDataManager,
             IUserDataManager userDataManager,
-            Func<IMediaEncoder> mediaEncoder)
+            IMediaEncoder mediaEncoder)
         {
         {
             _itemRepo = itemRepo;
             _itemRepo = itemRepo;
             _userManager = userManager;
             _userManager = userManager;
             _libraryManager = libraryManager;
             _libraryManager = libraryManager;
-            _logger = loggerFactory.CreateLogger(nameof(MediaSourceManager));
+            _logger = logger;
             _jsonSerializer = jsonSerializer;
             _jsonSerializer = jsonSerializer;
             _fileSystem = fileSystem;
             _fileSystem = fileSystem;
             _userDataManager = userDataManager;
             _userDataManager = userDataManager;
@@ -496,7 +496,7 @@ namespace Emby.Server.Implementations.Library
                     // hack - these two values were taken from LiveTVMediaSourceProvider
                     // hack - these two values were taken from LiveTVMediaSourceProvider
                     string cacheKey = request.OpenToken;
                     string cacheKey = request.OpenToken;
 
 
-                    await new LiveStreamHelper(_mediaEncoder(), _logger, _jsonSerializer, _appPaths)
+                    await new LiveStreamHelper(_mediaEncoder, _logger, _jsonSerializer, _appPaths)
                         .AddMediaInfoWithProbe(mediaSource, isAudio, cacheKey, true, cancellationToken)
                         .AddMediaInfoWithProbe(mediaSource, isAudio, cacheKey, true, cancellationToken)
                         .ConfigureAwait(false);
                         .ConfigureAwait(false);
                 }
                 }
@@ -621,7 +621,7 @@ namespace Emby.Server.Implementations.Library
 
 
             if (liveStreamInfo is IDirectStreamProvider)
             if (liveStreamInfo is IDirectStreamProvider)
             {
             {
-                var info = await _mediaEncoder().GetMediaInfo(new MediaInfoRequest
+                var info = await _mediaEncoder.GetMediaInfo(new MediaInfoRequest
                 {
                 {
                     MediaSource = mediaSource,
                     MediaSource = mediaSource,
                     ExtractChapters = false,
                     ExtractChapters = false,
@@ -674,7 +674,7 @@ namespace Emby.Server.Implementations.Library
                     mediaSource.AnalyzeDurationMs = 3000;
                     mediaSource.AnalyzeDurationMs = 3000;
                 }
                 }
 
 
-                mediaInfo = await _mediaEncoder().GetMediaInfo(new MediaInfoRequest
+                mediaInfo = await _mediaEncoder.GetMediaInfo(new MediaInfoRequest
                 {
                 {
                     MediaSource = mediaSource,
                     MediaSource = mediaSource,
                     MediaType = isAudio ? DlnaProfileType.Audio : DlnaProfileType.Video,
                     MediaType = isAudio ? DlnaProfileType.Audio : DlnaProfileType.Video,