Simplifying (hopefully) sfu.DownTrack (#213)
* Simplifying (hopefully) sfu.DownTrack * Remove unnecessary check as pdding only packets are dropped before that check * Temporal filtering max layer * - Split out forwarder bits into a separate structure - Address comments from Jie and David * Remove debug and unneeded stuff * Fix test * Remove unneeded default initialization
This commit is contained in:
@@ -707,8 +707,7 @@ func (p *ParticipantImpl) GetConnectionQuality() livekit.ConnectionQuality {
|
|||||||
if subTrack.IsMuted() {
|
if subTrack.IsMuted() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// LK-TODO: maybe this should check CurrentSpatialLayer as target may not have been achieved
|
if subTrack.DownTrack().GetForwardingStatus() != sfu.ForwardingStatusOptimal {
|
||||||
if subTrack.DownTrack().TargetSpatialLayer() < subTrack.DownTrack().MaxSpatialLayer() {
|
|
||||||
reducedQualitySub = true
|
reducedQualitySub = true
|
||||||
}
|
}
|
||||||
subLoss += subTrack.SubscribeLossPercentage()
|
subLoss += subTrack.SubscribeLossPercentage()
|
||||||
|
|||||||
@@ -45,17 +45,14 @@ func (a *atomicBool) get() bool {
|
|||||||
+-+-+-+-+-+-+-+-+
|
+-+-+-+-+-+-+-+-+
|
||||||
*/
|
*/
|
||||||
type VP8 struct {
|
type VP8 struct {
|
||||||
TemporalSupported bool // LK-TODO: CLEANUP-REMOVE
|
FirstByte byte
|
||||||
FirstByte byte
|
|
||||||
|
|
||||||
PictureIDPresent int
|
PictureIDPresent int
|
||||||
PictureID uint16 /* 8 or 16 bits, picture ID */
|
PictureID uint16 /* 8 or 16 bits, picture ID */
|
||||||
PicIDIdx int // LK-TODO: CLEANUP-REMOVE
|
|
||||||
MBit bool
|
MBit bool
|
||||||
|
|
||||||
TL0PICIDXPresent int
|
TL0PICIDXPresent int
|
||||||
TL0PICIDX uint8 /* 8 bits temporal level zero index */
|
TL0PICIDX uint8 /* 8 bits temporal level zero index */
|
||||||
TlzIdx int // LK-TODO: CLEANUP-REMOVE
|
|
||||||
|
|
||||||
// Optional Header If either of the T or K bits are set to 1,
|
// Optional Header If either of the T or K bits are set to 1,
|
||||||
// the TID/Y/KEYIDX extension field MUST be present.
|
// the TID/Y/KEYIDX extension field MUST be present.
|
||||||
@@ -100,15 +97,12 @@ func (p *VP8) Unmarshal(payload []byte) error {
|
|||||||
if L && !T {
|
if L && !T {
|
||||||
return errInvalidPacket
|
return errInvalidPacket
|
||||||
}
|
}
|
||||||
// Check if T is present, if not, no temporal layer is available
|
|
||||||
p.TemporalSupported = payload[idx]&0x20 > 0
|
|
||||||
// Check for PictureID
|
// Check for PictureID
|
||||||
if I {
|
if I {
|
||||||
idx++
|
idx++
|
||||||
if payloadLen < idx+1 {
|
if payloadLen < idx+1 {
|
||||||
return errShortPacket
|
return errShortPacket
|
||||||
}
|
}
|
||||||
p.PicIDIdx = idx
|
|
||||||
p.PictureIDPresent = 1
|
p.PictureIDPresent = 1
|
||||||
pid := payload[idx] & 0x7f
|
pid := payload[idx] & 0x7f
|
||||||
// Check if m is 1, then Picture ID is 15 bits
|
// Check if m is 1, then Picture ID is 15 bits
|
||||||
@@ -129,7 +123,6 @@ func (p *VP8) Unmarshal(payload []byte) error {
|
|||||||
if payloadLen < idx+1 {
|
if payloadLen < idx+1 {
|
||||||
return errShortPacket
|
return errShortPacket
|
||||||
}
|
}
|
||||||
p.TlzIdx = idx
|
|
||||||
p.TL0PICIDXPresent = 1
|
p.TL0PICIDXPresent = 1
|
||||||
|
|
||||||
if int(idx) >= payloadLen {
|
if int(idx) >= payloadLen {
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ func TestVP8Helper_Unmarshal(t *testing.T) {
|
|||||||
t.Errorf("Unmarshal() error = %v, wantErr %v", err, tt.wantErr)
|
t.Errorf("Unmarshal() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
}
|
}
|
||||||
if tt.checkTemporal {
|
if tt.checkTemporal {
|
||||||
assert.Equal(t, tt.temporalSupport, p.TemporalSupported)
|
assert.Equal(t, tt.temporalSupport, p.TIDPresent == 1)
|
||||||
}
|
}
|
||||||
if tt.checkKeyFrame {
|
if tt.checkKeyFrame {
|
||||||
assert.Equal(t, tt.keyFrame, p.IsKeyFrame)
|
assert.Equal(t, tt.keyFrame, p.IsKeyFrame)
|
||||||
|
|||||||
+838
-821
File diff suppressed because it is too large
Load Diff
@@ -1225,11 +1225,13 @@ type Track struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newTrack(downTrack *DownTrack, peerID string) *Track {
|
func newTrack(downTrack *DownTrack, peerID string) *Track {
|
||||||
|
maxSpatialLayer, maxTemporalLayer := downTrack.MaxLayers()
|
||||||
|
|
||||||
return &Track{
|
return &Track{
|
||||||
downTrack: downTrack,
|
downTrack: downTrack,
|
||||||
peerID: peerID,
|
peerID: peerID,
|
||||||
maxSpatialLayer: downTrack.MaxSpatialLayer(),
|
maxSpatialLayer: maxSpatialLayer,
|
||||||
maxTemporalLayer: downTrack.MaxTemporalLayer(),
|
maxTemporalLayer: maxTemporalLayer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user