Skip to content

Commit c89ce34

Browse files
committed
making karma test and qunit.html pass
1 parent 1620d53 commit c89ce34

14 files changed

+150
-147
lines changed

Gruntfile.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ module.exports = function(grunt) {
5656
'src/parsing/tfdt.js',
5757
'src/parsing/trun.js',
5858
'src/isofile.js',
59-
'src/box-print.js',
59+
'src/box-print.js',
6060
'src/mp4box.js'
6161
],
6262
dest: 'dist/<%= pkg.name %>.simple.js'
@@ -94,10 +94,10 @@ module.exports = function(grunt) {
9494
eqeqeq: false,
9595
asi: true,
9696
//verbose: true,
97-
loopfunc: true,
97+
loopfunc: true,
9898
eqnull: true,
99-
reporterOutput: "",
100-
globals: {
99+
reporterOutput: "",
100+
globals: {
101101
}
102102
}
103103
},

_config.yml

-1
This file was deleted.

karma.conf.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = function(config) {
1515
// client configuration
1616
client: {
1717
qunit: {
18-
testTimeout: 5000
18+
testTimeout: 20000
1919
}
2020
},
2121

@@ -93,7 +93,6 @@ module.exports = function(config) {
9393

9494
// start these browsers
9595
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
96-
//
9796
//browsers: ['Chrome', 'Firefox'],
9897
browsers: ['Chrome'],
9998

@@ -106,7 +105,7 @@ module.exports = function(config) {
106105
//browserDisconnectTolerance : 1, // default 0
107106
//browserNoActivityTimeout : 60000, //default 10000
108107
browserNoActivityTimeout: 30000,
109-
108+
110109
customLaunchers: {
111110
Chrome_travis_ci: {
112111
base: 'Chrome',
@@ -115,7 +114,7 @@ module.exports = function(config) {
115114
},
116115

117116
coverageReporter: {
118-
reporters: [
117+
reporters: [
119118
{ type: "lcov", dir: "coverage/" },
120119
{ type: 'text-summary' }
121120
]

package.json

+15-12
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,28 @@
2525
"license": "BSD-3-Clause",
2626
"devDependencies": {
2727
"blanket": "^1.2.3",
28-
"grunt": "^0.4.5",
29-
"grunt-bump": "^0.3.1",
28+
"grunt": "^1.0.4",
29+
"grunt-bump": "^0.8.0",
3030
"grunt-cli": "^1.2.0",
31-
"grunt-contrib-concat": "^0.5.0",
32-
"grunt-contrib-jshint": "^0.10.0",
33-
"grunt-contrib-qunit": "^0.5.2",
34-
"grunt-contrib-uglify": "^0.6.0",
35-
"grunt-contrib-watch": "^0.6.1",
36-
"grunt-karma": "^0.11.0",
31+
"grunt-contrib-concat": "^1.0.1",
32+
"grunt-contrib-jshint": "^2.1.0",
33+
"grunt-contrib-qunit": "^3.1.0",
34+
"grunt-contrib-uglify": "^4.0.1",
35+
"grunt-contrib-watch": "^1.1.0",
36+
"grunt-karma": "^3.0.2",
3737
"grunt-karma-coveralls": "^2.5.4",
38-
"karma": "^0.12.35",
39-
"karma-chrome-launcher": "^0.1.12",
40-
"karma-coverage": "^0.5.5",
41-
"karma-firefox-launcher": "^0.1.6",
38+
"karma": "^4.1.0",
39+
"karma-chrome-launcher": "^2.2.0",
40+
"karma-coverage": "^1.1.2",
41+
"karma-firefox-launcher": "^1.1.0",
4242
"karma-phantomjs-launcher": "^1.0.4",
4343
"karma-qunit": "^0.1.4",
4444
"qunitjs": "^1.23.0"
4545
},
4646
"scripts": {
4747
"test": "grunt test --verbose"
48+
},
49+
"dependencies": {
50+
"npm": "^6.9.0"
4851
}
4952
}

src/isofile-advanced-creation.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,13 @@ ISOFile.prototype.addTrack = function (_options) {
6363
var sample_description_entry = new BoxParser[options.type+"SampleEntry"]();
6464
sample_description_entry.data_reference_index = 1;
6565
var media_type = "";
66-
for (var i = 0; i < BoxParser.sampleEntryCodes.length; i++) {
67-
var code = BoxParser.sampleEntryCodes[i];
68-
if (code.types.indexOf(options.type) > -1) {
69-
media_type = code.prefix;
70-
break;
66+
for (var mediaType in BoxParser.sampleEntryCodes) {
67+
var codes = BoxParser.sampleEntryCodes[mediaType];
68+
for (var i = 0; i < codes.length; i++) {
69+
if (codes.indexOf(options.type) > -1) {
70+
media_type = mediaType;
71+
break;
72+
}
7173
}
7274
}
7375
switch(media_type) {

src/parsing/sampleentries/sampleentry.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ BoxParser.SampleEntry.prototype.parse = function(stream) {
1818
}
1919

2020
BoxParser.SampleEntry.prototype.parseDataAndRewind = function(stream) {
21-
this.parse(stream);
21+
this.parseHeader(stream);
22+
this.data = stream.readUint8Array(this.size - this.hdr_size);
2223
// restore the header size as if the sample entry header had not been parsed
2324
this.hdr_size -= 8;
2425
// rewinding

test/qunit-box-data.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ var boxtests = [
1212
compatible_brands: [ "avc1", "iso5", "dsms", "msix", "dash"]
1313
}
1414
},
15-
{
16-
url: mediaTestBaseUrl + "mp4/box/sidx.mp4",
15+
{
16+
url: mediaTestBaseUrl + "mp4/box/sidx.mp4",
1717
rangeStart: 1566,
1818
rangeSize: 152,
1919
boxname: "sidx",
@@ -27,79 +27,79 @@ var boxtests = [
2727
earliest_presentation_time: 0,
2828
first_offset: 0,
2929
references: [
30-
{
30+
{
3131
reference_type: 0,
3232
referenced_size: 776279,
3333
subsegment_duration: 224,
3434
starts_with_SAP: 1,
3535
SAP_type: 1,
3636
SAP_delta_time: 0
3737
},
38-
{
38+
{
3939
reference_type: 0,
4040
referenced_size: 298018,
4141
subsegment_duration: 110,
4242
starts_with_SAP: 1,
4343
SAP_type: 1,
4444
SAP_delta_time: 0
4545
},
46-
{
46+
{
4747
reference_type: 0,
4848
referenced_size: 151055,
4949
subsegment_duration: 62,
5050
starts_with_SAP: 1,
5151
SAP_type: 1,
5252
SAP_delta_time: 0
5353
},
54-
{
54+
{
5555
reference_type: 0,
5656
referenced_size: 583055,
5757
subsegment_duration: 130,
5858
starts_with_SAP: 1,
5959
SAP_type: 1,
6060
SAP_delta_time: 0
6161
},
62-
{
62+
{
6363
reference_type: 0,
6464
referenced_size: 310294,
6565
subsegment_duration: 45,
6666
starts_with_SAP: 1,
6767
SAP_type: 1,
6868
SAP_delta_time: 0
6969
},
70-
{
70+
{
7171
reference_type: 0,
7272
referenced_size: 353217,
7373
subsegment_duration: 50,
7474
starts_with_SAP: 1,
7575
SAP_type: 1,
7676
SAP_delta_time: 0
7777
},
78-
{
78+
{
7979
reference_type: 0,
8080
referenced_size: 229078,
8181
subsegment_duration: 37,
8282
starts_with_SAP: 1,
8383
SAP_type: 1,
8484
SAP_delta_time: 0
8585
},
86-
{
86+
{
8787
reference_type: 0,
8888
referenced_size: 685457,
8989
subsegment_duration: 114,
9090
starts_with_SAP: 1,
9191
SAP_type: 1,
9292
SAP_delta_time: 0
9393
},
94-
{
94+
{
9595
reference_type: 0,
9696
referenced_size: 746586,
9797
subsegment_duration: 250,
9898
starts_with_SAP: 1,
9999
SAP_type: 1,
100100
SAP_delta_time: 0
101101
},
102-
{
102+
{
103103
reference_type: 0,
104104
referenced_size: 228474,
105105
subsegment_duration: 231,
@@ -125,7 +125,7 @@ var boxtests = [
125125
timescale: 1,
126126
presentation_time_delta: 1,
127127
event_duration: 1,
128-
id: 1
128+
id: 1
129129
}
130130
}
131131
];

test/qunit-helper.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function checkBoxData(assert, box, data) {
4545
var dataentry = data[prop][i];
4646
assert.deepEqual(boxentry, dataentry, "Box property "+prop+", entry #"+i+" deep equality");
4747
}
48-
} else if (data[prop].byteLength) {
48+
} else if (data[prop] && data[prop].byteLength) {
4949
var uint8data = new Uint8Array(data[prop]);
5050
var uint8box = new Uint8Array(box[prop]);
5151
var equal = true;

test/qunit-iso-conformance.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function makeBoxParsingTest(fileIndex) {
2121
});
2222
}
2323

24-
/*
24+
/*
2525
var conformanceFiles = [];
2626
var xhr = new XMLHttpRequest();
2727
xhr.open('GET', 'iso-conformance-files.js', false);

test/qunit-iso-creation.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ QUnit.module("File Creation");
33
QUnit.test("addSample and segmentation", function( assert ) {
44
var timeout = window.setTimeout(function() { assert.ok(false, "Timeout"); QUnit.start(); }, TIMEOUT_MS);
55
var f = MP4Box.createFile();
6-
f.onSegment = function(id, user, buffer, sampleNum) {
6+
f.onSegment = function(id, user, buffer, sampleNum) {
77
window.clearTimeout(timeout);
88
console.log("Received segment for track "+id);
99
assert.ok(true, "Segment received");

test/qunit-media-data.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ var testFiles = [
5555
}
5656
/*,
5757
58-
{ // 12
58+
{ // 12
5959
desc: "File with negative CTS-DTS offsets",
6060
url: mediaTestBaseUrl + 'mp4/negctts.mp4'
6161
},
62-
{ // 13
62+
{ // 13
6363
desc: "File with no default flags in fragments",
6464
url: mediaTestBaseUrl + 'mp4/noFragsDefault.mp4'
6565
},
66-
{ // 14
66+
{ // 14
6767
desc: "File with negative CTS-DTS offsets and no default flags in fragments",
6868
url: mediaTestBaseUrl + 'mp4/negctts_noFragsDefault.mp4'
6969
}

test/qunit-mse-tests.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ QUnit.asyncTest( "Appending init segment", function( assert ) {
2121
function onInitAppended(e) {
2222
window.clearTimeout(timeout);
2323
assert.equal(ms.readyState, "open", "MSE opened after init append");
24-
QUnit.start();
24+
QUnit.start();
2525
}
2626

27-
mp4boxfile.onReady = function(info) {
27+
mp4boxfile.onReady = function(info) {
2828
track_id = info.tracks[0].id;
2929
mp4boxfile.setSegmentOptions(track_id, null, { nbSamples: 10, rapAlignement: true } );
3030
var initSegs = mp4boxfile.initializeSegmentation();
@@ -35,7 +35,7 @@ QUnit.asyncTest( "Appending init segment", function( assert ) {
3535
}
3636

3737
function onSourceOpen(e) {
38-
getFile(testFiles[index].url, function (buffer) {
38+
getFile(testFiles[index].url, function (buffer) {
3939
mp4boxfile.appendBuffer(buffer);
4040
});
4141
}

0 commit comments

Comments
 (0)