diff --git a/SilkCodec_Test/.gitignore b/SilkCodec_Test/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/SilkCodec_Test/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/SilkCodec_Test/AppScope/app.json5 b/SilkCodec_Test/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..37d124f0b33fd658f7cf1146286d4499955c94db --- /dev/null +++ b/SilkCodec_Test/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.silkcodec_test", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/SilkCodec_Test/AppScope/resources/base/element/string.json b/SilkCodec_Test/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..e39f1d343117ba8569714a38d2a6fc5d3953809b --- /dev/null +++ b/SilkCodec_Test/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "SilkCodec_Test" + } + ] +} diff --git a/SilkCodec_Test/AppScope/resources/base/media/background.png b/SilkCodec_Test/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/SilkCodec_Test/AppScope/resources/base/media/background.png differ diff --git a/SilkCodec_Test/AppScope/resources/base/media/foreground.png b/SilkCodec_Test/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/SilkCodec_Test/AppScope/resources/base/media/foreground.png differ diff --git a/SilkCodec_Test/AppScope/resources/base/media/layered_image.json b/SilkCodec_Test/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/SilkCodec_Test/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/SilkCodec_Test/build-profile.json5 b/SilkCodec_Test/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..af1b098b32986a9e3ef783f68ce86ee879014b7a --- /dev/null +++ b/SilkCodec_Test/build-profile.json5 @@ -0,0 +1,56 @@ +{ + "app": { + "signingConfigs": [ + { + "name": "default", + "type": "HarmonyOS", + "material": { + "certpath": "C:\\Users\\lenovo\\.ohos\\config\\default_SilkCodec_Test_R7IshQh_AVC_PmIvm7nw1Eyw7UzHIRxXfumm4wk2l-8=.cer", + "keyAlias": "debugKey", + "keyPassword": "0000001B646530BE256C2B918FA82086A9EDC62950DDCCFE8FD3869306BE218E0D18C78F5DE0B4AD48F5F7", + "profile": "C:\\Users\\lenovo\\.ohos\\config\\default_SilkCodec_Test_R7IshQh_AVC_PmIvm7nw1Eyw7UzHIRxXfumm4wk2l-8=.p7b", + "signAlg": "SHA256withECDSA", + "storeFile": "C:\\Users\\lenovo\\.ohos\\config\\default_SilkCodec_Test_R7IshQh_AVC_PmIvm7nw1Eyw7UzHIRxXfumm4wk2l-8=.p12", + "storePassword": "0000001B4D472D1BFBB2291AFCE252863085A941089C0ADDDC8BE07E615D60680D0C18A6C550108B9F4A9E" + } + } + ], + "products": [ + { + "name": "default", + "signingConfig": "default", + "targetSdkVersion": "5.0.5(17)", + "compatibleSdkVersion": "5.0.5(17)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/SilkCodec_Test/code-linter.json5 b/SilkCodec_Test/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..073990fa45394e1f8e85d85418ee60a8953f9b99 --- /dev/null +++ b/SilkCodec_Test/code-linter.json5 @@ -0,0 +1,32 @@ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/SilkCodec_Test/entry/.gitignore b/SilkCodec_Test/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/SilkCodec_Test/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/SilkCodec_Test/entry/build-profile.json5 b/SilkCodec_Test/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..03472ff55d5375bf9dd1575991cf9897659a8e81 --- /dev/null +++ b/SilkCodec_Test/entry/build-profile.json5 @@ -0,0 +1,40 @@ +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + "abiFilters": ["arm64-v8a","x86_64"] + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/SilkCodec_Test/entry/hvigorfile.ts b/SilkCodec_Test/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..b0e3a1ab98a91bc918d6404b2413111a5011f14a --- /dev/null +++ b/SilkCodec_Test/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ +} \ No newline at end of file diff --git a/SilkCodec_Test/entry/obfuscation-rules.txt b/SilkCodec_Test/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/SilkCodec_Test/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/SilkCodec_Test/entry/oh-package-lock.json5 b/SilkCodec_Test/entry/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ccf050a5468eb3abf8708258709d87eeecad2ad9 --- /dev/null +++ b/SilkCodec_Test/entry/oh-package-lock.json5 @@ -0,0 +1,18 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "libentry.so@src/main/cpp/types/libentry": "libentry.so@src/main/cpp/types/libentry" + }, + "packages": { + "libentry.so@src/main/cpp/types/libentry": { + "name": "libentry.so", + "version": "1.0.0", + "resolved": "src/main/cpp/types/libentry", + "registryType": "local" + } + } +} \ No newline at end of file diff --git a/SilkCodec_Test/entry/oh-package.json5 b/SilkCodec_Test/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b9c1d4cca76ac664388dd6b1cf96697184c5133b --- /dev/null +++ b/SilkCodec_Test/entry/oh-package.json5 @@ -0,0 +1,11 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libentry.so": "file:./src/main/cpp/types/libentry" + } +} \ No newline at end of file diff --git a/SilkCodec_Test/entry/src/main/cpp/CMakeLists.txt b/SilkCodec_Test/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..12098be42717b2b23a7c50abca67313770592b9d --- /dev/null +++ b/SilkCodec_Test/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,16 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(SilkCodec_Test) +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) +include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libSilkCodec/${OHOS_ARCH}/include) + +add_library(entry SHARED napi_init.cpp) +target_link_libraries(entry PUBLIC libace_napi.z.so) +target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libSilkCodec/${OHOS_ARCH}/lib/libSilkCodec.so) \ No newline at end of file diff --git a/SilkCodec_Test/entry/src/main/cpp/napi_init.cpp b/SilkCodec_Test/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8e51858f17b9bfde43e19f6db0a83bf839e40970 --- /dev/null +++ b/SilkCodec_Test/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,295 @@ +#include "napi/native_api.h" +#include "codec.h" +#include +#include +#include + +// 同步编解码上下文 +struct SyncCodecContext { + std::vector outputData; // 存储输出数据 + bool success; // 操作是否成功 + std::string errorMessage; // 错误信息 +}; + +// 同步解码回调 +static void SyncDecodeCallback(void* userdata, unsigned char* p, int len) { + auto* ctx = static_cast(userdata); + if (!ctx || !p || len <= 0) return; + + try { + // 累积解码数据 + size_t currentSize = ctx->outputData.size(); + ctx->outputData.resize(currentSize + len); + memcpy(ctx->outputData.data() + currentSize, p, len); + } catch (...) { + ctx->success = false; + ctx->errorMessage = "内存分配失败"; + } +} + +// 同步编码回调 +static void SyncEncodeCallback(void* userdata, unsigned char* p, int len) { + auto* ctx = static_cast(userdata); + if (!ctx || !p || len <= 0) return; + + try { + // 累积编码数据 + size_t currentSize = ctx->outputData.size(); + ctx->outputData.resize(currentSize + len); + memcpy(ctx->outputData.data() + currentSize, p, len); + } catch (...) { + ctx->success = false; + ctx->errorMessage = "内存分配失败"; + } +} + +// 同步 SILK 解码实现 +static napi_value SilkDecodeSync(napi_env env, napi_callback_info info) { + + size_t argc = 2; + napi_value argv[2]; + napi_value thisArg; + void* data; + + // 解析参数 + napi_get_cb_info(env, info, &argc, argv, &thisArg, &data); + + if (argc < 2) { + napi_throw_error(env, nullptr, "需要2个参数: silkData, sampleRate"); + return nullptr; + } + + // 参数类型验证 + napi_valuetype argTypes[2]; + for (int i = 0; i < 2; i++) { + napi_typeof(env, argv[i], &argTypes[i]); + } + + if (argTypes[0] != napi_object) { + napi_throw_type_error(env, nullptr, "silkData 必须是 ArrayBuffer"); + return nullptr; + } + if (argTypes[1] != napi_number) { + napi_throw_type_error(env, nullptr, "sampleRate 必须是数字"); + return nullptr; + } + + // 获取 SILK 数据 + unsigned char* silkData = nullptr; + size_t dataLen = 0; + napi_get_arraybuffer_info(env, argv[0], (void**)&silkData, &dataLen); + + if (!silkData || dataLen == 0) { + napi_throw_error(env, nullptr, "无效的 SILK 数据"); + return nullptr; + } + + // 获取采样率 + int32_t sampleRate; + napi_get_value_int32(env, argv[1], &sampleRate); + + if (sampleRate <= 0) { + napi_throw_range_error(env, nullptr, "采样率必须大于0"); + return nullptr; + } + + // 创建同步上下文 + SyncCodecContext ctx; + ctx.success = true; + ctx.outputData.reserve(dataLen * 4); // 预分配空间 + + try { + // 同步调用解码函数 + int result = silkDecode(silkData, static_cast(dataLen), sampleRate, + SyncDecodeCallback, &ctx); + + if (result != 1) { + ctx.success = false; + ctx.errorMessage = "解码函数返回失败"; + } + + } catch (const std::exception& e) { + ctx.success = false; + ctx.errorMessage = std::string("解码异常: ") + e.what(); + } catch (...) { + ctx.success = false; + ctx.errorMessage = "未知解码异常"; + } + + // 处理结果 + if (!ctx.success) { + napi_throw_error(env, nullptr, ctx.errorMessage.c_str()); + return nullptr; + } + + if (ctx.outputData.empty()) { + napi_throw_error(env, nullptr, "解码成功但未产生输出数据"); + return nullptr; + } + + // 创建返回的 ArrayBuffer + napi_value resultArrayBuffer; + void* resultData = nullptr; + napi_status status = napi_create_arraybuffer(env, ctx.outputData.size(), + &resultData, &resultArrayBuffer); + + if (status != napi_ok || !resultData) { + napi_throw_error(env, nullptr, "创建输出缓冲区失败"); + return nullptr; + } + + // 复制数据到 ArrayBuffer + memcpy(resultData, ctx.outputData.data(), ctx.outputData.size()); + + return resultArrayBuffer; +} + +// 同步 SILK 编码实现 +static napi_value SilkEncodeSync(napi_env env, napi_callback_info info) { + + + size_t argc = 2; + napi_value argv[2]; + napi_value thisArg; + void* data; + + napi_get_cb_info(env, info, &argc, argv, &thisArg, &data); + + if (argc < 2) { + napi_throw_error(env, nullptr, "需要2个参数: pcmData, sampleRate"); + return nullptr; + } + + // 参数验证 + napi_valuetype valueType; + napi_typeof(env, argv[0], &valueType); + if (valueType != napi_object) { + napi_throw_type_error(env, nullptr, "pcmData 必须是 ArrayBuffer"); + return nullptr; + } + + // 获取 PCM 数据 + unsigned char* pcmData = nullptr; + size_t dataLen = 0; + napi_get_arraybuffer_info(env, argv[0], (void**)&pcmData, &dataLen); + + if (!pcmData || dataLen == 0) { + napi_throw_error(env, nullptr, "无效的 PCM 数据"); + return nullptr; + } + + // 获取采样率 + int32_t sampleRate; + napi_get_value_int32(env, argv[1], &sampleRate); + + if (sampleRate <= 0) { + napi_throw_range_error(env, nullptr, "采样率必须大于0"); + return nullptr; + } + + // 创建同步上下文 + SyncCodecContext ctx; + ctx.success = true; + ctx.outputData.reserve(dataLen / 2); // SILK 通常比 PCM 小 + try { + // 计算 PCM 样本数 (假设 16bit 采样) + int pcmSamples = static_cast(dataLen) / 2; + + // 同步调用编码函数 + int encodeResult = silkEncode(pcmData, pcmSamples, sampleRate, + SyncEncodeCallback, &ctx); + + if (encodeResult != 1) { + ctx.success = false; + ctx.errorMessage = "编码函数返回失败"; + } + } catch (const std::exception& e) { + ctx.success = false; + ctx.errorMessage = std::string("编码异常: ") + e.what(); + } catch (...) { + ctx.success = false; + ctx.errorMessage = "未知编码异常"; + } + + // 处理结果 + if (!ctx.success) { + napi_throw_error(env, nullptr, ctx.errorMessage.c_str()); + return nullptr; + } + + if (ctx.outputData.empty()) { + napi_throw_error(env, nullptr, "编码成功但未产生输出数据"); + return nullptr; + } + + // 创建返回的 ArrayBuffer + napi_value resultArrayBuffer; + void* resultData = nullptr; + napi_status status = napi_create_arraybuffer(env, ctx.outputData.size(), + &resultData, &resultArrayBuffer); + + if (status != napi_ok || !resultData) { + napi_throw_error(env, nullptr, "创建输出缓冲区失败"); + return nullptr; + } + + // 复制数据到 ArrayBuffer + memcpy(resultData, ctx.outputData.data(), ctx.outputData.size()); + + return resultArrayBuffer; +} + +// 编解码器可用性检查 +static napi_value CheckCodecAvailable(napi_env env, napi_callback_info info) { + + napi_value result; + bool available = true; + + // 这里可以添加更详细的可用性检查 + // 比如检查必要的符号、初始化状态等 + + napi_get_boolean(env, available, &result); + + return result; +} + +// 获取版本信息 +static napi_value GetCodecVersion(napi_env env, napi_callback_info info) { + napi_value version; + napi_create_string_utf8(env, "1.0.0", NAPI_AUTO_LENGTH, &version); + return version; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) { + napi_property_descriptor desc[] = { + // 同步接口 + {"silkDecodeSync", nullptr, SilkDecodeSync, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"silkEncodeSync", nullptr, SilkEncodeSync, nullptr, nullptr, nullptr, napi_default, nullptr}, + + // 工具函数 + {"checkCodecAvailable", nullptr, CheckCodecAvailable, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"getCodecVersion", nullptr, GetCodecVersion, nullptr, nullptr, nullptr, napi_default, nullptr} + }; + + napi_status status = napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + if (status != napi_ok) { + return nullptr; + } + return exports; +} +EXTERN_C_END + +static napi_module codecModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void*)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { + napi_module_register(&codecModule); +} \ No newline at end of file diff --git a/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/arm64-v8a/include/codec.h b/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/arm64-v8a/include/codec.h new file mode 100644 index 0000000000000000000000000000000000000000..29246127e21d7103388eeb3550c29eb4a44940f2 --- /dev/null +++ b/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/arm64-v8a/include/codec.h @@ -0,0 +1,51 @@ +#ifndef _CODEC_H_ +#define _CODEC_H_ + +#include "common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Codec callback function +typedef void (cb_codec)(void* userdata, unsigned char* p, int len); + +/** + * Decode SILK data to PCM + * + * @param silkData silk file data + * + * @param dataLen data length + * + * @param sampleRate target samplerate + * + * @param callback codec callback + * + * @param userdata user data + * + * @return 1 = success, 0 = failed + */ +int __dllexport silkDecode(unsigned char* silkData, int dataLen, int sampleRate, cb_codec callback, void* userdata); + +/** + * Encode PCM data to SILK + * + * @param pcmData pcm data + * + * @param dataLen data length + * + * @param sampleRate target samplerate + * + * @param callback codec callback + * + * @param userdata user data + * + * @return 1 = success, 0 = failed + */ +int __dllexport silkEncode(unsigned char* pcmData, int dataLen, int sampleRate, cb_codec callback, void* userdata); + +#ifdef __cplusplus +} +#endif + +#endif /* _CODEC_H_ */ diff --git a/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/arm64-v8a/include/common.h b/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/arm64-v8a/include/common.h new file mode 100644 index 0000000000000000000000000000000000000000..305e43a7c2e51fed8ff906cd181e2b9136b06271 --- /dev/null +++ b/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/arm64-v8a/include/common.h @@ -0,0 +1,46 @@ +#ifndef _COMMON_H_ +#define _COMMON_H_ + +#define _CRT_SECURE_NO_WARNINGS + +//#include +//#include + +#include +#include + +/* Define codec specific settings */ +#define MAX_INPUT_FRAMES 5 +#define MAX_FRAME_LENGTH 480 +#define FRAME_LENGTH_MS 20 +#define MAX_API_FS_KHZ 48 +#define MAX_LBRR_DELAY 2 +#define MAX_BYTES_PER_FRAME 250 // Equals peak bitrate of 100 kbps + +#ifdef _SYSTEM_IS_BIG_ENDIAN +/* Function to convert a little endian int16 to a */ +/* big endian int16 or vica verca */ +void swap_endian( + SKP_int16 vec[], /* I/O array of */ + SKP_int len /* I length */ +) +{ + SKP_int i; + SKP_int16 tmp; + SKP_uint8* p1, * p2; + + for (i = 0; i < len; i++) { + tmp = vec[i]; + p1 = (SKP_uint8*)&vec[i]; p2 = (SKP_uint8*)&tmp; + p1[0] = p2[1]; p1[1] = p2[0]; + } +} +#endif + +#ifdef _WIN32 +#define __dllexport __declspec(dllexport) +#else +#define __dllexport +#endif + +#endif /* _COMMON_H_ */ diff --git a/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/arm64-v8a/lib/libSilkCodec.so b/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/arm64-v8a/lib/libSilkCodec.so new file mode 100644 index 0000000000000000000000000000000000000000..eef459879d3b486b7f9661e9bd93edb8b0f94cf7 Binary files /dev/null and b/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/arm64-v8a/lib/libSilkCodec.so differ diff --git a/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/arm64-v8a/lib/libSilkCodec_static.a b/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/arm64-v8a/lib/libSilkCodec_static.a new file mode 100644 index 0000000000000000000000000000000000000000..a55eae89cf1dd126cb58052fa02de581ac50ed92 Binary files /dev/null and b/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/arm64-v8a/lib/libSilkCodec_static.a differ diff --git a/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/armeabi-v7a/include/codec.h b/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/armeabi-v7a/include/codec.h new file mode 100644 index 0000000000000000000000000000000000000000..d4139b9fd5cf7eea8e7ed7e9c85b1d9ad08134a9 --- /dev/null +++ b/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/armeabi-v7a/include/codec.h @@ -0,0 +1,47 @@ +#ifndef _CODEC_H_ +#define _CODEC_H_ + +#include "common.h" +#ifdef __cplusplus +extern "C" { +#endif +// Codec callback function +typedef void (cb_codec)(void* userdata, unsigned char* p, int len); + +/** + * Decode SILK data to PCM + * + * @param silkData silk file data + * + * @param dataLen data length + * + * @param sampleRate target samplerate + * + * @param callback codec callback + * + * @param userdata user data + * + * @return 1 = success, 0 = failed + */ +int __dllexport silkDecode(unsigned char* silkData, int dataLen, int sampleRate, cb_codec callback, void* userdata); + +/** + * Encode PCM data to SILK + * + * @param pcmData pcm data + * + * @param dataLen data length + * + * @param sampleRate target samplerate + * + * @param callback codec callback + * + * @param userdata user data + * + * @return 1 = success, 0 = failed + */ +int __dllexport silkEncode(unsigned char* pcmData, int dataLen, int sampleRate, cb_codec callback, void* userdata); +#ifdef __cplusplus +} +#endif +#endif /* _CODEC_H_ */ diff --git a/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/armeabi-v7a/include/common.h b/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/armeabi-v7a/include/common.h new file mode 100644 index 0000000000000000000000000000000000000000..017aa1d091b786f337db7908977ad71fb97e551d --- /dev/null +++ b/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/armeabi-v7a/include/common.h @@ -0,0 +1,46 @@ +#ifndef _COMMON_H_ +#define _COMMON_H_ + +#define _CRT_SECURE_NO_WARNINGS + +#include +#include + +#include +#include + +/* Define codec specific settings */ +#define MAX_INPUT_FRAMES 5 +#define MAX_FRAME_LENGTH 480 +#define FRAME_LENGTH_MS 20 +#define MAX_API_FS_KHZ 48 +#define MAX_LBRR_DELAY 2 +#define MAX_BYTES_PER_FRAME 250 // Equals peak bitrate of 100 kbps + +#ifdef _SYSTEM_IS_BIG_ENDIAN +/* Function to convert a little endian int16 to a */ +/* big endian int16 or vica verca */ +void swap_endian( + SKP_int16 vec[], /* I/O array of */ + SKP_int len /* I length */ +) +{ + SKP_int i; + SKP_int16 tmp; + SKP_uint8* p1, * p2; + + for (i = 0; i < len; i++) { + tmp = vec[i]; + p1 = (SKP_uint8*)&vec[i]; p2 = (SKP_uint8*)&tmp; + p1[0] = p2[1]; p1[1] = p2[0]; + } +} +#endif + +#ifdef _WIN32 +#define __dllexport __declspec(dllexport) +#else +#define __dllexport +#endif + +#endif /* _COMMON_H_ */ diff --git a/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/armeabi-v7a/lib/libSilkCodec.so b/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/armeabi-v7a/lib/libSilkCodec.so new file mode 100644 index 0000000000000000000000000000000000000000..df68c165806734e54c171dfc879b5c33d79c0f68 Binary files /dev/null and b/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/armeabi-v7a/lib/libSilkCodec.so differ diff --git a/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/armeabi-v7a/lib/libSilkCodec_static.a b/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/armeabi-v7a/lib/libSilkCodec_static.a new file mode 100644 index 0000000000000000000000000000000000000000..bf2a24b5eff830933c2b7db136a2ea1339dcc03a Binary files /dev/null and b/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/armeabi-v7a/lib/libSilkCodec_static.a differ diff --git a/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/x86_64/include/codec.h b/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/x86_64/include/codec.h new file mode 100644 index 0000000000000000000000000000000000000000..3b70d3ecf2453530888e5f31450071627d73938f --- /dev/null +++ b/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/x86_64/include/codec.h @@ -0,0 +1,48 @@ +#ifndef _CODEC_H_ +#define _CODEC_H_ + +#include "common.h" +#ifdef __cplusplus +extern "C" { +#endif +// Codec callback function +typedef void (cb_codec)(void* userdata, unsigned char* p, int len); + +/** + * Decode SILK data to PCM + * + * @param silkData silk file data + * + * @param dataLen data length + * + * @param sampleRate target samplerate + * + * @param callback codec callback + * + * @param userdata user data + * + * @return 1 = success, 0 = failed + */ +int __dllexport silkDecode(unsigned char* silkData, int dataLen, int sampleRate, cb_codec callback, void* userdata); + +/** + * Encode PCM data to SILK + * + * @param pcmData pcm data + * + * @param dataLen data length + * + * @param sampleRate target samplerate + * + * @param callback codec callback + * + * @param userdata user data + * + * @return 1 = success, 0 = failed + */ +int __dllexport silkEncode(unsigned char* pcmData, int dataLen, int sampleRate, cb_codec callback, void* userdata); +#ifdef __cplusplus +} +#endif + +#endif /* _CODEC_H_ */ diff --git a/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/x86_64/include/common.h b/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/x86_64/include/common.h new file mode 100644 index 0000000000000000000000000000000000000000..305e43a7c2e51fed8ff906cd181e2b9136b06271 --- /dev/null +++ b/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/x86_64/include/common.h @@ -0,0 +1,46 @@ +#ifndef _COMMON_H_ +#define _COMMON_H_ + +#define _CRT_SECURE_NO_WARNINGS + +//#include +//#include + +#include +#include + +/* Define codec specific settings */ +#define MAX_INPUT_FRAMES 5 +#define MAX_FRAME_LENGTH 480 +#define FRAME_LENGTH_MS 20 +#define MAX_API_FS_KHZ 48 +#define MAX_LBRR_DELAY 2 +#define MAX_BYTES_PER_FRAME 250 // Equals peak bitrate of 100 kbps + +#ifdef _SYSTEM_IS_BIG_ENDIAN +/* Function to convert a little endian int16 to a */ +/* big endian int16 or vica verca */ +void swap_endian( + SKP_int16 vec[], /* I/O array of */ + SKP_int len /* I length */ +) +{ + SKP_int i; + SKP_int16 tmp; + SKP_uint8* p1, * p2; + + for (i = 0; i < len; i++) { + tmp = vec[i]; + p1 = (SKP_uint8*)&vec[i]; p2 = (SKP_uint8*)&tmp; + p1[0] = p2[1]; p1[1] = p2[0]; + } +} +#endif + +#ifdef _WIN32 +#define __dllexport __declspec(dllexport) +#else +#define __dllexport +#endif + +#endif /* _COMMON_H_ */ diff --git a/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/x86_64/lib/libSilkCodec.so b/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/x86_64/lib/libSilkCodec.so new file mode 100644 index 0000000000000000000000000000000000000000..d2a2573929fe67db72d2f0949b93242413fec016 Binary files /dev/null and b/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/x86_64/lib/libSilkCodec.so differ diff --git a/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/x86_64/lib/libSilkCodec_static.a b/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/x86_64/lib/libSilkCodec_static.a new file mode 100644 index 0000000000000000000000000000000000000000..0353f7255fe2b84ec25bbc19dc0896f9a7284c9a Binary files /dev/null and b/SilkCodec_Test/entry/src/main/cpp/thirdparty/libSilkCodec/x86_64/lib/libSilkCodec_static.a differ diff --git a/SilkCodec_Test/entry/src/main/cpp/types/libentry/Index.d.ts b/SilkCodec_Test/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..39d3dbddf61564c02b1c78c5020fdf00fddefe06 --- /dev/null +++ b/SilkCodec_Test/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,3 @@ +export const silkDecodeSync: (silkData: ArrayBuffer, sampleRate: number) =>ArrayBuffer; +// 同步编码 +export const silkEncodeSync:(pcmData: ArrayBuffer, sampleRate: number) => ArrayBuffer; \ No newline at end of file diff --git a/SilkCodec_Test/entry/src/main/cpp/types/libentry/oh-package.json5 b/SilkCodec_Test/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..56322781032ce5be8c48efc7fe8e4bf5b46baaa9 --- /dev/null +++ b/SilkCodec_Test/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -0,0 +1,6 @@ +{ + "name": "libentry.so", + "types": "./Index.d.ts", + "version": "1.0.0", + "description": "Please describe the basic information." +} \ No newline at end of file diff --git a/SilkCodec_Test/entry/src/main/ets/entryability/EntryAbility.ets b/SilkCodec_Test/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..b12b706076bc833e0f1c073e99881ef3b3a84004 --- /dev/null +++ b/SilkCodec_Test/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,44 @@ +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/SilkCodec_Test/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/SilkCodec_Test/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..fae19f9dd53d2857e2843539cbedf5bee4a34b5a --- /dev/null +++ b/SilkCodec_Test/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,16 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/SilkCodec_Test/entry/src/main/ets/pages/Index.ets b/SilkCodec_Test/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..74ae84f66e120965223ceff26846d74a0612885d --- /dev/null +++ b/SilkCodec_Test/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,230 @@ +import testNapi from 'libentry.so'; +import { BusinessError } from '@ohos.base'; +import fs from '@ohos.file.fs'; +import { common } from '@kit.AbilityKit'; +@Entry +@Component +struct Index { + @State message: string = 'SILK同步编解码测试'; + @State result: string = 'decodeSilk Test'; + @State output: string = '文件保存结果'; + @State isCodecAvailable: boolean = false; + @State isProcessing: boolean = false; + @State playStatus: string = "未播放"; + + private context = getContext(this) as common.UIAbilityContext; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(14) + .width('65%') + .padding(15) + .margin(25) + .backgroundColor('#007aff') + .borderRadius(8) + Button('同步编码测试') + .width('65%') + .onClick(async () => { + try { + console.log("pcmData test date start "); + const encodeResult = await this.testEncode(); + if (encodeResult != null) { + this.result += `testEncode调用成功!\nSILK 数据长度:${encodeResult.byteLength} 字节`; + } else { + this.result = `编码失败:${encodeResult || '未知原因'}`; + } + } catch (e) { + console.error("encodePcm errCode:" + e.code + ",errMessage:" + e.message); + this.result = `encodePcm test fail = ${e.code}`; + } + }) + + Text(this.result) + .fontSize(14) + .width('65%') + .padding(15) + .backgroundColor('#34c759') + .borderRadius(8) + .textAlign(TextAlign.Start) + + Text(this.output) + .fontSize(14) + .width('65%') + .padding(15) + .backgroundColor('#34c759') + .borderRadius(8) + .textAlign(TextAlign.Start) + } + .width('100%') + } + .height('100%') + } + + // 从文件读取PCM数据 + async readPcmFromFile(): Promise { + try { + let path = getContext().resourceDir + '/input.pcm'; + // let resourceDirTest = path + '/input.pcm'; + console.log(`读取PCM文件: ${path}`); + + const file = await fs.open(path, fs.OpenMode.READ_ONLY); + try { + const stat = await fs.stat(file.fd); + console.log(`文件大小: ${stat.size} 字节`); + const totalSize = stat.size; + const buffer = new ArrayBuffer(totalSize); + let offset = 0; // 已读取偏移量 + + // 循环读取,确保获取完整数据 + while (offset < totalSize) { + const readSize = await fs.read(file.fd, buffer, { offset }); + if (readSize <= 0) break; // 读取失败或结束 + offset += readSize; + } + + if (offset !== totalSize) { + console.error(`读取不完整:预期 ${totalSize} 字节,实际读取 ${offset} 字节`); + return null; + } + + console.log(`文件大小: ${totalSize} 字节,实际读取: ${offset} 字节`); + const dataView = new Uint8Array(buffer.slice(0, offset)); + console.log(`PCM文件前50字节:`, Array.from(dataView.slice(0, 50))); + return buffer.slice(0, offset); + } finally { + await fs.close(file.fd); + } + } catch (error) { + console.error("读取PCM文件失败:", error); + throw new Error(`读取PCM文件失败:: ${(error as BusinessError).message}`); + } + } + + // 保存编码后的数据 + async saveEncodedData(data: ArrayBuffer): Promise { + try { + let path = getContext().filesDir + '/output.silk'; + // let resourceDirTest = path + '/output.silk'; + console.log(`保存SILK文件: ${path}`); + const file = await fs.open(path, fs.OpenMode.WRITE_ONLY | fs.OpenMode.CREATE); + console.log(`打开SILK文件路径: ${file.fd}`); + try { + await fs.write(file.fd, data); + console.log(`编码结果保存成功: ${path}, 大小: ${data.byteLength} 字节`); + this.output += `\nSILK文件已保存: ${path}`; + } finally { + await fs.close(file.fd); + } + } catch (error) { + console.error("保存编码数据失败:", error); + this.output += `\nSILK文件已保存失败`; + } + } + + // 保存编码后的数据 + async saveDecodeData(data: ArrayBuffer): Promise { + try { + let path = getContext().filesDir; + let resourceDirTest = path + '/outputpcm.pcm'; + console.log(`保存PCM文件: ${resourceDirTest}`); + const file = await fs.open(resourceDirTest, fs.OpenMode.WRITE_ONLY | fs.OpenMode.CREATE); + console.log(`打开PCM文件路径: ${file.fd}`); + try { + await fs.write(file.fd, data); + console.log(`解码结果保存成功: ${resourceDirTest}, 大小: ${data.byteLength} 字节`); + this.output += `\nPCM文件已保存: ${resourceDirTest}`; + } finally { + await fs.close(file.fd); + } + } catch (error) { + console.error("保存解码数据失败:", error); + this.output += `\nPCM文件已保存失败`; + } + } + + async testEncode(): Promise { + this.isProcessing = true; + const pcmData = await this.readPcmFromFile(); + if (!pcmData) { + console.error("PCM 数据为空或读取失败"); + this.result += "编码失败:PCM 数据无效"; + return null; + } + console.log(`testEncode PCM文件数据长度:`, pcmData.byteLength); + // 验证 16bit 单声道格式(长度必须为 2 的倍数) + if (pcmData.byteLength % 2 !== 0) { + console.warn('PCM 数据长度不是 2 的倍数(16bit 格式要求),自动截断末尾字节'); + const validLength = Math.floor(pcmData.byteLength / 2) * 2; + const pcm = pcmData.slice(0, validLength); // 截断为 2 的倍数 + } + + const dataView = new Uint8Array(pcmData, 0, pcmData.byteLength); + console.log(`testEncode PCM文件前50字节:`, Array.from(dataView.slice(0, pcmData.byteLength))); + + try { + const result = testNapi.silkEncodeSync(pcmData, 24000); + console.log('syncCodecManager encodePcm test output SILK:', `长度=${result.byteLength} 字节`); + if (result.byteLength === 0) { + this.result += `++编码失败! 无有效 SILK 数据`; + return null; + } + this.result += `++编码成功!`; + console.log('编码成功 encodePcm test SILK:', `长度=${result.byteLength} 字节`); + // 保存编码结果 + await this.saveEncodedData(result); + const decodeResult = testNapi.silkDecodeSync(result, 24000); // 24kHz 与编码时一致 + console.log('解码后 PCM 长度:', `长度=${decodeResult.byteLength} 字节`); + if (!decodeResult || decodeResult.byteLength === 0 || decodeResult.byteLength % 2 !== 0) { + this.result += `\n解码失败:无有效 PCM 数据或数据格式错误`; + console.error('解码失败:数据无效', decodeResult); + return result; + } + // 验证解码数据与原始 PCM 的长度一致性(允许微小差异,如帧对齐导致的末尾截断) + const originLength = pcmData.byteLength; + const decodeLength = decodeResult.byteLength; + console.log(`原始 PCM 长度: ${originLength}, 解码 PCM 长度: ${decodeLength}`); + if (Math.abs(originLength - decodeLength) > 100) { // 允许 100 字节内差异(帧对齐) + console.warn('解码数据长度与原始数据差异较大,可能参数不匹配'); + this.result += `\n警告:解码数据长度与原始数据不一致(原始: ${originLength}, 解码: ${decodeLength})`; + } + + // 打印解码后前 50 字节,与原始 PCM 对比 + const originView = new Uint8Array(pcmData.slice(0, 50)); + const decodeView = new Uint8Array(decodeResult.slice(0, 50)); + console.log('原始 PCM 前 50 字节:', Array.from(originView)); + console.log('解码 PCM 前 50 字节:', Array.from(decodeView)); + + // const datalist = new Uint8Array(decodeResult, 0, decodeResult.byteLength); + // console.log(`解码成功 PCM文件前50字节:`, Array.from(datalist.slice(0, decodeResult.byteLength))); + // console.log('解码成功 decodePcm test PCM:', `长度=${decodeResult.byteLength} 字节`); + await this.saveDecodeData(decodeResult); + this.result += `++解码成功!`; + return decodeResult; + } catch (error) { + this.result += `silkEncodeSync 失败: ${error.message}`; + console.log('silkEncodeSync 失败 SILK:', error.message); + return null; + } finally { + this.isProcessing = false; + } + } + + async testDecode(pcmData: ArrayBuffer) { + this.isProcessing = true; + try { + const result = testNapi.silkDecodeSync(pcmData, 24000); + console.log("syncCodecManager decodeSilk test date : ", result.slice(0, 50)); + if (result.byteLength > 0) { + this.result = `解码成功!`; + } else { + this.result = `解码失败!`; + } + } catch (error) { + this.result = `解码失败: ${error.message}`; + } finally { + this.isProcessing = false; + } + } +} \ No newline at end of file diff --git a/SilkCodec_Test/entry/src/main/module.json5 b/SilkCodec_Test/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..1cf10bcbee31beca865cd0e3f142c7b258335421 --- /dev/null +++ b/SilkCodec_Test/entry/src/main/module.json5 @@ -0,0 +1,52 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/SilkCodec_Test/entry/src/main/resources/base/element/color.json b/SilkCodec_Test/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..d66f9a7d4ac61fb8d215239ab3620b7bcd77bf33 --- /dev/null +++ b/SilkCodec_Test/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/SilkCodec_Test/entry/src/main/resources/base/element/float.json b/SilkCodec_Test/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..a8a5d404dcd8b0466194afc3aa25d90a8a327470 --- /dev/null +++ b/SilkCodec_Test/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/SilkCodec_Test/entry/src/main/resources/base/element/string.json b/SilkCodec_Test/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f94595515a99e0c828807e243494f57f09251930 --- /dev/null +++ b/SilkCodec_Test/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/SilkCodec_Test/entry/src/main/resources/base/media/background.png b/SilkCodec_Test/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/SilkCodec_Test/entry/src/main/resources/base/media/background.png differ diff --git a/SilkCodec_Test/entry/src/main/resources/base/media/foreground.png b/SilkCodec_Test/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/SilkCodec_Test/entry/src/main/resources/base/media/foreground.png differ diff --git a/SilkCodec_Test/entry/src/main/resources/base/media/layered_image.json b/SilkCodec_Test/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/SilkCodec_Test/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/SilkCodec_Test/entry/src/main/resources/base/media/startIcon.png b/SilkCodec_Test/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/SilkCodec_Test/entry/src/main/resources/base/media/startIcon.png differ diff --git a/SilkCodec_Test/entry/src/main/resources/base/profile/backup_config.json b/SilkCodec_Test/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..d742c2f96e7dd0f406f499941f3147345e998f95 --- /dev/null +++ b/SilkCodec_Test/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/SilkCodec_Test/entry/src/main/resources/base/profile/main_pages.json b/SilkCodec_Test/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/SilkCodec_Test/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/SilkCodec_Test/entry/src/main/resources/dark/element/color.json b/SilkCodec_Test/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..438d5bc43bb23c59c210d586b96635a72da5b64a --- /dev/null +++ b/SilkCodec_Test/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/SilkCodec_Test/entry/src/main/resources/rawfile/input.pcm b/SilkCodec_Test/entry/src/main/resources/rawfile/input.pcm new file mode 100644 index 0000000000000000000000000000000000000000..98ead82e73d3715f12dcd707a6f344eb8e1130d1 Binary files /dev/null and b/SilkCodec_Test/entry/src/main/resources/rawfile/input.pcm differ diff --git a/SilkCodec_Test/entry/src/main/resources/rawfile/output.silk b/SilkCodec_Test/entry/src/main/resources/rawfile/output.silk new file mode 100644 index 0000000000000000000000000000000000000000..94367ab1441a8f40badb739f7278e85a132e95bc Binary files /dev/null and b/SilkCodec_Test/entry/src/main/resources/rawfile/output.silk differ diff --git a/SilkCodec_Test/entry/src/main/resources/rawfile/test.txt b/SilkCodec_Test/entry/src/main/resources/rawfile/test.txt new file mode 100644 index 0000000000000000000000000000000000000000..e2e107ac61ac259b87c544f6e7a4eb03422c6c21 --- /dev/null +++ b/SilkCodec_Test/entry/src/main/resources/rawfile/test.txt @@ -0,0 +1 @@ +123456789 \ No newline at end of file diff --git a/SilkCodec_Test/entry/src/main/resources/resfile/input.pcm b/SilkCodec_Test/entry/src/main/resources/resfile/input.pcm new file mode 100644 index 0000000000000000000000000000000000000000..98ead82e73d3715f12dcd707a6f344eb8e1130d1 Binary files /dev/null and b/SilkCodec_Test/entry/src/main/resources/resfile/input.pcm differ diff --git a/SilkCodec_Test/entry/src/mock/Libentry.mock.ets b/SilkCodec_Test/entry/src/mock/Libentry.mock.ets new file mode 100644 index 0000000000000000000000000000000000000000..c2171716d040a605ef6af71e90b937a945f2677d --- /dev/null +++ b/SilkCodec_Test/entry/src/mock/Libentry.mock.ets @@ -0,0 +1,7 @@ +const NativeMock: Record = { + 'add': (a: number, b: number) => { + return a + b; + }, +}; + +export default NativeMock; \ No newline at end of file diff --git a/SilkCodec_Test/entry/src/mock/mock-config.json5 b/SilkCodec_Test/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6540976c9acc8afbd45895db6404334cff195465 --- /dev/null +++ b/SilkCodec_Test/entry/src/mock/mock-config.json5 @@ -0,0 +1,5 @@ +{ + "libentry.so": { + "source": "src/mock/Libentry.mock.ets" + } +} \ No newline at end of file diff --git a/SilkCodec_Test/entry/src/ohosTest/ets/test/Ability.test.ets b/SilkCodec_Test/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c78f67579d6e31b5f5aeea463e216b9b141048 --- /dev/null +++ b/SilkCodec_Test/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/SilkCodec_Test/entry/src/ohosTest/ets/test/List.test.ets b/SilkCodec_Test/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..794c7dc4ed66bd98fa3865e07922906e2fcef545 --- /dev/null +++ b/SilkCodec_Test/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/SilkCodec_Test/entry/src/ohosTest/module.json5 b/SilkCodec_Test/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ae666e1a9eef300ea97e0859c0c67591aa459a23 --- /dev/null +++ b/SilkCodec_Test/entry/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/SilkCodec_Test/entry/src/test/List.test.ets b/SilkCodec_Test/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/SilkCodec_Test/entry/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/SilkCodec_Test/entry/src/test/LocalUnit.test.ets b/SilkCodec_Test/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/SilkCodec_Test/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/SilkCodec_Test/hvigor/hvigor-config.json5 b/SilkCodec_Test/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..3cff4b8144944ae5850e5b9c303fddecadfb1af6 --- /dev/null +++ b/SilkCodec_Test/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.5", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/SilkCodec_Test/hvigorfile.ts b/SilkCodec_Test/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..47113e2e36ecefde41c136272a0bd6ff745cffe4 --- /dev/null +++ b/SilkCodec_Test/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ +} \ No newline at end of file diff --git a/SilkCodec_Test/log.txt b/SilkCodec_Test/log.txt new file mode 100644 index 0000000000000000000000000000000000000000..e9f8222e6326b0bbcde3965cd0edede255997e99 --- /dev/null +++ b/SilkCodec_Test/log.txt @@ -0,0 +1,21 @@ +09:28:01:742 log task queue not empty +09:28:01:743 log task size: 1 +09:28:01:743 log before pop task size: 1 +09:28:01:743 log after task size: 0 +09:28:02:142 log timer task size: 1 +09:28:02:247 log timer task size: 1 +09:28:04:114 log task queue not empty +09:28:04:115 log task size: 1 +09:28:04:115 log before pop task size: 1 +09:28:04:115 log after task size: 0 +09:28:04:290 log task queue not empty +09:28:04:290 log task size: 1 +09:28:04:290 log before pop task size: 1 +09:28:04:290 log after task size: 0 +09:28:04:623 log timer task size: 1 +09:28:04:804 log timer task size: 1 +09:33:38:309 log task queue not empty +09:33:38:310 log task size: 1 +09:33:38:310 log before pop task size: 1 +09:33:38:310 log after task size: 0 +09:33:38:825 log timer task size: 1 diff --git a/SilkCodec_Test/oh-package-lock.json5 b/SilkCodec_Test/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e66b2da5feca3c3cbab26d52e800d062d528d440 --- /dev/null +++ b/SilkCodec_Test/oh-package-lock.json5 @@ -0,0 +1,27 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", + "@ohos/hypium@1.0.21": "@ohos/hypium@1.0.21" + }, + "packages": { + "@ohos/hamock@1.0.0": { + "name": "@ohos/hamock", + "version": "1.0.0", + "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hamock/-/hamock-1.0.0.har", + "registryType": "ohpm" + }, + "@ohos/hypium@1.0.21": { + "name": "@ohos/hypium", + "version": "1.0.21", + "integrity": "sha512-iyKGMXxE+9PpCkqEwu0VykN/7hNpb+QOeIuHwkmZnxOpI+dFZt6yhPB7k89EgV1MiSK/ieV/hMjr5Z2mWwRfMQ==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.21.har", + "registryType": "ohpm" + } + } +} \ No newline at end of file diff --git a/SilkCodec_Test/oh-package.json5 b/SilkCodec_Test/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..cd592e5edcfbdf9411c43db0a9c15226064a1af6 --- /dev/null +++ b/SilkCodec_Test/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "modelVersion": "5.0.5", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/vlc_build_script/HPKBUILD b/vlc_build_script/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..84fd180afa200113d6d3a379f2ae686804aa42c3 --- /dev/null +++ b/vlc_build_script/HPKBUILD @@ -0,0 +1,122 @@ +# Contributor: Jeff Han +# Maintainer: Jeff Han + +pkgname=vlc +pkgver=3.0.21 +pkgrel=0 +pkgdesc="VLC 是一款自由、开源的跨平台多媒体播放器及框架,可播放大多数多媒体文件,以及 DVD、音频 CD、VCD 及各类流媒体协议。" +url="https://www.videolan.org/" +archs=("arm64-v8a") +license=("GNU General Public License v2.0") +#depends=("FFmpeg" "faad2" "mpg123" "twolame" "libvorbis" "libvpx" "libdca" "flac" "speex" "libtheora" "aribb24" "speexdsp" "libkate" "libogg" "a52dec") +depends=("FFmpeg" "faad2" "libvorbis" "libvpx" "libdca" "flac" "speex" "libtheora" "aribb24" "speexdsp" "libkate" "libogg" "a52dec" "freetype2") +#depends=("FFmpeg" "libvorbis" "libvpx" "libdca" "flac" "libtheora" "aribb24" "speexdsp" "libogg" "a52dec") + +makedepends=() + +#source="https://gitclone.com/github.com/videolan/$pkgname.git" +#source="https://gh.llkk.cc/https://github.com/videolan/vlc.git" +#source="https://gitee.com/mirrors/vlc.git" +source="https://gitee.com/libo729/vlc.git" + +autounpack=false +downloadpackage=false +buildtools="configure" + +builddir=$pkgname-${pkgver} +packagename= +patchflag=false +cloneflag=false + +source envset.sh +inited=true + +host= +prepare() { + if [ $cloneflag == true ];then + git clone -b ohos-vlc-dev --depth=1 $source $builddir > $publicbuildlog 2>&1 + if [ $? -ne 0 ] + then + echo "$pkgname git clone $source error." + rm -rf $builddir + return -1 + fi + cd $builddir + # git checkout $pkgver >> $publicbuildlog 2>&1 + # if [ $? -ne 0 ] + # then + # echo "$pkgname git checkout $pkgver error." + # return -2 + #fi + cd $OLDPWD + cloneflag=false + fi + # 1.修改/tmp目录为/data/storage/el2/base/temp + # 2.不支持pthread_cancel函数,参考安卓处理方式,将posix下的thread.c文件替换安卓下的 + if [ $patchflag == true ];then + cd $builddir + patch -p1 < ../vlc_3.0.21_oh_pkg.patch >> $publicbuildlog 2>&1 + cd $OLDPWD + patchflag=false + fi + + mkdir -p $builddir/$ARCH-build + if [ $ARCH == "arm64-v8a" ] + then + setarm64ENV + CFLAGS="-Wl,-L$LYCIUM_ROOT/usr/libogg/arm64-v8a/lib/ -Wl,-logg -I$LYCIUM_ROOT/usr/libogg/arm64-v8a/include -Wl,-L$LYCIUM_ROOT/usr/a52dec/arm64-v8a/lib/ -Wl,-la52 -I$LYCIUM_ROOT/usr/a52dec/arm64-v8a/include $CFLAGS" + host=aarch64-linux + else + echo "${ARCH} not support" + return -1 + fi + + if [ $inited == true ];then + inited=false + cd $builddir + ./bootstrap >> $publicbuildlog 2>&1 + cd $OLDPWD + fi +} + +build() { + cd $builddir/$ARCH-build + # --with-default-font="path to the default font" + # --enable-gles2 最新的sysroot中仅有gles3 vlc最多支持到gles2 暂时取消这个 + PKG_CONFIG_LIBDIR="${pkgconfigpath}" \ + EGL_CFLAGS="-I${OHOS_SDK}/native/sysroot/usr/include" \ + EGL_LIBS="-L${OHOS_SDK}/native/sysroot/usr/lib/ -lEGL" \ + GLES2_CFLAGS="-I${OHOS_SDK}/native/sysroot/usr/include" \ + GLES2_LIBS="-L${OHOS_SDK}/native/sysroot/usr/lib/ -lGLESv2" \ + BUILDCC=gcc ../configure "$@" --host=$host --disable-lua --disable-a52 --disable-rpath \ + --disable-xcb --disable-alsa --disable-vlc --disable-v4l2 --enable-gles2 \ + --enable-freetype ac_cv_func_open_memstream=no > $buildlog 2>&1 + $MAKE >> $buildlog 2>&1 + ret=$? + cd $OLDPWD + return $ret +} + +package() { + cd $builddir/$ARCH-build + $MAKE install >> `pwd`/build.log 2>&1 + cd $OLDPWD +} + +check() { + unset host + if [ $ARCH == "arm64-v8a" ] + then + unsetarm64ENV + else + echo "${ARCH} not support" + return -1 + fi + echo "The test must be on an OpenHarmony device!" +} + +# 清理环境 +cleanbuild() { + echo "The test must be on an OpenHarmony device!" + #rm -rf ${PWD}/$builddir #${PWD}/$packagename +}