Skip to content

Commit

Permalink
Metrics Reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
davemevans committed Jan 29, 2016
1 parent 2fb8916 commit e9ac320
Show file tree
Hide file tree
Showing 51 changed files with 2,769 additions and 336 deletions.
1 change: 1 addition & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@
"Caster",
"TextTrackCue",
"HTMLMediaElement",
"MediaError",
"cea608parser"]
}
41 changes: 37 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ module.exports = function (grunt) {
'build/temp/dash.protection.min.js': 'build/temp/dash.protection.debug.js'
}
},

build_reporting: {
options: {
sourceMapIn: 'build/temp/dash.reporting.debug.js.map'
},
files: {
'build/temp/dash.reporting.min.js': 'build/temp/dash.reporting.debug.js'
}
},

build_all: {
options: {
sourceMapIn: 'build/temp/dash.all.debug.js.map'
Expand All @@ -69,8 +79,10 @@ module.exports = function (grunt) {
'dash.mediaplayer.min.js', 'dash.mediaplayer.min.js.map',
'dash.protection.min.js', 'dash.protection.min.js.map',
'dash.all.debug.js', 'dash.all.debug.js.map',
'dash.reporting.min.js', 'dash.reporting.min.js.map',
'dash.mediaplayer.debug.js', 'dash.mediaplayer.debug.js.map',
'dash.protection.debug.js', 'dash.protection.debug.js.map'
'dash.protection.debug.js', 'dash.protection.debug.js.map',
'dash.reporting.debug.js', 'dash.reporting.debug.js.map'
],
dest: 'dist/',
filter: 'isFile'
Expand All @@ -94,6 +106,12 @@ module.exports = function (grunt) {
files: {
'build/temp/dash.all.debug.js.map': ['build/temp/dash.all.debug.js']
}
},
reporting: {
options: {},
files: {
'build/temp/dash.reporting.debug.js.map': ['build/temp/dash.reporting.debug.js']
}
}
},
browserify: {
Expand Down Expand Up @@ -127,6 +145,21 @@ module.exports = function (grunt) {
transform: ['babelify']
}
},
reporting: {
files: {
'build/temp/dash.reporting.debug.js': ['src/streaming/metrics/MetricsReporting.js']
},
options: {
browserifyOptions: {
debug: true,
standalone: 'MetricsReporting'
},
plugin: [
['browserify-derequire']
],
transform: ['babelify']
}
},
all: {
files: {
'build/temp/dash.all.debug.js': ['src/All.js']
Expand All @@ -150,7 +183,7 @@ module.exports = function (grunt) {
watch: true,
keepAlive: true,
browserifyOptions: {
debug:true
debug: true
},
plugin: [
['browserify-derequire']
Expand Down Expand Up @@ -189,11 +222,11 @@ module.exports = function (grunt) {

require('load-grunt-tasks')(grunt);
grunt.registerTask('default', ['dist', 'test']);
grunt.registerTask('dist', ['clean', 'jshint', 'jscs', 'browserify:mediaplayer' , 'browserify:protection', 'browserify:all', 'minimize', 'copy:dist']);
grunt.registerTask('dist', ['clean', 'jshint', 'jscs', 'browserify:mediaplayer' , 'browserify:protection', 'browserify:reporting', 'browserify:all', 'minimize', 'copy:dist']);
grunt.registerTask('minimize', ['exorcise', 'uglify']);
grunt.registerTask('test', ['mocha_istanbul:test']);
grunt.registerTask('watch', ['browserify:watch']);
grunt.registerTask('release', ['default', 'jsdoc']);
grunt.registerTask('debug', ['clean', 'browserify:all', 'exorcise:all', 'copy:dist']);

};
};
46 changes: 23 additions & 23 deletions contrib/webmjs/app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,34 +180,34 @@ app.controller('DashController', function($scope, Sources, Notes, Contributors,

requestWindow = Requests
.slice(-20)
.filter(function(req){return req.responsecode >= 200 && req.responsecode < 300 && !!req.mediaduration && req.type === "Media Segment" && req.stream === type;})
.filter(function(req){return req.responsecode >= 200 && req.responsecode < 300 && !!req._mediaduration && req.type === "MediaSegment" && req._stream === type;})
.slice(-4);
if (requestWindow.length > 0) {

latencyTimes = requestWindow.map(function (req){ return Math.abs(req.tresponse.getTime() - req.trequest.getTime()) / 1000;});

movingLatency[type] = {
average: latencyTimes.reduce(function(l, r) {return l + r;}) / latencyTimes.length,
high: latencyTimes.reduce(function(l, r) {return l < r ? r : l;}),
low: latencyTimes.reduce(function(l, r) {return l < r ? l : r;}),
average: latencyTimes.reduce(function(l, r) {return l + r;}) / latencyTimes.length,
high: latencyTimes.reduce(function(l, r) {return l < r ? r : l;}),
low: latencyTimes.reduce(function(l, r) {return l < r ? l : r;}),
count: latencyTimes.length
};

downloadTimes = requestWindow.map(function (req){ return Math.abs(req.tfinish.getTime() - req.tresponse.getTime()) / 1000;});
downloadTimes = requestWindow.map(function (req){ return Math.abs(req._tfinish.getTime() - req.tresponse.getTime()) / 1000;});

movingDownload[type] = {
average: downloadTimes.reduce(function(l, r) {return l + r;}) / downloadTimes.length,
high: downloadTimes.reduce(function(l, r) {return l < r ? r : l;}),
low: downloadTimes.reduce(function(l, r) {return l < r ? l : r;}),
average: downloadTimes.reduce(function(l, r) {return l + r;}) / downloadTimes.length,
high: downloadTimes.reduce(function(l, r) {return l < r ? r : l;}),
low: downloadTimes.reduce(function(l, r) {return l < r ? l : r;}),
count: downloadTimes.length
};

durationTimes = requestWindow.map(function (req){ return req.mediaduration;});
durationTimes = requestWindow.map(function (req){ return req._mediaduration;});

movingRatio[type] = {
average: (durationTimes.reduce(function(l, r) {return l + r;}) / downloadTimes.length) / movingDownload[type].average,
high: durationTimes.reduce(function(l, r) {return l < r ? r : l;}) / movingDownload[type].low,
low: durationTimes.reduce(function(l, r) {return l < r ? l : r;}) / movingDownload[type].high,
average: (durationTimes.reduce(function(l, r) {return l + r;}) / downloadTimes.length) / movingDownload[type].average,
high: durationTimes.reduce(function(l, r) {return l < r ? r : l;}) / movingDownload[type].low,
low: durationTimes.reduce(function(l, r) {return l < r ? l : r;}) / movingDownload[type].high,
count: durationTimes.length
};
}
Expand All @@ -232,7 +232,7 @@ app.controller('DashController', function($scope, Sources, Notes, Contributors,
numBitratesValue = metricsExt.getMaxIndexForBufferType(type);

if (bufferLevel !== null) {
bufferLengthValue = bufferLevel.level.toPrecision(5);
bufferLengthValue = bufferLevel.toPrecision(5);
}

if (droppedFramesMetrics !== null) {
Expand Down Expand Up @@ -535,28 +535,28 @@ app.controller('DashController', function($scope, Sources, Notes, Contributors,
}

// Get initial stream if it was passed in.
var paramUrl = null;
var paramUrl = null;

if (vars && vars.hasOwnProperty("url")) {
paramUrl = vars.url;
paramUrl = vars.url;
}

if (vars && vars.hasOwnProperty("mpd")) {
paramUrl = vars.mpd;
paramUrl = vars.mpd;
}

if (paramUrl !== null) {
var startPlayback = true;
$scope.selectedItem = {};
var startPlayback = true;

$scope.selectedItem = {};
$scope.selectedItem.url = paramUrl;

if (vars.hasOwnProperty("autoplay")) {
startPlayback = (vars.autoplay === 'true');
startPlayback = (vars.autoplay === 'true');
}

if (startPlayback) {
$scope.doLoad();
}
if (startPlayback) {
$scope.doLoad();
}
}
});
58 changes: 32 additions & 26 deletions samples/dash-if-reference-player/app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,23 @@ app.controller('DashController', function($scope, Sources, Notes, Contributors,

$scope.getVideoTreeMetrics = function () {
var metrics = player.getMetricsFor("video");
$scope.videoMetrics = converter.toTreeViewDataSource(metrics);
if (metrics) {
$scope.videoMetrics = converter.toTreeViewDataSource(metrics);
}
}

$scope.getAudioTreeMetrics = function () {
var metrics = player.getMetricsFor("audio");
$scope.audioMetrics = converter.toTreeViewDataSource(metrics);
if (metrics) {
$scope.audioMetrics = converter.toTreeViewDataSource(metrics);
}
}

$scope.getStreamTreeMetrics = function () {
var metrics = player.getMetricsFor("stream");
$scope.streamMetrics = converter.toTreeViewDataSource(metrics);
if (metrics) {
$scope.streamMetrics = converter.toTreeViewDataSource(metrics);
}
}

// from: https://gist.github.com/siongui/4969449
Expand Down Expand Up @@ -189,34 +195,34 @@ app.controller('DashController', function($scope, Sources, Notes, Contributors,

requestWindow = Requests
.slice(-20)
.filter(function(req){return req.responsecode >= 200 && req.responsecode < 300 && !!req.mediaduration && req.type === "Media Segment" && req.stream === type;})
.filter(function(req){return req.responsecode >= 200 && req.responsecode < 300 && !!req._mediaduration && req.type === "MediaSegment" && req._stream === type;})
.slice(-4);
if (requestWindow.length > 0) {

latencyTimes = requestWindow.map(function (req){ return Math.abs(req.tresponse.getTime() - req.trequest.getTime()) / 1000;});

movingLatency[type] = {
average: latencyTimes.reduce(function(l, r) {return l + r;}) / latencyTimes.length,
high: latencyTimes.reduce(function(l, r) {return l < r ? r : l;}),
low: latencyTimes.reduce(function(l, r) {return l < r ? l : r;}),
average: latencyTimes.reduce(function(l, r) {return l + r;}) / latencyTimes.length,
high: latencyTimes.reduce(function(l, r) {return l < r ? r : l;}),
low: latencyTimes.reduce(function(l, r) {return l < r ? l : r;}),
count: latencyTimes.length
};

downloadTimes = requestWindow.map(function (req){ return Math.abs(req.tfinish.getTime() - req.tresponse.getTime()) / 1000;});
downloadTimes = requestWindow.map(function (req){ return Math.abs(req._tfinish.getTime() - req.tresponse.getTime()) / 1000;});

movingDownload[type] = {
average: downloadTimes.reduce(function(l, r) {return l + r;}) / downloadTimes.length,
high: downloadTimes.reduce(function(l, r) {return l < r ? r : l;}),
low: downloadTimes.reduce(function(l, r) {return l < r ? l : r;}),
average: downloadTimes.reduce(function(l, r) {return l + r;}) / downloadTimes.length,
high: downloadTimes.reduce(function(l, r) {return l < r ? r : l;}),
low: downloadTimes.reduce(function(l, r) {return l < r ? l : r;}),
count: downloadTimes.length
};

durationTimes = requestWindow.map(function (req){ return req.mediaduration;});
durationTimes = requestWindow.map(function (req){ return req._mediaduration;});

movingRatio[type] = {
average: (durationTimes.reduce(function(l, r) {return l + r;}) / downloadTimes.length) / movingDownload[type].average,
high: durationTimes.reduce(function(l, r) {return l < r ? r : l;}) / movingDownload[type].low,
low: durationTimes.reduce(function(l, r) {return l < r ? l : r;}) / movingDownload[type].high,
average: (durationTimes.reduce(function(l, r) {return l + r;}) / downloadTimes.length) / movingDownload[type].average,
high: durationTimes.reduce(function(l, r) {return l < r ? r : l;}) / movingDownload[type].low,
low: durationTimes.reduce(function(l, r) {return l < r ? l : r;}) / movingDownload[type].high,
count: durationTimes.length
};
}
Expand Down Expand Up @@ -244,7 +250,7 @@ app.controller('DashController', function($scope, Sources, Notes, Contributors,
numBitratesValue = metricsExt.getMaxIndexForBufferType(type, streamIdx);

if (bufferLevel !== null) {
bufferLengthValue = bufferLevel.level.toPrecision(5);
bufferLengthValue = bufferLevel.toPrecision(5);
}

if (droppedFramesMetrics !== null) {
Expand Down Expand Up @@ -699,28 +705,28 @@ app.controller('DashController', function($scope, Sources, Notes, Contributors,
}

// Get initial stream if it was passed in.
var paramUrl = null;
var paramUrl = null;

if (vars && vars.hasOwnProperty("url")) {
paramUrl = vars.url;
paramUrl = vars.url;
}

if (vars && vars.hasOwnProperty("mpd")) {
paramUrl = vars.mpd;
paramUrl = vars.mpd;
}

if (paramUrl !== null) {
var startPlayback = true;
$scope.selectedItem = {};
var startPlayback = true;

$scope.selectedItem = {};
$scope.selectedItem.url = paramUrl;

if (vars.hasOwnProperty("autoplay")) {
startPlayback = (vars.autoplay === 'true');
startPlayback = (vars.autoplay === 'true');
}

if (startPlayback) {
$scope.doLoad();
}
if (startPlayback) {
$scope.doLoad();
}
}
});
Loading

0 comments on commit e9ac320

Please sign in to comment.