Build ErsatzTV Image / CI image pin matches docker/ci (pull_request) Successful in 5s
Build ErsatzTV Image / Docs update reminder (pull_request) Successful in 8s
Build ErsatzTV Image / decisions.md append-only (pull_request) Successful in 54s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 5m48s
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (pull_request) Successful in 12m49s
Build ErsatzTV Image / Functional E2E (curl contracts) (pull_request) Successful in 14m35s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 18m11s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (pull_request) Successful in 13m23s
Make the ~14 health checks actionable: each check that has a fix now declares
where to go, and the SPA acts on it.
Backend:
- Widen domain HealthCheckLink (string Link) -> (string Target, HealthCheckLinkKind
Kind) with ExternalDoc|AppRoute + factories; only the 4 link-building checks and
the API mapper touched .Link.
- Evolve HealthCheckResponseModel additively (/api/v1 frozen-additive): keep
deprecated string? Link (still populated), add Brief (the BriefMessage the mapper
was silently dropping) and nested Remediation {Kind, Target}. Kind is a mapped
string, not a wire enum.
- Make Mapper.GetStatus total: NotApplicable no longer throws (defensive; handler
still filters it). InternalsVisibleTo(ErsatzTV.Tests) added to unit-test totality.
- Fix 2 stale Blazor route links (media/trash -> /app/trash, search?query ->
/app/search); add AppRoute remediation to actionable checks that had none
(libraries / schedules / ffmpeg-profiles / settings).
SPA:
- DashboardScreen health panel renders remediation: AppRoute -> client-side nav
button, ExternalDoc -> new-tab anchor; detail text truncates with title-hover.
- Remove the dead "Open Classic UI" -> /system/health row from SettingsScreen
(a #91b leftover that just 302'd to /app); update its regression test.
Docs: decisions.md (#164), api-conventions.md (deprecate-in-place DTO evolution),
blazor-route-parity.md (Section 4 correction); v1.json/v1.d.ts/endpoint-index
regenerated.
fixes #164
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
104 lines
3.9 KiB
C#
104 lines
3.9 KiB
C#
using System.Collections.Immutable;
|
|
using ErsatzTV.Core.Domain;
|
|
using ErsatzTV.Core.FFmpeg;
|
|
using ErsatzTV.Core.Health;
|
|
using ErsatzTV.Core.Health.Checks;
|
|
using ErsatzTV.FFmpeg;
|
|
using ErsatzTV.FFmpeg.Capabilities;
|
|
using ErsatzTV.Infrastructure.Data;
|
|
using ErsatzTV.Infrastructure.Extensions;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace ErsatzTV.Infrastructure.Health.Checks;
|
|
|
|
public class VaapiDriverHealthCheck(
|
|
IHardwareCapabilitiesFactory hardwareCapabilitiesFactory,
|
|
IDbContextFactory<TvContext> dbContextFactory)
|
|
: BaseHealthCheck, IVaapiDriverHealthCheck
|
|
{
|
|
public override string Title => "VAAPI Driver";
|
|
|
|
public async Task<HealthCheckResult> Check(CancellationToken cancellationToken)
|
|
{
|
|
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken);
|
|
|
|
List<Channel> channels = await dbContext.Channels
|
|
.AsNoTracking()
|
|
.ToListAsync(cancellationToken);
|
|
|
|
var channelFFmpegProfiles = channels
|
|
.Map(c => c.FFmpegProfileId)
|
|
.ToImmutableHashSet();
|
|
|
|
List<FFmpegProfile> ffmpegProfiles = await dbContext.FFmpegProfiles
|
|
.AsNoTracking()
|
|
.Include(p => p.Resolution)
|
|
.ToListAsync(cancellationToken);
|
|
|
|
var activeFFmpegProfiles = ffmpegProfiles
|
|
.Filter(f => channelFFmpegProfiles.Contains(f.Id))
|
|
.Filter(f => f.HardwareAcceleration is HardwareAccelerationKind.Vaapi)
|
|
.ToList();
|
|
|
|
if (activeFFmpegProfiles.Count == 0)
|
|
{
|
|
return NotApplicableResult();
|
|
}
|
|
|
|
Option<string> maybeFFmpegPath =
|
|
await dbContext.ConfigElements.GetValue<string>(ConfigElementKey.FFmpegPath, cancellationToken);
|
|
if (maybeFFmpegPath.IsNone)
|
|
{
|
|
return NotApplicableResult();
|
|
}
|
|
|
|
foreach (string ffmpegPath in maybeFFmpegPath)
|
|
{
|
|
IFFmpegCapabilities ffmpegCapabilities =
|
|
await hardwareCapabilitiesFactory.GetFFmpegCapabilities(ffmpegPath, cancellationToken);
|
|
foreach (FFmpegProfile profile in activeFFmpegProfiles)
|
|
{
|
|
Option<string> vaapiDriver = VaapiDriverName(profile.VaapiDriver);
|
|
|
|
IHardwareCapabilities capabilities = await hardwareCapabilitiesFactory.GetHardwareCapabilities(
|
|
ffmpegCapabilities,
|
|
ffmpegPath,
|
|
HardwareAccelerationMode.Vaapi,
|
|
profile.VaapiDisplay,
|
|
vaapiDriver,
|
|
profile.VaapiDevice
|
|
);
|
|
|
|
if (capabilities is VaapiHardwareCapabilities { EntrypointCount: 0 } or NoHardwareCapabilities)
|
|
{
|
|
return FailResult(
|
|
$"FFmpeg Profile {profile.Name} is using device and driver combination ({profile.VaapiDevice} and {profile.VaapiDriver}) that reports no capabilities. Hardware Acceleration WILL NOT WORK as configured.",
|
|
"Hardware acceleration WILL NOT WORK...",
|
|
HealthCheckLink.AppRoute("/app/ffmpeg-profiles"));
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
var defaultProfiles = activeFFmpegProfiles
|
|
.Filter(p => p.VaapiDriver == VaapiDriver.Default)
|
|
.ToList();
|
|
|
|
return defaultProfiles.Count != 0
|
|
? InfoResult(
|
|
$"{defaultProfiles.Count} FFmpeg Profile{(defaultProfiles.Count > 1 ? "s are" : " is")} set to use Default VAAPI Driver; selecting iHD (Gen 8+) or i965 (up to Gen 9) may offer better performance with Intel iGPU",
|
|
"Default VAAPI driver is not optimal")
|
|
: OkResult();
|
|
}
|
|
|
|
private static Option<string> VaapiDriverName(VaapiDriver driver) =>
|
|
driver switch
|
|
{
|
|
VaapiDriver.i965 => "i965",
|
|
VaapiDriver.iHD => "iHD",
|
|
VaapiDriver.RadeonSI => "radeonsi",
|
|
VaapiDriver.Nouveau => "nouveau",
|
|
_ => Option<string>.None
|
|
};
|
|
}
|