Documentation
¶
Index ¶
- Constants
- Variables
- type AnswerHandler
- type CallQuality
- type CallRoom
- func NewMeshCallRoom(streamingRoom streaming.Room, config Config, signaling SignalingManager, ...) CallRoom
- func NewMeshCallRoomFromOptions(opts streaming.RoomOptions, config Config, signaling SignalingManager, ...) (CallRoom, error)
- func NewSFUCallRoomFromOptions(opts streaming.RoomOptions, config Config, signaling SignalingManager, ...) (CallRoom, error)
- type Config
- type ConfigOption
- func WithAudioCodecs(codecs ...string) ConfigOption
- func WithQualityMonitoring(config QualityConfig) ConfigOption
- func WithRecording(path string) ConfigOption
- func WithSFU(config SFUConfig) ConfigOption
- func WithSTUNServers(servers ...string) ConfigOption
- func WithTURNServer(turn TURNConfig) ConfigOption
- func WithTopology(topology Topology) ConfigOption
- func WithVideoCodecs(codecs ...string) ConfigOption
- type ConnectionError
- type ConnectionQuality
- type ConnectionState
- type ConnectionStateHandler
- type DataChannel
- type DataChannelHandler
- type DataChannelMessageHandler
- type DataChannelState
- type DataChannelStateHandler
- type Extension
- func (e *Extension) CreateCallRoom(ctx context.Context, roomID string, opts streaming.RoomOptions) (CallRoom, error)
- func (e *Extension) DeleteCallRoom(ctx context.Context, roomID string) error
- func (e *Extension) Dependencies() []string
- func (e *Extension) Description() string
- func (e *Extension) GetCallRoom(roomID string) (CallRoom, error)
- func (e *Extension) GetCallRooms() []CallRoom
- func (e *Extension) GetConfig() Config
- func (e *Extension) GetQualityMonitor() QualityMonitor
- func (e *Extension) GetRecorder() Recorder
- func (e *Extension) GetSFURouter() SFURouter
- func (e *Extension) GetSignalingManager() SignalingManager
- func (e *Extension) Health(ctx context.Context) error
- func (e *Extension) JoinCall(ctx context.Context, roomID, userID string, opts *JoinOptions) (PeerConnection, error)
- func (e *Extension) LeaveCall(ctx context.Context, roomID, userID string) error
- func (e *Extension) Name() string
- func (e *Extension) Register(app forge.App) error
- func (e *Extension) RegisterRoutes(router forge.Router) error
- func (e *Extension) Start(ctx context.Context) error
- func (e *Extension) Stop(ctx context.Context) error
- func (e *Extension) Version() string
- type ICECandidate
- type ICECandidateHandler
- type ICECandidateReceivedHandler
- type ICEServer
- type JoinOptions
- type MediaConfig
- type MediaError
- type MediaTrack
- type MeshCallRoom
- func (r MeshCallRoom) Close(ctx context.Context) error
- func (r MeshCallRoom) DisableVideo(ctx context.Context, userID string) error
- func (r MeshCallRoom) EnableVideo(ctx context.Context, userID string) error
- func (r MeshCallRoom) GetParticipants() []Participant
- func (r MeshCallRoom) GetPeer(userID string) (PeerConnection, error)
- func (r MeshCallRoom) GetPeers() []PeerConnection
- func (r MeshCallRoom) GetQuality(ctx context.Context) (*CallQuality, error)
- func (r MeshCallRoom) ID() string
- func (r *MeshCallRoom) JoinCall(ctx context.Context, userID string, opts *JoinOptions) (PeerConnection, error)
- func (r MeshCallRoom) Leave(ctx context.Context, userID string) error
- func (r MeshCallRoom) MuteUser(ctx context.Context, userID string) error
- func (r MeshCallRoom) Name() string
- func (r MeshCallRoom) StartScreenShare(ctx context.Context, userID string, track MediaTrack) error
- func (r MeshCallRoom) StopScreenShare(ctx context.Context, userID string) error
- func (r MeshCallRoom) UnmuteUser(ctx context.Context, userID string) error
- type OfferHandler
- type Participant
- type PeerConnection
- type PeerStats
- type QualityChangeHandler
- type QualityConfig
- type QualityLayer
- type QualityMonitor
- type QualitySample
- type RecordOptions
- type Recorder
- type RecorderConfig
- type RecordingOptions
- type RecordingStats
- type RecordingStatus
- type RouterStats
- type SFUCallRoom
- func (r SFUCallRoom) Close(ctx context.Context) error
- func (r SFUCallRoom) DisableVideo(ctx context.Context, userID string) error
- func (r SFUCallRoom) EnableVideo(ctx context.Context, userID string) error
- func (r SFUCallRoom) GetParticipants() []Participant
- func (r SFUCallRoom) GetPeer(userID string) (PeerConnection, error)
- func (r SFUCallRoom) GetPeers() []PeerConnection
- func (r SFUCallRoom) GetQuality(ctx context.Context) (*CallQuality, error)
- func (r SFUCallRoom) ID() string
- func (r *SFUCallRoom) JoinCall(ctx context.Context, userID string, opts *JoinOptions) (PeerConnection, error)
- func (r SFUCallRoom) Leave(ctx context.Context, userID string) error
- func (r SFUCallRoom) MuteUser(ctx context.Context, userID string) error
- func (r SFUCallRoom) Name() string
- func (r SFUCallRoom) StartScreenShare(ctx context.Context, userID string, track MediaTrack) error
- func (r SFUCallRoom) StopScreenShare(ctx context.Context, userID string) error
- func (r SFUCallRoom) UnmuteUser(ctx context.Context, userID string) error
- type SFUConfig
- type SFURouter
- type SFUStats
- type SessionDescription
- type SessionDescriptionType
- type SignalingError
- type SignalingManager
- type SimulcastLayer
- type TURNConfig
- type Topology
- type TrackHandler
- type TrackInfo
- type TrackKind
- type TrackReceiver
- type TrackSettings
- type TrackStats
Constants ¶
const ( MessageTypeOffer = "webrtc.offer" MessageTypeAnswer = "webrtc.answer" MessageTypeICECandidate = "webrtc.ice_candidate" )
Message types for signaling
Variables ¶
var ( // Configuration errors ErrInvalidConfig = errors.New("webrtc: invalid configuration") ErrNoICEServers = errors.New("webrtc: no ICE servers configured") ErrInvalidBitrateRange = errors.New("webrtc: invalid bitrate range") // Connection errors ErrPeerNotFound = errors.New("webrtc: peer not found") ErrPeerAlreadyExists = errors.New("webrtc: peer already exists") ErrConnectionFailed = errors.New("webrtc: connection failed") ErrConnectionClosed = errors.New("webrtc: connection closed") ErrInvalidConnectionState = errors.New("webrtc: invalid connection state") // Signaling errors ErrSignalingFailed = errors.New("webrtc: signaling failed") ErrInvalidSDP = errors.New("webrtc: invalid SDP") ErrInvalidCandidate = errors.New("webrtc: invalid ICE candidate") ErrSignalingTimeout = errors.New("webrtc: signaling timeout") // Media errors ErrTrackNotFound = errors.New("webrtc: track not found") ErrInvalidTrackKind = errors.New("webrtc: invalid track kind") ErrMediaNotSupported = errors.New("webrtc: media type not supported") ErrCodecNotSupported = errors.New("webrtc: codec not supported") // Room errors ErrRoomNotFound = errors.New("webrtc: room not found") ErrRoomFull = errors.New("webrtc: room is full") ErrNotInRoom = errors.New("webrtc: not in room") ErrAlreadyInRoom = errors.New("webrtc: already in room") // Data channel errors ErrDataChannelClosed = errors.New("webrtc: data channel closed") ErrDataChannelFailed = errors.New("webrtc: data channel failed") // Recording errors ErrRecordingFailed = errors.New("webrtc: recording failed") ErrNotRecording = errors.New("webrtc: not recording") ErrAlreadyRecording = errors.New("webrtc: already recording") // SFU errors ErrSFUNotEnabled = errors.New("webrtc: SFU not enabled") ErrRoutingFailed = errors.New("webrtc: media routing failed") ErrReceiverNotFound = errors.New("webrtc: receiver not found") // Auth errors ErrForbidden = errors.New("webrtc: forbidden") // General errors ErrNotImplemented = errors.New("webrtc: not implemented - requires additional setup") )
Common errors
Functions ¶
This section is empty.
Types ¶
type AnswerHandler ¶
type AnswerHandler func(peerID string, answer *SessionDescription)
Callback handlers
type CallQuality ¶
type CallQuality struct {
RoomID string
ParticipantCount int
AverageQuality float64 // 0-100
PacketLoss float64
Jitter time.Duration
Latency time.Duration
Participants map[string]*ConnectionQuality
}
CallQuality holds overall call quality metrics
type CallRoom ¶
type CallRoom interface {
// ID returns room ID
ID() string
// Name returns room name
Name() string
// Join joins the call
JoinCall(ctx context.Context, userID string, options *JoinOptions) (PeerConnection, error)
// Leave leaves the call
Leave(ctx context.Context, userID string) error
// GetPeer returns peer connection for user
GetPeer(userID string) (PeerConnection, error)
// GetPeers returns all peer connections
GetPeers() []PeerConnection
// GetParticipants returns participant information
GetParticipants() []Participant
// MuteUser mutes a user's audio
MuteUser(ctx context.Context, userID string) error
// UnmuteUser unmutes a user's audio
UnmuteUser(ctx context.Context, userID string) error
// EnableVideo enables user's video
EnableVideo(ctx context.Context, userID string) error
// DisableVideo disables user's video
DisableVideo(ctx context.Context, userID string) error
StartScreenShare(ctx context.Context, userID string, track MediaTrack) error
StopScreenShare(ctx context.Context, userID string) error
// GetQuality returns call quality metrics
GetQuality(ctx context.Context) (*CallQuality, error)
// Close closes the call room
Close(ctx context.Context) error
}
CallRoom represents a WebRTC call room
func NewMeshCallRoom ¶
func NewMeshCallRoom( streamingRoom streaming.Room, config Config, signaling SignalingManager, logger forge.Logger, metrics forge.Metrics, ) CallRoom
NewMeshCallRoom creates a call room with mesh topology
func NewMeshCallRoomFromOptions ¶
func NewMeshCallRoomFromOptions( opts streaming.RoomOptions, config Config, signaling SignalingManager, logger forge.Logger, metrics forge.Metrics, ) (CallRoom, error)
NewMeshCallRoomFromOptions creates a mesh call room from streaming room options
func NewSFUCallRoomFromOptions ¶
func NewSFUCallRoomFromOptions( opts streaming.RoomOptions, config Config, signaling SignalingManager, router SFURouter, logger forge.Logger, metrics forge.Metrics, ) (CallRoom, error)
NewSFUCallRoomFromOptions creates an SFU call room from streaming room options
type Config ¶
type Config struct {
// Signaling
SignalingEnabled bool
SignalingTimeout time.Duration
// Topology
Topology Topology
// STUN servers for NAT traversal
STUNServers []string
// TURN servers for relaying when P2P fails
TURNServers []TURNConfig
// Media configuration
MediaConfig MediaConfig
// SFU configuration (if topology is SFU)
SFUConfig *SFUConfig
// Quality settings
QualityConfig QualityConfig
// Recording
RecordingEnabled bool
RecordingPath string
// Metrics
MetricsEnabled bool
// Security
RequireAuth bool
AllowGuests bool
}
Config holds WebRTC extension configuration
func (*Config) GetICEServers ¶
GetICEServers returns all configured ICE servers
type ConfigOption ¶
type ConfigOption func(*Config)
ConfigOption is a functional option for Config
func WithAudioCodecs ¶
func WithAudioCodecs(codecs ...string) ConfigOption
WithAudioCodecs sets audio codecs
func WithQualityMonitoring ¶
func WithQualityMonitoring(config QualityConfig) ConfigOption
WithQualityMonitoring enables quality monitoring
func WithSFU ¶
func WithSFU(config SFUConfig) ConfigOption
WithSFU enables SFU mode with configuration
func WithSTUNServers ¶
func WithSTUNServers(servers ...string) ConfigOption
WithSTUNServers sets STUN servers
func WithTURNServer ¶
func WithTURNServer(turn TURNConfig) ConfigOption
WithTURNServer adds a TURN server
func WithTopology ¶
func WithTopology(topology Topology) ConfigOption
WithTopology sets the connection topology
func WithVideoCodecs ¶
func WithVideoCodecs(codecs ...string) ConfigOption
WithVideoCodecs sets video codecs
type ConnectionError ¶
type ConnectionError struct {
PeerID string
State ConnectionState
Err error
}
ConnectionError wraps connection errors with context
func (*ConnectionError) Error ¶
func (e *ConnectionError) Error() string
func (*ConnectionError) Unwrap ¶
func (e *ConnectionError) Unwrap() error
type ConnectionQuality ¶
type ConnectionQuality struct {
Score float64 // 0-100
PacketLoss float64 // Percentage
Jitter time.Duration
Latency time.Duration
BitrateKbps int
Warnings []string
LastUpdated time.Time
}
ConnectionQuality holds connection quality metrics
type ConnectionState ¶
type ConnectionState string
ConnectionState represents peer connection state
const ( ConnectionStateNew ConnectionState = "new" ConnectionStateConnecting ConnectionState = "connecting" ConnectionStateConnected ConnectionState = "connected" ConnectionStateDisconnected ConnectionState = "disconnected" ConnectionStateFailed ConnectionState = "failed" ConnectionStateClosed ConnectionState = "closed" )
type ConnectionStateHandler ¶
type ConnectionStateHandler func(state ConnectionState)
Callback handlers
type DataChannel ¶
type DataChannel interface {
// ID returns channel ID
ID() string
// Label returns channel label
Label() string
// State returns channel state
State() DataChannelState
// Send sends data
Send(data []byte) error
// SendText sends text
SendText(text string) error
// OnMessage sets message callback
OnMessage(handler DataChannelMessageHandler)
// OnOpen sets open callback
OnOpen(handler DataChannelStateHandler)
// OnClose sets close callback
OnClose(handler DataChannelStateHandler)
// Close closes the channel
Close() error
}
DataChannel represents a WebRTC data channel
func NewDataChannel ¶
func NewDataChannel(pc *webrtc.PeerConnection, label string, ordered bool, logger forge.Logger) (DataChannel, error)
NewDataChannel creates a new data channel on a peer connection
type DataChannelState ¶
type DataChannelState string
DataChannelState represents data channel state
const ( DataChannelStateConnecting DataChannelState = "connecting" DataChannelStateOpen DataChannelState = "open" DataChannelStateClosing DataChannelState = "closing" DataChannelStateClosed DataChannelState = "closed" )
type Extension ¶
type Extension struct {
// contains filtered or unexported fields
}
Extension is the WebRTC extension
func New ¶
func New(streamingExt *streaming.Extension, config Config, opts ...ConfigOption) (*Extension, error)
New creates a new WebRTC extension
func (*Extension) CreateCallRoom ¶
func (e *Extension) CreateCallRoom(ctx context.Context, roomID string, opts streaming.RoomOptions) (CallRoom, error)
CreateCallRoom creates a new call room
func (*Extension) DeleteCallRoom ¶
DeleteCallRoom deletes a call room
func (*Extension) Dependencies ¶
Dependencies returns the extensions this extension depends on
func (*Extension) Description ¶
Description returns the extension description
func (*Extension) GetCallRoom ¶
GetCallRoom retrieves a call room
func (*Extension) GetCallRooms ¶
GetCallRooms returns all call rooms
func (*Extension) GetQualityMonitor ¶
func (e *Extension) GetQualityMonitor() QualityMonitor
GetQualityMonitor returns the quality monitor
func (*Extension) GetRecorder ¶
GetRecorder returns the recorder
func (*Extension) GetSFURouter ¶
GetSFURouter returns the SFU router (if enabled)
func (*Extension) GetSignalingManager ¶
func (e *Extension) GetSignalingManager() SignalingManager
GetSignalingManager returns the signaling manager
func (*Extension) JoinCall ¶
func (e *Extension) JoinCall(ctx context.Context, roomID, userID string, opts *JoinOptions) (PeerConnection, error)
JoinCall is a convenience method to join a call
func (*Extension) RegisterRoutes ¶
RegisterRoutes registers WebRTC HTTP routes
type ICECandidate ¶
type ICECandidate struct {
Candidate string
SDPMid string
SDPMLineIndex int
UsernameFragment string
}
ICECandidate represents an ICE candidate
type ICECandidateReceivedHandler ¶
type ICECandidateReceivedHandler func(peerID string, candidate *ICECandidate)
Callback handlers
type JoinOptions ¶
type JoinOptions struct {
AudioEnabled bool
VideoEnabled bool
DisplayName string
Metadata map[string]any
}
JoinOptions holds options for joining a call
type MediaConfig ¶
type MediaConfig struct {
// Audio
AudioEnabled bool
AudioCodecs []string // ["opus", "pcmu", "pcma"]
// Video
VideoEnabled bool
VideoCodecs []string // ["VP8", "VP9", "H264", "AV1"]
ScreenShareEnabled bool
// Data channels
DataChannelsEnabled bool
// Bitrate limits (kbps)
MaxAudioBitrate int
MaxVideoBitrate int
MinVideoBitrate int
// Resolution constraints
MaxWidth int
MaxHeight int
MaxFPS int
}
MediaConfig holds media stream configuration
type MediaError ¶
MediaError wraps media errors with context
func (*MediaError) Error ¶
func (e *MediaError) Error() string
func (*MediaError) Unwrap ¶
func (e *MediaError) Unwrap() error
type MediaTrack ¶
type MediaTrack interface {
// ID returns the track ID
ID() string
// Kind returns track kind ("audio" or "video")
Kind() TrackKind
// Label returns track label
Label() string
// Enabled returns if track is enabled
Enabled() bool
// SetEnabled enables/disables track
SetEnabled(enabled bool)
// GetSettings returns track settings
GetSettings() TrackSettings
// GetStats returns track statistics
GetStats(ctx context.Context) (*TrackStats, error)
// Close stops the track
Close() error
}
MediaTrack represents a media track (audio/video)
func NewLocalTrack ¶
NewLocalTrack creates a new local media track
type MeshCallRoom ¶
type MeshCallRoom struct {
// contains filtered or unexported fields
}
MeshCallRoom implements CallRoom with mesh topology
func (MeshCallRoom) DisableVideo ¶
DisableVideo disables user's video
func (MeshCallRoom) EnableVideo ¶
EnableVideo enables user's video
func (MeshCallRoom) GetParticipants ¶
func (r MeshCallRoom) GetParticipants() []Participant
GetParticipants returns participant information
func (MeshCallRoom) GetPeer ¶
func (r MeshCallRoom) GetPeer(userID string) (PeerConnection, error)
GetPeer returns peer connection for user
func (MeshCallRoom) GetPeers ¶
func (r MeshCallRoom) GetPeers() []PeerConnection
GetPeers returns all peer connections
func (MeshCallRoom) GetQuality ¶
func (r MeshCallRoom) GetQuality(ctx context.Context) (*CallQuality, error)
GetQuality returns call quality metrics (stub implementation)
func (*MeshCallRoom) JoinCall ¶
func (r *MeshCallRoom) JoinCall(ctx context.Context, userID string, opts *JoinOptions) (PeerConnection, error)
JoinCall joins the mesh call
func (MeshCallRoom) StartScreenShare ¶
func (r MeshCallRoom) StartScreenShare(ctx context.Context, userID string, track MediaTrack) error
StartScreenShare starts screen sharing (stub implementation)
func (MeshCallRoom) StopScreenShare ¶
StopScreenShare stops screen sharing (stub implementation)
type OfferHandler ¶
type OfferHandler func(peerID string, offer *SessionDescription)
Callback handlers
type Participant ¶
type Participant struct {
UserID string
DisplayName string
AudioEnabled bool
VideoEnabled bool
ScreenSharing bool
Quality *ConnectionQuality
JoinedAt time.Time
}
Participant represents a call participant
type PeerConnection ¶
type PeerConnection interface {
// ID returns the peer connection ID
ID() string
// UserID returns the user ID associated with this peer
UserID() string
// State returns the current connection state
State() ConnectionState
// CreateOffer creates an SDP offer
CreateOffer(ctx context.Context) (*SessionDescription, error)
// CreateAnswer creates an SDP answer
CreateAnswer(ctx context.Context) (*SessionDescription, error)
// SetLocalDescription sets local SDP
SetLocalDescription(ctx context.Context, sdp *SessionDescription) error
// SetRemoteDescription sets remote SDP
SetRemoteDescription(ctx context.Context, sdp *SessionDescription) error
// AddICECandidate adds an ICE candidate
AddICECandidate(ctx context.Context, candidate *ICECandidate) error
// AddTrack adds a media track
AddTrack(ctx context.Context, track MediaTrack) error
// RemoveTrack removes a media track
RemoveTrack(ctx context.Context, trackID string) error
// GetTracks returns all media tracks
GetTracks() []MediaTrack
// GetStats returns connection statistics
GetStats(ctx context.Context) (*PeerStats, error)
// Close closes the peer connection
Close(ctx context.Context) error
// OnICECandidate sets ICE candidate callback
OnICECandidate(handler ICECandidateHandler)
// OnTrack sets track received callback
OnTrack(handler TrackHandler)
// OnConnectionStateChange sets state change callback
OnConnectionStateChange(handler ConnectionStateHandler)
// OnDataChannel sets data channel callback
OnDataChannel(handler DataChannelHandler)
}
PeerConnection represents a WebRTC peer connection
func NewPeerConnection ¶
func NewPeerConnection(id, userID string, config Config, logger forge.Logger) (PeerConnection, error)
NewPeerConnection creates a new peer connection
type PeerStats ¶
type PeerStats struct {
PeerID string
ConnectionState ConnectionState
LocalCandidateType string
RemoteCandidateType string
BytesSent uint64
BytesReceived uint64
PacketsSent uint64
PacketsReceived uint64
PacketsLost uint64
Jitter time.Duration
RoundTripTime time.Duration
AvailableBitrate int
}
PeerStats holds peer connection statistics
type QualityChangeHandler ¶
type QualityChangeHandler func(peerID string, quality *ConnectionQuality)
Callback handlers
type QualityConfig ¶
type QualityConfig struct {
// Monitoring
MonitorEnabled bool
MonitorInterval time.Duration
// Thresholds for quality warnings
MaxPacketLoss float64 // Percentage
MaxJitter time.Duration
MinBitrate int // kbps
// Adaptive quality
AdaptiveQuality bool
QualityCheckInterval time.Duration
}
QualityConfig holds quality monitoring configuration
func DefaultQualityConfig ¶
func DefaultQualityConfig() QualityConfig
DefaultQualityConfig returns default quality monitoring configuration
type QualityLayer ¶
type QualityLayer struct {
RID string // "f" (full), "h" (half), "q" (quarter)
MaxWidth int
MaxHeight int
MaxFPS int
Bitrate int
}
QualityLayer represents a simulcast quality layer
type QualityMonitor ¶
type QualityMonitor interface {
// Monitor starts monitoring peer connection
Monitor(ctx context.Context, peer PeerConnection) error
// Stop stops monitoring
Stop(peerID string)
// GetQuality returns current quality metrics
GetQuality(peerID string) (*ConnectionQuality, error)
// OnQualityChange sets quality change callback
OnQualityChange(handler QualityChangeHandler)
}
QualityMonitor monitors connection quality
func NewQualityMonitor ¶
func NewQualityMonitor(peerID string, peer PeerConnection, config QualityConfig, logger forge.Logger, metrics forge.Metrics) QualityMonitor
NewQualityMonitor creates a new quality monitor
type QualitySample ¶
type QualitySample struct {
Timestamp time.Time
PacketLoss float64
Jitter time.Duration
RTT time.Duration
Bitrate uint64
AvailableBitrate uint64
}
QualitySample represents a quality measurement at a point in time
type RecordOptions ¶
type RecordOptions struct {
Format string
Quality string
AudioOnly bool
VideoOnly bool
MaxDuration time.Duration
}
RecordOptions holds recording configuration options
type Recorder ¶
type Recorder interface {
// Start starts recording
Start(ctx context.Context, roomID string, options *RecordingOptions) error
// Stop stops recording
Stop(ctx context.Context, roomID string) error
// Pause pauses recording
Pause(ctx context.Context, roomID string) error
// Resume resumes recording
Resume(ctx context.Context, roomID string) error
// GetStatus returns recording status
GetStatus(roomID string) (*RecordingStatus, error)
}
Recorder handles call recording
func NewRecorder ¶
func NewRecorder(roomID string, config RecorderConfig, logger forge.Logger, metrics forge.Metrics) (Recorder, error)
NewRecorder creates a new media recorder
type RecorderConfig ¶
type RecorderConfig struct {
OutputDir string
AudioCodec string // opus, pcm
VideoCodec string // vp8, h264
EnableAudio bool
EnableVideo bool
MaxDuration time.Duration
FileNamePrefix string
}
RecorderConfig holds recording configuration
func DefaultRecorderConfig ¶
func DefaultRecorderConfig() RecorderConfig
DefaultRecorderConfig returns default recorder configuration
type RecordingOptions ¶
type RecordingOptions struct {
Format string // "webm", "mp4"
VideoCodec string
AudioCodec string
OutputPath string
IncludeChat bool
}
RecordingOptions holds recording options
type RecordingStats ¶
type RecordingStats struct {
Duration time.Duration
FileSize uint64
Bitrate int
FrameRate int
AudioTracks int
VideoTracks int
StartTime time.Time
EndTime time.Time
}
RecordingStats holds recording statistics
type RecordingStatus ¶
type RecordingStatus struct {
RoomID string
Recording bool
Paused bool
StartedAt time.Time
Duration time.Duration
FileSize int64
OutputPath string
}
RecordingStatus represents recording status
type RouterStats ¶
type RouterStats struct {
TotalTracks int
ActiveReceivers int
TotalBytesSent uint64
TotalBytesReceived uint64
AverageBitrate int
}
RouterStats holds SFU router statistics
type SFUCallRoom ¶
type SFUCallRoom struct {
// contains filtered or unexported fields
}
SFUCallRoom implements CallRoom with SFU topology
func (SFUCallRoom) DisableVideo ¶
DisableVideo disables user's video
func (SFUCallRoom) EnableVideo ¶
EnableVideo enables user's video
func (SFUCallRoom) GetParticipants ¶
func (r SFUCallRoom) GetParticipants() []Participant
GetParticipants returns participant information
func (SFUCallRoom) GetPeer ¶
func (r SFUCallRoom) GetPeer(userID string) (PeerConnection, error)
GetPeer returns peer connection for user
func (SFUCallRoom) GetPeers ¶
func (r SFUCallRoom) GetPeers() []PeerConnection
GetPeers returns all peer connections
func (SFUCallRoom) GetQuality ¶
func (r SFUCallRoom) GetQuality(ctx context.Context) (*CallQuality, error)
GetQuality returns call quality metrics (stub implementation)
func (*SFUCallRoom) JoinCall ¶
func (r *SFUCallRoom) JoinCall(ctx context.Context, userID string, opts *JoinOptions) (PeerConnection, error)
JoinCall joins the SFU call
func (SFUCallRoom) StartScreenShare ¶
func (r SFUCallRoom) StartScreenShare(ctx context.Context, userID string, track MediaTrack) error
StartScreenShare starts screen sharing (stub implementation)
func (SFUCallRoom) StopScreenShare ¶
StopScreenShare stops screen sharing (stub implementation)
type SFUConfig ¶
type SFUConfig struct {
// Worker configuration
WorkerCount int
// Bandwidth management
MaxBandwidthMbps int
AdaptiveBitrate bool
SimulcastEnabled bool
// Quality layers for simulcast
QualityLayers []QualityLayer
// Recording
RecordingEnabled bool
RecordingFormat string // "webm", "mp4"
}
SFUConfig holds SFU-specific configuration
type SFURouter ¶
type SFURouter interface {
// RouteTrack routes a track from sender to receivers
RouteTrack(ctx context.Context, senderID string, track MediaTrack, receiverIDs []string) error
// AddPublisher adds a publishing peer
AddPublisher(ctx context.Context, userID string, peer PeerConnection) error
// AddSubscriber adds a subscribing peer
AddSubscriber(ctx context.Context, userID string, peer PeerConnection) error
// RemovePublisher removes a publishing peer
RemovePublisher(ctx context.Context, userID string) error
// RemoveSubscriber removes a subscribing peer
RemoveSubscriber(ctx context.Context, userID string) error
// SubscribeToTrack subscribes a peer to a publisher's track
SubscribeToTrack(ctx context.Context, subscriberID, publisherID, trackID string) error
// UnsubscribeFromTrack unsubscribes a peer from a track
UnsubscribeFromTrack(ctx context.Context, subscriberID, trackID string) error
// AddReceiver adds a receiver for a track
AddReceiver(ctx context.Context, trackID, receiverID string) error
// RemoveReceiver removes a receiver
RemoveReceiver(ctx context.Context, trackID, receiverID string) error
// GetReceivers returns all receivers for a track
GetReceivers(trackID string) []string
// SetQuality sets quality layer for receiver
SetQuality(ctx context.Context, trackID, receiverID, quality string) error
// GetStats returns routing statistics
GetStats(ctx context.Context) (*RouterStats, error)
// GetAvailableTracks returns all available tracks
GetAvailableTracks() []TrackInfo
}
SFURouter handles media routing in SFU mode
type SFUStats ¶
type SFUStats struct {
TotalTracks int
ActiveReceivers int
TotalBytesSent uint64
TotalBytesReceived uint64
AverageBitrate int
Timestamp time.Time
}
SFUStats holds SFU router statistics
type SessionDescription ¶
type SessionDescription struct {
Type SessionDescriptionType
SDP string
}
SessionDescription represents SDP
type SessionDescriptionType ¶
type SessionDescriptionType string
SessionDescriptionType is the type of SDP
const ( SessionDescriptionTypeOffer SessionDescriptionType = "offer" SessionDescriptionTypeAnswer SessionDescriptionType = "answer" )
type SignalingError ¶
type SignalingError struct {
Op string // Operation that failed
PeerID string
RoomID string
Err error
}
SignalingError wraps signaling errors with context
func (*SignalingError) Error ¶
func (e *SignalingError) Error() string
func (*SignalingError) Unwrap ¶
func (e *SignalingError) Unwrap() error
type SignalingManager ¶
type SignalingManager interface {
// SendOffer sends SDP offer to peer
SendOffer(ctx context.Context, roomID, peerID string, offer *SessionDescription) error
// SendAnswer sends SDP answer to peer
SendAnswer(ctx context.Context, roomID, peerID string, answer *SessionDescription) error
// SendICECandidate sends ICE candidate to peer
SendICECandidate(ctx context.Context, roomID, peerID string, candidate *ICECandidate) error
// OnOffer sets offer received callback
OnOffer(handler OfferHandler)
// OnAnswer sets answer received callback
OnAnswer(handler AnswerHandler)
// OnICECandidate sets ICE candidate received callback
OnICECandidate(handler ICECandidateReceivedHandler)
// Start begins listening for signaling messages
Start(ctx context.Context) error
// Stop stops listening
Stop(ctx context.Context) error
}
SignalingManager handles WebRTC signaling via streaming
func NewSignalingManager ¶
func NewSignalingManager(streamingExt *streaming.Extension, logger forge.Logger) SignalingManager
NewSignalingManager creates a new signaling manager
type SimulcastLayer ¶
SimulcastLayer represents a simulcast layer
type TURNConfig ¶
type TURNConfig struct {
URLs []string
Username string
Credential string
// TLS configuration
TLSEnabled bool
TLSCertFile string
TLSKeyFile string
}
TURNConfig holds TURN server configuration
type TrackHandler ¶
type TrackHandler func(track MediaTrack, receiver *TrackReceiver)
Callback handlers
type TrackReceiver ¶
type TrackReceiver struct {
TrackID string
PeerID string
Kind TrackKind
Settings TrackSettings
}
TrackReceiver receives a track