feat(drm): decrypt plugin segments as they land on the fetch_segments decrypter seam

This commit is contained in:
imSp4rky
2026-12-03 15:51:42 -07:00
parent e9adc50594
commit f1f91a7d5c
14 changed files with 309 additions and 84 deletions
+18 -1
View File
@@ -13,7 +13,7 @@ from tests.core.test_hls_kid_from_init import keyed_segment, no_kid_pssh, playli
from tests.core.test_hls_service_drm_keys import KID, OTHER_KID, SKD_KEY, encrypted_init
from unshackle.core.cdm.detect import cdm_type_stub
from unshackle.core.constants import DOWNLOAD_CANCELLED
from unshackle.core.drm import PlayReady, Widevine, cenc
from unshackle.core.drm import CustomDRM, PlayReady, Widevine, cenc
from unshackle.core.manifests.hls import HLS
from unshackle.core.manifests.hls_key_plan import HlsKeyPlan
from unshackle.core.tracks import Video
@@ -170,6 +170,23 @@ def test_one_init_segment_and_one_key_tag_make_a_single_init_track(text: str, si
assert plan.single_init(manifest.segments) is single
@pytest.mark.parametrize(
"text, single",
[
pytest.param(playlist("#EXTINF:6.0,\nseg.ts\n"), True, id="no-init-segment"),
pytest.param(playlist("#EXT-X-KEY:METHOD=NONE\n#EXTINF:6.0,\nseg.ts\n"), True, id="method-none"),
pytest.param(playlist("#EXTINF:6.0,\nseg.ts\n", "#EXTINF:6.0,\nnext.ts\n"), False, id="discontinuity"),
],
)
def test_a_cipher_that_is_not_cenc_needs_no_init_segment_or_key_tag(
example_plugins: None, text: str, single: bool
) -> None:
plan, _ = plan_of(text)
plan.drm = CustomDRM("example")
assert plan.single_init(m3u8.loads(text).segments) is single
@pytest.mark.parametrize("system, drm_class", [("playready", PlayReady), ("widevine", Widevine)])
def test_a_track_with_only_fairplay_tags_is_bridged_and_keeps_no_tag(system: str, drm_class: type) -> None:
text = playlist(f'#EXT-X-MAP:URI="a.mp4"\n{SKD_KEY}\n#EXTINF:6.0,\nseg.m4s\n')