Set video track for WebRTC always first

This commit is contained in:
Alexey Khit
2022-11-11 16:33:08 +03:00
parent f77db44529
commit d478436758
+7
View File
@@ -4,6 +4,7 @@ import (
"fmt"
"github.com/AlexxIT/go2rtc/pkg/streamer"
"github.com/pion/webrtc/v3"
"sort"
)
const (
@@ -100,6 +101,12 @@ func (c *Conn) SetOffer(offer string) (err error) {
}
rawSDP := []byte(c.Conn.RemoteDescription().SDP)
c.medias, err = streamer.UnmarshalSDP(rawSDP)
// sort medias, so video will always be before audio
sort.Slice(c.medias, func(i, j int) bool {
return c.medias[i].Kind == streamer.KindVideo
})
return
}