screenshots
Thumbnails of running sessions for the launcher's session cards.
A thumbnail is the desktop a session's container draws, asked of its Selkies
at /<session id>/api/screenshot (a PNG with the cursor drawn in), scaled
to WIDTH pixels across and handed to the client as a JPEG data URI inside
JSON, so it travels the encrypted lane and between nodes like any other
answer. The container is asked with the session's basic credentials, and in
a room, where Selkies runs in its secure mode, with the room's controller
token as ?token= as well: the master token is taken on the Authorization
header alone, which the basic login in front already owns.
One capture serves every page that asks within FRESH_SECONDS, and pages
asking at once share the capture under way. A container that gives none, as
one without pixelflux screenshots or one whose desktop is not up yet, is not
asked again for RETRY_SECONDS. A page the user has just landed on asks
for a fresh capture, which is taken now unless one is under way: a
screenshot reads the frame back from the GPU, so it is taken when someone is
looking, and the launcher asks sparingly otherwise.
attributelogger= logging.getLogger(__name__)attributeWIDTH= 640attributeFRESH_SECONDS= 4.0attributeRETRY_SECONDS= 20.0attributeQUALITY= 72attributeTIMEOUT= httpx.Timeout(6.0, connect=2.0)func_credentials(session) -> tuple[dict[str, str], dict[str, str]]Return the headers and query that let this server into a session's container API.
paramsessiondict[str, Any]Returns
tuple[dict[str, str], dict[str, str]]func_shrink(png) -> dict[str, Any]Scale a PNG to WIDTH across and return it as a JPEG data URI with its size.
parampngbytesReturns
dict[str, typing.Any]func_capture(session_id, session) -> dict[str, Any] | NoneAsk the session's container for a screenshot and shrink it, or return None when it gives none.
paramsession_idstrparamsessiondict[str, Any]Returns
dict[str, typing.Any] | Nonefunc_prune() -> NoneDrop what is kept for sessions that are gone.
Returns
Nonefuncthumbnail(session_id, session, fresh=False) -> dict[str, Any]Return a session's thumbnail, {"image", "width", "height", "taken_at"}.
paramsession_idstrThe session.
paramsessiondict[str, Any]Its record, with the container's address and credentials.
paramfreshbool= FalseTake a new capture rather than answer with a recent one.
Returns
dict[str, typing.Any]