37 lines
838 B
C#
37 lines
838 B
C#
using Serilog;
|
|
|
|
namespace Automata.Screen;
|
|
|
|
public class FramePipelineService : IDisposable
|
|
{
|
|
public FramePipeline Pipeline { get; }
|
|
public IScreenCapture Backend { get; }
|
|
|
|
public FramePipelineService()
|
|
{
|
|
Backend = CreateBackend();
|
|
Pipeline = new FramePipeline(Backend);
|
|
}
|
|
|
|
private static IScreenCapture CreateBackend()
|
|
{
|
|
try
|
|
{
|
|
var dxgi = new DesktopDuplication();
|
|
Log.Information("Screen capture: DXGI Desktop Duplication");
|
|
return dxgi;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.Warning(ex, "DXGI unavailable, falling back to GDI");
|
|
}
|
|
|
|
Log.Information("Screen capture: GDI (CopyFromScreen)");
|
|
return new GdiCapture();
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
Pipeline.Dispose();
|
|
}
|
|
}
|