diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/thirdparty/opus/HPKBUILD b/thirdparty/opus/HPKBUILD index c5579bc081a3ae2cbb55760e3077b8c86246ec09..05c3819c32a7de4abaaa64666ca1f85e4c930fbb 100644 --- a/thirdparty/opus/HPKBUILD +++ b/thirdparty/opus/HPKBUILD @@ -1,69 +1,63 @@ -# Contributor: shann -# Maintainer: shann -pkgname=opus -pkgver=v1.4 -pkgrel=0 -pkgdesc="OPUS is an open, royalty-free audio codec designed to provide high-fidelity audio transmission across various network environments." -url="https://opus-codec.org/" -archs=("armeabi-v7a" "arm64-v8a") -license=("BSD-licensed") -depends=() -makedepends=() - -source="https://downloads.xiph.org/releases/$pkgname/$pkgname-${pkgver:1}.tar.gz" - -autounpack=true -downloadpackage=true -buildtools="configure" - -builddir=$pkgname-${pkgver:1} -packagename=$builddir.tar.gz - -source envset.sh -host= +# This is an example HPKBUILD file. Use this as a start to creating your own, +# and remove these comments. +# NOTE: Please fill out the license field for your package! If it is unknown, +# then please put 'unknown'. + +# Contributor: Your Name +# Maintainer: Your Name + +pkgname=opus # 库名 +pkgver=1.4 # 库版本 +pkgrel=0 # 发布号 +pkgdesc="Opus is a codec for interactive speech and audio transmission over the Internet." # 库描述 +archs=("armeabi-v7a" "arm64-v8a") # cpu 架构 +url="https://opus-codec.org" +license=("the Modified(2-clause or 3-clause)BSD License or the Clear BSD License") +depends=() # 依赖库的目录名 必须保证被依赖的库的archs是当前库的archs的超集 +makedepends=() # 构建库时的依赖工具->需要用户安装的工具 +source="https://downloads.xiph.org/releases/opus/opus-1.4.tar.gz" + +downloadpackage=true # 是否自动下载压缩包,如若不写默认 true. (应对一些特殊情况,代码只能 git clone (项目中依赖 submoudle )) +autounpack=true # 是否自动解压,如若不写默认 true, 如果为 false 则需要用户在 prepare 函数中自行解压 +buildtools= cmake # 编译方法, 暂时支持cmake, configure, make等, 是什么就填写什么. 如若不写默认为cmake. + +builddir=$pkgname-${pkgver} # 源码压缩包解压后目录名 编译目录名 +packagename=$builddir.tar.gz # 压缩包名 + +# 为编译设置环境,如设置环境变量,创建编译目录等 prepare() { mkdir -p $builddir/$ARCH-build - if [ $ARCH == "armeabi-v7a" ]; then - setarm32ENV - host=arm-linux - elif [ $ARCH == "arm64-v8a" ]; then - setarm64ENV - host=aarch64-linux - else - echo "${ARCH} not support" - return -1 - fi } +# ${OHOS_SDK} oh sdk安装路径 +# $ARCH 编译的架构是 archs 的遍历 +# $LYCIUM_ROOT/usr/$pkgname/$ARCH 安装到顶层目录的usr/$pkgname/$ARCH +# 执行编译构建的命令 build() { - cd $builddir/$ARCH-build - ../configure "$@" --host=$host --enable-test > `pwd`/build.log 2>&1 - make -j4 VERBOSE=1 >> `pwd`/build.log 2>&1 + # 如果是cmake构建 "$@"=-DCMAKE_FIND_ROOT_PATH="..." -DCMAKE_TOOLCHAIN_FILE="..." -DCMAKE_INSTALL_PREFIX="..." 依赖库的搜索路径,toolchain file 路径,安装路径 + cd $builddir + ${OHOS_SDK}/native/build-tools/cmake/bin/cmake "$@" -DOHOS_ARCH=$ARCH -B$ARCH-build -S./ -L + make -j4 -C $ARCH-build + # 对最关键一步的退出码进行判断 ret=$? cd $OLDPWD return $ret } +# 打包安装 package() { cd $builddir - make -C $ARCH-build install >> `pwd`/$ARCH-build/build.log 2>&1 + make -C $ARCH-build install cd $OLDPWD - if [ $ARCH == "armeabi-v7a" ]; then - unsetarm32ENV - elif [ $ARCH == "arm64-v8a" ]; then - unsetarm64ENV - else - echo "${ARCH} not support" - return -1 - fi } +# 进行测试的准备和说明 check() { echo "The test must be on an OpenHarmony device!" - #编译生成目录$ARCH-build下执行make check } # 清理环境 cleanbuild() { - rm -rf ${PWD}/$builddir #${PWD}/$packagename + rm -rf ${PWD}/$builddir } + diff --git a/thirdparty/opus/HPKCHECK b/thirdparty/opus/HPKCHECK new file mode 100644 index 0000000000000000000000000000000000000000..379a6a5fe5416106412d25f40f230738b65435ce --- /dev/null +++ b/thirdparty/opus/HPKCHECK @@ -0,0 +1,46 @@ +# 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: zhangxin +# Maintainer: zhangxin + +source HPKBUILD > /dev/null 2>&1 +logfile=${LYCIUM_THIRDPARTY_ROOT}/${pkgname}/${pkgname}_${ARCH}_${OHOS_SDK_VER}_test.log + +openharmonycheck() { + cd $builddir/src + mount -o remount,rw / + + chmod 777 -R /tmp + + touch Enter.txt + #echo " " > Enter.txt + #busybox adduser test < Enter.txt + echo " " > Enter.txt + + + + ./opus.sh < Enter.txt > ${logfile} 2>&1 + res=$? + + rm Enter.txt + + chmod 771 -R /tmp + + + #busybox deluser test + + cd $OLDPWD + return $res +} + diff --git a/thirdparty/opus/OAT.xml b/thirdparty/opus/OAT.xml new file mode 100644 index 0000000000000000000000000000000000000000..03ee5a760a1f17e2e86907647046114696ade760 --- /dev/null +++ b/thirdparty/opus/OAT.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/thirdparty/opus/README.OpenSource b/thirdparty/opus/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..7066e9c06fb89ebcaac6caffea94567d5ef0dded --- /dev/null +++ b/thirdparty/opus/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "opus", + "License": "the Modified (2-clause or 3-clause) BSD License or the Clear BSD License." + "License File": "LICENSE_PLEASE_READ.txt", + "Version Number": "opus-1.4", + "Owner": "chenyajie5@huawei-partners.com", + "Upstream URL": "https://github.com/apple/cups/releases/tag/v2.3.6", + "Description": "Opus is a codec for interactive speech and audio transmission over the Internet." + } +] \ No newline at end of file diff --git a/thirdparty/opus/README_zh.md b/thirdparty/opus/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..fcc4ef8bf36c9bb0bab1d3a56b25828ef176ac7a --- /dev/null +++ b/thirdparty/opus/README_zh.md @@ -0,0 +1,19 @@ +# opus三方库说明 + +## 功能简介 + +Opus是一个用于在互联网上进行交互式语音和音频传输的编解码器。。 + + ## 使用约束 +- IDE版本:DevEco Studio 4.1.3.313 +- SDK版本:ohos_sdk_public 4.0.10.5 (API Version 10 Release) +- 三方库版本:opus-1.4 +- 当前适配的功能:支持语音和音乐,支持单声道和立体声,支持采样率8khz到48khz。 + + ## 集成方式 + [应用包hap集成](doc/hap_integrate.md) + + + + + diff --git a/thirdparty/opus/SHA512SUM b/thirdparty/opus/SHA512SUM index e4d39328caf028042fd1d26b57d637b27af17386..ddcc24d59d8573f717e002ddb491bc430913b120 100644 --- a/thirdparty/opus/SHA512SUM +++ b/thirdparty/opus/SHA512SUM @@ -1 +1 @@ -1ecd39e0add24de12823bf7c936bb67441228721e2cdae0edbfcf3cee0894bcc6edf2a1d0ca5cdfdad1565803bf39cc4c985ad32710c2a9582f850adeb5ca631 opus-1.4.tar.gz +5629eee714385d7fd9a97794b09acefa16654ef16cd5173cd8ff0415da12845808abe9369f94d7fc37b46a854c4a0430961ca112f47c9c2bf771f2607ecdb105 \ No newline at end of file diff --git a/thirdparty/opus/doc/hap_integrate.md b/thirdparty/opus/doc/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..f5930524153f07918868d10e86f0e7052a5e59f1 --- /dev/null +++ b/thirdparty/opus/doc/hap_integrate.md @@ -0,0 +1,77 @@ +# opus集成到应用hap + +本库是在华为mate60上进行测试的 + +## 开发环境 + +- [开发环境准备](../../../docs/hap_integrate_environment.md) + +## 编译三方库 + +- 下载本仓库 + + ```shell + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` + +- 三方库目录结构 + + ```shell + tpc_c_cplusplus/thirdparty/opus #三方库opus的目录结构如下 + ├── docs #三方库相关文档的文件 + ├── HPKBUILD #构建脚本 + ├── HPKCHECK #测试脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本、license等信息 + ├── README_zh.md + ``` + +- 在lycium目录下编译三方库 + + 编译环境的搭建参考[准备三方库构建环境](../../../lycium/README.md#1编译环境准备) + + ```shell + cd lycium + ./build.sh opus + ``` + +- 三方库头文件及生成的库 + + 在lycium目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + + ```shell + opus/arm64-v8a opus/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示 + +- ![Snipaste_2023-12-25_15-29-07](pic/Snipaste_2023-12-25_15-29-07.png) + +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + + ```cmake + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/opus/${OHOS_ARCH}/lib/libopus.a) + + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/opus/${OHOS_ARCH}/include) + ``` + + +## 测试三方库 + +三方库的测试使用原库自带的测试用例来做测试,[准备三方库测试环境](../../../lycium/README.md#3ci环境准备) + +因为该库编译后没有生成可执行程序需要自己手动编译,在对应架构的src目录下执行clang -o opus_demo opus_demo.c -lopus -lm -I../include -I../celt -I../silk,然后添加对应的参数进行测试 + +执行多项测试要自己创建一个.sh脚本将opus_demo放去其中输入不同的参数,执行编码或解码测试 + +![Snipaste_2023-12-25_15-33-25](pic/Snipaste_2023-12-25_15-33-25.png) + +## 参考资料 + +- [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) \ No newline at end of file diff --git a/thirdparty/opus/doc/pic/Snipaste_2023-12-25_15-29-07.png b/thirdparty/opus/doc/pic/Snipaste_2023-12-25_15-29-07.png new file mode 100644 index 0000000000000000000000000000000000000000..35d5b01ff75e1ea474aab8df5fac0c38de48ce42 Binary files /dev/null and b/thirdparty/opus/doc/pic/Snipaste_2023-12-25_15-29-07.png differ diff --git a/thirdparty/opus/doc/pic/Snipaste_2023-12-25_15-33-25.png b/thirdparty/opus/doc/pic/Snipaste_2023-12-25_15-33-25.png new file mode 100644 index 0000000000000000000000000000000000000000..abce775b82efd525d4d1d8ff758d2b0c066dc954 Binary files /dev/null and b/thirdparty/opus/doc/pic/Snipaste_2023-12-25_15-33-25.png differ diff --git a/thirdparty/opus/opus.sh b/thirdparty/opus/opus.sh new file mode 100644 index 0000000000000000000000000000000000000000..fca92a7a3ff08d4d2838139db0c8e6d164b5cf24 --- /dev/null +++ b/thirdparty/opus/opus.sh @@ -0,0 +1,2 @@ +./opus_demo -e voip 48000 1 32000 ../../speech.pcm ../../speech.opus #编码 +./opus_demo -d 24000 1 speech.opus speech1.pcm #解码