forked from chanbakjsd/gotrix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
voip.go
70 lines (58 loc) · 2.12 KB
/
voip.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package event
var (
_ RoomEvent = &CallInviteEvent{}
_ RoomEvent = &CallCandidatesEvent{}
_ RoomEvent = &CallAnswerEvent{}
_ RoomEvent = &CallHangupEvent{}
)
// TODO Maybe implement glare at some point.
// https://spec.matrix.org/v1.1/client-server-api/#glare
// CallInviteEvent is a message event where someone is inviting to establish a call.
type CallInviteEvent struct {
RoomEventInfo `json:"-"`
CallID string `json:"call_id"`
Version int `json:"version"` // Currently always 0.
Lifetime int `json:"lifetime"` // Milliseconds the offer is valid for.
Offer struct {
Type string `json:"type"` // Must be "offer".
SDP string `json:"sdp"` // Session Description Protocol
} `json:"offer"`
}
// CallCandidatesEvent is a message event where additional ICE candidates are provided
// to foster communication.
type CallCandidatesEvent struct {
RoomEventInfo `json:"-"`
CallID string `json:"call_id"`
Version int `json:"version"` // Currently always 0.
Candidates []struct {
SDPMediaType string `json:"sdpMid"`
SDPMediaLineIndex int `json:"sdpMLineIndex"`
Candidate string `json:"candidate"`
} `json:"candidates"`
}
// CallAnswerEvent is a message event where a callee wishes to answer the call.
type CallAnswerEvent struct {
RoomEventInfo `json:"-"`
CallID string `json:"call_id"`
Version int `json:"int"`
Answer struct {
Type string `json:"type"` // Must be "answer".
SDP string `json:"sdp"` // Session Description Protocol
} `json:"answer"`
}
// CallHangupEvent is a message event where the call is ended. This can be sent
// to hang up a call or to reject a call.
type CallHangupEvent struct {
RoomEventInfo `json:"-"`
CallID string `json:"call_id"`
Version int `json:"version"` // Currently always 0.
Reason CallHangupReason `json:"reason"`
}
// CallHangupReason is the reason we hung up.
type CallHangupReason string
// Possible reasons to hang up.
const (
CallHangupNormal CallHangupReason = ""
CallHangupICEFailed CallHangupReason = "ice_failed" // ICE negotiation failed.
CallHangupInviteTimeout CallHangupReason = "invite_timeout"
)