diff options
Diffstat (limited to 'Emby.Server.Implementations/Library/MediaSourceManager.cs')
| -rw-r--r-- | Emby.Server.Implementations/Library/MediaSourceManager.cs | 70 |
1 files changed, 39 insertions, 31 deletions
diff --git a/Emby.Server.Implementations/Library/MediaSourceManager.cs b/Emby.Server.Implementations/Library/MediaSourceManager.cs index ddda4b2c3..0adc5553b 100644 --- a/Emby.Server.Implementations/Library/MediaSourceManager.cs +++ b/Emby.Server.Implementations/Library/MediaSourceManager.cs @@ -1,28 +1,27 @@ -using MediaBrowser.Common.Extensions; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using MediaBrowser.Common.Configuration; +using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Controller.Persistence; using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Configuration; +using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; -using Microsoft.Extensions.Logging; +using MediaBrowser.Model.Globalization; +using MediaBrowser.Model.IO; using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.Serialization; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using MediaBrowser.Model.IO; -using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Threading; -using MediaBrowser.Model.Dlna; -using MediaBrowser.Model.Globalization; -using System.IO; -using System.Globalization; -using MediaBrowser.Common.Configuration; +using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.Library { @@ -42,12 +41,23 @@ namespace Emby.Server.Implementations.Library private ILocalizationManager _localizationManager; private IApplicationPaths _appPaths; - public MediaSourceManager(IItemRepository itemRepo, IApplicationPaths applicationPaths, ILocalizationManager localizationManager, IUserManager userManager, ILibraryManager libraryManager, ILogger logger, IJsonSerializer jsonSerializer, IFileSystem fileSystem, IUserDataManager userDataManager, ITimerFactory timerFactory, Func<IMediaEncoder> mediaEncoder) + public MediaSourceManager( + IItemRepository itemRepo, + IApplicationPaths applicationPaths, + ILocalizationManager localizationManager, + IUserManager userManager, + ILibraryManager libraryManager, + ILoggerFactory loggerFactory, + IJsonSerializer jsonSerializer, + IFileSystem fileSystem, + IUserDataManager userDataManager, + ITimerFactory timerFactory, + Func<IMediaEncoder> mediaEncoder) { _itemRepo = itemRepo; _userManager = userManager; _libraryManager = libraryManager; - _logger = logger; + _logger = loggerFactory.CreateLogger(nameof(MediaSourceManager)); _jsonSerializer = jsonSerializer; _fileSystem = fileSystem; _userDataManager = userDataManager; @@ -74,7 +84,7 @@ namespace Emby.Server.Implementations.Library return list; } - private bool StreamSupportsExternalStream(MediaStream stream) + private static bool StreamSupportsExternalStream(MediaStream stream) { if (stream.IsExternal) { @@ -128,7 +138,7 @@ namespace Emby.Server.Implementations.Library if (allowMediaProbe && mediaSources[0].Type != MediaSourceType.Placeholder && !mediaSources[0].MediaStreams.Any(i => i.Type == MediaStreamType.Audio || i.Type == MediaStreamType.Video)) { - await item.RefreshMetadata(new MediaBrowser.Controller.Providers.MetadataRefreshOptions(new DirectoryService(_logger, _fileSystem)) + await item.RefreshMetadata(new MetadataRefreshOptions(new DirectoryService(_logger, _fileSystem)) { EnableRemoteContentProbe = true, MetadataRefreshMode = MediaBrowser.Controller.Providers.MetadataRefreshMode.FullRefresh @@ -261,7 +271,7 @@ namespace Emby.Server.Implementations.Library } } - private void SetKeyProperties(IMediaSourceProvider provider, MediaSourceInfo mediaSource) + private static void SetKeyProperties(IMediaSourceProvider provider, MediaSourceInfo mediaSource) { var prefix = provider.GetType().FullName.GetMD5().ToString("N") + LiveStreamIdDelimeter; @@ -292,7 +302,7 @@ namespace Emby.Server.Implementations.Library { if (item == null) { - throw new ArgumentNullException("item"); + throw new ArgumentNullException(nameof(item)); } var hasMediaSources = (IHasMediaSources)item; @@ -401,7 +411,7 @@ namespace Emby.Server.Implementations.Library } } - private IEnumerable<MediaSourceInfo> SortMediaSources(IEnumerable<MediaSourceInfo> sources) + private static IEnumerable<MediaSourceInfo> SortMediaSources(IEnumerable<MediaSourceInfo> sources) { return sources.OrderBy(i => { @@ -501,7 +511,7 @@ namespace Emby.Server.Implementations.Library }, liveStream as IDirectStreamProvider); } - private void AddMediaInfo(MediaSourceInfo mediaSource, bool isAudio) + private static void AddMediaInfo(MediaSourceInfo mediaSource, bool isAudio) { mediaSource.DefaultSubtitleStreamIndex = null; @@ -629,6 +639,7 @@ namespace Emby.Server.Implementations.Library } catch (Exception ex) { + _logger.LogDebug(ex, "_jsonSerializer.DeserializeFromFile threw an exception."); } } @@ -759,7 +770,7 @@ namespace Emby.Server.Implementations.Library { if (string.IsNullOrEmpty(id)) { - throw new ArgumentNullException("id"); + throw new ArgumentNullException(nameof(id)); } var info = await GetLiveStreamInfo(id, cancellationToken).ConfigureAwait(false); @@ -770,15 +781,14 @@ namespace Emby.Server.Implementations.Library { if (string.IsNullOrEmpty(id)) { - throw new ArgumentNullException("id"); + throw new ArgumentNullException(nameof(id)); } await _liveStreamSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false); try { - ILiveStream info; - if (_openStreams.TryGetValue(id, out info)) + if (_openStreams.TryGetValue(id, out ILiveStream info)) { return info; } @@ -803,16 +813,14 @@ namespace Emby.Server.Implementations.Library { if (string.IsNullOrEmpty(id)) { - throw new ArgumentNullException("id"); + throw new ArgumentNullException(nameof(id)); } await _liveStreamSemaphore.WaitAsync().ConfigureAwait(false); try { - ILiveStream liveStream; - - if (_openStreams.TryGetValue(id, out liveStream)) + if (_openStreams.TryGetValue(id, out ILiveStream liveStream)) { liveStream.ConsumerCount--; |
