diff --git a/thirdparty/libsrtp/HPKBUILD b/thirdparty/libsrtp/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..4110d310e78c5ba435d281a5feda8112acdd57a6 --- /dev/null +++ b/thirdparty/libsrtp/HPKBUILD @@ -0,0 +1,52 @@ +# Contributor: liulihong +# Maintainer: liulihong + +pkgname=libsrtp +pkgver=v2.5.0 +pkgrel=0 +pkgdesc="" +url="" +archs=("armeabi-v7a" "arm64-v8a") +license=("2001-2017 Cisco Systems, Inc") +depends=("openssl" "libpcap") +makedepends=() +install= +source="https://github.com/cisco/$pkgname/archive/refs/tags/$pkgver.tar.gz" +patchflag=true +builddir=$pkgname-${pkgver:1} +packagename=$builddir.tar.gz + +prepare() { + if $patchflag + then + cd $builddir + patch -p1 < `pwd`/../libsrtp_oh_pkg.patch + patchflag=false + cd $OLDPWD + fi + mkdir -p $builddir/$ARCH-build +} + +build() { + cd $builddir + ${OHOS_SDK}/native/build-tools/cmake/bin/cmake "$@" -DOHOS_ARCH=$ARCH -B$ARCH-build -S./ -L -DBUILD_WITH_WARNINGS=OFF -DENABLE_OPENSSL=ON > `pwd`/$ARCH-build/build.log 2>&1 + make -j4 -C $ARCH-build >> `pwd`/$ARCH-build/build.log 2>&1 + ret=$? + cd $OLDPWD + return $ret + +} + +package() { + cd "$builddir" + make -C $ARCH-build install >> `pwd`/$ARCH-build/build.log 2>&1 + cd $OLDPWD +} + +check() { + echo "The test must be on an OpenHarmony device!" +} + +cleanbuild(){ + rm -rf ${PWD}/$builddir #${PWD}/packagename +} diff --git a/thirdparty/libsrtp/README.OpenSource b/thirdparty/libsrtp/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..9230c42198922eaded5a48438e54c0c37a7e96ab --- /dev/null +++ b/thirdparty/libsrtp/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "libsrtp", + "License": "2001-2017 Cisco Systems, Inc", + "License File": "notes.txt", + "Version Number": "v2.5.0", + "Owner": "llh_01129@163.com", + "Upstream URL": "https://github.com/cisco/libsrtp/archive/refs/tags/v2.5.0.tar.gz", + "Description": "libSRTP provides functions for protecting RTP and RTCP. RTP packets can be encrypted and authenticated (using the srtp_protect() function), turning them into SRTP packets." + } +] diff --git a/thirdparty/libsrtp/README_zh.md b/thirdparty/libsrtp/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..d6c48ca2957c93f18ebdaedfbe7dea9caaba4245 --- /dev/null +++ b/thirdparty/libsrtp/README_zh.md @@ -0,0 +1,12 @@ +# libsrtp三方库说明 +## 功能简介 +libSRTP提供了保护RTP和RTCP的功能。RTP数据包可以进行加密和身份验证(使用srtp_protect()函数),将其转换为srtp数据包。 +## 使用约束 +- IDE版本:DevEco Studio 3.1 Beta2 +- SDK版本:ohos_sdk_public 3.2.11.9 (API Version 9 Release) +- 三方库版本:v2.5.0 +- 当前适配的功能:支持加密的rtp数据包传输 +- [2001-2017 Cisco Systems, Inc](https://github.com/cisco/libsrtp/blob/main/LICENSE) + +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/libsrtp/SHA512SUM b/thirdparty/libsrtp/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..2d96ec67c45eb454ded8a7e2e116fa0083f8bc6b --- /dev/null +++ b/thirdparty/libsrtp/SHA512SUM @@ -0,0 +1,2 @@ +bd679ab65ccf22ca30fe867b9649a0b84cfa6fad6e22eb10f081141632f6dd56479a04d525b865f11fd46007303ca211065d9c170e4820d6ea7055403702340a libsrtp-2.5.0.tar.gz +4ca9729bdc73526ba392571672b3f24de11c74cb98cd95f4e71bcceda9b33597d8b6166202fbb0d12f9abd7ec2a99faa955f1c7c9a64e4088fde7b4bd7b9fca9 libsrtp_oh_pkg.patch diff --git a/thirdparty/libsrtp/docs/hap_integrate.md b/thirdparty/libsrtp/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..1ffd06ea218449cb2490b76e33c59bc1f1e44ddd --- /dev/null +++ b/thirdparty/libsrtp/docs/hap_integrate.md @@ -0,0 +1,76 @@ +# libsrtp集成到应用hap +本库是在RK3568开发板上基于OpenHarmony3.2 Release版本的镜像验证的,如果是从未使用过RK3568,可以先查看[润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld)。 +## 开发环境 +- ubuntu20.04 +- [OpenHarmony3.2Release镜像](https://gitee.com/link?target=https%3A%2F%2Frepo.huaweicloud.com%2Fopenharmony%2Fos%2F3.2-Release%2Fdayu200_standard_arm32.tar.gz) +- [ohos_sdk_public 3.2.11.9 (API Version 9 Release)](https://gitee.com/link?target=https%3A%2F%2Frepo.huaweicloud.com%2Fopenharmony%2Fos%2F3.2-Release%2Fohos-sdk-windows_linux-public.tar.gz) +- [DevEco Studio 3.1 Beta2](https://gitee.com/link?target=https%3A%2F%2Fcontentcenter-vali-drcn.dbankcdn.cn%2Fpvt_2%2FDeveloperAlliance_package_901_9%2Ff3%2Fv3%2FuJyuq3syQ2ak4hE1QZmAug%2Fdevecostudio-windows-3.1.0.400.zip%3FHW-CC-KV%3DV1%26HW-CC-Date%3D20230408T013335Z%26HW-CC-Expire%3D315360000%26HW-CC-Sign%3D96262721EDC9B34E6F62E66884AB7AE2A94C2A7B8C28D6F7FC891F46EB211A70) +- [准备三方库构建环境](../../../tools/README.md#编译环境准备) +- [准备三方库测试环境](../../../tools/README.md#ci环境准备) +## 编译三方库 +- 下载本仓库 + ``` + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` +- 三方库目录结构 + ``` + tpc_c_cplusplus/thirdparty/libsrtp #三方库libsrtp的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ├── libsrtp_oh_pkg.patch #三方库libsrtp的patch文件 + ``` + +- 将libsrtp拷贝至tools/main目录下,并且将依赖的openssl和libpcap也拷贝至tools/main目录下 + ``` + cd tpc_c_cplusplus + cp thirdparty/libsrtp tools/main -rf + cp thirdparty/openssl tools/main -rf + cp thirdparty/libpcap tools/main -rf + ``` +- 在tools目录下编译三方库 + 编译环境的搭建参考[准备三方库构建环境](../../../tools/README.md#编译环境准备) + ``` + cd tools + ./build.sh libsrtp openssl libpcap + ``` +- 三方库头文件及生成的库 + 在tools目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + + ``` + libsrtp/arm64-v8a libsrtp/armeabi-v7a libpcap/arm64-v8a libpcap/armeabi-v7a openssl/arm64-v8a openssl/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示 + ![thirdparty_install_dir](pic/libsrtp_install_dir.png) +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + ``` + #将三方库加入工程中 + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libsrtp/${OHOS_ARCH}/lib/libsrtp2.a) + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libpcap/${OHOS_ARCH}/lib/libpcap.a) + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/openssl/${OHOS_ARCH}/lib/libssl.a) + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/openssl/${OHOS_ARCH}/lib/libcrypto.a) +#将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libsrtp/${OHOS_ARCH}/include) + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libpcap/${OHOS_ARCH}/include) + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/openssl/${OHOS_ARCH}/include) + ``` + ![libsrtp_usage](pic/libsrtp_usage.png) +## 测试三方库 +三方库的测试使用原库自带的测试用例来做测试,[准备三方库测试环境](../../../tools/README.md#ci环境准备) + +进入到构建目录执行ctest运行测试用例(arm64-v8a-build为构建64位的目录,armeabi-v7a-build为构建32位的目录) + + ![libsrtp_test](pic/libsrtp_test.png) + +## 参考资料 +- [润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld) +- [OpenHarmony三方库地址](https://gitee.com/openharmony-tpc) +- [OpenHarmony知识体系](https://gitee.com/openharmony-sig/knowledge) +- [通过DevEco Studio开发一个NAPI工程](https://gitee.com/openharmony-sig/knowledge_demo_temp/blob/master/docs/napi_study/docs/hello_napi.md) diff --git a/thirdparty/libsrtp/docs/pic/libsrtp_install_dir.png b/thirdparty/libsrtp/docs/pic/libsrtp_install_dir.png new file mode 100644 index 0000000000000000000000000000000000000000..1aeb40668b9a20998a94de361e19ffe9e41f901c Binary files /dev/null and b/thirdparty/libsrtp/docs/pic/libsrtp_install_dir.png differ diff --git a/thirdparty/libsrtp/docs/pic/libsrtp_test.png b/thirdparty/libsrtp/docs/pic/libsrtp_test.png new file mode 100644 index 0000000000000000000000000000000000000000..8353e522c5fdb79e13a5078dc10a26813bdf2b82 Binary files /dev/null and b/thirdparty/libsrtp/docs/pic/libsrtp_test.png differ diff --git a/thirdparty/libsrtp/docs/pic/libsrtp_usage.png b/thirdparty/libsrtp/docs/pic/libsrtp_usage.png new file mode 100644 index 0000000000000000000000000000000000000000..949eb059a0209e370230c59e9a58fc55ec5c2196 Binary files /dev/null and b/thirdparty/libsrtp/docs/pic/libsrtp_usage.png differ diff --git a/thirdparty/libsrtp/libsrtp_oh_pkg.patch b/thirdparty/libsrtp/libsrtp_oh_pkg.patch new file mode 100644 index 0000000000000000000000000000000000000000..9d1999c742352fa62d56c33846057fb3fc2de336 --- /dev/null +++ b/thirdparty/libsrtp/libsrtp_oh_pkg.patch @@ -0,0 +1,13 @@ +--- libsrtp-2.5.0/CMakeLists.txt 2023-02-01 15:25:02.000000000 +0800 ++++ CMakeLists.txt 2023-03-22 10:57:04.552717234 +0800 +@@ -289,7 +289,9 @@ + find_package(PCAP) + if (PCAP_FOUND) + add_executable(rtp_decoder test/rtp_decoder.c test/getopt_s.c test/util.c) +- target_link_libraries(rtp_decoder srtp2 ${PCAP_LIBRARY}) ++ target_link_libraries(rtp_decoder srtp2 ${PCAP_LIBRARY_TEMP}) ++ target_include_directories(rtp_decoder PRIVATE ${PCAP_INCLUDE_DIR_TEMP}) ++ + endif() + + if(NOT (BUILD_SHARED_LIBS AND WIN32))