Browse Source

Merge pull request #11 from jianglieshan/v3

优化webrtc的播放逻辑,修改时标错误
v4
dexter 3 years ago
committed by GitHub
parent
commit
4ec2ac8c7b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      main.go

13
main.go

@ -291,20 +291,19 @@ func run() {
lastTimeStampV = ts
if pack.IDR {
for _, nalu := range vt.ExtraData.NALUs {
for _, packet := range vpacketer.Packetize(nalu, s) {
for _, packet := range vpacketer.Packetize(nalu, 0) {
err = videoTrack.WriteRTP(packet)
}
}
}
var firstTs uint32
for naluIndex, nalu := range pack.NALUs {
packets := vpacketer.Packetize(nalu, s)
for packIndex, packet := range packets {
if naluIndex == 0 {
firstTs = packet.Timestamp
var packets []*rtp.Packet
if naluIndex == len(pack.NALUs)-1 {
packets = vpacketer.Packetize(nalu, s)
} else {
packet.Timestamp = firstTs
packets = vpacketer.Packetize(nalu, 0)
}
for packIndex, packet := range packets {
packet.Marker = naluIndex == len(pack.NALUs)-1 && packIndex == len(packets)-1
err = videoTrack.WriteRTP(packet)
}

Loading…
Cancel
Save