1
0
Fork 0
forked from External/mediamtx

propagate H264 packets throughout the server

This commit is contained in:
aler9 2022-03-02 22:52:05 +01:00 committed by Alessandro Ros
parent a59ddf7176
commit d929197b21
15 changed files with 160 additions and 255 deletions

View file

@ -6,6 +6,7 @@ import (
"time"
"github.com/aler9/gortsplib"
"github.com/aler9/gortsplib/pkg/h264"
"github.com/aler9/gortsplib/pkg/rtpaac"
"github.com/aler9/gortsplib/pkg/rtph264"
@ -146,8 +147,21 @@ func (s *hlsSource) runInner() bool {
return
}
for _, pkt := range pkts {
stream.writePacketRTP(videoTrackID, pkt)
lastPkt := len(pkts) - 1
for i, pkt := range pkts {
if i != lastPkt {
stream.writeData(videoTrackID, &data{
rtp: pkt,
ptsEqualsDTS: false,
})
} else {
stream.writeData(videoTrackID, &data{
rtp: pkt,
ptsEqualsDTS: h264.IDRPresent(nalus),
h264NALUs: nalus,
h264PTS: pts,
})
}
}
}
@ -162,7 +176,10 @@ func (s *hlsSource) runInner() bool {
}
for _, pkt := range pkts {
stream.writePacketRTP(audioTrackID, pkt)
stream.writeData(audioTrackID, &data{
rtp: pkt,
ptsEqualsDTS: true,
})
}
}