public XvfbFileScreenshotSource(File path) {
    xvfbInterface = JnaLibraryLoader.getXvfbInterface();

    interfacePointer = xvfbInterface.xvfb_interface_init(path.getAbsolutePath());

    if (interfacePointer == null) {
      throw new IllegalStateException("Could not create xvfb interface");
    }

    doStartupSanityChecks();
  }
  @Override
  public int applyScreenshot(Pointer encoderContext) throws MissingFrameException {

    EncoderInterface encoder = JnaLibraryLoader.getEncoder();
    Pointer screenshotData = xvfbInterface.xvfb_interface_getScreenshot(interfacePointer);

    if (screenshotData == null) {
      throw new MissingFrameException(
          "Could not fetch screenshot data - result was a null pointer!");
    }
    return encoder.convert_frame(encoderContext, screenshotData);
  }