Skip to content

Version 1

Overview

The protocol is a TCP protocol on port 46899.

The header packet structure is defined as:

struct HEADER {
   uint32_t size; //Little Endian
   uint8_t opcode;
} header;

For a packet with no body, only the header is sent. In this case, size = 1.

When a body is attached, it has the following format.

struct BODY {
   uint8_t bytes[header.size - 1];
};

The body is a JSON string, encoded using UTF-8. Note the total packet size is max 32KB. Consequently, the maximum body size is 32000 - 1.

Opcode Name Description
0 None Not used
Play 1 Client message to play a video, body is PlayMessage
Pause 2 Client message to pause a video, no body
Resume 3 Client message to resume a video, no body
Stop 4 Client message to stop a video, no body
Seek 5 Client message to seek, body is SeekMessage
PlaybackUpdate 6 Receiver message to notify an updated playback state, body is PlaybackUpdateMessage
VolumeUpdate 7 Receiver message to notify when the volume has changed, body is VolumeUpdateMessage
SetVolume 8 Client message to change volume, body is SetVolumeMessage

Bodies

PlayMessage

export class PlayMessage {
    constructor(
        public container: String, //The MIME type (video/mp4)
        public url: String = null, //The URL to load (optional)
        public content: String = null, //The content to load (i.e. a DASH manifest, optional)
        public time: number = null //The time to start playing in seconds
    ) {}
}

SeekMessage

export class SeekMessage {
    constructor(
        public time: number //The time to seek to in seconds
    ) {}
}

PlaybackUpdateMessage

export class PlaybackUpdateMessage {
    constructor(
        public time: number, //The current time playing in seconds
        public state: number //The playback state
    ) {}
}

The playback state are defined as follows.

Number Name
0 Idle
1 Playing
2 Paused

VolumeUpdateMessage

export class VolumeUpdateMessage {
    constructor(
        public volume: number //The current volume (0-1)
    ) {}
}

SetVolumeMessage

export class SetVolumeMessage {
    constructor(
        public volume: number //The desired volume (0-1)
    ) {}
}