Function: writeTenc()
ts
function writeTenc(cursor, box): void;Defined in: writers/writeTenc.ts:26
Write the tenc box (TrackEncryptionBox).
ISO/IEC 23001-7:2016 - 8.2
Parameters
cursor
The write cursor
box
The TrackEncryptionBox fields to write
Returns
void
Throws
RangeError if a value of the box does not fit its field.
Throws
RangeError if defaultConstantIv has more than 255 bytes.
Example
ts
const writer = writeIsoBox(
{
type: 'tenc',
version: 1,
flags: 0,
defaultIsProtected: 1,
defaultPerSampleIvSize: 0,
defaultKid: new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]),
defaultCryptByteBlock: 1,
defaultSkipByteBlock: 9,
defaultConstantIv: new Uint8Array([
161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176,
]),
},
{ writers: { tenc: writeTenc } },
)
// 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
assert.deepStrictEqual(
new Uint8Array(writer.buffer),
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,
]),
)