Documentation
¶
Index ¶
- func IsProxyableStream(p pb.MediaStreamProtocol) bool
- func IsVideoStream(p pb.MediaStreamProtocol) bool
- func ResolveStreamIndex(r *http.Request, streams []*pb.MediaStream, ...) (int, error)
- type Bridge
- type BridgeManager
- type GetSourceURLFunc
- type GetStreamsFunc
- type Peer
- type RTSPServer
- func (rs *RTSPServer) Close()
- func (rs *RTSPServer) OnConnOpen(ctx *gortsplib.ServerHandlerOnConnOpenCtx)
- func (rs *RTSPServer) OnDescribe(ctx *gortsplib.ServerHandlerOnDescribeCtx) (*base.Response, *gortsplib.ServerStream, error)
- func (rs *RTSPServer) OnPlay(_ *gortsplib.ServerHandlerOnPlayCtx) (*base.Response, error)
- func (rs *RTSPServer) OnSessionClose(ctx *gortsplib.ServerHandlerOnSessionCloseCtx)
- func (rs *RTSPServer) OnSetup(ctx *gortsplib.ServerHandlerOnSetupCtx) (*base.Response, *gortsplib.ServerStream, error)
- func (rs *RTSPServer) Start(ln net.Listener) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsProxyableStream ¶ added in v0.0.23
func IsProxyableStream(p pb.MediaStreamProtocol) bool
func IsVideoStream ¶ added in v0.0.23
func IsVideoStream(p pb.MediaStreamProtocol) bool
IsVideoStream returns true for streams that can be bridged to WebRTC.
func ResolveStreamIndex ¶ added in v0.0.23
func ResolveStreamIndex(r *http.Request, streams []*pb.MediaStream, prefer func(pb.MediaStreamProtocol) bool) (int, error)
ResolveStreamIndex returns the camera stream index to use. If ?stream=N is set, it validates and returns N. Otherwise it finds the first stream where prefer() returns true, falling back to stream 0.
Types ¶
type Bridge ¶
type Bridge struct {
// contains filtered or unexported fields
}
Bridge manages a single video source and fans out RTP packets to multiple consumers (WebRTC peers, RTSP server streams, etc.) via a shared track.
func (*Bridge) AddPeer ¶
AddPeer creates a new WebRTC PeerConnection, adds the shared video track, performs SDP negotiation, and returns the SDP answer.
func (*Bridge) OnRTP ¶
OnRTP registers a callback that receives every RTP packet written to this bridge. Returns a key that can be passed to OffRTP to unregister.
type BridgeManager ¶
type BridgeManager struct {
OnEpoch func(key string, epoch time.Time)
// contains filtered or unexported fields
}
BridgeManager is the registry of active bridges keyed by "entityId/cameraIndex".
func NewBridgeManager ¶
func NewBridgeManager() *BridgeManager
func (*BridgeManager) GetOrCreate ¶
func (bm *BridgeManager) GetOrCreate(key, sourceURL string) (*Bridge, error)
GetOrCreate returns an existing bridge or creates a new one. Supports rtsp://, rtsps://, and v4l2:// source URLs.
func (*BridgeManager) SetupWebRTCMux ¶
func (bm *BridgeManager) SetupWebRTCMux(conn net.PacketConn)
SetupWebRTCMux configures a shared SettingEngine that multiplexes all ICE UDP traffic through the given listener.
type GetSourceURLFunc ¶ added in v0.0.23
GetSourceURLFunc returns the original source URL for a camera stream.
type GetStreamsFunc ¶ added in v0.0.23
type GetStreamsFunc func(entityID string) []*pb.MediaStream
GetStreamsFunc returns the camera streams for an entity, or nil if not found.
type Peer ¶
type Peer struct {
// contains filtered or unexported fields
}
Peer represents a single WHEP viewer connected to a Bridge.
type RTSPServer ¶
type RTSPServer struct {
// contains filtered or unexported fields
}
RTSPServer relays camera streams from entities as an RTSP server. Clients connect to rtsp://host:port/media/rtsp/{entityId}/{cameraIndex}. Supports both RTSP sources (direct relay) and HTTP MJPEG sources (fetches MJPEG, packetizes as RTP/JPEG).
func NewRTSPServer ¶
func NewRTSPServer(getStreams GetStreamsFunc, getSourceURL GetSourceURLFunc, bridges *BridgeManager, isRemoteAllowed func() bool) *RTSPServer
NewRTSPServer creates an RTSP relay server. isRemoteAllowed is called on each connection to check if non-loopback access is permitted.
func (*RTSPServer) OnConnOpen ¶
func (rs *RTSPServer) OnConnOpen(ctx *gortsplib.ServerHandlerOnConnOpenCtx)
OnConnOpen rejects non-loopback connections when remote sharing is disabled.
func (*RTSPServer) OnDescribe ¶
func (rs *RTSPServer) OnDescribe(ctx *gortsplib.ServerHandlerOnDescribeCtx) (*base.Response, *gortsplib.ServerStream, error)
OnDescribe handles DESCRIBE requests.
func (*RTSPServer) OnPlay ¶
func (rs *RTSPServer) OnPlay(_ *gortsplib.ServerHandlerOnPlayCtx) (*base.Response, error)
OnPlay handles PLAY requests.
func (*RTSPServer) OnSessionClose ¶
func (rs *RTSPServer) OnSessionClose(ctx *gortsplib.ServerHandlerOnSessionCloseCtx)
OnSessionClose handles session disconnection (RTCP timeout, TCP close, TEARDOWN).
func (*RTSPServer) OnSetup ¶
func (rs *RTSPServer) OnSetup(ctx *gortsplib.ServerHandlerOnSetupCtx) (*base.Response, *gortsplib.ServerStream, error)
OnSetup handles SETUP requests.