use full candidateInit, update encoding
This commit is contained in:
@@ -74,15 +74,13 @@ func NewParticipant(conf *WebRTCConfig, sc SignalConnection, name string) (*Part
|
||||
if c == nil {
|
||||
return
|
||||
}
|
||||
|
||||
ci := c.ToJSON()
|
||||
|
||||
// write candidate
|
||||
err := sc.WriteResponse(&livekit.SignalResponse{
|
||||
Message: &livekit.SignalResponse_Trickle{
|
||||
Trickle: &livekit.Trickle{
|
||||
Candidate: ci.Candidate,
|
||||
// TODO: there are other candidateInit fields that we might want
|
||||
},
|
||||
Trickle: ToProtoTrickle(ci),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -76,6 +76,10 @@ func (r *Room) Join(participant *Participant) error {
|
||||
|
||||
// subscribe participant to existing tracks
|
||||
for _, p := range r.participants {
|
||||
if p.id == participant.id {
|
||||
// don't send to itself
|
||||
continue
|
||||
}
|
||||
if err := p.AddSubscriber(participant); err != nil {
|
||||
// TODO: log error? or disconnect?
|
||||
logger.GetLogger().Errorw("could not subscribe to participant",
|
||||
|
||||
+8
-6
@@ -1,6 +1,7 @@
|
||||
package rtc
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
|
||||
"github.com/pion/webrtc/v3"
|
||||
@@ -57,14 +58,15 @@ func FromProtoSessionDescription(sd *livekit.SessionDescription) webrtc.SessionD
|
||||
}
|
||||
}
|
||||
|
||||
func ToProtoTrickle(candidateInit *webrtc.ICECandidateInit) *livekit.Trickle {
|
||||
func ToProtoTrickle(candidateInit webrtc.ICECandidateInit) *livekit.Trickle {
|
||||
data, _ := json.Marshal(candidateInit)
|
||||
return &livekit.Trickle{
|
||||
Candidate: candidateInit.Candidate,
|
||||
CandidateInit: string(data),
|
||||
}
|
||||
}
|
||||
|
||||
func FromProtoTrickle(trickle *livekit.Trickle) *webrtc.ICECandidateInit {
|
||||
return &webrtc.ICECandidateInit{
|
||||
Candidate: trickle.Candidate,
|
||||
}
|
||||
func FromProtoTrickle(trickle *livekit.Trickle) webrtc.ICECandidateInit {
|
||||
ci := webrtc.ICECandidateInit{}
|
||||
json.Unmarshal([]byte(trickle.CandidateInit), &ci)
|
||||
return ci
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user