HLS muxer: support dynamic H264 SPS/PPS

This commit is contained in:
aler9 2022-03-06 16:12:07 +01:00 committed by Alessandro Ros
parent 57cb2e99d1
commit 37e22b96cd
2 changed files with 0 additions and 22 deletions

View file

@ -1,7 +1,6 @@
package hls
import (
"fmt"
"io"
"time"
@ -23,12 +22,6 @@ func NewMuxer(
videoTrack *gortsplib.TrackH264,
audioTrack *gortsplib.TrackAAC,
) (*Muxer, error) {
if videoTrack != nil {
if videoTrack.SPS() == nil || videoTrack.PPS() == nil {
return nil, fmt.Errorf("invalid H264 track: SPS or PPS not provided into the SDP")
}
}
primaryPlaylist := newMuxerPrimaryPlaylist(videoTrack, audioTrack)
streamPlaylist := newMuxerStreamPlaylist(hlsSegmentCount)

View file

@ -119,21 +119,6 @@ func (m *muxerTSGenerator) writeH264(pts time.Duration, nalus [][]byte) error {
{byte(h264.NALUTypeAccessUnitDelimiter), 240},
}
for _, nalu := range nalus {
typ := h264.NALUType(nalu[0] & 0x1F)
switch typ {
case h264.NALUTypeSPS, h264.NALUTypePPS, h264.NALUTypeAccessUnitDelimiter:
// remove existing SPS, PPS, AUD
continue
case h264.NALUTypeIDR:
// add SPS and PPS before every IDR
filteredNALUs = append(filteredNALUs, m.videoTrack.SPS(), m.videoTrack.PPS())
}
filteredNALUs = append(filteredNALUs, nalu)
}
enc, err := h264.EncodeAnnexB(filteredNALUs)
if err != nil {
if m.currentSegment.buf.Len() > 0 {