Table of Contents

Rendering & Surfaces

The extension renders each feed onto a compositor surface and stops there. Where that surface sits, how big it is, whether it is visible and which screen it is on all belong to the screen configuration and the LayerManager. This page explains the split and how to work with it.

Table of Contents

SurfaceID Is the Only Link

Declaring Surfaces

Moving and Hiding Feeds at Runtime

Render Size

Touch Over Video

Multiple Screens

SurfaceID Is the Only Link

When a player starts, the service launches its pipeline with GLIMAGESINK_SURFACE_ID (and WAYLANDSINK_SURFACE_ID) set to the player's SurfaceID. glimagesink creates an IVI surface with that id, and the LayerManager places it according to the screen configuration.

Question Answered by
Which surface does camera 3 draw to? surfaceID in VideoPlayerConfiguration.json
Where is that surface? locationRectangle in PackageInfo.json
Which layer, which screen? layer and the screenSetup entry it sits under
Does it start visible? visibility.isVisible

If a player is Playing but nothing is on screen, the surface is almost always the reason: it is not declared, it is hidden, or it is behind something.

Declaring Surfaces

Declare one surface per player in the screen configuration, and give your application its own full-screen surface below them on the same layer for its UI:

"surfaceSetup": [
  { "surfaceId": 1001, "appID": "com.example.Background", "layer": "MainLayer",
    "locationRectangle": { "surfaceId": 1001, "x": 0, "y": 0, "width": 1280, "height": 800 },
    "visibility": { "surfaceId": 0, "isVisible": true, "opacity": 1 } },
  { "surfaceId": 1002, "appID": "GMSL_Camera1", "layer": "MainLayer",
    "locationRectangle": { "surfaceId": 1002, "x": 40, "y": 100, "width": 560, "height": 350 },
    "visibility": { "surfaceId": 0, "isVisible": false, "opacity": 1 } }
]

The Video Player page in the Toolkit offers every surface in the saved package as id - appID. There is no "video" role on a surface, so all of them are listed; pick the one you declared for that camera.

The compositor scales each feed to its rectangle. Match the rectangle's aspect ratio to the camera to avoid distortion — the GMSL demos use 560×350 tiles, a 1.6 ratio matching the sensor's 1920×1200.

Moving and Hiding Feeds at Runtime

Use LayerManagerServiceClient from Ahsoka.Services.LayerManager. It acts on the surface, so it never interrupts the video pipeline:

To Call
Show or hide a feed UpdateSurfaceVisibility(new SurfaceVisibility { SurfaceId, IsVisible, Opacity, CommitChanges })
Move or resize a feed UpdateSurfaceLocation(new SurfaceRectangle { SurfaceId, X, Y, Width, Height, CommitChanges })
Move a feed to another screen UpdateSurfaceLayer(new SurfaceLayer { SurfaceId, Layer, ScreenId, CommitChanges })

CommitChanges = false stages a change; the next committed call flushes everything staged. Stage a batch and commit only the last one, and the whole set changes on the same frame:

static void SetSurfacesVisible(LayerManagerServiceClient lm, IList<int> ids, bool visible)
{
    for (int i = 0; i < ids.Count; i++)
        lm.UpdateSurfaceVisibility(new SurfaceVisibility
        {
            SurfaceId = ids[i],
            IsVisible = visible,
            Opacity = visible ? 1.0 : 0.0,
            CommitChanges = i == ids.Count - 1,
        });
}

Two behaviours to plan for:

  • Stopping a feed destroys its surface, and the LayerManager drops any runtime placement with it. The next PlayVideo creates the surface again at its configured rectangle. Re-apply runtime moves after every play.
  • Visibility persists. Hide a surface before stopping its feed, and when the feed is played again the new surface comes back hidden. Show it again once it reports Playing.

The demos use both patterns: tiles are configured start-hidden, played while hidden, and revealed together once every feed reports Playing (with a three-second fallback so a missing camera cannot leave the page blank); and when leaving a page they hide every tile in one commit before stopping them, so the feeds vanish at once rather than one by one.

Render Size

renderWidth / renderHeight on a player, and RenderWidth / RenderHeight on a play request, set the resolution a feed is rendered at before it is handed to the compositor.

Input Render size
GMSL, Analog Not applied. The feed is presented at capture size and the compositor scales it into the surface rectangle.
VCIC Applied. The decoded frame is scaled on the GPU to this size. The request's value wins over the configuration's, and the request's width also picks the stream tier.
File Applied when both values are set. The decoded frame is scaled on the GPU to this size; the request's value wins over the configuration's. Left at 0, the file is presented at its own size and the compositor scales it.

The extension has no way to read a surface's rectangle — it only knows the id — so for VCIC set the render size to the size the surface is shown at. For a file, the cheapest choice is a file encoded at that size in the first place — see Preparing Files. Rendering four 1280×960 streams into small tiles wastes GPU and memory bandwidth and can underflow the display's scanout.

Changing a VCIC tile's size at runtime means doing both halves together: move the surface with the LayerManager, and stop and re-play the feed at the new render size. Expect about a second of black on that tile.

Touch Over Video

A video surface sits above your application's surface and receives the touches over it. A tap on a camera tile never reaches your application. Keep controls in an area no video surface covers — both demos put their buttons in a 90-pixel strip above the tiles for this reason.

Multiple Screens

Which screen a feed appears on is decided entirely by which screenSetup entry its surface is declared under. Moving a camera to a second screen is a configuration change — the player configuration does not change at all — or a runtime UpdateSurfaceLayer with a ScreenId.

Each screen that shows video also needs a surface of its own that covers the rest of the output. Without one, the area around a tile has no owner and shows stale buffer content, which reads as violent flashing. In practice that means one DrawingWindow per screen. The Flex demo does this; see The Demos.

Note

On Pro and Flex, a lone surface on an output can be promoted to direct scanout, and on the secondary display device that output then stops repainting and shows underflow artifacts. Setting WESTON_FORCE_RENDERER=1 for the compositor forces GL composition and avoids it. Prep does not set it on this platform yet.