m3u8 0.6.4 → 0.6.5
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 +3 -1
- data/lib/m3u8/playlist_item.rb +29 -19
- data/lib/m3u8/version.rb +1 -1
- data/spec/lib/m3u8/playlist_item_spec.rb +43 -34
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9771b4d74b91d96ee4c6eca99cce96fb16705233
|
4
|
+
data.tar.gz: 39dca18b7625bcceedb21f1dab3aa8363a773a17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79a97144562036dccad8cd96e4c753890a6616920707a617e50b84e2d6ec5c7f1648be6bfa1d34508446bda93f5b510ba0d98680caebdc325f233e917b6a2c3f
|
7
|
+
data.tar.gz: 81d6de6a6162f2820da6d2d0e652ae0b1917177214203530ccc5004eb56382b5e69249781a79add1dfa8949599a4b9e1dafaacb181ed90a59411be458c97d228
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
#### 0.6.
|
1
|
+
#### 0.6.5 (3/18/2016) - Merged pull requests #11 from [jviney](https://github.com/jviney). Adds codec string for main profile level 4.1.
|
2
|
+
|
3
|
+
#### 0.6.4 (2/21/2016) - Merged pull requests #8, #9, and #10 from [jviney](https://github.com/jviney). Adds FRAME-RATE attribute to PlayListItem, fixes NONE option for CLOSED-CAPTIONS attribute.
|
2
4
|
|
3
5
|
#### 0.6.3 (2/17/2016) - Merged pull request #7 from [jviney](https://github.com/jviney), fixing bug with require order.
|
4
6
|
|
data/lib/m3u8/playlist_item.rb
CHANGED
@@ -2,7 +2,7 @@ module M3u8
|
|
2
2
|
# PlaylistItem represents a set of EXT-X-STREAM-INF or
|
3
3
|
# EXT-X-I-FRAME-STREAM-INF attributes
|
4
4
|
class PlaylistItem
|
5
|
-
|
5
|
+
include M3u8
|
6
6
|
attr_accessor :program_id, :width, :height, :codecs, :bandwidth,
|
7
7
|
:audio_codec, :level, :profile, :video, :audio, :uri,
|
8
8
|
:average_bandwidth, :subtitles, :closed_captions, :iframe,
|
@@ -17,21 +17,15 @@ module M3u8
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.parse(text)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
average_bandwidth: average,
|
30
|
-
frame_rate: frame_rate,
|
31
|
-
video: attributes['VIDEO'], audio: attributes['AUDIO'],
|
32
|
-
uri: attributes['URI'], subtitles: attributes['SUBTITLES'],
|
33
|
-
closed_captions: attributes['CLOSED-CAPTIONS'] }
|
34
|
-
PlaylistItem.new options
|
20
|
+
item = PlaylistItem.new
|
21
|
+
item.parse(text)
|
22
|
+
item
|
23
|
+
end
|
24
|
+
|
25
|
+
def parse(text)
|
26
|
+
attributes = parse_attributes(text)
|
27
|
+
options = options_from_attributes(attributes)
|
28
|
+
initialize(options)
|
35
29
|
end
|
36
30
|
|
37
31
|
def resolution
|
@@ -63,11 +57,26 @@ module M3u8
|
|
63
57
|
|
64
58
|
private
|
65
59
|
|
66
|
-
def
|
60
|
+
def options_from_attributes(attributes)
|
61
|
+
resolution = parse_resolution(attributes['RESOLUTION'])
|
62
|
+
{ program_id: attributes['PROGRAM-ID'],
|
63
|
+
codecs: attributes['CODECS'],
|
64
|
+
width: resolution[:width],
|
65
|
+
height: resolution[:height],
|
66
|
+
bandwidth: attributes['BANDWIDTH'].to_i,
|
67
|
+
average_bandwidth:
|
68
|
+
parse_average_bandwidth(attributes['AVERAGE-BANDWIDTH']),
|
69
|
+
frame_rate: parse_frame_rate(attributes['FRAME-RATE']),
|
70
|
+
video: attributes['VIDEO'], audio: attributes['AUDIO'],
|
71
|
+
uri: attributes['URI'], subtitles: attributes['SUBTITLES'],
|
72
|
+
closed_captions: attributes['CLOSED-CAPTIONS'] }
|
73
|
+
end
|
74
|
+
|
75
|
+
def parse_average_bandwidth(value)
|
67
76
|
value.to_i unless value.nil?
|
68
77
|
end
|
69
78
|
|
70
|
-
def
|
79
|
+
def parse_resolution(resolution)
|
71
80
|
return { width: nil, height: nil } if resolution.nil?
|
72
81
|
|
73
82
|
values = resolution.split('x')
|
@@ -76,7 +85,7 @@ module M3u8
|
|
76
85
|
{ width: width, height: height }
|
77
86
|
end
|
78
87
|
|
79
|
-
def
|
88
|
+
def parse_frame_rate(frame_rate)
|
80
89
|
return if frame_rate.nil?
|
81
90
|
|
82
91
|
value = BigDecimal(frame_rate)
|
@@ -184,6 +193,7 @@ module M3u8
|
|
184
193
|
return 'avc1.77.30' if level == 3.0
|
185
194
|
return 'avc1.4d001f' if level == 3.1
|
186
195
|
return 'avc1.4d0028' if level == 4.0
|
196
|
+
return 'avc1.4d0029' if level == 4.1
|
187
197
|
end
|
188
198
|
|
189
199
|
def high_codec_string(level)
|
data/lib/m3u8/version.rb
CHANGED
@@ -15,40 +15,45 @@ describe M3u8::PlaylistItem do
|
|
15
15
|
expect(item.iframe).to be false
|
16
16
|
end
|
17
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
|
-
|
18
|
+
describe 'parse' do
|
19
|
+
it 'should parse m3u8 text into instance' do
|
20
|
+
input = %(#EXT-X-STREAM-INF:CODECS="avc",BANDWIDTH=540,) +
|
21
|
+
%(PROGRAM-ID=1,RESOLUTION=1920x1080,FRAME-RATE=23.976,) +
|
22
|
+
%(AVERAGE-BANDWIDTH=550,AUDIO="test",VIDEO="test2",) +
|
23
|
+
%(SUBTITLES="subs",CLOSED-CAPTIONS="caps",URI="test.url")
|
24
|
+
item = M3u8::PlaylistItem.parse(input)
|
25
|
+
expect(item.program_id).to eq '1'
|
26
|
+
expect(item.codecs).to eq 'avc'
|
27
|
+
expect(item.bandwidth).to eq 540
|
28
|
+
expect(item.average_bandwidth).to eq 550
|
29
|
+
expect(item.width).to eq 1920
|
30
|
+
expect(item.height).to eq 1080
|
31
|
+
expect(item.frame_rate).to eq BigDecimal('23.976')
|
32
|
+
expect(item.audio).to eq 'test'
|
33
|
+
expect(item.video).to eq 'test2'
|
34
|
+
expect(item.subtitles).to eq 'subs'
|
35
|
+
expect(item.closed_captions).to eq 'caps'
|
36
|
+
expect(item.uri).to eq 'test.url'
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should parse m3u8 into current instance' do
|
40
|
+
input = %(#EXT-X-STREAM-INF:CODECS="avc",BANDWIDTH=540,) +
|
41
|
+
%(PROGRAM-ID=1,AUDIO="test",VIDEO="test2",) +
|
42
|
+
%(SUBTITLES="subs",CLOSED-CAPTIONS="caps",URI="test.url")
|
43
|
+
item = M3u8::PlaylistItem.new
|
44
|
+
item.parse(input)
|
45
|
+
expect(item.program_id).to eq '1'
|
46
|
+
expect(item.codecs).to eq 'avc'
|
47
|
+
expect(item.bandwidth).to eq 540
|
48
|
+
expect(item.average_bandwidth).to be_nil
|
49
|
+
expect(item.width).to be_nil
|
50
|
+
expect(item.height).to be_nil
|
51
|
+
expect(item.audio).to eq 'test'
|
52
|
+
expect(item.video).to eq 'test2'
|
53
|
+
expect(item.subtitles).to eq 'subs'
|
54
|
+
expect(item.closed_captions).to eq 'caps'
|
55
|
+
expect(item.uri).to eq 'test.url'
|
56
|
+
end
|
52
57
|
end
|
53
58
|
|
54
59
|
it 'should provide m3u8 format representation' do
|
@@ -154,6 +159,10 @@ describe M3u8::PlaylistItem do
|
|
154
159
|
item = M3u8::PlaylistItem.new options
|
155
160
|
expect(item.codecs).to eq 'avc1.4d0028'
|
156
161
|
|
162
|
+
options = { profile: 'main', level: 4.1 }
|
163
|
+
item = M3u8::PlaylistItem.new options
|
164
|
+
expect(item.codecs).to eq 'avc1.4d0029'
|
165
|
+
|
157
166
|
options = { profile: 'high', level: 3.1 }
|
158
167
|
item = M3u8::PlaylistItem.new options
|
159
168
|
expect(item.codecs).to eq 'avc1.64001f'
|
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.6.
|
4
|
+
version: 0.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seth Deckard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|