mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-21 01:26:41 +00:00
update tuner discovery
This commit is contained in:
@@ -2542,6 +2542,60 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
public ProgramInfo Program { get; set; }
|
||||
public CancellationTokenSource CancellationTokenSource { get; set; }
|
||||
}
|
||||
|
||||
public async Task ScanForTunerDeviceChanges(CancellationToken cancellationToken)
|
||||
{
|
||||
foreach (var host in _liveTvManager.TunerHosts)
|
||||
{
|
||||
await ScanForTunerDeviceChanges(host, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ScanForTunerDeviceChanges(ITunerHost host, CancellationToken cancellationToken)
|
||||
{
|
||||
var discoveredDevices = await DiscoverDevices(host, 2000, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var configuredDevices = GetConfiguration().TunerHosts
|
||||
.Where(i => string.Equals(i.Type, host.Type, StringComparison.OrdinalIgnoreCase))
|
||||
.ToList();
|
||||
|
||||
foreach (var device in discoveredDevices)
|
||||
{
|
||||
var configuredDevice = configuredDevices.FirstOrDefault(i => string.Equals(i.DeviceId, device.DeviceId, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (configuredDevice != null)
|
||||
{
|
||||
if (!string.Equals(device.Url, configuredDevice.Url, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_logger.Info("Tuner url has changed from {0} to {1}", configuredDevice.Url, device.Url);
|
||||
|
||||
configuredDevice.Url = device.Url;
|
||||
await _liveTvManager.SaveTunerHost(configuredDevice).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<TunerHostInfo>> DiscoverDevices(ITunerHost host, int discoveryDuationMs, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
var discoveredDevices = await host.DiscoverDevices(discoveryDuationMs, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
foreach (var device in discoveredDevices)
|
||||
{
|
||||
_logger.Info("Discovered tuner device {0} at {1}", host.Name, device.Url);
|
||||
}
|
||||
|
||||
return discoveredDevices;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error discovering tuner devices", ex);
|
||||
|
||||
return new List<TunerHostInfo>();
|
||||
}
|
||||
}
|
||||
}
|
||||
public static class ConfigurationExtension
|
||||
{
|
||||
|
||||
@@ -1180,6 +1180,8 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
{
|
||||
EmbyTV.EmbyTV.Current.CreateRecordingFolders();
|
||||
|
||||
await EmbyTV.EmbyTV.Current.ScanForTunerDeviceChanges(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var numComplete = 0;
|
||||
double progressPerService = _services.Count == 0
|
||||
? 0
|
||||
|
||||
@@ -653,9 +653,9 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
|
||||
public int TunerCount { get; set; }
|
||||
}
|
||||
|
||||
public async Task<List<TunerHostInfo>> DiscoverDevices(int discoveryDurationMs)
|
||||
public async Task<List<TunerHostInfo>> DiscoverDevices(int discoveryDurationMs, CancellationToken cancellationToken)
|
||||
{
|
||||
var cancellationToken = new CancellationTokenSource(discoveryDurationMs).Token;
|
||||
cancellationToken = CancellationTokenSource.CreateLinkedTokenSource(new CancellationTokenSource(discoveryDurationMs).Token, cancellationToken).Token;
|
||||
var list = new List<TunerHostInfo>();
|
||||
|
||||
// Create udp broadcast discovery message
|
||||
|
||||
@@ -177,7 +177,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
public Task<List<TunerHostInfo>> DiscoverDevices(int discoveryDurationMs)
|
||||
public Task<List<TunerHostInfo>> DiscoverDevices(int discoveryDurationMs, CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult(new List<TunerHostInfo>());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user