Skip to content
This repository has been archived by the owner on Dec 8, 2024. It is now read-only.

EXT-X-MEDIA CHANNELS #168

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func decode(buf *bytes.Buffer, strict bool, customDecoders []CustomDecoder) (Pla
wv := new(WV)

master = NewMasterPlaylist()
media, err = NewMediaPlaylist(8, 1024) // Winsize for VoD will become 0, capacity auto extends
media, err = NewMediaPlaylist(8, 8*1024) // Winsize for VoD will become 0, capacity auto extends
if err != nil {
return nil, 0, fmt.Errorf("Create media playlist failed: %s", err)
}
Expand Down
1 change: 1 addition & 0 deletions structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ type Alternative struct {
Language string
Name string
Default bool
Channels string
Autoselect string
Forced string
Characteristics string
Expand Down
13 changes: 9 additions & 4 deletions writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,17 @@ func (p *MasterPlaylist) Encode() *bytes.Buffer {
}
}

var altsWritten = make(map[string]bool)
var altsWritten = make(map[string]struct{})

for _, pl := range p.Variants {
if pl.Alternatives != nil {
for _, alt := range pl.Alternatives {
// Make sure that we only write out an alternative once
altKey := fmt.Sprintf("%s-%s-%s-%s", alt.Type, alt.GroupId, alt.Name, alt.Language)
if altsWritten[altKey] {
altKey := fmt.Sprintf("%s-%s-%s-%s-%s", alt.Type, alt.GroupId, alt.Name, alt.Language, alt.URI)
if _, alreadyWritten := altsWritten[altKey]; alreadyWritten {
continue
}
altsWritten[altKey] = true
altsWritten[altKey] = struct{}{}

p.buf.WriteString("#EXT-X-MEDIA:")
if alt.Type != "" {
Expand All @@ -126,6 +126,11 @@ func (p *MasterPlaylist) Encode() *bytes.Buffer {
} else {
p.buf.WriteString("NO")
}
if alt.Channels != "" {
p.buf.WriteString(",CHANNELS=\"")
p.buf.WriteString(alt.Channels)
p.buf.WriteRune('"')
}
if alt.Autoselect != "" {
p.buf.WriteString(",AUTOSELECT=")
p.buf.WriteString(alt.Autoselect)
Expand Down