add packet trailer stripping support (#4361)
* bump protocol version to 17 to enable packet trailer stripping functionality * check subscriber protocol version for trailer stripping
This commit is contained in:
@@ -518,6 +518,10 @@ func (t *MediaTrackReceiver) IsEncrypted() bool {
|
||||
return t.TrackInfo().Encryption != livekit.Encryption_NONE
|
||||
}
|
||||
|
||||
func (t *MediaTrackReceiver) HasPacketTrailer() bool {
|
||||
return len(t.TrackInfo().GetPacketTrailerFeatures()) > 0
|
||||
}
|
||||
|
||||
func (t *MediaTrackReceiver) AddOnClose(f func(isExpectedToResume bool)) {
|
||||
if f == nil {
|
||||
return
|
||||
|
||||
+15
-14
@@ -2832,20 +2832,21 @@ func (p *ParticipantImpl) addPendingTrackLocked(req *livekit.AddTrackRequest) *l
|
||||
}
|
||||
|
||||
ti := &livekit.TrackInfo{
|
||||
Type: req.Type,
|
||||
Name: req.Name,
|
||||
Width: req.Width,
|
||||
Height: req.Height,
|
||||
Muted: req.Muted,
|
||||
DisableDtx: req.DisableDtx,
|
||||
Source: req.Source,
|
||||
Layers: cloneLayers(req.Layers),
|
||||
DisableRed: req.DisableRed,
|
||||
Stereo: req.Stereo,
|
||||
Encryption: req.Encryption,
|
||||
Stream: req.Stream,
|
||||
BackupCodecPolicy: backupCodecPolicy,
|
||||
AudioFeatures: sutils.DedupeSlice(req.AudioFeatures),
|
||||
Type: req.Type,
|
||||
Name: req.Name,
|
||||
Width: req.Width,
|
||||
Height: req.Height,
|
||||
Muted: req.Muted,
|
||||
DisableDtx: req.DisableDtx,
|
||||
Source: req.Source,
|
||||
Layers: cloneLayers(req.Layers),
|
||||
DisableRed: req.DisableRed,
|
||||
Stereo: req.Stereo,
|
||||
Encryption: req.Encryption,
|
||||
Stream: req.Stream,
|
||||
BackupCodecPolicy: backupCodecPolicy,
|
||||
AudioFeatures: sutils.DedupeSlice(req.AudioFeatures),
|
||||
PacketTrailerFeatures: sutils.DedupeSlice(req.PacketTrailerFeatures),
|
||||
}
|
||||
if req.Stereo && !slices.Contains(ti.AudioFeatures, livekit.AudioTrackFeature_TF_STEREO) {
|
||||
ti.AudioFeatures = append(ti.AudioFeatures, livekit.AudioTrackFeature_TF_STEREO)
|
||||
|
||||
+14
-11
@@ -129,18 +129,21 @@ func NewSubscribedTrack(params SubscribedTrackParams) (*SubscribedTrack, error)
|
||||
if isEncrypted {
|
||||
trailer = params.Subscriber.GetTrailer()
|
||||
}
|
||||
stripPacketTrailer := params.MediaTrack.HasPacketTrailer() &&
|
||||
!params.Subscriber.ProtocolVersion().SupportsPacketTrailer()
|
||||
downTrack, err := sfu.NewDownTrack(sfu.DownTrackParams{
|
||||
Codecs: codecs,
|
||||
IsEncrypted: isEncrypted,
|
||||
Source: params.MediaTrack.Source(),
|
||||
Receiver: params.WrappedReceiver,
|
||||
BufferFactory: params.Subscriber.GetBufferFactory(),
|
||||
SubID: params.Subscriber.ID(),
|
||||
StreamID: streamID,
|
||||
MaxTrack: maxTrack,
|
||||
PlayoutDelayLimit: params.Subscriber.GetPlayoutDelayConfig(),
|
||||
Pacer: params.Subscriber.GetPacer(),
|
||||
Trailer: trailer,
|
||||
Codecs: codecs,
|
||||
IsEncrypted: isEncrypted,
|
||||
Source: params.MediaTrack.Source(),
|
||||
Receiver: params.WrappedReceiver,
|
||||
BufferFactory: params.Subscriber.GetBufferFactory(),
|
||||
SubID: params.Subscriber.ID(),
|
||||
StreamID: streamID,
|
||||
MaxTrack: maxTrack,
|
||||
PlayoutDelayLimit: params.Subscriber.GetPlayoutDelayConfig(),
|
||||
Pacer: params.Subscriber.GetPacer(),
|
||||
Trailer: trailer,
|
||||
StripPacketTrailer: stripPacketTrailer,
|
||||
Logger: LoggerWithTrack(
|
||||
params.Subscriber.GetLogger().WithComponent(sutils.ComponentSub),
|
||||
params.MediaTrack.ID(),
|
||||
|
||||
@@ -766,6 +766,7 @@ type MediaTrack interface {
|
||||
ClearAllReceivers(isExpectedToResume bool)
|
||||
|
||||
IsEncrypted() bool
|
||||
HasPacketTrailer() bool
|
||||
}
|
||||
|
||||
//counterfeiter:generate . LocalMediaTrack
|
||||
|
||||
@@ -16,7 +16,7 @@ package types
|
||||
|
||||
type ProtocolVersion int
|
||||
|
||||
const CurrentProtocol = 16
|
||||
const CurrentProtocol = 17
|
||||
|
||||
func (v ProtocolVersion) SupportsPackedStreamId() bool {
|
||||
return v > 0
|
||||
@@ -99,3 +99,7 @@ func (v ProtocolVersion) SupportsNonErrorSignalResponse() bool {
|
||||
func (v ProtocolVersion) SupportsMoving() bool {
|
||||
return v > 15
|
||||
}
|
||||
|
||||
func (v ProtocolVersion) SupportsPacketTrailer() bool {
|
||||
return v > 16
|
||||
}
|
||||
|
||||
@@ -124,6 +124,16 @@ type FakeLocalMediaTrack struct {
|
||||
getTrackStatsReturnsOnCall map[int]struct {
|
||||
result1 *livekit.RTPStats
|
||||
}
|
||||
HasPacketTrailerStub func() bool
|
||||
hasPacketTrailerMutex sync.RWMutex
|
||||
hasPacketTrailerArgsForCall []struct {
|
||||
}
|
||||
hasPacketTrailerReturns struct {
|
||||
result1 bool
|
||||
}
|
||||
hasPacketTrailerReturnsOnCall map[int]struct {
|
||||
result1 bool
|
||||
}
|
||||
HasSdpCidStub func(string) bool
|
||||
hasSdpCidMutex sync.RWMutex
|
||||
hasSdpCidArgsForCall []struct {
|
||||
@@ -950,6 +960,59 @@ func (fake *FakeLocalMediaTrack) GetTrackStatsReturnsOnCall(i int, result1 *live
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeLocalMediaTrack) HasPacketTrailer() bool {
|
||||
fake.hasPacketTrailerMutex.Lock()
|
||||
ret, specificReturn := fake.hasPacketTrailerReturnsOnCall[len(fake.hasPacketTrailerArgsForCall)]
|
||||
fake.hasPacketTrailerArgsForCall = append(fake.hasPacketTrailerArgsForCall, struct {
|
||||
}{})
|
||||
stub := fake.HasPacketTrailerStub
|
||||
fakeReturns := fake.hasPacketTrailerReturns
|
||||
fake.recordInvocation("HasPacketTrailer", []interface{}{})
|
||||
fake.hasPacketTrailerMutex.Unlock()
|
||||
if stub != nil {
|
||||
return stub()
|
||||
}
|
||||
if specificReturn {
|
||||
return ret.result1
|
||||
}
|
||||
return fakeReturns.result1
|
||||
}
|
||||
|
||||
func (fake *FakeLocalMediaTrack) HasPacketTrailerCallCount() int {
|
||||
fake.hasPacketTrailerMutex.RLock()
|
||||
defer fake.hasPacketTrailerMutex.RUnlock()
|
||||
return len(fake.hasPacketTrailerArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *FakeLocalMediaTrack) HasPacketTrailerCalls(stub func() bool) {
|
||||
fake.hasPacketTrailerMutex.Lock()
|
||||
defer fake.hasPacketTrailerMutex.Unlock()
|
||||
fake.HasPacketTrailerStub = stub
|
||||
}
|
||||
|
||||
func (fake *FakeLocalMediaTrack) HasPacketTrailerReturns(result1 bool) {
|
||||
fake.hasPacketTrailerMutex.Lock()
|
||||
defer fake.hasPacketTrailerMutex.Unlock()
|
||||
fake.HasPacketTrailerStub = nil
|
||||
fake.hasPacketTrailerReturns = struct {
|
||||
result1 bool
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeLocalMediaTrack) HasPacketTrailerReturnsOnCall(i int, result1 bool) {
|
||||
fake.hasPacketTrailerMutex.Lock()
|
||||
defer fake.hasPacketTrailerMutex.Unlock()
|
||||
fake.HasPacketTrailerStub = nil
|
||||
if fake.hasPacketTrailerReturnsOnCall == nil {
|
||||
fake.hasPacketTrailerReturnsOnCall = make(map[int]struct {
|
||||
result1 bool
|
||||
})
|
||||
}
|
||||
fake.hasPacketTrailerReturnsOnCall[i] = struct {
|
||||
result1 bool
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeLocalMediaTrack) HasSdpCid(arg1 string) bool {
|
||||
fake.hasSdpCidMutex.Lock()
|
||||
ret, specificReturn := fake.hasSdpCidReturnsOnCall[len(fake.hasSdpCidArgsForCall)]
|
||||
|
||||
@@ -98,6 +98,16 @@ type FakeMediaTrack struct {
|
||||
getTemporalLayerForSpatialFpsReturnsOnCall map[int]struct {
|
||||
result1 int32
|
||||
}
|
||||
HasPacketTrailerStub func() bool
|
||||
hasPacketTrailerMutex sync.RWMutex
|
||||
hasPacketTrailerArgsForCall []struct {
|
||||
}
|
||||
hasPacketTrailerReturns struct {
|
||||
result1 bool
|
||||
}
|
||||
hasPacketTrailerReturnsOnCall map[int]struct {
|
||||
result1 bool
|
||||
}
|
||||
IDStub func() livekit.TrackID
|
||||
iDMutex sync.RWMutex
|
||||
iDArgsForCall []struct {
|
||||
@@ -742,6 +752,59 @@ func (fake *FakeMediaTrack) GetTemporalLayerForSpatialFpsReturnsOnCall(i int, re
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeMediaTrack) HasPacketTrailer() bool {
|
||||
fake.hasPacketTrailerMutex.Lock()
|
||||
ret, specificReturn := fake.hasPacketTrailerReturnsOnCall[len(fake.hasPacketTrailerArgsForCall)]
|
||||
fake.hasPacketTrailerArgsForCall = append(fake.hasPacketTrailerArgsForCall, struct {
|
||||
}{})
|
||||
stub := fake.HasPacketTrailerStub
|
||||
fakeReturns := fake.hasPacketTrailerReturns
|
||||
fake.recordInvocation("HasPacketTrailer", []interface{}{})
|
||||
fake.hasPacketTrailerMutex.Unlock()
|
||||
if stub != nil {
|
||||
return stub()
|
||||
}
|
||||
if specificReturn {
|
||||
return ret.result1
|
||||
}
|
||||
return fakeReturns.result1
|
||||
}
|
||||
|
||||
func (fake *FakeMediaTrack) HasPacketTrailerCallCount() int {
|
||||
fake.hasPacketTrailerMutex.RLock()
|
||||
defer fake.hasPacketTrailerMutex.RUnlock()
|
||||
return len(fake.hasPacketTrailerArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *FakeMediaTrack) HasPacketTrailerCalls(stub func() bool) {
|
||||
fake.hasPacketTrailerMutex.Lock()
|
||||
defer fake.hasPacketTrailerMutex.Unlock()
|
||||
fake.HasPacketTrailerStub = stub
|
||||
}
|
||||
|
||||
func (fake *FakeMediaTrack) HasPacketTrailerReturns(result1 bool) {
|
||||
fake.hasPacketTrailerMutex.Lock()
|
||||
defer fake.hasPacketTrailerMutex.Unlock()
|
||||
fake.HasPacketTrailerStub = nil
|
||||
fake.hasPacketTrailerReturns = struct {
|
||||
result1 bool
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeMediaTrack) HasPacketTrailerReturnsOnCall(i int, result1 bool) {
|
||||
fake.hasPacketTrailerMutex.Lock()
|
||||
defer fake.hasPacketTrailerMutex.Unlock()
|
||||
fake.HasPacketTrailerStub = nil
|
||||
if fake.hasPacketTrailerReturnsOnCall == nil {
|
||||
fake.hasPacketTrailerReturnsOnCall = make(map[int]struct {
|
||||
result1 bool
|
||||
})
|
||||
}
|
||||
fake.hasPacketTrailerReturnsOnCall[i] = struct {
|
||||
result1 bool
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeMediaTrack) ID() livekit.TrackID {
|
||||
fake.iDMutex.Lock()
|
||||
ret, specificReturn := fake.iDReturnsOnCall[len(fake.iDArgsForCall)]
|
||||
|
||||
Reference in New Issue
Block a user