spec/writer_spec.rb in m3u8-0.4.0 vs spec/writer_spec.rb in m3u8-0.5.0

- old
+ new

@@ -1,10 +1,10 @@ require 'spec_helper' describe M3u8::Writer do it 'should render master playlist' do - options = { playlist: 'playlist_url', bitrate: 6400, + options = { uri: 'playlist_url', bandwidth: 6400, audio_codec: 'mp3' } item = M3u8::PlaylistItem.new options playlist = M3u8::Playlist.new playlist.items.push item @@ -15,11 +15,11 @@ io = StringIO.open writer = M3u8::Writer.new io writer.write playlist expect(io.string).to eq output - options = { program_id: '1', playlist: 'playlist_url', bitrate: 6400, + options = { program_id: '1', uri: 'playlist_url', bandwidth: 6400, audio_codec: 'mp3' } item = M3u8::PlaylistItem.new options playlist = M3u8::Playlist.new playlist.items.push item @@ -30,11 +30,11 @@ io = StringIO.open writer = M3u8::Writer.new io writer.write playlist expect(io.string).to eq output - options = { program_id: '2', playlist: 'playlist_url', bitrate: 50_000, + options = { program_id: '2', uri: 'playlist_url', bandwidth: 50_000, width: 1920, height: 1080, profile: 'high', level: 4.1, audio_codec: 'aac-lc' } item = M3u8::PlaylistItem.new options playlist = M3u8::Playlist.new playlist.items.push item @@ -48,25 +48,31 @@ writer = M3u8::Writer.new io writer.write playlist expect(io.string).to eq output playlist = M3u8::Playlist.new - options = { program_id: '1', playlist: 'playlist_url', bitrate: 6400, + options = { program_id: '1', uri: 'playlist_url', bandwidth: 6400, audio_codec: 'mp3' } item = M3u8::PlaylistItem.new options playlist.items.push item - options = { program_id: '2', playlist: 'playlist_url', bitrate: 50_000, + options = { program_id: '2', uri: 'playlist_url', bandwidth: 50_000, width: 1920, height: 1080, profile: 'high', level: 4.1, audio_codec: 'aac-lc' } item = M3u8::PlaylistItem.new options playlist.items.push item + options = { data_id: 'com.test.movie.title', value: 'Test', + uri: 'http://test', language: 'en' } + item = M3u8::SessionDataItem.new(options) + playlist.items.push item output = "#EXTM3U\n" + %(#EXT-X-STREAM-INF:PROGRAM-ID=1,CODECS="mp4a.40.34") + ",BANDWIDTH=6400\nplaylist_url\n#EXT-X-STREAM-INF:PROGRAM-ID=2," + %(RESOLUTION=1920x1080,CODECS="avc1.640028,mp4a.40.2") + - ",BANDWIDTH=50000\nplaylist_url\n" + ",BANDWIDTH=50000\nplaylist_url\n" + + %(#EXT-X-SESSION-DATA:DATA-ID="com.test.movie.title",) + + %(VALUE="Test",URI="http://test",LANGUAGE="en"\n) io = StringIO.open writer = M3u8::Writer.new io writer.write playlist expect(io.string).to eq output @@ -108,20 +114,21 @@ io = StringIO.open writer = M3u8::Writer.new io writer.write playlist expect(io.string).to eq output - options = { version: 1, cache: false, target: 12, sequence: 1, - type: 'EVENT' } + options = { version: 4, cache: false, target: 12, sequence: 1, + type: 'EVENT', iframes_only: true } playlist = M3u8::Playlist.new options options = { duration: 11.344644, segment: '1080-7mbps00000.ts' } item = M3u8::SegmentItem.new options playlist.items.push item output = "#EXTM3U\n" \ "#EXT-X-PLAYLIST-TYPE:EVENT\n" \ - "#EXT-X-VERSION:1\n" \ + "#EXT-X-VERSION:4\n" \ + "#EXT-X-I-FRAMES-ONLY\n" \ "#EXT-X-MEDIA-SEQUENCE:1\n" \ "#EXT-X-ALLOW-CACHE:NO\n" \ "#EXT-X-TARGETDURATION:12\n" \ "#EXTINF:11.344644,\n" \ "1080-7mbps00000.ts\n" \ @@ -134,10 +141,10 @@ it 'should raise error on write if item types are mixed' do playlist = M3u8::Playlist.new hash = { program_id: 1, width: 1920, height: 1080, codecs: 'avc', - bitrate: 540, playlist: 'test.url' } + bandwidth: 540, playlist: 'test.url' } item = M3u8::PlaylistItem.new(hash) playlist.items.push item hash = { duration: 10.991, segment: 'test.ts' } item = M3u8::SegmentItem.new(hash)