dxgicapture: reinitialize duplication interface on ERROR_ACCESS_LOST
IDXGIOutputDuplication can become invalid for example when there's desktop switch, resolution change or Windows User Account Control prompt appears on screen.
When that happens, try to re-create the duplication interface for the changed output. Note that in the case of UAC prompt this operation will fail if the GStreamer process doesn't run at LOCAL_SYSTEM privileges. In such situation the source element won't create any frames as long as the output is occupied by UAC screen.
In order to enable UAC access to sufficiently privileged GStreamer processes, call SetThreadDesktop() with the desktop handle that currently receives user input before creating our output duplication.
Can be tested with simple gst-launch-1.0 dxgiscreencapsrc ! videoconvert ! autovideosink
.
To check interaction with UAC open Windows Command Prompt for SYSTEM user like this:
PsExec.exe -i -s cmd.exe
run the pipeline from there and then invoke some UAC prompt (e.g. right click + "Run as administrator" on an executable).
psexec
can be downloaded from Microsoft here: https://docs.microsoft.com/en-us/sysinternals/downloads/psexec