mirror of
https://github.com/jech/galene.git
synced 2024-11-10 02:35:58 +01:00
Restart ICE instead of restarting down connections.
This commit is contained in:
parent
e724194ef6
commit
9506615272
2 changed files with 28 additions and 19 deletions
|
@ -643,7 +643,7 @@ function serverConnect() {
|
||||||
let m = JSON.parse(e.data);
|
let m = JSON.parse(e.data);
|
||||||
switch(m.type) {
|
switch(m.type) {
|
||||||
case 'offer':
|
case 'offer':
|
||||||
gotOffer(m.id, m.labels, m.offer);
|
gotOffer(m.id, m.labels, m.offer, !!m.renegotiate);
|
||||||
break;
|
break;
|
||||||
case 'answer':
|
case 'answer':
|
||||||
gotAnswer(m.id, m.answer);
|
gotAnswer(m.id, m.answer);
|
||||||
|
@ -714,11 +714,12 @@ function sendRequest(value) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function gotOffer(id, labels, offer) {
|
async function gotOffer(id, labels, offer, renegotiate) {
|
||||||
let c = down[id];
|
let c = down[id];
|
||||||
if(c) {
|
if(c && !renegotiate) {
|
||||||
// a new offer with a known id does not indicate renegotiation,
|
// SDP is rather inflexible as to what can be renegotiated.
|
||||||
// but a new connection that replaces the old one.
|
// Unless the server indicates that this is a renegotiation with
|
||||||
|
// all parameters unchanged, tear down the existing connection.
|
||||||
delete(down[id])
|
delete(down[id])
|
||||||
c.close(false);
|
c.close(false);
|
||||||
c = null;
|
c = null;
|
||||||
|
|
36
webclient.go
36
webclient.go
|
@ -179,6 +179,7 @@ type clientMessage struct {
|
||||||
Offer *webrtc.SessionDescription `json:"offer,omitempty"`
|
Offer *webrtc.SessionDescription `json:"offer,omitempty"`
|
||||||
Answer *webrtc.SessionDescription `json:"answer,omitempty"`
|
Answer *webrtc.SessionDescription `json:"answer,omitempty"`
|
||||||
Candidate *webrtc.ICECandidateInit `json:"candidate,omitempty"`
|
Candidate *webrtc.ICECandidateInit `json:"candidate,omitempty"`
|
||||||
|
Renegotiate bool `json:"renegotiate,omitempty"`
|
||||||
Labels map[string]string `json:"labels,omitempty"`
|
Labels map[string]string `json:"labels,omitempty"`
|
||||||
Del bool `json:"del,omitempty"`
|
Del bool `json:"del,omitempty"`
|
||||||
Request rateMap `json:"request,omitempty"`
|
Request rateMap `json:"request,omitempty"`
|
||||||
|
@ -393,8 +394,9 @@ func addDownTrack(c *webClient, conn *rtpDownConnection, remoteTrack upTrack, re
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func negotiate(c *webClient, down *rtpDownConnection) error {
|
func negotiate(c *webClient, down *rtpDownConnection, renegotiate, restartIce bool) error {
|
||||||
offer, err := down.pc.CreateOffer(nil)
|
options := webrtc.OfferOptions{ICERestart: restartIce}
|
||||||
|
offer, err := down.pc.CreateOffer(&options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -422,10 +424,11 @@ func negotiate(c *webClient, down *rtpDownConnection) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.write(clientMessage{
|
return c.write(clientMessage{
|
||||||
Type: "offer",
|
Type: "offer",
|
||||||
Id: down.id,
|
Id: down.id,
|
||||||
Offer: &offer,
|
Offer: &offer,
|
||||||
Labels: labels,
|
Renegotiate: renegotiate,
|
||||||
|
Labels: labels,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -733,7 +736,7 @@ func clientLoop(c *webClient, conn *websocket.Conn) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if down != nil {
|
if down != nil {
|
||||||
err = negotiate(c, down)
|
err = negotiate(c, down, false, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Negotiate: %v", err)
|
log.Printf("Negotiate: %v", err)
|
||||||
delDownConn(c, down.id)
|
delDownConn(c, down.id)
|
||||||
|
@ -769,14 +772,19 @@ func clientLoop(c *webClient, conn *websocket.Conn) error {
|
||||||
"unknown connection")
|
"unknown connection")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
tracks := make([]upTrack, len(down.tracks))
|
err := negotiate(c, down, true, true)
|
||||||
for i, t := range down.tracks {
|
if err != nil {
|
||||||
tracks[i] = t.remote
|
tracks := make(
|
||||||
|
[]upTrack, len(down.tracks),
|
||||||
|
)
|
||||||
|
for i, t := range down.tracks {
|
||||||
|
tracks[i] = t.remote
|
||||||
|
}
|
||||||
|
go c.pushConn(
|
||||||
|
down.remote.Id(), down.remote,
|
||||||
|
tracks, down.remote.Label(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
go c.pushConn(
|
|
||||||
down.remote.Id(), down.remote,
|
|
||||||
tracks, down.remote.Label(),
|
|
||||||
)
|
|
||||||
case permissionsChangedAction:
|
case permissionsChangedAction:
|
||||||
c.write(clientMessage{
|
c.write(clientMessage{
|
||||||
Type: "permissions",
|
Type: "permissions",
|
||||||
|
|
Loading…
Reference in a new issue