From 797672cf657afea16f690adf7fe35e82ade24f42 Mon Sep 17 00:00:00 2001 From: dongxinli Date: Wed, 26 Jul 2023 10:04:32 +0800 Subject: [PATCH] add screenCapture testcase Signed-off-by: dongxinli --- multimedia/BUILD.gn | 1 + .../screenCapture_ndk_test/BUILD.gn | 40 + .../screenCapture_ndk_test/Test.json | 23 + .../entry/src/main/config.json | 112 ++ .../entry/src/main/cpp/BUILD.gn | 41 + .../entry/src/main/cpp/CMakeLists.txt | 11 + .../entry/src/main/cpp/screenCaptureTest.cpp | 1609 +++++++++++++++++ .../src/main/cpp/types/libentry/index.d.ts | 1 + .../main/cpp/types/libentry/oh-package.json5 | 21 + .../entry/src/main/ets/MainAbility/app.ets | 25 + .../src/main/ets/MainAbility/pages/index.ets | 38 + .../entry/src/main/ets/TestAbility/app.ets | 34 + .../src/main/ets/TestAbility/pages/index.ets | 50 + .../ets/TestRunner/OpenHarmonyTestRunner.ts | 53 + .../entry/src/main/ets/test/List.test.ets | 20 + .../entry/src/main/ets/test/NativeApiTest.ets | 607 +++++++ .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 24 + .../src/main/resources/base/media/icon.png | Bin 0 -> 6790 bytes .../main/resources/en_US/element/string.json | 16 + .../main/resources/zh_CN/element/string.json | 16 + .../signature/openharmony_sx.p7b | Bin 0 -> 3577 bytes 22 files changed, 2750 insertions(+) create mode 100644 multimedia/media/media_js_standard/screenCapture_ndk_test/BUILD.gn create mode 100644 multimedia/media/media_js_standard/screenCapture_ndk_test/Test.json create mode 100644 multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/config.json create mode 100644 multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/cpp/BUILD.gn create mode 100644 multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/cpp/CMakeLists.txt create mode 100644 multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/cpp/screenCaptureTest.cpp create mode 100644 multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/cpp/types/libentry/index.d.ts create mode 100644 multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/ets/MainAbility/app.ets create mode 100644 multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/ets/MainAbility/pages/index.ets create mode 100644 multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/ets/TestAbility/app.ets create mode 100644 multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/ets/TestAbility/pages/index.ets create mode 100644 multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts create mode 100644 multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/ets/test/List.test.ets create mode 100644 multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/ets/test/NativeApiTest.ets create mode 100644 multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/resources/base/element/color.json create mode 100644 multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/resources/base/element/string.json create mode 100644 multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/resources/base/media/icon.png create mode 100644 multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/resources/en_US/element/string.json create mode 100644 multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/resources/zh_CN/element/string.json create mode 100644 multimedia/media/media_js_standard/screenCapture_ndk_test/signature/openharmony_sx.p7b diff --git a/multimedia/BUILD.gn b/multimedia/BUILD.gn index 05486a394..f714bf6f2 100644 --- a/multimedia/BUILD.gn +++ b/multimedia/BUILD.gn @@ -58,6 +58,7 @@ group("multimedia") { "media/media_js_standard/avPlayer:avplayer_js_hap", "media/media_js_standard/avRecorder:av_recorder_js_hap", "media/media_js_standard/recorderFormat:recorder_format_js_hap", + "media/media_js_standard/screenCapture_ndk_test:screenCapture_xts_ndk_hap", "media/media_js_standard/videoPlayer:video_player_js_hap", "medialibrary/mediaLibrary_album:mediaLibrary_album_hap", "medialibrary/mediaLibrary_base:mediaLibrary_base_hap", diff --git a/multimedia/media/media_js_standard/screenCapture_ndk_test/BUILD.gn b/multimedia/media/media_js_standard/screenCapture_ndk_test/BUILD.gn new file mode 100644 index 000000000..d43b1931f --- /dev/null +++ b/multimedia/media/media_js_standard/screenCapture_ndk_test/BUILD.gn @@ -0,0 +1,40 @@ +# Copyright (c) 2021 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. + +import("//build/ohos.gni") +import("//test/xts/tools/build/suite.gni") +ohos_js_hap_suite("screenCapture_xts_ndk_hap") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":pixelmap_ets_assets", + ":pixelmap_ets_resources", + ":pixelmap_ets_test_assets", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsScreenCaptureNdkTest" + shared_libraries = [ "./entry/src/main/cpp:screenCaptureNdkTest" ] + part_name = "player_framework" + subsystem_name = "multimedia" +} + +ohos_js_assets("pixelmap_ets_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_js_assets("pixelmap_ets_test_assets") { + source_dir = "./entry/src/main/ets/TestAbility" +} +ohos_resources("pixelmap_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/multimedia/media/media_js_standard/screenCapture_ndk_test/Test.json b/multimedia/media/media_js_standard/screenCapture_ndk_test/Test.json new file mode 100644 index 000000000..eb796db58 --- /dev/null +++ b/multimedia/media/media_js_standard/screenCapture_ndk_test/Test.json @@ -0,0 +1,23 @@ +{ + "description": "Configuration for screen capture Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "1500000", + "bundle-name": "com.example.avscreencapturendkxts", + "package-name": "com.example.avscreencapturendkxts", + "shell-timeout": "600000" + }, + "kits": [ + { + "test-file-name": [ + "ActsScreenCaptureNdkTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [] + } + ] +} \ No newline at end of file diff --git a/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/config.json b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/config.json new file mode 100644 index 000000000..ae0d997c7 --- /dev/null +++ b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/config.json @@ -0,0 +1,112 @@ +{ + "app": { + "bundleName": "com.example.avscreencapturendkxts", + "vendor": "example", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 6, + "releaseType": "Beta1", + "target": 7 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.avscreencapturendkxts", + "name": ".entry", + "mainAbility": ".MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "reqPermissions": [ + { + "name": "ohos.permission.MICROPHONE" + }, + { + "name": "ohos.permission.CAPTURE_SCREEN" + }, + { + "name": "ohos.permission.READ_MEDIA" + }, + { + "name": "ohos.permission.WRITE_MEDIA" + } + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "formsEnabled": false, + "name": ".MainAbility", + "srcLanguage": "ets", + "srcPath": "MainAbility", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "label": "$string:MainAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "ets", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/cpp/BUILD.gn b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/cpp/BUILD.gn new file mode 100644 index 000000000..a36e94cfd --- /dev/null +++ b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/cpp/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (C) 2021 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. + +import("//build/config/ohos/config.gni") +import("//build/ohos.gni") +import("//foundation/arkui/napi/napi.gni") + +MEDIA_ROOT_DIR = "//foundation/multimedia/player_framework/" +config("config") { + visibility = [ ":*" ] + cflags = [ + "-Wall", + "-Werror", + "-g3", + "-Wunused-variable", + ] +} + +ohos_shared_library("screenCaptureNdkTest") { + sources = [ "./screenCaptureTest.cpp" ] + include_dirs = [ "$MEDIA_ROOT_DIR/interfaces/kits/c/" ] + external_deps = [ + "graphic_2d:surface", + "napi:ace_napi", + ] + deps = [ "$MEDIA_ROOT_DIR/interfaces/kits/c:native_avscreen_capture" ] + configs = [ ":config" ] + output_extension = "so" + part_name = "player_framework" + subsystem_name = "multimedia" +} diff --git a/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/cpp/CMakeLists.txt b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 000000000..45bf36c55 --- /dev/null +++ b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,11 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.4.1) +project(AVScreenCaptureNDKXTS) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(screenCaptureNdkTest SHARED screenCaptureTest.cpp) +target_link_libraries(screenCaptureNdkTest PUBLIC libace_napi.z.so libnative_avscreen_capture.so libnative_buffer.so libhilog_ndk.z.so) \ No newline at end of file diff --git a/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/cpp/screenCaptureTest.cpp b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/cpp/screenCaptureTest.cpp new file mode 100644 index 000000000..c287fc706 --- /dev/null +++ b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/cpp/screenCaptureTest.cpp @@ -0,0 +1,1609 @@ +/* + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "napi/native_api.h" +#include "native_avscreen_capture.h" +#include "native_avscreen_capture_base.h" +#include "native_avscreen_capture_errors.h" +using namespace std; +static char g_filename[100] = {0}; +static int32_t g_recordTime = 3; +static int32_t g_logCount = 30; +static int32_t g_aIndex = 0; +static int32_t g_vIndex = 0; +static int32_t g_aFlag = 0; +static int32_t g_vFlag = 0; + +class ScreenCaptureNdkCallBack { + public: + virtual ~ScreenCaptureNdkCallBack() = default; + virtual void OnError(int32_t errorCode) = 0; + virtual void OnAudioBufferAvailable(bool isReady, OH_AudioCaptureSourceType type) = 0; + virtual void OnVideoBufferAvailable(bool isReady) = 0; +}; +class ScreenCaptureNdkTestCallback : public ScreenCaptureNdkCallBack { +public: + ScreenCaptureNdkTestCallback(OH_AVScreenCapture *ScreenCapture, FILE *audioFile, FILE *iFile, FILE *videoFile) + : screenCapture_(ScreenCapture), aFile(audioFile), innerFile(iFile), vFile(videoFile) {} + ~ScreenCaptureNdkTestCallback() override; + void DumpVideoFile(OH_NativeBuffer *nativeBuffer, int32_t length); + void OnError(int32_t errorCode) override; + void OnAudioBufferAvailable(bool isReady, OH_AudioCaptureSourceType type) override; + void OnVideoBufferAvailable(bool isReady) override; + +private: + OH_AVScreenCapture *screenCapture_; + FILE *aFile = nullptr; + FILE *innerFile = nullptr; + FILE *vFile = nullptr; +}; + +#define LOG(cond, fmt, ...) \ + if (!(cond)) { \ + (void)printf(fmt, ##__VA_ARGS__); \ + } + +enum AudioSamplingRate { + SAMPLE_RATE_8000 = 8000, + SAMPLE_RATE_11025 = 11025, + SAMPLE_RATE_12000 = 12000, + SAMPLE_RATE_16000 = 16000, + SAMPLE_RATE_22050 = 22050, + SAMPLE_RATE_24000 = 24000, + SAMPLE_RATE_32000 = 32000, + SAMPLE_RATE_44100 = 44100, + SAMPLE_RATE_48000 = 48000, + SAMPLE_RATE_64000 = 64000, + SAMPLE_RATE_96000 = 96000 +}; + +enum AudioChannel { + MONO = 1, + STEREO = 2, + CHANNEL_3 = 3, + CHANNEL_4 = 4, + CHANNEL_5 = 5, + CHANNEL_6 = 6 +}; + +ScreenCaptureNdkTestCallback::~ScreenCaptureNdkTestCallback() +{ + screenCapture_ = nullptr; + aFile = nullptr; + innerFile = nullptr; + vFile = nullptr; +} + +void ScreenCaptureNdkTestCallback::OnError(int32_t errorCode) +{ + LOG(false, "Error received, errorCode: %d", errorCode); +} +void ScreenCaptureNdkTestCallback::OnAudioBufferAvailable(bool isReady, OH_AudioCaptureSourceType type) +{ + if (isReady == true) { + OH_AudioBuffer *audioBuffer = (OH_AudioBuffer *)malloc(sizeof(OH_AudioBuffer)); + LOG(audioBuffer != nullptr, "audio buffer is nullptr"); + if (OH_AVScreenCapture_AcquireAudioBuffer(screenCapture_, &audioBuffer, type) == AV_SCREEN_CAPTURE_ERR_OK) { + LOG(audioBuffer != nullptr, "AcquireAudioBuffer failed, audio buffer empty"); + LOG(g_aIndex % g_logCount != 0, + "AcquireAudioBuffer, audioBufferLen: %d, timestampe: %lld, audioSourceType: %d", + audioBuffer->size, audioBuffer->timestamp, audioBuffer->type); + if ((aFile != nullptr) && (audioBuffer->buf != nullptr) && (type == OH_MIC)) { + int32_t ret = fwrite(audioBuffer->buf, 1, audioBuffer->size, aFile); + LOG(ret == audioBuffer->size, "error occurred in fwrite audioFile: %s", strerror(errno)); + free(audioBuffer->buf); + audioBuffer->buf = nullptr; + } else if ((innerFile != nullptr) && (audioBuffer->buf != nullptr) && (type == OH_ALL_PLAYBACK)) { + int32_t ret = fwrite(audioBuffer->buf, 1, audioBuffer->size, innerFile); + LOG(ret == audioBuffer->size, "error occurred in fwrite innerFile_: %s", strerror(errno)); + free(audioBuffer->buf); + audioBuffer->buf = nullptr; + } + free(audioBuffer); + audioBuffer = nullptr; + } + if (g_aFlag == 1) { + OH_AVScreenCapture_ReleaseAudioBuffer(screenCapture_, type); + } + g_aIndex++; + } else { + LOG(false, "AcquireAudioBuffer failed"); + } +} + +void ScreenCaptureNdkTestCallback::DumpVideoFile(OH_NativeBuffer *nativeBuffer, int32_t length) +{ + if (vFile != nullptr) { + void *buf = nullptr; + OH_NativeBuffer_Map(nativeBuffer, &buf); + if (buf != nullptr) { + int32_t ret = fwrite(buf, 1, length, vFile); + LOG(ret == length, "error occurred in fwrite vFile_: %s", strerror(errno)); + } + } +} + +void ScreenCaptureNdkTestCallback::OnVideoBufferAvailable(bool isReady) +{ + if (isReady == true) { + int32_t fence = 0; + int64_t timestamp = 0; + int32_t size = 4; + OH_Rect damage; + OH_NativeBuffer_Config config; + OH_NativeBuffer *nativeBuffer = + OH_AVScreenCapture_AcquireVideoBuffer(screenCapture_, &fence, ×tamp, &damage); + if (nativeBuffer != nullptr) { + OH_NativeBuffer_GetConfig(nativeBuffer, &config); + int32_t length = config.height * config.width * size; + LOG(g_vIndex % g_logCount != 0, + "AcquireVideoBuffer, videoBufferLen: %d, timestamp: %lld, size: %d", length, timestamp, length); + DumpVideoFile(nativeBuffer, length); + OH_NativeBuffer_Unreference(nativeBuffer); + if (g_vFlag == 1) { + OH_AVScreenCapture_ReleaseVideoBuffer(screenCapture_); + } + g_vIndex++; + } else { + LOG(false, "AcquireVideoBuffer failed"); + } + } +} +std::shared_ptr screenCaptureCb = nullptr; +std::mutex mutex_; +std::map> mockCbMap_; +void DelCallback(OH_AVScreenCapture *screenCapture) +{ + std::lock_guard lock(mutex_); + if (mockCbMap_.empty()) { + return; + } + auto it = mockCbMap_.find(screenCapture); + if (it != mockCbMap_.end()) { + mockCbMap_.erase(it); + } +} + +std::shared_ptr GetCallback(OH_AVScreenCapture *screenCapture) +{ + std::lock_guard lock(mutex_); + if (mockCbMap_.empty()) { + return nullptr; + } + if (mockCbMap_.find(screenCapture) != mockCbMap_.end()) { + return mockCbMap_.at(screenCapture); + } + return nullptr; +} + +void OnError(OH_AVScreenCapture *screenCapture, int32_t errorCode) +{ + std::shared_ptr mockCb = GetCallback(screenCapture); + if (mockCb != nullptr) { + mockCb->OnError(errorCode); + } +} + +void OnAudioBufferAvailable(OH_AVScreenCapture *screenCapture, bool isReady, + OH_AudioCaptureSourceType type) +{ + std::shared_ptr mockCb = GetCallback(screenCapture); + if (mockCb != nullptr) { + mockCb->OnAudioBufferAvailable(isReady, type); + } +} + +void OnVideoBufferAvailable(OH_AVScreenCapture *screenCapture, bool isReady) +{ + std::shared_ptr mockCb = GetCallback(screenCapture); + if (mockCb != nullptr) { + mockCb->OnVideoBufferAvailable(isReady); + } +} + +void SetScreenCaptureCallback(OH_AVScreenCapture *screenCapture, std::shared_ptr &cb) +{ + if (cb != nullptr) { + std::lock_guard lock(mutex_); + mockCbMap_[screenCapture] = cb; + struct OH_AVScreenCaptureCallback callback; + callback.onError = OnError; + callback.onAudioBufferAvailable = OnAudioBufferAvailable; + callback.onVideoBufferAvailable = OnVideoBufferAvailable; + OH_AVScreenCapture_SetCallback(screenCapture, callback); + } +} + +OH_AVScreenCapture* CreateScreenCapture() +{ + OH_AVScreenCapture* screenCapture_ = OH_AVScreenCapture_Create(); + return screenCapture_; +} + +void SetConfig(OH_AVScreenCaptureConfig &config) +{ + char name[30] = "fd://11"; + int32_t width = 720; + int32_t height = 1280; + OH_AudioCaptureInfo miccapinfo = { + .audioSampleRate = SAMPLE_RATE_16000, + .audioChannels = STEREO, + .audioSource = OH_SOURCE_DEFAULT + }; + OH_VideoCaptureInfo videocapinfo = { + .videoFrameWidth = width, + .videoFrameHeight = height, + .videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA + }; + OH_AudioInfo audioinfo = { + .micCapInfo = miccapinfo + }; + OH_VideoInfo videoinfo = { + .videoCapInfo = videocapinfo + }; + OH_RecorderInfo recorderinfo = { + .url = name + }; + config = { + .captureMode = OH_CAPTURE_HOME_SCREEN, + .dataType = OH_ORIGINAL_STREAM, + .audioInfo = audioinfo, + .videoInfo = videoinfo, + .recorderInfo = recorderinfo + }; +} + +FILE* OpenVFile(FILE *videoFile, string filename) +{ + int32_t ret = snprintf_s(g_filename, sizeof(g_filename), sizeof(g_filename) - 1, + "data/storage/el2/base/files/%s.yuv", filename.c_str()); + if (ret >= 0) { + videoFile = fopen(g_filename, "w+"); + } + LOG(videoFile != nullptr, "vFile video open failed, %s", strerror(errno)); + return videoFile; +} + +FILE* OpenAFile(FILE *audioFile, string filename) +{ + int32_t ret = snprintf_s(g_filename, sizeof(g_filename), sizeof(g_filename) - 1, + "data/storage/el2/base/files/%s.pcm", filename.c_str()); + if (ret >= 0) { + audioFile = fopen(g_filename, "w+"); + } + LOG(audioFile != nullptr, "aFile audio open failed, %s", strerror(errno)); + return audioFile; +} + +void CloseFile(FILE *audioFile, FILE *videoFile) +{ + if (audioFile != nullptr) { + fclose(audioFile); + audioFile = nullptr; + } + if (videoFile != nullptr) { + fclose(videoFile); + videoFile = nullptr; + } +} + +// OH_Media_Screen_Capture_Init_001 +static napi_value InitWidthErr(napi_env env, napi_callback_info info) +{ + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.videoInfo.videoCapInfo.videoFrameWidth = -1; + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA; + + bool isMicrophone = false; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + OH_AVSCREEN_CAPTURE_ErrCode result = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVScreenCapture_Release(screenCapture); + napi_value res; + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_Init_002 +static napi_value InitHeightErr(napi_env env, napi_callback_info info) +{ + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.videoInfo.videoCapInfo.videoFrameHeight = -1; + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA; + + bool isMicrophone = false; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + OH_AVSCREEN_CAPTURE_ErrCode result = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVScreenCapture_Release(screenCapture); + napi_value res; + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_Init_003 +static napi_value InitVideoSourceYUV(napi_env env, napi_callback_info info) +{ + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_YUV; + + bool isMicrophone = false; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + OH_AVSCREEN_CAPTURE_ErrCode result = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVScreenCapture_Release(screenCapture); + napi_value res; + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_Init_004 +static napi_value InitVideoSourceES(napi_env env, napi_callback_info info) +{ + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_ES; + + bool isMicrophone = false; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + OH_AVSCREEN_CAPTURE_ErrCode result = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVScreenCapture_Release(screenCapture); + napi_value res; + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_Without_AudioData +static napi_value WithoutAudioData(napi_env env, napi_callback_info info) +{ + g_aFlag = 1; + g_vFlag = 1; + FILE *audioFile = nullptr; + FILE *videoFile = nullptr; + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + audioFile = OpenAFile(audioFile, "SUB_MULTIMEDIA_SCREEN_CAPTURE_WITHOUT_SOUND_DATA"); + videoFile = OpenVFile(videoFile, "SUB_MULTIMEDIA_SCREEN_CAPTURE_WITHOUT_SOUND_DATA"); + screenCaptureCb = std::make_shared(screenCapture, audioFile, nullptr, videoFile); + + bool isMicrophone = false; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + SetScreenCaptureCallback(screenCapture, screenCaptureCb); + OH_AVSCREEN_CAPTURE_ErrCode result1 = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVSCREEN_CAPTURE_ErrCode result2 = OH_AVScreenCapture_StartScreenCapture(screenCapture); + sleep(g_recordTime); + OH_AVSCREEN_CAPTURE_ErrCode result3 = OH_AVScreenCapture_StopScreenCapture(screenCapture); + DelCallback(screenCapture); + OH_AVScreenCapture_Release(screenCapture); + CloseFile(audioFile, videoFile); + screenCaptureCb = nullptr; + napi_value res; + OH_AVSCREEN_CAPTURE_ErrCode result; + if (result1 == AV_SCREEN_CAPTURE_ERR_OK && result2 == AV_SCREEN_CAPTURE_ERR_OK + && result3 == AV_SCREEN_CAPTURE_ERR_OK) { + result = AV_SCREEN_CAPTURE_ERR_OK; + } else { + LOG(false, "init/start/stop failed, init: %d, start: %d, stop: %d", result1, result2, result3); + result = AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT; + } + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_Init_005 +static napi_value InitAudioSampleRate_01(napi_env env, napi_callback_info info) +{ + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.audioInfo.micCapInfo.audioSampleRate = -1; + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA; + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + OH_AVSCREEN_CAPTURE_ErrCode result = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVScreenCapture_Release(screenCapture); + napi_value res; + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_Init_006 +static napi_value InitAudioSampleRate_02(napi_env env, napi_callback_info info) +{ + int32_t invalidRate = 98000; + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.audioInfo.micCapInfo.audioSampleRate = invalidRate; + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA; + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + OH_AVSCREEN_CAPTURE_ErrCode result = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVScreenCapture_Release(screenCapture); + napi_value res; + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_Init_007 +static napi_value InitAudioSampleRate_03(napi_env env, napi_callback_info info) +{ + int32_t invalidRate = 30000; + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.audioInfo.micCapInfo.audioSampleRate = invalidRate; + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA; + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + OH_AVSCREEN_CAPTURE_ErrCode result = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVScreenCapture_Release(screenCapture); + napi_value res; + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_Init_008 +static napi_value InitAudioChannels_01(napi_env env, napi_callback_info info) +{ + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.audioInfo.micCapInfo.audioChannels = -1; + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA; + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + OH_AVSCREEN_CAPTURE_ErrCode result = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVScreenCapture_Release(screenCapture); + napi_value res; + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_Init_009 +static napi_value InitAudioChannels_02(napi_env env, napi_callback_info info) +{ + int32_t invalidChannels = 7; + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.audioInfo.micCapInfo.audioChannels = invalidChannels; + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA; + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + OH_AVSCREEN_CAPTURE_ErrCode result = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVScreenCapture_Release(screenCapture); + napi_value res; + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_Init_010 +static napi_value InitAudioSourceErr(napi_env env, napi_callback_info info) +{ + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.audioInfo.micCapInfo.audioSource = OH_SOURCE_INVALID; + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA; + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + OH_AVSCREEN_CAPTURE_ErrCode result = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVScreenCapture_Release(screenCapture); + napi_value res; + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_Init_011 +static napi_value ScreenCaptureInitErr(napi_env env, napi_callback_info info) +{ + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.audioInfo.micCapInfo.audioSource = OH_SOURCE_INVALID; + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_YUV; + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + OH_AVSCREEN_CAPTURE_ErrCode result = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVScreenCapture_Release(screenCapture); + napi_value res; + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_With_AudioData +static napi_value WithAudioData(napi_env env, napi_callback_info info) +{ + g_aFlag = 1; + g_vFlag = 1; + FILE *audioFile = nullptr; + FILE *videoFile = nullptr; + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + audioFile = OpenAFile(audioFile, "SUB_MULTIMEDIA_SCREEN_CAPTURE_WITH_SOUND_DATA"); + videoFile = OpenVFile(videoFile, "SUB_MULTIMEDIA_SCREEN_CAPTURE_WITH_SOUND_DATA"); + screenCaptureCb = std::make_shared(screenCapture, audioFile, nullptr, videoFile); + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + SetScreenCaptureCallback(screenCapture, screenCaptureCb); + OH_AVSCREEN_CAPTURE_ErrCode result1 = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVSCREEN_CAPTURE_ErrCode result2 = OH_AVScreenCapture_StartScreenCapture(screenCapture); + sleep(g_recordTime); + OH_AVSCREEN_CAPTURE_ErrCode result3 = OH_AVScreenCapture_StopScreenCapture(screenCapture); + DelCallback(screenCapture); + OH_AVScreenCapture_Release(screenCapture); + CloseFile(audioFile, videoFile); + screenCaptureCb = nullptr; + napi_value res; + OH_AVSCREEN_CAPTURE_ErrCode result; + if (result1 == AV_SCREEN_CAPTURE_ERR_OK && result2 == AV_SCREEN_CAPTURE_ERR_OK + && result3 == AV_SCREEN_CAPTURE_ERR_OK) { + result = AV_SCREEN_CAPTURE_ERR_OK; + } else { + LOG(false, "init/start/stop failed, init: %d, start: %d, stop: %d", result1, result2, result3); + result = AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT; + } + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_Init_012 +static napi_value InitCaptureMode_01(napi_env env, napi_callback_info info) +{ + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.captureMode = static_cast(-1); + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA; + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + OH_AVSCREEN_CAPTURE_ErrCode result = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVScreenCapture_Release(screenCapture); + napi_value res; + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_Init_013 +static napi_value InitCaptureMode_02(napi_env env, napi_callback_info info) +{ + int32_t invalidMode = 3; + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.captureMode = static_cast(invalidMode); + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA; + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + OH_AVSCREEN_CAPTURE_ErrCode result = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVScreenCapture_Release(screenCapture); + napi_value res; + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_Init_014 +static napi_value InitDataType_01(napi_env env, napi_callback_info info) +{ + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA; + config_.dataType = OH_ENCODED_STREAM; + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + OH_AVSCREEN_CAPTURE_ErrCode result = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVScreenCapture_Release(screenCapture); + napi_value res; + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_Init_015 +static napi_value InitDataType_02(napi_env env, napi_callback_info info) +{ + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA; + config_.dataType = OH_CAPTURE_FILE; + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + OH_AVSCREEN_CAPTURE_ErrCode result = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVScreenCapture_Release(screenCapture); + napi_value res; + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_Init_016 +static napi_value InitDataType_03(napi_env env, napi_callback_info info) +{ + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA; + config_.dataType = OH_INVAILD; + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + OH_AVSCREEN_CAPTURE_ErrCode result = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVScreenCapture_Release(screenCapture); + napi_value res; + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_AudioSampleRate_8000 +static napi_value ChangeAudioSampleRate_01(napi_env env, napi_callback_info info) +{ + g_aFlag = 1; + g_vFlag = 1; + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.audioInfo.micCapInfo.audioSampleRate = SAMPLE_RATE_8000; + screenCaptureCb = std::make_shared(screenCapture, nullptr, nullptr, nullptr); + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + SetScreenCaptureCallback(screenCapture, screenCaptureCb); + OH_AVSCREEN_CAPTURE_ErrCode result1 = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVSCREEN_CAPTURE_ErrCode result2 = OH_AVScreenCapture_StartScreenCapture(screenCapture); + sleep(g_recordTime); + OH_AVSCREEN_CAPTURE_ErrCode result3 = OH_AVScreenCapture_StopScreenCapture(screenCapture); + DelCallback(screenCapture); + OH_AVScreenCapture_Release(screenCapture); + screenCaptureCb = nullptr; + napi_value res; + OH_AVSCREEN_CAPTURE_ErrCode result; + if (result1 == AV_SCREEN_CAPTURE_ERR_OK && result2 == AV_SCREEN_CAPTURE_ERR_OK + && result3 == AV_SCREEN_CAPTURE_ERR_OK) { + result = AV_SCREEN_CAPTURE_ERR_OK; + } else { + LOG(false, "init/start/stop failed, init: %d, start: %d, stop: %d", result1, result2, result3); + result = AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT; + } + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_AudioSampleRate_96000 +static napi_value ChangeAudioSampleRate_02(napi_env env, napi_callback_info info) +{ + g_aFlag = 1; + g_vFlag = 1; + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.audioInfo.micCapInfo.audioSampleRate = SAMPLE_RATE_96000; + screenCaptureCb = std::make_shared(screenCapture, nullptr, nullptr, nullptr); + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + SetScreenCaptureCallback(screenCapture, screenCaptureCb); + OH_AVSCREEN_CAPTURE_ErrCode result1 = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVSCREEN_CAPTURE_ErrCode result2 = OH_AVScreenCapture_StartScreenCapture(screenCapture); + sleep(g_recordTime); + OH_AVSCREEN_CAPTURE_ErrCode result3 = OH_AVScreenCapture_StopScreenCapture(screenCapture); + DelCallback(screenCapture); + OH_AVScreenCapture_Release(screenCapture); + screenCaptureCb = nullptr; + napi_value res; + OH_AVSCREEN_CAPTURE_ErrCode result; + if (result1 == AV_SCREEN_CAPTURE_ERR_OK && result2 == AV_SCREEN_CAPTURE_ERR_OK + && result3 == AV_SCREEN_CAPTURE_ERR_OK) { + result = AV_SCREEN_CAPTURE_ERR_OK; + } else { + LOG(false, "init/start/stop failed, init: %d, start: %d, stop: %d", result1, result2, result3); + result = AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT; + } + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_AudioChannels_001 +static napi_value ChangeAudioChannels_01(napi_env env, napi_callback_info info) +{ + g_aFlag = 1; + g_vFlag = 1; + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.audioInfo.micCapInfo.audioChannels = CHANNEL_3; + screenCaptureCb = std::make_shared(screenCapture, nullptr, nullptr, nullptr); + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + SetScreenCaptureCallback(screenCapture, screenCaptureCb); + OH_AVSCREEN_CAPTURE_ErrCode result1 = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVSCREEN_CAPTURE_ErrCode result2 = OH_AVScreenCapture_StartScreenCapture(screenCapture); + sleep(g_recordTime); + OH_AVSCREEN_CAPTURE_ErrCode result3 = OH_AVScreenCapture_StopScreenCapture(screenCapture); + DelCallback(screenCapture); + OH_AVScreenCapture_Release(screenCapture); + screenCaptureCb = nullptr; + napi_value res; + OH_AVSCREEN_CAPTURE_ErrCode result; + if (result1 == AV_SCREEN_CAPTURE_ERR_OK && result2 == AV_SCREEN_CAPTURE_ERR_OK + && result3 == AV_SCREEN_CAPTURE_ERR_OK) { + result = AV_SCREEN_CAPTURE_ERR_OK; + } else { + LOG(false, "init/start/stop failed, init: %d, start: %d, stop: %d", result1, result2, result3); + result = AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT; + } + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_AudioChannels_002 +static napi_value ChangeAudioChannels_02(napi_env env, napi_callback_info info) +{ + g_aFlag = 1; + g_vFlag = 1; + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.audioInfo.micCapInfo.audioChannels = CHANNEL_4; + screenCaptureCb = std::make_shared(screenCapture, nullptr, nullptr, nullptr); + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + SetScreenCaptureCallback(screenCapture, screenCaptureCb); + OH_AVSCREEN_CAPTURE_ErrCode result1 = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVSCREEN_CAPTURE_ErrCode result2 = OH_AVScreenCapture_StartScreenCapture(screenCapture); + sleep(g_recordTime); + OH_AVSCREEN_CAPTURE_ErrCode result3 = OH_AVScreenCapture_StopScreenCapture(screenCapture); + DelCallback(screenCapture); + OH_AVScreenCapture_Release(screenCapture); + screenCaptureCb = nullptr; + napi_value res; + OH_AVSCREEN_CAPTURE_ErrCode result; + if (result1 == AV_SCREEN_CAPTURE_ERR_OK && result2 == AV_SCREEN_CAPTURE_ERR_OK + && result3 == AV_SCREEN_CAPTURE_ERR_OK) { + result = AV_SCREEN_CAPTURE_ERR_OK; + } else { + LOG(false, "init/start/stop failed, init: %d, start: %d, stop: %d", result1, result2, result3); + result = AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT; + } + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_AudioChannels_003 +static napi_value ChangeAudioChannels_03(napi_env env, napi_callback_info info) +{ + g_aFlag = 1; + g_vFlag = 1; + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.audioInfo.micCapInfo.audioChannels = CHANNEL_5; + screenCaptureCb = std::make_shared(screenCapture, nullptr, nullptr, nullptr); + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + SetScreenCaptureCallback(screenCapture, screenCaptureCb); + OH_AVSCREEN_CAPTURE_ErrCode result1 = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVSCREEN_CAPTURE_ErrCode result2 = OH_AVScreenCapture_StartScreenCapture(screenCapture); + sleep(g_recordTime); + OH_AVSCREEN_CAPTURE_ErrCode result3 = OH_AVScreenCapture_StopScreenCapture(screenCapture); + DelCallback(screenCapture); + OH_AVScreenCapture_Release(screenCapture); + screenCaptureCb = nullptr; + napi_value res; + OH_AVSCREEN_CAPTURE_ErrCode result; + if (result1 == AV_SCREEN_CAPTURE_ERR_OK && result2 == AV_SCREEN_CAPTURE_ERR_OK + && result3 == AV_SCREEN_CAPTURE_ERR_OK) { + result = AV_SCREEN_CAPTURE_ERR_OK; + } else { + LOG(false, "init/start/stop failed, init: %d, start: %d, stop: %d", result1, result2, result3); + result = AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT; + } + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_AudioChannels_004 +static napi_value ChangeAudioChannels_04(napi_env env, napi_callback_info info) +{ + g_aFlag = 1; + g_vFlag = 1; + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.audioInfo.micCapInfo.audioChannels = CHANNEL_6; + screenCaptureCb = std::make_shared(screenCapture, nullptr, nullptr, nullptr); + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + SetScreenCaptureCallback(screenCapture, screenCaptureCb); + OH_AVSCREEN_CAPTURE_ErrCode result1 = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVSCREEN_CAPTURE_ErrCode result2 = OH_AVScreenCapture_StartScreenCapture(screenCapture); + sleep(g_recordTime); + OH_AVSCREEN_CAPTURE_ErrCode result3 = OH_AVScreenCapture_StopScreenCapture(screenCapture); + DelCallback(screenCapture); + OH_AVScreenCapture_Release(screenCapture); + screenCaptureCb = nullptr; + napi_value res; + OH_AVSCREEN_CAPTURE_ErrCode result; + if (result1 == AV_SCREEN_CAPTURE_ERR_OK && result2 == AV_SCREEN_CAPTURE_ERR_OK + && result3 == AV_SCREEN_CAPTURE_ERR_OK) { + result = AV_SCREEN_CAPTURE_ERR_OK; + } else { + LOG(false, "init/start/stop failed, init: %d, start: %d, stop: %d", result1, result2, result3); + result = AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT; + } + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_VideoSize_001 +static napi_value ChangeVideoSize_01(napi_env env, napi_callback_info info) +{ + g_aFlag = 1; + g_vFlag = 1; + int32_t width = 160; + int32_t height = 160; + FILE *videoFile = nullptr; + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.videoInfo.videoCapInfo.videoFrameWidth = width; + config_.videoInfo.videoCapInfo.videoFrameHeight = height; + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA; + videoFile = OpenVFile(videoFile, "SUB_MULTIMEDIA_SCREEN_CAPTURE_VIDEOSIZE_0001"); + screenCaptureCb = std::make_shared(screenCapture, nullptr, nullptr, videoFile); + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + SetScreenCaptureCallback(screenCapture, screenCaptureCb); + OH_AVSCREEN_CAPTURE_ErrCode result1 = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVSCREEN_CAPTURE_ErrCode result2 = OH_AVScreenCapture_StartScreenCapture(screenCapture); + sleep(g_recordTime); + OH_AVSCREEN_CAPTURE_ErrCode result3 = OH_AVScreenCapture_StopScreenCapture(screenCapture); + DelCallback(screenCapture); + OH_AVScreenCapture_Release(screenCapture); + CloseFile(nullptr, videoFile); + screenCaptureCb = nullptr; + napi_value res; + OH_AVSCREEN_CAPTURE_ErrCode result; + if (result1 == AV_SCREEN_CAPTURE_ERR_OK && result2 == AV_SCREEN_CAPTURE_ERR_OK + && result3 == AV_SCREEN_CAPTURE_ERR_OK) { + result = AV_SCREEN_CAPTURE_ERR_OK; + } else { + LOG(false, "init/start/stop failed, init: %d, start: %d, stop: %d", result1, result2, result3); + result = AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT; + } + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_VideoSize_002 +static napi_value ChangeVideoSize_02(napi_env env, napi_callback_info info) +{ + g_aFlag = 1; + g_vFlag = 1; + int32_t width = 640; + int32_t height = 480; + FILE *videoFile = nullptr; + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.videoInfo.videoCapInfo.videoFrameWidth = width; + config_.videoInfo.videoCapInfo.videoFrameHeight = height; + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA; + videoFile = OpenVFile(videoFile, "SUB_MULTIMEDIA_SCREEN_CAPTURE_VIDEOSIZE_0002"); + screenCaptureCb = std::make_shared(screenCapture, nullptr, nullptr, videoFile); + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + SetScreenCaptureCallback(screenCapture, screenCaptureCb); + OH_AVSCREEN_CAPTURE_ErrCode result1 = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVSCREEN_CAPTURE_ErrCode result2 = OH_AVScreenCapture_StartScreenCapture(screenCapture); + sleep(g_recordTime); + OH_AVSCREEN_CAPTURE_ErrCode result3 = OH_AVScreenCapture_StopScreenCapture(screenCapture); + DelCallback(screenCapture); + OH_AVScreenCapture_Release(screenCapture); + CloseFile(nullptr, videoFile); + screenCaptureCb = nullptr; + napi_value res; + OH_AVSCREEN_CAPTURE_ErrCode result; + if (result1 == AV_SCREEN_CAPTURE_ERR_OK && result2 == AV_SCREEN_CAPTURE_ERR_OK + && result3 == AV_SCREEN_CAPTURE_ERR_OK) { + result = AV_SCREEN_CAPTURE_ERR_OK; + } else { + LOG(false, "init/start/stop failed, init: %d, start: %d, stop: %d", result1, result2, result3); + result = AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT; + } + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_VideoSize_003 +static napi_value ChangeVideoSize_03(napi_env env, napi_callback_info info) +{ + g_aFlag = 1; + g_vFlag = 1; + int32_t width = 1920; + int32_t height = 1080; + FILE *videoFile = nullptr; + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.videoInfo.videoCapInfo.videoFrameWidth = width; + config_.videoInfo.videoCapInfo.videoFrameHeight = height; + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA; + videoFile = OpenVFile(videoFile, "SUB_MULTIMEDIA_SCREEN_CAPTURE_VIDEOSIZE_0003"); + screenCaptureCb = std::make_shared(screenCapture, nullptr, nullptr, videoFile); + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + SetScreenCaptureCallback(screenCapture, screenCaptureCb); + OH_AVSCREEN_CAPTURE_ErrCode result1 = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVSCREEN_CAPTURE_ErrCode result2 = OH_AVScreenCapture_StartScreenCapture(screenCapture); + sleep(g_recordTime); + OH_AVSCREEN_CAPTURE_ErrCode result3 = OH_AVScreenCapture_StopScreenCapture(screenCapture); + DelCallback(screenCapture); + OH_AVScreenCapture_Release(screenCapture); + CloseFile(nullptr, videoFile); + screenCaptureCb = nullptr; + napi_value res; + OH_AVSCREEN_CAPTURE_ErrCode result; + if (result1 == AV_SCREEN_CAPTURE_ERR_OK && result2 == AV_SCREEN_CAPTURE_ERR_OK + && result3 == AV_SCREEN_CAPTURE_ERR_OK) { + result = AV_SCREEN_CAPTURE_ERR_OK; + } else { + LOG(false, "init/start/stop failed, init: %d, start: %d, stop: %d", result1, result2, result3); + result = AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT; + } + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_Display +static napi_value ScreenCaptureFromDisplay(napi_env env, napi_callback_info info) +{ + g_aFlag = 1; + g_vFlag = 1; + size_t argc = 3; + int32_t num = 2; + napi_value args[3] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + int32_t width; + napi_get_value_int32(env, args[0], &width); + int32_t height; + napi_get_value_int32(env, args[1], &height); + int32_t frameRate; + napi_get_value_int32(env, args[num], &frameRate); + LOG(false, "Get display info: width: %d, height: %d", width, height); + config_.videoInfo.videoCapInfo.videoFrameWidth = width; + config_.videoInfo.videoCapInfo.videoFrameHeight = height; + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA; + screenCaptureCb = std::make_shared(screenCapture, nullptr, nullptr, nullptr); + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + SetScreenCaptureCallback(screenCapture, screenCaptureCb); + OH_AVSCREEN_CAPTURE_ErrCode result1 = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVSCREEN_CAPTURE_ErrCode result2 = OH_AVScreenCapture_StartScreenCapture(screenCapture); + sleep(g_recordTime); + OH_AVSCREEN_CAPTURE_ErrCode result3 = OH_AVScreenCapture_StopScreenCapture(screenCapture); + DelCallback(screenCapture); + OH_AVScreenCapture_Release(screenCapture); + screenCaptureCb = nullptr; + napi_value res; + OH_AVSCREEN_CAPTURE_ErrCode result; + if (result1 == AV_SCREEN_CAPTURE_ERR_OK && result2 == AV_SCREEN_CAPTURE_ERR_OK + && result3 == AV_SCREEN_CAPTURE_ERR_OK) { + result = AV_SCREEN_CAPTURE_ERR_OK; + } else { + LOG(false, "init/start/stop failed, init: %d, start: %d, stop: %d", result1, result2, result3); + result = AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT; + } + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_Buffer_001 +static napi_value BufferAndRelease_01(napi_env env, napi_callback_info info) +{ + g_aFlag = 0; + g_vFlag = 1; + int32_t time = 15; + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA; + screenCaptureCb = std::make_shared(screenCapture, nullptr, nullptr, nullptr); + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + SetScreenCaptureCallback(screenCapture, screenCaptureCb); + OH_AVSCREEN_CAPTURE_ErrCode result1 = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVSCREEN_CAPTURE_ErrCode result2 = OH_AVScreenCapture_StartScreenCapture(screenCapture); + sleep(time); + OH_AVSCREEN_CAPTURE_ErrCode result3 = OH_AVScreenCapture_StopScreenCapture(screenCapture); + DelCallback(screenCapture); + OH_AVScreenCapture_Release(screenCapture); + screenCaptureCb = nullptr; + napi_value res; + OH_AVSCREEN_CAPTURE_ErrCode result; + if (result1 == AV_SCREEN_CAPTURE_ERR_OK && result2 == AV_SCREEN_CAPTURE_ERR_OK + && result3 == AV_SCREEN_CAPTURE_ERR_OK) { + result = AV_SCREEN_CAPTURE_ERR_OK; + } else { + LOG(false, "init/start/stop failed, init: %d, start: %d, stop: %d", result1, result2, result3); + result = AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT; + } + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_Buffer_002 +static napi_value BufferAndRelease_02(napi_env env, napi_callback_info info) +{ + g_aFlag = 1; + g_vFlag = 0; + int32_t time = 10; + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA; + screenCaptureCb = std::make_shared(screenCapture, nullptr, nullptr, nullptr); + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + SetScreenCaptureCallback(screenCapture, screenCaptureCb); + OH_AVSCREEN_CAPTURE_ErrCode result1 = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVSCREEN_CAPTURE_ErrCode result2 = OH_AVScreenCapture_StartScreenCapture(screenCapture); + sleep(time); + OH_AVSCREEN_CAPTURE_ErrCode result3 = OH_AVScreenCapture_StopScreenCapture(screenCapture); + DelCallback(screenCapture); + OH_AVScreenCapture_Release(screenCapture); + screenCaptureCb = nullptr; + napi_value res; + OH_AVSCREEN_CAPTURE_ErrCode result; + if (result1 == AV_SCREEN_CAPTURE_ERR_OK && result2 == AV_SCREEN_CAPTURE_ERR_OK + && result3 == AV_SCREEN_CAPTURE_ERR_OK) { + result = AV_SCREEN_CAPTURE_ERR_OK; + } else { + LOG(false, "init/start/stop failed, init: %d, start: %d, stop: %d", result1, result2, result3); + result = AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT; + } + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_Buffer_003 +static napi_value BufferAndRelease_03(napi_env env, napi_callback_info info) +{ + g_aFlag = 0; + g_vFlag = 0; + int32_t time = 10; + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA; + screenCaptureCb = std::make_shared(screenCapture, nullptr, nullptr, nullptr); + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + SetScreenCaptureCallback(screenCapture, screenCaptureCb); + OH_AVSCREEN_CAPTURE_ErrCode result1 = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVSCREEN_CAPTURE_ErrCode result2 = OH_AVScreenCapture_StartScreenCapture(screenCapture); + sleep(time); + OH_AVSCREEN_CAPTURE_ErrCode result3 = OH_AVScreenCapture_StopScreenCapture(screenCapture); + DelCallback(screenCapture); + OH_AVScreenCapture_Release(screenCapture); + screenCaptureCb = nullptr; + napi_value res; + OH_AVSCREEN_CAPTURE_ErrCode result; + if (result1 == AV_SCREEN_CAPTURE_ERR_OK && result2 == AV_SCREEN_CAPTURE_ERR_OK + && result3 == AV_SCREEN_CAPTURE_ERR_OK) { + result = AV_SCREEN_CAPTURE_ERR_OK; + } else { + LOG(false, "init/start/stop failed, init: %d, start: %d, stop: %d", result1, result2, result3); + result = AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT; + } + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_Mic_001 +static napi_value SetMicrophoneEnabled_01(napi_env env, napi_callback_info info) +{ + g_aFlag = 1; + g_vFlag = 1; + int32_t time = 5; + FILE *audioFile = nullptr; + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA; + audioFile = OpenAFile(audioFile, "SUB_MULTIMEDIA_SCREEN_CAPTURE_MICTEST_0001"); + screenCaptureCb = std::make_shared(screenCapture, audioFile, nullptr, nullptr); + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + SetScreenCaptureCallback(screenCapture, screenCaptureCb); + OH_AVSCREEN_CAPTURE_ErrCode result1 = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVSCREEN_CAPTURE_ErrCode result2 = OH_AVScreenCapture_StartScreenCapture(screenCapture); + sleep(time); + isMicrophone = false; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + sleep(g_recordTime); + isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + sleep(g_recordTime); + OH_AVSCREEN_CAPTURE_ErrCode result3 = OH_AVScreenCapture_StopScreenCapture(screenCapture); + DelCallback(screenCapture); + OH_AVScreenCapture_Release(screenCapture); + CloseFile(audioFile, nullptr); + screenCaptureCb = nullptr; + napi_value res; + OH_AVSCREEN_CAPTURE_ErrCode result; + if (result1 == AV_SCREEN_CAPTURE_ERR_OK && result2 == AV_SCREEN_CAPTURE_ERR_OK + && result3 == AV_SCREEN_CAPTURE_ERR_OK) { + result = AV_SCREEN_CAPTURE_ERR_OK; + } else { + LOG(false, "init/start/stop failed, init: %d, start: %d, stop: %d", result1, result2, result3); + result = AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT; + } + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_Mic_002 +static napi_value SetMicrophoneEnabled_02(napi_env env, napi_callback_info info) +{ + g_aFlag = 1; + g_vFlag = 1; + int32_t time = 5; + FILE *audioFile = nullptr; + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA; + audioFile = OpenAFile(audioFile, "SUB_MULTIMEDIA_SCREEN_CAPTURE_MICTEST_0002"); + screenCaptureCb = std::make_shared(screenCapture, audioFile, nullptr, nullptr); + + bool isMicrophone = false; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + SetScreenCaptureCallback(screenCapture, screenCaptureCb); + OH_AVSCREEN_CAPTURE_ErrCode result1 = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVSCREEN_CAPTURE_ErrCode result2 = OH_AVScreenCapture_StartScreenCapture(screenCapture); + sleep(time); + isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + sleep(g_recordTime); + isMicrophone = false; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + sleep(g_recordTime); + OH_AVSCREEN_CAPTURE_ErrCode result3 = OH_AVScreenCapture_StopScreenCapture(screenCapture); + DelCallback(screenCapture); + OH_AVScreenCapture_Release(screenCapture); + CloseFile(audioFile, nullptr); + screenCaptureCb = nullptr; + napi_value res; + OH_AVSCREEN_CAPTURE_ErrCode result; + if (result1 == AV_SCREEN_CAPTURE_ERR_OK && result2 == AV_SCREEN_CAPTURE_ERR_OK + && result3 == AV_SCREEN_CAPTURE_ERR_OK) { + result = AV_SCREEN_CAPTURE_ERR_OK; + } else { + LOG(false, "init/start/stop failed, init: %d, start: %d, stop: %d", result1, result2, result3); + result = AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT; + } + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_Configure_001 +static napi_value ConfigureCombination_01(napi_env env, napi_callback_info info) +{ + g_aFlag = 1; + g_vFlag = 1; + int32_t width = 640; + int32_t height = 480; + FILE *videoFile = nullptr; + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.captureMode = OH_CAPTURE_SPECIFIED_SCREEN; + config_.videoInfo.videoCapInfo.videoFrameWidth = width; + config_.videoInfo.videoCapInfo.videoFrameHeight = height; + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA; + videoFile = OpenVFile(videoFile, "SUB_MULTIMEDIA_SCREEN_CAPTURE_CONFIG_COMBINATION_0001"); + screenCaptureCb = std::make_shared(screenCapture, nullptr, nullptr, videoFile); + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + SetScreenCaptureCallback(screenCapture, screenCaptureCb); + OH_AVSCREEN_CAPTURE_ErrCode result1 = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVSCREEN_CAPTURE_ErrCode result2 = OH_AVScreenCapture_StartScreenCapture(screenCapture); + sleep(g_recordTime); + OH_AVSCREEN_CAPTURE_ErrCode result3 = OH_AVScreenCapture_StopScreenCapture(screenCapture); + DelCallback(screenCapture); + OH_AVScreenCapture_Release(screenCapture); + CloseFile(nullptr, videoFile); + screenCaptureCb = nullptr; + OH_AVSCREEN_CAPTURE_ErrCode result; + if (result1 == AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT && result2 == AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT + && result3 == AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT) { + result = AV_SCREEN_CAPTURE_ERR_OK; + } else { + LOG(false, "init/start/stop failed, init: %d, start: %d, stop: %d", result1, result2, result3); + result = AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT; + } + napi_value res; + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_Configure_002 +static napi_value ConfigureCombination_02(napi_env env, napi_callback_info info) +{ + g_aFlag = 1; + g_vFlag = 1; + int32_t width = 1920; + int32_t height = 1080; + FILE *videoFile = nullptr; + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.captureMode = OH_CAPTURE_SPECIFIED_SCREEN; + config_.videoInfo.videoCapInfo.videoFrameWidth = width; + config_.videoInfo.videoCapInfo.videoFrameHeight = height; + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA; + videoFile = OpenVFile(videoFile, "SUB_MULTIMEDIA_SCREEN_CAPTURE_CONFIG_COMBINATION_0002"); + screenCaptureCb = std::make_shared(screenCapture, nullptr, nullptr, videoFile); + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + SetScreenCaptureCallback(screenCapture, screenCaptureCb); + OH_AVSCREEN_CAPTURE_ErrCode result1 = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVSCREEN_CAPTURE_ErrCode result2 = OH_AVScreenCapture_StartScreenCapture(screenCapture); + sleep(g_recordTime); + OH_AVSCREEN_CAPTURE_ErrCode result3 = OH_AVScreenCapture_StopScreenCapture(screenCapture); + DelCallback(screenCapture); + OH_AVScreenCapture_Release(screenCapture); + CloseFile(nullptr, videoFile); + screenCaptureCb = nullptr; + OH_AVSCREEN_CAPTURE_ErrCode result; + if (result1 == AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT && result2 == AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT + && result3 == AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT) { + result = AV_SCREEN_CAPTURE_ERR_OK; + } else { + LOG(false, "init/start/stop failed, init: %d, start: %d, stop: %d", result1, result2, result3); + result = AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT; + } + napi_value res; + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_Configure_003 +static napi_value ConfigureCombination_03(napi_env env, napi_callback_info info) +{ + g_aFlag = 1; + g_vFlag = 1; + int32_t width = 640; + int32_t height = 480; + FILE *videoFile = nullptr; + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.captureMode = OH_CAPTURE_SPECIFIED_WINDOW; + config_.videoInfo.videoCapInfo.videoFrameWidth = width; + config_.videoInfo.videoCapInfo.videoFrameHeight = height; + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA; + videoFile = OpenVFile(videoFile, "SUB_MULTIMEDIA_SCREEN_CAPTURE_CONFIG_COMBINATION_0003"); + screenCaptureCb = std::make_shared(screenCapture, nullptr, nullptr, videoFile); + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + SetScreenCaptureCallback(screenCapture, screenCaptureCb); + OH_AVSCREEN_CAPTURE_ErrCode result1 = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVSCREEN_CAPTURE_ErrCode result2 = OH_AVScreenCapture_StartScreenCapture(screenCapture); + sleep(g_recordTime); + OH_AVSCREEN_CAPTURE_ErrCode result3 = OH_AVScreenCapture_StopScreenCapture(screenCapture); + DelCallback(screenCapture); + OH_AVScreenCapture_Release(screenCapture); + CloseFile(nullptr, videoFile); + screenCaptureCb = nullptr; + OH_AVSCREEN_CAPTURE_ErrCode result; + if (result1 == AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT && result2 == AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT + && result3 == AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT) { + result = AV_SCREEN_CAPTURE_ERR_OK; + } else { + LOG(false, "init/start/stop failed, init: %d, start: %d, stop: %d", result1, result2, result3); + result = AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT; + } + napi_value res; + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_Configure_004 +static napi_value ConfigureCombination_04(napi_env env, napi_callback_info info) +{ + g_aFlag = 1; + g_vFlag = 1; + int32_t width = 1920; + int32_t height = 1080; + FILE *videoFile = nullptr; + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.captureMode = OH_CAPTURE_SPECIFIED_WINDOW; + config_.videoInfo.videoCapInfo.videoFrameWidth = width; + config_.videoInfo.videoCapInfo.videoFrameHeight = height; + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA; + videoFile = OpenVFile(videoFile, "SUB_MULTIMEDIA_SCREEN_CAPTURE_CONFIG_COMBINATION_0004"); + screenCaptureCb = std::make_shared(screenCapture, nullptr, nullptr, videoFile); + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + SetScreenCaptureCallback(screenCapture, screenCaptureCb); + OH_AVSCREEN_CAPTURE_ErrCode result1 = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVSCREEN_CAPTURE_ErrCode result2 = OH_AVScreenCapture_StartScreenCapture(screenCapture); + sleep(g_recordTime); + OH_AVSCREEN_CAPTURE_ErrCode result3 = OH_AVScreenCapture_StopScreenCapture(screenCapture); + DelCallback(screenCapture); + OH_AVScreenCapture_Release(screenCapture); + CloseFile(nullptr, videoFile); + screenCaptureCb = nullptr; + OH_AVSCREEN_CAPTURE_ErrCode result; + if (result1 == AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT && result2 == AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT + && result3 == AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT) { + result = AV_SCREEN_CAPTURE_ERR_OK; + } else { + LOG(false, "init/start/stop failed, init: %d, start: %d, stop: %d", result1, result2, result3); + result = AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT; + } + napi_value res; + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_MultiInstance +static void *MultiInstance(void *arg) +{ + g_aFlag = 1; + g_vFlag = 1; + int32_t width = 1920; + int32_t height = 1080; + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.audioInfo.micCapInfo.audioSampleRate = SAMPLE_RATE_48000; + config_.videoInfo.videoCapInfo.videoFrameWidth = width; + config_.videoInfo.videoCapInfo.videoFrameHeight = height; + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA; + FILE *audioFileMulti = nullptr; + FILE *videoFileMulti = nullptr; + audioFileMulti = OpenAFile(audioFileMulti, "SUB_MULTIMEDIA_SCREEN_CAPTURE_MULTI_INSTANCE_2"); + videoFileMulti = OpenVFile(videoFileMulti, "SUB_MULTIMEDIA_SCREEN_CAPTURE_MULTI_INSTANCE_2"); + screenCaptureCb = std::make_shared(screenCapture, audioFileMulti, nullptr, + videoFileMulti); + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + SetScreenCaptureCallback(screenCapture, screenCaptureCb); + OH_AVSCREEN_CAPTURE_ErrCode result1 = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVSCREEN_CAPTURE_ErrCode result2 = OH_AVScreenCapture_StartScreenCapture(screenCapture); + sleep(g_recordTime); + OH_AVSCREEN_CAPTURE_ErrCode result3 = OH_AVScreenCapture_StopScreenCapture(screenCapture); + DelCallback(screenCapture); + OH_AVScreenCapture_Release(screenCapture); + CloseFile(audioFileMulti, videoFileMulti); + screenCaptureCb = nullptr; + if (result1 == AV_SCREEN_CAPTURE_ERR_OK && result2 == AV_SCREEN_CAPTURE_ERR_OK + && result3 == AV_SCREEN_CAPTURE_ERR_OK) { + LOG(false, "MultiInstance init/start/stop success"); + } else { + LOG(false, "MultiInstance init/start/stop failed, init: %d, start: %d, stop: %d", result1, result2, result3); + } + return arg; +} + +static napi_value ScreenCaptureMultiInstance(napi_env env, napi_callback_info info) +{ + g_aFlag = 1; + g_vFlag = 1; + FILE *audioFile = nullptr; + FILE *videoFile = nullptr; + pthread_t tid; + pthread_create(&tid, nullptr, MultiInstance, nullptr); + struct OH_AVScreenCapture* screenCaptureMulti = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA; + audioFile = OpenAFile(audioFile, "SUB_MULTIMEDIA_SCREEN_CAPTURE_MULTI_INSTANCE"); + videoFile = OpenVFile(videoFile, "SUB_MULTIMEDIA_SCREEN_CAPTURE_MULTI_INSTANCE"); + std::shared_ptr screenCaptureCb_ = + std::make_shared(screenCaptureMulti, audioFile, nullptr, videoFile); + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCaptureMulti, isMicrophone); + SetScreenCaptureCallback(screenCaptureMulti, screenCaptureCb_); + OH_AVSCREEN_CAPTURE_ErrCode result1 = OH_AVScreenCapture_Init(screenCaptureMulti, config_); + OH_AVSCREEN_CAPTURE_ErrCode result2 = OH_AVScreenCapture_StartScreenCapture(screenCaptureMulti); + sleep(g_recordTime); + OH_AVSCREEN_CAPTURE_ErrCode result3 = OH_AVScreenCapture_StopScreenCapture(screenCaptureMulti); + DelCallback(screenCaptureMulti); + OH_AVScreenCapture_Release(screenCaptureMulti); + CloseFile(audioFile, videoFile); + screenCaptureCb = nullptr; + napi_value res; + OH_AVSCREEN_CAPTURE_ErrCode result; + if (result1 == AV_SCREEN_CAPTURE_ERR_OK && result2 == AV_SCREEN_CAPTURE_ERR_OK + && result3 == AV_SCREEN_CAPTURE_ERR_OK) { + result = AV_SCREEN_CAPTURE_ERR_OK; + } else { + LOG(false, "init/start/stop failed, init: %d, start: %d, stop: %d", result1, result2, result3); + result = AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT; + } + pthread_join(tid, nullptr); + napi_create_int32(env, result, &res); + return res; +} + +// OH_Media_Screen_Capture_InnerAudio +static napi_value ScreenCaptureInnerAudio(napi_env env, napi_callback_info info) +{ + g_aFlag = 1; + g_vFlag = 1; + int32_t time = 5; + FILE *audioFile = nullptr; + FILE *videoFile = nullptr; + OH_AVScreenCapture* screenCapture = CreateScreenCapture(); + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + config_.audioInfo.innerCapInfo.audioSampleRate = SAMPLE_RATE_48000; + config_.audioInfo.innerCapInfo.audioChannels = STEREO; + config_.audioInfo.innerCapInfo.audioSource = OH_ALL_PLAYBACK; + config_.videoInfo.videoCapInfo.videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA; + audioFile = OpenAFile(audioFile, "SUB_MULTIMEDIA_SCREEN_CAPTURE_INNER_AUDIO(mic)"); + videoFile = OpenVFile(videoFile, "SUB_MULTIMEDIA_SCREEN_CAPTURE_INNER_AUDIO(mic)"); + FILE *iFile = fopen("data/storage/el2/base/files/SUB_MULTIMEDIA_SCREEN_CAPTURE_INNER_AUDIO(inner).pcm", "w+"); + LOG(iFile != nullptr, "inner file audio inner open failed, %s", strerror(errno)); + screenCaptureCb = std::make_shared(screenCapture, audioFile, iFile, videoFile); + + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(screenCapture, isMicrophone); + SetScreenCaptureCallback(screenCapture, screenCaptureCb); + OH_AVSCREEN_CAPTURE_ErrCode result1 = OH_AVScreenCapture_Init(screenCapture, config_); + OH_AVSCREEN_CAPTURE_ErrCode result2 = OH_AVScreenCapture_StartScreenCapture(screenCapture); + sleep(time); + OH_AVSCREEN_CAPTURE_ErrCode result3 = OH_AVScreenCapture_StopScreenCapture(screenCapture); + DelCallback(screenCapture); + OH_AVScreenCapture_Release(screenCapture); + CloseFile(audioFile, videoFile); + if (iFile != nullptr) { + fclose(iFile); + iFile = nullptr; + } + screenCaptureCb = nullptr; + napi_value res; + OH_AVSCREEN_CAPTURE_ErrCode result; + if (result1 == AV_SCREEN_CAPTURE_ERR_OK && result2 == AV_SCREEN_CAPTURE_ERR_OK + && result3 == AV_SCREEN_CAPTURE_ERR_OK) { + result = AV_SCREEN_CAPTURE_ERR_OK; + } else { + LOG(false, "init/start/stop failed, init: %d, start: %d, stop: %d", result1, result2, result3); + result = AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT; + } + napi_create_int32(env, result, &res); + return res; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"initVideoWidthErr", nullptr, InitWidthErr, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"initVideoHeightErr", nullptr, InitHeightErr, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"initVideoSourceErr_YUV", nullptr, InitVideoSourceYUV, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"initVideoSourceErr_ES", nullptr, InitVideoSourceES, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"screenCaptureWithoutAudioData", nullptr, WithoutAudioData, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"initAudioSampleErr_01", nullptr, InitAudioSampleRate_01, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"initAudioSampleErr_02", nullptr, InitAudioSampleRate_02, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"initAudioSampleErr_03", nullptr, InitAudioSampleRate_03, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"initAudioChannelsErr_01", nullptr, InitAudioChannels_01, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"initAudioChannelsErr_02", nullptr, InitAudioChannels_02, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"initAudioSourceErr", nullptr, InitAudioSourceErr, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"initAVErr", nullptr, ScreenCaptureInitErr, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"screenCaptureWithAudioData", nullptr, WithAudioData, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"initCaptureMode_01", nullptr, InitCaptureMode_01, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"initCaptureMode_02", nullptr, InitCaptureMode_02, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"initDataTypeErr_01", nullptr, InitDataType_01, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"initDataTypeErr_02", nullptr, InitDataType_02, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"initDataTypeErr_03", nullptr, InitDataType_03, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"changeAudioSample_01", nullptr, ChangeAudioSampleRate_01, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"changeAudioSample_02", nullptr, ChangeAudioSampleRate_02, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"changeAudioChannels_01", nullptr, ChangeAudioChannels_01, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"changeAudioChannels_02", nullptr, ChangeAudioChannels_02, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"changeAudioChannels_03", nullptr, ChangeAudioChannels_03, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"changeAudioChannels_04", nullptr, ChangeAudioChannels_04, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"captureChangeVideoSize_01", nullptr, ChangeVideoSize_01, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"captureChangeVideoSize_02", nullptr, ChangeVideoSize_02, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"captureChangeVideoSize_03", nullptr, ChangeVideoSize_03, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"screenCaptureFromDisplay", nullptr, ScreenCaptureFromDisplay, nullptr, nullptr, nullptr, napi_default, + nullptr}, + {"setCallbackAcquireBuffer_01", nullptr, BufferAndRelease_01, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"setCallbackAcquireBuffer_02", nullptr, BufferAndRelease_02, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"setCallbackAcquireBuffer_03", nullptr, BufferAndRelease_03, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"setMicrophoneOpenCloseOpen", nullptr, SetMicrophoneEnabled_01, nullptr, nullptr, nullptr, napi_default, + nullptr}, + {"setMicrophoneCloseOpenClose", nullptr, SetMicrophoneEnabled_02, nullptr, nullptr, nullptr, napi_default, + nullptr}, + {"configCombination_01", nullptr, ConfigureCombination_01, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"configCombination_02", nullptr, ConfigureCombination_02, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"configCombination_03", nullptr, ConfigureCombination_03, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"configCombination_04", nullptr, ConfigureCombination_04, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"multiInstance", nullptr, ScreenCaptureMultiInstance, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"innerAudioAndMicAudio", nullptr, ScreenCaptureInnerAudio, nullptr, nullptr, nullptr, napi_default, nullptr}, + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .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(&demoModule); +} diff --git a/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/cpp/types/libentry/index.d.ts b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/cpp/types/libentry/index.d.ts new file mode 100644 index 000000000..e44f3615a --- /dev/null +++ b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/cpp/types/libentry/index.d.ts @@ -0,0 +1 @@ +export const add: (a: number, b: number) => number; \ No newline at end of file diff --git a/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/cpp/types/libentry/oh-package.json5 b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 000000000..c4c6840f5 --- /dev/null +++ b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -0,0 +1,21 @@ +/* + * 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. + */ + +{ + "name": "screenCaptureNdkTest.so", + "types": "./index.d.ts", + "version": "", + "description": "Please describe the basic information." +} \ No newline at end of file diff --git a/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/ets/MainAbility/app.ets b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 000000000..2c3cb0508 --- /dev/null +++ b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,25 @@ +/* + * 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. + */ + +import hilog from '@ohos.hilog'; + +export default { + onCreate() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Application onCreate'); + }, + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Application onDestroy'); + }, +} \ No newline at end of file diff --git a/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/ets/MainAbility/pages/index.ets b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 000000000..c9f8fb116 --- /dev/null +++ b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,38 @@ +/* + * 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. + */ + +import hilog from '@ohos.hilog'; +import testNapi from 'libentry.so' + +@Entry +@Component +struct Index { + @State message: string = 'Hello World' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + .onClick(() => { + hilog.info(0x0000, 'testTag', 'Test NAPI 2 + 3 = %{public}d', testNapi.add(2, 3)); + }) + } + .width('100%') + } + .height('100%') + } +} diff --git a/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/ets/TestAbility/app.ets b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/ets/TestAbility/app.ets new file mode 100644 index 000000000..d636b2297 --- /dev/null +++ b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,34 @@ +/* + * 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. + */ + +import hilog from '@ohos.hilog'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../test/List.test'; + +export default { + onCreate() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Application onCreate'); + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!'); + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Application onDestroy'); + }, +} \ No newline at end of file diff --git a/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/ets/TestAbility/pages/index.ets b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 000000000..9d3e0ad34 --- /dev/null +++ b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,50 @@ +/* + * 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. + */ + +import hilog from '@ohos.hilog'; + +@Entry +@Component +struct Index { + aboutToAppear() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear'); + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 000000000..882019408 --- /dev/null +++ b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,53 @@ +import hilog from '@ohos.hilog'; +import TestRunner from '@ohos.application.testRunner'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +async function onAbilityCreateCallback() { + hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', + JSON.stringify(err) ?? ''); +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare'); + } + + onRun() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run'); + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + var debug = abilityDelegatorArguments.parameters['-D'] + if (debug == 'true') + { + cmd += ' -D' + } + hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd); + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', + JSON.stringify(err) ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', + d.stdResult ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', + d.exitCode ?? ''); + }) + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end'); + } +}; \ No newline at end of file diff --git a/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/ets/test/List.test.ets b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/ets/test/List.test.ets new file mode 100644 index 000000000..69db69f80 --- /dev/null +++ b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * 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. + */ + +import napiTest from './NativeApiTest' + +export default function testsuite() { + napiTest() +} \ No newline at end of file diff --git a/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/ets/test/NativeApiTest.ets b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/ets/test/NativeApiTest.ets new file mode 100644 index 000000000..36bbfb037 --- /dev/null +++ b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/ets/test/NativeApiTest.ets @@ -0,0 +1,607 @@ +/* + * 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. + */ + +import hilog from '@ohos.hilog'; +import featureAbility from '@ohos.ability.featureAbility'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY } from '@ohos.UiTest'; +import myScreenCaptureNdk from "libscreenCaptureNdkTest.so" +import display from '@ohos.display' +const Tag = 'screen_capture_ndk_test:' +export default function nativeApiScreenCaptureJsunit() { + describe('napiTest', function () { + function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + async function getPermission() { + let permissions = ['ohos.permission.MICROPHONE', 'ohos.permission.READ_MEDIA', 'ohos.permission.WRITE_MEDIA', 'ohos.permission.CAPTURE_SCREEN']; + featureAbility.getContext().requestPermissionsFromUser(permissions, 0, (data) => { + console.info(Tag + "request success" + JSON.stringify(data)); + }) + } + beforeAll(async function () { + await getPermission(); + await sleep(1000); + let driver = UiDriver.create(); + let button = await driver.findComponent(BY.text("允许")); + while (button) { + await button.click(); + button = await driver.findComponent(BY.text("允许")); + } + await sleep(1000); + console.info('beforeAll case'); + }) + beforeEach(function () { + console.info('beforeEach case'); + }) + afterEach(function () { + console.info('afterEach case'); + }) + afterAll(function () { + console.info('afterAll case'); + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_VIDEO_CONFIGURE_0001 + * @tc.name : Test OH_AVScreenCapture_Init + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_VIDEO_CONFIGURE_0001', 0, async function (done) { + let a = myScreenCaptureNdk.initVideoWidthErr(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_VIDEO_CONFIGURE_0001-------------initVideoWidthErr:" + a); + expect(a).assertEqual(2) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_VIDEO_CONFIGURE_0002 + * @tc.name : Test OH_AVScreenCapture_Init + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_VIDEO_CONFIGURE_0002', 0, async function (done) { + let a = myScreenCaptureNdk.initVideoHeightErr(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_VIDEO_CONFIGURE_0002-------------initVideoHeightErr:" + a); + expect(a).assertEqual(2) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_VIDEO_CONFIGURE_0003 + * @tc.name : Test OH_AVScreenCapture_Init + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_VIDEO_CONFIGURE_0003', 0, async function (done) { + let a = myScreenCaptureNdk.initVideoSourceErr_YUV(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_VIDEO_CONFIGURE_0003-------------initVideoSourceErr_YUV:" + a); + expect(a).assertEqual(2) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_VIDEO_CONFIGURE_0004 + * @tc.name : Test OH_AVScreenCapture_Init + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_VIDEO_CONFIGURE_0004', 0, async function (done) { + let a = myScreenCaptureNdk.initVideoSourceErr_ES(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_VIDEO_CONFIGURE_0004-------------initVideoSourceErr_ES:" + a); + expect(a).assertEqual(2) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_WITHOUT_SOUND_DATA + * @tc.name : Test OH_AVScreenCapture_Init, OH_AVScreenCapture_StartScreenCapture, OH_AVScreenCapture_StopScreenCapture + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_WITHOUT_SOUND_DATA', 0, async function (done) { + let a = myScreenCaptureNdk.screenCaptureWithoutAudioData(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_WITHOUT_SOUND_DATA-------------screenCaptureWithoutAudioData:" + a); + expect(a).assertEqual(0) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIO_CONFIGURE_0001 + * @tc.name : Test OH_AVScreenCapture_Init + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIO_CONFIGURE_0001', 0, async function (done) { + let a = myScreenCaptureNdk.initAudioSampleErr_01(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIO_CONFIGURE_0001-------------initAudioSampleErr_01:" + a); + expect(a).assertEqual(2) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIO_CONFIGURE_0002 + * @tc.name : Test OH_AVScreenCapture_Init + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIO_CONFIGURE_0002', 0, async function (done) { + let a = myScreenCaptureNdk.initAudioSampleErr_02(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIO_CONFIGURE_0002-------------initAudioSampleErr_02:" + a); + expect(a).assertEqual(2) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIO_CONFIGURE_0003 + * @tc.name : Test OH_AVScreenCapture_Init + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIO_CONFIGURE_0003', 0, async function (done) { + let a = myScreenCaptureNdk.initAudioSampleErr_03(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIO_CONFIGURE_0003-------------initAudioSampleErr_03:" + a); + expect(a).assertEqual(2) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIO_CONFIGURE_0004 + * @tc.name : Test OH_AVScreenCapture_Init + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIO_CONFIGURE_0004', 0, async function (done) { + let a = myScreenCaptureNdk.initAudioChannelsErr_01(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIO_CONFIGURE_0004-------------initAudioChannelsErr_01:" + a); + expect(a).assertEqual(2) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIO_CONFIGURE_0005 + * @tc.name : Test OH_AVScreenCapture_Init + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIO_CONFIGURE_0005', 0, async function (done) { + let a = myScreenCaptureNdk.initAudioChannelsErr_02(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIO_CONFIGURE_0005-------------initAudioChannelsErr_02:" + a); + expect(a).assertEqual(2) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIO_CONFIGURE_0006 + * @tc.name : Test OH_AVScreenCapture_Init + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIO_CONFIGURE_0006', 0, async function (done) { + let a = myScreenCaptureNdk.initAudioSourceErr(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIO_CONFIGURE_0006-------------initAudioSourceErr:" + a); + expect(a).assertEqual(2) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_AV_CONFIGURE + * @tc.name : Test OH_AVScreenCapture_Init + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_AV_CONFIGURE', 0, async function (done) { + let a = myScreenCaptureNdk.initAVErr(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_AV_CONFIGURE-------------initAVErr:" + a); + expect(a).assertEqual(2) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_WITH_SOUND_DATA + * @tc.name : Test OH_AVScreenCapture_Init, OH_AVScreenCapture_StartScreenCapture, OH_AVScreenCapture_StopScreenCapture + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_WITH_SOUND_DATA', 0, async function (done) { + let a = myScreenCaptureNdk.screenCaptureWithAudioData(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_WITH_SOUND_DATA-------------screenCaptureWithAudioData:" + a); + expect(a).assertEqual(0) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_CAPTUREMODE_0001 + * @tc.name : Test OH_AVScreenCapture_Init + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_CAPTUREMODE_0001', 0, async function (done) { + let a = myScreenCaptureNdk.initCaptureMode_01(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_CAPTUREMODE_0001-------------initCaptureMode_01:" + a); + expect(a).assertEqual(2) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_CAPTUREMODE_0002 + * @tc.name : Test OH_AVScreenCapture_Init + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_CAPTUREMODE_0002', 0, async function (done) { + let a = myScreenCaptureNdk.initCaptureMode_02(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_CAPTUREMODE_0002-------------initCaptureMode_02:" + a); + expect(a).assertEqual(2) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_DATATYPE_0001 + * @tc.name : Test OH_AVScreenCapture_Init + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_DATATYPE_0001', 0, async function (done) { + let a = myScreenCaptureNdk.initDataTypeErr_01(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_DATATYPE_0001-------------initDataTypeErr_01:" + a); + expect(a).assertEqual(2) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_DATATYPE_0002 + * @tc.name : Test OH_AVScreenCapture_Init + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_DATATYPE_0002', 0, async function (done) { + let a = myScreenCaptureNdk.initDataTypeErr_02(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_DATATYPE_0002-------------initDataTypeErr_02:" + a); + expect(a).assertEqual(2) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_DATATYPE_0003 + * @tc.name : Test OH_AVScreenCapture_Init + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_DATATYPE_0003', 0, async function (done) { + let a = myScreenCaptureNdk.initDataTypeErr_03(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_DATATYPE_0003-------------initDataTypeErr_03:" + a); + expect(a).assertEqual(2) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIOSAMPLERATE_0001 + * @tc.name : Test OH_AVScreenCapture_Init, OH_AVScreenCapture_StartScreenCapture, OH_AVScreenCapture_StopScreenCapture + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIOSAMPLERATE_0001', 0, async function (done) { + let a = myScreenCaptureNdk.changeAudioSample_01(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIOSAMPLERATE_0001-------------changeAudioSample_01:" + a); + expect(a).assertEqual(0) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIOSAMPLERATE_0002 + * @tc.name : Test OH_AVScreenCapture_Init, OH_AVScreenCapture_StartScreenCapture, OH_AVScreenCapture_StopScreenCapture + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIOSAMPLERATE_0002', 0, async function (done) { + let a = myScreenCaptureNdk.changeAudioSample_02(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIOSAMPLERATE_0002-------------changeAudioSample_02:" + a); + expect(a).assertEqual(0) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIOCHANNELS_0001 + * @tc.name : Test OH_AVScreenCapture_Init, OH_AVScreenCapture_StartScreenCapture, OH_AVScreenCapture_StopScreenCapture + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIOCHANNELS_0001', 0, async function (done) { + let a = myScreenCaptureNdk.changeAudioChannels_01(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIOCHANNELS_0001-------------changeAudioChannels_01:" + a); + expect(a).assertEqual(0) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIOCHANNELS_0002 + * @tc.name : Test OH_AVScreenCapture_Init, OH_AVScreenCapture_StartScreenCapture, OH_AVScreenCapture_StopScreenCapture + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIOCHANNELS_0002', 0, async function (done) { + let a = myScreenCaptureNdk.changeAudioChannels_02(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIOCHANNELS_0002-------------changeAudioChannels_02:" + a); + expect(a).assertEqual(0) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIOCHANNELS_0003 + * @tc.name : Test OH_AVScreenCapture_Init, OH_AVScreenCapture_StartScreenCapture, OH_AVScreenCapture_StopScreenCapture + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIOCHANNELS_0003', 0, async function (done) { + let a = myScreenCaptureNdk.changeAudioChannels_03(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIOCHANNELS_0003-------------changeAudioChannels_03:" + a); + expect(a).assertEqual(0) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIOCHANNELS_0004 + * @tc.name : Test OH_AVScreenCapture_Init, OH_AVScreenCapture_StartScreenCapture, OH_AVScreenCapture_StopScreenCapture + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIOCHANNELS_0004', 0, async function (done) { + let a = myScreenCaptureNdk.changeAudioChannels_04(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_AUDIOCHANNELS_0004-------------changeAudioChannels_04:" + a); + expect(a).assertEqual(0) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_VIDEOSIZE_0001 + * @tc.name : Test OH_AVScreenCapture_Init, OH_AVScreenCapture_StartScreenCapture, OH_AVScreenCapture_StopScreenCapture + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_VIDEOSIZE_0001', 0, async function (done) { + let a = myScreenCaptureNdk.captureChangeVideoSize_01(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_VIDEOSIZE_0001-------------captureChangeVideoSize_01:" + a); + expect(a).assertEqual(0) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_VIDEOSIZE_0002 + * @tc.name : Test OH_AVScreenCapture_Init, OH_AVScreenCapture_StartScreenCapture, OH_AVScreenCapture_StopScreenCapture + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_VIDEOSIZE_0002', 0, async function (done) { + let a = myScreenCaptureNdk.captureChangeVideoSize_02(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_VIDEOSIZE_0002-------------captureChangeVideoSize_02:" + a); + expect(a).assertEqual(0) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_VIDEOSIZE_0003 + * @tc.name : Test OH_AVScreenCapture_Init, OH_AVScreenCapture_StartScreenCapture, OH_AVScreenCapture_StopScreenCapture + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_VIDEOSIZE_0003', 0, async function (done) { + let a = myScreenCaptureNdk.captureChangeVideoSize_03(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_VIDEOSIZE_0003-------------captureChangeVideoSize_03:" + a); + expect(a).assertEqual(0) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_FROM_DISPLAY + * @tc.name : Test OH_AVScreenCapture_Init, OH_AVScreenCapture_StartScreenCapture, OH_AVScreenCapture_StopScreenCapture + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_FROM_DISPLAY', 0, async function (done) { + const dftDisplay = display.getDefaultDisplaySync(); + let width = dftDisplay.width; + let height = dftDisplay.height; + let frameRate = dftDisplay.refreshRate; + let a = myScreenCaptureNdk.screenCaptureFromDisplay(width, height, frameRate); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_FROM_DISPLAY-------------screenCaptureFromDisplay:" + a); + expect(a).assertEqual(0) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_BUFFERTEST_0001 + * @tc.name : Test OH_AVScreenCapture_SetCallback, OH_AVScreenCapture_AcquireVideoBuffer, OH_AVScreenCapture_AcquireVideoBuffer + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_BUFFERTEST_0001', 0, async function (done) { + let a = myScreenCaptureNdk.setCallbackAcquireBuffer_01(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_BUFFERTEST_0001-------------setCallbackAcquireBuffer_01:" + a); + expect(a).assertEqual(0) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_BUFFERTEST_0002 + * @tc.name : Test OH_AVScreenCapture_SetCallback, OH_AVScreenCapture_AcquireVideoBuffer, OH_AVScreenCapture_AcquireVideoBuffer, OH_AVScreenCapture_ReleaseAudioBuffer, OH_AVScreenCapture_ReleaseVideoBuffer + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_BUFFERTEST_0002', 0, async function (done) { + let a = myScreenCaptureNdk.setCallbackAcquireBuffer_02(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_BUFFERTEST_0002-------------setCallbackAcquireBuffer_02:" + a); + expect(a).assertEqual(0) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_BUFFERTEST_0003 + * @tc.name : Test OH_AVScreenCapture_SetCallback, OH_AVScreenCapture_AcquireVideoBuffer, OH_AVScreenCapture_AcquireVideoBuffer + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_BUFFERTEST_0003', 0, async function (done) { + let a = myScreenCaptureNdk.setCallbackAcquireBuffer_03(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_BUFFERTEST_0003-------------setCallbackAcquireBuffer_03:" + a); + expect(a).assertEqual(0) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_MICTEST_0001 + * @tc.name : Test OH_AVScreenCapture_SetMicrophoneEnabled + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_MICTEST_0001', 0, async function (done) { + let a = myScreenCaptureNdk.setMicrophoneOpenCloseOpen(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_MICTEST_0001-------------setMicrophoneOpenCloseOpen:" + a); + expect(a).assertEqual(0) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_MICTEST_0002 + * @tc.name : Test OH_AVScreenCapture_SetMicrophoneEnabled + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_MICTEST_0002', 0, async function (done) { + let a = myScreenCaptureNdk.setMicrophoneCloseOpenClose(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_MICTEST_0002-------------setMicrophoneCloseOpenClose:" + a); + expect(a).assertEqual(0) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_CONFIG_COMBINATION_0001 + * @tc.name : Test VideoSize and CaptureMode combination + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_CONFIG_COMBINATION_0001', 0, async function (done) { + let a = myScreenCaptureNdk.configCombination_01(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_CONFIG_COMBINATION_0001-------------configCombination_01:" + a); + expect(a).assertEqual(0) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_CONFIG_COMBINATION_0002 + * @tc.name : Test VideoSize and CaptureMode combination + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_CONFIG_COMBINATION_0002', 0, async function (done) { + let a = myScreenCaptureNdk.configCombination_02(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_CONFIG_COMBINATION_0002-------------configCombination_02:" + a); + expect(a).assertEqual(0) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_CONFIG_COMBINATION_0003 + * @tc.name : Test VideoSize and CaptureMode combination + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_CONFIG_COMBINATION_0003', 0, async function (done) { + let a = myScreenCaptureNdk.configCombination_03(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_CONFIG_COMBINATION_0003-------------configCombination_03:" + a); + expect(a).assertEqual(0) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_CONFIG_COMBINATION_0004 + * @tc.name : Test VideoSize and CaptureMode combination + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_CONFIG_COMBINATION_0004', 0, async function (done) { + let a = myScreenCaptureNdk.configCombination_04(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_CONFIG_COMBINATION_0004-------------configCombination_04:" + a); + expect(a).assertEqual(0) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_MULTI_INSTANCE + * @tc.name : Test Multi Instance + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_MULTI_INSTANCE', 0, async function (done) { + let a = myScreenCaptureNdk.multiInstance(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_MULTI_INSTANCE-------------multiInstance:" + a); + expect(a).assertEqual(0) + done() + }) + /* * + * @tc.number : SUB_MULTIMEDIA_SCREEN_CAPTURE_INNER_AUDIO + * @tc.name : Test Multi Instance + * @tc.desc : + * @tc.size : + * @tc.type : Functional + * @tc.level : FWK Layer + */ + it('SUB_MULTIMEDIA_SCREEN_CAPTURE_INNER_AUDIO', 0, async function (done) { + let a = myScreenCaptureNdk.innerAudioAndMicAudio(); + console.info(Tag + "SUB_MULTIMEDIA_SCREEN_CAPTURE_INNER_AUDIO-------------innerAudioAndMicAudio:" + a); + expect(a).assertEqual(0) + done() + }) + }) +} \ No newline at end of file diff --git a/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/resources/base/element/color.json b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/resources/base/element/color.json new file mode 100644 index 000000000..3c712962d --- /dev/null +++ b/multimedia/media/media_js_standard/screenCapture_ndk_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/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/resources/base/element/string.json b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/resources/base/element/string.json new file mode 100644 index 000000000..bab0cfab6 --- /dev/null +++ b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/resources/base/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/resources/base/media/icon.png b/multimedia/media/media_js_standard/screenCapture_ndk_test/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch literal 6790 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