add support for client capabilities (#4461)
* update protocol version * only check for client capabiltiy to strip packet trailer
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
package rtc
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -118,6 +119,17 @@ func (c ClientInfo) SupportsTransceiverReuse() bool {
|
||||
return !c.isSafari()
|
||||
}
|
||||
|
||||
func (c ClientInfo) HasCapability(cap livekit.ClientInfo_Capability) bool {
|
||||
if c.ClientInfo == nil {
|
||||
return false
|
||||
}
|
||||
return slices.Contains(c.ClientInfo.Capabilities, cap)
|
||||
}
|
||||
|
||||
func (c ClientInfo) SupportsPacketTrailer() bool {
|
||||
return c.HasCapability(livekit.ClientInfo_CAP_PACKET_TRAILER)
|
||||
}
|
||||
|
||||
// compareVersion compares a semver against the current client SDK version
|
||||
// returning 1 if current version is greater than version
|
||||
// 0 if they are the same, and -1 if it's an earlier version
|
||||
|
||||
@@ -129,8 +129,10 @@ func NewSubscribedTrack(params SubscribedTrackParams) (*SubscribedTrack, error)
|
||||
if isEncrypted {
|
||||
trailer = params.Subscriber.GetTrailer()
|
||||
}
|
||||
stripPacketTrailer := params.MediaTrack.HasPacketTrailer() &&
|
||||
!params.Subscriber.ProtocolVersion().SupportsPacketTrailer()
|
||||
subClientInfo := ClientInfo{ClientInfo: params.Subscriber.GetClientInfo()}
|
||||
subSupportsPacketTrailer := subClientInfo.SupportsPacketTrailer()
|
||||
// Strip packet trailer if track has packet trailer but subscriber does not have cap
|
||||
stripPacketTrailer := params.MediaTrack.HasPacketTrailer() && !subSupportsPacketTrailer
|
||||
downTrack, err := sfu.NewDownTrack(sfu.DownTrackParams{
|
||||
Codecs: codecs,
|
||||
IsEncrypted: isEncrypted,
|
||||
|
||||
@@ -187,6 +187,18 @@ func ParseClientInfo(r *http.Request) *livekit.ClientInfo {
|
||||
ci.DeviceModel = values.Get("device_model")
|
||||
ci.Network = values.Get("network")
|
||||
|
||||
if capStr := values.Get("capabilities"); capStr != "" {
|
||||
for _, name := range strings.Split(capStr, ",") {
|
||||
name = strings.TrimSpace(name)
|
||||
if name == "" {
|
||||
continue
|
||||
}
|
||||
if v, ok := livekit.ClientInfo_Capability_value[name]; ok {
|
||||
ci.Capabilities = append(ci.Capabilities, livekit.ClientInfo_Capability(v))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AugmentClientInfo(ci, r)
|
||||
|
||||
return ci
|
||||
|
||||
Reference in New Issue
Block a user