Documentation
¶
Overview ¶
Package defaults picks a session's stream settings from what the host, the client and the route between them can do, with user overrides on top. Resolve is pure: no I/O, no clock, no map iteration.
Index ¶
- Constants
- func ViewSize(w, h int) (int, int)
- type BitDepthPref
- type ChromaPref
- type ClientCapabilities
- type ClientDisplay
- type Codec
- type CodecCap
- type CodecPref
- type Decision
- type EncoderCap
- type FECProfile
- type FPSPref
- type HostCapabilities
- type HostDisplay
- type Link
- type ResolutionPref
- type ResolvedProfile
- type RouteInfo
- type RouteKind
- type RoutePref
- type SlicesPref
- type Source
- type Toggle
- type UserOverrides
- type VDDCap
Constants ¶
const ( MinCustomWidth = 640 MaxCustomWidth = 7680 MinCustomHeight = 360 MaxCustomHeight = 4320 MaxBitrateMbps = 3000 )
const ( APINVENC = "NVENC" APIAMF = "AMF" APIOneVPL = "oneVPL" APIVideoToolbox = "VideoToolbox" APIPyroWave = "PyroWave" )
const Auto = "auto"
const MaxDisplayIDLen = 256
MaxDisplayIDLen bounds UserOverrides.Display.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BitDepthPref ¶
type BitDepthPref string // auto | 8 | 10
Every knob is a string enum; "" and "auto" both mean auto.
type ChromaPref ¶
type ChromaPref string // auto | 420 | 444
Every knob is a string enum; "" and "auto" both mean auto.
type ClientCapabilities ¶
type ClientCapabilities struct {
OS string `json:"os"`
Display ClientDisplay `json:"display"`
Decoders []CodecCap `json:"decoders"` // hardware only, from the startup probe
// Present10Bit: the client surface can show BGR10A2 (WS2).
Present10Bit bool `json:"present10Bit"`
DirectDisplay bool `json:"directDisplay"` // the platform has a full-screen direct path (macOS WS2)
// PresentHDR10: the client presents BT.2020 PQ pictures as HDR on a
// display whose HDR is set (macOS EDR).
PresentHDR10 bool `json:"presentHDR10,omitempty"`
Link Link `json:"link"`
}
type ClientDisplay ¶
type ClientDisplay struct {
WidthPx int `json:"widthPx"` // native backing pixels (3024x1964 on a 14" MacBook Pro)
HeightPx int `json:"heightPx"`
Scale float64 `json:"scale"` // backing scale factor
MaxHz int `json:"maxHz"` // ProMotion: 120
MinHz int `json:"minHz"` // ProMotion: 24
HDR bool `json:"hdr"`
// ViewWidthPx and ViewHeightPx are the stream window's size in pixels;
// 0 = no window, as a headless client. A virtual display with
// Resolution auto takes this size.
ViewWidthPx int `json:"viewWidthPx,omitempty"`
ViewHeightPx int `json:"viewHeightPx,omitempty"`
}
type CodecPref ¶
type CodecPref string // auto | pyrowave | hevc | av1 | h264
Every knob is a string enum; "" and "auto" both mean auto.
type EncoderCap ¶
type EncoderCap struct {
Adapter gpu.Adapter `json:"adapter"`
API string `json:"api"` // "NVENC" | "AMF" | "oneVPL" | "VideoToolbox" | "PyroWave"
Codecs []CodecCap `json:"codecs"` // sorted by Codec
Engines int `json:"engines"` // hardware encode engines (NVENC split needs >= 2)
SubFrame bool `json:"subFrame"`
// MaxPixelRate is width*height*fps the encoder sustains in real time.
// The startup probe measures it. The seed table in resolve.go is used
// until then.
MaxPixelRate int64 `json:"maxPixelRate"`
// EncodeP50Micros is the startup probe's 1080p p50 encode time. 0 = not measured.
EncodeP50Micros int `json:"encodeP50Micros"`
DrivesDisplay bool `json:"drivesDisplay"` // has an active physical output
}
type FECProfile ¶
type FPSPref ¶
type FPSPref string // auto | 60 | 120 | 144 | 240
Every knob is a string enum; "" and "auto" both mean auto.
type HostCapabilities ¶
type HostCapabilities struct {
OS string `json:"os"`
Encoders []EncoderCap `json:"encoders"` // one per adapter with a working backend; PyroWave is its own entry per adapter
Displays []HostDisplay `json:"displays"`
// PinnedDisplay is HostConfig.Display. If it is set, physical capture wins over VDD.
PinnedDisplay string `json:"pinnedDisplay,omitempty"`
VDD VDDCap `json:"vdd"`
Link Link `json:"link"`
Forced UserOverrides `json:"forced"` // host owner's policy; beats the client
}
type HostDisplay ¶
type HostDisplay struct {
ID string `json:"id"` // GDI name or CGDirectDisplayID
// Name is what the host's OS calls the display, "" when it has no name.
Name string `json:"name,omitempty"`
Width int `json:"width"`
Height int `json:"height"`
RefreshHz int `json:"refreshHz"`
Adapter gpu.LUID `json:"adapter"`
Primary bool `json:"primary"`
// HDR: the desktop on this display is in HDR10 (BT.2020 PQ), which
// capture can take as 10-bit.
HDR bool `json:"hdr,omitempty"`
}
type Link ¶
type Link struct {
Wired bool `json:"wired"` // Ethernet or Thunderbolt Ethernet, not Wi-Fi
SpeedMbps int `json:"speedMbps"` // 0 = unknown
}
Link is one end's interface toward the peer.
type ResolutionPref ¶
type ResolutionPref string // auto | 1080p | 1440p | 4k | custom
Every knob is a string enum; "" and "auto" both mean auto.
type ResolvedProfile ¶
type ResolvedProfile struct {
Route RouteKind `json:"route"`
MaxDatagram int `json:"maxDatagram"` // 1452 or 1152
LinkMbps int `json:"linkMbps"` // min of both ends, 0 = unknown
Wired bool `json:"wired"` // both ends
EncodeAdapter gpu.Adapter `json:"encodeAdapter"`
EncoderAPI string `json:"encoderAPI"`
VirtualDisplay bool `json:"virtualDisplay"`
CaptureDisplay string `json:"captureDisplay,omitempty"` // physical capture only
Codec Codec `json:"codec"`
Chroma444 bool `json:"chroma444"`
BitDepth int `json:"bitDepth"` // 8 | 10
// HDR10 is a 10-bit BT.2020 PQ stream from an HDR desktop.
HDR10 bool `json:"hdr10,omitempty"`
Width int `json:"width"`
Height int `json:"height"`
FPS int `json:"fps"`
BitrateKbps int `json:"bitrateKbps"` // start
MaxBitrateKbps int `json:"maxBitrateKbps"` // ratectl ceiling
Slices int `json:"slices"` // codec slices; PyroWave: 0 (its packetizer slices itself)
SubFrame bool `json:"subFrame"`
Split bool `json:"split"` // NVENC 2-engine split
DirectDisplay bool `json:"directDisplay"` // allowed; the client applies it only in full screen with the drawer closed
VSync bool `json:"vsync"`
FEC FECProfile `json:"fec"`
Decisions []Decision `json:"decisions"` // in resolve order
Warnings []string `json:"warnings"` // overrides that fell back
}
func Resolve ¶
func Resolve(host HostCapabilities, client ClientCapabilities, route RouteInfo, overrides UserOverrides) ResolvedProfile
Resolve is pure. Precedence per knob: host.Forced > client override > auto. An override the hardware or route cannot honour falls back to the auto value with a SourceFallback Decision and a Warning. Resolve never errors: HEVC 4:2:0 8-bit at the capture size is always reachable.
type RoutePref ¶
type RoutePref string // auto | lan | tailscale
Every knob is a string enum; "" and "auto" both mean auto.
type SlicesPref ¶
type SlicesPref string // auto | 1 | 4 | 8
Every knob is a string enum; "" and "auto" both mean auto.
type Toggle ¶
type Toggle string // auto | on | off
Every knob is a string enum; "" and "auto" both mean auto.
type UserOverrides ¶
type UserOverrides struct {
Codec CodecPref `json:"codec,omitempty"`
Chroma ChromaPref `json:"chroma,omitempty"`
BitDepth BitDepthPref `json:"bitDepth,omitempty"`
Resolution ResolutionPref `json:"resolution,omitempty"`
CustomWidth int `json:"customWidth,omitempty"` // with Resolution "custom": even, 640..7680
CustomHeight int `json:"customHeight,omitempty"` // even, 360..4320
FPS FPSPref `json:"fps,omitempty"`
BitrateMbps int `json:"bitrateMbps,omitempty"` // 0 = auto, else 1..3000
VirtualDisplay Toggle `json:"virtualDisplay,omitempty"`
// VirtualDisplayGPU picks the GPU that renders the virtual display and
// encodes (they must match for zero copy): a substring of the adapter
// name, matched case-insensitively ("4080", "Radeon"). "" = auto. A LUID
// is not stored because it changes on every boot.
VirtualDisplayGPU string `json:"virtualDisplayGPU,omitempty"`
SubFrameSlices SlicesPref `json:"subFrameSlices,omitempty"`
NVENC2EngineSplit Toggle `json:"nvenc2EngineSplit,omitempty"`
MetalDirectDisplay Toggle `json:"metalDirectDisplay,omitempty"`
VSyncMode Toggle `json:"vsyncMode,omitempty"` // auto = off
RoutePolicy RoutePref `json:"routePolicy,omitempty"`
// Display is the host display to capture, by HostDisplay.ID; "" lets
// the host choose. Picking one streams that physical display, not a
// virtual one.
Display string `json:"display,omitempty"`
HDR10 Toggle `json:"hdr10,omitempty"` // auto | off
}
func Merge ¶
func Merge(base, top UserOverrides) UserOverrides
Merge returns base with every non-auto field of top replacing base's. CustomWidth and CustomHeight travel with Resolution.
func (UserOverrides) Normalize ¶
func (o UserOverrides) Normalize() UserOverrides
Normalize turns every "" knob into "auto".
func (UserOverrides) Validate ¶
func (o UserOverrides) Validate() error