2.4. Data Service¶
2.4.1. Initialization¶
After a Connecting Client completes signaling, the Data Service has been created. This connection has five logical data-channel streams plus, when audio is enabled, one or more RTP audio media tracks negotiated in the same SDP (see Audio). Each data channel is identified on the wire by a numeric stream id that is the same on the server and the client.
Stream id |
Label |
Reliable |
Ordered |
Two-way |
Description |
|---|---|---|---|---|---|
20 |
|
No |
No |
No |
Video stream from server to client (parsed as AVC/HEVC Annex-B). |
40 |
|
No |
No |
No |
Per-frame video metadata; framed payloads. |
80 |
|
Yes |
Yes |
No |
Geometry streaming to client; framed payloads with the parser described in Geometry Payload. |
100 |
|
Yes |
Yes |
Yes |
Reliable commands and messages, including all |
120 |
|
No |
No |
Yes |
Unreliable, time-sensitive messages (per-frame poses, input states). |
The labels above must match exactly across implementations; the numeric ids are conventional but recommended. Audio is carried as WebRTC media tracks rather than a data channel; see Audio for the codec, multi-party fan-out and source identification.
The video stream can be configured as H.264 or HEVC; see Video.
When initial signaling is complete for this Client, the Server sends the Setup Command to the Client on the reliable channel (id 100).
Definitions
A server session starts when a server first initializes into its running state, and continues until the Server stops it. A client-server session starts when a client first connects to a specific server address, and continues until either the Client or the Server decides it is finished. This may include multiple network sessions, for example in the case of network outages or connection being paused by either party. The lifetime of a client-server session is a subset of the server session. A uid is an unsigned 64-bit number that is unique for a specific Server Session. uid’s are shared between the server and all of its clients. A uid need not be unique for different servers connected to the same client.
2.4.2. Command packets (server-to-client)¶
All packets on the reliable channel from server to client are commands. Each command begins with a one-byte CommandPayloadType discriminator and is followed by the fixed body of the command struct, then any appended variable-length data. The full command catalogue is in Commands from Server to Client.
bytes |
type |
description |
|---|---|---|
1 |
CommandPayloadType |
Discriminator (see below). |
sizeof(struct)-1 |
command body |
Packed, 1-byte aligned, little-endian. |
0+ |
appended data |
Optional, command-specific (e.g. uid lists) |
2.4.3. Message packets (client-to-server)¶
All packets sent by the client over the Data Service share a common 9-byte ClientMessage header. The Handshake (described below) is the only client message sent over the signaling WebSocket; every other client message is sent over the reliable channel (id 100) or the unreliable channel (id 120).
bytes |
type |
description |
|---|---|---|
1 |
ClientMessagePayloadType |
Discriminator (see below). |
8 |
int64 |
|
0+ |
message body |
Packed, 1-byte aligned, little-endian |
0+ |
appended data |
Optional, message-specific. |
The full client-to-server message catalogue is in Messages from Client to Server.
2.4.4. Setup Command¶
The Setup Command is the first command sent by the server, immediately after the signaling exchange completes. It tells the client how to configure its video decoder and audio path, what time-base the server is using, and which background to render. Its total size is 171 bytes (static_assert(sizeof(SetupCommand) == 171); reference: teleport::core::SetupCommand).
Bytes |
Type |
Description |
|---|---|---|
1 |
CommandPayloadType |
|
4 |
uint32 |
|
4 |
uint32 |
|
4 |
int32 |
|
4 |
uint32 |
|
8 |
uint64 |
|
89 |
VideoConfig |
|
17 |
AudioConfig |
|
4 |
float |
|
1 |
AxesStandard |
|
1 |
uint8 |
|
1 |
uint8 (bool) |
|
8 |
int64 |
|
1 |
BackgroundMode |
|
16 |
vec4 |
|
8 |
uid |
|
2.4.4.1. VideoConfig¶
89 bytes (static_assert(sizeof(VideoConfig) == 89); reference: avs::VideoConfig). Lighting cubemap layout is not in VideoConfig – it is sent later via the SetupLighting command (see Commands from Server to Client).
Bytes |
Type |
Description |
|---|---|---|
4 |
uint32 |
|
4 |
uint32 |
|
4 |
uint32 |
|
4 |
uint32 |
|
4 |
uint32 |
|
4 |
uint32 |
|
4 |
float |
|
4 |
float |
|
4 |
uint32 |
|
4 |
uint32 |
|
4 |
int32 |
|
4 |
int32 |
|
4 |
uint32 |
|
4 |
uint32 |
|
4 |
uint32 |
|
4 |
uint32 |
|
4 |
int32 |
|
4 |
int32 |
|
4 |
int32 |
|
4 |
avs::VideoCodec |
|
4 |
int32 |
|
4 |
int32 |
|
4 |
int32 |
|
2.4.5. Handshake¶
After receiving the Setup Command, the client sends a Handshake message back to the server. In the reference implementation this single message is sent as a binary WebSocket frame over the signaling connection (see DiscoveryService::SendBinary); all other client messages travel over the Data Service.
The Handshake is variable-size: it carries the fixed body below followed by resourceCount avs::uid entries listing the resources the client already has cached. Total fixed body size: 58 bytes (static_assert(sizeof(Handshake) == 58); reference: teleport::core::Handshake).
It is a ClientMessage and therefore begins with the standard 9-byte header.
Bytes |
Type |
Description |
|---|---|---|
1 |
ClientMessagePayloadType |
|
8 |
int64 |
|
4 |
uint32 |
|
4 |
uint32 |
|
4 |
float |
|
4 |
float |
|
4 |
float |
|
4 |
uint32 |
|
4 |
uint32 |
|
1 |
AxesStandard |
|
1 |
uint8 |
|
1 |
bool |
|
8 |
uint64 |
|
4 |
uint32 |
|
4 |
int32 |
|
2 |
RenderingFeatures |
|
8 * N |
uid[] |
Cached resource uids. |
When the server receives the Handshake, it starts streaming data and sends an AcknowledgeHandshake command on the reliable channel (id 100):
Bytes |
Type |
Description |
|---|---|---|
1 |
CommandPayloadType |
|
8 |
size_t (uint64) |
|
8 * N |
uid[] |
uids of nodes the client should expect to be streamed. |
(Reference: teleport::core::AcknowledgeHandshakeCommand.)
Once the Client has received the AcknowledgeHandshake, initialization is complete and the client enters the main continuous Update mode.
2.4.6. Update¶
- 2.4.6.1. Commands from Server to Client
- 2.4.6.2. Messages from Client to Server
- 2.4.6.2.1. Common header
- 2.4.6.2.2. DisplayInfo (id = 8)
- 2.4.6.2.3. ControllerPoses (id = 4)
- 2.4.6.2.4. ReceivedResources (id = 3)
- 2.4.6.2.5. NodeStatus (id = 2)
- 2.4.6.2.6. ResourceLost (id = 5)
- 2.4.6.2.7. InputStates (id = 6)
- 2.4.6.2.8. InputEvents (id = 7)
- 2.4.6.2.9. KeyframeRequest (id = 9)
- 2.4.6.2.10. PongForLatency (id = 10)
- 2.4.6.2.11. Acknowledgement (id = 12)
- 2.4.6.2.12. OrthogonalAcknowledgement (id = 11)