@@ -66,6 +66,7 @@ type TrackSynchronizer struct {
6666 preJitterBufferReceiveTimeEnabled bool
6767 rtcpSenderReportRebaseEnabled bool
6868 oldPacketThreshold time.Duration
69+ enableStartGate bool
6970
7071 // timing info
7172 startTime time.Time // time at initialization --> this should be when first packet is received
@@ -113,6 +114,7 @@ func newTrackSynchronizer(s *Synchronizer, track TrackRemote) *TrackSynchronizer
113114 preJitterBufferReceiveTimeEnabled : s .config .PreJitterBufferReceiveTimeEnabled ,
114115 rtcpSenderReportRebaseEnabled : s .config .RTCPSenderReportRebaseEnabled ,
115116 oldPacketThreshold : s .config .OldPacketThreshold ,
117+ enableStartGate : s .config .EnableStartGate ,
116118 nextPTSAdjustmentAt : mono .Now (),
117119 propagationDelayEstimator : NewOWDEstimator (OWDEstimatorParamsDefault ),
118120 }
@@ -210,6 +212,7 @@ func (t *TrackSynchronizer) initialize(extPkt jitter.ExtPacket) {
210212 "preJitterBufferReceiveTimeEnabled" , t .preJitterBufferReceiveTimeEnabled ,
211213 "rtcpSenderReportRebaseEnabled" , t .rtcpSenderReportRebaseEnabled ,
212214 "oldPacketThreshold" , t .oldPacketThreshold ,
215+ "enableStartGate" , t .enableStartGate ,
213216 )
214217}
215218
@@ -352,6 +355,9 @@ func (t *TrackSynchronizer) getPTSWithoutRebase(pkt jitter.ExtPacket) (time.Dura
352355 t .lastPTSAdjusted = adjusted
353356
354357 t .stats .numEmitted ++
358+ if adjusted < 0 {
359+ t .stats .numNegativePTS ++
360+ }
355361 return adjusted , nil
356362}
357363
@@ -490,6 +496,9 @@ func (t *TrackSynchronizer) getPTSWithRebase(pkt jitter.ExtPacket) (time.Duratio
490496 t .lastPTSAdjusted = adjusted
491497
492498 t .stats .numEmitted ++
499+ if adjusted < 0 {
500+ t .stats .numNegativePTS ++
501+ }
493502 return adjusted , nil
494503}
495504
@@ -897,6 +906,8 @@ type stats struct {
897906 numDroppedOutOfOrder uint32
898907 numDroppedEOF uint32
899908
909+ numNegativePTS uint32
910+
900911 gapHistogram [cGapHistogramNumBins ]uint32
901912 largestGap uint16
902913
@@ -910,6 +921,8 @@ func (s stats) MarshalLogObject(e zapcore.ObjectEncoder) error {
910921 e .AddUint32 ("numDroppedOutOfOrder" , s .numDroppedOutOfOrder )
911922 e .AddUint32 ("numDroppedEOF" , s .numDroppedEOF )
912923
924+ e .AddUint32 ("numNegativePTS" , s .numNegativePTS )
925+
913926 hasLoss := false
914927 first := true
915928 str := "["
0 commit comments