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

[widevine] Reintroduce CDM aarch64 support #1379

Merged
merged 3 commits into from
Sep 22, 2023

Conversation

CastagnaIT
Copy link
Collaborator

@CastagnaIT CastagnaIT commented Sep 11, 2023

Description

Reintroduce support to load Widevine CDM on linux aarch64 platorms
that has been removed after decrypters refactor

This is WIP since needs someone that is able to test it on a aarch64 device

TODO: on the "cdm loader" i add a class CCdmAarch64Loader
to wrap the methods required to load wv, but maybe its possible remove the class and declare static methods?

class removed

How has this been tested?

i have no way to test by myself
tested by users see discussion

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: Improvement non-breaking change which improves existing functionality v21 Omega labels Sep 11, 2023
@CastagnaIT
Copy link
Collaborator Author

i ping here @tmm1 @Nachtzuster from issue #1128
if someone have possibility to help us to test this on a aarch64 device or VM (ofc Kodi 21)

@CastagnaIT CastagnaIT force-pushed the aarch64_patch branch 4 times, most recently from 9bada9c to ab273a0 Compare September 16, 2023 14:38
@HiassofT
Copy link

Testing on RPi4 running LibreELEC master fails to load the cdm

error <general>: AddOnLog: inputstream.adaptive: Initialize: Initialize: Failed to load library: /storage/.kodi/cdm/libwidevinecdm.so: undefined symbol: __aarch64_ldadd4_acq_rel

@CastagnaIT
Copy link
Collaborator Author

looks like that despite i tried reproduce the old code dont works
so from my part i have no idea what to do and/or what its missing
if someone has some hint please leave a message

@DDuck007
Copy link

DDuck007 commented Sep 18, 2023

Just compiled/tested with actual libreelec-nightly and it looks like it searches the inputstream.adaptive-folder at the wrong place:

error : AddOnLog: inputstream.adaptive: The parameter "full" is no longer supported. For problems with live streaming contents please open an Issue to the GitHub repository.
info : AddOnLog: inputstream.adaptive: [Repr. chooser] Resolution set: 1920x1080, max allowed: 1920x1080, Adjust refresh rate: 1
error : GetDirectory - Error getting /usr/lib/kodi/addons/inputstream.adaptive/
error : GetDirectory - Error getting

On Libreelec /storage/.kodi/... is the correct location

@CastagnaIT
Copy link
Collaborator Author

GetDirectory errors are not real errors, are printed because it dont find the folder, is only a hassle of kodi core
if really dont find the folder of the binary a different error will be printed

@CastagnaIT
Copy link
Collaborator Author

@DDuck007 have you double checked that libcdm_aarch64_loader.so its in appropriate folder?
i remember you that LE needs some changes to the build system to allow copy automatically the libcdm_aarch64_loader.so file

@DDuck007
Copy link

ok, sorry ...
Yes I adapted the build-script and double-checked the folder - I will recheck again, but it was there ...

@HiassofT
Copy link

LE build only needs a very small change (include libcdm_aarch64_loader.so on aarch64). Here's the file I've been using for testing:

https://github.com/HiassofT/LibreELEC.tv/blob/le12-ia-test/packages/mediacenter/kodi-binary-addons/inputstream.adaptive/package.mk

  if [ "${ARCH}" = "aarch64" ]; then
    mkdir -p ${ADDON_BUILD}/${PKG_ADDON_ID}
    cp -P ${PKG_BUILD}/.${TARGET_NAME}/lib/cdm_aarch64/libcdm_aarch64_loader.so ${ADDON_BUILD}/${PKG_ADDON_ID}
  fi

@CastagnaIT
Copy link
Collaborator Author

@DDuck007
Copy link

Just checked the folder and the "libcdm_aarch64_loader.so" is there.
grafik

@HiassofT
Copy link

New test with the RTLD_NOLOAD commit: now the loader lib fails to load:

2023-09-20 19:43:19.396 T:1338    error <general>: AddOnLog: inputstream.adaptive: Initialize: Failed to load CDM aarch64 loader from path "/storage/.kodi/addons/inputstream.adaptive/libcdm_aarch64_loader.so", error: (null)

Full log is here: http://ix.io/4GUO

As a comparison here's the full log with the previous version (before the NOLOAD commit): http://ix.io/4GUM

@tmm1
Copy link
Contributor

tmm1 commented Sep 21, 2023

adding RTLD_NOLOAD doesn't make sense. that was the hack to reload the old lib.

changing to RTLD_NOW may help, or maybe even RTLD_DEEPBIND.

first step would be to confirm the built libcdm_aarch64_loader.so contains the expected symbols. is there some place i can download a binary built off this PR? curious what nm and ld show for that file.

@tmm1
Copy link
Contributor

tmm1 commented Sep 21, 2023

nm showed that the .so file did not include the symbols.

the fix was simple: e23cdd0

@DDuck007
Copy link

DDuck007 commented Sep 21, 2023

removed RTLD_NOLOAD and used RTLC_NOW together with changes from e23cdd0=> working (no loader-errror, ... anymore) :-)

@CastagnaIT CastagnaIT force-pushed the aarch64_patch branch 2 times, most recently from 2279b19 to cc6c9fb Compare September 21, 2023 06:32
@CastagnaIT
Copy link
Collaborator Author

CastagnaIT commented Sep 21, 2023

thanks guys for the help, i applied the changes to PR
please a last safety test by playing a widevine video

@DDuck007 Can you try to see if removing RTLC_NOW still works (and play video)?

@DDuck007
Copy link

Compiled it without RTLC_NOW and is also oK.
(m_hdlLibLoader = dlopen(binaryPath.c_str(), RTLD_GLOBAL | RTLD_LAZY);)

Playing a widevine video also works fine - see log:

2023-09-21 10:25:19.041 T:1312 warning : [script.module.inputstreamhelper] Widevine update check was made on 2023-09-17 16:44
2023-09-21 10:25:33.005 T:1169 info : Loading skin file: DialogContextMenu.xml, load type: KEEP_IN_MEMORY
2023-09-21 10:25:34.882 T:1169 info : VideoPlayer::OpenFile: plugin://plugin.video.dazn/?mode=play&title=FC+Bayern+M%C3%BCnchen+-+Man+United&id=19p5vxqesy1zc1w1xzes8zqcy2&params=8q5dj6hz0hss9esfe7nggtvro&verify_age=False
2023-09-21 10:25:34.883 T:1339 info : Creating InputStream
2023-09-21 10:25:34.969 T:1339 warning : AddOnLog: inputstream.adaptive: Warning "inputstream.adaptive.manifest_type" property is deprecated and will be removed next Kodi version, the manifest type is now automatically detected.
If you are using a proxy remember to add the appropriate "content-type" header to the HTTP manifest response
See Wiki page "How to provide custom manifest/license" to learn more about it.
2023-09-21 10:25:34.969 T:1339 warning : AddOnLog: inputstream.adaptive: Warning "inputstream.adaptive.manifest_update_parameter" property is deprecated and will be removed next Kodi version, use "inputstream.adaptive.manifest_upd_params" instead.
See Wiki integration page for more details.
2023-09-21 10:25:34.969 T:1339 error : AddOnLog: inputstream.adaptive: The parameter "full" is no longer supported. For problems with live streaming contents please open an Issue to the GitHub repository.
2023-09-21 10:25:34.977 T:1339 info : AddOnLog: inputstream.adaptive: [Repr. chooser] Resolution set: 1920x1080, max allowed: 1920x1080, Adjust refresh rate: 1
2023-09-21 10:25:34.980 T:1339 error : GetDirectory - Error getting /usr/lib/kodi/addons/inputstream.adaptive/
2023-09-21 10:25:34.980 T:1339 error : GetDirectory - Error getting
2023-09-21 10:25:35.105 T:1339 info : AddOnLog: inputstream.adaptive: Manifest successfully parsed (Periods: 1, Streams in first period: 2, Type: VOD)
2023-09-21 10:25:36.986 T:1339 info : Creating Demuxer
2023-09-21 10:25:36.987 T:1339 info : Opening stream: 1001 source: 256
2023-09-21 10:25:37.000 T:1339 info : [WHITELIST] Searching the whitelist for: width: 1920, height: 1080, fps: 50.000, 3D: false
2023-09-21 10:25:37.000 T:1339 info : Display resolution ADJUST : 1920x1080 @ 50.000000 Hz (22) (weight: 0.000)
2023-09-21 10:25:37.011 T:1339 info : Creating video codec with codec id: 27
2023-09-21 10:25:37.012 T:1339 info : CDVDVideoCodecDRMPRIME::Open - using decoder V4L2 mem2mem H.264 decoder wrapper
2023-09-21 10:25:37.048 T:1339 info : Creating video thread
2023-09-21 10:25:37.048 T:1345 info : running thread: video_thread
2023-09-21 10:25:37.049 T:1339 info : Opening stream: 1002 source: 256
2023-09-21 10:25:37.060 T:1339 info : Finding audio codec for: 86018
2023-09-21 10:25:37.065 T:1339 info : CDVDAudioCodecFFmpeg::Open() Successful opened audio decoder aac
2023-09-21 10:25:37.065 T:1339 info : OpenStream: Allowing max Out-Of-Sync Value of 10 ms
2023-09-21 10:25:37.065 T:1339 info : Creating audio thread
2023-09-21 10:25:37.065 T:1347 info : running thread: CVideoPlayerAudio::Process()
2023-09-21 10:25:37.299 T:1347 info : Creating audio stream (codec id: 86018, channels: 2, sample rate: 48000, no pass-through)
2023-09-21 10:25:37.323 T:1199 info : CActiveAESink::OpenSink - initialize sink
2023-09-21 10:25:37.522 T:1199 info : CAESinkALSA::Initialize - Attempting to open device "hdmi:CARD=vc4hdmi0,DEV=0"
2023-09-21 10:25:37.527 T:1199 info : CAESinkALSA::Initialize - Opened device "hdmi:CARD=vc4hdmi0,DEV=0,AES0=0x04,AES1=0x82,AES2=0x00,AES3=0x02"
2023-09-21 10:25:37.527 T:1199 info : CAESinkALSA::InitializeHW - Your hardware does not support AE_FMT_FLOAT, trying other formats
2023-09-21 10:25:37.527 T:1199 info : CAESinkALSA::InitializeHW - Using data format AE_FMT_S24NE3
2023-09-21 10:25:37.553 T:1169 info : Loading skin file: VideoFullScreen.xml, load type: KEEP_IN_MEMORY
2023-09-21 10:25:37.565 T:1169 info : [WHITELIST] Searching the whitelist for: width: 1920, height: 1080, fps: 50.000, 3D: false
2023-09-21 10:25:37.566 T:1169 info : Display resolution ADJUST : 1920x1080 @ 50.000000 Hz (22) (weight: 0.000)
2023-09-21 10:25:38.937 T:1233 info : PVR Manager: Starting cleanup of cached images.
2023-09-21 10:25:39.253 T:1233 info : PVR Manager: Cleaned up 0 cached images.
2023-09-21 10:26:07.076 T:1347 info : ProcessDecoderOutput: Changed max allowed Out-Of-Sync value to 44 ms due self-learning

@CastagnaIT
Copy link
Collaborator Author

@DDuck007 thanks
@glennguy PR ready for review

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.

Great work!

@CastagnaIT CastagnaIT merged commit 6102583 into xbmc:Omega Sep 22, 2023
10 checks passed
@CastagnaIT CastagnaIT deleted the aarch64_patch branch September 22, 2023 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Improvement non-breaking change which improves existing functionality v21 Omega
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants