wire

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package wire defines Planck protocol v1: control messages carried as length-prefixed frames on the QUIC control stream, and the plaintext layouts of media datagrams carried over AEAD-sealed UDP.

Index

Constants

View Source
const (
	// FeatureLANDatagram, from a client, says its route to the host is a
	// LAN interface with a 1500-byte MTU: the host may then use
	// MaxLANDatagram for the session.
	FeatureLANDatagram uint32 = 1 << 0
	// FeatureInputDedup, from a host, says it drops input events whose Seq
	// it has seen, so the client may send redundant copies.
	FeatureInputDedup uint32 = 1 << 1
	// FeatureCapabilities says the peer sends and reads Capabilities and
	// Profile. Both Hellos must carry it before either message is sent.
	FeatureCapabilities uint32 = 1 << 2
	// FeatureResize, from a host, says it takes Resize: a stream on a
	// virtual display follows the client's window size.
	FeatureResize uint32 = 1 << 3
	// FeaturePeerState says the peer reads PeerState. A peer sends it only
	// to a peer whose Hello carries this bit.
	FeaturePeerState uint32 = 1 << 4
	// FeatureMic, from a host, says it accepts the client's microphone as
	// FlowMic audio datagrams.
	FeatureMic uint32 = 1 << 5
	// FeatureClipboard says the peer reads clipboard streams.
	FeatureClipboard uint32 = 1 << 6
	// FeatureHostStats, from a client, says it reads HostStats.
	FeatureHostStats uint32 = 1 << 8
	// FeatureCursorState, from a client, says it reads CursorState.
	FeatureCursorState uint32 = 1 << 9
	// FeatureStreamSwitch, from a client, says it follows a stream whose
	// codec, format or size changes mid-session: the host announces each
	// new stream in a Stream message and tags its frames with the epoch.
	FeatureStreamSwitch uint32 = 1 << 10
	// FeatureResizeDisplay, from a host, says its Resize handler reads
	// Resize.Display. A client sends Display only to such a host: an
	// older one refuses the longer message.
	FeatureResizeDisplay uint32 = 1 << 11
	// FeatureCursorShape, from a client, says it reads CursorShape.
	FeatureCursorShape uint32 = 1 << 12
	// FeatureSwitchDisplay, from a host, says it takes SwitchDisplay: it
	// moves the stream to another of its displays and announces it in a
	// Stream message.
	FeatureSwitchDisplay uint32 = 1 << 13
	// FeatureRefInvalidate, offered by both ends, says a client that loses
	// a frame sends RefInvalidate instead of PLI and skips frames up to
	// the host's next Recovery frame (or keyframe), and the host answers
	// it so; neither end then turns a lost frame into a keyframe request.
	FeatureRefInvalidate uint32 = 1 << 14
	// FeatureRefInvalidateThrough, from a host, says it reads
	// RefInvalidate.Through. A client sends Through only to such a host:
	// an older one refuses the longer message.
	FeatureRefInvalidateThrough uint32 = 1 << 15
	// FeatureDisplayPhase, from a host, says it reads DisplayPhase.
	FeatureDisplayPhase uint32 = 1 << 16
)

Hello feature bits. A peer that does not know a bit ignores it, so either side may set one without breaking an older peer.

View Source
const (
	KindVideo    byte = 0x11
	KindAudio    byte = 0x12
	KindInput    byte = 0x13
	KindRumble   byte = 0x14
	KindPing     byte = 0x15
	KindPong     byte = 0x16
	KindFeedback byte = 0x17
)

Media datagram kinds, carried in the first plaintext byte.

View Source
const (
	MaxSlices = 16
	MaxBlocks = 32
	MaxShards = 255
)

Video shard limits. A frame has up to MaxSlices codec slices; a slice is split into up to MaxBlocks Reed-Solomon blocks; a block has at most MaxShards data plus parity shards.

View Source
const (
	PingLen = 16
	PongLen = 32
)
View Source
const AudioHeaderLen = 16

AudioHeaderLen precedes one audio packet.

View Source
const ClipHeaderLen = 1 + 16 + 32 + 4

ClipHeaderLen is the frame header in front of each item's bytes.

View Source
const CursorCacheSize = 32

CursorCacheSize is how many shapes the host and the client each keep, the least recently used going first. Both see the same shapes in the same order, so a shape the host refers to by ID alone is still in the client's cache.

View Source
const FeatureCalibration uint32 = 1 << 17

FeatureCalibration, from a host, says it serves calibration: it answers ProbeRequest with a train of probe datagrams, and streams its synthetic pattern, not its screen, to a client whose capabilities ask for a calibration stream. A client sends ProbeRequest only to such a host.

View Source
const FeedbackLen = 28

FeedbackLen is the fixed size of a feedback datagram.

View Source
const InputLen = 32

InputLen is the fixed size of an input datagram.

View Source
const KindProbe byte = 0x18

KindProbe is a probe datagram of a calibration train, host to client.

View Source
const MaxCapsJSON = 48 << 10

MaxCapsJSON bounds the JSON in Capabilities and Profile.

View Source
const MaxClip = 16 << 20

MaxClip bounds one clipboard item's bytes.

View Source
const MaxControlLen = 1 << 16

MaxControlLen bounds a control frame body, including its type byte.

View Source
const MaxCursorSide = 256

MaxCursorSide bounds a CursorShape's width and height, in pixels.

View Source
const MaxDatagram = 1152

MaxDatagram is the largest media UDP payload Planck sends by default: it fits Tailscale's 1280-byte tunnel MTU after IPv6, UDP and WireGuard overhead. Every sealed media datagram, header and AEAD tag included, must fit within it.

View Source
const MaxLANDatagram = 1452

MaxLANDatagram is the media UDP payload on a LAN path with a 1500-byte MTU, after IPv6 and UDP headers: 22% fewer datagrams per frame than MaxDatagram. Hosts use it only when both ends agree (FeatureLANDatagram).

View Source
const MaxProbeCount = 1 << 16

MaxProbeCount bounds the datagrams of one probe train.

View Source
const ProbeHeaderLen = 24

ProbeHeaderLen is the plaintext header of a probe datagram; padding fills the rest of it to the requested size.

View Source
const RumbleLen = 12

RumbleLen is the fixed size of a rumble datagram.

View Source
const StreamClipboard byte = 0x01

StreamClipboard is the first byte of a unidirectional QUIC stream that carries clipboard items. Each side opens one for what it sends.

View Source
const Version = 1

Version is the protocol version exchanged in Hello.

View Source
const VideoHeaderLen = 36

VideoHeaderLen is the plaintext header in front of every video shard.

Variables

View Source
var (
	ErrClipTooLarge = errors.New("wire: clipboard item too large")
	ErrClipHash     = errors.New("wire: clipboard item does not match its hash")
	ErrClipFormat   = errors.New("wire: unknown clipboard format")
)
View Source
var (
	ErrTooLarge   = errors.New("wire: control message too large")
	ErrMalformed  = errors.New("wire: malformed message")
	ErrUnknownMsg = errors.New("wire: unknown message type")
)
View Source
var ErrBadDatagram = errors.New("wire: bad media datagram")

Functions

func AppendMessage

func AppendMessage(b []byte, m Message) ([]byte, error)

AppendMessage appends m as a control frame: a 32-bit big-endian length, then the type byte and the body.

func WriteClip

func WriteClip(w io.Writer, c *Clip) error

WriteClip writes c as one frame.

func WriteMessage

func WriteMessage(w io.Writer, m Message) error

WriteMessage writes m as one control frame.

Types

type AudioCodec

type AudioCodec uint8
const (
	AudioOpus AudioCodec = iota
	// AudioPCM16 is raw little-endian int16 PCM.
	AudioPCM16
)

type AudioFlow

type AudioFlow uint8

AudioFlow says which stream an audio datagram belongs to.

const (
	// FlowDesktop is the host's desktop audio, host to client.
	FlowDesktop AudioFlow = iota
	// FlowMic is the client's microphone, client to host.
	FlowMic
)

type AudioHeader

type AudioHeader struct {
	Flow  AudioFlow
	Codec AudioCodec
	// FrameQuarterMs is the packet's frame length in quarter milliseconds;
	// zero means 10 ms.
	FrameQuarterMs uint8
	Seq            uint32
	Timestamp      int64
}

AudioHeader describes one audio packet. Hosts before the mic flow wrote zeros where Flow, Codec and FrameQuarterMs go: desktop Opus at the default frame length.

func ParseAudio

func ParseAudio(b []byte) (AudioHeader, []byte, error)

ParseAudio returns the header and the payload, which aliases b.

func (*AudioHeader) Put

func (h *AudioHeader) Put(b []byte)

type AuthMethod

type AuthMethod uint8
const (
	// AuthPaired: the client's certificate fingerprint was stored at pairing.
	AuthPaired AuthMethod = iota + 1
	// AuthPIN: first pairing; PINProof binds a shared PIN to this TLS session.
	AuthPIN
	// AuthTailscale: the host resolves the client's identity with Tailscale WhoIs.
	AuthTailscale
)

type AuthRequest

type AuthRequest struct {
	Method     AuthMethod
	DeviceName string
	PINProof   [32]byte
}

func (*AuthRequest) Type

func (*AuthRequest) Type() MsgType

type AuthResponse

type AuthResponse struct {
	Status   AuthStatus
	Identity string
	// PINProof is the host's proof of the PIN for AuthPIN, so the client
	// also detects a host that does not know it.
	PINProof [32]byte
	Message  string
}

func (*AuthResponse) Type

func (*AuthResponse) Type() MsgType

type AuthStatus

type AuthStatus uint8
const (
	AuthOK AuthStatus = iota + 1
	AuthDenied
	AuthPINRequired
)

type Capabilities

type Capabilities struct {
	Role Role
	JSON []byte
}

Capabilities carries JSON: pkg/defaults HostCapabilities from the host; from the client, {"v":1,"client":ClientCapabilities,"route":RouteInfo,"overrides":UserOverrides}. pkg/wire treats it as opaque, so the JSON schema can grow without a protocol bump.

func (*Capabilities) Type

func (*Capabilities) Type() MsgType

type Chroma

type Chroma uint8
const (
	Chroma420 Chroma = iota + 1
	Chroma444
)

type Clip

type Clip struct {
	Format ClipFormat
	Origin [16]byte
	Hash   [32]byte
	Data   []byte
}

Clip is one clipboard item. Origin identifies the device that first copied it, so an item is never applied back where it came from; Hash is the SHA-256 of Data.

func NewClip

func NewClip(f ClipFormat, origin [16]byte, data []byte) *Clip

NewClip makes an item from data and stamps its hash.

func ReadClip

func ReadClip(r io.Reader, limit int) (*Clip, error)

ReadClip reads one frame. A frame longer than limit (at most MaxClip) is read and discarded and returns ErrClipTooLarge, and a frame whose bytes do not match its hash returns ErrClipHash; the stream stays usable after either. Any other error ends the stream.

type ClipFormat

type ClipFormat uint8
const (
	// ClipText is UTF-8 text.
	ClipText ClipFormat = iota + 1
	// ClipPNG is a PNG image.
	ClipPNG
)

type Codec

type Codec uint8
const (
	CodecH264 Codec = iota + 1
	CodecHEVC
	CodecAV1
	// CodecPyroWave is only sent when both Hellos carry FeatureCapabilities.
	CodecPyroWave
)

type CursorShape

type CursorShape struct {
	// ID names the shape: a hash of its size, hotspot, DPI and pixels.
	ID uint64
	// Width and Height are the image's size in pixels, up to
	// MaxCursorSide, and HotX and HotY its hotspot on it. All are zero in
	// a reference.
	Width, Height uint16
	HotX, HotY    uint16
	// DPI is the display's the host sized the cursor for; 96 is 100%.
	DPI uint16
	// RGBA is the image, not premultiplied, rows top down: Width * Height
	// * 4 bytes. It is nil in a reference.
	RGBA []byte
}

CursorShape is the host's cursor as the client draws it in place of its own over the picture. A shape with no image refers to one sent before, by ID.

func (*CursorShape) Ref

func (m *CursorShape) Ref() bool

Ref reports whether m refers to a shape sent before.

func (*CursorShape) Type

func (*CursorShape) Type() MsgType

type CursorState

type CursorState struct {
	Visible bool
	// Captured is set while an app holds the mouse, as a game does: it
	// confines the cursor to less than the desktop, or warps it back. A
	// cursor hidden alone, as over a playing video, is not captured.
	Captured bool
	// HasPos says X and Y hold the cursor's place on the streamed display,
	// from 0 at its left or top edge to 65535 at its right or bottom edge.
	HasPos bool
	X, Y   uint16
}

CursorState is the host's system cursor. Neither capture path draws the cursor into the picture, so the client's own cursor stands in for a Visible one, drawn as the CursorShape a host sends.

func (*CursorState) Type

func (*CursorState) Type() MsgType

type DisplayPhase added in v0.2.0

type DisplayPhase struct {
	Valid, Locked bool
	// Direct and Composited say how the client's system shows the
	// pictures; neither is set while it cannot tell.
	Direct, Composited bool
	PeriodNs           uint32
	// ErrorNs is the median slack minus the target, wrapped into half a
	// refresh either way: above 0 the pictures were ready early.
	ErrorNs                     int32
	SlackNs, TargetNs, JitterNs uint32
	// LatePermille and CompositedPermille are the shares of pictures that
	// missed their refresh and that a compositor showed a refresh or more
	// later, in thousandths.
	LatePermille, CompositedPermille uint16
	// Oldest and Newest are the video frames measured.
	Oldest, Newest uint32
}

DisplayPhase is the client display's refresh and how long before a refresh its last pictures were ready (pkg/phaselock Report): the host steers the phase of its frames with it.

func (*DisplayPhase) Type added in v0.2.0

func (*DisplayPhase) Type() MsgType

type Feedback

type Feedback struct {
	FrameID uint32
	// ArrivalTS is the client's monotonic clock when the frame completed.
	ArrivalTS int64
	Bytes     uint32

	HasFinal     bool
	FinalOK      bool
	FinalFrameID uint32
	FinalRecv    uint16
	FinalSent    uint16
}

Feedback is the client's report for one fully received video frame. It also carries the final shard counts of the most recent frame that left the client's reassembly window, which the host uses as its loss signal.

func (*Feedback) Parse

func (f *Feedback) Parse(b []byte) error

func (*Feedback) Put

func (f *Feedback) Put(b []byte) []byte

type Goodbye

type Goodbye struct {
	Reason  GoodbyeReason
	Message string
}

func (*Goodbye) Type

func (*Goodbye) Type() MsgType

type GoodbyeReason

type GoodbyeReason uint8
const (
	GoodbyeNormal GoodbyeReason = iota + 1
	GoodbyeAuthFailed
	GoodbyeProtocolError
	GoodbyeTimeout
)

type Hello

type Hello struct {
	Version  uint16
	Role     Role
	Name     string
	Features uint32
}

func (*Hello) Type

func (*Hello) Type() MsgType

type HostStats

type HostStats struct {
	CaptureMicros uint32
	EncodeMicros  uint32
}

HostStats are the host's stage times the client cannot see in the video headers, which time a frame from its capture time: the p50 over the last frames of capture, from the system presenting a picture to the host acquiring it, and of encode, from acquiring it to the encoder finishing it.

func (*HostStats) Type

func (*HostStats) Type() MsgType

type Input

type Input struct {
	Type      InputType
	Seq       uint32
	Timestamp int64

	Code   uint16
	Mods   uint16
	Down   bool
	X, Y   int32
	Button uint8

	Pad            uint8
	Buttons        uint32
	LT, RT         uint8
	LX, LY, RX, RY int16
}

Input is one input event from the client. Which fields count depends on Type: Key uses Code (USB HID usage), Mods and Down; MouseRel and Scroll use X and Y as deltas; MouseAbs uses X and Y in 0..65535 of the video frame; MouseButton uses Button and Down; Gamepad uses Pad and the stick, trigger and button state, which is absolute so a lost packet is healed by the next.

func (*Input) Parse

func (in *Input) Parse(b []byte) error

func (*Input) Put

func (in *Input) Put(b []byte) []byte

type InputType

type InputType uint8
const (
	InputKey InputType = iota + 1
	InputMouseRel
	InputMouseAbs
	InputMouseButton
	InputScroll
	InputGamepad
)

type Message

type Message interface {
	Type() MsgType
	// contains filtered or unexported methods
}

Message is a control-stream message. The set is closed: only types in this package implement it.

func DecodeMessage

func DecodeMessage(body []byte) (Message, error)

DecodeMessage decodes a frame body: the type byte and the message fields. Trailing bytes are rejected so a frame has exactly one encoding.

func ReadMessage

func ReadMessage(r io.Reader) (Message, error)

ReadMessage reads one control frame.

type MsgType

type MsgType uint8
const (
	MsgHello MsgType = iota + 1
	MsgAuthRequest
	MsgAuthResponse
	MsgSessionConfig
	MsgSessionReady
	MsgPLI
	MsgRefInvalidate
	MsgStatsReport
	MsgGoodbye
	// MsgCapabilities goes both ways, once, right after AuthOK.
	MsgCapabilities MsgType = 10
	// MsgProfile goes host to client, right after SessionReady, and again
	// when a Resize changed the stream.
	MsgProfile MsgType = 11
	// MsgResize goes client to host, only to a host whose Hello carries
	// FeatureResize.
	MsgResize MsgType = 12
	// MsgPeerState goes both ways, to a peer with FeaturePeerState, at the
	// start of a session and whenever it changes.
	MsgPeerState MsgType = 13
	// MsgHostStats goes host to client, in answer to each StatsReport,
	// only to a client whose Hello carries FeatureHostStats.
	MsgHostStats MsgType = 16
	// MsgCursorState goes host to client, only to a client whose Hello
	// carries FeatureCursorState: at the start of a stream and whenever the
	// host's cursor shows, hides, or is captured or let go.
	MsgCursorState MsgType = 17
	// MsgStream goes host to client, only to a client whose Hello carries
	// FeatureStreamSwitch, when a Resize settled a new stream.
	MsgStream MsgType = 18
	// MsgCursorShape goes host to client, only to a client whose Hello
	// carries FeatureCursorShape: as a stream starts and whenever the
	// host's cursor changes shape.
	MsgCursorShape MsgType = 19
	// MsgSwitchDisplay goes client to host, only to a host whose Hello
	// carries FeatureSwitchDisplay, from a client with FeatureStreamSwitch.
	MsgSwitchDisplay MsgType = 20
	// MsgDisplayPhase goes client to host, only to a host whose Hello
	// carries FeatureDisplayPhase, a few times a second while pictures
	// reach the screen.
	MsgDisplayPhase MsgType = 21
)
const (
	// MsgProbeRequest goes client to host, only to a host whose Hello
	// carries FeatureCalibration.
	MsgProbeRequest MsgType = 22
	// MsgProbeDone goes host to client once a requested train went out.
	MsgProbeDone MsgType = 23
)

type PLI

type PLI struct{}

PLI asks the host for a keyframe.

func (*PLI) Type

func (*PLI) Type() MsgType

type PeerState

type PeerState struct {
	// ClipboardSend: this side sends its clipboard changes.
	ClipboardSend bool
	// ClipboardRecv: this side applies the peer's clipboard items.
	ClipboardRecv bool
	// MicDevice, from a host, is the virtual input device the client's
	// microphone plays into; empty when it has none, and MicHint says why.
	MicDevice string
	MicHint   string
}

PeerState is what one side does with the session's optional flows.

func (*PeerState) Type

func (*PeerState) Type() MsgType

type Ping

type Ping struct {
	Seq uint32
	T0  int64
}

Ping carries the sender's clock; Pong echoes it with the responder's receive time (T1) and send time (T2), NTP style.

func (*Ping) Parse

func (p *Ping) Parse(b []byte) error

func (*Ping) Put

func (p *Ping) Put(b []byte) []byte

type Pong

type Pong struct {
	Seq        uint32
	T0, T1, T2 int64
}

func (*Pong) Parse

func (p *Pong) Parse(b []byte) error

func (*Pong) Put

func (p *Pong) Put(b []byte) []byte

type ProbeDone added in v0.2.0

type ProbeDone struct {
	Train  uint32
	Sent   uint32
	SendNs uint64
}

ProbeDone says the host sent Sent datagrams of train Train, the first to the last SendNs apart; Sent 0 is a refused request.

func (*ProbeDone) Type added in v0.2.0

func (*ProbeDone) Type() MsgType

type ProbeHeader added in v0.2.0

type ProbeHeader struct {
	Train, Index, Count uint32
	SentTS              int64
}

ProbeHeader is datagram Index of the Count of train Train, sent at the host's monotonic SentTS.

func (*ProbeHeader) Parse added in v0.2.0

func (h *ProbeHeader) Parse(b []byte) error

func (*ProbeHeader) Put added in v0.2.0

func (h *ProbeHeader) Put(b []byte)

type ProbeRequest added in v0.2.0

type ProbeRequest struct {
	Train    uint32
	Count    uint32
	Size     uint16
	RateKbps uint32
}

ProbeRequest asks the host for a train of Count probe datagrams of Size bytes of plaintext each, paced at RateKbps, or back to back at 0.

func (*ProbeRequest) Type added in v0.2.0

func (*ProbeRequest) Type() MsgType

type Profile

type Profile struct {
	JSON []byte
}

Profile carries the host's pkg/defaults ResolvedProfile as JSON, for the client UI and player.

func (*Profile) Type

func (*Profile) Type() MsgType

type RefInvalidate

type RefInvalidate struct {
	FrameID, Through uint32
}

RefInvalidate tells the host that FrameID and every later frame are unusable as references, so it can recover with a non-IDR frame. Through, when after FrameID, is the last frame the client lost in this gap; otherwise the gap is FrameID alone. Through 0 is unset, so a gap cannot end at frame 0: legacy peers send no Through at all, and a 4-byte body must not read as a wrapped range for a FrameID past 1<<31.

func (*RefInvalidate) Last added in v0.2.0

func (m *RefInvalidate) Last() uint32

Last is the last frame of the gap.

func (*RefInvalidate) Type

func (*RefInvalidate) Type() MsgType

type Resize

type Resize struct {
	Width, Height uint16
	// Display is the client display the window is on now, when Width is
	// set; else the display offered at the start holds.
	Display ResizeDisplay
}

Resize asks the host to stream at the client window's new size, in pixels. The host answers with a Profile once the stream changed, or keeps the stream as it is.

func (*Resize) Type

func (*Resize) Type() MsgType

type ResizeDisplay

type ResizeDisplay struct {
	Width, Height uint16
	ScaleMilli    uint16
	MaxHz, MinHz  uint16
	HDR           bool
}

ResizeDisplay is a client display: its size in pixels, backing scale in thousandths, refresh range and HDR.

type Role

type Role uint8
const (
	RoleHost Role = iota + 1
	RoleClient
)

type Rumble

type Rumble struct {
	Pad        uint8
	Seq        uint32
	Low, High  uint16
	DurationMs uint16
}

Rumble drives a client gamepad's motors; strengths are 0..65535.

func (*Rumble) Parse

func (r *Rumble) Parse(b []byte) error

func (*Rumble) Put

func (r *Rumble) Put(b []byte) []byte

type SessionConfig

type SessionConfig struct {
	Codec           Codec
	Chroma          Chroma
	Width           uint16
	Height          uint16
	FPS             uint16
	BitrateKbps     uint32
	Slices          uint8
	SubFrame        bool
	AudioSampleRate uint32
	AudioChannels   uint8
}

func (*SessionConfig) Type

func (*SessionConfig) Type() MsgType

type SessionReady

type SessionReady struct {
	SessionID uint64
	MediaPort uint16
	// ShardSize is the video FEC shard payload size for this session.
	ShardSize uint16
	Config    SessionConfig
}

func (*SessionReady) Type

func (*SessionReady) Type() MsgType

type StatsReport

type StatsReport struct {
	RTTMicros       uint32
	JitterMicros    uint32
	LossPermille    uint16
	FramesReceived  uint32
	FramesDropped   uint32
	FramesRecovered uint32
	DecodeMicros    uint32
	ReceivedKbps    uint32
}

func (*StatsReport) Type

func (*StatsReport) Type() MsgType

type Stream

type Stream struct {
	Epoch   uint8
	Profile []byte
}

Stream announces the stream a Resize settled: Profile is its pkg/defaults ResolvedProfile as JSON, and every video frame of it carries Epoch.

func (*Stream) Type

func (*Stream) Type() MsgType

type SwitchDisplay

type SwitchDisplay struct {
	DisplayID string
}

SwitchDisplay asks the host to stream its display with this ID, one of the HostCapabilities displays. The host answers with a Stream once the stream moved, and ignores an ID it does not have.

func (*SwitchDisplay) Type

func (*SwitchDisplay) Type() MsgType

type VideoHeader

type VideoHeader struct {
	VideoInfo
	SliceIndex   uint8
	BlockIndex   uint8
	BlockCount   uint8
	ShardIndex   uint8
	DataShards   uint8
	ParityShards uint8
	ShardLen     uint16
	// BlockLen is the number of slice bytes the block's data shards carry;
	// the last data shard is zero-padded to ShardLen.
	BlockLen uint32
}

VideoHeader describes one shard of one Reed-Solomon block of one slice.

func (*VideoHeader) Parse

func (h *VideoHeader) Parse(b []byte) error

Parse decodes a video header from a whole shard datagram and checks it against the datagram length.

func (*VideoHeader) Put

func (h *VideoHeader) Put(b []byte)

type VideoInfo

type VideoInfo struct {
	FrameID  uint32
	Keyframe bool
	// CaptureTS and EncodeTS are the host's monotonic clock in nanoseconds
	// when the frame was captured and when its encode finished. The client
	// maps them to its clock with the ping/pong offset.
	CaptureTS  int64
	EncodeTS   int64
	SliceCount uint8
	// Recovery marks the first frame encoded after a RefInvalidate: it
	// predicts only from frames before the invalidated one, so a client
	// that skipped the frames since decodes again from it.
	Recovery bool
	// Epoch is the stream the frame belongs to: 0 from the start, and the
	// Epoch of each Stream message after it.
	Epoch uint8
}

VideoInfo is the per-frame part of a video shard header.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL