Add ability to roll back video layer selection. (#1871)
* Add ability to roll back video layer selection. Not currently useful, but it is possible to do things like not applying a layer switch if the switch point time stamp is too far back. Add ability to roll back a layer switch and invoke rollback if a packet was selected for forwarding, but a subsequent error or decision to drop the packet can rollback layer switch if that was the switching packet. In current code, the paths where a packet can be dropped after selection does not happen at switch points. So, it was okay to apply the selection unconditionally. But, adding the call to rollback in the current code also in all paths where packet is dropped after selection for consistent code flow. * separate switch for temporal layer
This commit is contained in:
+12
-1
@@ -1594,6 +1594,12 @@ func (f *Forwarder) getTranslationParamsAudio(extPkt *buffer.ExtPacket, layer in
|
||||
|
||||
// should be called with lock held
|
||||
func (f *Forwarder) getTranslationParamsVideo(extPkt *buffer.ExtPacket, layer int32) (*TranslationParams, error) {
|
||||
maybeRollback := func(isSwitching bool) {
|
||||
if isSwitching {
|
||||
f.vls.Rollback()
|
||||
}
|
||||
}
|
||||
|
||||
tp := &TranslationParams{}
|
||||
|
||||
if !f.vls.GetTarget().IsValid() {
|
||||
@@ -1640,20 +1646,23 @@ func (f *Forwarder) getTranslationParamsVideo(extPkt *buffer.ExtPacket, layer in
|
||||
// To differentiate between the two cases, drop only when in DEFICIENT state.
|
||||
//
|
||||
tp.shouldDrop = true
|
||||
maybeRollback(result.IsSwitching)
|
||||
return tp, nil
|
||||
}
|
||||
|
||||
_, err := f.getTranslationParamsCommon(extPkt, layer, tp)
|
||||
if tp.shouldDrop || len(extPkt.Packet.Payload) == 0 {
|
||||
maybeRollback(result.IsSwitching)
|
||||
return tp, err
|
||||
}
|
||||
|
||||
// codec specific forwarding check and any needed packet munging
|
||||
tl, isSwitching := f.vls.SelectTemporal(extPkt)
|
||||
codecBytes, err := f.codecMunger.UpdateAndGet(
|
||||
extPkt,
|
||||
tp.rtp.snOrdering == SequenceNumberOrderingOutOfOrder,
|
||||
tp.rtp.snOrdering == SequenceNumberOrderingGap,
|
||||
f.vls.SelectTemporal(extPkt),
|
||||
tl,
|
||||
)
|
||||
if err != nil {
|
||||
tp.rtp = nil
|
||||
@@ -1663,9 +1672,11 @@ func (f *Forwarder) getTranslationParamsVideo(extPkt *buffer.ExtPacket, layer in
|
||||
// filtered temporal layer, update sequence number offset to prevent holes
|
||||
f.rtpMunger.PacketDropped(extPkt)
|
||||
}
|
||||
maybeRollback(result.IsSwitching || isSwitching)
|
||||
return tp, nil
|
||||
}
|
||||
|
||||
maybeRollback(result.IsSwitching || isSwitching)
|
||||
return tp, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user