Skip to content

VideoChannel

UnknownSKL edited this page Jul 31, 2021 · 9 revisions

The Video channel only receives data and does not send data to this channel.

Packet format

Total length: 20-?? bytes

Name Type Description
Frame ID UInt32 (4bytes) Video Frame ID
Timestamp UInt32 (4bytes) Timestamp of the video frame
Frame size UInt32 (4bytes) Length of the frame
Frame Offset UInt32 (4bytes) Frame Offset
Server Data Key UInt32 (4bytes) Need to be saved for sending video confirmation packets back via the input channel
Frame Data Bytes (? bytes) Rest of the packet is the Video frame data

Javascript example

The example code below shows how the data is read in javascript. The first parameter in getUint32 is the offset. From byte 20 the video frame data can be read. You can send the data right into a Mediasource() buffer to render. All frames must be rendered in order or else corruption will happen or the stream can stop working.

var messageBuffer = new DataView(eventData.data);

var frameId = messageBuffer.getUint32(0, true)
var timestamp = (messageBuffer.getUint32(4, true)/10)
var frameSize = messageBuffer.getUint32(8, true)
var frameOffset = messageBuffer.getUint32(12, true)
var serverDataKey = messageBuffer.getUint32(16, true)

var offset = 20
var frameData = new Uint8Array(eventData.data, offset)