Documentation
¶
Overview ¶
Package webrtp provides RTSP to WebSocket streaming with fMP4 output.
Index ¶
- func AnnexbToAvcc(au [][]byte) []byte
- func AnnexbToNalus(data []byte) [][]byte
- func BuildFragment(seqNr uint32, dts uint64, dur uint32, isIDR bool, avcc []byte) ([]byte, error)
- func BuildInitH264(sps, pps []byte) ([]byte, error)
- func BuildInitH265(vps, sps, pps []byte) ([]byte, error)
- func EachH264AccessUnit(rd io.Reader, fn func(au [][]byte) error) error
- type Config
- type Frame
- type H264AccessUnit
- type H264Bridge
- type H264Fanout
- type H264KeyframeSampler
- type Hub
- func (r *Hub) Broadcast(data []byte, isKey bool)
- func (r *Hub) GetInit() []byte
- func (r *Hub) GetStartupSnapshot() ([]byte, []*Frame)
- func (r *Hub) GetStats(name string) StreamStats
- func (r *Hub) GetStatus() Status
- func (r *Hub) IsReceivingFrames() bool
- func (r *Hub) Reset()
- func (r *Hub) SetFramerate(framerate float64)
- func (r *Hub) SetInfo(codec string, width, height int, frameRate float64)
- func (r *Hub) SetInit(data []byte)
- func (r *Hub) Subscribe() chan *Frame
- func (r *Hub) SubscribeWithStartupSnapshot() ([]byte, []*Frame, chan *Frame)
- func (r *Hub) Unsubscribe(ch chan *Frame)
- type Instance
- func (r *Instance) Connect() error
- func (r *Instance) ForceNextKeyFrame() error
- func (r *Instance) GetHub() *Hub
- func (r *Instance) HandleWebsocket(conn *websocket.Conn)
- func (r *Instance) Handler() fiber.Handler
- func (r *Instance) InstanceReady() bool
- func (r *Instance) PublishDeskViewMetadata(topic string, payload []byte) error
- func (r *Instance) PublishH264AccessUnit(au [][]byte, pts90k uint32)
- func (r *Instance) RecordingStatus() RecordingStatus
- func (r *Instance) Start(addr string) error
- func (r *Instance) StartRecording(path, mode, offlineMode string) error
- func (r *Instance) Stop() error
- func (r *Instance) StopRecording() error
- func (r *Instance) UpdateKeyframeCalibration(distort, deskEnabled bool, fx, fy, scale float64, desk string) error
- type Keyframe
- type Keyframer
- type Logger
- type Recorder
- func (r *Recorder) OnOffline()
- func (r *Recorder) RecordSample(avcc []byte, dur uint32, isIDR bool)
- func (r *Recorder) SetInit(initData []byte)
- func (r *Recorder) SetSourceInfo(codec string, width, height int, frameRate float64)
- func (r *Recorder) Start(path, mode, offlineMode string) error
- func (r *Recorder) Status() RecordingStatus
- func (r *Recorder) Stop() error
- type RecordingStatus
- type Status
- type StreamStats
- type UsbCapabilityMode
- type UsbCapabilityRendition
- type UsbDevice
- type UsbDeviceCapabilities
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnnexbToAvcc ¶
AnnexbToAvcc converts Annex-B NAL units to AVCC format.
func AnnexbToNalus ¶
AnnexbToNalus splits an Annex-B byte stream into NAL units.
func BuildFragment ¶
BuildFragment creates an fMP4 media fragment.
func BuildInitH264 ¶
BuildInitH264 creates an fMP4 init segment for H264 video.
func BuildInitH265 ¶
BuildInitH265 creates an fMP4 init segment for H265 video.
Types ¶
type Config ¶
type Config struct {
SourceType string
StreamName string
Rtsp string
Device string
Path string
Codec string
H264Profile string
Width int
Height int
FrameRate float64
BitrateKbps int
KeyframeSink string
KeyframeOutput string
KeyframeFormat string
KeyframeMqttURL string
KeyframeMqttTopic string
Keyframer Keyframer
Logger Logger
WriteTimeout time.Duration
ReadBufferSize int
WriteBufferSize int
H264AccessUnitHandler func(H264AccessUnit)
}
type H264AccessUnit ¶ added in v1.1.0
H264AccessUnit is a single encoded H264 access unit with its 90kHz timestamp.
type H264Bridge ¶ added in v1.1.0
type H264Bridge struct {
// contains filtered or unexported fields
}
H264Bridge adapts externally-produced H264 access units into a WebRTP endpoint.
func NewH264Bridge ¶ added in v1.1.0
func NewH264Bridge(cfg *Config) *H264Bridge
NewH264Bridge creates a bridge that can publish H264 access units to browser clients.
func (*H264Bridge) Close ¶ added in v1.1.0
func (b *H264Bridge) Close() error
Close releases bridge resources and resets the underlying stream state.
func (*H264Bridge) Handler ¶ added in v1.1.0
func (b *H264Bridge) Handler() fiber.Handler
Handler exposes the bridge as a WebSocket endpoint for browser clients.
func (*H264Bridge) Instance ¶ added in v1.1.0
func (b *H264Bridge) Instance() *Instance
Instance exposes the underlying WebRTP instance for advanced control.
func (*H264Bridge) PublishH264AccessUnit ¶ added in v1.1.0
func (b *H264Bridge) PublishH264AccessUnit(au [][]byte, pts90k uint32)
PublishH264AccessUnit forwards a single H264 access unit into WebRTP.
func (*H264Bridge) Pump ¶ added in v1.1.0
func (b *H264Bridge) Pump(ctx context.Context, stream <-chan H264AccessUnit) error
Pump forwards access units from a channel until the context is canceled or the channel closes.
type H264Fanout ¶ added in v1.1.0
type H264Fanout struct {
// contains filtered or unexported fields
}
H264Fanout duplicates an access-unit stream to multiple consumers.
func NewH264Fanout ¶ added in v1.1.0
func NewH264Fanout(count, buffer int) *H264Fanout
NewH264Fanout allocates buffered output channels for a single producer stream.
func (*H264Fanout) Output ¶ added in v1.1.0
func (f *H264Fanout) Output(index int) <-chan H264AccessUnit
Output returns one of the fanout output channels.
func (*H264Fanout) Run ¶ added in v1.1.0
func (f *H264Fanout) Run(ctx context.Context, input <-chan H264AccessUnit) error
Run copies each access unit to every output until the input closes or the context is canceled.
type H264KeyframeSampler ¶ added in v1.1.0
type H264KeyframeSampler struct {
// contains filtered or unexported fields
}
H264KeyframeSampler forwards roughly one IDR access unit per interval from a source stream.
func NewH264KeyframeSampler ¶ added in v1.1.0
func NewH264KeyframeSampler(intervalSeconds int64) *H264KeyframeSampler
NewH264KeyframeSampler creates a wall-clock sampler for AI-oriented keyframe extraction.
func (*H264KeyframeSampler) Accept ¶ added in v1.1.0
func (s *H264KeyframeSampler) Accept(au H264AccessUnit) bool
Accept reports whether the access unit should be forwarded as the next sampled keyframe.
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
func (*Hub) GetStartupSnapshot ¶
func (*Hub) GetStats ¶
func (r *Hub) GetStats(name string) StreamStats
func (*Hub) IsReceivingFrames ¶
func (*Hub) SetFramerate ¶
func (*Hub) SubscribeWithStartupSnapshot ¶
func (*Hub) Unsubscribe ¶
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
func (*Instance) ForceNextKeyFrame ¶ added in v1.1.0
ForceNextKeyFrame requests that the current source emit a keyframe when supported.
func (*Instance) HandleWebsocket ¶
func (*Instance) InstanceReady ¶
func (*Instance) PublishDeskViewMetadata ¶
func (*Instance) PublishH264AccessUnit ¶ added in v1.1.0
func (*Instance) RecordingStatus ¶
func (r *Instance) RecordingStatus() RecordingStatus
func (*Instance) StartRecording ¶
func (*Instance) StopRecording ¶
type Logger ¶
type Logger interface {
Print(v ...interface{})
Printf(format string, v ...interface{})
}
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
func NewRecorder ¶
func (*Recorder) RecordSample ¶
func (*Recorder) SetSourceInfo ¶
func (*Recorder) Status ¶
func (r *Recorder) Status() RecordingStatus
type RecordingStatus ¶
type RecordingStatus struct {
Active bool `json:"active"`
Path string `json:"path,omitempty"`
OfflineMode string `json:"offlineMode,omitempty"`
StartedAt time.Time `json:"startedAt,omitempty"`
BytesWritten int64 `json:"bytesWritten"`
RequestedStartAt time.Time `json:"requestedStartAt,omitempty"`
ActualStartAt time.Time `json:"actualStartAt,omitempty"`
RequestedStopAt time.Time `json:"requestedStopAt,omitempty"`
ActualStopAt time.Time `json:"actualStopAt,omitempty"`
StartDriftMs int64 `json:"startDriftMs"`
StopDriftMs int64 `json:"stopDriftMs"`
MediaDurationMs int64 `json:"mediaDurationMs"`
TrimStartMs int64 `json:"trimStartMs"`
TrimEndMs int64 `json:"trimEndMs"`
MissingStartMs int64 `json:"missingStartMs"`
MissingEndMs int64 `json:"missingEndMs"`
}
type Status ¶
type Status struct {
Streams []*StreamStats `json:"streams"`
}
type StreamStats ¶
type StreamStats struct {
Name string `json:"name"`
Ready bool `json:"ready"`
Codec string `json:"codec"`
Width int `json:"width"`
Height int `json:"height"`
Framerate float64 `json:"framerate"`
FrameNo uint64 `json:"frameNo"`
ClientCount int32 `json:"clientCount"`
BytesRecv uint64 `json:"bytesRecv"`
Bitrate float64 `json:"bitrateKbps"`
Uptime time.Duration `json:"uptime"`
}
type UsbCapabilityMode ¶
type UsbCapabilityRendition ¶
type UsbDevice ¶
func UsbDeviceList ¶
type UsbDeviceCapabilities ¶
type UsbDeviceCapabilities struct {
Device *UsbDevice `json:"device,omitempty"`
Codecs []string `json:"codecs,omitempty"`
Modes []*UsbCapabilityMode `json:"modes,omitempty"`
SuggestedRenditions []*UsbCapabilityRendition `json:"suggestedRenditions,omitempty"`
BitrateControl string `json:"bitrateControl,omitempty"`
}
func UsbDeviceCapabilitiesGet ¶
func UsbDeviceCapabilitiesGet(device string) (*UsbDeviceCapabilities, error)
Source Files
¶
- h264_encode_common.go
- h264_encode_linux.go
- handler.go
- hub.go
- keyframe_calibration.go
- keyframe_image.go
- keyframe_native_decoder.go
- keyframe_native_decoder_debug.go
- keyframe_native_encode_stub.go
- keyframe_publish.go
- keyframe_quality_default.go
- keyframe_renderer.go
- keyframe_renderer_webgpu_stub.go
- keyframe_sink.go
- keyframe_worker.go
- manual_h264_bridge.go
- mqtt_publisher.go
- recorder.go
- recorder_black_native.go
- recorder_policy.go
- rtsp_codec.go
- rtsp_ffmpeg.go
- rtsp_h264.go
- rtsp_h265.go
- server.go
- server_policy.go
- source.go
- usb_capabilities.go
- usb_capabilities_stub.go
- usb_devices.go
- usb_devices_linux.go
- usb_linux.go
- video.go
- webrtp.go
- webrtp_file.go
- webrtp_rtsp.go
- webrtp_util.go
Directories
¶
| Path | Synopsis |
|---|---|
|
command
|
|
|
webrtp
command
|
|
|
experiment
|
|
|
streamable
command
|
|
|
usbauto
command
|
|
|
webtransport
command
|
|
