Commit 7590588a authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Don't renegotiate if nothing changed during a request.

parent 16bf4d6c
...@@ -426,7 +426,7 @@ func delDownTrackUnlocked(conn *rtpDownConnection, track *rtpDownTrack) error { ...@@ -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: ...@@ -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: ...@@ -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: ...@@ -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 { ...@@ -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 {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment