Skip to content

Commit

Permalink
fix tests and rendition flags
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed Oct 2, 2024
1 parent e245a86 commit 4453b3f
Show file tree
Hide file tree
Showing 4 changed files with 193 additions and 68 deletions.
12 changes: 7 additions & 5 deletions examples/muxer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ func handleIndex(wrapped http.HandlerFunc) http.HandlerFunc {
}

func main() {
videoTrack := &gohlslib.Track{
Codec: &codecs.H264{},
}

// create the HLS muxer
mux := &gohlslib.Muxer{
VideoTrack: &gohlslib.Track{
Codec: &codecs.H264{},
},
Tracks: []*gohlslib.Track{videoTrack},
}
err := mux.Start()
if err != nil {
Expand Down Expand Up @@ -80,7 +82,7 @@ func main() {
for _, track := range r.Tracks() {
if _, ok := track.Codec.(*mpegts.CodecH264); ok {
// setup a callback that is called once a H264 access unit is received
r.OnDataH26x(track, func(rawPTS int64, _ int64, au [][]byte) error {
r.OnDataH264(track, func(rawPTS int64, _ int64, au [][]byte) error {
// decode the time
if timeDec == nil {
timeDec = mpegts.NewTimeDecoder(rawPTS)
Expand All @@ -89,7 +91,7 @@ func main() {

// pass the access unit to the HLS muxer
log.Printf("visit http://localhost:8080 - encoding access unit with PTS = %v", pts)
mux.WriteH264(time.Now(), pts, au)
mux.WriteH264(videoTrack, time.Now(), pts, au)

return nil
})
Expand Down
2 changes: 1 addition & 1 deletion muxer.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func (m *Muxer) Start() error {
id = "audio" + strconv.FormatInt(int64(i+1), 10)
}

isRendition := !track.isLeading || !isVideo(track.Codec)
isRendition := !track.isLeading || (!isVideo(track.Codec) && len(m.Tracks) > 1)

var isDefaultRendition bool
if isRendition && !defaultRenditionChosen {
Expand Down
2 changes: 1 addition & 1 deletion muxer_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (s *muxerStream) populateMultivariantPlaylist(
GroupID: "audio",
Name: s.id,
Autoselect: true,
URI: &uri,
Default: s.isDefaultRendition,
}

// draft-pantos-hls-rfc8216bis:
Expand Down
Loading

0 comments on commit 4453b3f

Please sign in to comment.