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

EXT-X-MAP BYTERANGE should be quoted #159

Open
wants to merge 1 commit 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
EXT-X-MAP BYTERANGE should be quoted
  • Loading branch information
ronhopper committed Feb 19, 2020
commit 3119b161de3dd381746581580ced290a1914dc5f
6 changes: 4 additions & 2 deletions writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,10 +449,11 @@ func (p *MediaPlaylist) Encode() *bytes.Buffer {
p.buf.WriteString(p.Map.URI)
p.buf.WriteRune('"')
if p.Map.Limit > 0 {
p.buf.WriteString(",BYTERANGE=")
p.buf.WriteString(`,BYTERANGE="`)
p.buf.WriteString(strconv.FormatInt(p.Map.Limit, 10))
p.buf.WriteRune('@')
p.buf.WriteString(strconv.FormatInt(p.Map.Offset, 10))
p.buf.WriteRune('"')
}
p.buf.WriteRune('\n')
}
Expand Down Expand Up @@ -650,10 +651,11 @@ func (p *MediaPlaylist) Encode() *bytes.Buffer {
p.buf.WriteString(seg.Map.URI)
p.buf.WriteRune('"')
if seg.Map.Limit > 0 {
p.buf.WriteString(",BYTERANGE=")
p.buf.WriteString(`,BYTERANGE="`)
p.buf.WriteString(strconv.FormatInt(seg.Map.Limit, 10))
p.buf.WriteRune('@')
p.buf.WriteString(strconv.FormatInt(seg.Map.Offset, 10))
p.buf.WriteRune('"')
}
p.buf.WriteRune('\n')
}
Expand Down
6 changes: 3 additions & 3 deletions writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func TestSetDefaultMapForMediaPlaylist(t *testing.T) {
}
p.SetDefaultMap("https://example.com", 1000*1024, 1024*1024)

expected := `EXT-X-MAP:URI="https://example.com",BYTERANGE=1024000@1048576`
expected := `EXT-X-MAP:URI="https://example.com",BYTERANGE="1024000@1048576"`
if !strings.Contains(p.String(), expected) {
t.Fatalf("Media playlist did not contain: %s\nMedia Playlist:\n%v", expected, p.String())
}
Expand All @@ -338,7 +338,7 @@ func TestSetMapForMediaPlaylist(t *testing.T) {
t.Errorf("Set map to a media playlist failed: %s", e)
}

expected := `EXT-X-MAP:URI="https://example.com",BYTERANGE=1024000@1048576
expected := `EXT-X-MAP:URI="https://example.com",BYTERANGE="1024000@1048576"
#EXTINF:5.000,
test01.ts`
if !strings.Contains(p.String(), expected) {
Expand Down Expand Up @@ -367,7 +367,7 @@ func TestEncodeMediaPlaylistWithDefaultMap(t *testing.T) {
}

encoded := p.String()
expected := `EXT-X-MAP:URI="https://example.com",BYTERANGE=1024000@1048576`
expected := `EXT-X-MAP:URI="https://example.com",BYTERANGE="1024000@1048576"`
if !strings.Contains(encoded, expected) {
t.Fatalf("Media playlist did not contain: %s\nMedia Playlist:\n%v", expected, encoded)
}
Expand Down