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

Don't renegotiate if nothing changed during a request.

This commit is contained in:
Juliusz Chroboczek 2021-05-14 18:19:44 +02:00
parent 16bf4d6c95
commit 7590588a54

View file

@ -426,7 +426,7 @@ func delDownTrackUnlocked(conn *rtpDownConnection, track *rtpDownTrack) error {
return os.ErrNotExist return os.ErrNotExist
} }
func replaceTracks(conn *rtpDownConnection, remote []conn.UpTrack, remoteConn conn.Up) error { func replaceTracks(conn *rtpDownConnection, remote []conn.UpTrack, remoteConn conn.Up) (bool, error) {
conn.mu.Lock() conn.mu.Lock()
defer conn.mu.Unlock() defer conn.mu.Unlock()
@ -437,12 +437,12 @@ outer:
for _, rtrack := range remote { for _, rtrack := range remote {
rt, ok := rtrack.(*rtpUpTrack) rt, ok := rtrack.(*rtpUpTrack)
if !ok { if !ok {
return errUnexpectedTrackType return false, errUnexpectedTrackType
} }
for _, track := range conn.tracks { for _, track := range conn.tracks {
rt2, ok := track.remote.(*rtpUpTrack) rt2, ok := track.remote.(*rtpUpTrack)
if !ok { if !ok {
return errUnexpectedTrackType return false, errUnexpectedTrackType
} }
if rt == rt2 { if rt == rt2 {
continue outer continue outer
@ -455,12 +455,12 @@ outer2:
for _, track := range conn.tracks { for _, track := range conn.tracks {
rt, ok := track.remote.(*rtpUpTrack) rt, ok := track.remote.(*rtpUpTrack)
if !ok { if !ok {
return errUnexpectedTrackType return false, errUnexpectedTrackType
} }
for _, rtrack := range remote { for _, rtrack := range remote {
rt2, ok := rtrack.(*rtpUpTrack) rt2, ok := rtrack.(*rtpUpTrack)
if !ok { if !ok {
return errUnexpectedTrackType return false, errUnexpectedTrackType
} }
if rt == rt2 { if rt == rt2 {
continue outer2 continue outer2
@ -469,21 +469,25 @@ outer2:
del = append(del, track) del = append(del, track)
} }
if len(del) == 0 && len(add) == 0 {
return false, nil
}
for _, t := range del { for _, t := range del {
err := delDownTrackUnlocked(conn, t) err := delDownTrackUnlocked(conn, t)
if err != nil { if err != nil {
return err return false, err
} }
} }
for _, rt := range add { for _, rt := range add {
err := addDownTrackUnlocked(conn, rt, remoteConn) err := addDownTrackUnlocked(conn, rt, remoteConn)
if err != nil { if err != nil {
return err return false, err
} }
} }
return nil return true, nil
} }
func negotiate(c *webClient, down *rtpDownConnection, restartIce bool, replace string) error { func negotiate(c *webClient, down *rtpDownConnection, restartIce bool, replace string) error {
@ -906,10 +910,13 @@ func handleAction(c *webClient, a interface{}) error {
if err != nil { if err != nil {
return err return err
} }
err = replaceTracks(down, tracks, a.conn) done, err := replaceTracks(down, tracks, a.conn)
if err != nil { if err != nil {
return err return err
} }
if !done {
return nil
}
if a.replace != "" { if a.replace != "" {
err := delDownConn(c, a.replace) err := delDownConn(c, a.replace)
if err != nil { if err != nil {