/// <summary> /// Initializes a new instance of the <see cref="DlnaServerManager"/> class. /// </summary> /// <param name="loggerFactory">The <see cref="ILoggerFactory"/> instance.</param> /// <param name="appHost">The <see cref="IServerApplicationHost"/> instance.</param> /// <param name="libraryManager">The <see cref="ILibraryManager"/> instance.</param> /// <param name="userManager">The <see cref="IUserManager"/> instance.</param> /// <param name="profileManager">The <see cref="IProfileManager"/> instance.</param> /// <param name="imageProcessor">The <see cref="IImageProcessor"/> instance.</param> /// <param name="userDataManager">The <see cref="IUserDataManager"/> instance.</param> /// <param name="localizationManager">The <see cref="ILocalizationManager"/> instance.</param> /// <param name="mediaSourceManager">The <see cref="IMediaSourceManager"/> instance.</param> /// <param name="mediaEncoder">The <see cref="IMediaEncoder"/> instance.</param> /// <param name="networkManager">The <see cref="INetworkManager"/> instance.</param> /// <param name="userViewManager">The <see cref="IUserViewManager"/> instance.</param> /// <param name="tvSeriesManager">The <see cref="ITVSeriesManager"/> instance.</param> /// <param name="configurationManager">The <see cref="IConfigurationManager"/> instance.</param> /// <param name="httpClientFactory">The <see cref="IHttpClientFactory"/> instance.</param> /// <param name="xmlSerializer">The <see cref="IXmlSerializer"/> instance.</param> #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. :-> ServerString #pragma warning disable CA1062 // Validate arguments of public methods. -> Created by DI. public DlnaServerManager( ILoggerFactory loggerFactory, IServerApplicationHost appHost, ILibraryManager libraryManager, IUserManager userManager, IDeviceProfileManager profileManager, IImageProcessor imageProcessor, IUserDataManager userDataManager, ILocalizationManager localizationManager, IMediaSourceManager mediaSourceManager, IMediaEncoder mediaEncoder, INetworkManager networkManager, IUserViewManager userViewManager, ITVSeriesManager tvSeriesManager, IConfigurationManager configurationManager, IHttpClientFactory httpClientFactory, IXmlSerializer xmlSerializer) { SsdpConfiguration.JellyfinVersion = appHost.ApplicationVersionString; // Changing serverId will cause dlna url links to become invalid between restarts. ServerId = DlnaServerPlugin.Instance !.Configuration.ChangeIdOnStartup ? Guid.NewGuid() : Guid.Parse(appHost.SystemId); _networkManager = networkManager; _appHost = appHost; _logger = loggerFactory.CreateLogger <DlnaServerManager>(); _configurationManager = configurationManager; _profileManager = profileManager; EventManager = new DlnaEventManager(_logger, httpClientFactory); // Link into the streaming API, so that headers etc can be performed. StreamingHelpers.StreamEvent ??= DlnaStreamHelper.StreamEventProcessor; _logger.LogDebug("DLNA Server : Starting Content Directory service."); ContentDirectory = new ContentDirectoryService( profileManager, userDataManager, imageProcessor, libraryManager, userManager, _logger, localizationManager, mediaSourceManager, userViewManager, mediaEncoder, tvSeriesManager); _logger.LogDebug("DLNA Server : Starting Connection Manager service."); ConnectionManager = new ConnectionManagerService(profileManager, _logger); var config = DlnaServerPlugin.Instance !.Configuration; // Get bind addresses or interfaces if not specified. var interfaces = config.BindAddresses; var bindInterfaces = _networkManager.GetInternalBindAddresses(); if (interfaces.Length > 0) { // Select only the internal interfaces that are LAN and bound. var addresses = _networkManager.CreateIPCollection(interfaces, false, false); _bindAddresses = bindInterfaces.Where(i => addresses.Contains(i) && (i.AddressFamily == AddressFamily.InterNetwork || (i.AddressFamily == AddressFamily.InterNetworkV6 && i.Address.ScopeId != 0))) .ToArray(); } else { _bindAddresses = bindInterfaces.Where(i => !i.IsLoopback() && (i.AddressFamily == AddressFamily.InterNetwork || (i.AddressFamily == AddressFamily.InterNetworkV6 && i.Address.ScopeId != 0))) .ToArray(); } if (_bindAddresses.Length == 0) { // only use loop-backs if no other address available. _bindAddresses = bindInterfaces; } _publisher = new SsdpServerPublisher( configurationManager, _logger, loggerFactory, _networkManager, _bindAddresses, config.AliveMessageIntervalSeconds, config.EnableWindowsExplorerSupport); // Load system profiles into memory. ProfileHelper.ExtractSystemTemplates(_logger, _profileManager, xmlSerializer).GetAwaiter().GetResult(); // Solves a race condition can occur when API receives input before DI initialization is complete. Instance = this; }