Skip to content

Function: readTenc() ​

ts
function readTenc(cursor): TrackEncryptionBox;

Defined in: readers/readTenc.ts:22

Read the tenc box (TrackEncryptionBox).

ISO/IEC 23001-7:2016 - 8.2

Parameters ​

cursor ​

IsoBoxReadCursor<IsoInt64>

The read cursor at the first byte after the box header

Returns ​

TrackEncryptionBox

A parsed TrackEncryptionBox

Example ​

ts
// A version 1 tenc box: size (49), type (tenc), version, flags, a reserved byte,
// the pattern 1:9, default_isProtected (1), default_Per_Sample_IV_Size (0),
// default_KID, default_constant_IV_size (16), then default_constant_IV.
const bytes = new Uint8Array([
	0, 0, 0, 49, 116, 101, 110, 99, 1, 0, 0, 0, 0, 0x19, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
	12, 13, 14, 15, 16, 16, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174,
	175, 176,
])
const [tenc] = readIsoBoxes(bytes, { readers: { tenc: readTenc } })

assert.ok(isIsoBoxType('tenc', tenc))
assert.strictEqual(tenc.defaultIsProtected, 1)
assert.strictEqual(tenc.defaultPerSampleIvSize, 0)
assert.strictEqual(tenc.defaultCryptByteBlock, 1)
assert.strictEqual(tenc.defaultSkipByteBlock, 9)
assert.strictEqual(tenc.defaultConstantIv?.length, 16)
assert.deepStrictEqual(
	tenc.defaultConstantIv,
	new Uint8Array([
		161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176,
	]),
)

A Streaming Video Technology Alliance project.