Documentation
¶
Index ¶
- Constants
- func AttrsToHeaders(attrs, attrToHdr, headers map[string]string) map[string]string
- func ConfigureTLS(c *tls.Config)
- func HeadersToAttrs(attrs, hdrToAttr map[string]string, opts livekit.SIPHeaderOptions, c Signaling, ...) map[string]string
- func LoggerWithHeaders(log logger.Logger, c Signaling) logger.Logger
- func LoggerWithParams(log logger.Logger, c Signaling) logger.Logger
- func NewReferRequest(inviteRequest *sip.Request, inviteResponse *sip.Response, ...) *sip.Request
- func SIPTransportFrom(t Transport) livekit.SIPTransport
- func SelectValue[T any](then, els T, probElse float64) T
- func SelectValueBool(then bool, probElse float64) bool
- func ToSIPUri(ip string, u sip.Uri) *livekit.SIPUri
- type ActiveCalls
- type AuthInfo
- type AuthResult
- type CallDispatch
- type CallIdentifier
- type CallInfo
- type CallState
- func (s *CallState) DeferUpdate(update func(info *livekit.SIPCallInfo))
- func (s *CallState) EndTransfer(ctx context.Context, transferID string, inErr error)
- func (s *CallState) Flush(ctx context.Context)
- func (s *CallState) ForceFlush(ctx context.Context)
- func (s *CallState) StartTransfer(ctx context.Context, transferTo string) string
- func (s *CallState) Update(ctx context.Context, update func(info *livekit.SIPCallInfo))
- type CallStatus
- type Client
- func (c *Client) ContactURI(tr Transport) URI
- func (c *Client) CreateSIPParticipant(ctx context.Context, req *rpc.InternalCreateSIPParticipantRequest) (*rpc.InternalCreateSIPParticipantResponse, error)
- func (c *Client) DeregisterTransferSIPParticipant(sipCallID string)
- func (c *Client) OnRequest(req *sip.Request, tx sip.ServerTransaction) bool
- func (c *Client) RegisterTransferSIPParticipant(sipCallID string, o *outboundCall) error
- func (c *Client) SetHandler(handler Handler)
- func (c *Client) Start(agent *sipgo.UserAgent, sc *ServiceConfig) error
- func (c *Client) Stop()
- type DispatchResult
- type GetIOInfoClient
- type Handler
- type Headers
- type LocalTag
- type MediaConf
- type MediaOptions
- type MediaPort
- func (p *MediaPort) Close()
- func (p *MediaPort) Config() *MediaConf
- func (p *MediaPort) DisableOut()
- func (p *MediaPort) EnableOut()
- func (p *MediaPort) EnableTimeout(enabled bool)
- func (p *MediaPort) GetAudioWriter() msdk.PCM16Writer
- func (p *MediaPort) HandleDTMF(h func(ev dtmf.Event))
- func (p *MediaPort) NewOffer(encrypted sdp.Encryption) (*sdp.Offer, error)
- func (p *MediaPort) Port() int
- func (p *MediaPort) Received() <-chan struct{}
- func (p *MediaPort) SetAnswer(offer *sdp.Offer, answerData []byte, enc sdp.Encryption) (*MediaConf, error)
- func (p *MediaPort) SetConfig(c *MediaConf) error
- func (p *MediaPort) SetDTMFAudio(enabled bool)
- func (p *MediaPort) SetOffer(offerData []byte, enc sdp.Encryption) (*sdp.Answer, *MediaConf, error)
- func (p *MediaPort) SetTimeout(initial, general time.Duration)
- func (p *MediaPort) Timeout() <-chan struct{}
- func (p *MediaPort) WriteAudioTo(w msdk.PCM16Writer)
- func (p *MediaPort) WriteDTMF(ctx context.Context, digits string) error
- type MixerStatsSnapshot
- type ParticipantConfig
- type ParticipantInfo
- type PortStats
- type PortStatsSnapshot
- type ReasonHeader
- type RemoteTag
- type RequestHandler
- type Room
- func (r *Room) Close() error
- func (r *Room) CloseOutput() error
- func (r *Room) CloseWithReason(reason livekit.DisconnectReason) error
- func (r *Room) Closed() <-chan struct{}
- func (r *Room) Connect(conf *config.Config, rconf RoomConfig) error
- func (r *Room) NewParticipantTrack(sampleRate int) (msdk.WriteCloser[msdk.PCM16Sample], error)
- func (r *Room) NewTrack() *mixer.Input
- func (r *Room) Output() msdk.Writer[msdk.PCM16Sample]
- func (r *Room) Participant() ParticipantInfo
- func (r *Room) Room() *lksdk.Room
- func (r *Room) SendData(data lksdk.DataPacket, opts ...lksdk.DataPublishOption) error
- func (r *Room) SetDTMFOutput(w dtmf.Writer)
- func (r *Room) Subscribe()
- func (r *Room) Subscribed() <-chan struct{}
- func (r *Room) SwapOutput(out msdk.PCM16Writer) msdk.PCM16Writer
- type RoomConfig
- type RoomStats
- type RoomStatsSnapshot
- type Server
- func (s *Server) ContactURI(tr Transport) URI
- func (s *Server) DeregisterTransferSIPParticipant(sipCallID LocalTag)
- func (s *Server) OnNoRoute(log *slog.Logger, req *sip.Request, tx sip.ServerTransaction)
- func (s *Server) RegisterTransferSIPParticipant(sipCallID LocalTag, i *inboundCall) error
- func (s *Server) SetHandler(handler Handler)
- func (s *Server) Start(agent *sipgo.UserAgent, sc *ServiceConfig, tlsConf *tls.Config, ...) error
- func (s *Server) Stop()
- type Service
- func (s *Service) ActiveCalls() ActiveCalls
- func (s *Service) CreateSIPParticipant(ctx context.Context, req *rpc.InternalCreateSIPParticipantRequest) (*rpc.InternalCreateSIPParticipantResponse, error)
- func (s *Service) CreateSIPParticipantAffinity(ctx context.Context, req *rpc.InternalCreateSIPParticipantRequest) float32
- func (s *Service) SetHandler(handler Handler)
- func (s *Service) Start() error
- func (s *Service) Stop()
- func (s *Service) TransferSIPParticipant(ctx context.Context, req *rpc.InternalTransferSIPParticipantRequest) (*emptypb.Empty, error)
- type ServiceConfig
- type Signaling
- type StateUpdater
- type Stats
- type StatsSnapshot
- type Transport
- type UDPConn
- type URI
Constants ¶
const ( RoomSampleRate = 48000 RoomResample = false )
const ( AttrSIPCallIDFull = livekit.AttrSIPPrefix + "callIDFull" AttrSIPCallTag = livekit.AttrSIPPrefix + "callTag" )
const ( CallDialing CallRinging CallAutomation CallActive CallHangup )
const ( AuthNotFound = AuthResult(iota) AuthDrop AuthPassword AuthAccept AuthQuotaExceeded AuthNoTrunkFound )
const ( DispatchAccept = DispatchResult(iota) DispatchRequestPin DispatchNoRuleReject // reject the call with an error DispatchNoRuleDrop // silently drop the call )
const ( TransportUDP = Transport("udp") TransportTCP = Transport("tcp") TransportTLS = Transport("tls") )
const (
UserAgent = "LiveKit"
)
Variables ¶
This section is empty.
Functions ¶
func AttrsToHeaders ¶
func ConfigureTLS ¶
func HeadersToAttrs ¶
func NewReferRequest ¶
func SIPTransportFrom ¶
func SIPTransportFrom(t Transport) livekit.SIPTransport
func SelectValue ¶
func SelectValueBool ¶
Types ¶
type ActiveCalls ¶
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
RingingTimeout time.Duration
MaxCallDuration time.Duration
MediaEncryption livekit.SIPMediaEncryption
}
type CallIdentifier ¶
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 (*CallState) ForceFlush ¶
func (*CallState) StartTransfer ¶
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 (*Client) ContactURI ¶
func (*Client) CreateSIPParticipant ¶
func (c *Client) CreateSIPParticipant(ctx context.Context, req *rpc.InternalCreateSIPParticipantRequest) (*rpc.InternalCreateSIPParticipantResponse, error)
func (*Client) DeregisterTransferSIPParticipant ¶
func (*Client) RegisterTransferSIPParticipant ¶
func (*Client) SetHandler ¶
type DispatchResult ¶
type DispatchResult int
type GetIOInfoClient ¶
type GetIOInfoClient func(projectID string) rpc.IOInfoClient
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) msdk.PCM16Processor
RegisterTransferSIPParticipantTopic(sipCallId string) error
DeregisterTransferSIPParticipantTopic(sipCallId string)
OnSessionEnd(ctx context.Context, callIdentifier *CallIdentifier, callInfo *livekit.SIPCallInfo, reason string)
}
type MediaConf ¶
type MediaConf struct {
sdp.MediaConfig
Processor msdk.PCM16Processor
}
type MediaOptions ¶
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 (*MediaPort) DisableOut ¶
func (p *MediaPort) DisableOut()
func (*MediaPort) EnableTimeout ¶
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 ¶
HandleDTMF sets an incoming DTMF handler.
func (*MediaPort) SetAnswer ¶
func (p *MediaPort) SetAnswer(offer *sdp.Offer, answerData []byte, enc sdp.Encryption) (*MediaConf, error)
SetAnswer decodes and applies SDP answer for offer from NewOffer. SetConfig must be called with the decoded configuration.
func (*MediaPort) SetDTMFAudio ¶
SetDTMFAudio forces SIP to generate audio dTMF tones in addition to digital signals.
func (*MediaPort) SetOffer ¶
SetOffer decodes the offer from another party and returns encoded answer. To accept the offer, call SetConfig.
func (*MediaPort) SetTimeout ¶
func (*MediaPort) WriteAudioTo ¶
func (p *MediaPort) WriteAudioTo(w msdk.PCM16Writer)
WriteAudioTo sets audio writer that will receive decoded PCM from incoming RTP packets.
type MixerStatsSnapshot ¶
type MixerStatsSnapshot struct {
Tracks int64 `json:"tracks"`
TracksTotal uint64 `json:"tracks_total"`
Restarts uint64 `json:"restarts"`
Mixes uint64 `json:"mixes"`
TimedMixes uint64 `json:"mixes_timed"`
JumpMixes uint64 `json:"mixes_jump"`
ZeroMixes uint64 `json:"mixes_zero"`
InputSamples uint64 `json:"input_samples"`
InputFrames uint64 `json:"input_frames"`
MixedSamples uint64 `json:"mixed_samples"`
MixedFrames uint64 `json:"mixed_frames"`
OutputSamples uint64 `json:"output_samples"`
OutputFrames uint64 `json:"output_frames"`
}
type ParticipantConfig ¶
type ParticipantInfo ¶
type PortStatsSnapshot ¶
type PortStatsSnapshot struct {
Streams uint64 `json:"streams"`
Packets uint64 `json:"packets"`
IgnoredPackets uint64 `json:"packets_ignored"`
InputPackets uint64 `json:"packets_input"`
MuxPackets uint64 `json:"mux_packets"`
MuxBytes uint64 `json:"mux_bytes"`
AudioPackets uint64 `json:"audio_packets"`
AudioBytes uint64 `json:"audio_bytes"`
DTMFPackets uint64 `json:"dtmf_packets"`
DTMFBytes uint64 `json:"dtmf_bytes"`
Closed bool `json:"closed"`
}
type ReasonHeader ¶
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 RequestHandler ¶
type RequestHandler func(req *sip.Request, tx sip.ServerTransaction) bool
type Room ¶
type Room struct {
// contains filtered or unexported fields
}
func (*Room) CloseOutput ¶
func (*Room) CloseWithReason ¶
func (r *Room) CloseWithReason(reason livekit.DisconnectReason) error
func (*Room) NewParticipantTrack ¶
func (r *Room) NewParticipantTrack(sampleRate int) (msdk.WriteCloser[msdk.PCM16Sample], error)
func (*Room) Participant ¶
func (r *Room) Participant() ParticipantInfo
func (*Room) SendData ¶
func (r *Room) SendData(data lksdk.DataPacket, opts ...lksdk.DataPublishOption) error
func (*Room) SetDTMFOutput ¶
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
}
type RoomStatsSnapshot ¶
type RoomStatsSnapshot struct {
InputPackets uint64 `json:"input_packets"`
InputBytes uint64 `json:"input_bytes"`
DTMFPackets uint64 `json:"dtmf_packets"`
MixerSamples uint64 `json:"mixer_samples"`
MixerFrames uint64 `json:"mixer_frames"`
OutputSamples uint64 `json:"output_samples"`
OutputFrames uint64 `json:"output_frames"`
Closed bool `json:"closed"`
}
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) ContactURI ¶
func (*Server) DeregisterTransferSIPParticipant ¶
func (*Server) RegisterTransferSIPParticipant ¶
func (*Server) SetHandler ¶
func (*Server) Start ¶
func (s *Server) Start(agent *sipgo.UserAgent, sc *ServiceConfig, tlsConf *tls.Config, unhandled RequestHandler) error
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) ActiveCalls ¶
func (s *Service) ActiveCalls() ActiveCalls
func (*Service) CreateSIPParticipant ¶
func (s *Service) CreateSIPParticipant(ctx context.Context, req *rpc.InternalCreateSIPParticipantRequest) (*rpc.InternalCreateSIPParticipantResponse, error)
func (*Service) CreateSIPParticipantAffinity ¶
func (*Service) SetHandler ¶
func (*Service) TransferSIPParticipant ¶
type ServiceConfig ¶
func GetServiceConfig ¶
func GetServiceConfig(conf *config.Config) (*ServiceConfig, error)
type StateUpdater ¶
type StateUpdater interface {
UpdateSIPCallState(ctx context.Context, req *rpc.UpdateSIPCallStateRequest, opts ...psrpc.RequestOption) (*emptypb.Empty, error)
}
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