1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-26 02:25:58 +01:00

Restructure offers.

This commit is contained in:
Juliusz Chroboczek 2020-08-12 13:56:35 +02:00
parent bc7bd36ba2
commit 52c4f1a399
2 changed files with 16 additions and 10 deletions

View file

@ -646,7 +646,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, !!m.renegotiate); gotOffer(m.id, m.labels, m.offer, m.kind === 'renegotiate');
break; break;
case 'answer': case 'answer':
gotAnswer(m.id, m.answer); gotAnswer(m.id, m.answer);
@ -1276,10 +1276,10 @@ async function negotiate(id, restartIce) {
send({ send({
type: 'offer', type: 'offer',
kind: 'renegotiate',
id: id, id: id,
labels: c.labelsByMid, labels: c.labelsByMid,
offer: offer, offer: offer,
renegotiate: true,
}); });
} }

View file

@ -173,17 +173,16 @@ func (v rateMap) MarshalJSON() ([]byte, error) {
type clientMessage struct { type clientMessage struct {
Type string `json:"type"` Type string `json:"type"`
Kind string `json:"kind,omitempty"`
Id string `json:"id,omitempty"` Id string `json:"id,omitempty"`
Username string `json:"username,omitempty"` Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"` Password string `json:"password,omitempty"`
Permissions clientPermission `json:"permissions,omitempty"` Permissions clientPermission `json:"permissions,omitempty"`
Group string `json:"group,omitempty"` Group string `json:"group,omitempty"`
Value string `json:"value,omitempty"` Value string `json:"value,omitempty"`
Kind string `json:"kind,omitempty"`
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"`
Request rateMap `json:"request,omitempty"` Request rateMap `json:"request,omitempty"`
} }
@ -431,12 +430,17 @@ func negotiate(c *webClient, down *rtpDownConnection, renegotiate, restartIce bo
} }
} }
kind := ""
if renegotiate {
kind = "renegotiate"
}
return c.write(clientMessage{ return c.write(clientMessage{
Type: "offer", Type: "offer",
Id: down.id, Kind: kind,
Offer: &offer, Id: down.id,
Renegotiate: renegotiate, Offer: &offer,
Labels: labels, Labels: labels,
}) })
} }
@ -964,7 +968,9 @@ func handleClientMessage(c *webClient, m clientMessage) error {
if m.Offer == nil { if m.Offer == nil {
return protocolError("null offer") return protocolError("null offer")
} }
err := gotOffer(c, m.Id, *m.Offer, m.Renegotiate, m.Labels) err := gotOffer(
c, m.Id, *m.Offer, m.Kind == "renegotiate", m.Labels,
)
if err != nil { if err != nil {
log.Printf("gotOffer: %v", err) log.Printf("gotOffer: %v", err)
return failConnection(c, m.Id, "negotiation failed") return failConnection(c, m.Id, "negotiation failed")