voicehost

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DTMFInfoPackage       = "dtmf"
	DTMFRelayContentType  = "application/dtmf-relay"
	DefaultDTMFDurationMS = 160
	MaxDTMFDurationMS     = 5000
	DialogDTMFRouteRTP    = "rtp"
	DialogDTMFRouteInfo   = "info"
)
View Source
const (
	DefaultRTPDTMFPayloadType = 101
	DefaultRTPDTMFClockRate   = 8000
	DefaultRTPDTMFVolume      = 10
	DefaultRTPDTMFStepMS      = 50
	DefaultRTPDTMFEndPackets  = 3
)
View Source
const (
	SDPCodecPCMU           = "PCMU"
	SDPCodecPCMA           = "PCMA"
	SDPCodecAMR            = "AMR"
	SDPCodecAMRWB          = "AMR-WB"
	SDPCodecTelephoneEvent = "telephone-event"
)
View Source
const (
	SDPPCMUPayloadType = 0
	SDPPCMAPayloadType = 8
)
View Source
const (
	DefaultSimulateCallHoldSeconds = 10
	MaxSimulateCallHoldSeconds     = 300
)

Variables

View Source
var ErrIMSInboundAgentNotReady = errors.New("ims inbound voice agent not ready")
View Source
var ErrIMSVoiceAgentNotReady = errors.New("ims voice agent not ready")
View Source
var ErrInvalidDTMF = errors.New("invalid DTMF relay")
View Source
var ErrInvalidSDPDirection = errors.New("invalid SDP media direction")
View Source
var ErrInvalidSDPSecurity = errors.New("invalid SDP security")
View Source
var ErrRTPRelayConfig = errors.New("invalid rtp relay config")
View Source
var ErrRTPStreamStats = errors.New("invalid rtp stream stats")
View Source
var ErrSDPMediaNegotiation = errors.New("invalid SDP media negotiation")
View Source
var ErrSDPSecurityNegotiation = errors.New("SDP security negotiation failed")
View Source
var ErrSRTPMediaConfig = errors.New("invalid srtp media config")

Functions

func BuildDTMFRelayBody

func BuildDTMFRelayBody(signal string, durationMS int) ([]byte, error)

func BuildGoodbye

func BuildGoodbye(sources []uint32, reason string) *rtcp.Goodbye

BuildGoodbye builds an RTCP BYE packet for media sources that are no longer active.

func BuildRTPDTMFPacket

func BuildRTPDTMFPacket(in RTPDTMFPacket) ([]byte, error)

func BuildRTPDTMFSequence

func BuildRTPDTMFSequence(cfg RTPDTMFSequenceConfig) ([][]byte, error)

func BuildReceiverReport

func BuildReceiverReport(senderSSRC uint32, stats []RTPStreamStats) *rtcp.ReceiverReport

BuildReceiverReport converts RTP reception snapshots into an RTCP RR packet. A ReceiverReport can carry at most 31 report blocks, so extra streams are ignored.

func BuildSDPAnswer

func BuildSDPAnswer(info SDPInfo) []byte

func BuildSDPAnswerWithOptions

func BuildSDPAnswerWithOptions(info SDPInfo, options SDPAnswerOptions) []byte

func BuildSDPAnswerWithSecurity

func BuildSDPAnswerWithSecurity(info SDPInfo, security SDPSecurityInfo) []byte

func BuildSDPCryptoInlineKeyParams

func BuildSDPCryptoInlineKeyParams(profile SRTPProtectionProfile, params SDPCryptoInlineKeyParams) (string, error)

func BuildSDPFmtpParameters

func BuildSDPFmtpParameters(params map[string]string) string

func BuildSenderReport

func BuildSenderReport(cfg RTCPSenderReportConfig) *rtcp.SenderReport

BuildSenderReport converts local sender counters and optional reception snapshots into an RTCP SR packet.

func BuildSourceDescription

func BuildSourceDescription(cfg RTCPSourceDescriptionConfig) *rtcp.SourceDescription

BuildSourceDescription builds an RTCP SDES chunk for the local media source. CNAME should be stable for the lifetime of the RTP session.

func NormalizeDTMFSignal

func NormalizeDTMFSignal(signal string) (string, error)

func NormalizeRTPDTMFSignal

func NormalizeRTPDTMFSignal(signal string) (string, error)

func ParseDTMFRelayBody

func ParseDTMFRelayBody(body []byte) (signal string, durationMS int, err error)

func ParseSDPFmtpParameters

func ParseSDPFmtpParameters(fmtp string) map[string]string

func ParseSDPWithSecurity

func ParseSDPWithSecurity(body []byte) (SDPInfo, SDPSecurityInfo, error)

func RTPDTMFEventCode

func RTPDTMFEventCode(signal string) (uint8, error)

func RTPDTMFSignalFromEventCode

func RTPDTMFSignalFromEventCode(code uint8) string

func RewriteRTPDTMFPayloadType

func RewriteRTPDTMFPayloadType(packet []byte, sourcePayloadTypes, targetPayloadTypes map[uint8]int) ([]byte, bool, error)

func RewriteSDPMediaDirection

func RewriteSDPMediaDirection(body []byte, direction string) ([]byte, error)

func RewriteSDPMediaEndpoint

func RewriteSDPMediaEndpoint(body []byte, endpoint SDPInfo) []byte

func RewriteSDPMediaEndpointWithOptions

func RewriteSDPMediaEndpointWithOptions(body []byte, endpoint SDPInfo, options SDPMediaRewriteOptions) []byte

func RewriteSDPRTCPFeedback

func RewriteSDPRTCPFeedback(body []byte, feedback []SDPRTCPFeedbackAttribute) []byte

func SelectSDPAnswerDirection

func SelectSDPAnswerDirection(offerDirection, localDirection string) (string, error)

func SelectSDPAnswerPacketizationTime

func SelectSDPAnswerPacketizationTime(offer, local SDPInfo) (int, int)

func SelectSDPSetupAnswer

func SelectSDPSetupAnswer(offerSetup, preferred string) (string, error)

func ValidateSDPCryptoAttribute

func ValidateSDPCryptoAttribute(attr SDPCryptoAttribute) error

Types

type Agent

type Agent interface{}

type ClientAdapter

type ClientAdapter interface {
	GetClientContact(deviceID string) (contactURI string, contactIP string, username string, err error)
}

type DialogAutoDTMFResult

type DialogAutoDTMFResult struct {
	Accepted                   bool
	StatusCode                 int
	Reason                     string
	Route                      string
	RegistrationRecoveryNeeded bool
	RetryAfter                 time.Duration
	RTP                        DialogRTPDTMFResult
	INFO                       DialogDTMFResult
}

type DialogAutoDTMFSender

type DialogAutoDTMFSender interface {
	SendDialogAutoDTMF(context.Context, DialogDTMFRequest) (DialogAutoDTMFResult, error)
}

type DialogCanceller

type DialogCanceller interface {
	CancelVoiceCall(context.Context, DialogInfo) error
}

type DialogCancellerWithResult

type DialogCancellerWithResult interface {
	CancelVoiceCallWithResult(context.Context, DialogInfo) (DialogInfoResult, error)
}

type DialogDTMFRequest

type DialogDTMFRequest struct {
	DeviceID   string
	CallID     string
	Signal     string
	DurationMS int
	Headers    map[string]string
}

type DialogDTMFResult

type DialogDTMFResult = DialogInfoResult

type DialogDTMFSender

type DialogDTMFSender interface {
	SendDialogDTMF(context.Context, DialogDTMFRequest) (DialogDTMFResult, error)
}

type DialogHoldController

type DialogHoldController interface {
	SendDialogHold(context.Context, DialogHoldRequest) (DialogUpdateResult, error)
	SendDialogResume(context.Context, DialogResumeRequest) (DialogUpdateResult, error)
}

type DialogHoldRequest

type DialogHoldRequest struct {
	DeviceID    string
	CallID      string
	Direction   string
	ContentType string
	Headers     map[string]string
}

type DialogInfo

type DialogInfo struct {
	DeviceID    string
	CallID      string
	Callee      string
	State       DialogState
	CSeq        int
	ContentType string
	Body        []byte
	Headers     map[string]string
}

type DialogInfoRequest

type DialogInfoRequest struct {
	DeviceID    string
	CallID      string
	ContentType string
	InfoPackage string
	Body        []byte
	Headers     map[string]string
}

func BuildDialogDTMFInfoRequest

func BuildDialogDTMFInfoRequest(req DialogDTMFRequest) (DialogInfoRequest, error)

type DialogInfoResult

type DialogInfoResult struct {
	Accepted                   bool
	StatusCode                 int
	Reason                     string
	RegistrationRecoveryNeeded bool
	RetryAfter                 time.Duration
	ContentType                string
	Body                       []byte
	Headers                    map[string]string
}

type DialogInfoSender

type DialogInfoSender interface {
	SendDialogInfo(context.Context, DialogInfoRequest) (DialogInfoResult, error)
}

type DialogMessageRequest

type DialogMessageRequest struct {
	DeviceID    string
	CallID      string
	ContentType string
	Body        []byte
	Headers     map[string]string
}

type DialogMessageResult

type DialogMessageResult = DialogInfoResult

type DialogMessageSender

type DialogMessageSender interface {
	SendDialogMessage(context.Context, DialogMessageRequest) (DialogMessageResult, error)
}

type DialogNotifyRequest

type DialogNotifyRequest struct {
	DeviceID          string
	CallID            string
	Event             string
	SubscriptionState string
	ContentType       string
	Body              []byte
	Headers           map[string]string
}

type DialogNotifyResult

type DialogNotifyResult = DialogInfoResult

type DialogNotifySender

type DialogNotifySender interface {
	SendDialogNotify(context.Context, DialogNotifyRequest) (DialogNotifyResult, error)
}

type DialogOptionsRequest

type DialogOptionsRequest struct {
	DeviceID string
	CallID   string
	Headers  map[string]string
}

type DialogOptionsResult

type DialogOptionsResult = DialogInfoResult

type DialogOptionsSender

type DialogOptionsSender interface {
	SendDialogOptions(context.Context, DialogOptionsRequest) (DialogOptionsResult, error)
}

type DialogPrackRequest

type DialogPrackRequest struct {
	DeviceID    string
	CallID      string
	RAck        string
	ContentType string
	Body        []byte
	Headers     map[string]string
}

type DialogPrackResult

type DialogPrackResult = DialogInfoResult

type DialogPrackSender

type DialogPrackSender interface {
	SendDialogPrack(context.Context, DialogPrackRequest) (DialogPrackResult, error)
}

type DialogRTPDTMFRequest

type DialogRTPDTMFRequest struct {
	DeviceID       string
	CallID         string
	Direction      RTPDTMFDirection
	Signal         string
	DurationMS     int
	StepMS         int
	EndPacketCount int
	Volume         uint8
	SequenceNumber uint16
	Timestamp      uint32
	SSRC           uint32
	PayloadType    uint8
	ClockRate      int
}

type DialogRTPDTMFResult

type DialogRTPDTMFResult struct {
	Accepted   bool
	StatusCode int
	Reason     string
	RTP        RTPRelayDTMFResult
}

type DialogRTPDTMFSender

type DialogRTPDTMFSender interface {
	SendDialogRTPDTMF(context.Context, DialogRTPDTMFRequest) (DialogRTPDTMFResult, error)
}

type DialogReferRequest

type DialogReferRequest struct {
	DeviceID   string
	CallID     string
	ReferTo    string
	ReferredBy string
	ReferSub   string
	Headers    map[string]string
}

type DialogReferResult

type DialogReferResult = DialogInfoResult

type DialogReferSender

type DialogReferSender interface {
	SendDialogRefer(context.Context, DialogReferRequest) (DialogReferResult, error)
}

type DialogReinviteRequest

type DialogReinviteRequest struct {
	DeviceID    string
	CallID      string
	ContentType string
	Body        []byte
	Headers     map[string]string
}

type DialogReinviteResult

type DialogReinviteResult struct {
	Accepted                   bool
	StatusCode                 int
	Reason                     string
	RegistrationRecoveryNeeded bool
	RetryAfter                 time.Duration
	ContentType                string
	Body                       []byte
	Headers                    map[string]string
}

type DialogReinviter

type DialogReinviter interface {
	SendDialogReinvite(context.Context, DialogReinviteRequest) (DialogReinviteResult, error)
}

type DialogResumeRequest

type DialogResumeRequest struct {
	DeviceID    string
	CallID      string
	ContentType string
	Headers     map[string]string
}

type DialogState

type DialogState string
const (
	DialogStateEarly       DialogState = "early"
	DialogStateEstablished DialogState = "established"
	DialogStateTerminated  DialogState = "terminated"
)

type DialogSubscribeRequest

type DialogSubscribeRequest struct {
	DeviceID    string
	CallID      string
	Event       string
	Expires     string
	ContentType string
	Body        []byte
	Headers     map[string]string
}

type DialogSubscribeResult

type DialogSubscribeResult = DialogInfoResult

type DialogSubscribeSender

type DialogSubscribeSender interface {
	SendDialogSubscribe(context.Context, DialogSubscribeRequest) (DialogSubscribeResult, error)
}

type DialogTerminator

type DialogTerminator interface {
	EndVoiceCall(context.Context, DialogInfo) error
}

type DialogTerminatorWithResult

type DialogTerminatorWithResult interface {
	EndVoiceCallWithResult(context.Context, DialogInfo) (DialogInfoResult, error)
}

type DialogUpdateRequest

type DialogUpdateRequest struct {
	DeviceID    string
	CallID      string
	ContentType string
	Body        []byte
	Headers     map[string]string
}

type DialogUpdateResult

type DialogUpdateResult struct {
	Accepted                   bool
	StatusCode                 int
	Reason                     string
	RegistrationRecoveryNeeded bool
	RetryAfter                 time.Duration
	ContentType                string
	Body                       []byte
	Headers                    map[string]string
}

type DialogUpdater

type DialogUpdater interface {
	SendDialogUpdate(context.Context, DialogUpdateRequest) (DialogUpdateResult, error)
}

type Gateway

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

func NewGateway

func NewGateway() *Gateway

func (*Gateway) DeviceStatus

func (g *Gateway) DeviceStatus(deviceID string) map[string]interface{}

func (*Gateway) GetAgent

func (g *Gateway) GetAgent(deviceID string) Agent

func (*Gateway) HandleClientAck

func (g *Gateway) HandleClientAck(deviceID string, req *sip.Request, tx sip.ServerTransaction)

func (*Gateway) HandleClientBye

func (g *Gateway) HandleClientBye(deviceID string, req *sip.Request, tx sip.ServerTransaction)

func (*Gateway) HandleClientCancel

func (g *Gateway) HandleClientCancel(deviceID string, req *sip.Request, tx sip.ServerTransaction)

func (*Gateway) HandleClientInfo

func (g *Gateway) HandleClientInfo(deviceID string, req *sip.Request, tx sip.ServerTransaction)

func (*Gateway) HandleClientInvite

func (g *Gateway) HandleClientInvite(deviceID string, req *sip.Request, tx sip.ServerTransaction)

func (*Gateway) HandleClientMessage

func (g *Gateway) HandleClientMessage(deviceID string, req *sip.Request, tx sip.ServerTransaction)

func (*Gateway) HandleClientNotify

func (g *Gateway) HandleClientNotify(deviceID string, req *sip.Request, tx sip.ServerTransaction)

func (*Gateway) HandleClientOptions

func (g *Gateway) HandleClientOptions(deviceID string, req *sip.Request, tx sip.ServerTransaction)

func (*Gateway) HandleClientPrack

func (g *Gateway) HandleClientPrack(deviceID string, req *sip.Request, tx sip.ServerTransaction)

func (*Gateway) HandleClientRefer

func (g *Gateway) HandleClientRefer(deviceID string, req *sip.Request, tx sip.ServerTransaction)

func (*Gateway) HandleClientSubscribe

func (g *Gateway) HandleClientSubscribe(deviceID string, req *sip.Request, tx sip.ServerTransaction)

func (*Gateway) HandleClientUpdate

func (g *Gateway) HandleClientUpdate(deviceID string, req *sip.Request, tx sip.ServerTransaction)

func (*Gateway) RegisterAgent

func (g *Gateway) RegisterAgent(deviceID string, agent Agent)

func (*Gateway) SetClientAdapter

func (g *Gateway) SetClientAdapter(a ClientAdapter)

func (*Gateway) SetNotifier

func (g *Gateway) SetNotifier(n any)

func (*Gateway) SimulateCall

func (g *Gateway) SimulateCall(ctx context.Context, deviceID string, req SimulateCallRequest) (SimulateCallResult, error)

func (*Gateway) Start

func (g *Gateway) Start(ctx context.Context) error

func (*Gateway) Stop

func (g *Gateway) Stop() error

type IMSByeHandler

type IMSByeHandler interface {
	HandleIMSBye(context.Context, IMSByeRequest) (IMSByeResult, error)
}

type IMSByeHandlerFunc

type IMSByeHandlerFunc func(context.Context, IMSByeRequest) (IMSByeResult, error)

func (IMSByeHandlerFunc) HandleIMSBye

func (f IMSByeHandlerFunc) HandleIMSBye(ctx context.Context, req IMSByeRequest) (IMSByeResult, error)

type IMSByeRequest

type IMSByeRequest struct {
	URI         string
	FromURI     string
	ToURI       string
	CallID      string
	CSeq        int
	ContentType string
	Body        []byte
	Headers     map[string][]string
}

type IMSByeResult

type IMSByeResult struct {
	Handled     bool
	StatusCode  int
	Reason      string
	ContentType string
	Body        []byte
	Headers     map[string]string
}

type IMSInboundAgent

type IMSInboundAgent struct {
	ClientTransport  voiceclient.SIPRequestTransport
	Profile          voiceclient.IMSProfile
	Registration     voiceclient.RegistrationBinding
	ClientContactURI string
	LocalContactURI  string
	LocalTag         string
	UserAgent        string
	MediaRelay       *RTPRelayConfig
	// contains filtered or unexported fields
}

func (*IMSInboundAgent) AckInboundCall

func (a *IMSInboundAgent) AckInboundCall(ctx context.Context, info DialogInfo) error

func (*IMSInboundAgent) CancelInboundCall

func (a *IMSInboundAgent) CancelInboundCall(ctx context.Context, info DialogInfo) error

func (*IMSInboundAgent) CancelInboundCallWithResult

func (a *IMSInboundAgent) CancelInboundCallWithResult(ctx context.Context, info DialogInfo) (DialogInfoResult, error)

func (*IMSInboundAgent) EndInboundCall

func (a *IMSInboundAgent) EndInboundCall(ctx context.Context, info DialogInfo) error

func (*IMSInboundAgent) EndInboundCallWithResult

func (a *IMSInboundAgent) EndInboundCallWithResult(ctx context.Context, info DialogInfo) (DialogInfoResult, error)

func (*IMSInboundAgent) HandleInboundInfo

func (a *IMSInboundAgent) HandleInboundInfo(ctx context.Context, req IMSInfoRequest) (IMSInfoResult, error)

func (*IMSInboundAgent) HandleInboundInvite

func (a *IMSInboundAgent) HandleInboundInvite(ctx context.Context, req InboundCallRequest) (InboundCallResult, error)

func (*IMSInboundAgent) HandleInboundMessage

func (a *IMSInboundAgent) HandleInboundMessage(ctx context.Context, req IMSMessageRequest) (IMSInfoResult, error)

func (*IMSInboundAgent) HandleInboundNotify

func (a *IMSInboundAgent) HandleInboundNotify(ctx context.Context, req InboundDialogRequest) (IMSInfoResult, error)

func (*IMSInboundAgent) HandleInboundPrack

func (a *IMSInboundAgent) HandleInboundPrack(ctx context.Context, req InboundDialogRequest) (InboundCallResult, error)

func (*IMSInboundAgent) HandleInboundRefer

func (a *IMSInboundAgent) HandleInboundRefer(ctx context.Context, req InboundDialogRequest) (InboundCallResult, error)

func (*IMSInboundAgent) HandleInboundSubscribe

func (a *IMSInboundAgent) HandleInboundSubscribe(ctx context.Context, req InboundDialogRequest) (IMSInfoResult, error)

func (*IMSInboundAgent) HandleInboundUpdate

func (a *IMSInboundAgent) HandleInboundUpdate(ctx context.Context, req InboundDialogRequest) (InboundCallResult, error)

func (*IMSInboundAgent) SendDialogRTPDTMF

type IMSInboundRequireOptionClassification

type IMSInboundRequireOptionClassification struct {
	Required    []string
	Supported   []string
	Unsupported []string
}

IMSInboundRequireOptionClassification partitions inbound Require option-tags by local support.

func ClassifyIMSInboundRequireOptions

func ClassifyIMSInboundRequireOptions(headers map[string][]string) IMSInboundRequireOptionClassification

ClassifyIMSInboundRequireOptions classifies Require option-tags against inbound IMS wire support.

func (IMSInboundRequireOptionClassification) UnsupportedHeader

func (c IMSInboundRequireOptionClassification) UnsupportedHeader() string

UnsupportedHeader renders unsupported option-tags for a SIP Unsupported response header.

type IMSInboundWireResponse

type IMSInboundWireResponse struct {
	StatusCode int
	Reason     string
	Headers    map[string]string
	Body       []byte
	NoResponse bool
}

type IMSInboundWireServer

type IMSInboundWireServer struct {
	Agent           *IMSInboundAgent
	MessageHandler  IMSMessageHandler
	InfoHandler     IMSInfoHandler
	ByeHandler      IMSByeHandler
	ContactURI      string
	LocalTag        string
	UserAgent       string
	ResponseHeaders map[string]string
	ReadTimeout     time.Duration
	TransactionTTL  time.Duration
	InviteFinalT1   time.Duration
	InviteFinalT2   time.Duration
	Reliable1xxT1   time.Duration
	Reliable1xxT2   time.Duration
	// contains filtered or unexported fields
}

func (*IMSInboundWireServer) CachedTransactionSnapshot

CachedTransactionSnapshot returns a diagnostic view of a cached inbound SIP server transaction keyed by req's Via branch, Call-ID, method, and CSeq.

func (*IMSInboundWireServer) HandleRequest

func (*IMSInboundWireServer) ServeListener

func (s *IMSInboundWireServer) ServeListener(ctx context.Context, ln net.Listener) error

func (*IMSInboundWireServer) ServePacket

func (s *IMSInboundWireServer) ServePacket(ctx context.Context, pc net.PacketConn) error

type IMSInboundWireTransactionSnapshot

type IMSInboundWireTransactionSnapshot struct {
	Method       string
	Invite       bool
	State        voiceclient.SIPServerTransactionState
	StatusCodes  []int
	Provisional  bool
	Final        bool
	Pending      bool
	CleanupAfter time.Duration
	TimeoutAfter time.Duration
	ExpiresAt    time.Time
}

IMSInboundWireTransactionSnapshot describes the cached server transaction state for an inbound SIP request without exposing cached response bodies.

type IMSInfoHandler

type IMSInfoHandler interface {
	HandleIMSInfo(context.Context, IMSInfoRequest) (IMSInfoResult, error)
}

type IMSInfoHandlerFunc

type IMSInfoHandlerFunc func(context.Context, IMSInfoRequest) (IMSInfoResult, error)

func (IMSInfoHandlerFunc) HandleIMSInfo

func (f IMSInfoHandlerFunc) HandleIMSInfo(ctx context.Context, req IMSInfoRequest) (IMSInfoResult, error)

type IMSInfoRequest

type IMSInfoRequest struct {
	URI         string
	FromURI     string
	ToURI       string
	CallID      string
	CSeq        int
	ContentType string
	InfoPackage string
	Body        []byte
	Headers     map[string][]string
}

type IMSInfoResult

type IMSInfoResult struct {
	Handled     bool
	StatusCode  int
	Reason      string
	ContentType string
	Body        []byte
	Headers     map[string]string
}

type IMSMessageHandler

type IMSMessageHandler interface {
	HandleIMSMessage(context.Context, IMSMessageRequest) (IMSMessageResult, error)
}

type IMSMessageHandlerFunc

type IMSMessageHandlerFunc func(context.Context, IMSMessageRequest) (IMSMessageResult, error)

func (IMSMessageHandlerFunc) HandleIMSMessage

type IMSMessageRequest

type IMSMessageRequest struct {
	URI         string
	FromURI     string
	ToURI       string
	CallID      string
	CSeq        int
	ContentType string
	Body        []byte
	Headers     map[string][]string
}

type IMSMessageResult

type IMSMessageResult struct {
	StatusCode  int
	Reason      string
	ContentType string
	Body        []byte
	Headers     map[string]string
}

type IMSOutboundAgent

type IMSOutboundAgent struct {
	Transport          voiceclient.SIPRequestTransport
	Profile            voiceclient.IMSProfile
	Registration       voiceclient.RegistrationBinding
	Domain             string
	UserAgent          string
	LocalTag           string
	SessionExpires     int
	SessionRefresher   string
	SessionRefreshLead time.Duration
	RemoteTargetURI    string
	MediaRelay         *RTPRelayConfig
	// contains filtered or unexported fields
}

func (*IMSOutboundAgent) CancelVoiceCall

func (a *IMSOutboundAgent) CancelVoiceCall(ctx context.Context, info DialogInfo) error

func (*IMSOutboundAgent) CancelVoiceCallWithResult

func (a *IMSOutboundAgent) CancelVoiceCallWithResult(ctx context.Context, info DialogInfo) (DialogInfoResult, error)

func (*IMSOutboundAgent) EndVoiceCall

func (a *IMSOutboundAgent) EndVoiceCall(ctx context.Context, info DialogInfo) error

func (*IMSOutboundAgent) EndVoiceCallWithResult

func (a *IMSOutboundAgent) EndVoiceCallWithResult(ctx context.Context, info DialogInfo) (DialogInfoResult, error)

func (*IMSOutboundAgent) SendDialogDTMF

func (*IMSOutboundAgent) SendDialogHold

func (*IMSOutboundAgent) SendDialogInfo

func (*IMSOutboundAgent) SendDialogMessage

func (*IMSOutboundAgent) SendDialogNotify

func (*IMSOutboundAgent) SendDialogOptions

func (*IMSOutboundAgent) SendDialogPrack

func (*IMSOutboundAgent) SendDialogRTPDTMF

func (*IMSOutboundAgent) SendDialogRefer

func (*IMSOutboundAgent) SendDialogReinvite

func (*IMSOutboundAgent) SendDialogResume

func (*IMSOutboundAgent) SendDialogSubscribe

func (*IMSOutboundAgent) SendDialogUpdate

func (*IMSOutboundAgent) StartOutboundCall

func (a *IMSOutboundAgent) StartOutboundCall(ctx context.Context, req OutboundCallRequest) (OutboundCallResult, error)

func (*IMSOutboundAgent) StopSessionTimers

func (a *IMSOutboundAgent) StopSessionTimers()

func (*IMSOutboundAgent) UpdateIMSRegistration

func (a *IMSOutboundAgent) UpdateIMSRegistration(update IMSRegistrationUpdate)

type IMSRegistrationUpdate

type IMSRegistrationUpdate struct {
	Transport          voiceclient.SIPRequestTransport
	Profile            voiceclient.IMSProfile
	Registration       voiceclient.RegistrationBinding
	Domain             string
	UserAgent          string
	SessionExpires     int
	SessionRefresher   string
	SessionRefreshLead time.Duration
	MediaRelay         *RTPRelayConfig
}

type IMSRegistrationUpdater

type IMSRegistrationUpdater interface {
	UpdateIMSRegistration(IMSRegistrationUpdate)
}

type InboundCallRequest

type InboundCallRequest struct {
	DeviceID        string
	CallID          string
	CallerURI       string
	CalleeURI       string
	RemoteTag       string
	RemoteTargetURI string
	CSeq            int
	RemoteSDP       SDPInfo
	RawSDP          []byte
	Headers         map[string][]string
	// contains filtered or unexported fields
}

type InboundCallResult

type InboundCallResult struct {
	Accepted   bool
	StatusCode int
	Reason     string
	LocalSDP   SDPInfo
	RawSDP     []byte
	Headers    map[string]string
	// contains filtered or unexported fields
}

type InboundDialogRequest

type InboundDialogRequest struct {
	CallID            string
	CSeq              int
	ContentType       string
	Body              []byte
	RawSDP            []byte
	RemoteSDP         SDPInfo
	Headers           map[string][]string
	RAck              string
	ReferTo           string
	ReferredBy        string
	ReferSub          string
	Event             string
	Expires           string
	SubscriptionState string
}

type OutboundCallAgent

type OutboundCallAgent interface {
	StartOutboundCall(context.Context, OutboundCallRequest) (OutboundCallResult, error)
}

type OutboundCallRequest

type OutboundCallRequest struct {
	DeviceID   string
	CallID     string
	Callee     string
	RequestURI string
	RouteSet   []string
	RemoteSDP  SDPInfo
	RawSDP     []byte
	Headers    map[string]string
}

type OutboundCallResult

type OutboundCallResult struct {
	Accepted                   bool
	StatusCode                 int
	Reason                     string
	RegistrationRecoveryNeeded bool
	RetryAfter                 time.Duration
	LocalSDP                   SDPInfo
	RawSDP                     []byte
	Headers                    map[string]string
}

type RTCPFeedbackDirection

type RTCPFeedbackDirection string
const (
	RTCPFeedbackClientToIMS RTCPFeedbackDirection = "client_to_ims"
	RTCPFeedbackIMSToClient RTCPFeedbackDirection = "ims_to_client"
)

type RTCPFeedbackEvent

type RTCPFeedbackEvent struct {
	Direction        RTCPFeedbackDirection
	Kind             RTCPFeedbackKind
	PacketType       string
	SenderSSRC       uint32
	MediaSSRC        uint32
	SSRC             uint32
	NTPTime          uint64
	RTPTime          uint32
	PacketCount      uint32
	OctetCount       uint32
	DestinationSSRCs []uint32
	GoodbyeSSRCs     []uint32
	GoodbyeReason    string
	ReportCount      int
	NACKCount        int
	FIRCount         int
	SLICount         int
	REMBBitrate      float64
	REMBSSRCs        []uint32
	TransportCCCount int
	Reports          []RTCPReceptionReport
	Packet           rtcp.Packet
}

type RTCPFeedbackHandler

type RTCPFeedbackHandler func(RTCPFeedbackEvent)

type RTCPFeedbackKind

type RTCPFeedbackKind string
const (
	RTCPFeedbackSenderReport                    RTCPFeedbackKind = "sender_report"
	RTCPFeedbackReceiverReport                  RTCPFeedbackKind = "receiver_report"
	RTCPFeedbackPictureLossIndication           RTCPFeedbackKind = "picture_loss_indication"
	RTCPFeedbackFullIntraRequest                RTCPFeedbackKind = "full_intra_request"
	RTCPFeedbackRapidResynchronizationRequest   RTCPFeedbackKind = "rapid_resynchronization_request"
	RTCPFeedbackTransportLayerNack              RTCPFeedbackKind = "transport_layer_nack"
	RTCPFeedbackReceiverEstimatedMaximumBitrate RTCPFeedbackKind = "receiver_estimated_maximum_bitrate"
	RTCPFeedbackTransportLayerCongestionControl RTCPFeedbackKind = "transport_layer_congestion_control"
	RTCPFeedbackSliceLossIndication             RTCPFeedbackKind = "slice_loss_indication"
	RTCPFeedbackExtendedReport                  RTCPFeedbackKind = "extended_report"
	RTCPFeedbackSourceDescription               RTCPFeedbackKind = "source_description"
	RTCPFeedbackGoodbye                         RTCPFeedbackKind = "goodbye"
	RTCPFeedbackApplicationDefined              RTCPFeedbackKind = "application_defined"
	RTCPFeedbackUnknown                         RTCPFeedbackKind = "unknown"
)

type RTCPFeedbackSummary

type RTCPFeedbackSummary struct {
	Packets                          uint64
	SenderReports                    uint64
	ReceiverReports                  uint64
	PictureLossIndications           uint64
	FullIntraRequests                uint64
	RapidResynchronizationRequests   uint64
	TransportLayerNacks              uint64
	ReceiverEstimatedMaximumBitrates uint64
	TransportLayerCongestionControls uint64
	SliceLossIndications             uint64
	ExtendedReports                  uint64
	SourceDescriptions               uint64
	Goodbyes                         uint64
	ApplicationDefined               uint64
	UnknownPackets                   uint64
}

func InspectRTCPFeedback

func InspectRTCPFeedback(direction RTCPFeedbackDirection, packet []byte, handler RTCPFeedbackHandler) (RTCPFeedbackSummary, error)

type RTCPReceptionReport

type RTCPReceptionReport struct {
	SSRC               uint32
	FractionLost       uint8
	TotalLost          uint32
	LastSequenceNumber uint32
	Jitter             uint32
	LastSenderReport   uint32
	Delay              uint32
}

type RTCPReportKind

type RTCPReportKind string
const (
	RTCPReportKindReceiver RTCPReportKind = "receiver"
	RTCPReportKindSender   RTCPReportKind = "sender"
)

type RTCPSenderReportConfig

type RTCPSenderReportConfig struct {
	SSRC           uint32
	NTPTime        uint64
	WallClock      time.Time
	RTPTime        uint32
	PacketCount    uint32
	OctetCount     uint32
	ReceptionStats []RTPStreamStats
}

type RTCPSourceDescriptionConfig

type RTCPSourceDescriptionConfig struct {
	SSRC  uint32
	CNAME string
	Name  string
	Tool  string
}

type RTPDTMFDirection

type RTPDTMFDirection string
const (
	RTPDTMFClientToIMS RTPDTMFDirection = "client_to_ims"
	RTPDTMFIMSToClient RTPDTMFDirection = "ims_to_client"
)

type RTPDTMFEvent

type RTPDTMFEvent struct {
	Direction       RTPDTMFDirection
	PayloadType     uint8
	EventCode       uint8
	Signal          string
	End             bool
	Volume          uint8
	DurationSamples uint16
	DurationMS      int
	SequenceNumber  uint16
	Timestamp       uint32
	SSRC            uint32
	Marker          bool
	ClockRate       int
	Packet          []byte
}

func ParseRTPDTMFEvent

func ParseRTPDTMFEvent(direction RTPDTMFDirection, packet []byte, payloadTypes map[uint8]int) (RTPDTMFEvent, bool, error)

type RTPDTMFHandler

type RTPDTMFHandler func(RTPDTMFEvent)

type RTPDTMFPacket

type RTPDTMFPacket struct {
	PayloadType     uint8
	Marker          bool
	SequenceNumber  uint16
	Timestamp       uint32
	SSRC            uint32
	Signal          string
	End             bool
	Volume          uint8
	DurationSamples uint16
	ClockRate       int
}

type RTPDTMFSequenceConfig

type RTPDTMFSequenceConfig struct {
	PayloadType    uint8
	Signal         string
	DurationMS     int
	StepMS         int
	EndPacketCount int
	Volume         uint8
	SequenceNumber uint16
	Timestamp      uint32
	SSRC           uint32
	ClockRate      int
}

type RTPDTMFSummary

type RTPDTMFSummary struct {
	Events    uint64
	EndEvents uint64
}

func InspectRTPDTMF

func InspectRTPDTMF(direction RTPDTMFDirection, packet []byte, payloadTypes map[uint8]int, handler RTPDTMFHandler) (RTPDTMFSummary, error)

type RTPPlaintextEvent

type RTPPlaintextEvent struct {
	Direction RTPDTMFDirection
	Packet    []byte
}

type RTPPlaintextHandler

type RTPPlaintextHandler func(RTPPlaintextEvent)

type RTPRelayConfig

type RTPRelayConfig struct {
	ClientListenIP      string
	ClientAdvertiseIP   string
	ClientPort          int
	ClientRTCPPort      int
	ClientRTPClockRate  int
	IMSListenIP         string
	IMSAdvertiseIP      string
	IMSPort             int
	IMSRTCPPort         int
	IMSRTPClockRate     int
	BufferSize          int
	Transforms          RTPRelayTransforms
	SRTP                *RTPRelaySRTPConfig
	RTCPFeedbackHandler RTCPFeedbackHandler
	RTPDTMFHandler      RTPDTMFHandler
	RTPQualityHandler   RTPRelayQualityHandler
	RTPQualityConfig    RTPRelayQualityConfig
	RTCPReportSchedule  RTPRelayRTCPReportScheduleConfig
}

type RTPRelayDTMFRequest

type RTPRelayDTMFRequest struct {
	Direction      RTPDTMFDirection
	Signal         string
	DurationMS     int
	StepMS         int
	EndPacketCount int
	Volume         uint8
	SequenceNumber uint16
	Timestamp      uint32
	SSRC           uint32
	PayloadType    uint8
	ClockRate      int
}

type RTPRelayDTMFResult

type RTPRelayDTMFResult struct {
	Packets        int
	Bytes          int
	PayloadType    uint8
	ClockRate      int
	SequenceNumber uint16
	Timestamp      uint32
	SSRC           uint32
	Signal         string
	DurationMS     int
}

type RTPRelayDirectionQuality

type RTPRelayDirectionQuality struct {
	Direction             RTCPFeedbackDirection
	RTPPackets            uint64
	RTPBytes              uint64
	RTPDrops              uint64
	RTCPPackets           uint64
	RTCPBytes             uint64
	RTCPDrops             uint64
	RTPReceivedPackets    uint64
	RTPExpectedPackets    uint64
	RTPLostPackets        uint64
	RTPDuplicatePackets   uint64
	RTPOutOfOrderPackets  uint64
	RTPSequenceRollovers  uint64
	RTPTimestampRollovers uint64
	RTPFractionLost       uint8
	RTPMaxJitter          uint32
	RTPStreams            []RTPStreamStats
	RTCPReports           []RTPRelayRTCPReportQuality
	RTCPMaxRoundTripTime  time.Duration
}

func (RTPRelayDirectionQuality) DiagnoseRTCPReports

DiagnoseRTCPReports classifies the RTCP reports already present in a quality snapshot.

type RTPRelayQualityAction

type RTPRelayQualityAction string

RTPRelayQualityAction is a recovery hint for media quality degradation.

const (
	RTPRelayQualityActionNone                 RTPRelayQualityAction = "none"
	RTPRelayQualityActionMonitor              RTPRelayQualityAction = "monitor"
	RTPRelayQualityActionIncreaseJitterBuffer RTPRelayQualityAction = "increase_jitter_buffer"
	RTPRelayQualityActionReduceBitrate        RTPRelayQualityAction = "reduce_bitrate"
	RTPRelayQualityActionRecoverMediaPath     RTPRelayQualityAction = "recover_media_path"
)

type RTPRelayQualityConfig

type RTPRelayQualityConfig struct {
	ClientToIMS RTPStreamDiagnosisConfig
	IMSToClient RTPStreamDiagnosisConfig
	EmitInitial bool
}

type RTPRelayQualityEvent

type RTPRelayQualityEvent struct {
	Direction      RTCPFeedbackDirection
	Status         RTPStreamDiagnosisStatus
	PreviousStatus RTPStreamDiagnosisStatus
	Reasons        []RTPStreamDiagnosisReason
	Quality        RTPRelayDirectionQuality
	Diagnoses      []RTPStreamDiagnosis
	ObservedAt     time.Time
}

type RTPRelayQualityHandler

type RTPRelayQualityHandler func(RTPRelayQualityEvent)

type RTPRelayQualityStats

type RTPRelayQualityStats struct {
	ClientToIMS             RTPRelayDirectionQuality
	IMSToClient             RTPRelayDirectionQuality
	RTCPFeedback            RTCPFeedbackSummary
	RTCPFeedbackParseErrors uint64
}

type RTPRelayRTCPReportDiagnosis

RTPRelayRTCPReportDiagnosis classifies one remote RTCP reception report.

func DiagnoseRTPRelayRTCPReports

func DiagnoseRTPRelayRTCPReports(reports []RTPRelayRTCPReportQuality, cfg RTPStreamDiagnosisConfig) []RTPRelayRTCPReportDiagnosis

DiagnoseRTPRelayRTCPReports classifies remote RTCP reception reports and preserves the input order.

type RTPRelayRTCPReportJitterDiagnosis

type RTPRelayRTCPReportJitterDiagnosis struct {
	Status   RTPStreamDiagnosisStatus
	Jitter   uint32
	Duration time.Duration
}

RTPRelayRTCPReportJitterDiagnosis classifies report-block jitter using the configured clock rate.

type RTPRelayRTCPReportLossDiagnosis

type RTPRelayRTCPReportLossDiagnosis struct {
	Status       RTPStreamDiagnosisStatus
	FractionLost uint8
	TotalLost    uint32
}

RTPRelayRTCPReportLossDiagnosis classifies the report-block loss fields.

type RTPRelayRTCPReportQuality

type RTPRelayRTCPReportQuality struct {
	Direction          RTCPFeedbackDirection
	ReporterSSRC       uint32
	MediaSSRC          uint32
	FractionLost       uint8
	TotalLost          uint32
	LastSequenceNumber uint32
	Jitter             uint32
	LastSenderReport   uint32
	Delay              uint32
	RoundTripTime      time.Duration
}

func (RTPRelayRTCPReportQuality) Diagnose

Diagnose classifies loss, jitter, and RTT for one remote RTCP reception report.

type RTPRelayRTCPReportRoundTripTimeDiagnosis

type RTPRelayRTCPReportRoundTripTimeDiagnosis struct {
	Status        RTPStreamDiagnosisStatus
	RoundTripTime time.Duration
}

RTPRelayRTCPReportRoundTripTimeDiagnosis classifies RTT computed from LSR/DLSR timing.

type RTPRelayRTCPReportScheduleConfig

type RTPRelayRTCPReportScheduleConfig struct {
	Enabled            bool
	Interval           time.Duration
	ClientToIMS        bool
	IMSToClient        bool
	Kind               RTCPReportKind
	SenderSSRC         uint32
	ClientToIMSSSRC    uint32
	IMSToClientSSRC    uint32
	ClientToIMSCNAME   string
	IMSToClientCNAME   string
	ClientToIMSRTPTime uint32
	IMSToClientRTPTime uint32
	ClientToIMSPackets uint32
	IMSToClientPackets uint32
	ClientToIMSOctets  uint32
	IMSToClientOctets  uint32
	RunImmediately     bool
	StopOnError        bool
}

type RTPRelayRTCPRequest

type RTPRelayRTCPRequest struct {
	Direction RTCPFeedbackDirection
	Packets   []rtcp.Packet
}

type RTPRelayRTCPResult

type RTPRelayRTCPResult struct {
	Datagrams int
	Bytes     int
	Feedback  RTCPFeedbackSummary
}

type RTPRelayReceiverReportRequest

type RTPRelayReceiverReportRequest struct {
	Direction  RTCPFeedbackDirection
	SenderSSRC uint32
}

type RTPRelaySRTPConfig

type RTPRelaySRTPConfig struct {
	Profiles         []SRTPProtectionProfile
	CryptoTag        string
	SessionParams    string
	ReplayWindowSize uint
	Random           io.Reader
}

type RTPRelaySenderReportRequest

type RTPRelaySenderReportRequest struct {
	Direction   RTCPFeedbackDirection
	SSRC        uint32
	CNAME       string
	NTPTime     uint64
	WallClock   time.Time
	RTPTime     uint32
	PacketCount uint32
	OctetCount  uint32
}

type RTPRelaySession

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

func NewRTPRelaySession

func NewRTPRelaySession(ctx context.Context, cfg RTPRelayConfig, clientTarget SDPInfo) (*RTPRelaySession, error)

func NewRTPRelaySessionForIMSRemote

func NewRTPRelaySessionForIMSRemote(ctx context.Context, cfg RTPRelayConfig, imsTarget SDPInfo) (*RTPRelaySession, error)

func (*RTPRelaySession) ClientAnswerSDP

func (s *RTPRelaySession) ClientAnswerSDP(imsAnswer SDPInfo) []byte

func (*RTPRelaySession) ClientEndpoint

func (s *RTPRelaySession) ClientEndpoint() SDPInfo

func (*RTPRelaySession) ClientToIMSRTPStreamStats

func (s *RTPRelaySession) ClientToIMSRTPStreamStats() []RTPStreamStats

func (*RTPRelaySession) Close

func (s *RTPRelaySession) Close() error

func (*RTPRelaySession) HasRTCPReportSchedule

func (s *RTPRelaySession) HasRTCPReportSchedule() bool

func (*RTPRelaySession) IMSEndpoint

func (s *RTPRelaySession) IMSEndpoint() SDPInfo

func (*RTPRelaySession) IMSOfferSDP

func (s *RTPRelaySession) IMSOfferSDP(clientOffer SDPInfo) []byte

func (*RTPRelaySession) IMSToClientRTPStreamStats

func (s *RTPRelaySession) IMSToClientRTPStreamStats() []RTPStreamStats

func (*RTPRelaySession) ObserveRTPPlaintext

func (s *RTPRelaySession) ObserveRTPPlaintext(event RTPPlaintextEvent)

func (*RTPRelaySession) Quality

func (*RTPRelaySession) RTPPlaintextHandler

func (s *RTPRelaySession) RTPPlaintextHandler() RTPPlaintextHandler

func (*RTPRelaySession) SendRTCP

func (*RTPRelaySession) SendRTCPToClient

func (s *RTPRelaySession) SendRTCPToClient(ctx context.Context, packets ...rtcp.Packet) (RTPRelayRTCPResult, error)

func (*RTPRelaySession) SendRTCPToIMS

func (s *RTPRelaySession) SendRTCPToIMS(ctx context.Context, packets ...rtcp.Packet) (RTPRelayRTCPResult, error)

func (*RTPRelaySession) SendRTPDTMF

func (*RTPRelaySession) SendRTPDTMFToClient

func (s *RTPRelaySession) SendRTPDTMFToClient(ctx context.Context, req RTPRelayDTMFRequest) (RTPRelayDTMFResult, error)

func (*RTPRelaySession) SendRTPDTMFToIMS

func (*RTPRelaySession) SendReceiverReport

func (*RTPRelaySession) SendReceiverReportToClient

func (s *RTPRelaySession) SendReceiverReportToClient(ctx context.Context, senderSSRC uint32) (RTPRelayRTCPResult, error)

func (*RTPRelaySession) SendReceiverReportToIMS

func (s *RTPRelaySession) SendReceiverReportToIMS(ctx context.Context, senderSSRC uint32) (RTPRelayRTCPResult, error)

func (*RTPRelaySession) SendSenderReport

func (*RTPRelaySession) SendSenderReportToClient

func (s *RTPRelaySession) SendSenderReportToClient(ctx context.Context, req RTPRelaySenderReportRequest) (RTPRelayRTCPResult, error)

func (*RTPRelaySession) SendSenderReportToIMS

func (*RTPRelaySession) SetClientRemote

func (s *RTPRelaySession) SetClientRemote(info SDPInfo) error

func (*RTPRelaySession) SetIMSRemote

func (s *RTPRelaySession) SetIMSRemote(info SDPInfo) error

func (*RTPRelaySession) SetTransforms

func (s *RTPRelaySession) SetTransforms(transforms RTPRelayTransforms) error

func (*RTPRelaySession) StartRTCPReportSchedule

func (s *RTPRelaySession) StartRTCPReportSchedule(ctx context.Context, cfg RTPRelayRTCPReportScheduleConfig) error

func (*RTPRelaySession) Stats

func (s *RTPRelaySession) Stats() RTPRelayStats

func (*RTPRelaySession) StopRTCPReportSchedule

func (s *RTPRelaySession) StopRTCPReportSchedule()

func (*RTPRelaySession) Transforms

func (s *RTPRelaySession) Transforms() RTPRelayTransforms

type RTPRelayStats

type RTPRelayStats struct {
	ClientToIMSPackets                   uint64
	IMSToClientPackets                   uint64
	ClientToIMSBytes                     uint64
	IMSToClientBytes                     uint64
	ClientToIMSRTPPackets                uint64
	IMSToClientRTPPackets                uint64
	ClientToIMSRTCPPackets               uint64
	IMSToClientRTCPPackets               uint64
	ClientToIMSRTPBytes                  uint64
	IMSToClientRTPBytes                  uint64
	ClientToIMSRTCPBytes                 uint64
	IMSToClientRTCPBytes                 uint64
	ClientToIMSRTPDrops                  uint64
	IMSToClientRTPDrops                  uint64
	ClientToIMSRTCPDrops                 uint64
	IMSToClientRTCPDrops                 uint64
	RTCPFeedbackPackets                  uint64
	RTCPFeedbackParseErrors              uint64
	RTCPSenderReports                    uint64
	RTCPReceiverReports                  uint64
	RTCPPictureLossIndications           uint64
	RTCPFullIntraRequests                uint64
	RTCPRapidResynchronizationRequests   uint64
	RTCPTransportLayerNacks              uint64
	RTCPReceiverEstimatedMaximumBitrates uint64
	RTCPTransportLayerCongestionControls uint64
	RTCPSliceLossIndications             uint64
	RTCPExtendedReports                  uint64
	RTCPSourceDescriptions               uint64
	RTCPGoodbyes                         uint64
	RTCPApplicationDefined               uint64
	RTCPUnknownPackets                   uint64
	RTPDTMFEvents                        uint64
	RTPDTMFEndEvents                     uint64
	RTPDTMFClientToIMSEvents             uint64
	RTPDTMFIMSToClientEvents             uint64
	RTPDTMFRemappedEvents                uint64
	RTPDTMFClientToIMSRemappedEvents     uint64
	RTPDTMFIMSToClientRemappedEvents     uint64
	RTPDTMFParseErrors                   uint64
	ClientToIMSRTPStreams                []RTPStreamStats
	IMSToClientRTPStreams                []RTPStreamStats
}

type RTPRelayTransform

type RTPRelayTransform func([]byte) ([]byte, error)

type RTPRelayTransforms

type RTPRelayTransforms struct {
	ClientToIMSRTP        RTPRelayTransform
	IMSToClientRTP        RTPRelayTransform
	ClientToIMSRTCP       RTPRelayTransform
	IMSToClientRTCP       RTPRelayTransform
	GeneratedToIMSRTP     RTPRelayTransform
	GeneratedToClientRTP  RTPRelayTransform
	GeneratedToIMSRTCP    RTPRelayTransform
	GeneratedToClientRTCP RTPRelayTransform
}

type RTPStreamDiagnosis

type RTPStreamDiagnosis struct {
	SSRC          uint32
	Status        RTPStreamDiagnosisStatus
	Reasons       []RTPStreamDiagnosisReason
	Loss          RTPStreamLossDiagnosis
	Jitter        RTPStreamJitterDiagnosis
	RTCPKeepalive RTPStreamRTCPKeepaliveDiagnosis
}

func DiagnoseRTPStreamStats

func DiagnoseRTPStreamStats(stats []RTPStreamStats, cfg RTPStreamDiagnosisConfig) []RTPStreamDiagnosis

DiagnoseRTPStreamStats classifies RTP stream snapshots without touching the network or requiring a live relay. The output preserves input order.

type RTPStreamDiagnosisConfig

type RTPStreamDiagnosisConfig struct {
	ClockRate             int
	MinExpectedPackets    uint64
	LossWarningFraction   uint8
	LossCriticalFraction  uint8
	JitterWarning         time.Duration
	JitterCritical        time.Duration
	RoundTripWarning      time.Duration
	RoundTripCritical     time.Duration
	RTCPKeepaliveInterval time.Duration
	RTCPKeepaliveGrace    time.Duration
	RequireRTCP           bool
}

RTPStreamDiagnosisConfig tunes the conservative thresholds used to classify a received RTP stream and remote RTCP reception reports. RTCP keepalive classification is enabled only when RTCPKeepaliveInterval is positive or RequireRTCP is true.

type RTPStreamDiagnosisReason

type RTPStreamDiagnosisReason string
const (
	RTPStreamDiagnosisReasonNoRTP         RTPStreamDiagnosisReason = "no_rtp"
	RTPStreamDiagnosisReasonPacketLoss    RTPStreamDiagnosisReason = "packet_loss"
	RTPStreamDiagnosisReasonJitter        RTPStreamDiagnosisReason = "jitter"
	RTPStreamDiagnosisReasonRTCPKeepalive RTPStreamDiagnosisReason = "rtcp_keepalive"
	RTPStreamDiagnosisReasonRoundTripTime RTPStreamDiagnosisReason = "round_trip_time"
)

type RTPStreamDiagnosisStatus

type RTPStreamDiagnosisStatus string
const (
	RTPStreamDiagnosisStatusUnknown  RTPStreamDiagnosisStatus = "unknown"
	RTPStreamDiagnosisStatusOK       RTPStreamDiagnosisStatus = "ok"
	RTPStreamDiagnosisStatusWarning  RTPStreamDiagnosisStatus = "warning"
	RTPStreamDiagnosisStatusCritical RTPStreamDiagnosisStatus = "critical"
)

type RTPStreamJitterDiagnosis

type RTPStreamJitterDiagnosis struct {
	Status   RTPStreamDiagnosisStatus
	Jitter   uint32
	Duration time.Duration
}

type RTPStreamLossDiagnosis

type RTPStreamLossDiagnosis struct {
	Status          RTPStreamDiagnosisStatus
	FractionLost    uint8
	LostPackets     uint64
	ExpectedPackets uint64
}

type RTPStreamRTCPKeepaliveDiagnosis

type RTPStreamRTCPKeepaliveDiagnosis struct {
	Status           RTPStreamDiagnosisStatus
	LastSenderReport uint32
	Delay            time.Duration
	StaleAfter       time.Duration
	Missing          bool
}

type RTPStreamStats

type RTPStreamStats struct {
	SSRC               uint32
	Packets            uint64
	DuplicatePackets   uint64
	OutOfOrderPackets  uint64
	ExpectedPackets    uint64
	LostPackets        uint64
	FractionLost       uint8
	LastSequenceNumber uint32
	SequenceRollovers  uint32
	LastTimestamp      uint64
	TimestampRollovers uint32
	Jitter             uint32
	LastSenderReport   uint32
	Delay              uint32
}

RTPStreamStats is a reception snapshot for one RTP SSRC.

func (RTPStreamStats) Diagnose

Diagnose classifies packet loss, jitter, and RTCP keepalive freshness for one RTP stream snapshot.

type RTPStreamStatsTracker

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

RTPStreamStatsTracker keeps RTP reception statistics split by SSRC.

func NewRTPStreamStatsTracker

func NewRTPStreamStatsTracker() *RTPStreamStatsTracker

NewRTPStreamStatsTracker returns an empty tracker. The zero value is also usable.

func (*RTPStreamStatsTracker) ObserveRTCPPacket

func (t *RTPStreamStatsTracker) ObserveRTCPPacket(packet []byte, arrival time.Time) ([]RTPStreamStats, error)

ObserveRTCPPacket parses one RTCP datagram and records any Sender Reports it contains. Snapshots are returned only for SSRCs whose RTP stream is already being tracked; Sender Reports for future streams are still remembered.

func (*RTPStreamStatsTracker) ObserveRTCPSenderReport

func (t *RTPStreamStatsTracker) ObserveRTCPSenderReport(ssrc uint32, ntpTime uint64, arrival time.Time) (RTPStreamStats, bool)

ObserveRTCPSenderReport records the newest SR timing for an RTP source so future RTCP reception reports can include LSR/DLSR timing fields.

func (*RTPStreamStatsTracker) ObserveRTPPacket

func (t *RTPStreamStatsTracker) ObserveRTPPacket(packet []byte, arrival time.Time, clockRate int) (RTPStreamStats, error)

ObserveRTPPacket parses one RTP packet and updates the matching SSRC stream.

func (*RTPStreamStatsTracker) Stats

Stats returns deterministic snapshots ordered by SSRC.

func (*RTPStreamStatsTracker) StatsAt

func (t *RTPStreamStatsTracker) StatsAt(now time.Time) []RTPStreamStats

StatsAt returns deterministic snapshots ordered by SSRC with DLSR measured against now for streams that have observed an RTCP sender report.

func (*RTPStreamStatsTracker) StatsForSSRC

func (t *RTPStreamStatsTracker) StatsForSSRC(ssrc uint32) (RTPStreamStats, bool)

StatsForSSRC returns a snapshot for one SSRC when the tracker has observed it.

func (*RTPStreamStatsTracker) StatsForSSRCAt

func (t *RTPStreamStatsTracker) StatsForSSRCAt(ssrc uint32, now time.Time) (RTPStreamStats, bool)

StatsForSSRCAt returns a snapshot for one SSRC with DLSR measured against now.

type SDPAMRFMTPCompatibility

type SDPAMRFMTPCompatibility struct {
	Compatible bool
	Status     SDPAMRFMTPCompatibilityStatus
	Parameter  string
	AnswerFMTP string
}

SDPAMRFMTPCompatibility describes whether offered AMR/AMR-WB fmtp parameters can satisfy a local codec preference and, when compatible, the fmtp to answer.

func ClassifySDPAMRFMTPCompatibility

func ClassifySDPAMRFMTPCompatibility(offered, want string) SDPAMRFMTPCompatibility

ClassifySDPAMRFMTPCompatibility checks whether offered AMR/AMR-WB fmtp parameters can satisfy a local codec preference.

type SDPAMRFMTPCompatibilityStatus

type SDPAMRFMTPCompatibilityStatus string
const (
	SDPAMRFMTPCompatible            SDPAMRFMTPCompatibilityStatus = "compatible"
	SDPAMRFMTPIncompatibleParameter SDPAMRFMTPCompatibilityStatus = "incompatible_parameter"
	SDPAMRFMTPIncompatibleModeSet   SDPAMRFMTPCompatibilityStatus = "incompatible_mode_set"
)

type SDPAnswerOptions

type SDPAnswerOptions struct {
	RTPProfile string
	RTCPMux    bool
	Codecs     []SDPCodec
	Security   SDPSecurityInfo
	PTimeMS    int
	MaxPTimeMS int
}

type SDPCodec

type SDPCodec struct {
	Payload      int
	EncodingName string
	ClockRate    int
	Channels     int
	FMTP         string
}

func NewSDPAMRCodec

func NewSDPAMRCodec(payload int, fmtp string) SDPCodec

func NewSDPAMRWBCodec

func NewSDPAMRWBCodec(payload int, fmtp string) SDPCodec

func NewSDPPCMACodec

func NewSDPPCMACodec() SDPCodec

func NewSDPPCMUCodec

func NewSDPPCMUCodec() SDPCodec

func NewSDPTelephoneEventCodec

func NewSDPTelephoneEventCodec(payload, clockRate int) SDPCodec

func SelectSDPAnswerCodecs

func SelectSDPAnswerCodecs(offer, local []SDPCodec) []SDPCodec

type SDPCryptoAttribute

type SDPCryptoAttribute struct {
	Tag           string
	Suite         string
	KeyParams     string
	SessionParams string
}

func BuildSDPCryptoAttribute

func BuildSDPCryptoAttribute(tag string, profile SRTPProtectionProfile, params SDPCryptoInlineKeyParams, sessionParams string) (SDPCryptoAttribute, error)

func (SDPCryptoAttribute) SDPValue

func (a SDPCryptoAttribute) SDPValue() string

type SDPCryptoInlineKeyParams

type SDPCryptoInlineKeyParams struct {
	MasterKey  []byte
	MasterSalt []byte
	Lifetime   string
	MKIValue   string
	MKILength  int
}

func ParseSDPCryptoInlineKeyParams

func ParseSDPCryptoInlineKeyParams(profile SRTPProtectionProfile, keyParams string) (SDPCryptoInlineKeyParams, error)

type SDPFingerprintAttribute

type SDPFingerprintAttribute struct {
	HashFunc    string
	Fingerprint string
}

func (SDPFingerprintAttribute) SDPValue

func (a SDPFingerprintAttribute) SDPValue() string

type SDPInfo

type SDPInfo struct {
	ConnectionIP           string
	MediaPort              int
	RTCPIP                 string
	RTCPPort               int
	Payloads               []int
	TelephoneEventPayloads map[uint8]int
	Direction              string
	PTimeMS                int
	MaxPTimeMS             int
}

func ParseSDP

func ParseSDP(body []byte) (SDPInfo, error)

func SDPInfoWithCodecs

func SDPInfoWithCodecs(info SDPInfo, codecs []SDPCodec) SDPInfo

type SDPMediaDescription

type SDPMediaDescription struct {
	Info         SDPInfo
	RTPProfile   string
	RTCPMux      bool
	ExplicitRTCP bool
	Codecs       []SDPCodec
}

func ParseSDPMediaDescription

func ParseSDPMediaDescription(body []byte) (SDPMediaDescription, error)

type SDPMediaRewriteOptions

type SDPMediaRewriteOptions struct {
	RTCPMux bool
}

type SDPRTCPFeedbackAttribute

type SDPRTCPFeedbackAttribute struct {
	Payload   string
	Type      string
	Parameter string
}

func ParseSDPRTCPFeedbackAttributes

func ParseSDPRTCPFeedbackAttributes(body []byte) ([]SDPRTCPFeedbackAttribute, error)

func ParseSDPRTCPFeedbackLine

func ParseSDPRTCPFeedbackLine(line string) (SDPRTCPFeedbackAttribute, bool, error)

func SelectSDPRTCPFeedbackAnswer

func SelectSDPRTCPFeedbackAnswer(offer, local []SDPRTCPFeedbackAttribute, payloads []int) []SDPRTCPFeedbackAttribute

func (SDPRTCPFeedbackAttribute) AppliesToPayload

func (a SDPRTCPFeedbackAttribute) AppliesToPayload(payload int) bool

func (SDPRTCPFeedbackAttribute) RTCPFeedbackKind

func (a SDPRTCPFeedbackAttribute) RTCPFeedbackKind() RTCPFeedbackKind

func (SDPRTCPFeedbackAttribute) SDPValue

func (a SDPRTCPFeedbackAttribute) SDPValue() string

type SDPRTCPFeedbackPolicy

type SDPRTCPFeedbackPolicy struct {
	Payload                         int
	TransportLayerNack              bool
	PictureLossIndication           bool
	FullIntraRequest                bool
	ReceiverEstimatedMaximumBitrate bool
	TransportLayerCongestionControl bool
	SliceLossIndication             bool
}

func BuildSDPRTCPFeedbackPolicy

func BuildSDPRTCPFeedbackPolicy(attrs []SDPRTCPFeedbackAttribute, payload int) SDPRTCPFeedbackPolicy

func (SDPRTCPFeedbackPolicy) Allows

type SDPSecurityAnswerOptions

type SDPSecurityAnswerOptions struct {
	RTPProfiles  []string
	Crypto       []SDPCryptoAttribute
	Fingerprints []SDPFingerprintAttribute
	Setup        string
	PreferCrypto bool
}

type SDPSecurityInfo

type SDPSecurityInfo struct {
	RTPProfile        string
	Crypto            []SDPCryptoAttribute
	Fingerprints      []SDPFingerprintAttribute
	Setup             string
	RTCPMux           bool
	RTCPMuxOnly       bool
	RTCPReducedSize   bool
	RTCPFeedback      []SDPRTCPFeedbackAttribute
	UnknownAttributes []string
}

func ParseSDPSecurity

func ParseSDPSecurity(body []byte) (SDPSecurityInfo, error)

func SelectSDPSecurityAnswer

func SelectSDPSecurityAnswer(offer SDPSecurityInfo, options SDPSecurityAnswerOptions) (SDPSecurityInfo, error)

func (SDPSecurityInfo) HasSecurityAttributes

func (s SDPSecurityInfo) HasSecurityAttributes() bool

func (SDPSecurityInfo) IsZero

func (s SDPSecurityInfo) IsZero() bool

type SRTPKeys

type SRTPKeys struct {
	MasterKey  []byte
	MasterSalt []byte
}

func GenerateSRTPKeys

func GenerateSRTPKeys(profile SRTPProtectionProfile, random io.Reader) (SRTPKeys, error)

func (SRTPKeys) IsZero

func (k SRTPKeys) IsZero() bool

type SRTPMediaConfig

type SRTPMediaConfig struct {
	Profile               SRTPProtectionProfile
	ClientKeys            SRTPKeys
	IMSKeys               SRTPKeys
	ClientProtectKeys     SRTPKeys
	ClientUnprotectKeys   SRTPKeys
	IMSProtectKeys        SRTPKeys
	IMSUnprotectKeys      SRTPKeys
	ReplayWindowSize      uint
	RTCPFeedbackHandler   RTCPFeedbackHandler
	RTPDTMFHandler        RTPDTMFHandler
	RTPPlaintextHandler   RTPPlaintextHandler
	ClientRTPDTMFPayloads map[uint8]int
	IMSRTPDTMFPayloads    map[uint8]int
}

type SRTPMediaSession

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

func NewSRTPMediaSession

func NewSRTPMediaSession(cfg SRTPMediaConfig) (*SRTPMediaSession, error)

func (*SRTPMediaSession) ClientToIMSRTCP

func (s *SRTPMediaSession) ClientToIMSRTCP(packet []byte) ([]byte, error)

func (*SRTPMediaSession) ClientToIMSRTP

func (s *SRTPMediaSession) ClientToIMSRTP(packet []byte) ([]byte, error)

func (*SRTPMediaSession) IMSToClientRTCP

func (s *SRTPMediaSession) IMSToClientRTCP(packet []byte) ([]byte, error)

func (*SRTPMediaSession) IMSToClientRTP

func (s *SRTPMediaSession) IMSToClientRTP(packet []byte) ([]byte, error)

func (*SRTPMediaSession) ProtectClientRTCP

func (s *SRTPMediaSession) ProtectClientRTCP(packet []byte) ([]byte, error)

func (*SRTPMediaSession) ProtectClientRTP

func (s *SRTPMediaSession) ProtectClientRTP(packet []byte) ([]byte, error)

func (*SRTPMediaSession) ProtectIMSRTCP

func (s *SRTPMediaSession) ProtectIMSRTCP(packet []byte) ([]byte, error)

func (*SRTPMediaSession) ProtectIMSRTP

func (s *SRTPMediaSession) ProtectIMSRTP(packet []byte) ([]byte, error)

func (*SRTPMediaSession) RelayTransforms

func (s *SRTPMediaSession) RelayTransforms() RTPRelayTransforms

func (*SRTPMediaSession) RelayTransformsWithMediaEvents

func (s *SRTPMediaSession) RelayTransformsWithMediaEvents(rtcpHandler RTCPFeedbackHandler, dtmfHandler RTPDTMFHandler, clientRTPDTMFPayloads, imsRTPDTMFPayloads map[uint8]int) RTPRelayTransforms

func (*SRTPMediaSession) RelayTransformsWithMediaObservers

func (s *SRTPMediaSession) RelayTransformsWithMediaObservers(rtcpHandler RTCPFeedbackHandler, dtmfHandler RTPDTMFHandler, rtpHandler RTPPlaintextHandler, clientRTPDTMFPayloads, imsRTPDTMFPayloads map[uint8]int) RTPRelayTransforms

func (*SRTPMediaSession) RelayTransformsWithRTCPFeedback

func (s *SRTPMediaSession) RelayTransformsWithRTCPFeedback(handler RTCPFeedbackHandler) RTPRelayTransforms

func (*SRTPMediaSession) UnprotectClientRTCP

func (s *SRTPMediaSession) UnprotectClientRTCP(packet []byte) ([]byte, error)

func (*SRTPMediaSession) UnprotectClientRTP

func (s *SRTPMediaSession) UnprotectClientRTP(packet []byte) ([]byte, error)

func (*SRTPMediaSession) UnprotectIMSRTCP

func (s *SRTPMediaSession) UnprotectIMSRTCP(packet []byte) ([]byte, error)

func (*SRTPMediaSession) UnprotectIMSRTP

func (s *SRTPMediaSession) UnprotectIMSRTP(packet []byte) ([]byte, error)

type SRTPProtectionProfile

type SRTPProtectionProfile string
const (
	SRTPProfileAes128CmHmacSha1_80 SRTPProtectionProfile = "AES_CM_128_HMAC_SHA1_80"
	SRTPProfileAes128CmHmacSha1_32 SRTPProtectionProfile = "AES_CM_128_HMAC_SHA1_32"
	SRTPProfileAes256CmHmacSha1_80 SRTPProtectionProfile = "AES_CM_256_HMAC_SHA1_80"
	SRTPProfileAes256CmHmacSha1_32 SRTPProtectionProfile = "AES_CM_256_HMAC_SHA1_32"
	SRTPProfileAeadAes128Gcm       SRTPProtectionProfile = "AEAD_AES_128_GCM"
	SRTPProfileAeadAes256Gcm       SRTPProtectionProfile = "AEAD_AES_256_GCM"
)

func SRTPProtectionProfileFromSDPCryptoSuite

func SRTPProtectionProfileFromSDPCryptoSuite(suite string) (SRTPProtectionProfile, error)

func (SRTPProtectionProfile) SDPCryptoSuite

func (p SRTPProtectionProfile) SDPCryptoSuite() string

type SimulateCallRequest

type SimulateCallRequest struct {
	Callee      string `json:"callee"`
	HoldSeconds int    `json:"hold_seconds"`
	OnConnected func() `json:"-"`
}

type SimulateCallResult

type SimulateCallResult struct {
	Success    bool   `json:"success"`
	Reason     string `json:"reason,omitempty"`
	DurationMs int64  `json:"duration_ms"`
}

Jump to

Keyboard shortcuts

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