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

[Omega] Extract default kid from init data if required #1725

Merged
merged 1 commit into from
Nov 10, 2024

Conversation

matthuisman
Copy link
Contributor

@matthuisman matthuisman commented Nov 10, 2024

Description

Sending the below as license_data property
AAAAMnBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAABISEByIsi1reEZguaxNxHvMJt8=

Kodi 20 - OK

2024-11-10 20:09:10.652 T:1943  debug <general>: AddOnLog: inputstream.adaptive: Searching PSSH data in FILE
2024-11-10 20:09:10.652 T:1943  debug <general>: AddOnLog: inputstream.adaptive: Initializing stream with KID: 1c88b22d6b784660b9ac4dc47bcc26df

Kodi 21 - ERROR

2024-11-10 11:42:10.723 T:1003 debug <general>: AddOnLog: inputstream.adaptive: License data: Use PSSH data provided by the license data property
2024-11-10 11:42:10.723 T:1003 error <general>: AddOnLog: inputstream.adaptive: ConvertKidStrToBytes: Cannot convert KID "" as bytes due to wrong size
2024-11-10 11:42:10.723 T:1003 warning <general>: AddOnLog: inputstream.adaptive: Initializing stream with unknown KID!

Kodi 22 - OK

2024-11-10 21:24:47.437 T:22820   debug <general>: AddOnLog: inputstream.adaptive: License data: Use PSSH data provided by the license data property
2024-11-10 21:24:47.437 T:22820   debug <general>: AddOnLog: inputstream.adaptive: Default KID parsed from init data
2024-11-10 21:24:47.438 T:22820   debug <general>: AddOnLog: inputstream.adaptive: Initializing stream with KID: 1c88b22d6b784660b9ac4dc47bcc26df

Motivation and context

How has this been 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

src/Session.cpp Outdated
// If no KID, but init data, extract the KID from init data
if (!initData.empty() && defaultKidStr.empty())
{
DRM::PSSH parser;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh, this might not even be available in Omega

@matthuisman matthuisman force-pushed the fix_default_kid_init_data branch 2 times, most recently from 36eb7d4 to 6e623bc Compare November 10, 2024 08:35
@matthuisman
Copy link
Contributor Author

this isnt actually working, I still get

2024-11-10 21:44:44.730 T:21220   debug <general>: AddOnLog: inputstream.adaptive: License data: Use PSSH data provided by the license data property
2024-11-10 21:44:44.730 T:21220   error <general>: AddOnLog: inputstream.adaptive: DRM::ConvertKidStrToBytes: Cannot convert KID "" as bytes due to wrong size
2024-11-10 21:44:44.730 T:21220 warning <general>: AddOnLog: inputstream.adaptive: Initializing stream with unknown KID!

@CastagnaIT
Copy link
Collaborator

this because your PSSH data is wrong, PSSH version 0 dont support kids container

@matthuisman
Copy link
Contributor Author

oh, thats because the parser in kodi 21 doesnt GetKeyIds for version 0 from the data..
Trying again now with version 1 with same keyid in kids...

@matthuisman
Copy link
Contributor Author

matthuisman commented Nov 10, 2024

so problems with Kodi 21:

  1. does not create default kid from initdata (Kodi 20 and 22 both do)
  2. does not support version 0 getting KID from data (Kodi 20 and 22 both do)

@CastagnaIT
Copy link
Collaborator

CastagnaIT commented Nov 10, 2024

does not support version 0 getting KID from data (Kodi 20 and 22 both do)

ah yeah now remember,
on 22 i reworked the pssh parser and all others related code, and that's why i didn't backport,
too much code to change and it wasn't worth investing time with the risk of regressions

so on 22 the parser is able to get kids from widevine data, contained in the PSSH data (regardless of PSSH version)

@matthuisman
Copy link
Contributor Author

when I use
AAAARnBzc2gBAAAA7e+LqXnWSs6jyCfc1R0h7QAAAAEciLIta3hGYLmsTcR7zCbfAAAAEhIQHIiyLWt4RmC5rE3Ee8wm3w==

it gets further

2024-11-10 22:03:36.659 T:20768   debug <general>: AddOnLog: inputstream.adaptive: License data: Use PSSH data provided by the license data property
2024-11-10 22:03:36.659 T:20768   debug <general>: AddOnLog: inputstream.adaptive: Default KID parsed from init data
2024-11-10 22:03:36.659 T:20768   debug <general>: AddOnLog: inputstream.adaptive: Initializing stream with KID: 
2024-11-10 22:03:36.694 T:20768   debug <general>: AddOnLog: inputstream.adaptive: CDMMessage: 1 arrived!

it plays regardless of this issue, so im not sure if the default kid is being set correctly.
I know a user has issues on Linux64 with this stream so thinking this is the problem there.

"Initializing stream with KID: "
Its just showing blank...
Maybe thats just a type issue? cant convert to str ?

@matthuisman
Copy link
Contributor Author

On 22, the parser can get kid from the DATA only (version 0) :)
here is where it does that: https://github.com/xbmc/inputstream.adaptive/blob/Piers/src/decrypters/Helpers.cpp#L353

Its not a biggy, I can add the key as well.
But would still need the fix to grab default_kid from init_data (this PR)

@matthuisman
Copy link
Contributor Author

oh, I see

LOG::Log(LOGDEBUG, "Initializing stream with KID: %s", sessionPsshset.defaultKID_.c_str());

We logging sessionPsshset.defaultKID not defaultkid..

@matthuisman matthuisman force-pushed the fix_default_kid_init_data branch from 6e623bc to 178e12a Compare November 10, 2024 09:10
@matthuisman
Copy link
Contributor Author

Fixed that with latest commit :)

@matthuisman matthuisman changed the title [Omega] Parse default kid from init data if empty [Omega] Extract default kid from init data if required Nov 10, 2024
@matthuisman
Copy link
Contributor Author

success, with this PR and adding kids to my license_data:
AAAARnBzc2gBAAAA7e+LqXnWSs6jyCfc1R0h7QAAAAEciLIta3hGYLmsTcR7zCbfAAAAEhIQHIiyLWt4RmC5rE3Ee8wm3w==

2024-11-10 22:17:26.709 T:22348   debug <general>: AddOnLog: inputstream.adaptive: media::CdmAdapter::OnInitialized: CDM is initialized: true
2024-11-10 22:17:26.709 T:22348   debug <general>: AddOnLog: inputstream.adaptive: License data: Use PSSH data provided by the license data property
2024-11-10 22:17:26.709 T:22348   debug <general>: AddOnLog: inputstream.adaptive: Default KID parsed from init data
2024-11-10 22:17:26.709 T:22348   debug <general>: AddOnLog: inputstream.adaptive: Initializing stream with KID: 1c88b22d6b784660b9ac4dc47bcc26df
2024-11-10 22:17:26.743 T:22348   debug <general>: AddOnLog: inputstream.adaptive: CDMMessage: 1 arrived!

@CastagnaIT
Copy link
Collaborator

seem there is a bit of mess with vars (also on 22)

e.g. ExtractStreamProtectionData set extracted kid to sessionPsshset but dont update defaultKidStr

also on condition below
if (sessionPsshset.pssh_ == m_adaptiveTree->m_currentPeriod->GetPSSHSets()[i].pssh_)
imo sessionPsshset.pssh_ should be updated by initData when needed

I've always found this part confusing, although with the rework i will delete all this

@matthuisman
Copy link
Contributor Author

Understood. But this PR is not a rework. It's fixing a regression so I'm trying to keep changes minimal. Is this able to go in to fix the issue? Otherwise I'll need to proxy manifest and add in content protection section

Copy link
Collaborator

@CastagnaIT CastagnaIT left a comment

Choose a reason for hiding this comment

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

its ok,
just please add prefix to commit title otherwise will make more hard to read the git history
in your case you are modify the session, so [Session] xy...

@CastagnaIT CastagnaIT added Type: Fix non-breaking change which fixes an issue Type: Partial backport v21 Omega labels Nov 10, 2024
@matthuisman matthuisman force-pushed the fix_default_kid_init_data branch from 178e12a to 6387a1a Compare November 10, 2024 20:05
@matthuisman
Copy link
Contributor Author

no worries :) I have updated the commit message

@CastagnaIT CastagnaIT merged commit 0627453 into xbmc:Omega Nov 10, 2024
1 of 8 checks passed
@matthuisman
Copy link
Contributor Author

Thank you @CastagnaIT :)

@matthuisman
Copy link
Contributor Author

@CastagnaIT if there are no more planned changes coming soon for Omega - are you able to do a release with this change ?

@CastagnaIT
Copy link
Collaborator

yes the intention is to make releases by saturday

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Fix non-breaking change which fixes an issue Type: Partial backport v21 Omega
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants