diff --git a/reader.go b/reader.go index 9deee4f0..84b6827c 100644 --- a/reader.go +++ b/reader.go @@ -315,7 +315,7 @@ func decodeLineOfMasterPlaylist(p *MasterPlaylist, state *decodingState, line st case "VIDEO-RANGE": state.variant.VideoRange = v case "HDCP-LEVEL": - state.variant.HCDPLevel = v + state.variant.HDCPLevel = v } } case state.tagStreamInf && !strings.HasPrefix(line, "#"): @@ -366,7 +366,7 @@ func decodeLineOfMasterPlaylist(p *MasterPlaylist, state *decodingState, line st case "VIDEO-RANGE": state.variant.VideoRange = v case "HDCP-LEVEL": - state.variant.HCDPLevel = v + state.variant.HDCPLevel = v } } case strings.HasPrefix(line, "#"): // unknown tags treated as comments diff --git a/reader_test.go b/reader_test.go index ab09c13d..885e7d28 100644 --- a/reader_test.go +++ b/reader_test.go @@ -245,24 +245,24 @@ func TestDecodeMasterWithHLSV7(t *testing.T) { } var unexpected []*Variant expected := map[string]VariantParams{ - "sdr_720/prog_index.m3u8": {Bandwidth: 3971374, AverageBandwidth: 2778321, Codecs: "hvc1.2.4.L123.B0", Resolution: "1280x720", Captions: "NONE", VideoRange: "SDR", HCDPLevel: "NONE", FrameRate: 23.976}, - "sdr_1080/prog_index.m3u8": {Bandwidth: 10022043, AverageBandwidth: 6759875, Codecs: "hvc1.2.4.L123.B0", Resolution: "1920x1080", Captions: "NONE", VideoRange: "SDR", HCDPLevel: "TYPE-0", FrameRate: 23.976}, - "sdr_2160/prog_index.m3u8": {Bandwidth: 28058971, AverageBandwidth: 20985770, Codecs: "hvc1.2.4.L150.B0", Resolution: "3840x2160", Captions: "NONE", VideoRange: "SDR", HCDPLevel: "TYPE-1", FrameRate: 23.976}, - "dolby_720/prog_index.m3u8": {Bandwidth: 5327059, AverageBandwidth: 3385450, Codecs: "dvh1.05.01", Resolution: "1280x720", Captions: "NONE", VideoRange: "PQ", HCDPLevel: "NONE", FrameRate: 23.976}, - "dolby_1080/prog_index.m3u8": {Bandwidth: 12876596, AverageBandwidth: 7999361, Codecs: "dvh1.05.03", Resolution: "1920x1080", Captions: "NONE", VideoRange: "PQ", HCDPLevel: "TYPE-0", FrameRate: 23.976}, - "dolby_2160/prog_index.m3u8": {Bandwidth: 30041698, AverageBandwidth: 24975091, Codecs: "dvh1.05.06", Resolution: "3840x2160", Captions: "NONE", VideoRange: "PQ", HCDPLevel: "TYPE-1", FrameRate: 23.976}, - "hdr10_720/prog_index.m3u8": {Bandwidth: 5280654, AverageBandwidth: 3320040, Codecs: "hvc1.2.4.L123.B0", Resolution: "1280x720", Captions: "NONE", VideoRange: "PQ", HCDPLevel: "NONE", FrameRate: 23.976}, - "hdr10_1080/prog_index.m3u8": {Bandwidth: 12886714, AverageBandwidth: 7964551, Codecs: "hvc1.2.4.L123.B0", Resolution: "1920x1080", Captions: "NONE", VideoRange: "PQ", HCDPLevel: "TYPE-0", FrameRate: 23.976}, - "hdr10_2160/prog_index.m3u8": {Bandwidth: 29983769, AverageBandwidth: 24833402, Codecs: "hvc1.2.4.L150.B0", Resolution: "3840x2160", Captions: "NONE", VideoRange: "PQ", HCDPLevel: "TYPE-1", FrameRate: 23.976}, - "sdr_720/iframe_index.m3u8": {Bandwidth: 593626, AverageBandwidth: 248586, Codecs: "hvc1.2.4.L123.B0", Resolution: "1280x720", Iframe: true, VideoRange: "SDR", HCDPLevel: "NONE"}, - "sdr_1080/iframe_index.m3u8": {Bandwidth: 956552, AverageBandwidth: 399790, Codecs: "hvc1.2.4.L123.B0", Resolution: "1920x1080", Iframe: true, VideoRange: "SDR", HCDPLevel: "TYPE-0"}, - "sdr_2160/iframe_index.m3u8": {Bandwidth: 1941397, AverageBandwidth: 826971, Codecs: "hvc1.2.4.L150.B0", Resolution: "3840x2160", Iframe: true, VideoRange: "SDR", HCDPLevel: "TYPE-1"}, - "dolby_720/iframe_index.m3u8": {Bandwidth: 573073, AverageBandwidth: 232253, Codecs: "dvh1.05.01", Resolution: "1280x720", Iframe: true, VideoRange: "PQ", HCDPLevel: "NONE"}, - "dolby_1080/iframe_index.m3u8": {Bandwidth: 905037, AverageBandwidth: 365337, Codecs: "dvh1.05.03", Resolution: "1920x1080", Iframe: true, VideoRange: "PQ", HCDPLevel: "TYPE-0"}, - "dolby_2160/iframe_index.m3u8": {Bandwidth: 1893236, AverageBandwidth: 739114, Codecs: "dvh1.05.06", Resolution: "3840x2160", Iframe: true, VideoRange: "PQ", HCDPLevel: "TYPE-1"}, - "hdr10_720/iframe_index.m3u8": {Bandwidth: 572673, AverageBandwidth: 232511, Codecs: "hvc1.2.4.L123.B0", Resolution: "1280x720", Iframe: true, VideoRange: "PQ", HCDPLevel: "NONE"}, - "hdr10_1080/iframe_index.m3u8": {Bandwidth: 905053, AverageBandwidth: 364552, Codecs: "hvc1.2.4.L123.B0", Resolution: "1920x1080", Iframe: true, VideoRange: "PQ", HCDPLevel: "TYPE-0"}, - "hdr10_2160/iframe_index.m3u8": {Bandwidth: 1895477, AverageBandwidth: 739757, Codecs: "hvc1.2.4.L150.B0", Resolution: "3840x2160", Iframe: true, VideoRange: "PQ", HCDPLevel: "TYPE-1"}, + "sdr_720/prog_index.m3u8": {Bandwidth: 3971374, AverageBandwidth: 2778321, Codecs: "hvc1.2.4.L123.B0", Resolution: "1280x720", Captions: "NONE", VideoRange: "SDR", HDCPLevel: "NONE", FrameRate: 23.976}, + "sdr_1080/prog_index.m3u8": {Bandwidth: 10022043, AverageBandwidth: 6759875, Codecs: "hvc1.2.4.L123.B0", Resolution: "1920x1080", Captions: "NONE", VideoRange: "SDR", HDCPLevel: "TYPE-0", FrameRate: 23.976}, + "sdr_2160/prog_index.m3u8": {Bandwidth: 28058971, AverageBandwidth: 20985770, Codecs: "hvc1.2.4.L150.B0", Resolution: "3840x2160", Captions: "NONE", VideoRange: "SDR", HDCPLevel: "TYPE-1", FrameRate: 23.976}, + "dolby_720/prog_index.m3u8": {Bandwidth: 5327059, AverageBandwidth: 3385450, Codecs: "dvh1.05.01", Resolution: "1280x720", Captions: "NONE", VideoRange: "PQ", HDCPLevel: "NONE", FrameRate: 23.976}, + "dolby_1080/prog_index.m3u8": {Bandwidth: 12876596, AverageBandwidth: 7999361, Codecs: "dvh1.05.03", Resolution: "1920x1080", Captions: "NONE", VideoRange: "PQ", HDCPLevel: "TYPE-0", FrameRate: 23.976}, + "dolby_2160/prog_index.m3u8": {Bandwidth: 30041698, AverageBandwidth: 24975091, Codecs: "dvh1.05.06", Resolution: "3840x2160", Captions: "NONE", VideoRange: "PQ", HDCPLevel: "TYPE-1", FrameRate: 23.976}, + "hdr10_720/prog_index.m3u8": {Bandwidth: 5280654, AverageBandwidth: 3320040, Codecs: "hvc1.2.4.L123.B0", Resolution: "1280x720", Captions: "NONE", VideoRange: "PQ", HDCPLevel: "NONE", FrameRate: 23.976}, + "hdr10_1080/prog_index.m3u8": {Bandwidth: 12886714, AverageBandwidth: 7964551, Codecs: "hvc1.2.4.L123.B0", Resolution: "1920x1080", Captions: "NONE", VideoRange: "PQ", HDCPLevel: "TYPE-0", FrameRate: 23.976}, + "hdr10_2160/prog_index.m3u8": {Bandwidth: 29983769, AverageBandwidth: 24833402, Codecs: "hvc1.2.4.L150.B0", Resolution: "3840x2160", Captions: "NONE", VideoRange: "PQ", HDCPLevel: "TYPE-1", FrameRate: 23.976}, + "sdr_720/iframe_index.m3u8": {Bandwidth: 593626, AverageBandwidth: 248586, Codecs: "hvc1.2.4.L123.B0", Resolution: "1280x720", Iframe: true, VideoRange: "SDR", HDCPLevel: "NONE"}, + "sdr_1080/iframe_index.m3u8": {Bandwidth: 956552, AverageBandwidth: 399790, Codecs: "hvc1.2.4.L123.B0", Resolution: "1920x1080", Iframe: true, VideoRange: "SDR", HDCPLevel: "TYPE-0"}, + "sdr_2160/iframe_index.m3u8": {Bandwidth: 1941397, AverageBandwidth: 826971, Codecs: "hvc1.2.4.L150.B0", Resolution: "3840x2160", Iframe: true, VideoRange: "SDR", HDCPLevel: "TYPE-1"}, + "dolby_720/iframe_index.m3u8": {Bandwidth: 573073, AverageBandwidth: 232253, Codecs: "dvh1.05.01", Resolution: "1280x720", Iframe: true, VideoRange: "PQ", HDCPLevel: "NONE"}, + "dolby_1080/iframe_index.m3u8": {Bandwidth: 905037, AverageBandwidth: 365337, Codecs: "dvh1.05.03", Resolution: "1920x1080", Iframe: true, VideoRange: "PQ", HDCPLevel: "TYPE-0"}, + "dolby_2160/iframe_index.m3u8": {Bandwidth: 1893236, AverageBandwidth: 739114, Codecs: "dvh1.05.06", Resolution: "3840x2160", Iframe: true, VideoRange: "PQ", HDCPLevel: "TYPE-1"}, + "hdr10_720/iframe_index.m3u8": {Bandwidth: 572673, AverageBandwidth: 232511, Codecs: "hvc1.2.4.L123.B0", Resolution: "1280x720", Iframe: true, VideoRange: "PQ", HDCPLevel: "NONE"}, + "hdr10_1080/iframe_index.m3u8": {Bandwidth: 905053, AverageBandwidth: 364552, Codecs: "hvc1.2.4.L123.B0", Resolution: "1920x1080", Iframe: true, VideoRange: "PQ", HDCPLevel: "TYPE-0"}, + "hdr10_2160/iframe_index.m3u8": {Bandwidth: 1895477, AverageBandwidth: 739757, Codecs: "hvc1.2.4.L150.B0", Resolution: "3840x2160", Iframe: true, VideoRange: "PQ", HDCPLevel: "TYPE-1"}, } for _, variant := range p.Variants { var found bool diff --git a/structure.go b/structure.go index 2a40ffb7..cedbbd0d 100644 --- a/structure.go +++ b/structure.go @@ -171,7 +171,7 @@ type VariantParams struct { Name string // EXT-X-STREAM-INF only (non standard Wowza/JWPlayer extension to name the variant/quality in UA) Iframe bool // EXT-X-I-FRAME-STREAM-INF VideoRange string - HCDPLevel string + HDCPLevel string FrameRate float64 // EXT-X-STREAM-INF Alternatives []*Alternative // EXT-X-MEDIA } diff --git a/writer.go b/writer.go index 01e9574d..dd796df0 100644 --- a/writer.go +++ b/writer.go @@ -175,9 +175,9 @@ func (p *MasterPlaylist) Encode() *bytes.Buffer { p.buf.WriteString(",VIDEO-RANGE=") p.buf.WriteString(pl.VideoRange) } - if pl.HCDPLevel != "" { + if pl.HDCPLevel != "" { p.buf.WriteString(",HDCP-LEVEL=") - p.buf.WriteString(pl.HCDPLevel) + p.buf.WriteString(pl.HDCPLevel) } if pl.URI != "" { p.buf.WriteString(",URI=\"") @@ -241,9 +241,9 @@ func (p *MasterPlaylist) Encode() *bytes.Buffer { p.buf.WriteString(",VIDEO-RANGE=") p.buf.WriteString(pl.VideoRange) } - if pl.HCDPLevel != "" { + if pl.HDCPLevel != "" { p.buf.WriteString(",HDCP-LEVEL=") - p.buf.WriteString(pl.HCDPLevel) + p.buf.WriteString(pl.HDCPLevel) } p.buf.WriteRune('\n') diff --git a/writer_test.go b/writer_test.go index 350d6b90..8a9410bc 100644 --- a/writer_test.go +++ b/writer_test.go @@ -944,8 +944,8 @@ func ExampleMasterPlaylist_String_with_hlsv7() { m.SetVersion(7) m.SetIndependentSegments(true) p, _ := NewMediaPlaylist(3, 5) - m.Append("hdr10_1080/prog_index.m3u8", p, VariantParams{AverageBandwidth: 7964551, Bandwidth: 12886714, VideoRange: "PQ", Codecs: "hvc1.2.4.L123.B0", Resolution: "1920x1080", FrameRate: 23.976, Captions: "NONE", HCDPLevel: "TYPE-0"}) - m.Append("hdr10_1080/iframe_index.m3u8", p, VariantParams{Iframe: true, AverageBandwidth: 364552, Bandwidth: 905053, VideoRange: "PQ", Codecs: "hvc1.2.4.L123.B0", Resolution: "1920x1080", HCDPLevel: "TYPE-0"}) + m.Append("hdr10_1080/prog_index.m3u8", p, VariantParams{AverageBandwidth: 7964551, Bandwidth: 12886714, VideoRange: "PQ", Codecs: "hvc1.2.4.L123.B0", Resolution: "1920x1080", FrameRate: 23.976, Captions: "NONE", HDCPLevel: "TYPE-0"}) + m.Append("hdr10_1080/iframe_index.m3u8", p, VariantParams{Iframe: true, AverageBandwidth: 364552, Bandwidth: 905053, VideoRange: "PQ", Codecs: "hvc1.2.4.L123.B0", Resolution: "1920x1080", HDCPLevel: "TYPE-0"}) fmt.Printf("%s", m) // Output: // #EXTM3U