sip

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2026 License: Apache-2.0 Imports: 66 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoomSampleRate = 48000
	RoomResample   = false
)
View Source
const (
	AttrSIPCallIDFull = livekit.AttrSIPPrefix + "callIDFull"
	AttrSIPCallTag    = livekit.AttrSIPPrefix + "callTag"
)
View Source
const (
	CallDialing
	CallRinging
	CallAutomation
	CallActive
	CallHangup
)
View Source
const (
	AuthNotFound = AuthResult(iota)
	AuthDrop
	AuthPassword
	AuthAccept
	AuthQuotaExceeded
	AuthNoTrunkFound
)
View Source
const (
	DispatchAccept = DispatchResult(iota)
	DispatchRequestPin
	DispatchNoRuleReject // reject the call with an error
	DispatchNoRuleDrop   // silently drop the call
)
View Source
const (
	// DefaultInitialNoiseFloorDB is the default noise floor in dBFS.
	DefaultInitialNoiseFloorDB = -50
	// DefaultHangoverDuration is how long we stay in "signal" after level drops below exit threshold.
	DefaultHangoverDuration = 1 * time.Second
	// DefaultEnterVoiceOffsetDB is the default offset above noise floor to enter voice (hysteresis high).
	DefaultEnterVoiceOffsetDB = 10
	// DefaultExitVoiceOffsetDB is the default offset above noise floor to exit voice (hysteresis low).
	DefaultExitVoiceOffsetDB = 5
)
View Source
const (
	TransportUDP = Transport("udp")
	TransportTCP = Transport("tcp")
	TransportTLS = Transport("tls")
)
View Source
const (
	UserAgent = "LiveKit"
)

Variables

View Source
var Tracer = otel.Tracer(
	"github.com/livekit/sip",
	trace.WithInstrumentationAttributes(getSIPVersions()...),
)

Functions

func AttrsToHeaders

func AttrsToHeaders(attrs, attrToHdr, headers map[string]string) map[string]string

func ConfigureTLS

func ConfigureTLS(c *tls.Config)

func Diff16 added in v1.3.0

func Diff16(cur, prev uint16) int16

func HeadersToAttrs

func HeadersToAttrs(attrs, hdrToAttr map[string]string, opts livekit.SIPHeaderOptions, c Signaling, headers Headers) map[string]string

func LoggerWithHeaders

func LoggerWithHeaders(log logger.Logger, c Signaling) logger.Logger

func NewReferRequest

func NewReferRequest(inviteRequest *sip.Request, inviteResponse *sip.Response, contactHeader *sip.ContactHeader, referToUrl string, headers map[string]string) *sip.Request

func NewSignalLogger added in v1.3.0

func NewSignalLogger(log logger.Logger, name string, next msdk.PCM16Writer, options ...SignalLoggerOption) (msdk.PCM16Writer, error)

func SIPTransportFrom

func SIPTransportFrom(t Transport) livekit.SIPTransport

func SelectValue

func SelectValue[T any](then, els T, probElse float64) T

func SelectValueBool

func SelectValueBool(then bool, probElse float64) bool

func ToSIPUri

func ToSIPUri(ip string, u sip.Uri) *livekit.SIPUri

Types

type ActiveCalls

type ActiveCalls struct {
	Inbound   int
	Outbound  int
	SampleIDs []string
}

func (ActiveCalls) Total

func (st ActiveCalls) Total() int

type AuthInfo

type AuthInfo struct {
	Result       AuthResult
	ProjectID    string
	TrunkID      string
	Username     string
	Password     string
	ProviderInfo *livekit.ProviderInfo
}

type AuthResult

type AuthResult int

type CallDispatch

type CallDispatch struct {
	Result              DispatchResult
	Room                RoomConfig
	ProjectID           string
	TrunkID             string
	DispatchRuleID      string
	Headers             map[string]string
	HeadersToAttributes map[string]string
	IncludeHeaders      livekit.SIPHeaderOptions
	AttributesToHeaders map[string]string
	EnabledFeatures     []livekit.SIPFeature
	FeatureFlags        map[string]string
	RingingTimeout      time.Duration
	MaxCallDuration     time.Duration
	MediaEncryption     livekit.SIPMediaEncryption
}

type CallIdentifier

type CallIdentifier struct {
	TraceID   traceid.ID
	ProjectID string
	CallID    string
	SipCallID string
}

type CallInfo

type CallInfo struct {
	TrunkID string
	Call    *rpc.SIPCall
	Pin     string
	NoPin   bool
}

type CallState

type CallState struct {
	// contains filtered or unexported fields
}

func NewCallState

func NewCallState(cli StateUpdater, initial *livekit.SIPCallInfo) *CallState

func (*CallState) DeferUpdate

func (s *CallState) DeferUpdate(update func(info *livekit.SIPCallInfo))

func (*CallState) EndTransfer

func (s *CallState) EndTransfer(ctx context.Context, transferID string, inErr error)

func (*CallState) Flush

func (s *CallState) Flush(ctx context.Context)

func (*CallState) ForceFlush

func (s *CallState) ForceFlush(ctx context.Context)

func (*CallState) StartTransfer

func (s *CallState) StartTransfer(ctx context.Context, transferTo string) string

func (*CallState) Update

func (s *CallState) Update(ctx context.Context, update func(info *livekit.SIPCallInfo))

type CallStatus

type CallStatus int

func (CallStatus) Attribute

func (v CallStatus) Attribute() string

func (CallStatus) DisconnectReason

func (v CallStatus) DisconnectReason() livekit.DisconnectReason

func (CallStatus) SIPStatus

func (v CallStatus) SIPStatus() (sip.StatusCode, string)

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(region string, conf *config.Config, log logger.Logger, mon *stats.Monitor, getIOClient GetIOInfoClient, options ...ClientOption) *Client

func (*Client) ContactURI

func (c *Client) ContactURI(tr Transport) URI

func (*Client) DeregisterTransferSIPParticipant

func (c *Client) DeregisterTransferSIPParticipant(sipCallID string)

func (*Client) OnRequest

func (c *Client) OnRequest(req *sip.Request, tx sip.ServerTransaction) bool

func (*Client) RegisterTransferSIPParticipant

func (c *Client) RegisterTransferSIPParticipant(sipCallID string, o *outboundCall) error

func (*Client) SetHandler

func (c *Client) SetHandler(handler Handler)

func (*Client) Start

func (c *Client) Start(agent *sipgo.UserAgent, sc *ServiceConfig) error

func (*Client) Stop

func (c *Client) Stop()

type ClientOption added in v1.3.0

type ClientOption func(c *Client)

func WithGetRoomClient added in v1.3.0

func WithGetRoomClient(fn GetRoomFunc) ClientOption

func WithGetSipClient added in v1.3.0

func WithGetSipClient(fn GetSipClientFunc) ClientOption

type DispatchResult

type DispatchResult int

type GetIOInfoClient

type GetIOInfoClient func(projectID string) rpc.IOInfoClient

type GetRoomFunc added in v1.3.0

type GetRoomFunc func(log logger.Logger, st *RoomStats) RoomInterface

type GetSipClientFunc added in v1.3.0

type GetSipClientFunc func(ua *sipgo.UserAgent, options ...sipgo.ClientOption) (SIPClient, error)

type Handler

type Handler interface {
	GetAuthCredentials(ctx context.Context, call *rpc.SIPCall) (AuthInfo, error)
	DispatchCall(ctx context.Context, info *CallInfo) CallDispatch
	GetMediaProcessor(features []livekit.SIPFeature, featureFlags map[string]string) msdk.PCM16Processor

	RegisterTransferSIPParticipantTopic(sipCallId string) error
	DeregisterTransferSIPParticipantTopic(sipCallId string)

	OnInboundInfo(log logger.Logger, callInfo *rpc.SIPCall, headers Headers)
	OnSessionEnd(ctx context.Context, callIdentifier *CallIdentifier, callInfo *livekit.SIPCallInfo, reason string)
}

type Headers

type Headers []sip.Header

func (Headers) GetHeader

func (h Headers) GetHeader(name string) sip.Header

type LatencyStats added in v1.3.0

type LatencyStats struct {
	Count atomic.Uint64
	SumNs atomic.Uint64
	MaxNs atomic.Uint64
}

LatencyStats is a lock-free accumulator for per-frame latency measurements. It tracks count, sum (for average), and max.

func (*LatencyStats) Load added in v1.3.0

func (*LatencyStats) Record added in v1.3.0

func (s *LatencyStats) Record(d time.Duration)

type LatencyStatsSnapshot added in v1.3.0

type LatencyStatsSnapshot struct {
	Count uint64 `json:"count"`
	AvgNs uint64 `json:"avg_ns"`
	MaxNs uint64 `json:"max_ns"`
}

type LocalTag

type LocalTag string

func GetLocalTagUAS added in v1.3.0

func GetLocalTagUAS(r *sip.Request) (LocalTag, error)

type MediaConf

type MediaConf struct {
	sdp.MediaConfig
	Processor msdk.PCM16Processor
}

type MediaOptions

type MediaOptions struct {
	IP                  netip.Addr
	Ports               rtcconfig.PortRange
	MediaTimeoutInitial time.Duration
	MediaTimeout        time.Duration
	Stats               *PortStats
	EnableJitterBuffer  bool
	NoInputResample     bool
	IgnorePreanswerData bool
	LogSignalChanges    bool
}

type MediaPort

type MediaPort struct {
	// contains filtered or unexported fields
}

MediaPort combines all functionality related to sending and accepting SIP media.

func NewMediaPort

func NewMediaPort(tid traceid.ID, log logger.Logger, mon *stats.CallMonitor, opts *MediaOptions, sampleRate int) (*MediaPort, error)

func NewMediaPortWith

func NewMediaPortWith(tid traceid.ID, log logger.Logger, mon *stats.CallMonitor, conn UDPConn, opts *MediaOptions, sampleRate int) (*MediaPort, error)

func (*MediaPort) Close

func (p *MediaPort) Close()

func (*MediaPort) Config

func (p *MediaPort) Config() *MediaConf

func (*MediaPort) DisableOut

func (p *MediaPort) DisableOut()

func (*MediaPort) EnableOut

func (p *MediaPort) EnableOut()

func (*MediaPort) EnableTimeout

func (p *MediaPort) EnableTimeout(enabled bool)

func (*MediaPort) GetAudioWriter

func (p *MediaPort) GetAudioWriter() msdk.PCM16Writer

GetAudioWriter returns audio writer that will send PCM to the destination via RTP.

func (*MediaPort) HandleDTMF

func (p *MediaPort) HandleDTMF(h func(ev dtmf.Event))

HandleDTMF sets an incoming DTMF handler.

func (*MediaPort) NewOffer

func (p *MediaPort) NewOffer(encrypted sdp.Encryption) (*sdp.Offer, error)

NewOffer generates an SDP offer for the media.

func (*MediaPort) Port

func (p *MediaPort) Port() int

func (*MediaPort) Received

func (p *MediaPort) Received() <-chan struct{}

func (*MediaPort) SetAnswer

func (p *MediaPort) SetAnswer(offer *sdp.Offer, answerData []byte, enc sdp.Encryption) (*MediaConf, []byte, error)

SetAnswer decodes and applies SDP answer for offer from NewOffer. SetConfig must be called with the decoded configuration.

func (*MediaPort) SetConfig

func (p *MediaPort) SetConfig(c *MediaConf) error

func (*MediaPort) SetDTMFAudio

func (p *MediaPort) SetDTMFAudio(enabled bool)

SetDTMFAudio forces SIP to generate audio dTMF tones in addition to digital signals.

func (*MediaPort) SetOffer

func (p *MediaPort) SetOffer(offerData []byte, enc sdp.Encryption) (*sdp.Answer, *MediaConf, error)

SetOffer decodes the offer from another party and returns encoded answer. To accept the offer, call SetConfig.

func (*MediaPort) SetTimeout

func (p *MediaPort) SetTimeout(initial, general time.Duration)

func (*MediaPort) Timeout

func (p *MediaPort) Timeout() <-chan struct{}

func (*MediaPort) WriteAudioTo

func (p *MediaPort) WriteAudioTo(w msdk.PCM16Writer)

WriteAudioTo sets audio writer that will receive decoded PCM from incoming RTP packets.

func (*MediaPort) WriteDTMF

func (p *MediaPort) WriteDTMF(ctx context.Context, digits string) error

type MixerStatsSnapshot

type MixerStatsSnapshot struct {
	Tracks       int64  `json:"tracks"`
	TracksTotal  uint64 `json:"tracks_total"`
	Restarts     uint64 `json:"restarts"`
	TimingResets uint64 `json:"timing_resets"`

	Mixes         uint64 `json:"mixes"`
	TimedMixes    uint64 `json:"mixes_timed"`
	JumpMixes     uint64 `json:"mixes_jump"`
	ZeroMixes     uint64 `json:"mixes_zero"`
	NegativeMixes uint64 `json:"mixes_negative"`

	InputSamples        uint64 `json:"input_samples"`
	InputFrames         uint64 `json:"input_frames"`
	InputSamplesDropped uint64 `json:"input_samples_dropped"`
	InputFramesDropped  uint64 `json:"input_frames_dropped"`

	MixedSamples uint64 `json:"mixed_samples"`
	MixedFrames  uint64 `json:"mixed_frames"`

	OutputSamples uint64 `json:"output_samples"`
	OutputFrames  uint64 `json:"output_frames"`

	WriteErrors  uint64 `json:"write_errors"`
	BlockedMixes uint64 `json:"blocked_mixes"`
}

type ParticipantConfig

type ParticipantConfig struct {
	Identity   string
	Name       string
	Metadata   string
	Attributes map[string]string
}

type ParticipantInfo

type ParticipantInfo struct {
	ID       string
	RoomName string
	Identity string
	Name     string
}

type PendingTransfer added in v1.3.0

type PendingTransfer struct {
	CallID     string
	TransferTo string
	Done       chan error
}

type PortStats

type PortStats struct {
	Streams        atomic.Uint64
	Packets        atomic.Uint64
	IgnoredPackets atomic.Uint64
	InputPackets   atomic.Uint64
	FailedPackets  atomic.Uint64

	MuxStats rtpCountingStats

	AudioPackets atomic.Uint64
	AudioBytes   atomic.Uint64

	AudioInFrames   atomic.Uint64
	AudioInSamples  atomic.Uint64
	AudioOutFrames  atomic.Uint64
	AudioOutSamples atomic.Uint64

	AudioRX atomic.Uint64 // based on AudioInSamples
	AudioTX atomic.Uint64 // based on AudioOutSamples

	DTMFPackets atomic.Uint64
	DTMFBytes   atomic.Uint64

	JitterBufferPacketsLost    atomic.Uint64
	JitterBufferPacketsDropped atomic.Uint64

	LatencyInE2E LatencyStats
	LatencyOut   LatencyStats

	Closed atomic.Bool
	// contains filtered or unexported fields
}

func (*PortStats) Load added in v1.3.0

func (s *PortStats) Load() PortStatsSnapshot

func (*PortStats) Update added in v1.3.0

func (s *PortStats) Update()

type PortStatsSnapshot

type PortStatsSnapshot struct {
	Streams        uint64 `json:"streams"`
	Packets        uint64 `json:"packets"`
	IgnoredPackets uint64 `json:"packets_ignored"`
	InputPackets   uint64 `json:"packets_input"`
	FailedPackets  uint64 `json:"packets_failed"`

	MuxPackets        uint64 `json:"mux_packets"`
	MuxBytes          uint64 `json:"mux_bytes"`
	MuxResets         uint64 `json:"mux_resets"`
	MuxGaps           uint64 `json:"mux_gaps"`
	MuxGapsSum        uint64 `json:"mux_gaps_sum"`
	MuxLate           uint64 `json:"mux_late"`
	MuxLateSum        uint64 `json:"mux_late_sum"`
	MuxRapidPackets   uint64 `json:"mux_rapid_packets"`
	MuxDelayedPackets uint64 `json:"mux_delayed_packets"`
	MuxDelayedSum     uint64 `json:"mux_delayed_sum"`

	AudioPackets uint64 `json:"audio_packets"`
	AudioBytes   uint64 `json:"audio_bytes"`

	AudioInFrames   uint64 `json:"audio_in_frames"`
	AudioInSamples  uint64 `json:"audio_in_samples"`
	AudioOutFrames  uint64 `json:"audio_out_frames"`
	AudioOutSamples uint64 `json:"audio_out_samples"`

	AudioRX float64 `json:"audio_rx"`
	AudioTX float64 `json:"audio_tx"`

	DTMFPackets uint64 `json:"dtmf_packets"`
	DTMFBytes   uint64 `json:"dtmf_bytes"`

	JitterBufferPacketsLost    uint64 `json:"jitter_buffer_packets_lost"`
	JitterBufferPacketsDropped uint64 `json:"jitter_buffer_packets_dropped"`

	LatencyInE2E LatencyStatsSnapshot `json:"latency_in_e2e"`
	LatencyOut   LatencyStatsSnapshot `json:"latency_out"`

	Closed bool `json:"closed"`
}

type ReasonHeader

type ReasonHeader struct {
	Type  string
	Cause int
	Text  string
}

func ParseReasonHeader

func ParseReasonHeader(header string) (ReasonHeader, error)

func (ReasonHeader) IsNormal

func (r ReasonHeader) IsNormal() bool

func (ReasonHeader) IsZero

func (r ReasonHeader) IsZero() bool

func (ReasonHeader) String

func (r ReasonHeader) String() string

type RemoteTag

type RemoteTag string

type RequestHandler

type RequestHandler func(req *sip.Request, tx sip.ServerTransaction) bool

type Room

type Room struct {
	// contains filtered or unexported fields
}

func NewRoom

func NewRoom(log logger.Logger, st *RoomStats) *Room

func (*Room) Close

func (r *Room) Close() error

func (*Room) CloseOutput

func (r *Room) CloseOutput() error

func (*Room) CloseWithReason

func (r *Room) CloseWithReason(reason livekit.DisconnectReason) error

func (*Room) Closed

func (r *Room) Closed() <-chan struct{}

func (*Room) Connect

func (r *Room) Connect(conf *config.Config, rconf RoomConfig) error

func (*Room) NewParticipantTrack

func (r *Room) NewParticipantTrack(sampleRate int) (msdk.WriteCloser[msdk.PCM16Sample], error)

func (*Room) NewTrack

func (r *Room) NewTrack() *mixer.Input

func (*Room) Output

func (r *Room) Output() msdk.Writer[msdk.PCM16Sample]

func (*Room) Participant

func (r *Room) Participant() ParticipantInfo

func (*Room) Room

func (r *Room) Room() *lksdk.Room

func (*Room) SendData

func (r *Room) SendData(data lksdk.DataPacket, opts ...lksdk.DataPublishOption) error

func (*Room) SetDTMFOutput

func (r *Room) SetDTMFOutput(w dtmf.Writer)

func (*Room) Subscribe

func (r *Room) Subscribe()

func (*Room) Subscribed

func (r *Room) Subscribed() <-chan struct{}

func (*Room) SwapOutput

func (r *Room) SwapOutput(out msdk.PCM16Writer) msdk.PCM16Writer

SwapOutput sets room audio output and returns the old one. Caller is responsible for closing the old writer.

type RoomConfig

type RoomConfig struct {
	WsUrl            string
	Token            string
	RoomName         string
	Participant      ParticipantConfig
	RoomPreset       string
	RoomConfig       *livekit.RoomConfiguration
	JitterBuf        bool
	LogSignalChanges bool
}

type RoomInterface added in v1.3.0

type RoomInterface interface {
	Connect(conf *config.Config, rconf RoomConfig) error
	Closed() <-chan struct{}
	Subscribed() <-chan struct{}
	Room() *lksdk.Room
	Subscribe()
	Output() msdk.Writer[msdk.PCM16Sample]
	SwapOutput(out msdk.PCM16Writer) msdk.PCM16Writer
	CloseOutput() error
	SetDTMFOutput(w dtmf.Writer)
	Close() error
	CloseWithReason(reason livekit.DisconnectReason) error
	Participant() ParticipantInfo
	NewParticipantTrack(sampleRate int) (msdk.WriteCloser[msdk.PCM16Sample], error)
	SendData(data lksdk.DataPacket, opts ...lksdk.DataPublishOption) error
	NewTrack() *mixer.Input
}

RoomInterface defines the interface for room operations

func DefaultGetRoomFunc added in v1.3.0

func DefaultGetRoomFunc(log logger.Logger, st *RoomStats) RoomInterface

type RoomStats

type RoomStats struct {
	PublishedFrames  atomic.Uint64
	PublishedSamples atomic.Uint64
	PublishTX        atomic.Uint64

	JitterBufferPacketsLost    atomic.Uint64
	JitterBufferPacketsDropped atomic.Uint64

	LatencyOutRecv LatencyStats // measures track recv → opus decode → mixer input.

	Mixer mixer.Stats

	Closed atomic.Bool
	// contains filtered or unexported fields
}

func (*RoomStats) Load added in v1.3.0

func (s *RoomStats) Load() RoomStatsSnapshot

func (*RoomStats) Update added in v1.3.0

func (s *RoomStats) Update()

type RoomStatsSnapshot

type RoomStatsSnapshot struct {
	// Stats quantifying total incoming traffic from all tracks
	InputPackets   uint64 `json:"input_packets"`
	InputBytes     uint64 `json:"input_bytes"`
	Resets         uint64 `json:"resets"`
	Gaps           uint64 `json:"gaps"`
	GapsSum        uint64 `json:"gaps_sum"`
	Late           uint64 `json:"late"`
	LateSum        uint64 `json:"late_sum"`
	DelayedPackets uint64 `json:"delayed_packets"`
	DelayedSum     uint64 `json:"delayed_sum"`
	RapidPackets   uint64 `json:"rapid_packets"`
	DataPackets    uint64 `json:"data_packets"`

	// Stats quantifying total outgoing traffic
	PublishedFrames  uint64  `json:"published_frames"`
	PublishedSamples uint64  `json:"published_samples"`
	PublishTX        float64 `json:"publish_tx"`

	JitterBufferPacketsLost    uint64 `json:"jitter_buffer_packets_lost"`
	JitterBufferPacketsDropped uint64 `json:"jitter_buffer_packets_dropped"`

	LatencyOutRecv LatencyStatsSnapshot `json:"latency_out_recv"`

	Closed bool `json:"closed"`
}

type SDPError added in v1.3.0

type SDPError struct {
	Err error
}

func (SDPError) Error added in v1.3.0

func (e SDPError) Error() string

func (SDPError) Unwrap added in v1.3.0

func (e SDPError) Unwrap() error

type SIPClient added in v1.3.0

type SIPClient interface {
	TransactionRequest(req *sip.Request, options ...sipgo.ClientRequestOption) (sip.ClientTransaction, error)
	WriteRequest(req *sip.Request, options ...sipgo.ClientRequestOption) error
	Close() error
}

An interface mirroring sipgo.Client to be able to mock it in tests. Note: *sipgo.Client implements this interface directly, so no wrapper is needed.

func DefaultGetSipClientFunc added in v1.3.0

func DefaultGetSipClientFunc(ua *sipgo.UserAgent, options ...sipgo.ClientOption) (SIPClient, error)

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(region string, conf *config.Config, log logger.Logger, mon *stats.Monitor, getIOClient GetIOInfoClient, options ...ServerOption) *Server

func (*Server) ContactURI

func (s *Server) ContactURI(tr Transport) URI

func (*Server) DeregisterTransferSIPParticipant

func (s *Server) DeregisterTransferSIPParticipant(sipCallID LocalTag)

func (*Server) OnNoRoute

func (s *Server) OnNoRoute(log *slog.Logger, req *sip.Request, tx sip.ServerTransaction)

func (*Server) RegisterTransferSIPParticipant

func (s *Server) RegisterTransferSIPParticipant(sipCallID LocalTag, i *inboundCall) error

func (*Server) SetHandler

func (s *Server) SetHandler(handler Handler)

func (*Server) Start

func (s *Server) Start(agent *sipgo.UserAgent, sc *ServiceConfig, tlsConf *tls.Config, unhandled RequestHandler) error

func (*Server) Stop

func (s *Server) Stop()

type ServerOption added in v1.3.0

type ServerOption func(s *Server)

func WithClient added in v1.3.0

func WithClient(cli *Client) ServerOption

func WithGetRoomServer added in v1.3.0

func WithGetRoomServer(fn GetRoomFunc) ServerOption

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(region string, conf *config.Config, mon *stats.Monitor, log logger.Logger, getIOClient GetIOInfoClient) (*Service, error)

func (*Service) ActiveCalls

func (s *Service) ActiveCalls() ActiveCalls

func (*Service) CreateSIPParticipantAffinity

func (s *Service) CreateSIPParticipantAffinity(ctx context.Context, req *rpc.InternalCreateSIPParticipantRequest) float32

func (*Service) SetHandler

func (s *Service) SetHandler(handler Handler)

func (*Service) Start

func (s *Service) Start() error

func (*Service) Stop

func (s *Service) Stop()

func (*Service) TransferSIPParticipant

func (s *Service) TransferSIPParticipant(ctx context.Context, req *rpc.InternalTransferSIPParticipantRequest) (*emptypb.Empty, error)

type ServiceConfig

type ServiceConfig struct {
	SignalingIP      netip.Addr
	SignalingIPLocal netip.Addr
	MediaIP          netip.Addr
}

func GetServiceConfig

func GetServiceConfig(conf *config.Config) (*ServiceConfig, error)

type SignalLogger added in v1.3.0

type SignalLogger struct {
	// contains filtered or unexported fields
}

SignalLogger keeps internal state of whether we're in voice or silence, using RMS → dBFS and a fixed noise floor with hysteresis. It implements msdk.PCM16Writer and logs state changes.

func (*SignalLogger) Close added in v1.3.0

func (s *SignalLogger) Close() error

func (*SignalLogger) SampleRate added in v1.3.0

func (s *SignalLogger) SampleRate() int

func (*SignalLogger) String added in v1.3.0

func (s *SignalLogger) String() string

func (*SignalLogger) WriteSample added in v1.3.0

func (s *SignalLogger) WriteSample(sample msdk.PCM16Sample) error

type SignalLoggerOption added in v1.3.0

type SignalLoggerOption func(*SignalLogger) error

func WithEnterVoiceOffsetDB added in v1.3.0

func WithEnterVoiceOffsetDB(db float64) SignalLoggerOption

WithEnterVoiceOffsetDB sets the offset (dB) above noise floor to enter voice. Default is DefaultEnterVoiceOffsetDB.

func WithExitVoiceOffsetDB added in v1.3.0

func WithExitVoiceOffsetDB(db float64) SignalLoggerOption

WithExitVoiceOffsetDB sets the offset (dB) above noise floor to exit voice. Default is DefaultExitVoiceOffsetDB.

func WithHangoverDuration added in v1.3.0

func WithHangoverDuration(hangoverDuration time.Duration) SignalLoggerOption

func WithNoiseFloor added in v1.3.0

func WithNoiseFloor(noiseFloorDB float64) SignalLoggerOption

WithNoiseFloor sets the noise floor in dBFS (e.g. -40). Must be >= minDBFS.

type Signaling

type Signaling interface {
	Address() sip.Uri
	From() sip.Uri
	To() sip.Uri
	ID() LocalTag
	Tag() RemoteTag
	SIPCallID() string
	RemoteHeaders() Headers

	WriteRequest(req *sip.Request) error
	Transaction(req *sip.Request) (sip.ClientTransaction, error)

	Drop()
}

type SilenceSuppressionOption added in v1.3.0

type SilenceSuppressionOption func(*silenceFiller)

func WithMaxGapSize added in v1.3.0

func WithMaxGapSize(maxGapSize int) SilenceSuppressionOption

type StateUpdater

type StateUpdater interface {
	UpdateSIPCallState(ctx context.Context, req *rpc.UpdateSIPCallStateRequest, opts ...psrpc.RequestOption) (*emptypb.Empty, error)
}

type Stats

type Stats struct {
	Port   PortStats
	Room   RoomStats
	Closed atomic.Bool
}

func (*Stats) Load

func (s *Stats) Load() StatsSnapshot

func (*Stats) Log added in v1.3.0

func (s *Stats) Log(log logger.Logger, callStart time.Time)

func (*Stats) MarshalJSON

func (s *Stats) MarshalJSON() ([]byte, error)

func (*Stats) Update added in v1.3.0

func (s *Stats) Update()

type StatsSnapshot

type StatsSnapshot struct {
	Port   PortStatsSnapshot  `json:"port"`
	Room   RoomStatsSnapshot  `json:"room"`
	Mixer  MixerStatsSnapshot `json:"mixer"`
	Closed bool               `json:"closed"`
}

type Transport

type Transport string

func TransportFrom

func TransportFrom(t livekit.SIPTransport) Transport

type UDPConn

type UDPConn interface {
	net.Conn
	ReadFromUDPAddrPort(b []byte) (n int, addr netip.AddrPort, err error)
	WriteToUDPAddrPort(b []byte, addr netip.AddrPort) (int, error)
}

type URI

type URI struct {
	User      string
	Host      string
	Addr      netip.AddrPort
	Transport Transport
}

func ConvertURI

func ConvertURI(u *sip.Uri) URI

func CreateURIFromUserAndAddress

func CreateURIFromUserAndAddress(user string, address string, transport Transport) URI

func (URI) GetContactURI

func (u URI) GetContactURI() *sip.Uri

func (URI) GetDest

func (u URI) GetDest() string

func (URI) GetHost

func (u URI) GetHost() string

func (URI) GetHostPort

func (u URI) GetHostPort() string

func (URI) GetPort

func (u URI) GetPort() int

func (URI) GetPortOrNone

func (u URI) GetPortOrNone() int

func (URI) GetURI

func (u URI) GetURI() *sip.Uri

func (URI) Normalize

func (u URI) Normalize() URI

func (URI) ToSIPUri

func (u URI) ToSIPUri() *livekit.SIPUri

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL