mirror of
https://dev.narayana.im/narayana/telegabber.git
synced 2026-08-05 20:17:08 +00:00
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
// tdlib <-> ntgcalls type conversions for call setup
|
|
package tgsig
|
|
|
|
import (
|
|
"gotgcalls/ntgcalls"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
"github.com/zelenin/go-tdlib/client"
|
|
)
|
|
|
|
func callProtocol() *client.CallProtocol {
|
|
p := ntgcalls.GetProtocol()
|
|
return &client.CallProtocol{
|
|
UdpP2p: p.UdpP2P,
|
|
UdpReflector: p.UdpReflector,
|
|
MinLayer: p.MinLayer,
|
|
MaxLayer: p.MaxLayer,
|
|
LibraryVersions: p.Versions,
|
|
}
|
|
}
|
|
|
|
func convertCallServers(servers []*client.CallServer) []ntgcalls.RTCServer {
|
|
out := make([]ntgcalls.RTCServer, 0, len(servers))
|
|
for _, s := range servers {
|
|
rtc := ntgcalls.RTCServer{
|
|
ID: int64(s.Id),
|
|
Ipv4: s.IpAddress,
|
|
Ipv6: s.Ipv6Address,
|
|
Port: s.Port,
|
|
}
|
|
switch t := s.Type.(type) {
|
|
case *client.CallServerTypeTelegramReflector:
|
|
rtc.PeerTag = t.PeerTag
|
|
rtc.Tcp = t.IsTcp
|
|
rtc.Turn = true
|
|
case *client.CallServerTypeWebrtc:
|
|
rtc.Username = t.Username
|
|
rtc.Password = t.Password
|
|
rtc.Turn = t.SupportsTurn
|
|
rtc.Stun = t.SupportsStun
|
|
default:
|
|
log.WithField("type", s.Type.CallServerTypeType()).Warn("Unknown call server type")
|
|
continue
|
|
}
|
|
out = append(out, rtc)
|
|
}
|
|
return out
|
|
}
|