xbmc / inputstream.adaptive

kodi inputstream addon for several manifest types
Other
453 stars 242 forks source link

Widevine DRM not working on LibreELEC 12 with Kodi 21.0 due to missing folder #1534

Closed tgiesela closed 6 months ago

tgiesela commented 6 months ago

Bug report

Describe the bug

On LibreELEC 12 (Beta) my addon does not play Widevine encoded live video streams. From the log I can see that Inputstream Adaptive cannot write to the widevine folder. I previously submitted a bug report to LibreElec, but they said it was a problem in ISA.

Expected Behavior

Play a widevine encoded live video stream.

Actual Behavior

The video does not play. This is caused by a required folder which is missing: /storage/.kodi/userdata/addon_data/inputstream.adaptive/widevine/5c016e8f0f95f039102cbe8366c5c7f3/

Possible Fix

Create the folder when it is not present. On other versions of LibreELEC the folder is created automatically. When I manually create the folder (storage/.kodi/userdata/addon_data/inputstream.adaptive/widevine/5c016e8f0f95f039102cbe8366c5c7f3/) everything works fine.

To Reproduce

Steps to reproduce the behavior:

  1. Try to play a Widevine encoded live video-stream

Debuglog

The debuglog can be found here:

kodi.log

MPD/M3U8s/ISM

An example or copy of a manifest (or manifests for HLS - master and variants) can be found here:

Screenshots

Here are some links or screenshots to help explain the problem:

N/A

Additional context or screenshots (if appropriate)

Here is some additional context or explanation that might help:

N/A

Your Environment

Used Operating system:

note: Once the issue is made we require you to update it with new information should that be required. Team Kodi will consider your problem report however, we will not make any promises the problem will be solved.

CastagnaIT commented 6 months ago

have you a chance to test fix PR #1539? i have no way to provide you compiled binary for LE - RPI

tgiesela commented 6 months ago

Thanks for your quick response! I am also not able to build a binary, but reported this to the Libreelec developers with the request to test it.

heitbaum commented 6 months ago

Thanks for your quick response! I am also not able to build a binary, but reported this to the Libreelec developers with the request to test it.

Test addon built - https://heitbaum.libreelec.tv/inputstream.adaptive-21.4.5.1.zip

tgiesela commented 6 months ago

Unfortunately this cause a crash dump of LibreElec. See attached. kodi_crashlog_20240425083101.log

CastagnaIT commented 6 months ago

this is not the same problem of above

[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
Core was generated by `/usr/lib/kodi/kodi.bin --standalone -fs --audio-backend=alsa+pulseaudio'.
Program terminated with signal SIGILL, Illegal instruction.
#0  0x0000007f284305e0 in __aarch64_ldadd4_acq_rel () from /storage/.kodi/addons/inputstream.adaptive/libcdm_aarch64_loader.so
[Current thread is 1 (Thread 0x7f07dbef00 (LWP 1902))]

libcdm_aarch64_loader code has not been changed, maybe binary build wrongly or something else happened that i'm not aware of i dont know...

tgiesela commented 6 months ago

I don't know either. As far as I can see ISA is invoked and is processing some data until it crashes. I am not able to see if your fix is included or something else happened.

heitbaum commented 6 months ago
PROJECT=ARMARCH=aarch64 DEVICE=ARMv8 s/unpack inputstream.adaptive
UNPACK      inputstream.adaptive
    APPLY PATCH (common)      packages/mediacenter/kodi-binary-addons/inputstream.adaptive/patches/1539.patch
patching file lib/cdm/cdm/media/cdm/cdm_adapter.cc
patching file src/decrypters/widevine/WVCdmAdapter.cpp

I have kicked off a clean rebuild - just in case there were any other artefacts. PROJECT=ARM ARCH=aarch64 DEVICE=ARMv8 s/create_addon inputstream.adaptive I’ll share once built.

heitbaum commented 6 months ago

@tgiesela please find the rebuild here. https://heitbaum.libreelec.tv/inputstream.adaptive-21.4.5.1-rebuild.zip

sha256sum should be 39d772cba43c02a3e873030c9ab9cb2a4daef17b072349949b506b06f1a8e7e5

tgiesela commented 6 months ago

Tested it again. Fortunately LE does not crash. But the results for the missing folder are still the same. See partial debug log attached. kodi.log

And again: manually creating the folder solves the issue. I cannot verify if the patches made by @CastagnaIT are included in the build made by @heitbaum.

CastagnaIT commented 6 months ago

then the problem is not the ending backslash "/" on the path something else prevent the addon to create the folder under LE but i have no idea, the code is this

https://github.com/xbmc/inputstream.adaptive/blob/444f9780d0b064da04c181c2ba406c3356d3d209/lib/cdm/cdm/media/cdm/cdm_adapter.cc#L131-L138

@heitbaum have you some hint?

heitbaum commented 6 months ago

@tgiesela - can you please share the output from ls -laR /storage/.kodi/userdata/addon_data/inputstream.adaptive

and also make sure ls -lad /storage/.kodi/userdata/addon_data/inputstream.adaptive and all parents don’t have any weird permissions.

They should all be

ls -lad /storage/.kodi/userdata
drwxr-xr-x   11 root     root          4096 Jan 30  2021 /storage/.kodi/userdata
tgiesela commented 6 months ago

Just to be sure I have done a clean install of LE 2024.04.

After first run:

ls -lad /storage/.kodi/userdata/addon_data/inputstream.adaptive
ls: /storage/.kodi/userdata/addon_data/inputstream.adaptive: No such file or directory
ls -lad /storage/.kodi/userdata/addon_data
drwxr-xr-x    7 root     root          1024 Apr 26 15:35 /storage/.kodi/userdata/addon_data
# ls -lad /storage/.kodi/userdata
drwxr-xr-x   10 root     root          1024 Apr 26 15:22 /storage/.kodi/userdata
# ls -lad /storage/.kodi
drwxr-xr-x    8 root     root          1024 Apr 26 15:41 /storage/.kodi
# ls -lad /storage/
drwxr-xr-x   19 root     root          1024 Apr 26 15:25 /storage/

As you can see the folder inputstream.adaptive is not created at all. Should this be done by the inputstream.adaptive addon or by inputstreamhelper?

@CastagnaIT Does your code create the parent directories if they do not exist? The code snippet just seems to create a subdirectory?

tgiesela commented 6 months ago

I think I found the issue. In the linux versions the ISA addon is invoked with a foldername such as: '/storage/.kodi/userdata/addon_data/inputstream.adaptive/widevine/5c016e8f0f95f039102cbe8366c5c7f3/'. Due to the code in unpatched version, the first folder that will be created has an empty name (''). I created a version which skips the first separator in CreateDirs and then it works. I have not verified what the impact on Windows Filesystem will be, but I hope this will help in further solving the issue.


// \brief Create a full directory path
bool CreateDirs(const char* path)
{
  const char* p;
  bool ret = true;
  // Skip Windows drive letter.
#ifdef _WIN32
  p = std::strchr(path, ':');
  if (p != NULL)
    p++;
  else
  {
#endif
    p = path;
    while (*p == PATH_SEPARATOR) p++;
#ifdef _WIN32
  }
CastagnaIT commented 6 months ago

thank you for the hint i made the fix PR #1542 if you can give a feedback

tgiesela commented 6 months ago

I just tested the fix on LibreELEC and I can confirm that the fix works. The folder is now created and the Widevine DRM video's are playing. I have not tested it on Windows (and other platforms), because I have no build environments.

CastagnaIT commented 6 months ago

thanks, doesnt matter for windows there is no difference

tomoqv commented 4 months ago

Could somebody help me with the latest addon zip-file for Omega on Rpi4 (LibreElec 12.0)? I don't know how to compile it myself. Thx

CastagnaIT commented 4 months ago

@tomoqv you can find some help on wiki https://github.com/xbmc/inputstream.adaptive/wiki/How-to-build but RPI build instructions has not updated from several years idk if need some adjustments

tomoqv commented 4 months ago

I installed the "reloaded" zip from this thread, and then updated it to version 21.4.9.1 in LibreElec. Netflix still doesn't work for me, but also the addon Telia Play stopped working with the Omega update.