mirror of
https://dev.narayana.im/narayana/telegabber.git
synced 2026-08-05 12:17:06 +00:00
81 lines
2.3 KiB
Go
81 lines
2.3 KiB
Go
package jingle
|
|
|
|
import (
|
|
"encoding/xml"
|
|
|
|
"gosrc.io/xmpp/stanza"
|
|
)
|
|
|
|
// Jingle Message Initiation, XEP-0353
|
|
const NSJMI = "urn:xmpp:jingle-message:0"
|
|
|
|
// <propose/> - advertises media the caller wants
|
|
type JMIPropose struct {
|
|
XMLName xml.Name `xml:"urn:xmpp:jingle-message:0 propose"`
|
|
ID string `xml:"id,attr"`
|
|
Descriptions []JMIDescription `xml:"urn:xmpp:jingle:apps:rtp:1 description"`
|
|
}
|
|
|
|
// slim XEP-0167 <description> used inside JMI; only media is meaningful here
|
|
type JMIDescription struct {
|
|
XMLName xml.Name `xml:"urn:xmpp:jingle:apps:rtp:1 description"`
|
|
Media string `xml:"media,attr"`
|
|
}
|
|
|
|
// <proceed/> - callee picked up, caller may send session-initiate
|
|
type JMIProceed struct {
|
|
XMLName xml.Name `xml:"urn:xmpp:jingle-message:0 proceed"`
|
|
ID string `xml:"id,attr"`
|
|
}
|
|
|
|
// <ringing/> - callee alerting
|
|
type JMIRinging struct {
|
|
XMLName xml.Name `xml:"urn:xmpp:jingle-message:0 ringing"`
|
|
ID string `xml:"id,attr"`
|
|
}
|
|
|
|
// <reject/> - callee declined before media setup
|
|
type JMIReject struct {
|
|
XMLName xml.Name `xml:"urn:xmpp:jingle-message:0 reject"`
|
|
ID string `xml:"id,attr"`
|
|
Reason *Reason `xml:"urn:xmpp:jingle:1 reason,omitempty"`
|
|
}
|
|
|
|
// <retract/> - caller cancelled before proceed
|
|
type JMIRetract struct {
|
|
XMLName xml.Name `xml:"urn:xmpp:jingle-message:0 retract"`
|
|
ID string `xml:"id,attr"`
|
|
}
|
|
|
|
// <finish/> - terminal marker, parsed only so the parser doesn't fall back to Node
|
|
type JMIFinish struct {
|
|
XMLName xml.Name `xml:"urn:xmpp:jingle-message:0 finish"`
|
|
ID string `xml:"id,attr"`
|
|
}
|
|
|
|
// gosrc.io/xmpp MsgExtension boilerplate
|
|
func (JMIPropose) Namespace() string { return NSJMI }
|
|
func (JMIProceed) Namespace() string { return NSJMI }
|
|
func (JMIRinging) Namespace() string { return NSJMI }
|
|
func (JMIReject) Namespace() string { return NSJMI }
|
|
func (JMIRetract) Namespace() string { return NSJMI }
|
|
func (JMIFinish) Namespace() string { return NSJMI }
|
|
|
|
func init() {
|
|
for _, m := range []struct {
|
|
local string
|
|
empty stanza.MsgExtension
|
|
}{
|
|
{"propose", JMIPropose{}},
|
|
{"proceed", JMIProceed{}},
|
|
{"ringing", JMIRinging{}},
|
|
{"reject", JMIReject{}},
|
|
{"retract", JMIRetract{}},
|
|
{"finish", JMIFinish{}},
|
|
} {
|
|
stanza.TypeRegistry.MapExtension(stanza.PKTMessage, xml.Name{
|
|
Space: NSJMI,
|
|
Local: m.local,
|
|
}, m.empty)
|
|
}
|
|
}
|