版权声明:原创文章,欢迎转载,但请注明出处,谢谢。https://blog.csdn.net/qiuguolu1108/article/details/106445799
ortp库实现了rtp/rtcp协议。
一、环境
本文使用Ubuntu18.04
安装ortp库,cmake的版本如下:
root@learner:~# cmake --version
cmake version 3.10.2
二、安装依赖
ortp库依赖bctoolbox库,而bctoolbox库依赖mbedtls库。
安装mbedtls库
mbedtls库在github的地址:https://github.com/ARMmbed/mbedtls
下载mbedtls
git clone https://github.com/ARMmbed/mbedtls
编译安装mbedtls
cd mbedtls
mkdir build
cd build
cmake .. -DUSE_SHARED_MBEDTLS_LIBRARY=ON
make && make install
注意:编译生成的静态库和动态库,库文件安装在了/usr/local/lib
,头文件安装在了/usr/local/include
。
安装bctoolbox库
bctoolbox库在github的地址:https://github.com/BelledonneCommunications/bctoolbox
下载bctoolbox
git clone https://github.com/BelledonneCommunications/bctoolbox.git
编译安装bctoolbox
cd bctoolbox
mkdir _build
cd _build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DENABLE_TESTS_COMPONENT=NO
make && make install
三、ortp库的编译安装
ortp库在github的地址:https://github.com/BelledonneCommunications/ortp
下载ortp库
git clone https://github.com/BelledonneCommunications/ortp.git
编译安装ortp
cd ortp
mkdir _build
cd _build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr
make && make install
添加libmbedtls.so库所在的路径
在运行测试示例的时候,会报error while loading shared libraries: libmbedtls.so.12: cannot open shared object file: No such file or directory
错误,应该是libmbedtls.so.12
库所在的路径/usr/local/lib
无法被自动加载。所以需要将上述路径加载到动态库搜索路径中。
vim /etc/ld.so.conf #打开这个文件
在打开的文件中添加:/usr/local/lib
include /etc/ld.so.conf.d/*.conf
/usr/local/lib
运行ldconfig 更新一下/etc/ld.so.cache。
测试
示例文件在ortp/src/test
目录中,进入这个目录。
gcc test_timer.c -lortp -lbctoolbox
编译测试文件,运行结果如下:
root@learner:/opt/ortp/ortp/src/tests# ./a.out
doing something...
doing something...
doing something...
doing something...
doing something...
doing something...
doing something...
doing something...
doing something...
doing something...
运行成功~~~
参考:https://blog.csdn.net/wang3141128/article/details/80481111