a02c09db by David LaPalomento

Fix up dist production in Gruntfile and cleanup jshint in test cases

Explicitly list out source files so they are concatenated in the correct order in the final build.
1 parent dd4862c9
......@@ -20,7 +20,19 @@ module.exports = function(grunt) {
stripBanners: true
},
dist: {
src: ['src/*.js'],
src: ['src/video-js-hls.js',
'src/flv-tag.js',
'src/exp-golomb.js',
'src/h264-stream.js',
'src/aac-stream.js',
'src/segment-parser.js',
'src/segment-controller.js',
'src/m3u8/m3u8.js',
'src/m3u8/m3u8-tag-types.js',
'src/m3u8/m3u8-parser.js',
'src/manifest-controller.js',
'src/segment-controller.js',
'src/hls-playback-controller.js'],
dest: 'dist/videojs.hls.js'
},
},
......@@ -53,7 +65,7 @@ module.exports = function(grunt) {
options: {
jshintrc: 'test/.jshintrc'
},
src: ['test/**/*.js', '!test/tsSegment.js']
src: ['test/**/*.js', '!test/tsSegment.js', '!test/fixtures/*.js']
},
},
watch: {
......
......@@ -21,8 +21,7 @@
*/
var
buffer,
expGolomb,
view;
expGolomb;
module('Exponential Golomb coding');
......
......@@ -6,4 +6,4 @@ window.brightcove_playlist_data = '#EXTM3U\n'+
'#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=440000,RESOLUTION=396x224\n'+
'http://c.brightcove.com/services/mobile/streaming/index/rendition.m3u8?assetId=1824686593001&videoId=1824650741001\n'+
'#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1928000,RESOLUTION=960x540\n'+
'http://c.brightcove.com/services/mobile/streaming/index/rendition.m3u8?assetId=1824687660001&videoId=1824650741001'
\ No newline at end of file
'http://c.brightcove.com/services/mobile/streaming/index/rendition.m3u8?assetId=1824687660001&videoId=1824650741001';
......
(function (window) {
(function(window) {
/*
======== A Handy Little QUnit Reference ========
http://api.qunitjs.com/
......@@ -34,22 +34,23 @@
testScriptTag,
asciiFromBytes,
testScriptString,
testScriptEcmaArray;
testScriptEcmaArray,
testNalUnit;
module('environment');
test('is sane', function () {
test('is sane', function() {
expect(1);
ok(true);
});
module('segment parser', {
setup: function () {
setup: function() {
parser = new window.videojs.hls.SegmentParser();
}
});
test('creates an flv header', function () {
test('creates an flv header', function() {
var header = Array.prototype.slice.call(parser.getFlvHeader());
ok(header, 'the header is truthy');
equal(9 + 4, header.length, 'the header length is correct');
......@@ -60,17 +61,13 @@
deepEqual(expectedHeader, header, 'the rest of the header is correct');
});
test('parses the first bipbop segment', function () {
var tag, bytes, i;
test('parses the first bipbop segment', function() {
parser.parseSegmentBinaryData(window.bcSegment);
ok(parser.tagsAvailable(), 'tags are available');
console.log('h264 tags:', parser.stats.h264Tags(),
'aac tags:', parser.stats.aacTags());
});
testAudioTag = function (tag) {
testAudioTag = function(tag) {
var
byte = tag.bytes[11],
format = (byte & 0xF0) >>> 4,
......@@ -93,12 +90,10 @@
frameType = (byte & 0xF0) >>> 4,
codecId = byte & 0x0F,
packetType = tag.bytes[12],
compositionTime = (tag.view.getInt32(13) & 0xFFFFFF00) >> 8,
nalHeader;
compositionTime = (tag.view.getInt32(13) & 0xFFFFFF00) >> 8;
// payload starts at tag.bytes[16]
// XXX: I'm not sure that frame types 3-5 are invalid
ok(frameType === 1 || frameType === 2,
'the frame type should be valid');
......@@ -120,10 +115,10 @@
}
};
testNalUnit = function (bytes) {
testNalUnit = function(bytes) {
var
nalHeader = bytes[0],
unitType = nalHeader & 0x1F;
nalHeader = bytes[0];
// unitType = nalHeader & 0x1F;
equal(0, (nalHeader & 0x80) >>> 7, 'the first bit is always 0');
// equal(90, (nalHeader & 0x60) >>> 5, 'the NAL reference indicator is something');
......@@ -132,7 +127,7 @@
};
asciiFromBytes = function (bytes) {
asciiFromBytes = function(bytes) {
var
string = [],
i = bytes.byteLength;
......@@ -143,12 +138,11 @@
return string.join('');
};
testScriptString = function (tag, offset, expected) {
testScriptString = function(tag, offset, expected) {
var
type = tag.bytes[offset],
stringLength = tag.view.getUint16(offset + 1),
string,
i = expected.length;
string;
equal(2, type, 'the script element is of string type');
equal(stringLength, expected.length, 'the script string length is correct');
......@@ -157,7 +151,7 @@
equal(expected, string, 'the string value is "' + expected + '"');
};
testScriptEcmaArray = function (tag, start) {
testScriptEcmaArray = function(tag, start) {
var
numItems = tag.view.getUint32(start),
i = numItems,
......@@ -191,7 +185,7 @@
equal(tag.bytes[offset + 2], 9, 'the property array terminator is valid');
};
testScriptTag = function (tag) {
testScriptTag = function(tag) {
testScriptString(tag, 11, 'onMetaData');
// the onMetaData object is stored as an 'ecma array', an array with non-
......@@ -200,7 +194,7 @@
testScriptEcmaArray(tag, 25);
};
test('the flv tags are well-formed', function () {
test('the flv tags are well-formed', function() {
var
tag,
byte,
......@@ -242,21 +236,21 @@
*/
module('m3u8 parser', {
setup: function () {
setup: function() {
m3u8parser = new window.videojs.hls.M3U8Parser();
}
});
test('should create my parser', function () {
ok(m3u8parser != undefined);
test('should create my parser', function() {
ok(m3u8parser !== undefined);
});
test('should successfully parse manifest data', function () {
test('should successfully parse manifest data', function() {
var parsedData = m3u8parser.parse(window.playlistData);
ok(parsedData);
});
test('test for expected results', function () {
test('test for expected results', function() {
var data = m3u8parser.parse(window.playlistData);
notEqual(data, null, 'data is not NULL');
......@@ -273,12 +267,12 @@
});
module('brightcove playlist', {
setup: function () {
setup: function() {
m3u8parser = new window.videojs.hls.M3U8Parser();
}
});
test('should parse a brightcove manifest data', function () {
test('should parse a brightcove manifest data', function() {
var data = m3u8parser.parse(window.brightcove_playlist_data);
ok(data);
......@@ -292,23 +286,23 @@
);
module('manifest controller', {
setup: function () {
setup: function() {
manifestController = new window.videojs.hls.ManifestController();
this.vjsget = vjs.get;
vjs.get = function (url, success, error) {
this.vjsget = window.videojs.get;
window.videojs.get = function(url, success) {
success(window.brightcove_playlist_data);
};
},
teardown: function () {
vjs.get = this.vjsget;
teardown: function() {
window.videojs.get = this.vjsget;
}
});
test('should create', function () {
test('should create', function() {
ok(manifestController);
});
test('should return a parsed object', function () {
test('should return a parsed object', function() {
var data = manifestController.parseManifest(window.brightcove_playlist_data);
ok(data);
......@@ -319,33 +313,31 @@
equal(data.playlistItems[0].resolution.height, 224, 'First rendition index resolution height is correct');
});
test('should get a manifest from hermes', function () {
test('should get a manifest from hermes', function() {
manifestController.loadManifest('http://example.com/16x9-master.m3u8',
function (responseData) {
function(responseData) {
ok(responseData);
},
function (errorData) {
function() {
ok(false, 'does not error');
},
function (updateData) {
});
function() {});
});
module('segment controller', {
setup: function () {
setup: function() {
segmentController = new window.videojs.hls.SegmentController();
this.vjsget = vjs.get;
vjs.get = function (url, success, error) {
console.log('load segment url', url);
this.vjsget = window.videojs.get;
window.videojs.get = function(url, success) {
success(window.bcSegment);
};
},
teardown: function () {
vjs.get = this.vjsget;
teardown: function() {
window.videojs.get = this.vjsget;
}
});
test('bandwidth calulation test', function () {
test('bandwidth calulation test', function() {
var
multiSecondData = segmentController.calculateThroughput(10000, 1000, 2000),
subSecondData = segmentController.calculateThroughput(10000, 1000, 1500);
......