Skip to content

Commit

Permalink
fix: correct settings of renditions for all variants.
Browse files Browse the repository at this point in the history
I-frame playlists reset the renditions.
Now all variants get the right renditions for
its group-ids.
  • Loading branch information
tobbee committed Dec 31, 2024
1 parent 5162b8d commit c691187
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- CHANNELS attribute to EXT-X-MEDIA

### Fixed

- Renditions were not properly distributed to Variants

## v0.1.0 - cleaned grafov/m3u8 code

### Changed
Expand Down
9 changes: 4 additions & 5 deletions m3u8/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ func (p *MasterPlaylist) decode(buf *bytes.Buffer, strict bool) error {

func (p *MasterPlaylist) attachRenditionsToVariants(alternatives []*Alternative) {
for _, variant := range p.Variants {
if variant.Iframe {
continue
}
for _, alt := range alternatives {
if alt == nil {
continue
Expand Down Expand Up @@ -231,7 +234,6 @@ func decode(buf *bytes.Buffer, strict bool, customDecoders []CustomDecoder) (Pla
line = trimLineEnd(line)

err = decodeLineOfMasterPlaylist(master, state, line, strict)
master.attachRenditionsToVariants(state.alternatives)
if strict && err != nil {
return master, state.listType, err
}
Expand All @@ -249,6 +251,7 @@ func decode(buf *bytes.Buffer, strict bool, customDecoders []CustomDecoder) (Pla

switch state.listType {
case MASTER:
master.attachRenditionsToVariants(state.alternatives)
return master, MASTER, nil
case MEDIA:
if media.Closed || media.MediaType == EVENT {
Expand Down Expand Up @@ -398,10 +401,6 @@ func decodeLineOfMasterPlaylist(p *MasterPlaylist, state *decodingState, line st
state.listType = MASTER
state.variant = new(Variant)
state.variant.Iframe = true
if len(state.alternatives) > 0 {
state.variant.Alternatives = state.alternatives
state.alternatives = nil
}
p.Variants = append(p.Variants, state.variant)
for k, v := range decodeParamsLine(line[26:]) {
switch k {
Expand Down

0 comments on commit c691187

Please sign in to comment.