Package limn.video

Class VideoSurfaces

java.lang.Object
limn.video.VideoSurfaces

public final class VideoSurfaces extends Object
Video-surface facade + install-at-startup SPI (the same inversion as the image, audio and 3D facades): a neutral entry point here, the device implementation installed by the backend. One provider, unlike Videos's ordered list of decoders: a surface is created by whichever backend owns the window being rendered, and there is nothing for a second one to claim.

 VideoSurface surface = VideoSurfaces.create();   // once, while the widget is alive
 // ... per picture, inside the frame that draws it:
 surface.upload(frame);
 canvas.drawSurface(surface, x, y, width, height);
 

create() must run on the UI thread inside a frame, because the surface belongs to the GL context of the window rendering it. Installation and the availability probe are safe from any thread.

  • Method Details

    • install

      public static void install(VideoSurfaces.Provider newProvider)
      Installs the backend's provider. Called once at startup, before any surface is created.
    • uninstall

      public static void uninstall(VideoSurfaces.Provider expected)
      Removes the provider if it is still expected, so a late teardown cannot clear a newer one.
    • isAvailable

      public static boolean isAvailable()
      Returns:
      whether a backend provider is installed (false when running headless)
    • create

      public static VideoSurface create()
      Creates a surface for the window being rendered. The caller owns it and must release it: a surface holds a picture's worth of device memory, and a stream that opens one per playback and never releases it leaks that much per playback. Release it from inside a frame with VideoSurface.dispose(), or from a widget being detached with Scene.disposeLater(limn.graphics.GpuSurface), which defers it to one.
      Throws:
      IllegalStateException - if no backend provider is installed, if the calling thread is not the UI thread, or if no frame is being rendered