Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add grunt tasks and Dash tests #10

Merged
merged 4 commits into from
May 17, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@
## Node.js
#################


node_modules

npm-debug.log

#################
## Grunt
#################


.grunt
_SpecRunner.html
reports


#################
## Eclipse
#################
Expand Down
25 changes: 25 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"noarg": true,
"noempty": true,
"latedef": true,
"undef": true,
"unused": true,
"strict": false,
"trailing": true,
"node": true,
"jquery" : true,
"devel" : true,
"browser": true,
"loopfunc" : true,
"predef" : [
"dijon",
"Q",
"ObjectIron",
"X2JS",
"kendo",
"utils",
"MediaPlayer",
"Dash",
"WebKitMediaSource",
"MediaSource"]
}
70 changes: 70 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
module.exports = function(grunt) {
grunt.initConfig({
connect: {
default_options: {}
},
watch: {},
jshint: {
all: ["app/js/*/**/*.js"],
options: {
jshintrc: ".jshintrc"
}
},
uglify : {
dist : {
files: {
"dash.min.js" : [
"app/js/streaming/MediaPlayer.js",
"app/js/streaming/Context.js",
"app/js/dash/Dash.js",
"app/js/dash/DashContext.js",
"app/js/*/**/*.js"],
}
}
},
jasmine: {
tests: {
src: [
"app/js/streaming/MediaPlayer.js",
"app/js/streaming/Context.js",
"app/js/dash/Dash.js",
"app/js/dash/DashContext.js",
"app/js/*/**/*.js"],

options: {
host: 'http://127.0.0.1:8000/',
specs: [
'test/js/dash/ParserSuite.js',
'test/js/dash/FragmentExtensionsSuite.js',
'test/js/dash/DashMetricsExtensionsSuite.js',
'test/js/dash/DashManifestExtensionsSuite.js'],
vendor: [
"app/lib/jquery/js/jquery-1.8.3.min.js",
"app/lib/jquery/js/jquery-ui-1.9.2.custom.min.js",
"app/lib/q.min.js",
"app/lib/xml2json.js",
"app/lib/objectiron.js",
"app/lib/dijon.js",
"test/js/utils/MPDfiles.js"],
template : require('grunt-template-jasmine-istanbul'),
templateOptions: {
coverage: 'reports/coverage.json',
report: 'reports/coverage'},
junit: {
path: grunt.option('jsunit-path'),
consolidate: true}
}
}
}
});

// Require needed grunt-modules
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jasmine');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');

// Define tasks
grunt.registerTask('default', ['uglify', 'connect', 'jasmine', 'jshint']);
};
8 changes: 4 additions & 4 deletions app/js/dash/BaseURLExtensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ Dash.dependencies.BaseURLExtensions = function () {

request = new XMLHttpRequest();

request.onloadend = function (e) {
request.onloadend = function () {
if (!loaded) {
deferred.reject("Error loading initialization.");
}
Expand Down Expand Up @@ -247,7 +247,7 @@ Dash.dependencies.BaseURLExtensions = function () {
info.range.start = 0;
info.range.end = info.bytesToLoad;

request.onloadend = function (e) {
request.onloadend = function () {
if (!loaded) {
deferred.reject("Error finding initialization.");
}
Expand Down Expand Up @@ -331,7 +331,7 @@ Dash.dependencies.BaseURLExtensions = function () {
info.range.start = 0;
info.range.end = info.bytesLoaded + (size - bytesAvailable);

request.onloadend = function (e) {
request.onloadend = function () {
if (!loaded) {
deferred.reject("Error loading sidx.");
}
Expand Down Expand Up @@ -440,7 +440,7 @@ Dash.dependencies.BaseURLExtensions = function () {
info.range.end = parseFloat(parts[1]);
}

request.onloadend = function (e) {
request.onloadend = function () {
if (!loaded) {
deferred.reject("Error loading sidx.");
}
Expand Down
10 changes: 4 additions & 6 deletions app/js/dash/DashHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Dash.dependencies.DashHandler = function () {
request.range = theRange;
deferred.resolve(request);
},
function (err) {
function () {
//alert("Error loading initialization.");
self.errHandler.downloadError("Error loading initialization.");
}
Expand Down Expand Up @@ -245,8 +245,7 @@ Dash.dependencies.DashHandler = function () {

getSegmentsFromSource = function (representation) {
var url = representation.BaseURL,
range = null,
manifest = this.manifestModel.getValue();
range = null;

if (representation.hasOwnProperty("SegmentBase")) {
if (representation.SegmentBase.hasOwnProperty("indexRange")) {
Expand Down Expand Up @@ -286,8 +285,7 @@ Dash.dependencies.DashHandler = function () {
frag,
ft,
fd,
i,
len;
i;

if (segments && segments.length > 0) {
for (i = segments.length - 1; i >= 0; i--) {
Expand Down Expand Up @@ -595,7 +593,7 @@ Dash.dependencies.DashHandler = function () {

deferred.resolve(time);
}
)
);

return deferred.promise;
};
Expand Down
21 changes: 8 additions & 13 deletions app/js/dash/DashManifestExtensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Dash.dependencies.DashManifestExtensions.prototype = {
return Q.when(result);
},

getIsMain: function (adaptation) {
getIsMain: function (/*adaptation*/) {
"use strict";
// TODO : Check "Role" node.
// TODO : Use this somewhere.
Expand All @@ -122,8 +122,7 @@ Dash.dependencies.DashManifestExtensions.prototype = {

getDataForId: function (id, manifest) {
"use strict";
var self = this,
adaptations = manifest.Period_asArray[0].AdaptationSet_asArray,
var adaptations = manifest.Period_asArray[0].AdaptationSet_asArray,
i,
len;

Expand All @@ -138,17 +137,15 @@ Dash.dependencies.DashManifestExtensions.prototype = {

getDataForIndex: function (index, manifest) {
"use strict";
var self = this,
adaptations = manifest.Period_asArray[0].AdaptationSet_asArray;
var adaptations = manifest.Period_asArray[0].AdaptationSet_asArray;

return Q.when(adaptations[index]);
},

getDataIndex: function (data, manifest) {
"use strict";

var self = this,
adaptations = manifest.Period_asArray[0].AdaptationSet_asArray,
var adaptations = manifest.Period_asArray[0].AdaptationSet_asArray,
i,
len;

Expand Down Expand Up @@ -299,7 +296,9 @@ Dash.dependencies.DashManifestExtensions.prototype = {
fStart = 1,
fDuration,
fTimescale = 1,
representation;
representation,
list = null,
template = null;

// We don't really care what representation we use; they should all start at the same time.
// Just grab the first representation; if this isn't there, we have bigger problems.
Expand Down Expand Up @@ -349,11 +348,7 @@ Dash.dependencies.DashManifestExtensions.prototype = {
liveOffset = 0,
now = new Date(),
start = manifest.availabilityStartTime,
end,
representation,
list,
template,
timeline;
end;

self.getLiveOffset(manifest).then(
function (delay) {
Expand Down
8 changes: 1 addition & 7 deletions app/js/dash/FragmentExtensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,10 @@ Dash.dependencies.FragmentExtensions = function () {
parseSIDX = function (ab) {
var d = new DataView(ab),
pos = 0,
sidxEnd,
version,
timescale,
earliest_presentation_time,
first_offset,
reference_count,
references = [],
i,
ref_size,
ref_dur,
type,
size,
charCode;
Expand Down Expand Up @@ -132,7 +126,7 @@ Dash.dependencies.FragmentExtensions = function () {

url = media;

request.onloadend = function (e) {
request.onloadend = function () {
if (!loaded) {
errorStr = "Error loading fragment: " + url;
deferred.reject(errorStr);
Expand Down
8 changes: 4 additions & 4 deletions app/js/dash/SonyExtensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ Dash.dependencies.SonyExtensions = function () {

request = new XMLHttpRequest();

request.onloadend = function (e) {
request.onloadend = function () {
if (!loaded) {
deferred.reject("Error loading initialization.");
}
Expand Down Expand Up @@ -242,7 +242,7 @@ Dash.dependencies.SonyExtensions = function () {
range.start = 0;
range.end = bytesToLoad;

request.onloadend = function (e) {
request.onloadend = function () {
if (!loaded) {
deferred.reject("Error finding initialization.");
}
Expand Down Expand Up @@ -335,7 +335,7 @@ Dash.dependencies.SonyExtensions = function () {
range.start = 0;
range.end = bytesLoaded + (size - bytesAvailable);

request.onloadend = function (e) {
request.onloadend = function () {
if (!loaded) {
deferred.reject("Error loading sidx.");
}
Expand Down Expand Up @@ -434,7 +434,7 @@ Dash.dependencies.SonyExtensions = function () {
range.end = parseFloat(parts[1]);
}

request.onloadend = function (e) {
request.onloadend = function () {
if (!loaded) {
deferred.reject("Error loading sidx.");
}
Expand Down
2 changes: 0 additions & 2 deletions app/js/streaming/AbrController.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ MediaPlayer.dependencies.AbrController = function () {
var self = this,
deferred = Q.defer(),
newQuality = 999,
ruleQuality,
rules,
i,
len,
funcs = [],
Expand Down
16 changes: 6 additions & 10 deletions app/js/streaming/BufferController.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ MediaPlayer.dependencies.BufferController = function () {
onTimer = null,
stalled = false,
liveOffset = -1,
liveStartTime = null,
isLiveStream = false,
liveInitialization = false,

Expand Down Expand Up @@ -174,8 +173,7 @@ MediaPlayer.dependencies.BufferController = function () {
},

onBytesLoaded = function (response) {
var self = this,
time = 0;
var self = this;

self.debug.log("Bytes finished loading.");

Expand All @@ -194,7 +192,7 @@ MediaPlayer.dependencies.BufferController = function () {
}

self.sourceBufferExt.append(buffer, data, self.videoModel).then(
function (appended) {
function (/*appended*/) {
self.debug.log("Append complete: " + buffer.buffered.length);
if (buffer.buffered.length > 0) {
var ranges = buffer.buffered,
Expand All @@ -218,7 +216,7 @@ MediaPlayer.dependencies.BufferController = function () {
);
},

onBytesError = function (error) {
onBytesError = function () {
if (state === LOADING) {
setState(READY);
}
Expand Down Expand Up @@ -256,8 +254,7 @@ MediaPlayer.dependencies.BufferController = function () {

loadNextFragment = function (quality) {
var promise,
self = this,
time = 0;
self = this;

if (dataChanged && !seeking) {
//time = self.videoModel.getCurrentTime();
Expand Down Expand Up @@ -361,7 +358,6 @@ MediaPlayer.dependencies.BufferController = function () {
newQuality,
representation = null,
now = new Date(),
segmentRequest,
currentVideoTime = self.videoModel.getCurrentTime(),
currentTime = getWorkingTime.call(self);

Expand Down Expand Up @@ -541,7 +537,7 @@ MediaPlayer.dependencies.BufferController = function () {
playingTime = time;
data = value;
}
)
);
}
);
} else {
Expand All @@ -565,7 +561,7 @@ MediaPlayer.dependencies.BufferController = function () {
minBufferTime = value;
},

clearMetrics: function (value) {
clearMetrics: function () {
var self = this;

if (type === null || type === "") {
Expand Down
Loading