diff --git a/sample-playlists/master-playlist-with-discontinuity-and-maps.m3u8 b/sample-playlists/master-playlist-with-discontinuity-and-maps.m3u8 index 1648b162..88e64a62 100644 --- a/sample-playlists/master-playlist-with-discontinuity-and-maps.m3u8 +++ b/sample-playlists/master-playlist-with-discontinuity-and-maps.m3u8 @@ -1,18 +1,18 @@ #EXTM3U #EXT-X-VERSION:5 -#EXT-X-MAP:URI="https://example.com/content-init.mp4",BYTERANGE=1024000@1048576 +#EXT-X-MAP:URI="https://example.com/content-init.mp4",BYTERANGE="1024000@1048576" #EXT-X-MEDIA-SEQUENCE:0 #EXT-X-TARGETDURATION:6 #EXTINF:5.000, test01.mp4 #EXT-X-DISCONTINUITY -#EXT-X-MAP:URI="https://segmentencoded.com/ad-init.mp4",BYTERANGE=1024000@1048576 +#EXT-X-MAP:URI="https://segmentencoded.com/ad-init.mp4",BYTERANGE="1024000@1048576" #EXTINF:6.000, test02.mp4 #EXTINF:6.000, test03.mp4 #EXT-X-DISCONTINUITY -#EXT-X-MAP:URI="https://example.com/content-init.mp4",BYTERANGE=1024000@1048576 +#EXT-X-MAP:URI="https://example.com/content-init.mp4",BYTERANGE="1024000@1048576" #EXTINF:6.000, test04.mp4 #EXTINF:6.000, diff --git a/sample-playlists/master-playlist-with-maps.m3u8 b/sample-playlists/master-playlist-with-maps.m3u8 index 64a924b5..9197a619 100644 --- a/sample-playlists/master-playlist-with-maps.m3u8 +++ b/sample-playlists/master-playlist-with-maps.m3u8 @@ -1,6 +1,6 @@ #EXTM3U #EXT-X-VERSION:5 -#EXT-X-MAP:URI="https://example.com/content-init.mp4",BYTERANGE=1024000@1048576 +#EXT-X-MAP:URI="https://example.com/content-init.mp4",BYTERANGE="1024000@1048576" #EXT-X-MEDIA-SEQUENCE:0 #EXT-X-TARGETDURATION:6 #EXTINF:6.000, diff --git a/writer.go b/writer.go index 1c2cc998..33a3ae05 100644 --- a/writer.go +++ b/writer.go @@ -506,10 +506,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') } @@ -751,10 +752,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') } @@ -765,10 +767,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') } diff --git a/writer_test.go b/writer_test.go index 096ba7d8..7c2b004d 100644 --- a/writer_test.go +++ b/writer_test.go @@ -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()) } @@ -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) { @@ -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) } @@ -409,11 +409,11 @@ func TestEncodeMediaPlaylistWithDiscontinuityAndDefaultMap(t *testing.T) { } encoded := p.String() //fmt.Println(p.Encode().String()) - expectDefaultMap := `EXT-X-MAP:URI="https://example.com",BYTERANGE=1024000@1048576` + expectDefaultMap := `EXT-X-MAP:URI="https://example.com",BYTERANGE="1024000@1048576"` if !strings.Contains(encoded, expectDefaultMap) { t.Fatalf("Media playlist did not contain: %s\nMedia Playlist:\n%v", expectDefaultMap, encoded) } - expectSegmentMap := `EXT-X-MAP:URI="https://segmentencoded.com",BYTERANGE=1024000@1048576` + expectSegmentMap := `EXT-X-MAP:URI="https://segmentencoded.com",BYTERANGE="1024000@1048576"` if !strings.Contains(encoded, expectSegmentMap) { t.Fatalf("Media playlist did not contain: %s\nMedia Playlist:\n%v", expectSegmentMap, encoded) } @@ -449,11 +449,11 @@ func TestEncodeMediaPlaylistWithDiscontinuityAndDefaultMapWithAppendSegment(t *t } encoded := p.String() //fmt.Println(p.Encode().String()) - expectDefaultMap := `EXT-X-MAP:URI="https://example.com",BYTERANGE=1024000@1048576` + expectDefaultMap := `EXT-X-MAP:URI="https://example.com",BYTERANGE="1024000@1048576"` if !strings.Contains(encoded, expectDefaultMap) { t.Fatalf("Media playlist did not contain: %s\nMedia Playlist:\n%v", expectDefaultMap, encoded) } - expectSegmentMap := `EXT-X-MAP:URI="https://segmentencoded.com",BYTERANGE=1024000@1048576` + expectSegmentMap := `EXT-X-MAP:URI="https://segmentencoded.com",BYTERANGE="1024000@1048576"` if !strings.Contains(encoded, expectSegmentMap) { t.Fatalf("Media playlist did not contain: %s\nMedia Playlist:\n%v", expectSegmentMap, encoded) }