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

New DRM Config property implementation rework #1672

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

CastagnaIT
Copy link
Collaborator

@CastagnaIT CastagnaIT commented Sep 4, 2024

Description

I remind everyone that the DRM configuration transition is designed to be backward compatible,
with some particular exceptions, specified on "breaking changes" section.

New inputstream.adaptive.drm property

The property has been for now limited to support only a unique DRM configuration.
Support to multiple DRM configurations, will be implemented at later time, with future PR's

Since there is no automatic drm selection yet, it is necessary for now to always add the keysystem with protected streams, even with empty parameters if there is no need to change the default values.

JSON structure example (just a unique key system for now):

{
    "[key system string]": {
        "persistent_storage": bool,
        "secure_decoder_disabled": bool,
        "init_data": str,
        "optional_key_req_params": dict,
        ...
        "license": {
            "server_certificate": str,
            "server_url": str,
            "req_headers": str,
            ...
        }
    }
}

In order not to do double work for the documentation, I will write directly on the wiki integration page the instructions on how to use it

Here is an example of a working STRM to compare the old with the new:

OLD PROPERTIES:

#KODIPROP:mimetype=application/dash+xml
#KODIPROP:inputstream=inputstream.adaptive
#KODIPROP:inputstream.adaptive.license_type=com.widevine.alpha
#KODIPROP:inputstream.adaptive.license_key=https://cwip-shaka-proxy.appspot.com/no_auth||R{SSM}|R
https://bitmovin-a.akamaihd.net/content/art-of-motion_drm/mpds/11331.mpd

NEW DRM PROPERTY:

#KODIPROP:mimetype=application/dash+xml
#KODIPROP:inputstream=inputstream.adaptive
#KODIPROP:inputstream.adaptive.drm={"com.widevine.alpha": {"license": {"server_url": "https://cwip-shaka-proxy.appspot.com/no_auth"}}}
https://bitmovin-a.akamaihd.net/content/art-of-motion_drm/mpds/11331.mpd

ofc python addons can take the advantage to use python dict and use json.dumps to set the "drm" property value

Add XML license wrapper support

License wrapper term i mean the things that are set in to inputstream.adaptive.license_key [Response-Data] field, where we currently support base64 and JSON, wrappers

Since here the code that manage the license wrapper has been reworked (for widevine), add the XML wrapper support its a very small change, so is included here
fix #267

Breaking changes

  1. Removed old undocumented specific use case of inputstream.adaptive.license_data to inject PRCustomData to the Playready DRM. This was available only for smoothstreaming manifest Playready protected, this old feature has been never documented, because confusing. Currently im not aware of addons that could use it. This use case will not works anymore from inputstream.adaptive.license_data, but same feature can be used with the new inputstream.adaptive.drm property, with an appropriate configuration (see optional_key_req_params).

  2. HLS "renew license url" add-on callbacks, has been removed. This was an old undocumented feature, that seem to allow addons to provide an updated license url for the AES128 encryption. Currently im not aware of addons that could use it, also im not aware of possible HLS use cases that could use it. I am not even aware if this functionality really works since i have no pratical test case. If anyone is using it, please mention, and also link its python implementation. The code was however only commented on, for future removal or reintroduction.

  3. On inputstream.adaptive.license_key property in the [Response-Data] field, the HB type has been removed. This because we have no info about this addition, i have not found info on web, nor addon that use it, therefore if in future someone will complain about this removal, we can obtain more info about it to reimplement it.

Other changes, due to cleanups

1) Changes on behaviours to disable the secure decoder. This is currently partially documented on wiki, anyway the change is backward compatible:

Old behaviour: only the Try avoiding the use of secure decoder ISA setting can allow to disable secure decoder, but its applied globally (to all addons), and so each single addon that require decoder must find a way to disable this setting, there are 3 ways:
1] set inputstream.adaptive.license_flags with force_secure_decoder flag
2] if dash, can use a proxy to add a custom ContentProtection tag (hard to do)
3] "brute force" to modify ISA addon setting

New behaviour: You can use Try avoiding the use of secure decoder ISA setting to disable secure decoder, its always applied globally, but now each addon can use following ways to override ISA setting (enable or disable as they wish):
1] with inputstream.adaptive.drm property set to "license" dict, the following item:
"secure_decoder" : [bool] set to True/False the bool value to enable or disable secure decoder
2] for DASH manifest the custom ISA ContentProtection tag:
<widevine:license robustness_level="[value]">
[value] can be: HW_SECURE_CODECS_REQUIRED to enable secure decoder (existing behaviour)
[value] can be: HW_SECURE_CODECS_NOT_ALLOWED to disable secure decoder (new)
3] set inputstream.adaptive.license_flags with force_secure_decoder flag (deprecated, and only to enable it)
4] "brute force" to modify ISA addon setting

2) More easy debug license data with wrappers/unwrappers.
On the license saved files for debug, now there will be saved a new file [UUID].request,
the ".request" file will contain the data already wrapped, ready for the HTTP license server request, while ".response" file will contain the data already unwrapped, ready to be sent to widevine CDM. This makes it easier to see if there is a problem in the wrap or unwrap methods.

3) Initialization PSSH placeholder now available for all systems
With the old inputstream.adaptive.license_key the b{PSSH} and B{PSSH} was available only for android OS, with the new "drm" config that data can be used on all operative systems, by using the new placeholders: {PSSH-B64} {PSSH-B64U}

Motivation and context

This is a first partial implementation of #1415 that concern only the new DRM config, and not the drm auto-selection

this step is a first transition to adapt the existing code to the new drm config,
because there is too much source code that need to be changed,
more likely part of the code implemented here could also be revisited more times with future PR's

How has this been tested?

i tested common widevine, playready, clearkey use cases

not tested:

  • wrappers/unwrappers (for provider customized license requests, like am@zon iirc)
  • custom init data
  • custom license data partially tested
  • pre-init data partially tested (miss to test android case)

It would be helpful to have someone who can provide feedback for testing for the more special cases mentioned on the list "not tested"

Screenshots (if appropriate):

Types of change

  • Bug fix (non-breaking change which fixes an issue)
  • Clean up (non-breaking change which removes non-working, unmaintained functionality)
  • Improvement (non-breaking change which improves existing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that will cause existing functionality to change)
  • Cosmetic change (non-breaking change that doesn't touch code)
  • None of the above (please explain below)

Checklist:

  • I have read the Contributing document
  • My code follows the Code Guidelines of this project
  • My change requires a change to the Wiki documentation
  • I have updated the documentation accordingly

@CastagnaIT CastagnaIT added WIP Type: Breaking change fix or feature that will cause existing functionality to change Type: Feature non-breaking change which adds functionality Wiki: Needed v22 Piers labels Sep 4, 2024
@CastagnaIT CastagnaIT force-pushed the drm_config_impl branch 4 times, most recently from 4eeb63c to 44c3a48 Compare September 5, 2024 13:56
@CastagnaIT CastagnaIT removed the WIP label Sep 24, 2024
@CastagnaIT CastagnaIT marked this pull request as ready for review September 25, 2024 07:45
@CastagnaIT
Copy link
Collaborator Author

CastagnaIT commented Sep 25, 2024

since this PR is a first big step for Kodi 22,
would be useful to have some feedback for particular use cases like:

  • wrappers/unwrappers (for provider customized license requests, like am@zon iirc)
  • custom init data (referred to old inputstream.adaptive.license_data)
  • custom license data (referred to [Post-Data] field in the old inputstream.adaptive.license_key)
  • pre-init data (n@tflix but atm its almost full broken, i will test myself next months if i have chance)

or other special cases that idr

The new inputstream.adaptive.drm property is more cleaner, but also totally different configuration interface,
you can find instructions on how to implement it on this temporary Wiki page:
https://github.com/xbmc/inputstream.adaptive/wiki/Integration-DRM-(NEW)
(that after will replace the current one)

pings some of you if you have a chance to test for regressions
@glennguy @matthuisman @Sandmann79
test builds (link updated): https://jenkins.kodi.tv/blue/organizations/jenkins/xbmc%2Finputstream.adaptive/detail/PR-1672/10/pipeline

surely there are other video addons that make use of particular use cases but idk, feel free to ping other devs if you think it is worthwhile.

@Arias800 if you are still around for your add-on that use XML data on license, i added the xml wrapper support with the new "drm" property, if you can do some tests, open wiki page linked above to get examples for wrappers/unwrappers (should allow you to remove the proxy server)

@CastagnaIT CastagnaIT force-pushed the drm_config_impl branch 4 times, most recently from bd3601c to c5c9ed4 Compare September 25, 2024 08:57
@matthuisman
Copy link
Contributor

"This DRM has been implemented at later time of Kodi 21 so can be configured only by using the drm_legacy property of the "simple method". This choice was made because the current "advanced method" will in future be deprecated and removed in favour of more advanced functionality. We want to encourage the use of the new methods to limit future changes needed."

Im confused by this.
Its saying use drm_legacy for clearkey and not this new property?
Or has this text not being updated yet?

@CastagnaIT
Copy link
Collaborator Author

@matthuisman you have opened the current (old) wiki page and not the new one,
the current page is not updated, since the PR is not yet merged,
you have to open the wiki link i posted above, the new page dont exists on the wiki menu

@matthuisman
Copy link
Contributor

matthuisman commented Sep 26, 2024

I went to the new one. It's at the bottom under clear stream

@CastagnaIT
Copy link
Collaborator Author

I went to the new one. It's at the bottom under clear stream

ouch i haven't seen it, yes my mistake i will edit it

@matthuisman
Copy link
Contributor

matthuisman commented Sep 26, 2024 via email

Copy link
Contributor

@glennguy glennguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow, lots and lots of work!!!!

@CastagnaIT
Copy link
Collaborator Author

first days of next week i will merge
if someone want more time to test and provide a feedback, please leave a message

@CastagnaIT CastagnaIT merged commit d94a317 into xbmc:Piers Oct 1, 2024
10 checks passed
@CastagnaIT CastagnaIT deleted the drm_config_impl branch October 1, 2024 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Breaking change fix or feature that will cause existing functionality to change Type: Feature non-breaking change which adds functionality v22 Piers Wiki: Done
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Mycanal.fr] Licence server return "challenge is missing"
3 participants