batocera-linux / batocera.linux

batocera.linux
https://batocera.org
Other
2.04k stars 523 forks source link

Using Moonlight streaming on RPI3B with hardware decoder #11459

Open Moldiz opened 7 months ago

Moldiz commented 7 months ago

Batocera build version

39 2024/03/01 05:31

Your architecture

Raspberry Pi 3B 1.2V

Your Graphic Processor Unit(s) (GPU)

Integrated

Issue description

I cannot run moonlight streaming with use of hardware decoding platform for RPI3B. I tried all of the options for moonlight build included in batocera, and only SDL software decoder is working properly. Moonlight version included in last stable batocera version is "Moonlight Embedded 2.6.1" which is kinda old, there is now 2.7 version available for some time.

After running "moonlight" command we can see that manpage specify platforms you can choose: "pi/imx/aml/rk/x11/x11_vdpau/sdl/fake (default auto)". On batocera wiki page about this app https://wiki.batocera.org/systems:moonlight), there is a link to default/example moonlight config file https://github.com/moonlight-stream/moonlight-embedded/blob/master/moonlight.conf , where we can find list of platforms to choose:

## default - autodetect
## aml - hardware video decoder for ODROID-C1/C2
## rk  - hardware video decoder for ODROID-N1 Rockchip
## omx - hardware video decoder for Raspberry Pi
## imx - hardware video decoder for i.MX6 devices
## x11 - software decoder
## sdl - software decoder with SDL input and audio
## fake - no audio and video
#platform = default

And here we can see "omx" platform which i assume is equivalent for "pi" command or there is some inconsistency in options. I tried both of them with the same result:

Searching for server...
Connecting to 192.168.1.10...
Platform 'pi' not found
[root@BATOCERA /userdata/system]# moonlight stream -width 1440 -height 900 -fps 60 -app Steam -codec h264 -platform omx
Searching for server...
Connecting to 192.168.1.10...
Platform 'omx' not found

So i tried to dig dipper, i know close to nothing about buildroot but i found config file for moonlight package in batocera github https://github.com/batocera-linux/batocera.linux/blob/master/package/batocera/emulators/moonlight-embedded/Config.in where we can see whats included to build it

config BR2_PACKAGE_MOONLIGHT_EMBEDDED
    bool "moonlight-embedded"
    select BR2_PACKAGE_OPUS
    select BR2_PACKAGE_EXPAT
    select BR2_PACKAGE_LIBEVDEV
    select BR2_PACKAGE_AVAHI
    select BR2_PACKAGE_ALSA_LIB
    select BR2_PACKAGE_HAS_UDEV
    select BR2_PACKAGE_LIBCURL
    select BR2_PACKAGE_LIBCEC
    select BR2_PACKAGE_FFMPEG
    select BR2_PACKAGE_FFMPEG_SWSCALE
    select BR2_PACKAGE_SDL2
    select BR2_PACKAGE_LIBENET
    select BR2_PACKAGE_ROCKCHIP_MPP          if BR2_PACKAGE_ROCKCHIP_RGA
    select BR2_PACKAGE_LIBVA_INTEL_DRIVER    if BR2_PACKAGE_BATOCERA_TARGET_X86_ANY
    select BR2_PACKAGE_INTEL_MEDIADRIVER     if BR2_PACKAGE_BATOCERA_TARGET_X86_ANY

I took a look at Moonlight code and found this building file https://github.com/moonlight-stream/moonlight-embedded/blob/master/CMakeLists.txt where we can see what packages is it looking for while being make

find_package(ALSA)
find_package(Opus REQUIRED)
find_package(Broadcom-OMX)
find_package(Freescale)
find_package(Amlogic)
find_package(Rockchip)

And focusing on Broadcom OMX

if(BROADCOM-OMX_FOUND)
  list(APPEND MOONLIGHT_DEFINITIONS HAVE_PI)
  list(APPEND MOONLIGHT_OPTIONS PI)
  aux_source_directory(./third_party/ilclient ILCLIENT_SRC_LIST)
  add_library(moonlight-pi SHARED ./src/video/pi.c ./src/audio/omx.c ./src/util.c ${ILCLIENT_SRC_LIST})
  target_include_directories(moonlight-pi PRIVATE ./third_party/ilclient ${BROADCOM_INCLUDE_DIRS} ${GAMESTREAM_INCLUDE_DIR} ${MOONLIGHT_COMMON_INCLUDE_DIR} ${OPUS_INCLUDE_DIRS})
  target_link_libraries(moonlight-pi gamestream ${BROADCOM_OMX_LIBRARIES} ${OPUS_LIBRARY})
  set_property(TARGET moonlight-pi PROPERTY COMPILE_DEFINITIONS ${BROADCOM_OMX_DEFINITIONS})
  install(TARGETS moonlight-pi DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()

As i said I'm newbie in terms of embedded and making distros for them, but that looks to me like there is missing package of Broadcom OMX for Raspberry Pi3 build. Maybe this will help someone to fix that problem.

Detailed reproduction steps

Installed newest stable batocera on sd card and booted it on RPI3B1.2V. Tried to run moonlight from console (ctrl+alt+f3) with command like "moonlight stream -app Steam -platform omx" or "moonlight stream -app Steam -platform pi" just to get error message about not finding selected platform.

Details of any attempts to fix this yourself

No response

Details of any modifications you have made to Batocera.

I did not make any custom modifications.

Logs and data

No response

dmanlfc commented 7 months ago

Firstly, thanks for the detailed issue report, it's refreshing.

AFAIK the OpenMAX integration layer is deprecated and since the RPI switch to 64-bit, I'm sure this interface is no longer possible with the suggested move to standard V4L interfaces. Moonlight Embedded supports older implementations of OMX for older OS's that still provide it. We don't.

Therefore your only option is SDL as the RPI3 does not provide X11 (which we don't even use on X86). Note: SDL provides the necessary controller support, hence the preference.

With SDL, it uses FFMPEG (AFAIK) and thus hardware accelerated playback for acceleration technologies which are supported, i.e. VA-API & VDPAU etc.

So you probably need to ask the question to the Moonlight Embedded team. How to get Hardware Acceleration under Wayland via SDL & FFMPEG ?

Note: FFPMPEG is compiled with V4L enabled.

dmanlfc commented 7 months ago

@jdorigao thoughts?

jdorigao commented 7 months ago

@Moldiz Only for rpi0/1 we use vcore (omx) for the others we use mesa3d (ffmpeg).