Documentation ¶
Index ¶
- Variables
- func MatchDialog(req *sip.Request) (*DialogServerSession, *DialogClientSession, error)
- func NewConnRecorder() *connRecorder
- type AudioPlayback
- type AudioPlaybackControl
- type AudioReaderOption
- type AudioWriterOption
- type Bridge
- type Bridger
- type DTMFReader
- type DTMFWriter
- type Diago
- func (dg *Diago) Invite(ctx context.Context, recipient sip.Uri, opts InviteOptions) (d *DialogClientSession, err error)
- func (dg *Diago) InviteBridge(ctx context.Context, recipient sip.Uri, bridge *Bridge, opts InviteOptions) (d *DialogClientSession, err error)
- func (dg *Diago) Register(ctx context.Context, recipient sip.Uri, opts RegisterOptions) error
- func (dg *Diago) RegisterTransaction(ctx context.Context, recipient sip.Uri, opts RegisterOptions) (*RegisterTransaction, error)
- func (dg *Diago) Serve(ctx context.Context, f ServeDialogFunc) error
- func (dg *Diago) ServeBackground(ctx context.Context, f ServeDialogFunc) error
- type DiagoOption
- type DialogCache
- type DialogClientSession
- func (d *DialogClientSession) Close()
- func (d *DialogClientSession) DialogSIP() *sipgo.Dialog
- func (d *DialogClientSession) FromUser() string
- func (d *DialogClientSession) Hangup(ctx context.Context) error
- func (d *DialogClientSession) Id() string
- func (d *DialogClientSession) ReInvite(ctx context.Context) error
- func (d *DialogClientSession) RemoteContact() *sip.ContactHeader
- func (d *DialogClientSession) ToUser() string
- type DialogData
- type DialogMedia
- func (d *DialogMedia) AudioReader(opts ...AudioReaderOption) (io.Reader, error)
- func (m *DialogMedia) AudioReaderDTMF() *DTMFReader
- func (d *DialogMedia) AudioWriter(opts ...AudioWriterOption) (io.Writer, error)
- func (m *DialogMedia) AudioWriterDTMF() *DTMFWriter
- func (d *DialogMedia) Close()
- func (d *DialogMedia) InitMediaSession(m *media.MediaSession, r *media.RTPPacketReader, w *media.RTPPacketWriter)
- func (d *DialogMedia) Listen() error
- func (d *DialogMedia) ListenContext(ctx context.Context) error
- func (d *DialogMedia) ListenUntil(dur time.Duration) error
- func (d *DialogMedia) Media() *DialogMedia
- func (d *DialogMedia) OnClose(f func())
- func (d *DialogMedia) PlaybackControlCreate() (AudioPlaybackControl, error)
- func (d *DialogMedia) PlaybackCreate() (AudioPlayback, error)
- func (d *DialogMedia) SetAudioReader(r io.Reader)
- func (d *DialogMedia) SetAudioWriter(r io.Writer)
- type DialogServerSession
- func (d *DialogServerSession) Answer() error
- func (d *DialogServerSession) AnswerSession(rtpSess *media.RTPSession) error
- func (d *DialogServerSession) Close()
- func (d *DialogServerSession) DialogSIP() *sipgo.Dialog
- func (d *DialogServerSession) FromUser() string
- func (d *DialogServerSession) Hangup(ctx context.Context) error
- func (d *DialogServerSession) Id() string
- func (d *DialogServerSession) Progress() error
- func (d *DialogServerSession) ReInvite(ctx context.Context) error
- func (d *DialogServerSession) Refer(ctx context.Context, referTo sip.Uri) error
- func (d *DialogServerSession) RemoteContact() *sip.ContactHeader
- func (d *DialogServerSession) Respond(statusCode sip.StatusCode, reason string, body []byte, headers ...sip.Header) error
- func (d *DialogServerSession) RespondSDP(body []byte) error
- func (d *DialogServerSession) Ringing() error
- func (d *DialogServerSession) ToUser() string
- func (d *DialogServerSession) Transport() string
- type DialogSession
- type InviteOptions
- type MediaConfig
- type MediaProps
- type RegisterOptions
- type RegisterResponseError
- type RegisterTransaction
- type ServeDialogFunc
- type Transport
Constants ¶
This section is empty.
Variables ¶
var (
HTTPDebug = os.Getenv("HTTP_DEBUG") == "true"
)
var (
PlaybackBufferSize = 320
)
Functions ¶
func MatchDialog ¶
func MatchDialog(req *sip.Request) (*DialogServerSession, *DialogClientSession, error)
func NewConnRecorder ¶ added in v0.3.0
func NewConnRecorder() *connRecorder
Types ¶
type AudioPlayback ¶
type AudioPlayback struct { // Read only values // This will influence playout sampling buffer BitDepth int NumChannels int // contains filtered or unexported fields }
func NewAudioPlayback ¶
func NewAudioPlayback(writer io.Writer, codec media.Codec) AudioPlayback
NewAudioPlayback creates a playback where writer is encoder/streamer to media codec Use dialog.PlaybackCreate() instead creating manually playback
func (*AudioPlayback) Play ¶
Play is generic approach to play supported audio contents Empty mimeType will stream reader as buffer. Make sure that bitdepth and numchannels is set correctly
type AudioPlaybackControl ¶
type AudioPlaybackControl struct { AudioPlayback // contains filtered or unexported fields }
func (*AudioPlaybackControl) Mute ¶
func (p *AudioPlaybackControl) Mute(mute bool)
func (*AudioPlaybackControl) Stop ¶
func (p *AudioPlaybackControl) Stop()
type AudioReaderOption ¶
type AudioReaderOption func(d *DialogMedia) error
func WithAudioReaderMediaProps ¶
func WithAudioReaderMediaProps(p *MediaProps) AudioReaderOption
type AudioWriterOption ¶
type AudioWriterOption func(d *DialogMedia) error
func WithAudioWriterMediaProps ¶
func WithAudioWriterMediaProps(p *MediaProps) AudioWriterOption
type Bridge ¶
type Bridge struct { // Originator is dialog session that created bridge Originator DialogSession // contains filtered or unexported fields }
func (*Bridge) AddDialogSession ¶
func (b *Bridge) AddDialogSession(d DialogSession) error
func (*Bridge) GetDialogs ¶
func (b *Bridge) GetDialogs() []DialogSession
type Bridger ¶
type Bridger interface {
AddDialogSession(d DialogSession) error
}
type DTMFReader ¶
type DTMFReader struct {
// contains filtered or unexported fields
}
type DTMFWriter ¶
type DTMFWriter struct {
// contains filtered or unexported fields
}
func (*DTMFWriter) WriteDTMF ¶
func (w *DTMFWriter) WriteDTMF(dtmf rune) error
type Diago ¶
type Diago struct {
// contains filtered or unexported fields
}
func NewDiago ¶
func NewDiago(ua *sipgo.UserAgent, opts ...DiagoOption) *Diago
NewDiago construct b2b user agent that will act as server and client
func (*Diago) Invite ¶
func (dg *Diago) Invite(ctx context.Context, recipient sip.Uri, opts InviteOptions) (d *DialogClientSession, err error)
Invite makes outgoing call leg and waits for answer. If you want to bridge call then use helper InviteBridge
func (*Diago) InviteBridge ¶
func (dg *Diago) InviteBridge(ctx context.Context, recipient sip.Uri, bridge *Bridge, opts InviteOptions) (d *DialogClientSession, err error)
InviteBridge makes outgoing call leg and does bridging. Outgoing session will be added into bridge on answer If bridge has Originator (first participant) it will be used for creating outgoing call leg as in B2BUA When bridge is provided then this call will be bridged with any participant already present in bridge TODO: - transcoding will not be allowed -> error will be returned
func (*Diago) Register ¶ added in v0.2.0
Register will create register transaction and keep registration ongoing until error is hit. For more granular control over registraions user RegisterTransaction
func (*Diago) RegisterTransaction ¶ added in v0.3.0
func (dg *Diago) RegisterTransaction(ctx context.Context, recipient sip.Uri, opts RegisterOptions) (*RegisterTransaction, error)
Register transaction creates register transaction object that can be used for Register Unregister requests
func (*Diago) ServeBackground ¶
func (dg *Diago) ServeBackground(ctx context.Context, f ServeDialogFunc) error
Serve starts serving in background but waits server listener started before returning
type DiagoOption ¶
type DiagoOption func(dg *Diago)
func WithAuth ¶
func WithAuth(auth sipgo.DigestAuth) DiagoOption
func WithClient ¶ added in v0.3.0
func WithClient(client *sipgo.Client) DiagoOption
WithClient allows providing custom client handle. Consider still it needs to use same UA as diago
func WithMediaConfig ¶
func WithMediaConfig(conf MediaConfig) DiagoOption
func WithServer ¶
func WithServer(srv *sipgo.Server) DiagoOption
WithServer allows providing custom server handle. Consider still it needs to use same UA as diago
func WithTransport ¶
func WithTransport(t Transport) DiagoOption
type DialogCache ¶
type DialogCache[T DialogSession] interface { DialogStore(ctx context.Context, id string, v T) error DialogLoad(ctx context.Context, id string) (T, error) DialogDelete(ctx context.Context, id string) error DialogRange(ctx context.Context, f func(id string, d T) bool) error }
var ( // TODO, replace with typed versions DialogsClientCache DialogCache[*DialogClientSession] = &dialogCacheMap[*DialogClientSession]{sync.Map{}} DialogsServerCache DialogCache[*DialogServerSession] = &dialogCacheMap[*DialogServerSession]{sync.Map{}} )
type DialogClientSession ¶
type DialogClientSession struct { *sipgo.DialogClientSession DialogMedia // contains filtered or unexported fields }
DialogClientSession represents outbound channel
func MatchDialogClient ¶
func MatchDialogClient(req *sip.Request) (*DialogClientSession, error)
func (*DialogClientSession) Close ¶
func (d *DialogClientSession) Close()
func (*DialogClientSession) DialogSIP ¶
func (d *DialogClientSession) DialogSIP() *sipgo.Dialog
func (*DialogClientSession) FromUser ¶
func (d *DialogClientSession) FromUser() string
func (*DialogClientSession) Hangup ¶
func (d *DialogClientSession) Hangup(ctx context.Context) error
func (*DialogClientSession) Id ¶
func (d *DialogClientSession) Id() string
func (*DialogClientSession) ReInvite ¶
func (d *DialogClientSession) ReInvite(ctx context.Context) error
ReInvite sends new invite based on current media session
func (*DialogClientSession) RemoteContact ¶
func (d *DialogClientSession) RemoteContact() *sip.ContactHeader
func (*DialogClientSession) ToUser ¶
func (d *DialogClientSession) ToUser() string
type DialogData ¶
type DialogData struct { InviteRequest sip.Request State sip.DialogState }
type DialogMedia ¶
type DialogMedia struct { // Packet reader is default reader for RTP audio stream // Use always AudioReader to get current Audio reader // Use this only as read only // It MUST be always created on Media Session Init // Only safe to use after dialog Answered (Completed state) RTPPacketReader *media.RTPPacketReader // Packet writer is default writer for RTP audio stream // Use always AudioWriter to get current Audio reader // Use this only as read only RTPPacketWriter *media.RTPPacketWriter // contains filtered or unexported fields }
DialogMedia is common struct for server and client session and it shares same functionality which is mostly arround media
func (*DialogMedia) AudioReader ¶
func (d *DialogMedia) AudioReader(opts ...AudioReaderOption) (io.Reader, error)
AudioReader gets current audio reader. It MUST be called after Answer. Use AuidioListen for optimized reading. Reading buffer should be equal or bigger of media.RTPBufSize
func (*DialogMedia) AudioReaderDTMF ¶
func (m *DialogMedia) AudioReaderDTMF() *DTMFReader
AudioReaderDTMF is DTMF over RTP. It reads audio and provides hook for dtmf while listening for audio
func (*DialogMedia) AudioWriter ¶
func (d *DialogMedia) AudioWriter(opts ...AudioWriterOption) (io.Writer, error)
func (*DialogMedia) AudioWriterDTMF ¶
func (m *DialogMedia) AudioWriterDTMF() *DTMFWriter
func (*DialogMedia) Close ¶
func (d *DialogMedia) Close()
func (*DialogMedia) InitMediaSession ¶
func (d *DialogMedia) InitMediaSession(m *media.MediaSession, r *media.RTPPacketReader, w *media.RTPPacketWriter)
func (*DialogMedia) Listen ¶
func (d *DialogMedia) Listen() error
func (*DialogMedia) ListenContext ¶
func (d *DialogMedia) ListenContext(ctx context.Context) error
func (*DialogMedia) ListenUntil ¶
func (d *DialogMedia) ListenUntil(dur time.Duration) error
func (*DialogMedia) Media ¶
func (d *DialogMedia) Media() *DialogMedia
func (*DialogMedia) OnClose ¶
func (d *DialogMedia) OnClose(f func())
func (*DialogMedia) PlaybackControlCreate ¶
func (d *DialogMedia) PlaybackControlCreate() (AudioPlaybackControl, error)
PlaybackControlCreate creates playback for audio with controls like mute unmute
func (*DialogMedia) PlaybackCreate ¶
func (d *DialogMedia) PlaybackCreate() (AudioPlayback, error)
PlaybackCreate creates playback for audio
func (*DialogMedia) SetAudioReader ¶
func (d *DialogMedia) SetAudioReader(r io.Reader)
SetAudioReader adds/changes audio reader. Use this when you want to have interceptors of your audio
func (*DialogMedia) SetAudioWriter ¶
func (d *DialogMedia) SetAudioWriter(r io.Writer)
SetAudioWriter adds/changes audio reader. Use this when you want to have interceptors of your audio
type DialogServerSession ¶
type DialogServerSession struct { *sipgo.DialogServerSession // MediaSession *media.MediaSession DialogMedia // contains filtered or unexported fields }
DialogServerSession represents inbound channel
func MatchDialogServer ¶
func MatchDialogServer(req *sip.Request) (*DialogServerSession, error)
func (*DialogServerSession) Answer ¶
func (d *DialogServerSession) Answer() error
Answer creates media session and answers NOTE: Not final API
func (*DialogServerSession) AnswerSession ¶
func (d *DialogServerSession) AnswerSession(rtpSess *media.RTPSession) error
AnswerSession. It allows answering with custom RTP Session. NOTE: Not final API
func (*DialogServerSession) Close ¶
func (d *DialogServerSession) Close()
func (*DialogServerSession) DialogSIP ¶
func (d *DialogServerSession) DialogSIP() *sipgo.Dialog
func (*DialogServerSession) FromUser ¶
func (d *DialogServerSession) FromUser() string
func (*DialogServerSession) Hangup ¶
func (d *DialogServerSession) Hangup(ctx context.Context) error
func (*DialogServerSession) Id ¶
func (d *DialogServerSession) Id() string
func (*DialogServerSession) Progress ¶
func (d *DialogServerSession) Progress() error
func (*DialogServerSession) ReInvite ¶
func (d *DialogServerSession) ReInvite(ctx context.Context) error
func (*DialogServerSession) RemoteContact ¶
func (d *DialogServerSession) RemoteContact() *sip.ContactHeader
func (*DialogServerSession) Respond ¶
func (d *DialogServerSession) Respond(statusCode sip.StatusCode, reason string, body []byte, headers ...sip.Header) error
func (*DialogServerSession) RespondSDP ¶
func (d *DialogServerSession) RespondSDP(body []byte) error
func (*DialogServerSession) Ringing ¶
func (d *DialogServerSession) Ringing() error
func (*DialogServerSession) ToUser ¶
func (d *DialogServerSession) ToUser() string
User that was dialed
func (*DialogServerSession) Transport ¶
func (d *DialogServerSession) Transport() string
type DialogSession ¶
type InviteOptions ¶
type MediaConfig ¶
type RegisterOptions ¶ added in v0.2.0
type RegisterOptions struct { // Digest auth Username string Password string // Expiry is for Expire header Expiry time.Duration // Retry interval is interval before next Register is sent RetryInterval time.Duration AllowHeaders []string // Useragent default will be used on what is provided as NewUA() UserAgent string UserAgentHostname string }
type RegisterResponseError ¶ added in v0.2.0
func (RegisterResponseError) Error ¶ added in v0.2.0
func (e RegisterResponseError) Error() string
func (*RegisterResponseError) StatusCode ¶ added in v0.2.0
func (e *RegisterResponseError) StatusCode() sip.StatusCode
type RegisterTransaction ¶ added in v0.2.0
func (*RegisterTransaction) QualifyLoop ¶ added in v0.2.0
func (t *RegisterTransaction) QualifyLoop(ctx context.Context) error
func (*RegisterTransaction) Register ¶ added in v0.2.0
func (p *RegisterTransaction) Register(ctx context.Context) error
func (*RegisterTransaction) Unregister ¶ added in v0.2.0
func (t *RegisterTransaction) Unregister(ctx context.Context) error
type ServeDialogFunc ¶
type ServeDialogFunc func(d *DialogServerSession)