room
Room websocket: presence, chat, webcam/mic binary fanout, resolution negotiation, and input assignment.
Room websocket: presence, chat, webcam/mic binary fanout, resolution negotiation, and input assignment.
Binary wire format:
[0..7] 8-byte ASCII publicId of sender
[8] 0x01 video frame / 0x02 audio frame / 0x03 video config / 0x04 pcm
[9..] payload; for a video frame, [9] is 0x01 on a keyframeThe publicId indirection keeps real tokens out of the media byte stream. It
is a per-connection id (connection_info["public_id"] below), regenerated
on every reconnect and sent to the room over state_update as mediaId;
that is distinct from a seat's persistent public_id in session.py, which
state_update sends as publicId and which survives reconnects for the
seat's whole life.
attributelog= logging.getLogger(__name__)attributerouter= APIRouter()attributeMAX_TEXT_FRAME_BYTES= 8 * 1024attributeCHAT_COOLDOWN_SECONDS= 1.0attributeMAX_MEDIA_FRAME_BYTES= 1024 * 1024Ceiling on one binary media frame; anything larger is dropped, not relayed.
attributeMEDIA_ID_BYTES= session.PUBLIC_ID_HEX_CHARSWidth of the sender-id prefix on a binary media frame.
Every offset in the wire format is measured from it, and both ends read the
frame type from the byte straight after it, so it has to stay exactly as wide
as the ids session.new_public_id mints. A connection whose id does not match
is refused rather than left stamping frames a recipient would misparse.
attributeMEDIA_HEADER_BYTES= MEDIA_ID_BYTES + 1Sender id plus the frame-type byte: the shortest frame that can carry one.
attributeMAX_MESSAGE_ID_CHARS= 64Ceiling on a replyTo id, which is relayed to the room as the client sent it.
attributeMAX_RESOLUTION_PIXELS= 16384Ceiling on a self-reported client width or height, well past any real display.