Skip to content

Commit

Permalink
Addressing indentation issues
Browse files Browse the repository at this point in the history
  • Loading branch information
AM\haguirre committed Feb 8, 2018
1 parent 0a10587 commit cd93865
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 51 deletions.
2 changes: 1 addition & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export var hlsDefaultConfig = {
fragLoadingMaxRetry: 6, // used by fragment-loader
fragLoadingRetryDelay: 1000, // used by fragment-loader
fragLoadingMaxRetryTimeout: 64000, // used by fragment-loader
startFragPrefetch: false, // used by stream-controller
startFragPrefetch: false, // used by stream-controller
fpsDroppedMonitoringPeriod: 5000, // used by fps-controller
fpsDroppedMonitoringThreshold: 0.2, // used by fps-controller
appendErrorMaxRetry: 3, // used by buffer-controller
Expand Down
62 changes: 31 additions & 31 deletions src/controller/stream-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,29 +348,29 @@ class StreamController extends TaskLoop {
even if SN are not synchronized between playlists, loading this frag will help us
compute playlist sliding and find the right one after in case it was not the right consecutive one */
if (fragPrevious) {

if (!levelDetails.programDateTime) {//Uses buffer and sequence number to calculate switch segment (required if using EXT-X-DISCONTINUITY-SEQUENCE)
const targetSN = fragPrevious.sn + 1;
if (targetSN >= levelDetails.startSN && targetSN <= levelDetails.endSN) {
const fragNext = fragments[targetSN - levelDetails.startSN];
if (fragPrevious.cc === fragNext.cc) {
frag = fragNext;
logger.log(`live playlist, switching playlist, load frag with next SN: ${frag.sn}`);
frag = fragNext;
logger.log(`live playlist, switching playlist, load frag with next SN: ${frag.sn}`);
}
}
// next frag SN not available (or not with same continuity counter)
// look for a frag sharing the same CC
if (!frag) {
frag = BinarySearch.search(fragments, function(frag) {
return fragPrevious.cc - frag.cc;
return fragPrevious.cc - frag.cc;
});
if (frag) {
logger.log(`live playlist, switching playlist, load frag with same CC: ${frag.sn}`);
logger.log(`live playlist, switching playlist, load frag with same CC: ${frag.sn}`);
}
}
} else {//Relies on PDT in order to switch bitrates (Support EXT-X-DISCONTINUITY without EXT-X-DISCONTINUITY-SEQUENCE)
frag = this._findFragmentByPDT(fragments, fragPrevious.endPdt + 1);
}
}
}
if (!frag) {
/* we have no idea about which fragment should be loaded.
Expand All @@ -382,30 +382,30 @@ class StreamController extends TaskLoop {
}
return frag;
}

_findFragmentByPDT(fragments, PDTValue){

if(!fragments || PDTValue === undefined){
return null;
}

//if less than start
let firstSegment = fragments[0];

if(PDTValue < firstSegment.pdt){
return null;
}

let lastSegment = fragments[fragments.length - 1];

if(PDTValue >= lastSegment.endPdt){
return null;
}

return BinarySearch.search(fragments, function(frag) {
return PDTValue < frag.pdt ? -1 : PDTValue >= frag.endPdt ? 1 : 0;
});
}
if(!fragments || PDTValue === undefined){
return null;
}

//if less than start
let firstSegment = fragments[0];

if(PDTValue < firstSegment.pdt){
return null;
}

let lastSegment = fragments[fragments.length - 1];

if(PDTValue >= lastSegment.endPdt){
return null;
}

return BinarySearch.search(fragments, function(frag) {
return PDTValue < frag.pdt ? -1 : PDTValue >= frag.endPdt ? 1 : 0;
});
}


_findFragmentBySN(fragPrevious, fragments, bufferEnd, end) {
Expand Down Expand Up @@ -450,8 +450,8 @@ class StreamController extends TaskLoop {
}
}
return foundFrag;
}
}

_findFragment(start, fragPrevious, fragLen, fragments, bufferEnd, end, levelDetails) {
const config = this.hls.config;
let frag;
Expand All @@ -463,7 +463,7 @@ class StreamController extends TaskLoop {
} else {//Relies on PDT in order to switch bitrates (Support EXT-X-DISCONTINUITY without EXT-X-DISCONTINUITY-SEQUENCE)
foundFrag = this._findFragmentByPDT(fragments, fragPrevious ? fragPrevious.endPdt + 1 : bufferEnd + (levelDetails.programDateTime ? Date.parse(levelDetails.programDateTime) : 0));
}

} else {
// reach end of playlist
foundFrag = fragments[fragLen-1];
Expand Down
38 changes: 19 additions & 19 deletions tests/unit/loader/playlist-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,35 +628,35 @@ Rollover38803/20160525T064049-01-69844069.ts

it('parses #EXTINF without a leading digit', () => {
var level = `#EXTM3U
#EXT-X-VERSION:3
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-TARGETDURATION:14
#EXTINF:.360,
/sec(3ae40f708f79ca9471f52b86da76a3a8)/frag(1)/video/107/282/158282701_mp4_h264_aac_hq.ts
#EXT-X-ENDLIST`;
#EXT-X-VERSION:3
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-TARGETDURATION:14
#EXTINF:.360,
/sec(3ae40f708f79ca9471f52b86da76a3a8)/frag(1)/video/107/282/158282701_mp4_h264_aac_hq.ts
#EXT-X-ENDLIST`;
var result = M3U8Parser.parseLevelPlaylist(level, 'http://proxy-62.dailymotion.com/sec(3ae40f708f79ca9471f52b86da76a3a8)/video/107/282/158282701_mp4_h264_aac_hq.m3u8#cell=core',0);
assert.strictEqual(result.fragments.length, 1);
assert.strictEqual(result.fragments[0].duration, 0.360);
});

it('parses #EXT-X-MAP URI', () => {
var level = `#EXTM3U
#EXT-X-TARGETDURATION:6
#EXT-X-VERSION:7
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MAP:URI="main.mp4",BYTERANGE="718@0"
#EXTINF:6.00600,
#EXT-X-BYTERANGE:1543597@718
main.mp4`;
#EXT-X-TARGETDURATION:6
#EXT-X-VERSION:7
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MAP:URI="main.mp4",BYTERANGE="718@0"
#EXTINF:6.00600,
#EXT-X-BYTERANGE:1543597@718
main.mp4`;
var result = M3U8Parser.parseLevelPlaylist(level, 'http://proxy-62.dailymotion.com/sec(3ae40f708f79ca9471f52b86da76a3a8)/video/107/282/158282701_mp4_h264_aac_hq.m3u8#cell=core',0);
assert.strictEqual(result.initSegment.url, "http://proxy-62.dailymotion.com/sec(3ae40f708f79ca9471f52b86da76a3a8)/video/107/282/main.mp4");
assert.strictEqual(result.initSegment.byteRangeStartOffset, 0);
assert.strictEqual(result.initSegment.byteRangeEndOffset, 718);
assert.strictEqual(result.initSegment.sn, 'initSegment');
});

it('if playlists contains #EXT-X-PROGRAM-DATE-TIME switching will be applied by PDT', () => {
var level = `#EXTM3U
#EXT-X-VERSION:2
Expand All @@ -675,7 +675,7 @@ Rollover38803/20160525T064049-01-69844069.ts
var hls = {config : { }, on : function() { }};
var result = M3U8Parser.parseLevelPlaylist(level, 'http://video.example.com/disc.m3u8',0);
assert.ok(result.programDateTime);
});
});

it('if playlists does NOT contain #EXT-X-PROGRAM-DATE-TIME switching will be applied by CC count', () => {
var level = `#EXTM3U
Expand All @@ -692,6 +692,6 @@ Rollover38803/20160525T064049-01-69844069.ts
var hls = {config : { }, on : function() { }};
var result = M3U8Parser.parseLevelPlaylist(level, 'http://video.example.com/disc.m3u8',0);
assert.strictEqual(result.programDateTime, undefined);
});
});

});

0 comments on commit cd93865

Please sign in to comment.