Set video track for WebRTC always first
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/AlexxIT/go2rtc/pkg/streamer"
|
"github.com/AlexxIT/go2rtc/pkg/streamer"
|
||||||
"github.com/pion/webrtc/v3"
|
"github.com/pion/webrtc/v3"
|
||||||
|
"sort"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -100,6 +101,12 @@ func (c *Conn) SetOffer(offer string) (err error) {
|
|||||||
}
|
}
|
||||||
rawSDP := []byte(c.Conn.RemoteDescription().SDP)
|
rawSDP := []byte(c.Conn.RemoteDescription().SDP)
|
||||||
c.medias, err = streamer.UnmarshalSDP(rawSDP)
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user