Documentation
¶
Index ¶
- Variables
- func CheckLazySipUri(target string, destOverwrite string) string
- func FindFreeInterfaceHostPort(network string, targetAddr string) (ip net.IP, port int, err error)
- func UACRequestBuild(req *sip.Request, lastReq *sip.Request, lastResp *sip.Response)
- func UASRequestBuild(req *sip.Request, lastResp *sip.Response)
- type AnswerOptions
- type AnswerReadyCtxValue
- type DialOptions
- type DialResponseError
- type DialogClientSession
- type DialogReferState
- type DialogServerSession
- func (d *DialogServerSession) Bye(ctx context.Context) error
- func (d *DialogServerSession) Close() error
- func (d *DialogServerSession) Hangup(ctx context.Context) error
- func (d *DialogServerSession) Notify(req *sip.Request) error
- func (d *DialogServerSession) Refer(ctx context.Context, referTo sip.Uri) error
- type ListenAddr
- type Listener
- type Phone
- func (p *Phone) Answer(ansCtx context.Context, opts AnswerOptions) (*DialogServerSession, error)
- func (p *Phone) AnswerWithCode(ansCtx context.Context, code sip.StatusCode, reason string, opts AnswerOptions) (*DialogServerSession, error)
- func (p *Phone) Close()
- func (p *Phone) Dial(dialCtx context.Context, recipient sip.Uri, o DialOptions) (*DialogClientSession, error)
- func (p *Phone) Register(ctx context.Context, recipient sip.Uri, opts RegisterOptions) error
- type PhoneOption
- type RegisterOptions
- type RegisterResponseError
- type RegisterTransaction
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrRegisterFail = fmt.Errorf("register failed") ErrRegisterUnathorized = fmt.Errorf("register unathorized") )
View Source
var ( // You can use this key with AnswerReadyCtxValue to get signal when // Answer is ready to receive traffic AnswerReadyCtxKey = "AnswerReadyCtxKey" )
View Source
var (
// Value must be zerolog.Logger
ContextLoggerKey = "logger"
)
Functions ¶
func CheckLazySipUri ¶
We are lazy to write full sip uris
func FindFreeInterfaceHostPort ¶ added in v0.6.0
func UACRequestBuild ¶ added in v0.8.0
Types ¶
type AnswerOptions ¶
type AnswerOptions struct {
Ringtime time.Duration
SipHeaders []sip.Header
// For authorizing INVITE unless RegisterAddr is defined
Username string
Password string
Realm string //default sipgo
RegisterAddr string //If defined it will keep registration in background
// For SDP codec manipulating
Formats sdp.Formats
// OnCall is just INVITE request handler that you can use to notify about incoming call
// After this dialog should be created and you can watch your changes with dialog.State
// -1 == Cancel
// 0 == continue
// >0 different response
OnCall func(inviteRequest *sip.Request) int
// Default is 200 (answer a call)
AnswerCode sip.StatusCode
AnswerReason string
}
type AnswerReadyCtxValue ¶ added in v0.4.0
type AnswerReadyCtxValue chan struct{}
type DialOptions ¶
type DialOptions struct {
// Authentication via digest challenge
Username string
Password string
// Custom headers passed on INVITE
SipHeaders []sip.Header
// SDP Formats to customize. NOTE: Only ulaw and alaw are fully supported
Formats sdp.Formats
// OnResponse is just callback called after INVITE is sent and all responses before final one
// Useful for tracking call state
OnResponse func(inviteResp *sip.Response)
// OnRefer is called 2 times.
// 1st with state NONE and dialog=nil. This is to have caller prepared
// 2nd with state Established or Ended with dialog
OnRefer func(state DialogReferState)
// Experimental
//
// OnMedia handles INVITE updates and passes new MediaSession with new propertie
OnMedia func(sess *media.MediaSession)
}
type DialResponseError ¶ added in v0.3.0
func (DialResponseError) Error ¶ added in v0.3.0
func (e DialResponseError) Error() string
func (*DialResponseError) StatusCode ¶ added in v0.3.0
func (e *DialResponseError) StatusCode() sip.StatusCode
type DialogClientSession ¶ added in v0.5.0
type DialogClientSession struct {
*media.MediaSession
*sipgo.DialogClientSession
// contains filtered or unexported fields
}
func (*DialogClientSession) Bye ¶ added in v0.5.0
func (d *DialogClientSession) Bye(ctx context.Context) error
func (*DialogClientSession) Close ¶ added in v0.5.0
func (d *DialogClientSession) Close() error
type DialogReferState ¶ added in v0.8.0
type DialogReferState struct {
// Updates current transfer progress with state
State sip.DialogState
// Dialog present when state is answered (Confirmed dialog state)
Dialog *DialogClientSession
}
type DialogServerSession ¶ added in v0.5.0
type DialogServerSession struct {
*media.MediaSession
*sipgo.DialogServerSession
// contains filtered or unexported fields
}
func (*DialogServerSession) Bye ¶ added in v0.5.0
func (d *DialogServerSession) Bye(ctx context.Context) error
func (*DialogServerSession) Close ¶ added in v0.5.0
func (d *DialogServerSession) Close() error
func (*DialogServerSession) Hangup ¶ added in v0.5.0
func (d *DialogServerSession) Hangup(ctx context.Context) error
Hangup is alias for Bye
type Phone ¶
func (*Phone) Answer ¶
func (p *Phone) Answer(ansCtx context.Context, opts AnswerOptions) (*DialogServerSession, error)
Answer will answer call Closing ansCtx will close listeners or it will be closed on BYE TODO: reusing listener
func (*Phone) AnswerWithCode ¶ added in v0.3.0
func (p *Phone) AnswerWithCode(ansCtx context.Context, code sip.StatusCode, reason string, opts AnswerOptions) (*DialogServerSession, error)
AnswerWithCode will answer with custom code Dialog object is created but it is immediately closed Deprecated: Use Answer with options
func (*Phone) Dial ¶
func (p *Phone) Dial(dialCtx context.Context, recipient sip.Uri, o DialOptions) (*DialogClientSession, error)
Dial creates dialog with recipient
return DialResponseError in case non 200 responses
type PhoneOption ¶
type PhoneOption func(p *Phone)
func WithPhoneListenAddr ¶
func WithPhoneListenAddr(addr ListenAddr) PhoneOption
WithPhoneListenAddrs NOT TLS supported
func WithPhoneLogger ¶
func WithPhoneLogger(l zerolog.Logger) PhoneOption
type RegisterOptions ¶ added in v0.5.0
type RegisterOptions struct {
Username string
Password string
Expiry int
AllowHeaders []string
UnregisterAll bool
}
Register the phone by sip uri. Pass username and password via opts NOTE: this will block and keep periodic registration. Use context to cancel
type RegisterResponseError ¶ added in v0.5.0
func (RegisterResponseError) Error ¶ added in v0.5.0
func (e RegisterResponseError) Error() string
func (*RegisterResponseError) StatusCode ¶ added in v0.5.0
func (e *RegisterResponseError) StatusCode() sip.StatusCode
type RegisterTransaction ¶ added in v0.5.0
func NewRegisterTransaction ¶ added in v0.6.0
func NewRegisterTransaction(log zerolog.Logger, client *sipgo.Client, recipient sip.Uri, contact sip.ContactHeader, opts RegisterOptions) *RegisterTransaction
func (*RegisterTransaction) QualifyLoop ¶ added in v0.6.0
func (t *RegisterTransaction) QualifyLoop(ctx context.Context) error
func (*RegisterTransaction) Register ¶ added in v0.6.0
func (p *RegisterTransaction) Register(ctx context.Context) error
func (*RegisterTransaction) Terminate ¶ added in v0.5.0
func (t *RegisterTransaction) Terminate() error
func (*RegisterTransaction) Unregister ¶ added in v0.6.0
func (t *RegisterTransaction) Unregister(ctx context.Context) error
Source Files
¶
Click to show internal directories.
Click to hide internal directories.