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:
+16
-9
@@ -54,14 +54,15 @@ func (r RTPMungerState) String() string {
|
|||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
type RTPMungerParams struct {
|
type RTPMungerParams struct {
|
||||||
started bool
|
started bool
|
||||||
highestIncomingSN uint16
|
highestIncomingSN uint16
|
||||||
lastSN uint16
|
lastSN uint16
|
||||||
snOffset uint16
|
snOffset uint16
|
||||||
highestIncomingTS uint32
|
highestIncomingTS uint32
|
||||||
lastTS uint32
|
lastTS uint32
|
||||||
tsOffset uint32
|
tsOffset uint32
|
||||||
lastMarker bool
|
tsOffsetAdjustment uint32
|
||||||
|
lastMarker bool
|
||||||
|
|
||||||
snOffsets [SnOffsetCacheSize]uint16
|
snOffsets [SnOffsetCacheSize]uint16
|
||||||
snOffsetsWritePtr int
|
snOffsetsWritePtr int
|
||||||
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user