rk3588/rk356x/rv1109/rv1126 live555移植+mpp编译 rtsp拉流

本文主要是为了记录一下rk板子的踩坑日记。
项目主要是rk3588 rtsp拉流。

mpp编译

1.下载MPP源码:https://github.com/rockchip-linux/mpp
2.rk3588/rk356x的板子进入Mpp源码目录mpp/build/linux/aarch64(rk3588/rk356x是64位板子)中,修改arm.linux.cross.cmake文件中的配置

cmake_minimum_required( VERSION 2.6.3 )

SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_C_COMPILER "aarch64-linux-gnu-gcc")
SET(CMAKE_CXX_COMPILER "aarch64-linux-gnu-g++")
#SET(CMAKE_SYSTEM_PROCESSOR "armv7-a")
SET(CMAKE_SYSTEM_PROCESSOR "armv8-a")

add_definitions(-fPIC)
add_definitions(-DARMLINUX)
add_definitions(-Dlinux)

修改make-Makefiles.bash的配置,主要改MPP_TOOLCHAIN编译链(rk3588/rk356x的交叉编译链)

#!/bin/bash
# Run this from within a bash shell
set +e
MPP_PWD=`pwd`
MPP_TOP=${MPP_PWD}/../../..
# toolchain detection
check_cmd(){
    "$@" >> /dev/null 2>&1
}
check_system_arm_linux_gcc(){
    check_cmd aarch64-linux-gnu-gcc -v
}
check_system_arm_linux_gcc
if [ $? -eq 127 ];then
    #MPP_TOOLCHAIN=/usr/bin
    MPP_TOOLCHAIN=~/3gi/software/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin
    export PATH=$PATH:${MPP_TOOLCHAIN}
fi
# generate Makefile
cmake -DCMAKE_BUILD_TYPE=Release \
      -DCMAKE_TOOLCHAIN_FILE=./arm.linux.cross.cmake \
      -DHAVE_DRM=ON \
      -G "Unix Makefiles" \
      ${MPP_TOP}

rv1109/1126是32位系统,则进入mpp/build/linux/arm,修改配置的如下:

cmake_minimum_required( VERSION 2.6.3 )
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_C_COMPILER "arm-linux-gnueabihf-gcc")
SET(CMAKE_CXX_COMPILER "arm-linux-gnueabihf-g++")
SET(CMAKE_SYSTEM_PROCESSOR "armv7-a_hardfp")
add_definitions(-fPIC)
add_definitions(-DARMLINUX)
add_definitions(-D__gnu_linux__)
#!/bin/bash
# Run this from within a bash shell
set +e
MPP_PWD=`pwd`
MPP_TOP=${MPP_PWD}/../../..
# toolchain detection
check_cmd(){
    "$@" >> /dev/null 2>&1
}
check_system_arm_linux_gcc(){
    check_cmd arm-linux-gcc -v
}
check_system_arm_linux_gcc
if [ $? -eq 127 ];then
    #MPP_TOOLCHAIN=${MPP_TOP}/../prebuilts/toolschain/usr/bin
    MPP_TOOLCHAIN=~/3gi/software/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin
    export PATH=$PATH:${MPP_TOOLCHAIN}
fi
# generate Makefile
cmake -DCMAKE_BUILD_TYPE=Release \
      -DCMAKE_TOOLCHAIN_FILE=./arm.linux.cross.cmake \
      -DHAVE_DRM=ON \
      -G "Unix Makefiles" \
      ${MPP_TOP}
  1. 执行 ./make-Makefiles.bash 后脚本会把需要文件都拷贝到该目录下,再执行 make命令就可以生成so文件和可执行文件,如果想要生成库的形式让别的程序调用可以按照如下的命令:
./make-Makefiles.bash
make 
export DESTDIR=./install
make install

执行上述命令后就可以在该目录的install文件夹下生成如下文件:
rk3588/rk356x/rv1109/rv1126 live555移植+mpp编译 rtsp拉流_第1张图片
然后就可以让别的程序调用它了。
4.如果想在板子上执行生成的应用程序,要把这些执行文件和so文件都adb push 到板端上,然后执行应用程序,比如
./mpi_dec_test -t 7 -i BarbieGirl.h264 -n 10
就会看到如下打印(我是在rk3588上执行的)
rk3588/rk356x/rv1109/rv1126 live555移植+mpp编译 rtsp拉流_第2张图片
如果没有打印信息,可能新版mpp程序把打印接口改为系统log,可以在板端另外开一个命令行使用命令tail -10f /var/log/messages,也可以看到打印信息

编译live555

  1. 下载live555源码: http://www.live555.com/liveMedia/public/
  2. 进入源码目录,新增config.rk3588(根据个人编译器指定内容),内容如下:
CROSS_COMPILE?=         /home/software/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
COMPILE_OPTS =          $(INCLUDES) -I. -O2 -DSOCKLEN_T=socklen_t -DNO_SSTREAM=1 -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -DNO_OPENSSL=1 -DLOCALE_NOT_USED -DDEBUG
C =                     c
C_COMPILER =            $(CROSS_COMPILE)gcc
C_FLAGS =               $(COMPILE_OPTS)
CPP =                   cpp
CPLUSPLUS_COMPILER =    $(CROSS_COMPILE)g++
CPLUSPLUS_FLAGS =       $(COMPILE_OPTS) -Wall -DBSD=1
OBJ =                   o
LINK =                  $(CROSS_COMPILE)g++ -o
LINK_OPTS =
CONSOLE_LINK_OPTS =     $(LINK_OPTS)
LIBRARY_LINK =          $(CROSS_COMPILE)ar cr 
LIBRARY_LINK_OPTS =     $(LINK_OPTS)
LIB_SUFFIX =                    a
LIBS_FOR_GUI_APPLICATION =
EXE =
PREFIX =                /home/test/rtsp/live/live555_install

CROSS_COMPILE为自己的编译链,PREFIX为自己想要生成的安装路径,安装路径可以随意改。
3.运行genMakefiles生成makefile,根据后缀名匹配对应的config文件,命令如下:

./genMakefiles rk3588

4.执行make命令,再执行make install,就可以生成静态库和头文件让别的工程引用它了

tree
.
├── bin
├── include
│   ├── BasicUsageEnvironment 
│   ├── groupsock
│   ├── liveMedia
│   └── UsageEnvironment
└── lib
    ├── libBasicUsageEnvironment.a
    ├── libgroupsock.a
    ├── libliveMedia.a
    └── libUsageEnvironment.a

引用时要注意这4个库的引用顺序,顺序不对会报错


target_link_libraries(${PROJECT_NAME}  
        ${LIVE_PATH}/libliveMedia.so
        ${LIVE_PATH}/libBasicUsageEnvironment.so
        ${LIVE_PATH}/libgroupsock.so
        ${LIVE_PATH}/libUsageEnvironment.so
        rockchip_mpp
        utils
        ${RK_DRM_LIB}
        pthread
        rga
        )

如果想实现rk3588的拉流,可以参考以下链接:
Liunx_mpp :
https://github.com/WainDing/mpp_linux_cpp
https://github.com/MUZLATAN/ffmpeg_rtsp_mpp
mpp的运行可以参考官方文档的mpi_dec_test.c、mpi_dec_mt_test.c、mpi_dec_multi_test.c几个例子

live555:
参考live555的码源给的/testProgs/testRTSPClient.cpp拉流代码
https://github.com/wexiangis/rtsp_to_h264 这个是live555接收h264的demo

你可能感兴趣的:(rk嵌入式,linux,嵌入式硬件)