Files
ersatztv/ErsatzTV/Pages/Troubleshooting.razor
T
Jason DoveandGitHub 0489741123 add videotoolbox capabilities (#2239)
* implement videotoolbox hardware capabilities

* add videotoolbox troubleshooting info

* update changelog
2025-08-02 17:16:24 +00:00

149 lines
6.1 KiB
Plaintext

@page "/system/troubleshooting"
@using System.Runtime.InteropServices
@using System.Text.Json
@using System.Text.Json.Serialization
@using ErsatzTV.Application.Troubleshooting
@using ErsatzTV.Application.Troubleshooting.Queries
@implements IDisposable
@inject IMediator Mediator
@inject IJSRuntime JsRuntime
<MudForm>
<div class="d-flex flex-column" style="height: 100vh; overflow-x: auto">
<MudContainer MaxWidth="MaxWidth.ExtraLarge" Class="pt-8">
<MudText Typo="Typo.h5" Class="mb-2">Playback</MudText>
<MudDivider Class="mb-6"/>
<div class="mb-6">
<MudLink Href="system/troubleshooting/playback">Playback Troubleshooting</MudLink>
</div>
<MudText Typo="Typo.h5" Class="mt-10 mb-2">General</MudText>
<MudDivider Class="mb-6"/>
<MudExpansionPanel Class="mb-6">
<div class="overflow-y-scroll" style="max-height: 500px">
<pre>
<code @ref="_troubleshootingView">@_troubleshootingInfo</code>
</pre>
</div>
<MudButton Variant="Variant.Filled" Color="Color.Primary" Class="mt-4" OnClick="() => CopyToClipboard(_troubleshootingView)">
Copy
</MudButton>
</MudExpansionPanel>
@if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
<MudText Typo="Typo.h5" Class="mt-10 mb-2">VideoToolbox Capabilities</MudText>
<MudDivider Class="mb-6"/>
<MudExpansionPanel Class="mb-6">
<div class="overflow-y-scroll" style="max-height: 500px">
<pre>
<code @ref="_videoToolboxView">@_videoToolboxCapabilities</code>
</pre>
</div>
<MudButton Variant="Variant.Filled" Color="Color.Primary" Class="mt-4" OnClick="() => CopyToClipboard(_videoToolboxView)">
Copy
</MudButton>
</MudExpansionPanel>
}
else
{
<MudText Typo="Typo.h5" Class="mt-10 mb-2">NVIDIA Capabilities</MudText>
<MudDivider Class="mb-6"/>
<MudExpansionPanel Class="mb-6">
<div class="overflow-y-scroll" style="max-height: 500px">
<pre>
<code @ref="_nvidiaView">@_nvidiaCapabilities</code>
</pre>
</div>
<MudButton Variant="Variant.Filled" Color="Color.Primary" Class="mt-4" OnClick="() => CopyToClipboard(_nvidiaView)">
Copy
</MudButton>
</MudExpansionPanel>
<MudText Typo="Typo.h5" Class="mt-10 mb-2">QSV Capabilities</MudText>
<MudDivider Class="mb-6"/>
<MudExpansionPanel Class="mb-6">
<div class="overflow-y-scroll" style="max-height: 500px">
<pre>
<code @ref="_qsvView">@_qsvCapabilities</code>
</pre>
</div>
<MudButton Variant="Variant.Filled" Color="Color.Primary" Class="mt-4" OnClick="() => CopyToClipboard(_qsvView)">
Copy
</MudButton>
</MudExpansionPanel>
}
@if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
<MudText Typo="Typo.h5" Class="mt-10 mb-2">VAAPI Capabilities</MudText>
<MudDivider Class="mb-6"/>
<MudExpansionPanel Class="mb-6">
<div class="overflow-y-scroll" style="max-height: 500px">
<pre>
<code @ref="_vaapiView">@_vaapiCapabilities</code>
</pre>
</div>
<MudButton Variant="Variant.Filled" Color="Color.Primary" Class="mt-4" OnClick="() => CopyToClipboard(_vaapiView)">
Copy
</MudButton>
</MudExpansionPanel>
}
</MudContainer>
</div>
</MudForm>
@code {
private readonly CancellationTokenSource _cts = new();
private string _troubleshootingInfo;
private string _nvidiaCapabilities;
private string _qsvCapabilities;
private string _vaapiCapabilities;
private string _videoToolboxCapabilities;
private ElementReference _troubleshootingView;
private ElementReference _nvidiaView;
private ElementReference _qsvView;
private ElementReference _vaapiView;
private ElementReference _videoToolboxView;
public void Dispose()
{
_cts.Cancel();
_cts.Dispose();
}
protected override async Task OnParametersSetAsync()
{
try
{
TroubleshootingInfo info = await Mediator.Send(new GetTroubleshootingInfo(), _cts.Token);
_troubleshootingInfo = JsonSerializer.Serialize(
new
{
info.Version,
Environment = info.Environment.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value),
info.Cpus,
info.VideoControllers,
info.Health,
info.FFmpegSettings,
info.Channels,
info.FFmpegProfiles
},
new JsonSerializerOptions
{
Converters = { new JsonStringEnumConverter() },
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
WriteIndented = true
});
_nvidiaCapabilities = info.NvidiaCapabilities;
_qsvCapabilities = info.QsvCapabilities;
_vaapiCapabilities = info.VaapiCapabilities;
_videoToolboxCapabilities = info.VideoToolboxCapabilities;
}
catch (Exception ex)
{
_troubleshootingInfo = ex.ToString();
}
}
private async Task CopyToClipboard(ElementReference view) => await JsRuntime.InvokeVoidAsync("clipboardCopy.copyText", view);
}