Skip to content

Commit a5cfa30

Browse files
authored
Log timestamps on track initialization and on unexpected PTS jumps (#738)
1 parent 575d774 commit a5cfa30

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

pkg/synchronizer/track.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ func (t *TrackSynchronizer) Initialize(pkt *rtp.Packet) {
106106
t.lastTS = pkt.Timestamp
107107
t.lastPTS = 0
108108
t.lastPTSAdjusted = t.currentPTSOffset
109+
t.logger.Infow("initialized track synchronizer",
110+
"startRTP", t.startRTP,
111+
"currentPTSOffset", t.currentPTSOffset,
112+
)
109113
}
110114

111115
// GetPTS will reset sequence numbers and/or offsets if necessary
@@ -126,8 +130,18 @@ func (t *TrackSynchronizer) GetPTS(pkt *rtp.Packet) (time.Duration, error) {
126130
pts := t.lastPTS + t.toDuration(ts-t.lastTS)
127131
estimatedPTS := time.Since(t.startTime)
128132
if pts < t.lastPTS || !t.acceptable(pts-estimatedPTS) {
133+
newStartRTP := ts - t.toRTP(estimatedPTS)
134+
t.logger.Infow("correcting PTS",
135+
"TS", ts,
136+
"lastTS", t.lastTS,
137+
"PTS", pts,
138+
"lastPTS", t.lastPTS,
139+
"estimatedPTS", estimatedPTS,
140+
"startRTP", t.startRTP,
141+
"newStartRTP", newStartRTP,
142+
)
129143
pts = estimatedPTS
130-
t.startRTP = ts - t.toRTP(pts)
144+
t.startRTP = newStartRTP
131145
}
132146

133147
if t.shouldAdjustPTS() {

0 commit comments

Comments
 (0)