Skip to content

Commit

Permalink
-1.0-PLAT-PLAT-5976-r (#244)
Browse files Browse the repository at this point in the history
- added logs
- allowed for 0 length chunk due to gaps (split) inside mixclip range.
- mixfilter returns invalid range in case on of the concat sources has no data.
  • Loading branch information
igorshevach authored Sep 1, 2016
1 parent 72517fe commit cb774d2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
10 changes: 7 additions & 3 deletions lib/playlistGenerator/ConcatSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,15 @@ ConcatSource.prototype.split = function (newSrc,r) {
} else {
that.durationsMan.setDurationAt(lastThisIndex-1,updatedDuration);
}

that.logger.debug("split %j-%j len=%j",lastThisIndex,firstThatIndex,that.durationsMan.firstDTS.length);
}

that.logger.debug("split %j-%j len=%j",lastThisIndex,firstThatIndex,that.durationsMan.firstDTS.length);

_.each(that.inner.durations.slice(lastThisIndex,firstThatIndex),function(duration){
var item = that.getItem(lastThisIndex);
that.logger.info('split: gap. delete chunk = [%s]; Dts = [%d]; Duration = [%d]',
item.paths, item.firstDTS, item.durations);

removeItem.call(that,lastThisIndex);
that.inner.lastEncoderDTS -= duration;
firstThatIndex--;
Expand All @@ -311,7 +315,7 @@ ConcatSource.prototype.split = function (newSrc,r) {
newSrc.keyFrameDurations.push(item.keyFrames);
}

that.logger.info('split: Append clip = [%s]; Dts = [%d]; Duration = [%d]',
that.logger.info('split: Append chunk = [%s]; Dts = [%d]; Duration = [%d]',
item.paths, item.firstDTS, item.durations);

});
Expand Down
13 changes: 10 additions & 3 deletions lib/playlistGenerator/MixFilterClip.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ MixFilterClip.prototype.insert = function (fileInfo) {
checkNewSource.call(this,'a',fileInfo);
}

that.logger.debug('insert %j',fileInfo);

for( var idx = 0; idx < that.inner.sources.length; idx++ ) {
var src = that.inner.sources[idx];

Expand All @@ -252,7 +254,7 @@ MixFilterClip.prototype.insert = function (fileInfo) {
break;
}

that.logger.debug('Insert Clip %s: Track=%s; Duration=%d First_dts=%d Enc_dts=%d wrap=%j',
that.logger.trace('insert %s: Track=%s; Duration=%d First_dts=%d Enc_dts=%d wrap=%j',
fileInfo.path, src.inner.tracks,
track.duration.toFixed(2),
track.firstDTS,
Expand Down Expand Up @@ -286,9 +288,14 @@ MixFilterClip.prototype.getDTSRange = function(){
filteredSrc = that.inner.sources;
}

_.each(filteredSrc,function(s) {
_.every(filteredSrc,function(s) {
var range = s.getDTSRange();
retVal.mergeWith(range);
if(range.valid) {
retVal.mergeWith(range);
} else {
retVal = range;
}
return retVal.valid;
});

//that.logger.debug('getDTSRange. %j', retVal);
Expand Down
16 changes: 9 additions & 7 deletions lib/playlistGenerator/Playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ Playlist.prototype.doValidate = function playlist_doValidate(opts) {

if(_.some(that.inner.clipTimes, function(clipTime,index){
if( index > 0 ){
return that.inner.clipTimes[index-1] + that.inner.durations[index-1] > that.inner.clipTimes[index];
return that.inner.clipTimes[index] > 0 && that.inner.clipTimes[index-1] + that.inner.durations[index-1] > that.inner.clipTimes[index];
}
return false;
})) {
Expand Down Expand Up @@ -348,11 +348,6 @@ var calcClipStartTimeAndDuration = function(index){

if( that.inner.clipTimes[index].value != retVal.min) {
that.inner.clipTimes[index].value = retVal.min;
that.logger.info("Recalculate Offsets And Duration(%d). Set clipTime: %s (%d). duration: %d",
index,
new Date(that.inner.clipTimes[index]),
that.inner.clipTimes[index],
that.inner.durations[index]);

// special case for first clip
if (index === 0) {
Expand All @@ -361,6 +356,13 @@ var calcClipStartTimeAndDuration = function(index){
}
}
}

that.logger.info("Recalculate Offsets And Duration(%d). Set clipTime: %s (%d). duration: %d",
index,
new Date(that.inner.clipTimes[index]),
that.inner.clipTimes[index],
that.inner.durations[index]);

return retVal;
};

Expand Down Expand Up @@ -538,7 +540,7 @@ Playlist.prototype.toJSON = function() {

// durations can have 0 values during transition period
// when some sequences have emptied their clip[0] while others not.
if(obj.durations.length && obj.durations[0] <= 0) {
if(obj.durations.length > 0) {
obj.durations = _.filter(obj.durations, function (d, index) {
return d > 0;
});
Expand Down
4 changes: 4 additions & 0 deletions lib/playlistGenerator/PlaylistGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,10 @@ PlaylistGenerator.prototype.doValidate = function() {
return this.playlistImp.doValidate();
};

PlaylistGenerator.prototype.validate = function() {
return this.playlistImp.validate();
};

PlaylistGenerator.prototype.checkFileExists = function(fileName){
return this.playlistImp.checkFileExists(fileName);
};
Expand Down

0 comments on commit cb774d2

Please sign in to comment.