提交 33f7fee0 编写于 作者: Z zhubx0704

Add AVScreenCapture Ndk XTS Test

Signed-off-by: Nzhubx0704 <zhubx0704@thundersoft.com>
上级 6c84d5c7
......@@ -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",
......
# 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"
}
{
"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
{
"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
# 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"
}
# 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
/*
* 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 <native_buffer.h>
#include <unistd.h>
#include <fcntl.h>
#include <securec.h>
#include <cstdio>
#include <string>
#include <map>
#include <iostream>
#include <thread>
#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, &timestamp, &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<ScreenCaptureNdkTestCallback> screenCaptureCb = nullptr;
std::mutex mutex_;
std::map<OH_AVScreenCapture *, std::shared_ptr<ScreenCaptureNdkCallBack>> mockCbMap_;
void DelCallback(OH_AVScreenCapture *screenCapture)
{
std::lock_guard<std::mutex> lock(mutex_);
if (mockCbMap_.empty()) {
return;
}
auto it = mockCbMap_.find(screenCapture);
if (it != mockCbMap_.end()) {
mockCbMap_.erase(it);
}
}
std::shared_ptr<ScreenCaptureNdkCallBack> GetCallback(OH_AVScreenCapture *screenCapture)
{
std::lock_guard<std::mutex> 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<ScreenCaptureNdkCallBack> mockCb = GetCallback(screenCapture);
if (mockCb != nullptr) {
mockCb->OnError(errorCode);
}
}
void OnAudioBufferAvailable(OH_AVScreenCapture *screenCapture, bool isReady,
OH_AudioCaptureSourceType type)
{
std::shared_ptr<ScreenCaptureNdkCallBack> mockCb = GetCallback(screenCapture);
if (mockCb != nullptr) {
mockCb->OnAudioBufferAvailable(isReady, type);
}
}
void OnVideoBufferAvailable(OH_AVScreenCapture *screenCapture, bool isReady)
{
std::shared_ptr<ScreenCaptureNdkCallBack> mockCb = GetCallback(screenCapture);
if (mockCb != nullptr) {
mockCb->OnVideoBufferAvailable(isReady);
}
}
void SetScreenCaptureCallback(OH_AVScreenCapture *screenCapture, std::shared_ptr<ScreenCaptureNdkTestCallback> &cb)
{
if (cb != nullptr) {
std::lock_guard<std::mutex> 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<ScreenCaptureNdkTestCallback>(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<ScreenCaptureNdkTestCallback>(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<OH_CaptureMode>(-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<OH_CaptureMode>(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<ScreenCaptureNdkTestCallback>(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<ScreenCaptureNdkTestCallback>(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<ScreenCaptureNdkTestCallback>(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<ScreenCaptureNdkTestCallback>(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<ScreenCaptureNdkTestCallback>(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<ScreenCaptureNdkTestCallback>(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<ScreenCaptureNdkTestCallback>(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<ScreenCaptureNdkTestCallback>(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<ScreenCaptureNdkTestCallback>(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<ScreenCaptureNdkTestCallback>(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<ScreenCaptureNdkTestCallback>(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<ScreenCaptureNdkTestCallback>(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<ScreenCaptureNdkTestCallback>(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<ScreenCaptureNdkTestCallback>(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<ScreenCaptureNdkTestCallback>(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<ScreenCaptureNdkTestCallback>(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<ScreenCaptureNdkTestCallback>(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<ScreenCaptureNdkTestCallback>(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<ScreenCaptureNdkTestCallback>(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<ScreenCaptureNdkTestCallback>(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<ScreenCaptureNdkTestCallback> screenCaptureCb_ =
std::make_shared<ScreenCaptureNdkTestCallback>(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<ScreenCaptureNdkTestCallback>(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);
}
export const add: (a: number, b: number) => number;
\ No newline at end of file
/*
* 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
/*
* 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
/*
* 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%')
}
}
/*
* 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
/*
* 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
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
/*
* 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
/*
* 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
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
{
"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
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "模块描述"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册