mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-04-24 14:08:44 -04:00
Updates
This commit is contained in:
parent
1d86084653
commit
93568be3e7
1 changed files with 56 additions and 56 deletions
|
@ -131,69 +131,20 @@ namespace Emby.Dlna.Main
|
||||||
{
|
{
|
||||||
await ((DlnaManager)_dlnaManager).InitProfilesAsync().ConfigureAwait(false);
|
await ((DlnaManager)_dlnaManager).InitProfilesAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
ReloadComponents();
|
await ReloadComponents().ConfigureAwait(false);
|
||||||
|
|
||||||
_config.NamedConfigurationUpdated += _config_NamedConfigurationUpdated;
|
_config.NamedConfigurationUpdated += OnNamedConfigurationUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
private async void OnNamedConfigurationUpdated(object sender, ConfigurationUpdateEventArgs e)
|
||||||
{
|
|
||||||
DisposeDevicePublisher();
|
|
||||||
DisposePlayToManager();
|
|
||||||
DisposeDeviceDiscovery();
|
|
||||||
|
|
||||||
if (_communicationsServer != null)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Disposing SsdpCommunicationsServer");
|
|
||||||
_communicationsServer.Dispose();
|
|
||||||
_communicationsServer = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
ContentDirectory = null;
|
|
||||||
ConnectionManager = null;
|
|
||||||
MediaReceiverRegistrar = null;
|
|
||||||
Current = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _config_NamedConfigurationUpdated(object sender, ConfigurationUpdateEventArgs e)
|
|
||||||
{
|
{
|
||||||
if (string.Equals(e.Key, "dlna", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(e.Key, "dlna", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
ReloadComponents();
|
await ReloadComponents().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void ReloadComponents()
|
private async Task ReloadComponents()
|
||||||
{
|
{
|
||||||
var options = _config.GetDlnaConfiguration();
|
var options = _config.GetDlnaConfiguration();
|
||||||
|
|
||||||
|
@ -227,7 +178,7 @@ namespace Emby.Dlna.Main
|
||||||
var enableMultiSocketBinding = OperatingSystem.Id == OperatingSystemId.Windows ||
|
var enableMultiSocketBinding = OperatingSystem.Id == OperatingSystemId.Windows ||
|
||||||
OperatingSystem.Id == OperatingSystemId.Linux;
|
OperatingSystem.Id == OperatingSystemId.Linux;
|
||||||
|
|
||||||
_communicationsServer = new SsdpCommunicationsServer(_socketFactory, _networkManager, _logger, enableMultiSocketBinding)
|
_communicationsServer = new SsdpCommunicationsServer(_config, _socketFactory, _networkManager, _logger, enableMultiSocketBinding)
|
||||||
{
|
{
|
||||||
IsShared = true
|
IsShared = true
|
||||||
};
|
};
|
||||||
|
@ -271,6 +222,36 @@ namespace Emby.Dlna.Main
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async Task RegisterServerEndpoints()
|
private async Task RegisterServerEndpoints()
|
||||||
{
|
{
|
||||||
var addresses = await _appHost.GetLocalIpAddresses(CancellationToken.None).ConfigureAwait(false);
|
var addresses = await _appHost.GetLocalIpAddresses(CancellationToken.None).ConfigureAwait(false);
|
||||||
|
@ -418,6 +399,25 @@ namespace Emby.Dlna.Main
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
public void DisposeDevicePublisher()
|
public void DisposeDevicePublisher()
|
||||||
{
|
{
|
||||||
if (_publisher != null)
|
if (_publisher != null)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue