Fix drm errors
This commit is contained in:
1 parent
d6c776fbd5
commit
6822f12336
3 files changed
+125
-17
No files matched your search
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
|
||||
- DRM playback errors on certain TVs, by filtering out FairPlay-only streams
|
||||
|
||||
## [0.48.10] - 2026-10-17
|
||||
|
||||
### Added
|
||||
|
||||
@@ -267,6 +267,10 @@ class DashManifest
|
||||
continue for
|
||||
end if
|
||||
|
||||
if m.HasOnlyUnsupportedDrm(format)
|
||||
continue for
|
||||
end if
|
||||
|
||||
if (format.width = invalid or format.height = invalid) and not StringUtils.IsNullOrEmpty(format.size)
|
||||
if format.size.instr("x") > 0
|
||||
parts = format.size.Tokenize("x")
|
||||
@@ -323,7 +327,12 @@ class DashManifest
|
||||
audioTrackId = format.audioTrack.id
|
||||
end if
|
||||
|
||||
groupId = `${mimeType}-${justCodec}-${colorInfo}-${audioTrackId}${m.GetAudioVariantSuffix(format)}`
|
||||
drmFamilies = ""
|
||||
if IsArray(format.drmFamilies)
|
||||
drmFamilies = format.drmFamilies.Join("+")
|
||||
end if
|
||||
|
||||
groupId = `${mimeType}-${justCodec}-${colorInfo}-${audioTrackId}${m.GetAudioVariantSuffix(format)}-${drmFamilies}`
|
||||
|
||||
if groupInfo[groupId] = invalid
|
||||
groupInfo[groupId] = []
|
||||
@@ -473,14 +482,7 @@ class DashManifest
|
||||
end if
|
||||
|
||||
if xml.Node("AdaptationSet", adaptationSetAttributes)
|
||||
if IsArray(firstFormat.drmFamilies)
|
||||
for each drmFamily in firstFormat.drmFamilies
|
||||
systemId = m.GetDrmSystemId(drmFamily)
|
||||
if IsString(systemId)
|
||||
xml.EmptyNode("ContentProtection", { "schemeIdUri": `urn:uuid:${systemId}` })
|
||||
end if
|
||||
end for
|
||||
end if
|
||||
m.AddContentProtection(xml, firstFormat)
|
||||
|
||||
if IsAssociativeArray(firstFormat.audioTrack) or firstFormat.isDrc = true or firstFormat.isVoiceBoost = true
|
||||
' Roles
|
||||
@@ -574,14 +576,7 @@ class DashManifest
|
||||
end if
|
||||
|
||||
if xml.Node("AdaptationSet", adaptationSetAttributes)
|
||||
if IsArray(firstFormat.drmFamilies)
|
||||
for each drmFamily in firstFormat.drmFamilies
|
||||
systemId = m.GetDrmSystemId(drmFamily)
|
||||
if IsString(systemId)
|
||||
xml.EmptyNode("ContentProtection", { "schemeIdUri": `urn:uuid:${systemId}` })
|
||||
end if
|
||||
end for
|
||||
end if
|
||||
m.AddContentProtection(xml, firstFormat)
|
||||
|
||||
m.AddColorInfo(firstFormat, xml)
|
||||
|
||||
@@ -1015,6 +1010,32 @@ class DashManifest
|
||||
}
|
||||
end function
|
||||
|
||||
' DRM movies have formats whose only DRM family is FAIRPLAY, which no ContentProtection Roku supports can declare.
|
||||
function HasOnlyUnsupportedDrm(format as object) as boolean
|
||||
if not IsArray(format.drmFamilies) or format.drmFamilies.Count() = 0
|
||||
return false
|
||||
end if
|
||||
for each drmFamily in format.drmFamilies
|
||||
if IsString(m.GetDrmSystemId(drmFamily))
|
||||
return false
|
||||
end if
|
||||
end for
|
||||
return true
|
||||
end function
|
||||
|
||||
' A set's formats share their drmFamilies: CreateFormatGroupings keys groups on them.
|
||||
function AddContentProtection(xml as object, format as object) as void
|
||||
if not IsArray(format.drmFamilies)
|
||||
return
|
||||
end if
|
||||
for each drmFamily in format.drmFamilies
|
||||
systemId = m.GetDrmSystemId(drmFamily)
|
||||
if IsString(systemId)
|
||||
xml.EmptyNode("ContentProtection", { "schemeIdUri": `urn:uuid:${systemId}` })
|
||||
end if
|
||||
end for
|
||||
end function
|
||||
|
||||
function GetDrmSystemId(drmFamily as dynamic) as dynamic
|
||||
if not IsString(drmFamily)
|
||||
return invalid
|
||||
|
||||
@@ -34,6 +34,87 @@ namespace Tests
|
||||
m.assertInvalid(proxied[0].url)
|
||||
end function
|
||||
|
||||
@describe("DashManifest.FromVideoMetadata DRM")
|
||||
|
||||
function DrmFormat(itag as string, mimeType as string, drmFamilies as dynamic) as object
|
||||
format = {
|
||||
itag: itag
|
||||
url: `https://rr1.googlevideo.com/videoplayback?itag=${itag}`
|
||||
type: mimeType
|
||||
bitrate: 1000000
|
||||
init: "0-700"
|
||||
index: "701-900"
|
||||
}
|
||||
if mimeType.startsWith("video")
|
||||
format.width = 1920
|
||||
format.height = 1080
|
||||
end if
|
||||
if drmFamilies <> invalid
|
||||
format.drmFamilies = drmFamilies
|
||||
end if
|
||||
return format
|
||||
end function
|
||||
|
||||
' Each audio/video AdaptationSet as { reps: its Representation ids, drm: its ContentProtection schemeIdUris }.
|
||||
function DrmAdaptationSets(formats as object) as object
|
||||
manifest = new DashManifest("")
|
||||
xml = CreateObject("roXMLElement")
|
||||
xml.Parse(manifest.FromVideoMetadata({ videoId: "v", lengthSeconds: 100, isPostLiveDvr: false, adaptiveFormats: formats, storyboards: [] }, {}, false))
|
||||
sets = []
|
||||
for each adaptationSet in xml.GetNamedElements("Period").GetNamedElements("AdaptationSet")
|
||||
contentType = adaptationSet@contentType
|
||||
if contentType <> "audio" and contentType <> "video"
|
||||
continue for
|
||||
end if
|
||||
reps = []
|
||||
for each representation in adaptationSet.GetNamedElements("Representation")
|
||||
reps.Push(representation@id)
|
||||
end for
|
||||
drm = []
|
||||
for each contentProtection in adaptationSet.GetNamedElements("ContentProtection")
|
||||
drm.Push(contentProtection@schemeIdUri)
|
||||
end for
|
||||
sets.Push({ reps: reps, drm: drm })
|
||||
end for
|
||||
return sets
|
||||
end function
|
||||
|
||||
@it("leaves out formats whose only DRM is FairPlay, and keeps the formats without DRM")
|
||||
function _()
|
||||
sets = m.DrmAdaptationSets([
|
||||
m.DrmFormat("137", `video/mp4; codecs="avc1.640028"`, ["WIDEVINE", "PLAYREADY"])
|
||||
m.DrmFormat("399", `video/mp4; codecs="vp09.00.40.08.00.01.01.01.00"`, ["FAIRPLAY"])
|
||||
m.DrmFormat("140", `audio/mp4; codecs="mp4a.40.2"`, ["WIDEVINE", "PLAYREADY"])
|
||||
m.DrmFormat("141", `audio/mp4; codecs="mp4a.40.2"`, ["FAIRPLAY"])
|
||||
m.DrmFormat("136", `video/mp4; codecs="avc1.4D401F"`, invalid)
|
||||
])
|
||||
reps = []
|
||||
for each adaptationSet in sets
|
||||
reps.Append(adaptationSet.reps)
|
||||
end for
|
||||
reps.Sort()
|
||||
m.assertEqual(reps, ["136", "137", "140"])
|
||||
end function
|
||||
|
||||
@it("marks each set with the DRM systems its formats carry")
|
||||
function _()
|
||||
widevine = "urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"
|
||||
playready = "urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95"
|
||||
sets = m.DrmAdaptationSets([
|
||||
m.DrmFormat("140", `audio/mp4; codecs="mp4a.40.2"`, ["WIDEVINE", "PLAYREADY"])
|
||||
m.DrmFormat("139", `audio/mp4; codecs="mp4a.40.5"`, ["WIDEVINE"])
|
||||
m.DrmFormat("136", `video/mp4; codecs="avc1.4D401F"`, invalid)
|
||||
])
|
||||
drmByRep = {}
|
||||
for each adaptationSet in sets
|
||||
m.assertEqual(adaptationSet.reps.Count(), 1)
|
||||
drmByRep[adaptationSet.reps[0]] = adaptationSet.drm
|
||||
end for
|
||||
m.assertEqual(drmByRep["140"], [widevine, playready])
|
||||
m.assertEqual(drmByRep["139"], [widevine])
|
||||
m.assertEqual(drmByRep["136"], [])
|
||||
end function
|
||||
|
||||
@describe("DashManifest.FillLiveManifest")
|
||||
|
||||
' The filled startNumber, <S> entries ({ t, d, r }) and now.
|
||||
|
||||
Reference in new issue
Block a user