|
1 | 1 | import M3U8Parser from '../../../src/loader/m3u8-parser'; |
2 | | -import { mergeDetails } from '../../../src/controller/level-helper'; |
3 | 2 | import AttrList from '../../../src/utils/attr-list'; |
4 | 3 |
|
5 | 4 | describe('PlaylistLoader', function () { |
@@ -966,132 +965,4 @@ http://dummy.url.com/hls/live/segment/segment_022916_164500865_719928.ts |
966 | 965 | expect(result.fragments[0].url).to.equal('http://dummy.url.com/180724_Allison VLOG v3_00001.ts'); |
967 | 966 | expect(result.fragments[1].url).to.equal('http://dummy.url.com/180724_Allison VLOG v3_00002.ts'); |
968 | 967 | }); |
969 | | - |
970 | | - describe('LHLS Parsing', function () { |
971 | | - const level = `#EXTM3U |
972 | | -#EXT-X-VERSION:3 |
973 | | -#EXT-X-TARGETDURATION:2 |
974 | | -#EXT-X-MEDIA-SEQUENCE: 0 |
975 | | -#EXT-X-DISCONTINUITY-SEQUENCE: 0 |
976 | | -#EXT-X-PROGRAM-DATE-TIME:2018-09-05T20:59:06.531Z |
977 | | -#EXTINF:2.000 |
978 | | -https://foo.com/bar/0.ts |
979 | | -#EXT-X-PROGRAM-DATE-TIME:2018-09-05T20:59:08.531Z |
980 | | -#EXTINF:2.000 |
981 | | -https://foo.com/bar/1.ts |
982 | | -
|
983 | | -#EXT-X-PREFETCH:https://foo.com/bar/2.ts |
984 | | - `; |
985 | | - const levelRefreshed = `#EXTM3U |
986 | | -#EXT-X-VERSION:3 |
987 | | -#EXT-X-TARGETDURATION:2 |
988 | | -#EXT-X-MEDIA-SEQUENCE: 1 |
989 | | -#EXT-X-DISCONTINUITY-SEQUENCE: 0 |
990 | | -#EXT-X-PROGRAM-DATE-TIME:2018-09-05T20:59:08.531Z |
991 | | -#EXTINF:2.000 |
992 | | -https://foo.com/bar/1.ts |
993 | | -#EXT-X-PROGRAM-DATE-TIME:2018-09-05T20:59:10.531Z |
994 | | -#EXTINF:2.000 |
995 | | -https://foo.com/bar/2.ts |
996 | | -
|
997 | | -#EXT-X-PREFETCH:https://foo.com/bar/3.ts |
998 | | - `; |
999 | | - const levelWithDiscontinuity = `#EXTM3U |
1000 | | -#EXT-X-VERSION:3 |
1001 | | -#EXT-X-TARGETDURATION:2 |
1002 | | -#EXT-X-MEDIA-SEQUENCE: 100 |
1003 | | -#EXT-X-DISCONTINUITY-SEQUENCE: 5 |
1004 | | -#EXT-X-PROGRAM-DATE-TIME:2018-09-05T20:59:06.531Z |
1005 | | -#EXTINF:2.000 |
1006 | | -https://foo.com/bar/0.ts |
1007 | | -#EXT-X-PROGRAM-DATE-TIME:2018-09-05T20:59:08.531Z |
1008 | | -#EXTINF:2.000 |
1009 | | -https://foo.com/bar/1.ts |
1010 | | -
|
1011 | | -#EXT-X-PREFETCH-DISCONTINUITY |
1012 | | -#EXT-X-PREFETCH:https://foo.com/bar/5.ts |
1013 | | - `; |
1014 | | - |
1015 | | - it('Adds prefetch segments to the appropriate Level object', function () { |
1016 | | - const result = M3U8Parser.parseLevelPlaylist(level, 'http://dummy.url.com/playlist.m3u8', 2, 'main', 0); |
1017 | | - expect(result.fragments).to.have.lengthOf(3); |
1018 | | - expect(result.fragments[2].baseurl).to.equal('http://dummy.url.com/playlist.m3u8'); |
1019 | | - expect(result.fragments[2].level).to.equal(2); |
1020 | | - expect(result.fragments[2].type).to.equal('main'); |
1021 | | - expect(result.fragments[2].urlId).to.equal(0); |
1022 | | - expect(result.fragments[2].relurl).to.equal('https://foo.com/bar/2.ts'); |
1023 | | - }); |
1024 | | - it('Adds `prefetch: true` to prefetch segments', function () { |
1025 | | - const result = M3U8Parser.parseLevelPlaylist(level, 'http://dummy.url.com/playlist.m3u8', 0); |
1026 | | - expect(result.fragments[2]).to.have.property('prefetch').which.equals(true); |
1027 | | - }); |
1028 | | - it('Adds `prefetch: false` to complete segments', function () { |
1029 | | - const result = M3U8Parser.parseLevelPlaylist(level, 'http://dummy.url.com/playlist.m3u8', 0); |
1030 | | - expect(result.fragments[0]).to.have.property('prefetch').which.equals(false); |
1031 | | - expect(result.fragments[1]).to.have.property('prefetch').which.equals(false); |
1032 | | - }); |
1033 | | - it('Updates `prefetch` to `false` when prefetch segments transform to complete segments', function () { |
1034 | | - const result1 = M3U8Parser.parseLevelPlaylist(level, 'http://dummy.url.com/playlist.m3u8', 0); |
1035 | | - const result2 = M3U8Parser.parseLevelPlaylist(levelRefreshed, 'http://dummy.url.com/playlist.m3u8', 0); |
1036 | | - |
1037 | | - expect(result1.fragments).to.have.lengthOf(3); |
1038 | | - expect(result1.endSN).to.equal(2); |
1039 | | - expect(result1.fragments[0].start).to.equal(0); |
1040 | | - expect(result1.fragments[0].sn).to.equal(0); |
1041 | | - expect(result1.fragments[1].sn).to.equal(1); |
1042 | | - expect(result1.fragments[2].sn).to.equal(2); |
1043 | | - expect(result1.fragments[0].prefetch).to.equal(false); |
1044 | | - expect(result1.fragments[1].prefetch).to.equal(false); |
1045 | | - expect(result1.fragments[2].prefetch).to.equal(true); |
1046 | | - expect(result1.fragments[1].relurl).to.equal('https://foo.com/bar/1.ts'); |
1047 | | - expect(result1.fragments[2].relurl).to.equal('https://foo.com/bar/2.ts'); |
1048 | | - |
1049 | | - expect(result2.fragments).to.have.lengthOf(3); |
1050 | | - expect(result2.endSN).to.equal(3); |
1051 | | - expect(result2.fragments[0].start).to.equal(0); |
1052 | | - expect(result2.fragments[0].sn).to.equal(1); |
1053 | | - expect(result2.fragments[1].sn).to.equal(2); |
1054 | | - expect(result2.fragments[2].sn).to.equal(3); |
1055 | | - expect(result2.fragments[0].prefetch).to.equal(false); |
1056 | | - expect(result2.fragments[1].prefetch).to.equal(false); |
1057 | | - expect(result2.fragments[2].prefetch).to.equal(true); |
1058 | | - expect(result2.fragments[1].relurl).to.equal('https://foo.com/bar/2.ts'); |
1059 | | - expect(result2.fragments[2].relurl).to.equal('https://foo.com/bar/3.ts'); |
1060 | | - |
1061 | | - // Clone the new results that mergeDetails will change |
1062 | | - const newDetails = JSON.parse(JSON.stringify(result2)); |
1063 | | - mergeDetails(result1, newDetails); |
1064 | | - |
1065 | | - expect(newDetails.fragments[0].start).to.equal(2); |
1066 | | - }); |
1067 | | - |
1068 | | - it('Calculates the correct start time, duration and program date time for prefetch segments', function () { |
1069 | | - const result = M3U8Parser.parseLevelPlaylist(level, 'http://dummy.url.com/playlist.m3u8', 0); |
1070 | | - const previousPDT = 1536181148531; |
1071 | | - expect(result.fragments[2].duration).to.equal(2); |
1072 | | - expect(result.fragments[2].start).to.equal(4); |
1073 | | - expect(result.fragments[1].programDateTime).to.equal(previousPDT); |
1074 | | - expect(result.fragments[2].programDateTime).to.equal(previousPDT + 2000); |
1075 | | - }); |
1076 | | - |
1077 | | - it('Adds "PREFETCH-DIS" to `frag.tagList` and updates discontinuity sequence (cc) tags', function () { |
1078 | | - const result = M3U8Parser.parseLevelPlaylist(levelWithDiscontinuity, 'http://dummy.url.com/playlist.m3u8', 0); |
1079 | | - expect(result.fragments[0].cc).to.equal(5); |
1080 | | - expect(result.fragments[2].cc).to.equal(6); |
1081 | | - expect(result.fragments[2].tagList).to.have.lengthOf(1); |
1082 | | - expect(result.fragments[2].tagList[0][0]).to.equal('PREFETCH-DIS'); |
1083 | | - }); |
1084 | | - |
1085 | | - it('Calculates the correct SN, start time and duration for prefetch segments with discontinuity', function () { |
1086 | | - const result = M3U8Parser.parseLevelPlaylist(levelWithDiscontinuity, 'http://dummy.url.com/playlist.m3u8', 0); |
1087 | | - const previousPDT = 1536181148531; |
1088 | | - expect(result.fragments[0].sn).to.equal(100); |
1089 | | - expect(result.fragments[1].sn).to.equal(101); |
1090 | | - expect(result.fragments[2].sn).to.equal(102); |
1091 | | - expect(result.fragments[2].duration).to.equal(2); |
1092 | | - expect(result.fragments[2].start).to.equal(4); |
1093 | | - expect(result.fragments[1].programDateTime).to.equal(previousPDT); |
1094 | | - expect(result.fragments[2].programDateTime).to.equal(previousPDT + 2000); |
1095 | | - }); |
1096 | | - }); |
1097 | 968 | }); |
0 commit comments