Documentation
¶
Overview ¶
Package webrtc provides shared video transport and WebSocket signaling.
Index ¶
- Constants
- Variables
- type AudioSample
- type AudioSource
- type ClipboardController
- type Config
- type EncoderProfile
- type InputCapabilities
- type InputController
- type InputEvent
- type InputEventType
- type MediaSource
- type Observer
- type PeerInfo
- type Quality
- type QualityOption
- type RTCPFeedback
- type RTPCodec
- type SDPRequirements
- type Service
- type VideoSample
Constants ¶
const ( PayloaderVP8 = "vp8" PayloaderH264 = "h264" )
const ( InputEventPointerAbsolute = remoteinput.EventPointerAbsolute InputEventPointerRelative = remoteinput.EventPointerRelative InputEventPointerButton = remoteinput.EventPointerButton InputEventPointerScroll = remoteinput.EventPointerScroll InputEventKeyboardKey = remoteinput.EventKeyboardKey )
Variables ¶
var ( ErrInputBusy = remoteinput.ErrBusy ErrInputDisabled = remoteinput.ErrDisabled ErrInputNotReady = remoteinput.ErrNotReady ErrInputNotOwner = remoteinput.ErrNotOwner ErrInputOverloaded = remoteinput.ErrOverloaded ErrInputClosed = remoteinput.ErrClosed )
Functions ¶
This section is empty.
Types ¶
type AudioSample ¶
AudioSample is one encoded Opus frame ready for transport.
type AudioSource ¶
type AudioSource interface {
Samples() <-chan AudioSample
}
AudioSource supplies optional encoded Opus audio.
type ClipboardController ¶
type ClipboardController interface {
Enabled() bool
Set(context.Context, clipboard.Content) error
Latest() (clipboard.Content, bool)
Subscribe() (<-chan clipboard.Content, func())
}
ClipboardController synchronizes clipboard content with peers.
type Config ¶
type Config struct {
AudioEnabled bool
ICEServers []string
ICEUsername string
ICECredential string
UDPPortMin uint16
UDPPortMax uint16
Subprotocols []string
MaxPeers int
ReplaceExistingPeer bool
AllowedOrigins []string
TracingEnabled bool
Observer Observer
}
Config contains static WebRTC and signaling settings.
type EncoderProfile ¶
type EncoderProfile struct {
DefaultOption string
Options map[string]QualityOption
FrontendTransform string
Codec RTPCodec
}
EncoderProfile contains the profile metadata needed by the WebRTC transport.
type InputCapabilities ¶
type InputCapabilities = remoteinput.Capabilities
InputCapabilities reports the input classes available to a peer.
type InputController ¶
type InputController interface {
Acquire(uint64, func(uint64, error)) (InputCapabilities, error)
Release(uint64) error
Owns(uint64) bool
Submit(uint64, InputEvent) error
}
InputController owns peer input leases and dispatches validated events.
type InputEvent ¶
type InputEvent = remoteinput.Event
InputEvent is one validated remote input transition or motion.
type InputEventType ¶
type InputEventType = remoteinput.EventType
InputEventType identifies one input event.
type MediaSource ¶
type MediaSource interface {
Samples() <-chan VideoSample
Quality() Quality
Profile(string) (EncoderProfile, bool)
UpdateQuality(Quality) error
RequestKeyframe() error
SetActive(bool)
}
MediaSource supplies one shared encoded video stream.
type Observer ¶
type Observer interface {
PeerOpened(PeerInfo)
PeerStateChanged(PeerInfo, string)
PeerClosed(PeerInfo)
}
Observer receives peer lifecycle notifications.
type Quality ¶
type Quality struct {
Profile string `json:"profile"`
Option string `json:"option"`
Width int `json:"width"`
Height int `json:"height"`
Framerate int `json:"framerate"`
BitrateKbps int `json:"bitrate_kbps"`
}
Quality contains runtime-adjustable video settings.
type QualityOption ¶
type QualityOption struct {
Label string `json:"label"`
Width int `json:"width"`
Height int `json:"height"`
Framerate int `json:"framerate"`
BitrateKbps int `json:"bitrate_kbps"`
}
QualityOption is one complete video quality tuple exposed to clients.
func (QualityOption) Quality ¶
func (option QualityOption) Quality(profileName, optionName string) Quality
Quality resolves this option into runtime encoder settings.
type RTCPFeedback ¶
RTCPFeedback describes one negotiated RTCP feedback mechanism.
type RTPCodec ¶
type RTPCodec struct {
ID string
MimeType string
ClockRate uint32
Channels uint16
PayloadType uint8
Payloader string
SDPFmtpLine string
RTCPFeedback []RTCPFeedback
SDP SDPRequirements
}
RTPCodec contains codec, RTP, packetizer, and SDP settings.
func (RTPCodec) Compatible ¶
Compatible reports whether two codec definitions can share an active peer connection.
type SDPRequirements ¶
SDPRequirements controls offer validation and answer parameter rewriting.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service fans one encoded media source out to active peer connections.
func New ¶
func New( cfg Config, source MediaSource, audio AudioSource, inputController InputController, clipboardController ClipboardController, logger *zap.Logger, ) (*Service, error)
New constructs a reusable WebRTC service without opening listeners.
func (*Service) Close ¶
func (s *Service) Close()
Close stops signaling and closes every active peer.
func (*Service) Handler ¶
Handler returns the signaling handler for mounting behind application middleware.