Skip to content

Commit 1d74e5f

Browse files
committed
Fix comments accordingly with golint advices
Refs to issue grafov#151.
1 parent c9a7424 commit 1d74e5f

File tree

5 files changed

+88
-69
lines changed

5 files changed

+88
-69
lines changed

doc.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
/* Package M3U8 is parser & generator library for Apple HLS.
1+
// Package m3u8 is parser & generator library for Apple HLS.
22

3-
This is a most complete opensource library for parsing and generating of M3U8 playlists used in HTTP Live Streaming (Apple HLS) for internet video translations.
3+
/* This is a most complete opensource library for parsing and
4+
generating of M3U8 playlists used in HTTP Live Streaming (Apple
5+
HLS) for internet video translations.
46
5-
M3U8 is simple text format and parsing library for it must be simple too. It did not offer ways to play HLS or handle playlists over HTTP. Library features are:
7+
M3U8 is simple text format and parsing library for it must be simple
8+
too. It did not offer ways to play HLS or handle playlists over
9+
HTTP. Library features are:
610
711
* Support HLS specs up to version 5 of the protocol.
812
* Parsing and generation of master-playlists and media-playlists.
@@ -11,11 +15,14 @@ M3U8 is simple text format and parsing library for it must be simple too. It did
1115
* Encryption keys support for usage with DRM systems like Verimatrix (http://verimatrix.com) etc.
1216
* Support for non standard Google Widevine (http://www.widevine.com) tags.
1317
14-
Library coded accordingly with IETF draft http://tools.ietf.org/html/draft-pantos-http-live-streaming
18+
Library coded accordingly with IETF draft
19+
http://tools.ietf.org/html/draft-pantos-http-live-streaming
1520
16-
Examples of usage may be found in *_test.go files of a package. Also see below some simple examples.
21+
Examples of usage may be found in *_test.go files of a package. Also
22+
see below some simple examples.
1723
18-
Create simple media playlist with sliding window of 3 segments and maximum of 50 segments.
24+
Create simple media playlist with sliding window of 3 segments and
25+
maximum of 50 segments.
1926
2027
p, e := NewMediaPlaylist(3, 50)
2128
if e != nil {
@@ -29,7 +36,8 @@ Create simple media playlist with sliding window of 3 segments and maximum of 50
2936
}
3037
fmt.Println(p.Encode(true).String())
3138
32-
We add 5 testX.ts segments to playlist then encode it to M3U8 format and convert to string.
39+
We add 5 testX.ts segments to playlist then encode it to M3U8 format
40+
and convert to string.
3341
3442
Next example shows parsing of master playlist:
3543
@@ -46,8 +54,8 @@ Next example shows parsing of master playlist:
4654
fmt.Printf("Playlist object: %+v\n", p)
4755
4856
We are open playlist from the file and parse it as master playlist.
49-
5057
*/
58+
5159
package m3u8
5260

5361
// Copyright 2013-2019 The Project Developers.

example/template/custom-playlist-tag-template.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,33 @@ import (
1010

1111
// #CUSTOM-PLAYLIST-TAG:<number>
1212

13-
// Implements both CustomTag and CustomDecoder interfaces
13+
// CustomPlaylistTag implements both CustomTag and CustomDecoder
14+
// interfaces.
1415
type CustomPlaylistTag struct {
1516
Number int
1617
}
1718

18-
// TagName() should return the full indentifier including the leading '#' and trailing ':'
19-
// if the tag also contains a value or attribute list
19+
// TagName should return the full indentifier including the leading
20+
// '#' and trailing ':' if the tag also contains a value or attribute
21+
// list.
2022
func (tag *CustomPlaylistTag) TagName() string {
2123
return "#CUSTOM-PLAYLIST-TAG:"
2224
}
2325

24-
// line will be the entire matched line, including the identifier
26+
// Decode decodes the input line. The line will be the entire matched
27+
// line, including the identifier
2528
func (tag *CustomPlaylistTag) Decode(line string) (m3u8.CustomTag, error) {
2629
_, err := fmt.Sscanf(line, "#CUSTOM-PLAYLIST-TAG:%d", &tag.Number)
2730

2831
return tag, err
2932
}
3033

31-
// This is a playlist tag example
34+
// SegmentTag is a playlist tag example.
3235
func (tag *CustomPlaylistTag) SegmentTag() bool {
3336
return false
3437
}
3538

39+
// Encode formats the structure to the text result.
3640
func (tag *CustomPlaylistTag) Encode() *bytes.Buffer {
3741
buf := new(bytes.Buffer)
3842

@@ -42,6 +46,7 @@ func (tag *CustomPlaylistTag) Encode() *bytes.Buffer {
4246
return buf
4347
}
4448

49+
// String implements Stringer interface.
4550
func (tag *CustomPlaylistTag) String() string {
4651
return tag.Encode().String()
4752
}

example/template/custom-segment-tag-template.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,21 @@ import (
99

1010
// #CUSTOM-SEGMENT-TAG:<attribute-list>
1111

12-
// Implements both CustomTag and CustomDecoder interfaces
12+
// CustomSegmentTag implements both CustomTag and CustomDecoder
13+
// interfaces.
1314
type CustomSegmentTag struct {
1415
Name string
1516
Jedi bool
1617
}
1718

18-
// TagName() should return the full indentifier including the leading '#' and trailing ':'
19+
// TagName should return the full indentifier including the leading '#' and trailing ':'
1920
// if the tag also contains a value or attribute list
2021
func (tag *CustomSegmentTag) TagName() string {
2122
return "#CUSTOM-SEGMENT-TAG:"
2223
}
2324

24-
// line will be the entire matched line, including the identifier
25+
// Decode decodes the input string to the internal structure. The line
26+
// will be the entire matched line, including the identifier.
2527
func (tag *CustomSegmentTag) Decode(line string) (m3u8.CustomTag, error) {
2628
var err error
2729

@@ -47,11 +49,12 @@ func (tag *CustomSegmentTag) Decode(line string) (m3u8.CustomTag, error) {
4749
return newTag, err
4850
}
4951

50-
// This is a playlist tag example
52+
// SegmentTag is a playlist tag example.
5153
func (tag *CustomSegmentTag) SegmentTag() bool {
5254
return true
5355
}
5456

57+
// Encode encodes the structure to the text result.
5558
func (tag *CustomSegmentTag) Encode() *bytes.Buffer {
5659
buf := new(bytes.Buffer)
5760

@@ -70,6 +73,7 @@ func (tag *CustomSegmentTag) Encode() *bytes.Buffer {
7073
return buf
7174
}
7275

76+
// String implements Stringer interface.
7377
func (tag *CustomSegmentTag) String() string {
7478
return tag.Encode().String()
7579
}

structure.go

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@ const (
3131
o The EXT-X-MEDIA tag.
3232
o The AUDIO and VIDEO attributes of the EXT-X-STREAM-INF tag.
3333
*/
34-
minver = uint8(3)
35-
DATETIME = time.RFC3339Nano // Format for EXT-X-PROGRAM-DATE-TIME defined in section 3.4.5
34+
minver = uint8(3)
35+
36+
// DATETIME represents format of the timestamps in encoded
37+
// playlists. Format for EXT-X-PROGRAM-DATE-TIME defined in
38+
// section 3.4.5
39+
DATETIME = time.RFC3339Nano
3640
)
3741

3842
// ListType is type of the playlist.
@@ -74,34 +78,33 @@ const (
7478
SCTE35Cue_End // SCTE35Cue_End indicates an in cue point
7579
)
7680

77-
/*
78-
MediaPlaylist structure represents a single bitrate playlist aka media playlist.
79-
It related to both a simple media playlists and a sliding window media playlists.
80-
URI lines in the Playlist point to media segments.
81-
82-
Simple Media Playlist file sample:
83-
84-
#EXTM3U
85-
#EXT-X-VERSION:3
86-
#EXT-X-TARGETDURATION:5220
87-
#EXTINF:5219.2,
88-
http://media.example.com/entire.ts
89-
#EXT-X-ENDLIST
90-
91-
Sample of Sliding Window Media Playlist, using HTTPS:
92-
93-
#EXTM3U
94-
#EXT-X-VERSION:3
95-
#EXT-X-TARGETDURATION:8
96-
#EXT-X-MEDIA-SEQUENCE:2680
97-
98-
#EXTINF:7.975,
99-
https://priv.example.com/fileSequence2680.ts
100-
#EXTINF:7.941,
101-
https://priv.example.com/fileSequence2681.ts
102-
#EXTINF:7.975,
103-
https://priv.example.com/fileSequence2682.ts
104-
*/
81+
// MediaPlaylist structure represents a single bitrate playlist aka
82+
// media playlist. It related to both a simple media playlists and a
83+
// sliding window media playlists. URI lines in the Playlist point to
84+
// media segments.
85+
//
86+
// Simple Media Playlist file sample:
87+
//
88+
// #EXTM3U
89+
// #EXT-X-VERSION:3
90+
// #EXT-X-TARGETDURATION:5220
91+
// #EXTINF:5219.2,
92+
// http://media.example.com/entire.ts
93+
// #EXT-X-ENDLIST
94+
//
95+
// Sample of Sliding Window Media Playlist, using HTTPS:
96+
//
97+
// #EXTM3U
98+
// #EXT-X-VERSION:3
99+
// #EXT-X-TARGETDURATION:8
100+
// #EXT-X-MEDIA-SEQUENCE:2680
101+
//
102+
// #EXTINF:7.975,
103+
// https://priv.example.com/fileSequence2680.ts
104+
// #EXTINF:7.941,
105+
// https://priv.example.com/fileSequence2681.ts
106+
// #EXTINF:7.975,
107+
// https://priv.example.com/fileSequence2682.ts
105108
type MediaPlaylist struct {
106109
TargetDuration float64
107110
SeqNo uint64 // EXT-X-MEDIA-SEQUENCE
@@ -129,21 +132,19 @@ type MediaPlaylist struct {
129132
customDecoders []CustomDecoder
130133
}
131134

132-
/*
133-
MasterPlaylist structure represents a master playlist which combines media playlists for multiple bitrates.
134-
URI lines in the playlist identify media playlists.
135-
Sample of Master Playlist file:
136-
137-
#EXTM3U
138-
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1280000
139-
http://example.com/low.m3u8
140-
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2560000
141-
http://example.com/mid.m3u8
142-
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=7680000
143-
http://example.com/hi.m3u8
144-
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=65000,CODECS="mp4a.40.5"
145-
http://example.com/audio-only.m3u8
146-
*/
135+
// MasterPlaylist structure represents a master playlist which
136+
// combines media playlists for multiple bitrates. URI lines in the
137+
// playlist identify media playlists. Sample of Master Playlist file:
138+
//
139+
// #EXTM3U
140+
// #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1280000
141+
// http://example.com/low.m3u8
142+
// #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2560000
143+
// http://example.com/mid.m3u8
144+
// #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=7680000
145+
// http://example.com/hi.m3u8
146+
// #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=65000,CODECS="mp4a.40.5"
147+
// http://example.com/audio-only.m3u8
147148
type MasterPlaylist struct {
148149
Variants []*Variant
149150
Args string // optional arguments placed after URI (URI?Args)
@@ -241,7 +242,7 @@ type Key struct {
241242
// Initialization Section required to parse the applicable
242243
// Media Segments.
243244
//
244-
// It applies to every Media Segment that appears after it in the
245+
// It applied to every Media Segment that appears after it in the
245246
// Playlist until the next EXT-X-MAP tag or until the end of the
246247
// playlist.
247248
//

writer.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ import (
2121
"time"
2222
)
2323

24-
var (
25-
ErrPlaylistFull = errors.New("playlist is full")
26-
)
24+
// ErrPlaylistFull declares the playlist error.
25+
var ErrPlaylistFull = errors.New("playlist is full")
2726

2827
// Set version of the playlist accordingly with section 7
2928
func version(ver *uint8, newver uint8) {
@@ -94,7 +93,7 @@ func (p *MasterPlaylist) Encode() *bytes.Buffer {
9493
}
9594
}
9695

97-
var altsWritten map[string]bool = make(map[string]bool)
96+
var altsWritten = make(map[string]bool)
9897

9998
for _, pl := range p.Variants {
10099
if pl.Alternatives != nil {
@@ -853,7 +852,8 @@ func (p *MediaPlaylist) SetProgramDateTime(value time.Time) error {
853852
return nil
854853
}
855854

856-
// SetCustomTag sets the provided tag on the media playlist for its TagName
855+
// SetCustomTag sets the provided tag on the media playlist for its
856+
// TagName.
857857
func (p *MediaPlaylist) SetCustomTag(tag CustomTag) {
858858
if p.Custom == nil {
859859
p.Custom = make(map[string]CustomTag)
@@ -862,7 +862,8 @@ func (p *MediaPlaylist) SetCustomTag(tag CustomTag) {
862862
p.Custom[tag.TagName()] = tag
863863
}
864864

865-
// SetCustomTag sets the provided tag on the current media segment for its TagName
865+
// SetCustomSegmentTag sets the provided tag on the current media
866+
// segment for its TagName.
866867
func (p *MediaPlaylist) SetCustomSegmentTag(tag CustomTag) error {
867868
if p.count == 0 {
868869
return errors.New("playlist is empty")

0 commit comments

Comments
 (0)