Documentation
¶
Index ¶
- Constants
- Variables
- type Channel
- func (c *Channel) Close() error
- func (c *Channel) GetChannelId() ChannelId
- func (c *Channel) GetResource() Resource
- func (c *Channel) NewEvent(event, requestState string) Message
- func (c *Channel) NewRequest(method string) Message
- func (c *Channel) NewResponse(msg Message, statusCode int, requestState string) Message
- func (c *Channel) SendMrcpMessage(msg Message) error
- func (c *Channel) SetChannelId(id ChannelId)
- type ChannelHandler
- type ChannelHandlerFunc
- type ChannelId
- type Client
- type CodecDesc
- type CompletionCause
- type ControlDesc
- type Desc
- type DialogClient
- type DialogClientOptionFunc
- type DialogHandler
- type DialogHandlerFunc
- type DialogServer
- type Direction
- type Media
- type MediaDesc
- type MediaHandler
- type MediaHandlerFunc
- type Message
- func (m *Message) GetBody() []byte
- func (m *Message) GetCompletionCause() CompletionCause
- func (m *Message) GetHeader(key string) string
- func (m *Message) GetMessageType() MessageType
- func (m *Message) GetName() string
- func (m *Message) GetRequestId() uint32
- func (m *Message) GetRequestState() string
- func (m *Message) GetStatusCode() int
- func (m *Message) Marshal() []byte
- func (m *Message) SetBody(body []byte, contentType string)
- func (m *Message) SetCompletionCause(resource Resource, cc CompletionCause)
- func (m *Message) SetHeader(k, v string)
- func (m *Message) SetRequestId(requestId uint32)
- type MessageType
- type Resource
- type Server
- type ServerHandler
- type ServerHandlerFunc
Constants ¶
View Source
const ( ProtoTCP = "TCP/MRCPv2" ProtoTLS = "TCP/TLS/MRCPv2" SetupActive = "active" SetupPassive = "passive" ConnectionNew = "new" ConnectionExisting = "existing" )
View Source
const ( MethodRecognize = "RECOGNIZE" MethodSetParams = "SET-PARAMS" MethodGetParams = "GET-PARAMS" MethodDefineGrammar = "DEFINE-GRAMMAR" MethodInterpret = "INTERPRET" MethodGetResult = "GET-RESULT" MethodStartInputTimers = "START-INPUT-TIMERS" MethodStop = "STOP" MethodStartPhraseEnrollment = "START-PHRASE-ENROLLMENT" MethodEnrollmentRollback = "ENROLLMENT-ROLLBACK" MethodEndPhraseEnrollment = "END-PHRASE-ENROLLMENT" MethodModifyPhrase = "MODIFY-PHRASE" MethodDeletePhrase = "DELETE-PHRASE" MethodSpeak = "SPEAK" MethodPause = "PAUSE" MethodResume = "RESUME" MethodBargeInOccurred = "BARGE-IN-OCCURRED" MethodControl = "CONTROL" MethodDefineLexicon = "DEFINE-LEXICON" )
View Source
const ( HeaderContentType = "Content-Type" HeaderContentLength = "Content-Length" HeaderCompletionCause = "Completion-Cause" HeaderChannelIdentifier = "Channel-Identifier" )
View Source
const ( RequestStateComplete = "COMPLETE" RequestStateInProgress = "IN-PROGRESS" RequestStatePending = "PENDING" )
View Source
const (
CodecTelephoneEvent = "telephone-event"
)
Variables ¶
View Source
var (
ErrNoFreePorts = errors.New("no free rtp ports")
)
Functions ¶
This section is empty.
Types ¶
type Channel ¶
type Channel struct {
// contains filtered or unexported fields
}
func (*Channel) GetChannelId ¶
func (*Channel) GetResource ¶
func (*Channel) NewRequest ¶
func (*Channel) NewResponse ¶
func (*Channel) SendMrcpMessage ¶
TODO: check Channel inused
func (*Channel) SetChannelId ¶ added in v1.0.1
type ChannelHandler ¶
type ChannelHandlerFunc ¶
type ChannelHandlerFunc struct {
// OnMessageFunc mrcp response
OnMessageFunc func(c *Channel, msg Message)
}
func (ChannelHandlerFunc) OnMessage ¶
func (h ChannelHandlerFunc) OnMessage(c *Channel, msg Message)
type Client ¶
type Client struct {
// Host local host
// default: 127.0.0.1
Host string
// SIPPort SIP server port
// default: 5060
SIPPort int
// UserAgent SIP User-Agent
UserAgent string
// AudioCodecs audio codecs
// Default: defaultAudioCodecs
AudioCodecs []CodecDesc
// RtpPortMin RtpPortMax RTP port range
// Default: [20000, 40000)
RtpPortMin, RtpPortMax uint16
// Logger
// Default: slog.Default
Logger *slog.Logger
// contains filtered or unexported fields
}
func (*Client) Dial ¶
func (c *Client) Dial( raddr string, resource Resource, handler DialogHandler, opts ...DialogClientOptionFunc, ) (*DialogClient, error)
type CompletionCause ¶
type CompletionCause int
const ( SynthCompletionCauseNormal CompletionCause = iota SynthCompletionCauseBargeIn SynthCompletionCauseParseFailure SynthCompletionCauseUriFailure SynthCompletionCauseError SynthCompletionCauseLanguageUnsupported SynthCompletionCauseLexiconLoadFailure SynthCompletionCauseCancelled )
const ( RecogCompletionCauseSuccess CompletionCause = iota RecogCompletionCauseNoMatch RecogCompletionCauseNoInputTimeout RecogCompletionCauseHotWordMaxTime RecogCompletionCauseGrammarLoadFailure RecogCompletionCauseGrammarCompilationFailure RecogCompletionCauseRecognizerError RecogCompletionCauseSpeechTooEarly RecogCompletionCauseSuccessMaxTime RecogCompletionCauseUriFailure RecogCompletionCauseLanguageUnsupported RecogCompletionCauseCancelled RecogCompletionCauseSemanticsFailure RecogCompletionCausePartialMatch RecogCompletionCausePartialMatchMaxTime RecogCompletionCauseNoMatchMaxTime RecogCompletionCauseGrammarDefinitionFailure )
func (CompletionCause) Marshal ¶
func (c CompletionCause) Marshal(resource Resource) string
type ControlDesc ¶
type Desc ¶
type Desc struct {
// UserAgent The username in the SDP Origin field
UserAgent string
// Host The global connection-address in the SDP Connection field
Host string
AudioDesc MediaDesc
ControlDesc ControlDesc
}
Desc SDP
type DialogClient ¶
type DialogClient struct {
// contains filtered or unexported fields
}
func (*DialogClient) Close ¶
func (d *DialogClient) Close() error
func (*DialogClient) GetChannel ¶
func (d *DialogClient) GetChannel() *Channel
func (*DialogClient) GetLocalDesc ¶ added in v1.0.1
func (d *DialogClient) GetLocalDesc() *Desc
func (*DialogClient) GetRemoteDesc ¶ added in v1.0.1
func (d *DialogClient) GetRemoteDesc() *Desc
type DialogClientOptionFunc ¶ added in v1.0.1
type DialogClientOptionFunc func(d *DialogClient)
func WithAudioCodecs ¶ added in v1.0.1
func WithAudioCodecs(codecs []CodecDesc) DialogClientOptionFunc
type DialogHandler ¶
type DialogHandler interface {
OnMediaOpen(media *Media) MediaHandler
OnChannelOpen(channel *Channel) ChannelHandler
OnClose()
}
type DialogHandlerFunc ¶
type DialogHandlerFunc struct {
OnMediaOpenFunc func(media *Media) MediaHandler
OnChannelOpenFunc func(channel *Channel) ChannelHandler
OnCloseFunc func()
}
func (DialogHandlerFunc) OnChannelOpen ¶
func (h DialogHandlerFunc) OnChannelOpen(channel *Channel) ChannelHandler
func (DialogHandlerFunc) OnClose ¶ added in v1.0.1
func (h DialogHandlerFunc) OnClose()
func (DialogHandlerFunc) OnMediaOpen ¶
func (h DialogHandlerFunc) OnMediaOpen(media *Media) MediaHandler
type DialogServer ¶
type DialogServer struct {
// contains filtered or unexported fields
}
func (*DialogServer) Close ¶
func (d *DialogServer) Close() error
func (*DialogServer) GetChannel ¶ added in v1.0.1
func (d *DialogServer) GetChannel() *Channel
func (*DialogServer) GetLocalDesc ¶ added in v1.0.1
func (d *DialogServer) GetLocalDesc() *Desc
func (*DialogServer) GetRemoteDesc ¶ added in v1.0.1
func (d *DialogServer) GetRemoteDesc() *Desc
func (*DialogServer) GetResource ¶ added in v1.0.2
func (d *DialogServer) GetResource() Resource
type Media ¶
type Media struct {
// contains filtered or unexported fields
}
func (*Media) LocalAudioDesc ¶
func (*Media) RemoteAudioDesc ¶
type MediaHandler ¶
type MediaHandler interface {
// StartTx is called when starting to send RTP stream
StartTx(m *Media, codec CodecDesc) error
// ReadRTPPacket read a RTP packet from high-level
// stop sending by returning false
ReadRTPPacket(m *Media) ([]byte, bool)
// StartRx is called when starting to receive RTP stream
StartRx(m *Media, codec CodecDesc) error
// WriteRTPPacket write a RTP packet to high-level
// stop receiving by returning false
WriteRTPPacket(m *Media, rtp []byte) bool
}
type MediaHandlerFunc ¶
type MediaHandlerFunc struct {
StartTxFunc func(m *Media, codec CodecDesc) error
ReadRTPPacketFunc func(m *Media) ([]byte, bool)
StartRxFunc func(m *Media, codec CodecDesc) error
WriteRTPPacketFunc func(m *Media, rtp []byte) bool
}
func (MediaHandlerFunc) ReadRTPPacket ¶
func (h MediaHandlerFunc) ReadRTPPacket(m *Media) ([]byte, bool)
func (MediaHandlerFunc) StartRx ¶
func (h MediaHandlerFunc) StartRx(m *Media, codec CodecDesc) error
func (MediaHandlerFunc) StartTx ¶
func (h MediaHandlerFunc) StartTx(m *Media, codec CodecDesc) error
func (MediaHandlerFunc) WriteRTPPacket ¶
func (h MediaHandlerFunc) WriteRTPPacket(m *Media, rtp []byte) bool
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
func (*Message) GetCompletionCause ¶
func (m *Message) GetCompletionCause() CompletionCause
func (*Message) GetMessageType ¶
func (m *Message) GetMessageType() MessageType
func (*Message) GetRequestId ¶
func (*Message) GetRequestState ¶
func (*Message) GetStatusCode ¶
func (*Message) SetCompletionCause ¶
func (m *Message) SetCompletionCause(resource Resource, cc CompletionCause)
func (*Message) SetRequestId ¶
type MessageType ¶
type MessageType uint8
const ( MessageTypeRequest MessageType = 1 + iota MessageTypeResponse MessageTypeEvent )
func (MessageType) String ¶ added in v1.0.2
func (m MessageType) String() string
type Server ¶
type Server struct {
// Host local host
// default: 127.0.0.1
Host string
// SIPPort SIP server port
// default: 5060
SIPPort int
// MRCPPort MRCP server port
// default: 1544
MRCPPort int
// UserAgent SIP User-Agent
UserAgent string
// AudioCodecs audio codecs
// Default: defaultAudioCodecs
AudioCodecs []CodecDesc
// RtpPortMin RtpPortMax RTP port range
// Default: [20000, 40000)
RtpPortMin, RtpPortMax uint16
// Handler handler
Handler ServerHandler
// Logger
// Default: slog.Default
Logger *slog.Logger
// contains filtered or unexported fields
}
type ServerHandler ¶
type ServerHandler interface {
OnDialogCreate(d *DialogServer) (DialogHandler, error)
}
type ServerHandlerFunc ¶
type ServerHandlerFunc struct {
OnDialogCreateFunc func(d *DialogServer) (DialogHandler, error)
}
func (ServerHandlerFunc) OnDialogCreate ¶
func (h ServerHandlerFunc) OnDialogCreate(d *DialogServer) (DialogHandler, error)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.