m3u8 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile +1 -0
- data/Guardfile +1 -0
- data/Rakefile +1 -0
- data/lib/m3u8.rb +6 -1
- data/lib/m3u8/byte_range.rb +1 -0
- data/lib/m3u8/date_range_item.rb +113 -0
- data/lib/m3u8/discontinuity_item.rb +1 -3
- data/lib/m3u8/encryptable.rb +1 -0
- data/lib/m3u8/error.rb +1 -0
- data/lib/m3u8/key_item.rb +1 -0
- data/lib/m3u8/map_item.rb +1 -0
- data/lib/m3u8/media_item.rb +1 -0
- data/lib/m3u8/playback_start.rb +1 -0
- data/lib/m3u8/playlist.rb +1 -0
- data/lib/m3u8/playlist_item.rb +12 -18
- data/lib/m3u8/reader.rb +17 -9
- data/lib/m3u8/segment_item.rb +1 -0
- data/lib/m3u8/session_data_item.rb +1 -0
- data/lib/m3u8/session_key_item.rb +1 -0
- data/lib/m3u8/time_item.rb +1 -0
- data/lib/m3u8/version.rb +2 -1
- data/lib/m3u8/writer.rb +1 -0
- data/spec/fixtures/date_range_scte35.m3u8 +16 -0
- data/spec/lib/m3u8/byte_range_spec.rb +1 -0
- data/spec/lib/m3u8/date_range_item_spec.rb +124 -0
- data/spec/lib/m3u8/discontinuity_item_spec.rb +1 -0
- data/spec/lib/m3u8/key_item_spec.rb +1 -0
- data/spec/lib/m3u8/map_item_spec.rb +2 -5
- data/spec/lib/m3u8/media_item_spec.rb +1 -0
- data/spec/lib/m3u8/playback_start_spec.rb +1 -0
- data/spec/lib/m3u8/playlist_item_spec.rb +1 -0
- data/spec/lib/m3u8/playlist_spec.rb +1 -0
- data/spec/lib/m3u8/reader_spec.rb +254 -236
- data/spec/lib/m3u8/segment_item_spec.rb +4 -14
- data/spec/lib/m3u8/session_data_item_spec.rb +1 -0
- data/spec/lib/m3u8/session_key_item_spec.rb +1 -0
- data/spec/lib/m3u8/time_item_spec.rb +1 -0
- data/spec/lib/m3u8/writer_spec.rb +174 -171
- data/spec/lib/m3u8_spec.rb +1 -0
- data/spec/spec_helper.rb +1 -0
- metadata +8 -3
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
describe M3u8::SegmentItem do
|
@@ -11,11 +12,7 @@ describe M3u8::SegmentItem do
|
|
11
12
|
expect(item.program_date_time).to be_nil
|
12
13
|
|
13
14
|
hash = { duration: 10.991, segment: 'test.ts', comment: 'anything',
|
14
|
-
byterange: {
|
15
|
-
length: 4500,
|
16
|
-
start: 600
|
17
|
-
}
|
18
|
-
}
|
15
|
+
byterange: { length: 4500, start: 600 } }
|
19
16
|
item = M3u8::SegmentItem.new(hash)
|
20
17
|
expect(item.duration).to eq 10.991
|
21
18
|
expect(item.byterange.length).to eq 4500
|
@@ -43,21 +40,14 @@ describe M3u8::SegmentItem do
|
|
43
40
|
expect(output).to eq expected
|
44
41
|
|
45
42
|
hash = { duration: 10.991, segment: 'test.ts', comment: 'anything',
|
46
|
-
byterange: {
|
47
|
-
length: 4500,
|
48
|
-
start: 600
|
49
|
-
}
|
50
|
-
}
|
43
|
+
byterange: { length: 4500, start: 600 } }
|
51
44
|
item = M3u8::SegmentItem.new(hash)
|
52
45
|
output = item.to_s
|
53
46
|
expected = "#EXTINF:10.991,anything\n#EXT-X-BYTERANGE:4500@600\ntest.ts"
|
54
47
|
expect(output).to eq expected
|
55
48
|
|
56
49
|
hash = { duration: 10.991, segment: 'test.ts', comment: 'anything',
|
57
|
-
byterange: {
|
58
|
-
length: 4500
|
59
|
-
}
|
60
|
-
}
|
50
|
+
byterange: { length: 4500 } }
|
61
51
|
item = M3u8::SegmentItem.new(hash)
|
62
52
|
output = item.to_s
|
63
53
|
expected = "#EXTINF:10.991,anything\n#EXT-X-BYTERANGE:4500\ntest.ts"
|
@@ -1,176 +1,179 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
describe M3u8::Writer do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
"#
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
"#
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
.
|
5
|
+
describe '#write' do
|
6
|
+
it 'should render master playlist' do
|
7
|
+
options = { uri: 'playlist_url', bandwidth: 6400,
|
8
|
+
audio_codec: 'mp3' }
|
9
|
+
item = M3u8::PlaylistItem.new(options)
|
10
|
+
playlist = M3u8::Playlist.new(version: 6, independent_segments: true)
|
11
|
+
playlist.items << item
|
12
|
+
|
13
|
+
output = "#EXTM3U\n" \
|
14
|
+
"#EXT-X-VERSION:6\n" \
|
15
|
+
"#EXT-X-INDEPENDENT-SEGMENTS\n" +
|
16
|
+
%(#EXT-X-STREAM-INF:CODECS="mp4a.40.34") +
|
17
|
+
",BANDWIDTH=6400\nplaylist_url\n"
|
18
|
+
|
19
|
+
io = StringIO.open
|
20
|
+
writer = M3u8::Writer.new(io)
|
21
|
+
writer.write(playlist)
|
22
|
+
expect(io.string).to eq(output)
|
23
|
+
|
24
|
+
options = { program_id: '1', uri: 'playlist_url', bandwidth: 6400,
|
25
|
+
audio_codec: 'mp3' }
|
26
|
+
item = M3u8::PlaylistItem.new(options)
|
27
|
+
playlist = M3u8::Playlist.new
|
28
|
+
playlist.items << item
|
29
|
+
|
30
|
+
output = "#EXTM3U\n" +
|
31
|
+
%(#EXT-X-STREAM-INF:PROGRAM-ID=1,CODECS="mp4a.40.34") +
|
32
|
+
",BANDWIDTH=6400\nplaylist_url\n"
|
33
|
+
|
34
|
+
io = StringIO.open
|
35
|
+
writer = M3u8::Writer.new(io)
|
36
|
+
writer.write(playlist)
|
37
|
+
expect(io.string).to eq(output)
|
38
|
+
|
39
|
+
options = { program_id: '2', uri: 'playlist_url', bandwidth: 50_000,
|
40
|
+
width: 1920, height: 1080, profile: 'high', level: 4.1,
|
41
|
+
audio_codec: 'aac-lc' }
|
42
|
+
item = M3u8::PlaylistItem.new(options)
|
43
|
+
playlist = M3u8::Playlist.new
|
44
|
+
playlist.items << item
|
45
|
+
|
46
|
+
output = "#EXTM3U\n" \
|
47
|
+
'#EXT-X-STREAM-INF:PROGRAM-ID=2,RESOLUTION=1920x1080,' +
|
48
|
+
%(CODECS="avc1.640029,mp4a.40.2",BANDWIDTH=50000\n) +
|
49
|
+
"playlist_url\n"
|
50
|
+
|
51
|
+
io = StringIO.open
|
52
|
+
writer = M3u8::Writer.new(io)
|
53
|
+
writer.write(playlist)
|
54
|
+
expect(io.string).to eq(output)
|
55
|
+
|
56
|
+
playlist = M3u8::Playlist.new
|
57
|
+
options = { program_id: '1', uri: 'playlist_url', bandwidth: 6400,
|
58
|
+
audio_codec: 'mp3' }
|
59
|
+
item = M3u8::PlaylistItem.new(options)
|
60
|
+
playlist.items << item
|
61
|
+
options = { program_id: '2', uri: 'playlist_url', bandwidth: 50_000,
|
62
|
+
width: 1920, height: 1080, profile: 'high', level: 4.1,
|
63
|
+
audio_codec: 'aac-lc' }
|
64
|
+
item = M3u8::PlaylistItem.new(options)
|
65
|
+
playlist.items << item
|
66
|
+
options = { data_id: 'com.test.movie.title', value: 'Test',
|
67
|
+
uri: 'http://test', language: 'en' }
|
68
|
+
item = M3u8::SessionDataItem.new(options)
|
69
|
+
playlist.items << item
|
70
|
+
|
71
|
+
output = "#EXTM3U\n" +
|
72
|
+
%(#EXT-X-STREAM-INF:PROGRAM-ID=1,CODECS="mp4a.40.34") +
|
73
|
+
",BANDWIDTH=6400\nplaylist_url\n#EXT-X-STREAM-INF:PROGRAM-ID=2," +
|
74
|
+
%(RESOLUTION=1920x1080,CODECS="avc1.640029,mp4a.40.2") +
|
75
|
+
",BANDWIDTH=50000\nplaylist_url\n" +
|
76
|
+
%(#EXT-X-SESSION-DATA:DATA-ID="com.test.movie.title",) +
|
77
|
+
%(VALUE="Test",URI="http://test",LANGUAGE="en"\n)
|
78
|
+
|
79
|
+
io = StringIO.open
|
80
|
+
writer = M3u8::Writer.new(io)
|
81
|
+
writer.write(playlist)
|
82
|
+
expect(io.string).to eq(output)
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'should render playlist' do
|
86
|
+
options = { duration: 11.344644, segment: '1080-7mbps00000.ts' }
|
87
|
+
item = M3u8::SegmentItem.new(options)
|
88
|
+
playlist = M3u8::Playlist.new(version: 7)
|
89
|
+
playlist.items << item
|
90
|
+
|
91
|
+
output = "#EXTM3U\n" \
|
92
|
+
"#EXT-X-VERSION:7\n" \
|
93
|
+
"#EXT-X-MEDIA-SEQUENCE:0\n" \
|
94
|
+
"#EXT-X-TARGETDURATION:10\n" \
|
95
|
+
"#EXTINF:11.344644,\n" \
|
96
|
+
"1080-7mbps00000.ts\n" \
|
97
|
+
"#EXT-X-ENDLIST\n"
|
98
|
+
io = StringIO.open
|
99
|
+
writer = M3u8::Writer.new(io)
|
100
|
+
writer.write(playlist)
|
101
|
+
expect(io.string).to eq(output)
|
102
|
+
|
103
|
+
options = { method: 'AES-128', uri: 'http://test.key',
|
104
|
+
iv: 'D512BBF', key_format: 'identity',
|
105
|
+
key_format_versions: '1/3' }
|
106
|
+
item = M3u8::KeyItem.new(options)
|
107
|
+
playlist.items << item
|
108
|
+
|
109
|
+
options = { duration: 11.261233, segment: '1080-7mbps00001.ts' }
|
110
|
+
item = M3u8::SegmentItem.new(options)
|
111
|
+
playlist.items << item
|
112
|
+
|
113
|
+
output = "#EXTM3U\n" \
|
114
|
+
"#EXT-X-VERSION:7\n" \
|
115
|
+
"#EXT-X-MEDIA-SEQUENCE:0\n" \
|
116
|
+
"#EXT-X-TARGETDURATION:10\n" \
|
117
|
+
"#EXTINF:11.344644,\n" \
|
118
|
+
"1080-7mbps00000.ts\n" +
|
119
|
+
%(#EXT-X-KEY:METHOD=AES-128,URI="http://test.key",) +
|
120
|
+
%(IV=D512BBF,KEYFORMAT="identity",KEYFORMATVERSIONS="1/3"\n) +
|
121
|
+
"#EXTINF:11.261233,\n" \
|
122
|
+
"1080-7mbps00001.ts\n" \
|
123
|
+
"#EXT-X-ENDLIST\n"
|
124
|
+
io = StringIO.open
|
125
|
+
writer = M3u8::Writer.new(io)
|
126
|
+
writer.write(playlist)
|
127
|
+
expect(io.string).to eq(output)
|
128
|
+
|
129
|
+
options = { version: 4, cache: false, target: 12, sequence: 1,
|
130
|
+
type: 'EVENT', iframes_only: true }
|
131
|
+
playlist = M3u8::Playlist.new(options)
|
132
|
+
options = { duration: 11.344644, segment: '1080-7mbps00000.ts' }
|
133
|
+
item = M3u8::SegmentItem.new(options)
|
134
|
+
playlist.items << item
|
135
|
+
|
136
|
+
output = "#EXTM3U\n" \
|
137
|
+
"#EXT-X-PLAYLIST-TYPE:EVENT\n" \
|
138
|
+
"#EXT-X-VERSION:4\n" \
|
139
|
+
"#EXT-X-I-FRAMES-ONLY\n" \
|
140
|
+
"#EXT-X-MEDIA-SEQUENCE:1\n" \
|
141
|
+
"#EXT-X-ALLOW-CACHE:NO\n" \
|
142
|
+
"#EXT-X-TARGETDURATION:12\n" \
|
143
|
+
"#EXTINF:11.344644,\n" \
|
144
|
+
"1080-7mbps00000.ts\n" \
|
145
|
+
"#EXT-X-ENDLIST\n"
|
146
|
+
io = StringIO.open
|
147
|
+
writer = M3u8::Writer.new(io)
|
148
|
+
writer.write(playlist)
|
149
|
+
expect(io.string).to eq(output)
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'should render the target duration as a decimal-integer' do
|
153
|
+
playlist = M3u8::Playlist.new(target: 6.2)
|
154
|
+
io = StringIO.open
|
155
|
+
writer = M3u8::Writer.new(io)
|
156
|
+
writer.write(playlist)
|
157
|
+
expect(io.string).to include('#EXT-X-TARGETDURATION:6')
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'should raise error on write if item types are mixed' do
|
161
|
+
playlist = M3u8::Playlist.new
|
162
|
+
|
163
|
+
hash = { program_id: 1, width: 1920, height: 1080, codecs: 'avc',
|
164
|
+
bandwidth: 540, playlist: 'test.url' }
|
165
|
+
item = M3u8::PlaylistItem.new(hash)
|
166
|
+
playlist.items << item
|
167
|
+
|
168
|
+
hash = { duration: 10.991, segment: 'test.ts' }
|
169
|
+
item = M3u8::SegmentItem.new(hash)
|
170
|
+
playlist.items << item
|
171
|
+
|
172
|
+
message = 'Playlist is invalid.'
|
173
|
+
io = StringIO.new
|
174
|
+
writer = M3u8::Writer.new(io)
|
175
|
+
expect { writer.write(playlist) }
|
176
|
+
.to raise_error(M3u8::PlaylistTypeError, message)
|
177
|
+
end
|
175
178
|
end
|
176
179
|
end
|
data/spec/lib/m3u8_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: m3u8
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seth Deckard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -128,6 +128,7 @@ files:
|
|
128
128
|
- Rakefile
|
129
129
|
- lib/m3u8.rb
|
130
130
|
- lib/m3u8/byte_range.rb
|
131
|
+
- lib/m3u8/date_range_item.rb
|
131
132
|
- lib/m3u8/discontinuity_item.rb
|
132
133
|
- lib/m3u8/encryptable.rb
|
133
134
|
- lib/m3u8/error.rb
|
@@ -145,6 +146,7 @@ files:
|
|
145
146
|
- lib/m3u8/version.rb
|
146
147
|
- lib/m3u8/writer.rb
|
147
148
|
- m3u8.gemspec
|
149
|
+
- spec/fixtures/date_range_scte35.m3u8
|
148
150
|
- spec/fixtures/encrypted.m3u8
|
149
151
|
- spec/fixtures/iframes.m3u8
|
150
152
|
- spec/fixtures/map_playlist.m3u8
|
@@ -157,6 +159,7 @@ files:
|
|
157
159
|
- spec/fixtures/variant_angles.m3u8
|
158
160
|
- spec/fixtures/variant_audio.m3u8
|
159
161
|
- spec/lib/m3u8/byte_range_spec.rb
|
162
|
+
- spec/lib/m3u8/date_range_item_spec.rb
|
160
163
|
- spec/lib/m3u8/discontinuity_item_spec.rb
|
161
164
|
- spec/lib/m3u8/key_item_spec.rb
|
162
165
|
- spec/lib/m3u8/map_item_spec.rb
|
@@ -192,11 +195,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
195
|
version: '0'
|
193
196
|
requirements: []
|
194
197
|
rubyforge_project:
|
195
|
-
rubygems_version: 2.
|
198
|
+
rubygems_version: 2.5.2
|
196
199
|
signing_key:
|
197
200
|
specification_version: 4
|
198
201
|
summary: Generate and parse m3u8 playlists for HTTP Live Streaming (HLS).
|
199
202
|
test_files:
|
203
|
+
- spec/fixtures/date_range_scte35.m3u8
|
200
204
|
- spec/fixtures/encrypted.m3u8
|
201
205
|
- spec/fixtures/iframes.m3u8
|
202
206
|
- spec/fixtures/map_playlist.m3u8
|
@@ -209,6 +213,7 @@ test_files:
|
|
209
213
|
- spec/fixtures/variant_angles.m3u8
|
210
214
|
- spec/fixtures/variant_audio.m3u8
|
211
215
|
- spec/lib/m3u8/byte_range_spec.rb
|
216
|
+
- spec/lib/m3u8/date_range_item_spec.rb
|
212
217
|
- spec/lib/m3u8/discontinuity_item_spec.rb
|
213
218
|
- spec/lib/m3u8/key_item_spec.rb
|
214
219
|
- spec/lib/m3u8/map_item_spec.rb
|