mirror of https://github.com/gwuhaolin/livego.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
461 B
29 lines
461 B
package hls |
|
|
|
const ( |
|
syncms = 2 // ms |
|
) |
|
|
|
type align struct { |
|
frameNum uint64 |
|
frameBase uint64 |
|
} |
|
|
|
func (a *align) align(dts *uint64, inc uint32) { |
|
aFrameDts := *dts |
|
estPts := a.frameBase + a.frameNum*uint64(inc) |
|
var dPts uint64 |
|
if estPts >= aFrameDts { |
|
dPts = estPts - aFrameDts |
|
} else { |
|
dPts = aFrameDts - estPts |
|
} |
|
|
|
if dPts <= uint64(syncms)*h264_default_hz { |
|
a.frameNum++ |
|
*dts = estPts |
|
return |
|
} |
|
a.frameNum = 1 |
|
a.frameBase = aFrameDts |
|
}
|
|
|