Compiling GStreamer 1 for OpenWRT on RK3568 Platform

  • • To utilize the RKMMP hardware decoding feature on the OpenWRT system for the RK3568 platform, we will use the customized GStreamer 1 source code from the RK3568 Buildroot SDK to cross-compile the relevant components of GStreamer 1, aiming to adapt it for the OpenWRT target board. The compilation process is for reference only.
  • Compiling GStreamer 1 for OpenWRT on RK3568 Platform

Source Code Acquisition

The source code is from the patched GStreamer 1 source package in the RK3568 Buildroot SDK, located at:

#1. gst1
/home/test/rk356x/buildroot/output/rockchip_rk3568/build/gstreamer1-1.20.3

Creating cross_file

Cross-compile GStreamer 1 based on Ninja.

# Modify the compilation options and create the cross_file.txt file with the following content
# Note: Buildroot's and Meson's terminologies differ about the meaning
# of 'build', 'host' and 'target':
# - Buildroot's 'host' is Meson's 'build'
# - Buildroot's 'target' is Meson's 'host'

[binaries]
c = 'aarch64-openwrt-linux-gcc'
cpp = 'aarch64-openwrt-linux-g++'
ar = 'aarch64-openwrt-linux-ar'
strip = 'aarch64-openwrt-linux-strip'
pkgconfig = '/home/test/friendlywrt22-rk3568/test/staging_dir/host/bin/pkg-config'

[built-in options]
c_args = ['-D_LARGEFILE_SOURCE', '-D_LARGEFILE64_SOURCE', '-D_FILE_OFFSET_BITS=64', '-Os']
c_link_args = []
cpp_args = ['-D_LARGEFILE_SOURCE', '-D_LARGEFILE64_SOURCE', '-D_FILE_OFFSET_BITS=64', '-Os']
cpp_link_args = []
wrap_mode = 'nodownload'

[properties]
needs_exe_wrapper = true
sys_root = '/home/test/friendlywrt22-rk3568/test/staging_dir/target-aarch64_generic_musl/root-rockchip'
pkg_config_libdir = '/home/test/friendlywrt22-rk3568/test/staging_dir/target-aarch64_generic_musl/usr/lib/pkgconfig:/home/test/friendlywrt22-rk3568/test/staging_dir/target-aarch64_generic_musl/usr/lib/pkgconfig'
pkg_config_static = 'false'

[host_machine]
system = 'linux'
cpu_family = 'aarch64'
cpu = 'cortex-a55'
endian = 'little'

export STAGING_DIR=/home/test/friendlywrt22-rk3568/test/staging_dir/target-aarch64_generic_musl
export STAGING_DIR_HOST=/home/test/friendlywrt22-rk3568/test/staging_dir/host
export PATH=$PATH:/home/test/friendlywrt22-rk3568/test/staging_dir/toolchain-aarch64_generic_gcc-11.3.0_musl/bin/
mkdir build
cd build
meson --prefix=$(pwd)/../install  --cross-file=../cross_file.txt 
cd ../
ninja -C build install

Configuration and Compilation Issues

Run-time dependency glib-2.0 found: NO (tried pkgconfig and cmake)

# Configuration Issue 1: Missing glibc
Run-time dependency glib-2.0 found: NO (tried pkgconfig and cmake)
Looking for a fallback subproject for the dependency glib-2.0

../meson.build:488:0: ERROR: Neither a subproject directory nor a glib.wrap file was found.

Solution:

# Solution: In cross_file.txt, set pkgconfig and also add the environment variable STAGING_DIR_HOST
pkgconfig = '/home/test/friendlywrt22-rk3568/test/staging_dir/host/bin/pkg-config'

Compilation Issue: ./gst/printf/gst-printf.h:23:10: fatal error: glib.h: No such file or directory

# Compilation Issue 1:
aarch64-openwrt-linux-gcc: warning: environment variable 'STAGING_DIR' not defined
cc1: warning: /include/glib-2.0: No such file or directory [-Wmissing-include-dirs]
cc1: warning: /lib/glib-2.0/include: No such file or directory [-Wmissing-include-dirs]
cc1: warning: /include: No such file or directory [-Wmissing-include-dirs]
In file included from ../gst/printf/printf-args.c:23:
../gst/printf/gst-printf.h:23:10: fatal error: glib.h: No such file or directory
   23 | #include <glib.h>

Solution: Search for the header file and copy it to the corresponding directory.

# Solution: In the directory where glib2-0 is located, execute
cp glib2-0/* ./

Runtime Issues and Solutions

No such element or plugin ‘xvimagesink’

# After compilation, run the test
root@test:~/install/bin# gst-inspect-1.0 xvimagesink
No such element or plugin 'xvimagesink'

Compile gst1-plugins-base-1.20.3

#3. First compile gst1-plugins-base-1.20.3, before compiling, install gstream1
root@test:/home/test/tool/gst/gst1-plugins-base-1.20.3#cp  ../gstreamer1-1.20.3/install/* /home/test/friendlywrt22-rk3568/test/staging_dir/target-aarch64_generic_musl/usr/ -r

## Configuration
root@test:/home/test/tool/gst/gst1-plugins-base-1.20.3/build# meson --prefix=$(pwd)/../install  --cross-file=../cross_file.txt 

## Compilation Error 1
In file included from ../ext/opus/gstopusdec.c:52:
../ext/opus/gstopusdec.h:27:10: fatal error: opus_multistream.h: No such file or directory
   27 | #include <opus_multistream.h>
      |          ^~~~~~~~~~~~~~~~~~~~
## Disable opus
root@test:/home/test/tool/gst/gst1-plugins-base-1.20.3/build# meson --prefix=$(pwd)/../install  --cross-file=../cross_file.txt  -Dopus=disabled --reconfigure
cd ../
ninja -C build install

## Compilation Error 2, copy from include\gio-unix-2.0\gio to include/gio/
../tests/check/pipelines/tcp.c:31:10: fatal error: gio/gunixfdmessage.h: No such file or directory
   31 | #include <gio/gunixfdmessage.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

## Compilation completed, installed to staging_dir
root@test:/home/test/tool/gst/gst1-plugins-base-1.20.3# cp install/*  /home/test/friendlywrt22-rk3568/test/staging_dir/target-aarch64_generic_musl/usr/ -r

#4. Install linuxrga : 
meson --prefix=$(pwd)/../install  --cross-file=../../cross_file.txt
/home/test/friendlywrt22-rk3568/test/staging_dir/target-aarch64_generic_musl/usr/include/sys/ 
   64 | # if __GNUC_PREREQ (4, 6) && !defined _LIBC

#2.  gst-rk, 

root@test:/home/test/tool/gst/gstreamer1-rockchip-master#
export STAGING_DIR=/home/test/friendlywrt22-rk3568/test/staging_dir/target-aarch64_generic_musl
export STAGING_DIR_HOST=/home/test/friendlywrt22-rk3568/test/staging_dir/host
export PATH=$PATH:/home/test/friendlywrt22-rk3568/test/staging_dir/toolchain-aarch64_generic_gcc-11.3.0_musl/bin/
mkdir build
cd build
meson --prefix=$(pwd)/../install  --cross-file=../cross_file.txt 
cd ../
ninja -C build install

# Install to staging dir
root@test:/home/test/tool/gst/gstreamer1-rockchip-master# cp  install/lib/gstreamer-1.0/libgstrockchipmpp.so  /home/test/friendlywrt22-rk3568/test/staging_dir/target-aarch64_generic_musl/usr/lib/
root@test:/home/test/tool/gst/gstreamer1-rockchip-master# 

#5. Install interpipe
root@test:/home/test/tool/gst/gst1-interpipe-v1.1.8/build# meson --prefix=$(pwd)/../install  --cross-file=../../cross_file.txt

## Configuration Error 
Program gtkdoc-scan found: NO

../docs/plugins/meson.build:18:6: ERROR: Program 'gtkdoc-scan' not found or not executable

## Modify vim ../meson_options.txt, disable gtk-doc
option('enable-gtk-doc', type : 'boolean', value : false, description : 'Use gtk-doc to build documentation')

## Install to staging dir
root@test:/home/test/tool/gst/gst1-interpipe-v1.1.8# cp install/lib/gstreamer-1.0/libgstinterpipe.so  /home/test/friendlywrt22-rk3568/test/staging_dir/target-aarch64_generic_musl/usr/lib/
root@test:/home/test/tool/gst/gst1-interpipe-v1.1.8#

Leave a Comment