编译ORTP库遇到的问题
转自:【HD-G2UL-EVM开发板体验】基于RTP协议的实时流传输实现 - 单片机/MCU论坛 - 电子技术论坛 - 广受欢迎的专业电子论坛! (elecfans.com)
前言
RTP(Real-timeTransportProtocol)是用于Internet上针对多媒体数据流的一种传输协议,做流媒体传输方面的应用离不开RTP协议的实现及使用。可在项目中应用RTP协议实现流媒体(音视频)的传输,比如我们的游戏机项目实现就可以通过RTP推流音视频到PC,通过PC显示和播放音频,这样就不需要使用开发板的LCD和音频模块,刚好开发板也没有附带LCD,所以我们就这么干了。RTP实现有一些开源库可以选择,这里选择ORTP库,这个库是纯使用c语言编写,移植比较简单。
开发环境搭建交叉编译
WSL中
sudo apt install make
git clone https://github.com/dmonakhov/ortp.git
cd ortp/
./autogen.sh
报如下错误
lhj@lhj:~/ortp$ ./autogen.sh
解决
sudo apt-get install libtool*
重新
./autogen.sh
配置
./configure CC=aarch64-linux-gnu-gcc --host=aarch64-linux --target=aarch64-linux --prefix=/home/lhj/opt/
报错
configure: Could not find libsrtp headers or lib, cryto transport disabled.
解决
cd ../
git clone https://github.com/cisco/libsrtp.git
cd libsrtp
./configure
make
make runtest
sudo make install
再重新配置
cd ../ortp
./configure CC=aarch64-linux-gnu-gcc --host=aarch64-linux --target=aarch64-linux --prefix=/home/lhj/opt/
报错
configure: Could not find libsrtp headers or lib, cryto transport disabled.
解决
sudo apt-get install pkg-config
再重新配置
./configure CC=aarch64-linux-gnu-gcc --host=aarch64-linux --target=aarch64-linux --prefix=/home/lhj/opt/
编译
make
make install
查看编译的内容
sudo apt-get install tree
将上述lib/下的libortp.so.9.0.0和 libortp.la导入到开发板的/usr/lib目录下
并创建软连接
root@g2uliot:/usr/lib# ln -s libortp.so.9.0.0 libortp.so
最终开发板中文件如下
-rw-r--r-- 1 root root 944 Dec 19 2022 libortp.la PC编译
cd /home/lhj/ortp
./autogen.sh
./configure --prefix=/home/lhj/opt/win
make clean
make
make install
cd src/tests/
sudo cp /home/lhj/opt/win/lib/libortp.so.9* /usr/lib
gcc rtpsend.c -lortp -L/home/lhj/opt/win/lib -I/home/lhj/opt/win/include -o rtpsend
gcc rtprecv.c -lortp -L/home/lhj/opt/win/lib -I/home/lhj/opt/win/include -o rtprecv
PC中测试
新建一个终端接收
./rtprecv test 5000
lhj@lhj:~/ortp/src/tests$ ./rtprecv test 5000
新建一个终端发送
./rtpsend hello.txt 127.0.0.1 5000
lhj@lhj:~/ortp/src/tests$ ./rtpsend hello.txt 127.0.0.1 5000
分别交叉编译和本地编译测试代码
cd /home/lhj/ortp/src/tests
编译
aarch64-linux-gnu-gcc rtpsend.c -lortp -L/home/lhj/opt/board/lib -I/home/lhj/opt/board/include -o rtpsend
aarch64-linux-gnu-gcc rtprecv.c -lortp -L/home/lhj/opt/board/lib -I/home/lhj/opt/board/include -o rtprecv
将交叉编译的程序rtpsend rtprecv导入到开发板
chmod +x rtpsend rtprecv
开发板中运行
vi hello.txt新建测试文件,内容随便写,比如简单一句hello ortp
./rtprecv test 5000
root@g2uliot:~# ./rtprecv test 5000
WSL中运行本地编译的版本
./rtpsend hello.txt 192.168.1.10 5000
lhj@lhj:~/ortp/src/tests$ ./rtpsend hello.txt 192.168.1.10 5000
开发板中打开收到文件tets
vi test
说明收发测试OK。
总结
以上实现了ortp的开发环境搭建,并进行了文件实时传输的测试,为后面音视频的传输做了准备,后面就是分别实现音频和视频的实时推流到PC播放,为游戏机项目做准备。
|