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) {
106
106
t .lastTS = pkt .Timestamp
107
107
t .lastPTS = 0
108
108
t .lastPTSAdjusted = t .currentPTSOffset
109
+ t .logger .Infow ("initialized track synchronizer" ,
110
+ "startRTP" , t .startRTP ,
111
+ "currentPTSOffset" , t .currentPTSOffset ,
112
+ )
109
113
}
110
114
111
115
// GetPTS will reset sequence numbers and/or offsets if necessary
@@ -126,8 +130,18 @@ func (t *TrackSynchronizer) GetPTS(pkt *rtp.Packet) (time.Duration, error) {
126
130
pts := t .lastPTS + t .toDuration (ts - t .lastTS )
127
131
estimatedPTS := time .Since (t .startTime )
128
132
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
+ )
129
143
pts = estimatedPTS
130
- t .startRTP = ts - t . toRTP ( pts )
144
+ t .startRTP = newStartRTP
131
145
}
132
146
133
147
if t .shouldAdjustPTS () {
You can’t perform that action at this time.
0 commit comments