Apply time stamp adjustment only at the start of a frame. (#1698)

It was possible that the adjustment applied in the middle
of a frame resulting in the same frame having multiple time stamps.
That would have caused video to pause/jump.

Apply the offset only at the start of the frame so that all
packets of a frame get the same offset.
This commit is contained in:
Raja Subramanian
2023-05-09 12:39:11 +05:30
committed by GitHub
parent 0e582ec82a
commit cf2a078579
+8 -1
View File
@@ -61,6 +61,7 @@ type RTPMungerParams struct {
highestIncomingTS uint32 highestIncomingTS uint32
lastTS uint32 lastTS uint32
tsOffset uint32 tsOffset uint32
tsOffsetAdjustment uint32
lastMarker bool lastMarker bool
snOffsets [SnOffsetCacheSize]uint16 snOffsets [SnOffsetCacheSize]uint16
@@ -143,7 +144,7 @@ func (r *RTPMunger) PacketDropped(extPkt *buffer.ExtPacket) {
} }
func (r *RTPMunger) UpdateTsOffset(tsAdjust uint32) { func (r *RTPMunger) UpdateTsOffset(tsAdjust uint32) {
r.tsOffset -= tsAdjust r.tsOffsetAdjustment = tsAdjust
} }
func (r *RTPMunger) UpdateAndGetSnTs(extPkt *buffer.ExtPacket) (*TranslationParamsRTP, error) { func (r *RTPMunger) UpdateAndGetSnTs(extPkt *buffer.ExtPacket) (*TranslationParamsRTP, error) {
@@ -199,6 +200,12 @@ func (r *RTPMunger) UpdateAndGetSnTs(extPkt *buffer.ExtPacket) (*TranslationPara
} }
} }
// apply timestamp offset adjustment at the start of a frame only
if extPkt.Packet.Timestamp != r.highestIncomingTS && r.tsOffsetAdjustment != 0 {
r.tsOffset -= r.tsOffsetAdjustment
r.tsOffsetAdjustment = 0
}
// in-order incoming packet, may or may not be contiguous. // in-order incoming packet, may or may not be contiguous.
// In the case of loss (i.e. incoming sequence number is not contiguous), // In the case of loss (i.e. incoming sequence number is not contiguous),
// forward even if it is a padding only packet. With temporal scalability, // forward even if it is a padding only packet. With temporal scalability,