File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff 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 () {
You can’t perform that action at this time.
0 commit comments