forked from pion/webrtc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ice_go.go
63 lines (57 loc) · 1.78 KB
/
ice_go.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
// +build !js
package webrtc
import "github.com/pion/sdp/v2"
// NewICEGatherer creates a new NewICEGatherer.
// This constructor is part of the ORTC API. It is not
// meant to be used together with the basic WebRTC API.
func (api *API) NewICEGatherer(opts ICEGatherOptions) (*ICEGatherer, error) {
return NewICEGatherer(
api.settingEngine.ephemeralUDP.PortMin,
api.settingEngine.ephemeralUDP.PortMax,
api.settingEngine.timeout.ICEConnection,
api.settingEngine.timeout.ICEKeepalive,
api.settingEngine.LoggerFactory,
api.settingEngine.candidates.ICENetworkTypes,
opts,
)
}
// NewICETransport creates a new NewICETransport.
// This constructor is part of the ORTC API. It is not
// meant to be used together with the basic WebRTC API.
func (api *API) NewICETransport(gatherer *ICEGatherer) *ICETransport {
return NewICETransport(gatherer, api.settingEngine.LoggerFactory)
}
func newICECandidateFromSDP(c sdp.ICECandidate) (ICECandidate, error) {
typ, err := NewICECandidateType(c.Typ)
if err != nil {
return ICECandidate{}, err
}
protocol, err := NewICEProtocol(c.Protocol)
if err != nil {
return ICECandidate{}, err
}
return ICECandidate{
Foundation: c.Foundation,
Priority: c.Priority,
IP: c.IP,
Protocol: protocol,
Port: c.Port,
Component: c.Component,
Typ: typ,
RelatedAddress: c.RelatedAddress,
RelatedPort: c.RelatedPort,
}, nil
}
func iceCandidateToSDP(c ICECandidate) sdp.ICECandidate {
return sdp.ICECandidate{
Foundation: c.Foundation,
Priority: c.Priority,
IP: c.IP,
Protocol: c.Protocol.String(),
Port: c.Port,
Component: c.Component,
Typ: c.Typ.String(),
RelatedAddress: c.RelatedAddress,
RelatedPort: c.RelatedPort,
}
}