2020-01-22 20:00:07 +00:00
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
2019-01-13 19:54:44 +00:00
|
|
|
using System;
|
2019-02-28 22:22:57 +00:00
|
|
|
using System.Globalization;
|
2020-03-03 22:07:10 +00:00
|
|
|
using System.Net.Sockets;
|
2019-01-13 19:16:19 +00:00
|
|
|
using System.Threading;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Emby.Dlna.PlayTo;
|
|
|
|
using Emby.Dlna.Ssdp;
|
|
|
|
using MediaBrowser.Common.Configuration;
|
2016-10-29 22:22:20 +00:00
|
|
|
using MediaBrowser.Common.Extensions;
|
|
|
|
using MediaBrowser.Common.Net;
|
|
|
|
using MediaBrowser.Controller;
|
|
|
|
using MediaBrowser.Controller.Configuration;
|
|
|
|
using MediaBrowser.Controller.Dlna;
|
|
|
|
using MediaBrowser.Controller.Drawing;
|
|
|
|
using MediaBrowser.Controller.Library;
|
2019-01-13 19:16:19 +00:00
|
|
|
using MediaBrowser.Controller.MediaEncoding;
|
2016-10-29 22:22:20 +00:00
|
|
|
using MediaBrowser.Controller.Plugins;
|
|
|
|
using MediaBrowser.Controller.Session;
|
2018-09-12 17:26:21 +00:00
|
|
|
using MediaBrowser.Controller.TV;
|
2016-10-29 22:22:20 +00:00
|
|
|
using MediaBrowser.Model.Dlna;
|
|
|
|
using MediaBrowser.Model.Globalization;
|
2016-11-04 08:31:05 +00:00
|
|
|
using MediaBrowser.Model.Net;
|
2016-11-04 19:51:59 +00:00
|
|
|
using MediaBrowser.Model.System;
|
2019-01-13 19:16:19 +00:00
|
|
|
using Microsoft.Extensions.Logging;
|
2016-10-29 22:22:20 +00:00
|
|
|
using Rssdp;
|
|
|
|
using Rssdp.Infrastructure;
|
2020-03-03 22:07:10 +00:00
|
|
|
using OperatingSystem = MediaBrowser.Common.System.OperatingSystem;
|
2016-10-29 22:22:20 +00:00
|
|
|
|
2016-10-29 22:34:54 +00:00
|
|
|
namespace Emby.Dlna.Main
|
2016-10-29 22:22:20 +00:00
|
|
|
{
|
2018-09-12 17:26:21 +00:00
|
|
|
public class DlnaEntryPoint : IServerEntryPoint, IRunBeforeStartup
|
2016-10-29 22:22:20 +00:00
|
|
|
{
|
|
|
|
private readonly IServerConfigurationManager _config;
|
|
|
|
private readonly ILogger _logger;
|
|
|
|
private readonly IServerApplicationHost _appHost;
|
|
|
|
private readonly ISessionManager _sessionManager;
|
|
|
|
private readonly IHttpClient _httpClient;
|
|
|
|
private readonly ILibraryManager _libraryManager;
|
|
|
|
private readonly IUserManager _userManager;
|
|
|
|
private readonly IDlnaManager _dlnaManager;
|
|
|
|
private readonly IImageProcessor _imageProcessor;
|
|
|
|
private readonly IUserDataManager _userDataManager;
|
|
|
|
private readonly ILocalizationManager _localization;
|
|
|
|
private readonly IMediaSourceManager _mediaSourceManager;
|
|
|
|
private readonly IMediaEncoder _mediaEncoder;
|
|
|
|
private readonly IDeviceDiscovery _deviceDiscovery;
|
2016-11-04 08:31:05 +00:00
|
|
|
private readonly ISocketFactory _socketFactory;
|
2016-12-04 21:30:38 +00:00
|
|
|
private readonly INetworkManager _networkManager;
|
2020-04-29 11:24:01 +00:00
|
|
|
private readonly object _syncLock = new object();
|
2016-11-04 08:31:05 +00:00
|
|
|
|
2020-04-29 11:24:01 +00:00
|
|
|
private PlayToManager _manager;
|
|
|
|
private SsdpDevicePublisher _publisher;
|
2016-11-14 19:48:01 +00:00
|
|
|
private ISsdpCommunicationsServer _communicationsServer;
|
|
|
|
|
2018-09-12 17:26:21 +00:00
|
|
|
internal IContentDirectory ContentDirectory { get; private set; }
|
2020-03-03 22:07:10 +00:00
|
|
|
|
2018-09-12 17:26:21 +00:00
|
|
|
internal IConnectionManager ConnectionManager { get; private set; }
|
2020-03-03 22:07:10 +00:00
|
|
|
|
2018-09-12 17:26:21 +00:00
|
|
|
internal IMediaReceiverRegistrar MediaReceiverRegistrar { get; private set; }
|
|
|
|
|
|
|
|
public static DlnaEntryPoint Current;
|
|
|
|
|
2020-04-29 11:24:01 +00:00
|
|
|
public DlnaEntryPoint(
|
|
|
|
IServerConfigurationManager config,
|
2018-12-13 13:18:25 +00:00
|
|
|
ILoggerFactory loggerFactory,
|
2016-10-29 22:22:20 +00:00
|
|
|
IServerApplicationHost appHost,
|
|
|
|
ISessionManager sessionManager,
|
|
|
|
IHttpClient httpClient,
|
|
|
|
ILibraryManager libraryManager,
|
|
|
|
IUserManager userManager,
|
|
|
|
IDlnaManager dlnaManager,
|
|
|
|
IImageProcessor imageProcessor,
|
|
|
|
IUserDataManager userDataManager,
|
2018-09-12 17:26:21 +00:00
|
|
|
ILocalizationManager localizationManager,
|
2016-10-29 22:22:20 +00:00
|
|
|
IMediaSourceManager mediaSourceManager,
|
2019-01-07 23:27:46 +00:00
|
|
|
IDeviceDiscovery deviceDiscovery,
|
|
|
|
IMediaEncoder mediaEncoder,
|
|
|
|
ISocketFactory socketFactory,
|
2018-09-12 17:26:21 +00:00
|
|
|
INetworkManager networkManager,
|
|
|
|
IUserViewManager userViewManager,
|
|
|
|
ITVSeriesManager tvSeriesManager)
|
2016-10-29 22:22:20 +00:00
|
|
|
{
|
|
|
|
_config = config;
|
|
|
|
_appHost = appHost;
|
|
|
|
_sessionManager = sessionManager;
|
|
|
|
_httpClient = httpClient;
|
|
|
|
_libraryManager = libraryManager;
|
|
|
|
_userManager = userManager;
|
|
|
|
_dlnaManager = dlnaManager;
|
|
|
|
_imageProcessor = imageProcessor;
|
|
|
|
_userDataManager = userDataManager;
|
2018-09-12 17:26:21 +00:00
|
|
|
_localization = localizationManager;
|
2016-10-29 22:22:20 +00:00
|
|
|
_mediaSourceManager = mediaSourceManager;
|
|
|
|
_deviceDiscovery = deviceDiscovery;
|
|
|
|
_mediaEncoder = mediaEncoder;
|
2016-11-04 08:31:05 +00:00
|
|
|
_socketFactory = socketFactory;
|
2016-12-04 21:30:38 +00:00
|
|
|
_networkManager = networkManager;
|
2018-12-13 13:18:25 +00:00
|
|
|
_logger = loggerFactory.CreateLogger("Dlna");
|
2018-09-12 17:26:21 +00:00
|
|
|
|
2019-02-01 16:43:31 +00:00
|
|
|
ContentDirectory = new ContentDirectory.ContentDirectory(
|
|
|
|
dlnaManager,
|
2019-01-07 23:27:46 +00:00
|
|
|
userDataManager,
|
|
|
|
imageProcessor,
|
|
|
|
libraryManager,
|
|
|
|
config,
|
|
|
|
userManager,
|
2020-03-03 22:07:10 +00:00
|
|
|
loggerFactory.CreateLogger<ContentDirectory.ContentDirectory>(),
|
2019-01-07 23:27:46 +00:00
|
|
|
httpClient,
|
|
|
|
localizationManager,
|
|
|
|
mediaSourceManager,
|
2018-09-12 17:26:21 +00:00
|
|
|
userViewManager,
|
2019-01-07 23:27:46 +00:00
|
|
|
mediaEncoder,
|
2018-09-12 17:26:21 +00:00
|
|
|
tvSeriesManager);
|
|
|
|
|
2020-03-03 22:07:10 +00:00
|
|
|
ConnectionManager = new ConnectionManager.ConnectionManager(
|
|
|
|
dlnaManager,
|
|
|
|
config,
|
|
|
|
loggerFactory.CreateLogger<ConnectionManager.ConnectionManager>(),
|
|
|
|
httpClient);
|
2018-09-12 17:26:21 +00:00
|
|
|
|
2020-03-03 22:07:10 +00:00
|
|
|
MediaReceiverRegistrar = new MediaReceiverRegistrar.MediaReceiverRegistrar(
|
|
|
|
loggerFactory.CreateLogger<MediaReceiverRegistrar.MediaReceiverRegistrar>(),
|
|
|
|
httpClient,
|
|
|
|
config);
|
2018-09-12 17:26:21 +00:00
|
|
|
Current = this;
|
2016-10-29 22:22:20 +00:00
|
|
|
}
|
|
|
|
|
2019-01-27 14:40:37 +00:00
|
|
|
public async Task RunAsync()
|
2016-10-29 22:22:20 +00:00
|
|
|
{
|
2019-01-27 14:40:37 +00:00
|
|
|
await ((DlnaManager)_dlnaManager).InitProfilesAsync().ConfigureAwait(false);
|
2016-10-29 22:22:20 +00:00
|
|
|
|
2020-06-09 21:05:22 +00:00
|
|
|
await ReloadComponents().ConfigureAwait(false);
|
2016-10-29 22:22:20 +00:00
|
|
|
|
2020-06-09 21:05:22 +00:00
|
|
|
_config.NamedConfigurationUpdated += OnNamedConfigurationUpdated;
|
|
|
|
}
|
2020-04-29 11:24:01 +00:00
|
|
|
|
2020-06-09 21:05:22 +00:00
|
|
|
private async void OnNamedConfigurationUpdated(object sender, ConfigurationUpdateEventArgs e)
|
2016-10-29 22:22:20 +00:00
|
|
|
{
|
|
|
|
if (string.Equals(e.Key, "dlna", StringComparison.OrdinalIgnoreCase))
|
|
|
|
{
|
2020-06-09 21:05:22 +00:00
|
|
|
await ReloadComponents().ConfigureAwait(false);
|
2016-10-29 22:22:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-09 21:05:22 +00:00
|
|
|
private async Task ReloadComponents()
|
2016-10-29 22:22:20 +00:00
|
|
|
{
|
|
|
|
var options = _config.GetDlnaConfiguration();
|
|
|
|
|
2018-09-12 17:26:21 +00:00
|
|
|
StartSsdpHandler();
|
2016-10-29 22:22:20 +00:00
|
|
|
|
2018-09-12 17:26:21 +00:00
|
|
|
if (options.EnableServer)
|
2016-10-29 22:22:20 +00:00
|
|
|
{
|
2018-09-12 17:26:21 +00:00
|
|
|
await StartDevicePublisher(options).ConfigureAwait(false);
|
2016-10-29 22:22:20 +00:00
|
|
|
}
|
2018-09-12 17:26:21 +00:00
|
|
|
else
|
2016-10-29 22:22:20 +00:00
|
|
|
{
|
2018-09-12 17:26:21 +00:00
|
|
|
DisposeDevicePublisher();
|
2016-10-29 22:22:20 +00:00
|
|
|
}
|
|
|
|
|
2018-09-12 17:26:21 +00:00
|
|
|
if (options.EnablePlayTo)
|
2016-10-29 22:22:20 +00:00
|
|
|
{
|
|
|
|
StartPlayToManager();
|
|
|
|
}
|
2018-09-12 17:26:21 +00:00
|
|
|
else
|
2016-10-29 22:22:20 +00:00
|
|
|
{
|
|
|
|
DisposePlayToManager();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void StartSsdpHandler()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2016-11-14 19:48:01 +00:00
|
|
|
if (_communicationsServer == null)
|
|
|
|
{
|
2019-03-07 16:39:40 +00:00
|
|
|
var enableMultiSocketBinding = OperatingSystem.Id == OperatingSystemId.Windows ||
|
|
|
|
OperatingSystem.Id == OperatingSystemId.Linux;
|
2016-12-05 18:46:38 +00:00
|
|
|
|
2020-06-09 21:05:22 +00:00
|
|
|
_communicationsServer = new SsdpCommunicationsServer(_config, _socketFactory, _networkManager, _logger, enableMultiSocketBinding)
|
2016-11-14 19:48:01 +00:00
|
|
|
{
|
|
|
|
IsShared = true
|
|
|
|
};
|
2016-10-29 22:22:20 +00:00
|
|
|
|
2018-09-12 17:26:21 +00:00
|
|
|
StartDeviceDiscovery(_communicationsServer);
|
|
|
|
}
|
2016-10-29 22:22:20 +00:00
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
2018-12-20 12:11:26 +00:00
|
|
|
_logger.LogError(ex, "Error starting ssdp handlers");
|
2016-10-29 22:22:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void LogMessage(string msg)
|
|
|
|
{
|
2018-12-13 13:18:25 +00:00
|
|
|
_logger.LogDebug(msg);
|
2016-10-29 22:22:20 +00:00
|
|
|
}
|
|
|
|
|
2016-11-14 19:48:01 +00:00
|
|
|
private void StartDeviceDiscovery(ISsdpCommunicationsServer communicationsServer)
|
2016-10-29 22:22:20 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2016-11-14 19:48:01 +00:00
|
|
|
((DeviceDiscovery)_deviceDiscovery).Start(communicationsServer);
|
2016-10-29 22:22:20 +00:00
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
2018-12-20 12:11:26 +00:00
|
|
|
_logger.LogError(ex, "Error starting device discovery");
|
2016-10-29 22:22:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void DisposeDeviceDiscovery()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2018-12-13 13:18:25 +00:00
|
|
|
_logger.LogInformation("Disposing DeviceDiscovery");
|
2016-10-29 22:22:20 +00:00
|
|
|
((DeviceDiscovery)_deviceDiscovery).Dispose();
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
2018-12-20 12:11:26 +00:00
|
|
|
_logger.LogError(ex, "Error stopping device discovery");
|
2016-10-29 22:22:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-09 21:05:22 +00:00
|
|
|
public async Task StartDevicePublisher(Configuration.DlnaOptions options)
|
|
|
|
{
|
|
|
|
if (!options.BlastAliveMessages)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_publisher != null)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
_publisher = new SsdpDevicePublisher(_communicationsServer, _networkManager, OperatingSystem.Name, Environment.OSVersion.VersionString, _config.GetDlnaConfiguration().SendOnlyMatchedHost)
|
|
|
|
{
|
|
|
|
LogFunction = LogMessage,
|
|
|
|
SupportPnpRootDevice = false
|
|
|
|
};
|
|
|
|
|
|
|
|
await RegisterServerEndpoints().ConfigureAwait(false);
|
|
|
|
|
|
|
|
_publisher.StartBroadcastingAliveMessages(TimeSpan.FromSeconds(options.BlastAliveMessageIntervalSeconds));
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
_logger.LogError(ex, "Error registering endpoint");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-29 22:22:20 +00:00
|
|
|
private async Task RegisterServerEndpoints()
|
|
|
|
{
|
2019-03-01 16:12:22 +00:00
|
|
|
var addresses = await _appHost.GetLocalIpAddresses(CancellationToken.None).ConfigureAwait(false);
|
2016-10-29 22:22:20 +00:00
|
|
|
|
2016-11-04 23:57:21 +00:00
|
|
|
var udn = CreateUuid(_appHost.SystemId);
|
|
|
|
|
2016-10-29 22:22:20 +00:00
|
|
|
foreach (var address in addresses)
|
|
|
|
{
|
2019-07-07 19:03:26 +00:00
|
|
|
if (address.AddressFamily == AddressFamily.InterNetworkV6)
|
2019-02-22 12:14:04 +00:00
|
|
|
{
|
2020-04-01 16:50:19 +00:00
|
|
|
// Not supporting IPv6 right now
|
2020-03-24 15:12:06 +00:00
|
|
|
continue;
|
2019-02-22 12:14:04 +00:00
|
|
|
}
|
2016-10-29 22:22:20 +00:00
|
|
|
|
2020-04-28 20:57:39 +00:00
|
|
|
// Limit to LAN addresses only
|
|
|
|
if (!_networkManager.IsAddressInSubnets(address, true, true))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2020-04-29 11:24:01 +00:00
|
|
|
|
2016-10-29 22:22:20 +00:00
|
|
|
var fullService = "urn:schemas-upnp-org:device:MediaServer:1";
|
|
|
|
|
2019-02-02 15:12:16 +00:00
|
|
|
_logger.LogInformation("Registering publisher for {0} on {1}", fullService, address);
|
2016-10-29 22:22:20 +00:00
|
|
|
|
|
|
|
var descriptorUri = "/dlna/" + udn + "/description.xml";
|
2016-11-08 18:44:23 +00:00
|
|
|
var uri = new Uri(_appHost.GetLocalApiUrl(address) + descriptorUri);
|
2016-10-29 22:22:20 +00:00
|
|
|
|
|
|
|
var device = new SsdpRootDevice
|
|
|
|
{
|
2020-04-29 11:24:01 +00:00
|
|
|
CacheLifetime = TimeSpan.FromSeconds(1800), // How long SSDP clients can cache this info.
|
2019-01-07 23:27:46 +00:00
|
|
|
Location = uri, // Must point to the URL that serves your devices UPnP description document.
|
2019-02-22 04:06:49 +00:00
|
|
|
Address = address,
|
|
|
|
SubnetMask = _networkManager.GetLocalIpSubnetMask(address),
|
2018-12-13 09:18:29 +00:00
|
|
|
FriendlyName = "Jellyfin",
|
|
|
|
Manufacturer = "Jellyfin",
|
2018-12-13 19:10:22 +00:00
|
|
|
ModelName = "Jellyfin Server",
|
2016-10-29 22:22:20 +00:00
|
|
|
Uuid = udn
|
2019-01-07 23:27:46 +00:00
|
|
|
// This must be a globally unique value that survives reboots etc. Get from storage or embedded hardware etc.
|
2016-10-29 22:22:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
SetProperies(device, fullService);
|
2020-04-29 11:24:01 +00:00
|
|
|
_publisher.AddDevice(device);
|
2016-10-29 22:22:20 +00:00
|
|
|
|
2019-01-13 19:16:19 +00:00
|
|
|
var embeddedDevices = new[]
|
2016-10-29 22:22:20 +00:00
|
|
|
{
|
|
|
|
"urn:schemas-upnp-org:service:ContentDirectory:1",
|
|
|
|
"urn:schemas-upnp-org:service:ConnectionManager:1",
|
2020-04-29 11:24:01 +00:00
|
|
|
// "urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1"
|
2016-10-29 22:22:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
foreach (var subDevice in embeddedDevices)
|
|
|
|
{
|
|
|
|
var embeddedDevice = new SsdpEmbeddedDevice
|
|
|
|
{
|
|
|
|
FriendlyName = device.FriendlyName,
|
|
|
|
Manufacturer = device.Manufacturer,
|
|
|
|
ModelName = device.ModelName,
|
|
|
|
Uuid = udn
|
2019-01-07 23:27:46 +00:00
|
|
|
// This must be a globally unique value that survives reboots etc. Get from storage or embedded hardware etc.
|
2016-10-29 22:22:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
SetProperies(embeddedDevice, subDevice);
|
|
|
|
device.AddDevice(embeddedDevice);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private string CreateUuid(string text)
|
|
|
|
{
|
2019-01-13 20:46:33 +00:00
|
|
|
if (!Guid.TryParse(text, out var guid))
|
2016-11-04 23:57:21 +00:00
|
|
|
{
|
|
|
|
guid = text.GetMD5();
|
|
|
|
}
|
2020-04-29 11:24:01 +00:00
|
|
|
|
2019-02-28 22:22:57 +00:00
|
|
|
return guid.ToString("N", CultureInfo.InvariantCulture);
|
2016-10-29 22:22:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void SetProperies(SsdpDevice device, string fullDeviceType)
|
|
|
|
{
|
2020-04-29 11:24:01 +00:00
|
|
|
var service = fullDeviceType.Replace("urn:", string.Empty, StringComparison.OrdinalIgnoreCase).Replace(":1", string.Empty, StringComparison.OrdinalIgnoreCase);
|
2016-10-29 22:22:20 +00:00
|
|
|
|
|
|
|
var serviceParts = service.Split(':');
|
|
|
|
|
|
|
|
var deviceTypeNamespace = serviceParts[0].Replace('.', '-');
|
|
|
|
|
|
|
|
device.DeviceTypeNamespace = deviceTypeNamespace;
|
|
|
|
device.DeviceClass = serviceParts[1];
|
|
|
|
device.DeviceType = serviceParts[2];
|
|
|
|
}
|
|
|
|
|
|
|
|
private void StartPlayToManager()
|
|
|
|
{
|
|
|
|
lock (_syncLock)
|
|
|
|
{
|
2018-09-12 17:26:21 +00:00
|
|
|
if (_manager != null)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-10-29 22:22:20 +00:00
|
|
|
try
|
|
|
|
{
|
2020-04-29 11:24:01 +00:00
|
|
|
_manager = new PlayToManager(
|
|
|
|
_logger,
|
2016-10-29 22:22:20 +00:00
|
|
|
_sessionManager,
|
|
|
|
_libraryManager,
|
|
|
|
_userManager,
|
|
|
|
_dlnaManager,
|
|
|
|
_appHost,
|
|
|
|
_imageProcessor,
|
|
|
|
_deviceDiscovery,
|
|
|
|
_httpClient,
|
|
|
|
_config,
|
|
|
|
_userDataManager,
|
|
|
|
_localization,
|
|
|
|
_mediaSourceManager,
|
2019-02-05 08:49:46 +00:00
|
|
|
_mediaEncoder);
|
2016-10-29 22:22:20 +00:00
|
|
|
|
|
|
|
_manager.Start();
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
2018-12-20 12:11:26 +00:00
|
|
|
_logger.LogError(ex, "Error starting PlayTo manager");
|
2016-10-29 22:22:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void DisposePlayToManager()
|
|
|
|
{
|
|
|
|
lock (_syncLock)
|
|
|
|
{
|
|
|
|
if (_manager != null)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2018-12-13 13:18:25 +00:00
|
|
|
_logger.LogInformation("Disposing PlayToManager");
|
2016-10-29 22:22:20 +00:00
|
|
|
_manager.Dispose();
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
2018-12-20 12:11:26 +00:00
|
|
|
_logger.LogError(ex, "Error disposing PlayTo manager");
|
2016-10-29 22:22:20 +00:00
|
|
|
}
|
2020-04-29 11:24:01 +00:00
|
|
|
|
2016-10-29 22:22:20 +00:00
|
|
|
_manager = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-09 21:05:22 +00:00
|
|
|
public void Dispose()
|
|
|
|
{
|
|
|
|
DisposeDevicePublisher();
|
|
|
|
DisposePlayToManager();
|
|
|
|
DisposeDeviceDiscovery();
|
|
|
|
|
|
|
|
if (_communicationsServer != null)
|
|
|
|
{
|
|
|
|
_logger.LogInformation("Disposing SsdpCommunicationsServer");
|
|
|
|
_communicationsServer.Dispose();
|
|
|
|
_communicationsServer = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
ContentDirectory = null;
|
|
|
|
ConnectionManager = null;
|
|
|
|
MediaReceiverRegistrar = null;
|
|
|
|
Current = null;
|
|
|
|
}
|
|
|
|
|
2018-09-12 17:26:21 +00:00
|
|
|
public void DisposeDevicePublisher()
|
2016-10-29 22:22:20 +00:00
|
|
|
{
|
2020-04-29 11:24:01 +00:00
|
|
|
if (_publisher != null)
|
2016-10-29 22:22:20 +00:00
|
|
|
{
|
2018-12-13 13:18:25 +00:00
|
|
|
_logger.LogInformation("Disposing SsdpDevicePublisher");
|
2020-04-29 11:24:01 +00:00
|
|
|
_publisher.Dispose();
|
|
|
|
_publisher = null;
|
2016-10-29 22:22:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|