Skip to content

[2.46][CDMProxyThunder] Pass CAPS to decrypt function#1489

Closed
asurdej-comcast wants to merge 1 commit intoWebPlatformForEmbedded:wpe-2.46from
asurdej-comcast:asurdej/ocdm_decrypt_buffer
Closed

[2.46][CDMProxyThunder] Pass CAPS to decrypt function#1489
asurdej-comcast wants to merge 1 commit intoWebPlatformForEmbedded:wpe-2.46from
asurdej-comcast:asurdej/ocdm_decrypt_buffer

Conversation

@asurdej-comcast
Copy link
Copy Markdown

@asurdej-comcast asurdej-comcast commented Apr 10, 2025

Use new version of decrypt function
opencdm_gstreamer_session_decrypt_buffer()
to handle CAPS/stream properties

New API is available in all Thunder releases, R2, R3, R4 and newer:
OpenCDMError opencdm_gstreamer_session_decrypt_buffer(struct OpenCDMSession* session, GstBuffer* buffer, GstCaps* caps);
It takes all decryption info from protection meta structure attached to GstBuffer - pretty similar to what WebKitCommonEncryptionDecryptorGStreamer::transformInPlace() does.
I'm not sure if there is/or can be any other implementation of WebKit Decryptor interface other than Thunder, especially decrypt() function. But if thunder is the only one then most of transformInPlace() impl can be removed, parts to parse protection_meta as it is done inside opencdm_gstreamer_session_decrypt_buffer() now
30c7ea0

Build-Tests Layout-Tests
❌ 🛠 wpe-246-amd64-build ❌ 🧪 wpe-246-amd64-layout
❌ 🛠 wpe-246-arm32-build ❌ 🧪 wpe-246-arm32-layout

Use new version of decrypt function
  opencdm_gstreamer_session_decrypt_buffer()
to handle CAPS/stream properties
@asurdej-comcast asurdej-comcast requested a review from philn as a code owner April 10, 2025 10:53
@asurdej-comcast asurdej-comcast changed the title [CDMProxyThunder] Pass CAPS to decrypt function [2.46][CDMProxyThunder] Pass CAPS to decrypt function Apr 10, 2025
@philn philn requested a review from calvaris April 10, 2025 11:02
// Decrypt cipher.
OpenCDMError errorCode = opencdm_gstreamer_session_decrypt(session->get(), input.dataBuffer, input.subsamplesBuffer, input.numSubsamples,
input.ivBuffer, input.keyIDBuffer, 0);
OpenCDMError errorCode = opencdm_gstreamer_session_decrypt_buffer(session->get(), input.dataBuffer, input.caps.get());
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This cannot be upstreamed as-is, we would need some kind of Thunder version check and an ifdef here. I'll take a look next week.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can you try this PR please? WebKit/WebKit#44057

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The patch fails to detect new API because of missing header. (cmake logs below). It uses C compiler. Replaced with "check_cxx_symbol_exists()" but it failed again with undefined decrypt_buffer() symbol as THUNDER libraries are WebCore local. Otherwise it seems fine, encrypted playback works as expected
Here are my modifications:

include(CheckCXXSymbolExists)
...
    # globaly add thunder libraries:
    set(CMAKE_REQUIRED_LIBRARIES ${THUNDER_LIBRARIES})

    check_cxx_symbol_exists(opencdm_gstreamer_session_decrypt_buffer ${THUNDER_INCLUDE_DIR}/open_cdm_adapter.h HAS_OCDM_DECRYPT_BUFFER)
...

logs:

Determining if the opencdm_gstreamer_session_decrypt_buffer exist failed with the following output:
Change Dir: /home/asurdej/work/hisense_25Q2/build-hisense-v2/tmp/work/armv7at2hf-neon-rdk-linux-gnueabi/wpe-webkit/2.46+gitAUTOINC+15440d15c6-r0/build/CMakeFiles/CMakeTmp

Run Build Command(s):ninja cmTC_65fac && [1/2] Building C object CMakeFiles/cmTC_65fac.dir/CheckSymbolExists.c.o
FAILED: CMakeFiles/cmTC_65fac.dir/CheckSymbolExists.c.o
ccache /home/asurdej/work/hisense_25Q2/build-hisense-v2/tmp/work/armv7at2hf-neon-rdk-linux-gnueabi/wpe-webkit/2.46+gitAUTOINC+15440d15c6-r0/recipe-sysroot-native/usr/bin/arm-rdk-linux-gnueabi/arm-rdk-linux-gnueabi-gcc -D_GNU_SOURCE=1  -fdiagnostics
In file included from /home/asurdej/work/hisense_25Q2/build-hisense-v2/tmp/work/armv7at2hf-neon-rdk-linux-gnueabi/wpe-webkit/2.46+gitAUTOINC+15440d15c6-r0/recipe-sysroot/usr/include/WPEFramework/ocdm/open_cdm_adapter.h:23,
                 from /home/asurdej/work/hisense_25Q2/build-hisense-v2/tmp/work/armv7at2hf-neon-rdk-linux-gnueabi/wpe-webkit/2.46+gitAUTOINC+15440d15c6-r0/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:2:
/home/asurdej/work/hisense_25Q2/build-hisense-v2/tmp/work/armv7at2hf-neon-rdk-linux-gnueabi/wpe-webkit/2.46+gitAUTOINC+15440d15c6-r0/recipe-sysroot/usr/include/WPEFramework/ocdm/open_cdm.h:61:10: fatal error: string: No such file or directory
   61 | #include <string>
      |          ^~~~~~~~
compilation terminated.
ninja: build stopped: subcommand failed.


File /home/asurdej/work/hisense_25Q2/build-hisense-v2/tmp/work/armv7at2hf-neon-rdk-linux-gnueabi/wpe-webkit/2.46+gitAUTOINC+15440d15c6-r0/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include </home/asurdej/work/hisense_25Q2/build-hisense-v2/tmp/work/armv7at2hf-neon-rdk-linux-gnueabi/wpe-webkit/2.46+gitAUTOINC+15440d15c6-r0/recipe-sysroot/usr/include/WPEFramework/ocdm/open_cdm_adapter.h>

int main(int argc, char** argv)
{
  (void)argv;
#ifndef opencdm_gstreamer_session_decrypt_buffer
  return ((int*)(&opencdm_gstreamer_session_decrypt_buffer))[argc];
#else
  (void)argc;
  return 0;
#endif
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Replaced with "check_cxx_symbol_exists()" but it failed again with undefined decrypt_buffer() symbol as THUNDER libraries are WebCore local.

Can you share the log for that?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I've just realized that include is our local modification, there is also a in open_cdm.h but unused so easy to remove.
Without that it hits the same undefined reference as CXX case:

/usr/src/debug/wpe-webkit/2.46+gitAUTOINC+15440d15c6-r0/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:13: undefined reference to `opencdm_gstreamer_session_decrypt_buffer'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Seems like thunder include/lib options can be added in the check, https://cmake.org/cmake/help/latest/module/CheckCXXSymbolExists.html

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I got back to C version check_symbol_exists(). We have couple of local modifications that fails with C compiler but we can fix that I think. Or we can go with CXX version that will be easier to maintain

On undefined reference (C version): and Yes, in my case it works with
set(CMAKE_REQUIRED_LIBRARIES ${THUNDER_LIBRARIES})

Determining if the opencdm_gstreamer_session_decrypt_buffer exist failed with the following output:
Change Dir: /home/asurdej/work/hisense_25Q2/build-hisense-v2/tmp/work/armv7at2hf-neon-rdk-linux-gnueabi/wpe-webkit/2.46+gitAUTOINC+15440d15c6-r0/build/CMakeFiles/CMakeTmp

Run Build Command(s):ninja cmTC_dbd4f && [1/2] Building C object CMakeFiles/cmTC_dbd4f.dir/CheckSymbolExists.c.o
[2/2] Linking C executable cmTC_dbd4f
FAILED: cmTC_dbd4f
: && /home/asurdej/work/hisense_25Q2/build-hisense-v2/tmp/work/armv7at2hf-neon-rdk-linux-gnueabi/wpe-webkit/2.46+gitAUTOINC+15440d15c6-r0/recipe-sysroot-native/usr/bin/arm-rdk-linux-gnueabi/arm-rdk-linux-gnueabi-gcc -fdiagnostics-color=always -Wext
/home/asurdej/work/hisense_25Q2/build-hisense-v2/tmp/work/armv7at2hf-neon-rdk-linux-gnueabi/wpe-webkit/2.46+gitAUTOINC+15440d15c6-r0/recipe-sysroot-native/usr/bin/arm-rdk-linux-gnueabi/../../libexec/arm-rdk-linux-gnueabi/gcc/arm-rdk-linux-gnueabi/1
/usr/src/debug/wpe-webkit/2.46+gitAUTOINC+15440d15c6-r0/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:13: undefined reference to `opencdm_gstreamer_session_decrypt_buffer'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.


File /home/asurdej/work/hisense_25Q2/build-hisense-v2/tmp/work/armv7at2hf-neon-rdk-linux-gnueabi/wpe-webkit/2.46+gitAUTOINC+15440d15c6-r0/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include </home/asurdej/work/hisense_25Q2/build-hisense-v2/tmp/work/armv7at2hf-neon-rdk-linux-gnueabi/wpe-webkit/2.46+gitAUTOINC+15440d15c6-r0/recipe-sysroot/usr/include/WPEFramework/ocdm/open_cdm_adapter.h>

int main(int argc, char** argv)
{
  (void)argv;
#ifndef opencdm_gstreamer_session_decrypt_buffer
  return ((int*)(&opencdm_gstreamer_session_decrypt_buffer))[argc];
#else
  (void)argc;
  return 0;
#endif
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

So, iiuc, with set(CMAKE_REQUIRED_LIBRARIES ${THUNDER_LIBRARIES}) and CXX check it works? If so, I don't mind going with that :)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

That’s correct. Here is my snippet

include(CheckCXXSymbolExists)
...
    # globaly add thunder libraries:
    set(CMAKE_REQUIRED_LIBRARIES ${THUNDER_LIBRARIES})

    check_cxx_symbol_exists(opencdm_gstreamer_session_decrypt_buffer ${THUNDER_INCLUDE_DIR}/open_cdm_adapter.h HAS_OCDM_DECRYPT_BUFFER)
...

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks, let's see how the PR review goes. Might not be reviewed until next week due to Easter.

@asurdej-comcast
Copy link
Copy Markdown
Author

Fixed with b709dd2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

3 participants