mirror of https://github.com/ErsatzTV/ErsatzTV.git
25 changed files with 6758 additions and 57 deletions
@ -1,45 +1,47 @@ |
|||||||
using System; |
using System.Collections.Generic; |
||||||
using System.Reflection; |
using System.Linq; |
||||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||||
using ErsatzTV.Core.Domain; |
using ErsatzTV.Core.Domain; |
||||||
using ErsatzTV.Core.FFmpeg; |
using ErsatzTV.Core.FFmpeg; |
||||||
using ErsatzTV.Core.Health; |
using ErsatzTV.Core.Health; |
||||||
using ErsatzTV.Core.Health.Checks; |
using ErsatzTV.Core.Health.Checks; |
||||||
using ErsatzTV.Core.Interfaces.Repositories; |
using ErsatzTV.Infrastructure.Data; |
||||||
using LanguageExt; |
using Microsoft.EntityFrameworkCore; |
||||||
|
|
||||||
namespace ErsatzTV.Infrastructure.Health.Checks |
namespace ErsatzTV.Infrastructure.Health.Checks |
||||||
{ |
{ |
||||||
public class VaapiDriverHealthCheck : BaseHealthCheck, IVaapiDriverHealthCheck |
public class VaapiDriverHealthCheck : BaseHealthCheck, IVaapiDriverHealthCheck |
||||||
{ |
{ |
||||||
private readonly IConfigElementRepository _configElementRepository; |
private readonly IDbContextFactory<TvContext> _dbContextFactory; |
||||||
|
|
||||||
public VaapiDriverHealthCheck(IConfigElementRepository configElementRepository) => |
public VaapiDriverHealthCheck(IDbContextFactory<TvContext> dbContextFactory) |
||||||
_configElementRepository = configElementRepository; |
{ |
||||||
|
_dbContextFactory = dbContextFactory; |
||||||
|
} |
||||||
|
|
||||||
protected override string Title => "VAAPI Driver"; |
protected override string Title => "VAAPI Driver"; |
||||||
|
|
||||||
public async Task<HealthCheckResult> Check() |
public async Task<HealthCheckResult> Check() |
||||||
{ |
{ |
||||||
string version = Assembly.GetEntryAssembly()?.GetCustomAttribute<AssemblyInformationalVersionAttribute>() |
await using TvContext dbContext = _dbContextFactory.CreateDbContext(); |
||||||
?.InformationalVersion ?? "unknown"; |
List<FFmpegProfile> profiles = await dbContext.FFmpegProfiles |
||||||
|
.Filter(p => p.HardwareAcceleration == HardwareAccelerationKind.Vaapi) |
||||||
if (!version.Contains("docker", StringComparison.OrdinalIgnoreCase) || |
.ToListAsync(); |
||||||
!version.Contains("vaapi", StringComparison.OrdinalIgnoreCase)) |
|
||||||
{ |
|
||||||
return NotApplicableResult(); |
|
||||||
} |
|
||||||
|
|
||||||
Option<int> maybeVaapiDriver = |
if (profiles.Count == 0) |
||||||
await _configElementRepository.GetValue<int>(ConfigElementKey.FFmpegVaapiDriver); |
|
||||||
var vaapiDriver = (VaapiDriver)await maybeVaapiDriver.IfNoneAsync(0); |
|
||||||
if (vaapiDriver == VaapiDriver.Default) |
|
||||||
{ |
{ |
||||||
return InfoResult( |
return NotApplicableResult(); |
||||||
"Settings > FFmpeg Settings > VAAPI Driver is set to Default; selecting iHD (Gen 8+) or i965 (up to Gen 9) may offer better performance"); |
|
||||||
} |
} |
||||||
|
|
||||||
return OkResult(); |
|
||||||
|
var defaultProfiles = profiles |
||||||
|
.Filter(p => p.VaapiDriver == VaapiDriver.Default) |
||||||
|
.ToList(); |
||||||
|
|
||||||
|
return defaultProfiles.Any() |
||||||
|
? 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") |
||||||
|
: OkResult(); |
||||||
} |
} |
||||||
} |
} |
||||||
} |
} |
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,34 @@ |
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||||
|
|
||||||
|
namespace ErsatzTV.Infrastructure.Migrations |
||||||
|
{ |
||||||
|
public partial class Add_FFmpegProfileVaapiDriverVaapiDevice : Migration |
||||||
|
{ |
||||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||||
|
{ |
||||||
|
migrationBuilder.AddColumn<string>( |
||||||
|
name: "VaapiDevice", |
||||||
|
table: "FFmpegProfile", |
||||||
|
type: "TEXT", |
||||||
|
nullable: true); |
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>( |
||||||
|
name: "VaapiDriver", |
||||||
|
table: "FFmpegProfile", |
||||||
|
type: "INTEGER", |
||||||
|
nullable: false, |
||||||
|
defaultValue: 0); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||||
|
{ |
||||||
|
migrationBuilder.DropColumn( |
||||||
|
name: "VaapiDevice", |
||||||
|
table: "FFmpegProfile"); |
||||||
|
|
||||||
|
migrationBuilder.DropColumn( |
||||||
|
name: "VaapiDriver", |
||||||
|
table: "FFmpegProfile"); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,19 @@ |
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||||
|
|
||||||
|
namespace ErsatzTV.Infrastructure.Migrations |
||||||
|
{ |
||||||
|
public partial class Update_FFmpegProfileVaapiDriverVaapiDevice : Migration |
||||||
|
{ |
||||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||||
|
{ |
||||||
|
migrationBuilder.Sql("UPDATE FFmpegProfile SET VaapiDevice = '/dev/dri/renderD128'"); |
||||||
|
migrationBuilder.Sql( |
||||||
|
"UPDATE FFmpegProfile SET VaapiDriver = (SELECT IFNULL(Value, 0) FROM ConfigElement WHERE Key = 'ffmpeg.vaapi_driver')"); |
||||||
|
migrationBuilder.Sql("DELETE FROM ConfigElement WHERE Key = 'ffmpeg.vaapi_driver'"); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||||
|
{ |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue