Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DASH: Implement Content Protection References #1439

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

peaBerberian
Copy link
Collaborator

@peaBerberian peaBerberian commented May 16, 2024

This Pull Request implements the Content Protection referencing logic as for example specified in the ISO/IEC 23009-1:2022 DASH spec at chapter 5.8.4.1.3.

The idea is to reduce the size of an MPD for encrypted contents by preventing the repetition of similar <ContentProtection> elements in it. Because ContentProtection can become big due to them containing Base64-encoded binary data (e.g. the PSSH), this can save a lot of space on multi-Period contents with repeating DRM information.


This size-saving mechanism works by adding a system of "references" which are <ContentProtection> elements that can be "referenced" by other <ContentProtection> - which simply means that the latter inherits from the former.

In appearance simple, this <ContentProtection> referencing concept has some edge cases, from how I understood the specification, that complexified its implementation:

  • <ContentProtection> elements can now be at the <MPD> and <Period> levels, in which case it only acts as reference, or at the <AdaptationSet> and <Representation> level, in which case it acts as both a reference object and an object to actually apply on the corresponding element.

    This means that those elements have to be processed differently based on which levels they are found.

  • It seems that the spec allows some form of what I would call forward-referencing, where a <ContentProtection> inherits from another <ContentProtection> that has not yet been encountered by our current parsing pass.

    This was the main complexity here as to stay readable I didn't want to add another parsing pass just to resolve all ContentProtection elements (e.g. other loops through all the Periods -> AdaptationSets -> Representation just to parse that single object).
    I ended up adding another class, the ContentProtectionParser, whose role will be to keep track of references and parse lazily (as soon as all referenced ContentProtection are known) the ContentProtection elements. This is still a little awkward as it means that a Representation that has theoretically already been parsed could be updated after parsing a later Representation - which seems unnatural and may break some developers' expectations - yet which seems kind of unavoidable (well, in the forward-referencing edge case which is a situation that would probably never happen).

  • Technically, ContentProtection references act as an inheritance system, in the way that it merges attributes from both a referencer and a referenced, with priority for the referencer (if an attribute is found in both). This means that some logic has to be added for the inheritance to be performed (as opposed to just replace the referencer by the referenced).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant