m3u8 0.8.0 → 0.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 266fa2220bfc0c9acdc04144747da7d7a01d9b5f
4
- data.tar.gz: ed5b06cd8baccf5eec7a4fd592a4715a367fa791
3
+ metadata.gz: ddb2f4d0d192d3240638f292df9af726bb34cc0a
4
+ data.tar.gz: b83b3ef504e0103d8dfa1295ee8b27b5860824b1
5
5
  SHA512:
6
- metadata.gz: 9942efab7468eaa317280e6b465251d972700e43ce3b7b0ca281c4fe3084ad3743acbe24074a324fdaa4f9421be0da732a3128e00311b468caf257814337ba1e
7
- data.tar.gz: d02d9f3c6853f68557ff89d5a6a7d3d4f3a2c77a5d1ea535fa3e5c89911ec0c724e8646dfaa2da6f951a8672494fb32cfc1b9dd0502da95d29ed0a82e94e3d94
6
+ metadata.gz: f07895da5aa3a400e2020c3ac0d14e421ac99869d35573985f1589809267e1ddb2d1b25a2174eb88057ba8497f0651f12f453c8b1c765453ef0ff68e99d0689c
7
+ data.tar.gz: 053c1be2adfa5bb2593fc1ee603c21af04f0ba71e8f0fa232a379ea4d27ad8789b9ff753b5e94c1a0e5c41ee9adc65eef043ad42ed1d58ce558ad3a24cfd5437
@@ -2,5 +2,8 @@ AllCops:
2
2
  Exclude:
3
3
  - 'spec/spec_helper.rb'
4
4
  - 'm3u8.gemspec'
5
+ Metrics/BlockLength:
6
+ Exclude:
7
+ - 'spec/**/*'
5
8
  Style/StringLiterals:
6
9
  EnforcedStyle: single_quotes
@@ -1,8 +1,11 @@
1
+ **0.8.1**
2
+ Merged pull request #23 from [ryanische](https:/github.com/ryanische) which fixes issue of CODEC attribute validation not matching the HLS I-D.
3
+
1
4
  **0.8.0 (4/13/2017)**
2
5
 
3
- * Added several improvements for writing playlists: Allow playlist to be initalized as master, expose `write_header`/`write_footer` on `Writer` class.
4
- * Added support for the `#EXT-X-DISCONTINUITY-SEQUENCE` tag. Added missing attributes to `MediaItem`: `INSTREAM-ID`, `CHARACTERISTICS`, `CHANNELS`, Added missing `HDCP-LEVEL` attribute to `PlaylistItem`.
5
- * Fixed issue [#20](https://github.com/sethdeckard/m3u8/issues/20).
6
+ * Added several improvements for writing playlists: Allow playlist to be initalized as master, expose `write_header`/`write_footer` on `Writer` class.
7
+ * Added support for the `#EXT-X-DISCONTINUITY-SEQUENCE` tag. Added missing attributes to `MediaItem`: `INSTREAM-ID`, `CHARACTERISTICS`, `CHANNELS`, Added missing `HDCP-LEVEL` attribute to `PlaylistItem`.
8
+ * Fixed issue [#20](https://github.com/sethdeckard/m3u8/issues/20).
6
9
  * Merged pull request #21 from [rmberg](https://github.com/rmberg), adding support for live playlists to `Writer`.
7
10
 
8
11
  ***
@@ -3,9 +3,6 @@ module M3u8
3
3
  class InvalidPlaylistError < StandardError
4
4
  end
5
5
 
6
- class MissingCodecError < StandardError
7
- end
8
-
9
6
  class PlaylistTypeError < StandardError
10
7
  end
11
8
  end
@@ -8,7 +8,6 @@ module M3u8
8
8
  :audio_codec, :level, :profile, :video, :audio, :uri,
9
9
  :average_bandwidth, :subtitles, :closed_captions, :iframe,
10
10
  :frame_rate, :name, :hdcp_level
11
- MISSING_CODEC_MESSAGE = 'Audio or video codec info should be provided.'
12
11
 
13
12
  def initialize(params = {})
14
13
  self.iframe = false
@@ -37,16 +36,23 @@ module M3u8
37
36
  def codecs
38
37
  return @codecs unless @codecs.nil?
39
38
 
40
- video_code = video_codec(profile, level)
41
- return audio_codec_code if video_code.nil?
42
- return video_code if audio_codec_code.nil?
39
+ video_codec_string = video_codec(profile, level)
43
40
 
44
- "#{video_code},#{audio_codec_code}"
41
+ # profile and/or level were specified but not recognized,
42
+ # do not specify any codecs
43
+ return nil if !(profile.nil? && level.nil?) && video_codec_string.nil?
44
+
45
+ audio_codec_string = audio_codec_code
46
+
47
+ # audio codec was specified but not recognized,
48
+ # do not specify any codecs
49
+ return nil if !@audio_codec.nil? && audio_codec_string.nil?
50
+
51
+ codec_strings = [video_codec_string, audio_codec_string].compact
52
+ codec_strings.empty? ? nil : codec_strings.join(',')
45
53
  end
46
54
 
47
55
  def to_s
48
- validate
49
-
50
56
  m3u8_format
51
57
  end
52
58
 
@@ -88,10 +94,6 @@ module M3u8
88
94
  value if value > 0
89
95
  end
90
96
 
91
- def validate
92
- raise MissingCodecError, MISSING_CODEC_MESSAGE if codecs.nil?
93
- end
94
-
95
97
  def m3u8_format
96
98
  return %(#EXT-X-I-FRAME-STREAM-INF:#{attributes},URI="#{uri}") if iframe
97
99
 
@@ -134,6 +136,7 @@ module M3u8
134
136
  end
135
137
 
136
138
  def codecs_format
139
+ return if codecs.nil?
137
140
  %(CODECS="#{codecs}")
138
141
  end
139
142
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  # M3u8 provides parsing, generation, and validation of m3u8 playlists
3
3
  module M3u8
4
- VERSION = '0.8.0'
4
+ VERSION = '0.8.1'
5
5
  end
@@ -75,11 +75,83 @@ describe M3u8::PlaylistItem do
75
75
 
76
76
  describe '#to_s' do
77
77
  context 'when codecs is missing' do
78
- it 'raises error' do
78
+ it 'does not specify CODECS' do
79
79
  params = { bandwidth: 540, uri: 'test.url' }
80
80
  item = M3u8::PlaylistItem.new params
81
- message = 'Audio or video codec info should be provided.'
82
- expect { item.to_s }.to raise_error(M3u8::MissingCodecError, message)
81
+ expect(item.to_s).not_to include('CODECS')
82
+ end
83
+ end
84
+
85
+ context 'when level is not recognized' do
86
+ it 'does not specify CODECS' do
87
+ params = { bandwidth: 540, uri: 'test.url', level: 9001 }
88
+ item = M3u8::PlaylistItem.new params
89
+ expect(item.to_s).not_to include('CODECS')
90
+ end
91
+ end
92
+
93
+ context 'when profile is not recognized' do
94
+ it 'does not specify CODECS' do
95
+ params = { bandwidth: 540, uri: 'test.url', profile: 'best' }
96
+ item = M3u8::PlaylistItem.new params
97
+ expect(item.to_s).not_to include('CODECS')
98
+ end
99
+ end
100
+
101
+ context 'when profile and level are not recognized' do
102
+ it 'does not specify CODECS' do
103
+ params = { bandwidth: 540, uri: 'test.url', profile: 'best',
104
+ level: 9001 }
105
+ item = M3u8::PlaylistItem.new params
106
+ expect(item.to_s).not_to include('CODECS')
107
+ end
108
+
109
+ context 'when audio codec is recognized' do
110
+ it 'does not specify CODECS' do
111
+ params = { bandwidth: 540, uri: 'test.url', profile: 'best',
112
+ level: 9001, audio_codec: 'aac-lc' }
113
+ item = M3u8::PlaylistItem.new params
114
+ expect(item.to_s).not_to include('CODECS')
115
+ end
116
+ end
117
+ end
118
+
119
+ context 'when profile and level are not set' do
120
+ context 'when audio codec is recognized' do
121
+ it 'specifies CODECS with audio codec' do
122
+ params = { bandwidth: 540, uri: 'test.url', audio_codec: 'aac-lc' }
123
+ item = M3u8::PlaylistItem.new params
124
+ expect(item.to_s).to include('CODECS="mp4a.40.2"')
125
+ end
126
+ end
127
+ end
128
+
129
+ context 'when profile and level are recognized' do
130
+ context 'when audio codec is not recognized' do
131
+ it 'does not specify CODECS' do
132
+ params = { bandwidth: 540, uri: 'test.url', profile: 'high',
133
+ level: 4.1, audio_codec: 'fuzzy' }
134
+ item = M3u8::PlaylistItem.new params
135
+ expect(item.to_s).not_to include('CODECS')
136
+ end
137
+ end
138
+
139
+ context 'when audio codec is not set' do
140
+ it 'specifies CODECS with video codec' do
141
+ params = { bandwidth: 540, uri: 'test.url', profile: 'high',
142
+ level: 4.1 }
143
+ item = M3u8::PlaylistItem.new params
144
+ expect(item.to_s).to include('CODECS="avc1.640029"')
145
+ end
146
+ end
147
+
148
+ context 'when audio codec is recognized' do
149
+ it 'specifies CODECS with video codec and audio_codec' do
150
+ params = { bandwidth: 540, uri: 'test.url', profile: 'high',
151
+ level: 4.1, audio_codec: 'aac-lc' }
152
+ item = M3u8::PlaylistItem.new params
153
+ expect(item.to_s).to include('CODECS="avc1.640029,mp4a.40.2"')
154
+ end
83
155
  end
84
156
  end
85
157
 
@@ -101,8 +173,8 @@ describe M3u8::PlaylistItem do
101
173
  subtitles: 'subs', frame_rate: 30, closed_captions: 'caps',
102
174
  name: 'SD', hdcp_level: 'TYPE-0', program_id: '1' }
103
175
  item = described_class.new(options)
104
- expected = %(#EXT-X-STREAM-INF:PROGRAM-ID=1,CODECS="avc",BANDWIDTH=540,) +
105
- %(AVERAGE-BANDWIDTH=500,FRAME-RATE=30.000,) +
176
+ expected = %(#EXT-X-STREAM-INF:PROGRAM-ID=1,CODECS="avc",) +
177
+ 'BANDWIDTH=540,AVERAGE-BANDWIDTH=500,FRAME-RATE=30.000,' \
106
178
  'HDCP-LEVEL=TYPE-0,' +
107
179
  %(AUDIO="test",VIDEO="test2",SUBTITLES="subs",) +
108
180
  %(CLOSED-CAPTIONS="caps",NAME="SD"\ntest.url)
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.8.0
4
+ version: 0.8.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-04-13 00:00:00.000000000 Z
11
+ date: 2017-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler