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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e96c846721a2a84feb5682879e7e3bfcb3f3e0dd
4
- data.tar.gz: 438952587f84fa55401e22ba4c2f5c089de14af9
3
+ metadata.gz: 9771b4d74b91d96ee4c6eca99cce96fb16705233
4
+ data.tar.gz: 39dca18b7625bcceedb21f1dab3aa8363a773a17
5
5
  SHA512:
6
- metadata.gz: 62a05705eefa8c3929c9db56f65be2f2137f90c1e3fecd8e228a840c7285a9a5f20b7c2a59055ba462e55329d54214bee41497c5d0aef3b965cd6deef784d3f4
7
- data.tar.gz: 3a34c9d4e231f2d37030b4a8357accc486d1cb88d67b238abe1183f1f1e87e8e7d2a0d8b45bd0bfb51ff682c664c78c7c34a43f166f4c77d2a85695763479289
6
+ metadata.gz: 79a97144562036dccad8cd96e4c753890a6616920707a617e50b84e2d6ec5c7f1648be6bfa1d34508446bda93f5b510ba0d98680caebdc325f233e917b6a2c3f
7
+ data.tar.gz: 81d6de6a6162f2820da6d2d0e652ae0b1917177214203530ccc5004eb56382b5e69249781a79add1dfa8949599a4b9e1dafaacb181ed90a59411be458c97d228
@@ -1,4 +1,6 @@
1
- #### 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.
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
 
@@ -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
- extend M3u8
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
- attributes = parse_attributes text
21
- resolution = parse_resolution attributes['RESOLUTION']
22
- average = parse_average_bandwidth attributes['AVERAGE-BANDWIDTH']
23
- frame_rate = parse_frame_rate attributes['FRAME-RATE']
24
- options = { program_id: attributes['PROGRAM-ID'],
25
- codecs: attributes['CODECS'],
26
- width: resolution[:width],
27
- height: resolution[:height],
28
- bandwidth: attributes['BANDWIDTH'].to_i,
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 self.parse_average_bandwidth(value)
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 self.parse_resolution(resolution)
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 self.parse_frame_rate(frame_rate)
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)
@@ -1,4 +1,4 @@
1
1
  # M3u8 provides parsing, generation, and validation of m3u8 playlists
2
2
  module M3u8
3
- VERSION = '0.6.4'
3
+ VERSION = '0.6.5'
4
4
  end
@@ -15,40 +15,45 @@ describe M3u8::PlaylistItem do
15
15
  expect(item.iframe).to be false
16
16
  end
17
17
 
18
- it 'should parse m3u8 text into instance' do
19
- format = %(#EXT-X-STREAM-INF:CODECS="avc",BANDWIDTH=540,) +
20
- %(PROGRAM-ID=1,RESOLUTION=1920x1080,FRAME-RATE=23.976,) +
21
- %(AVERAGE-BANDWIDTH=550,AUDIO="test",VIDEO="test2",) +
22
- %(SUBTITLES="subs",CLOSED-CAPTIONS="caps",URI="test.url")
23
- item = M3u8::PlaylistItem.parse(format)
24
- expect(item.program_id).to eq '1'
25
- expect(item.codecs).to eq 'avc'
26
- expect(item.bandwidth).to eq 540
27
- expect(item.average_bandwidth).to eq 550
28
- expect(item.width).to eq 1920
29
- expect(item.height).to eq 1080
30
- expect(item.frame_rate).to eq BigDecimal('23.976')
31
- expect(item.audio).to eq 'test'
32
- expect(item.video).to eq 'test2'
33
- expect(item.subtitles).to eq 'subs'
34
- expect(item.closed_captions).to eq 'caps'
35
- expect(item.uri).to eq 'test.url'
36
-
37
- format = %(#EXT-X-STREAM-INF:CODECS="avc",BANDWIDTH=540,) +
38
- %(PROGRAM-ID=1,AUDIO="test",VIDEO="test2",) +
39
- %(SUBTITLES="subs",CLOSED-CAPTIONS="caps",URI="test.url")
40
- item = M3u8::PlaylistItem.parse(format)
41
- expect(item.program_id).to eq '1'
42
- expect(item.codecs).to eq 'avc'
43
- expect(item.bandwidth).to eq 540
44
- expect(item.average_bandwidth).to be_nil
45
- expect(item.width).to be_nil
46
- expect(item.height).to be_nil
47
- expect(item.audio).to eq 'test'
48
- expect(item.video).to eq 'test2'
49
- expect(item.subtitles).to eq 'subs'
50
- expect(item.closed_captions).to eq 'caps'
51
- expect(item.uri).to eq 'test.url'
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
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-02-21 00:00:00.000000000 Z
11
+ date: 2016-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler