CLI framing, creates rooms
This commit is contained in:
+4
-4
@@ -11,8 +11,8 @@ import (
|
||||
)
|
||||
|
||||
type WebRTCConfig struct {
|
||||
configuration webrtc.Configuration
|
||||
setting webrtc.SettingEngine
|
||||
Configuration webrtc.Configuration
|
||||
SettingEngine webrtc.SettingEngine
|
||||
feedbackTypes []webrtc.RTCPFeedback
|
||||
|
||||
receiver ReceiverConfig
|
||||
@@ -68,8 +68,8 @@ func NewWebRTCConfig(conf *config.RTCConfig, externalIP string) (*WebRTCConfig,
|
||||
s.AddSDPExtensions(webrtc.SDPSectionVideo, exts)
|
||||
|
||||
return &WebRTCConfig{
|
||||
configuration: c,
|
||||
setting: s,
|
||||
Configuration: c,
|
||||
SettingEngine: s,
|
||||
feedbackTypes: ft,
|
||||
receiver: ReceiverConfig{
|
||||
maxBandwidth: conf.MaxBandwidth,
|
||||
|
||||
+2
-2
@@ -35,8 +35,8 @@ type WebRTCPeer struct {
|
||||
}
|
||||
|
||||
func NewWebRTCPeer(id string, me *MediaEngine, conf WebRTCConfig) (*WebRTCPeer, error) {
|
||||
api := webrtc.NewAPI(webrtc.WithMediaEngine(me.MediaEngine), webrtc.WithSettingEngine(conf.setting))
|
||||
pc, err := api.NewPeerConnection(conf.configuration)
|
||||
api := webrtc.NewAPI(webrtc.WithMediaEngine(me.MediaEngine), webrtc.WithSettingEngine(conf.SettingEngine))
|
||||
pc, err := api.NewPeerConnection(conf.Configuration)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// TODO: could probably increase this depending on configuration/memory
|
||||
// TODO: could probably increase this depending on Configuration/memory
|
||||
maxChanSize = 1024
|
||||
)
|
||||
|
||||
|
||||
+4
-15
@@ -127,16 +127,11 @@ func (s *RTCService) handleJoin(sc SignalConnection, room *rtc.Room, sdp string)
|
||||
|
||||
// TODO: it might be better to return error instead of nil
|
||||
peer.OnICECandidate = func(c *webrtc.ICECandidateInit) {
|
||||
bytes, err := json.Marshal(c)
|
||||
if err != nil {
|
||||
logger.GetLogger().Errorf("could not marshal ice candidate: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
err = sc.WriteResponse(&livekit.SignalResponse{
|
||||
Message: &livekit.SignalResponse_Trickle{
|
||||
Trickle: &livekit.Trickle{
|
||||
CandidateInit: string(bytes),
|
||||
Candidate: c.Candidate,
|
||||
// TODO: there are other candidateInit fields that we might want
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -200,14 +195,8 @@ func (s *RTCService) handleNegotiate(sc SignalConnection, peer *rtc.WebRTCPeer,
|
||||
}
|
||||
|
||||
func (s *RTCService) handleTrickle(peer *rtc.WebRTCPeer, trickle *livekit.Trickle) error {
|
||||
var candidate webrtc.ICECandidateInit
|
||||
err := json.Unmarshal([]byte(trickle.CandidateInit), &candidate)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = peer.AddICECandidate(candidate)
|
||||
if err != nil {
|
||||
candidateInit := FromProtoTrickle(trickle)
|
||||
if err := peer.AddICECandidate(*candidateInit); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -30,3 +30,15 @@ func FromProtoSessionDescription(sd *livekit.SessionDescription) webrtc.SessionD
|
||||
SDP: sd.Sdp,
|
||||
}
|
||||
}
|
||||
|
||||
func ToProtoTrickle(candidateInit *webrtc.ICECandidateInit) *livekit.Trickle {
|
||||
return &livekit.Trickle{
|
||||
Candidate: candidateInit.Candidate,
|
||||
}
|
||||
}
|
||||
|
||||
func FromProtoTrickle(trickle *livekit.Trickle) *webrtc.ICECandidateInit {
|
||||
return &webrtc.ICECandidateInit{
|
||||
Candidate: trickle.Candidate,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user