mirror of
https://github.com/bluenviron/mediamtx
synced 2025-02-28 09:30:32 +00:00
hls muxer: update primary playlist in case SPS/PPS changed
This commit is contained in:
parent
3b21da7762
commit
07591c7514
@ -1,7 +1,6 @@
|
|||||||
package hls
|
package hls
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"io"
|
"io"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -13,19 +12,20 @@ import (
|
|||||||
type muxerPrimaryPlaylist struct {
|
type muxerPrimaryPlaylist struct {
|
||||||
videoTrack *gortsplib.TrackH264
|
videoTrack *gortsplib.TrackH264
|
||||||
audioTrack *gortsplib.TrackAAC
|
audioTrack *gortsplib.TrackAAC
|
||||||
|
|
||||||
cnt []byte
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func newMuxerPrimaryPlaylist(
|
func newMuxerPrimaryPlaylist(
|
||||||
videoTrack *gortsplib.TrackH264,
|
videoTrack *gortsplib.TrackH264,
|
||||||
audioTrack *gortsplib.TrackAAC,
|
audioTrack *gortsplib.TrackAAC,
|
||||||
) *muxerPrimaryPlaylist {
|
) *muxerPrimaryPlaylist {
|
||||||
p := &muxerPrimaryPlaylist{
|
return &muxerPrimaryPlaylist{
|
||||||
videoTrack: videoTrack,
|
videoTrack: videoTrack,
|
||||||
audioTrack: audioTrack,
|
audioTrack: audioTrack,
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *muxerPrimaryPlaylist) reader() io.Reader {
|
||||||
|
return &asyncReader{generator: func() []byte {
|
||||||
var codecs []string
|
var codecs []string
|
||||||
|
|
||||||
if p.videoTrack != nil {
|
if p.videoTrack != nil {
|
||||||
@ -40,15 +40,10 @@ func newMuxerPrimaryPlaylist(
|
|||||||
codecs = append(codecs, "mp4a.40."+strconv.FormatInt(int64(p.audioTrack.Type()), 10))
|
codecs = append(codecs, "mp4a.40."+strconv.FormatInt(int64(p.audioTrack.Type()), 10))
|
||||||
}
|
}
|
||||||
|
|
||||||
p.cnt = []byte("#EXTM3U\n" +
|
return []byte("#EXTM3U\n" +
|
||||||
"#EXT-X-VERSION:3\n" +
|
"#EXT-X-VERSION:3\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"#EXT-X-STREAM-INF:BANDWIDTH=200000,CODECS=\"" + strings.Join(codecs, ",") + "\"\n" +
|
"#EXT-X-STREAM-INF:BANDWIDTH=200000,CODECS=\"" + strings.Join(codecs, ",") + "\"\n" +
|
||||||
"stream.m3u8\n")
|
"stream.m3u8\n")
|
||||||
|
}}
|
||||||
return p
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *muxerPrimaryPlaylist) reader() io.Reader {
|
|
||||||
return bytes.NewReader(p.cnt)
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user