Skip to content

Commit

Permalink
Diagnostics calculate drift (#263)
Browse files Browse the repository at this point in the history
* Diagnostics calculate drift

* Diagnostics calculate drift - 1
  • Loading branch information
gadyaari authored Sep 27, 2016
1 parent 4bcf918 commit 664eb87
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
11 changes: 9 additions & 2 deletions lib/playlistGenerator/ConcatSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,8 @@ var checkClipStartTime = function(fileInfo){
// check for gaps, reorder etc.
ConcatSource.prototype.checkDiscontinuity = function (fileInfo,track) {
var that = this;

var firstDTS,discontinuity = false;
let diagDrift = { deltaPts : 0, deltaClock : 0 , refPts : 0, refEncoderDts : 0};

track.firstDTS = Math.ceil(track.firstDTS);

Expand Down Expand Up @@ -439,7 +439,14 @@ ConcatSource.prototype.checkDiscontinuity = function (fileInfo,track) {
}
firstDTS = that.inner.refPTS + dtsDistance(track.firstEncoderDTS, that.inner.refEncoderDTS,track.wrapEncoderDTS);
}

// Fill drift information for diagnostics purposes
diagDrift['deltaPts'] = track.firstDTS - that.inner.refPTS;
diagDrift['deltaClock'] = track.firstEncoderDTS - that.inner.refEncoderDTS;
diagDrift['refPts'] = that.inner.refPTS;
diagDrift['refEncoderDts'] = that.inner.refEncoderDTS;

that.emit(playlistUtils.ClipEvents.diagnosticsInfo, that, diagDrift);

checkOverlap.call(that,firstDTS,lastDTS);

if (timestampDiff < playlistConfig.maxChunkGapSize ) {
Expand Down
8 changes: 7 additions & 1 deletion lib/playlistGenerator/PlaylistGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ function PlaylistGenerator (entryObject) {
setPlayList.call(that,new Playlist(that.loggerInfo));
that.gapsCounter = 0;
that.reorderCounter = 0;

that.driftInfo = {};
}

util.inherits(PlaylistGenerator,EventEmitter);
Expand Down Expand Up @@ -404,6 +406,9 @@ PlaylistGenerator.prototype.handleEvent = function (type,arg) {
case playlistUtils.ClipEvents.modified:
that.isDirty = true;
break;
case playlistUtils.ClipEvents.diagnosticsInfo:
that.driftInfo = arguments[2];
break;
case playlistUtils.ClipEvents.diagnosticsAlert:
that.emit('diagnosticsAlert', arguments[2]);
break;
Expand All @@ -413,10 +418,11 @@ PlaylistGenerator.prototype.handleEvent = function (type,arg) {
// JSON.stringify callback
PlaylistGenerator.prototype.toJSON = function () {
var that = this;
var diag = {};//that.getDiagnostics();
var diag = {};
diag.playlistPath = that.playlistPath;
diag.gapsCounter = that.gapsCounter;
diag.config = that.playListLimits;
diag.drift = that.driftInfo;
return diag;
};

Expand Down
1 change: 1 addition & 0 deletions lib/playlistGenerator/playlistGen-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ module.exports.ClipEvents = {
// param 2 : object returned at humanReadablePass
humanReadablePass: 'humanReadablePass',
item_disposed: 'item_disposed',
diagnosticsInfo: 'diagnosticsInfo',
diagnosticsAlert: 'diagnosticsAlert'
};

Expand Down

0 comments on commit 664eb87

Please sign in to comment.