Browse Source

HLS muxer: support dynamic H264 SPS/PPS

pull/923/head
aler9 4 years ago committed by Alessandro Ros
parent
commit
37e22b96cd
  1. 7
      internal/hls/muxer.go
  2. 15
      internal/hls/muxer_ts_generator.go

7
internal/hls/muxer.go

@ -1,7 +1,6 @@ @@ -1,7 +1,6 @@
package hls
import (
"fmt"
"io"
"time"
@ -23,12 +22,6 @@ func NewMuxer( @@ -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)

15
internal/hls/muxer_ts_generator.go

@ -119,21 +119,6 @@ func (m *muxerTSGenerator) writeH264(pts time.Duration, nalus [][]byte) error { @@ -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 {

Loading…
Cancel
Save