Skip to content

Commit

Permalink
EXT-X-MAP BYTERANGE should be quoted
Browse files Browse the repository at this point in the history
  • Loading branch information
ronhopper committed Feb 19, 2020
1 parent 2ce07e6 commit 3119b16
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
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

0 comments on commit 3119b16

Please sign in to comment.