-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"type": "commonjs" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import {Buffer} from "buffer"; | ||
import {expect} from "chai"; | ||
import {trun} from "@isomp4/box-moof"; | ||
|
||
/* eslint-disable array-element-newline */ | ||
|
||
const goodData = Buffer.from([ | ||
0x00, 0x00, 0x00, 0x14, // size: 20 | ||
0x74, 0x72, 0x75, 0x6E, // type: trun | ||
0x00, 0x00, 0x00, 0x01, // version and flags: 0x0 and 0x1 (dataOffset present) | ||
0x00, 0x00, 0x00, 0x01, // sample count: 1 | ||
0x00, 0x00, 0x00, 0x68, // dataOffset: 104 | ||
]); | ||
|
||
/* eslint-enable array-element-newline */ | ||
|
||
function checkGoodData(data: Buffer) { | ||
const result = trun.decode(data); | ||
if (typeof result === "number") { | ||
expect.fail("failed with required bytes: " + result); | ||
return; | ||
} | ||
expect(result.size).eq(20); | ||
expect(result.size).eq(trun.decodedBytes); // no children | ||
expect(result.type).eq("trun"); | ||
expect(result.samples.length).eq(1); | ||
expect(result.samples[0].duration).eq(undefined); | ||
expect(result.samples[0].size).eq(undefined); | ||
expect(result.samples[0].flags).eq(undefined); | ||
expect(result.samples[0].compositionTimeOffset).eq(undefined); | ||
} | ||
|
||
describe("trun", () => { | ||
// it("should fail to decode bad data (6 bytes)", () => { | ||
// const result = trun.decode(badData6); | ||
// expect(result).to.be.a("number"); | ||
// expect(result).to.be.gt(badData6.length); | ||
// }); | ||
// it("should fail to decode bad data (8 bytes)", () => { | ||
// const result = ftyp.decode(badData8); | ||
// expect(result).to.be.a("number"); | ||
// expect(result).to.be.gt(badData8.length); | ||
// }); | ||
// it("should fail to decode bad data (12 bytes)", () => { | ||
// const result = ftyp.decode(badData12); | ||
// expect(result).to.be.a("number"); | ||
// expect(result).to.be.gt(badData12.length); | ||
// }); | ||
// it("should fail to decode bad data (22 bytes)", () => { | ||
// const result = ftyp.decode(badData22); | ||
// expect(result).to.be.a("number"); | ||
// expect(result).to.be.gt(badData22.length); | ||
// }); | ||
it("should decode good data (20 bytes)", () => { | ||
checkGoodData(goodData); | ||
}); | ||
// it("should not parse extra data (36 bytes)", () => { | ||
// checkGoodData(moreData); | ||
// }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "../../../tsconfig.test.json", | ||
"compilerOptions": { | ||
"outDir": "" | ||
}, | ||
"references": [ | ||
{ "path": "../src" } | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"files": [], | ||
"references": [ | ||
{ "path": "src" } | ||
{ "path": "src" }, | ||
{ "path": "test" } | ||
] | ||
} |