-
Notifications
You must be signed in to change notification settings - Fork 344
/
Copy pathqunit-iso-creation.js
37 lines (33 loc) · 1.3 KB
/
qunit-iso-creation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
QUnit.module("File Creation");
QUnit.test("addSample and segmentation", function( assert ) {
var timeout = window.setTimeout(function() { assert.ok(false, "Timeout"); QUnit.start(); }, TIMEOUT_MS);
var f = MP4Box.createFile();
f.onSegment = function(id, user, buffer, sampleNum) {
window.clearTimeout(timeout);
console.log("Received segment for track "+id);
assert.ok(true, "Segment received");
}
var track_id = f.addTrack();
f.setSegmentOptions(track_id, null, { nbSamples: 2 } );
f.initializeSegmentation();
f.start();
f.addSample(track_id, new Uint8Array(100));
f.addSample(track_id, new Uint8Array(100));
});
QUnit.test("addSample and file save", function( assert ) {
var f = MP4Box.createFile();
var track_id = f.addTrack();
f.addSample(track_id, new Uint8Array(100));
f.addSample(track_id, new Uint8Array(100));
f.save("test.mp4");
assert.ok(true, "File created");
});
QUnit.test("Create simple stpp track and save file", function( assert ) {
Log.setLogLevel(Log.debug);
var f = MP4Box.createFile();
var track_id = f.addTrack({ type: "stpp", hdlr: "subt", namespace: "mynamespace"});
f.addSample(track_id, (new TextEncoder("utf8").encode("<xml></xml>")));
f.addSample(track_id, (new TextEncoder("utf8").encode("<xml></xml>")));
f.save("stpp-track.mp4");
assert.ok(true, "File created");
});