mirror of https://github.com/ErsatzTV/ErsatzTV.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
2.9 KiB
62 lines
2.9 KiB
using System.Threading; |
|
using System.Threading.Tasks; |
|
using ErsatzTV.Core.Domain; |
|
using ErsatzTV.Core.Interfaces.Repositories; |
|
using LanguageExt; |
|
using MediatR; |
|
|
|
namespace ErsatzTV.Application.FFmpegProfiles.Queries |
|
{ |
|
public class GetFFmpegSettingsHandler : IRequestHandler<GetFFmpegSettings, FFmpegSettingsViewModel> |
|
{ |
|
private readonly IConfigElementRepository _configElementRepository; |
|
|
|
public GetFFmpegSettingsHandler(IConfigElementRepository configElementRepository) => |
|
_configElementRepository = configElementRepository; |
|
|
|
public async Task<FFmpegSettingsViewModel> Handle( |
|
GetFFmpegSettings request, |
|
CancellationToken cancellationToken) |
|
{ |
|
Option<string> ffmpegPath = await _configElementRepository.GetValue<string>(ConfigElementKey.FFmpegPath); |
|
Option<string> ffprobePath = await _configElementRepository.GetValue<string>(ConfigElementKey.FFprobePath); |
|
Option<int> defaultFFmpegProfileId = |
|
await _configElementRepository.GetValue<int>(ConfigElementKey.FFmpegDefaultProfileId); |
|
Option<bool> saveReports = |
|
await _configElementRepository.GetValue<bool>(ConfigElementKey.FFmpegSaveReports); |
|
Option<string> preferredLanguageCode = |
|
await _configElementRepository.GetValue<string>(ConfigElementKey.FFmpegPreferredLanguageCode); |
|
Option<int> watermark = |
|
await _configElementRepository.GetValue<int>(ConfigElementKey.FFmpegGlobalWatermarkId); |
|
Option<int> fallbackFiller = |
|
await _configElementRepository.GetValue<int>(ConfigElementKey.FFmpegGlobalFallbackFillerId); |
|
Option<int> hlsSegmenterIdleTimeout = |
|
await _configElementRepository.GetValue<int>(ConfigElementKey.FFmpegSegmenterTimeout); |
|
Option<int> workAheadSegmenterLimit = |
|
await _configElementRepository.GetValue<int>(ConfigElementKey.FFmpegWorkAheadSegmenters); |
|
|
|
var result = new FFmpegSettingsViewModel |
|
{ |
|
FFmpegPath = await ffmpegPath.IfNoneAsync(string.Empty), |
|
FFprobePath = await ffprobePath.IfNoneAsync(string.Empty), |
|
DefaultFFmpegProfileId = await defaultFFmpegProfileId.IfNoneAsync(0), |
|
SaveReports = await saveReports.IfNoneAsync(false), |
|
PreferredLanguageCode = await preferredLanguageCode.IfNoneAsync("eng"), |
|
HlsSegmenterIdleTimeout = await hlsSegmenterIdleTimeout.IfNoneAsync(60), |
|
WorkAheadSegmenterLimit = await workAheadSegmenterLimit.IfNoneAsync(1), |
|
}; |
|
|
|
foreach (int watermarkId in watermark) |
|
{ |
|
result.GlobalWatermarkId = watermarkId; |
|
} |
|
|
|
foreach (int fallbackFillerId in fallbackFiller) |
|
{ |
|
result.GlobalFallbackFillerId = fallbackFillerId; |
|
} |
|
|
|
return result; |
|
} |
|
} |
|
}
|
|
|