"""get_boxes must give each thread its own box when tracks read their init segments at the same time.""" from __future__ import annotations import struct from uuid import UUID, uuid4 from unshackle.core.utilities import get_boxes def tenc_init(kid: UUID, version: int, crypt_skip: int) -> bytes: body = struct.pack(">B3s", version, b"\0\0\0") + bytes([0, crypt_skip if version else 0]) + b"\x01\x10" + kid.bytes return b"\x00" * 8 + struct.pack(">I", 8 + len(body)) + b"tenc" + body def test_get_boxes_finds_the_tenc() -> None: kid = uuid4() (box,) = get_boxes(tenc_init(kid, 1, 0x19), b"tenc") assert box.key_ID == kid