diff --git a/thirdparty/openh264/HPKBUILD b/thirdparty/openh264/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..22511cd87ad64c9031a54324dafaa4aaafcf9ebe --- /dev/null +++ b/thirdparty/openh264/HPKBUILD @@ -0,0 +1,114 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License + +# Contributor: Jeff Han , wupingyuan <3415239542@qq.com> +# Maintainer: Jeff Han +pkgname=openh264 +pkgver=v2.4.1 +pkgrel=0 +pkgdesc="Open Source H.264 Codec" +url="http://www.openh264.org/" +archs=("armeabi-v7a" "arm64-v8a" "x86_64") +license=("BSD-2-Clause") +depends=() +makedepends=() + +source="https://github.com/cisco/$pkgname/archive/refs/tags/$pkgver.tar.gz" + +autounpack=true +downloadpackage=true +patchflag=true +buildtools="configure" + +builddir=$pkgname-${pkgver:1} +packagename=$builddir.tar.gz + +source envset.sh + +arch= +destdir= +prepare() { + if $patchflag + then + cd $builddir + # 由于x86_64编译报错ld.lld: error: undefined symbol: __fprintf_chk + # >>> referenced by welsCodecTrace.cpp + # >>> welsCodecTrace.o:(welsStderrTrace(void*, int, char const*)) in archive ./libcommon.a + patch -p1 < `pwd`/../openh264_oh_pkg.patch + patchflag=false + cd $OLDPWD + fi + cp -rf $builddir $builddir-$ARCH-build + # 创建安装目录 + mkdir -p $LYCIUM_ROOT/usr/$pkgname/$ARCH + destdir=$LYCIUM_ROOT/usr/$pkgname/$ARCH/ + if [ $ARCH == "armeabi-v7a" ] + then + setarm32ENV + arch=armeabi + elif [ $ARCH == "arm64-v8a" ] + then + setarm64ENV + arch=aarch64 + elif [ $ARCH == "x86_64" ] + then + setx86_64ENV + arch=x86_64 + else + echo "${ARCH} not support" + return -1 + fi +} + +#参数1 +build() { + cd $builddir-$ARCH-build + envarch=$ARCH + $MAKE PREFIX=$destdir ARCH=$arch > $buildlog 2>&1 + ret=$? + cd $OLDPWD + ARCH=$envarch + return $ret +} + +package() { + cd $builddir-$ARCH-build + envarch=$ARCH + $MAKE install-static ARCH=$arch PREFIX=$destdir >> $buildlog 2>&1 + ARCH=$envarch + cd $OLDPWD +} + +check() { + unset arch + unset destdir + if [ $ARCH == "armeabi-v7a" ] + then + unsetarm32ENV + elif [ $ARCH == "arm64-v8a" ] + then + unsetarm64ENV + elif [ $ARCH == "x86_64" ] + then + unsetx86_64ENV + else + echo "${ARCH} not support" + return -1 + fi + echo "The test must be on an OpenHarmony device!" +} + +# 清理环境 +cleanbuild() { + rm -rf ${PWD}/$builddir $builddir-armeabi-v7a-build $builddir-arm64-v8a-build $builddir-x86_64-build #${PWD}/$packagename +} diff --git a/thirdparty/openh264/HPKCHECK b/thirdparty/openh264/HPKCHECK new file mode 100644 index 0000000000000000000000000000000000000000..001fc4855162150e720faec5575d87f269363c29 --- /dev/null +++ b/thirdparty/openh264/HPKCHECK @@ -0,0 +1,33 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License + +# Contributor: wupingyuan <3415239542@qq.com> +# Maintainer: wupingyuan <3415239542@qq.com> + +source HPKBUILD > /dev/null 2>&1 +logfile=${LYCIUM_THIRDPARTY_ROOT}/${pkgname}/${pkgname}_${ARCH}_${OHOS_SDK_VER}_test.log + +openharmonycheck() { + res=0 + cd $builddir-$ARCH-build/testbin + chmod 777 CmdLineExample.sh + ./CmdLineExample.sh > ${logfile} 2>&1 + res=$? + if [ $res -ne 0 ] + then + echo "CmdLineExample.sh failed" >> ${logfile} 2>&1 + res=1 + fi + cd $OLDPWD + return $res +} \ No newline at end of file diff --git a/thirdparty/openh264/README.OpenSource b/thirdparty/openh264/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..48363dab1ac282e5aa6aa0d33f13671291c44909 --- /dev/null +++ b/thirdparty/openh264/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "openh264", + "License": "BSD-2-Clause", + "License File": "https://github.com/cisco/openh264/blob/master/LICENSE", + "Version Number": "2.4.1", + "Owner": "xiafeng@huawei.com", + "Upstream URL": "https://github.com/cisco/openh264/archive/refs/tags/v2.4.1.tar.gz", + "Description": "Open Source H.264 Codec" + } +] diff --git a/thirdparty/openh264/README_zh.md b/thirdparty/openh264/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..efcb2216304db27edc575c8279dac4301805aa3b --- /dev/null +++ b/thirdparty/openh264/README_zh.md @@ -0,0 +1,15 @@ +# openh264三方库说明 +## 功能简介 +openh264是一个开源的H264编码器。 + +## 三方库版本 +- 2.4.1 + +## 已适配功能 +- 支持视频的编码 + +## 使用约束 +- [IDE和SDK版本](../../docs/constraint.md) + +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/openh264/SHA512SUM b/thirdparty/openh264/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..5f7a8f54a922ad4aed3a73446edde2d046015873 --- /dev/null +++ b/thirdparty/openh264/SHA512SUM @@ -0,0 +1,2 @@ +eb99144addd2e9c352bb95e752366e104ac6b0ddc84311dc7c87dafb803f8e7fe4d1e726833d49f8cc6d3914508e19c3a25ef82637a4993e8af3f504aa005baf openh264-2.4.1.tar.gz +b2be19c6cc952295229fd0195e57eee9546fa6764ce72bde439ecef5702184d79ca6abec0cd504d5e323d8f8907f29cad8f4ba973226dc7041c44456a5aa8cab openh264_oh_pkg.patch diff --git a/thirdparty/openh264/docs/hap_integrate.md b/thirdparty/openh264/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..636dd9bd09650b9996836d51c2d80323dd16128c --- /dev/null +++ b/thirdparty/openh264/docs/hap_integrate.md @@ -0,0 +1,69 @@ +# openh264集成到应用hap +本库是在RK3568开发板上基于OpenHarmony3.2 Release版本的镜像验证的,如果是从未使用过RK3568,可以先查看[润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld)。 +## 开发环境 +- [开发环境准备](../../../docs/hap_integrate_environment.md) +## 编译三方库 +- 下载本仓库 + ``` + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` + +- 三方库目录结构 + ``` + tpc_c_cplusplus/thirdparty/openh264 #三方库openh264的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── HPKCHECK #自动化测试脚本 + ├── openh264_oh_pkg.patch #补丁文件 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` + +- 在lycium目录下编译三方库 + 编译环境的搭建参考[准备三方库构建环境](../../../lycium/README.md#1编译环境准备) + + ``` + cd lycium + ./build.sh openh264 + ``` + +- 三方库头文件及生成的库 + 在lycium目录下会生成usr目录,该目录下存在已编译完成的32位、64位、x86_64位三方库 + ``` + openh264/arm64-v8a openh264/armeabi-v7a openh264/x86_64 + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示 + ![thirdparty_install_dir](pic/openh264_install_dir.png) + +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + ``` + #将三方库加入工程中 + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/openh264/${OHOS_ARCH}/lib/libopenh264.a) + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/openh264/${OHOS_ARCH}/include) + ``` +## 测试三方库 +三方库的测试使用原库自带的测试用例来做测试,[准备三方库测试环境](../../../lycium/README.md#3ci环境准备) + +- 进入到构建目录下的testbin目录,执行测试用例 + +- 执行结果如图所示: + + ```shell + cd tpc_c_cplusplus/thirdparty/openh264/openh264-2.4.1-arm64-v8a-build/testbin + ./CmdLineExample.sh + ``` + + ![openh264_test](pic/openh264_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/openh264/docs/pic/openh264_install_dir.png b/thirdparty/openh264/docs/pic/openh264_install_dir.png new file mode 100644 index 0000000000000000000000000000000000000000..68f27d434c4195def5f294ca862ee60b8c7a393b Binary files /dev/null and b/thirdparty/openh264/docs/pic/openh264_install_dir.png differ diff --git a/thirdparty/openh264/docs/pic/openh264_test.png b/thirdparty/openh264/docs/pic/openh264_test.png new file mode 100644 index 0000000000000000000000000000000000000000..fe8197e21610c3d9fe36b23fd443ee43827fbc29 Binary files /dev/null and b/thirdparty/openh264/docs/pic/openh264_test.png differ diff --git a/thirdparty/openh264/openh264_oh_pkg.patch b/thirdparty/openh264/openh264_oh_pkg.patch new file mode 100644 index 0000000000000000000000000000000000000000..485f5c90f7e2aa275ac2c35a762f66f0567623de --- /dev/null +++ b/thirdparty/openh264/openh264_oh_pkg.patch @@ -0,0 +1,12 @@ +diff -Naur openh264-2.4.1/codec/common/src/welsCodecTrace.cpp openh264-2.4.1-new/codec/common/src/welsCodecTrace.cpp +--- openh264-2.4.1/codec/common/src/welsCodecTrace.cpp 2024-01-30 13:56:32.000000000 +0800 ++++ openh264-2.4.1-new/codec/common/src/welsCodecTrace.cpp 2024-10-17 12:58:06.683361221 +0800 +@@ -47,7 +47,7 @@ + + + static void welsStderrTrace (void* ctx, int level, const char* string) { +- fprintf (stderr, "%s\n", string); ++ perror(string); + } + + welsCodecTrace::welsCodecTrace() {