Use DI for MediaReceiverRegistrarService

pull/10391/head
Patrick Barron 1 year ago
parent e0b089a375
commit 010cf2340a

@ -5,6 +5,7 @@ using System.Net.Http;
using System.Text; using System.Text;
using Emby.Dlna.ConnectionManager; using Emby.Dlna.ConnectionManager;
using Emby.Dlna.ContentDirectory; using Emby.Dlna.ContentDirectory;
using Emby.Dlna.MediaReceiverRegistrar;
using Emby.Dlna.Ssdp; using Emby.Dlna.Ssdp;
using MediaBrowser.Common.Net; using MediaBrowser.Common.Net;
using MediaBrowser.Controller; using MediaBrowser.Controller;
@ -52,5 +53,6 @@ public static class DlnaServiceCollectionExtensions
services.AddSingleton<IDeviceDiscovery, DeviceDiscovery>(); services.AddSingleton<IDeviceDiscovery, DeviceDiscovery>();
services.AddSingleton<IContentDirectory, ContentDirectoryService>(); services.AddSingleton<IContentDirectory, ContentDirectoryService>();
services.AddSingleton<IConnectionManager, ConnectionManagerService>(); services.AddSingleton<IConnectionManager, ConnectionManagerService>();
services.AddSingleton<IMediaReceiverRegistrar, MediaReceiverRegistrarService>();
} }
} }

@ -94,12 +94,6 @@ namespace Emby.Dlna.Main
_networkManager = networkManager; _networkManager = networkManager;
_logger = loggerFactory.CreateLogger<DlnaEntryPoint>(); _logger = loggerFactory.CreateLogger<DlnaEntryPoint>();
MediaReceiverRegistrar = new MediaReceiverRegistrar.MediaReceiverRegistrarService(
loggerFactory.CreateLogger<MediaReceiverRegistrar.MediaReceiverRegistrarService>(),
httpClientFactory,
config);
Current = this;
var netConfig = config.GetConfiguration<NetworkConfiguration>(NetworkConfigurationStore.StoreKey); var netConfig = config.GetConfiguration<NetworkConfiguration>(NetworkConfigurationStore.StoreKey);
_disabled = appHost.ListenWithHttps && netConfig.RequireHttps; _disabled = appHost.ListenWithHttps && netConfig.RequireHttps;
@ -109,15 +103,11 @@ namespace Emby.Dlna.Main
} }
} }
public static DlnaEntryPoint Current { get; private set; }
/// <summary> /// <summary>
/// Gets a value indicating whether the dlna server is enabled. /// Gets a value indicating whether the dlna server is enabled.
/// </summary> /// </summary>
public static bool Enabled { get; private set; } public static bool Enabled { get; private set; }
public IMediaReceiverRegistrar MediaReceiverRegistrar { get; private set; }
public async Task RunAsync() public async Task RunAsync()
{ {
await ((DlnaManager)_dlnaManager).InitProfilesAsync().ConfigureAwait(false); await ((DlnaManager)_dlnaManager).InitProfilesAsync().ConfigureAwait(false);
@ -425,9 +415,6 @@ namespace Emby.Dlna.Main
_communicationsServer = null; _communicationsServer = null;
} }
MediaReceiverRegistrar = null;
Current = null;
_disposed = true; _disposed = true;
} }
} }

@ -5,7 +5,6 @@ using System.IO;
using System.Net.Mime; using System.Net.Mime;
using System.Threading.Tasks; using System.Threading.Tasks;
using Emby.Dlna; using Emby.Dlna;
using Emby.Dlna.Main;
using Jellyfin.Api.Attributes; using Jellyfin.Api.Attributes;
using Jellyfin.Api.Constants; using Jellyfin.Api.Constants;
using MediaBrowser.Controller.Dlna; using MediaBrowser.Controller.Dlna;
@ -35,15 +34,17 @@ public class DlnaServerController : BaseJellyfinApiController
/// <param name="dlnaManager">Instance of the <see cref="IDlnaManager"/> interface.</param> /// <param name="dlnaManager">Instance of the <see cref="IDlnaManager"/> interface.</param>
/// <param name="contentDirectory">Instance of the <see cref="IContentDirectory"/> interface.</param> /// <param name="contentDirectory">Instance of the <see cref="IContentDirectory"/> interface.</param>
/// <param name="connectionManager">Instance of the <see cref="IConnectionManager"/> interface.</param> /// <param name="connectionManager">Instance of the <see cref="IConnectionManager"/> interface.</param>
/// <param name="mediaReceiverRegistrar">Instance of the <see cref="IMediaReceiverRegistrar"/> interface.</param>
public DlnaServerController( public DlnaServerController(
IDlnaManager dlnaManager, IDlnaManager dlnaManager,
IContentDirectory contentDirectory, IContentDirectory contentDirectory,
IConnectionManager connectionManager) IConnectionManager connectionManager,
IMediaReceiverRegistrar mediaReceiverRegistrar)
{ {
_dlnaManager = dlnaManager; _dlnaManager = dlnaManager;
_contentDirectory = contentDirectory; _contentDirectory = contentDirectory;
_connectionManager = connectionManager; _connectionManager = connectionManager;
_mediaReceiverRegistrar = DlnaEntryPoint.Current.MediaReceiverRegistrar; _mediaReceiverRegistrar = mediaReceiverRegistrar;
} }
/// <summary> /// <summary>

Loading…
Cancel
Save