feat(tracks): resume segment decryption and rolling merge through the segment store

This commit is contained in:
imSp4rky
2026-11-28 22:09:44 -07:00
parent f4d178c26b
commit 82991dd823
26 changed files with 1125 additions and 186 deletions
+9 -5
View File
@@ -24,6 +24,7 @@ from unshackle.core.drm.key_args import shaka_noise, track_key_args
from unshackle.core.drm.segment_decrypt import SegmentDecrypter, can_use
from unshackle.core.drm.verify import kidless_track_kids
from unshackle.core.remote_protocol import APIErrorCode
from unshackle.core.tracks.segment_store import decrypted
KEY = "b5df2ae3f63b8dda9049d6e41422e075"
OTHER_KEY = "11" * 16
@@ -146,14 +147,15 @@ def test_a_failed_segment_decrypt_keeps_the_segment(
mp4decrypt_writes(output, 0, stderr)
drm = _widevine(A)
drm.content_keys[A] = KEY
segment_dir = tmp_path / "segments"
# the path holds a keyword that categorize_exception reads as a rate limit
segment_dir = tmp_path / "segments-429"
segment_dir.mkdir()
segment = segment_dir / "000.mp4"
segment.write_bytes(b"segment-0")
(segment_dir / "000.mp4.dec").write_bytes(b"stale")
(segment_dir / "000.clear.!dev").write_bytes(b"stale")
decrypter = SegmentDecrypter(drm, movie(encv(A)), tmp_path / "work", workers=1)
decrypter.submit(segment)
decrypter.submit(segment, decrypted(segment))
with pytest.raises(raises) as caught:
decrypter.finish()
@@ -284,6 +286,9 @@ def test_a_failed_mp4decrypt_keeps_the_input(
raises: type[BaseException],
) -> None:
mp4decrypt_writes(output, code, stderr)
# the path holds a keyword that categorize_exception reads as a rate limit
tmp_path = tmp_path / "work-429"
tmp_path.mkdir()
path, original, drm = mp4decrypt_track(tmp_path)
stray = tmp_path / "track_decrypted.mp4"
stray.write_bytes(b"stale")
@@ -293,8 +298,7 @@ def test_a_failed_mp4decrypt_keeps_the_input(
assert path.read_bytes() == original
assert not stray.exists()
if raises is subprocess.CalledProcessError:
assert categorize_exception(caught.value).error_code == APIErrorCode.DRM_ERROR
assert categorize_exception(caught.value).error_code == APIErrorCode.DRM_ERROR
@POSIX_STUBS