Speed up track publication (#2952)

* speed up track publication

Add metrics for track publication and subscription

Return EnabledCodecs in JoinResponse so client can
choose codec without server side codec fallback

Cache remote webrtc track without AddTrackRequest to
let client send publisher offer before AddTrackRequest response

* go mod

* clean code
This commit is contained in:
cnderrauber
2024-08-23 18:38:32 +08:00
committed by GitHub
parent 37c6f95fe4
commit 947e8f5909
11 changed files with 159 additions and 38 deletions
-12
View File
@@ -19,7 +19,6 @@ import (
"strings"
"github.com/pion/webrtc/v3"
"golang.org/x/exp/slices"
"github.com/livekit/livekit-server/pkg/sfu"
"github.com/livekit/protocol/livekit"
@@ -204,17 +203,6 @@ func IsCodecEnabled(codecs []*livekit.Codec, cap webrtc.RTPCodecCapability) bool
}
func selectAlternativeVideoCodec(enabledCodecs []*livekit.Codec) string {
// sort these by compatibility, since we are looking for backups
if slices.ContainsFunc(enabledCodecs, func(c *livekit.Codec) bool {
return strings.EqualFold(c.Mime, webrtc.MimeTypeVP8)
}) {
return webrtc.MimeTypeVP8
}
if slices.ContainsFunc(enabledCodecs, func(c *livekit.Codec) bool {
return strings.EqualFold(c.Mime, webrtc.MimeTypeH264)
}) {
return webrtc.MimeTypeH264
}
for _, c := range enabledCodecs {
if strings.HasPrefix(c.Mime, "video/") {
return c.Mime