Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
e71a0278
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e71a0278
编写于
6月 30, 2023
作者:
B
bayanxing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
avRecorder 视频录制用例上库
Signed-off-by:
N
bayanxing
<
bayanxing@kaihong.com
>
上级
473e6006
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
359 addition
and
1 deletion
+359
-1
multimedia/media/media_js_standard/AVRecorderTestBase.js
multimedia/media/media_js_standard/AVRecorderTestBase.js
+1
-1
multimedia/media/media_js_standard/AvVideoRecorderTestBase.js
...imedia/media/media_js_standard/AvVideoRecorderTestBase.js
+162
-0
multimedia/media/media_js_standard/avRecorder/src/main/js/test/AvVideoRecorderFuncTestOne.test.js
...order/src/main/js/test/AvVideoRecorderFuncTestOne.test.js
+196
-0
未找到文件。
multimedia/media/media_js_standard/AVRecorderTestBase.js
浏览文件 @
e71a0278
...
...
@@ -284,7 +284,7 @@ export async function releasePromise(avRecorder) {
});
}
async
function
releaseDone
(
avRecorder
,
done
){
export
async
function
releaseDone
(
avRecorder
,
done
){
await
avRecorder
.
release
().
then
(()
=>
{
console
.
info
(
'
releaseDone avRecorder.state is
'
+
avRecorder
.
state
);
expect
(
avRecorder
.
state
).
assertEqual
(
AV_RECORDER_STATE
.
RELEASED
);
...
...
multimedia/media/media_js_standard/AvVideoRecorderTestBase.js
0 → 100644
浏览文件 @
e71a0278
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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
media
from
'
@ohos.multimedia.media
'
import
*
as
mediaTestBase
from
'
./MediaTestBase.js
'
;
import
*
as
AVRecorderTestBase
from
'
./AVRecorderTestBase.js
'
;
import
camera
from
'
@ohos.multimedia.camera
'
let
TAG
=
"
[avVideoRecorderTest]
"
;
let
cameraManager
;
let
videoOutput
;
let
captureSession
;
let
cameraInput
;
let
previewOutput
;
let
cameraOutputCap
;
let
videoSurfaceId
=
null
;
let
events
=
require
(
'
events
'
);
let
eventEmitter
=
new
events
.
EventEmitter
();
export
const
AV_RECORDER_STATE
=
{
IDLE
:
'
idle
'
,
PREPARED
:
'
prepared
'
,
STARTED
:
'
started
'
,
PAUSED
:
'
paused
'
,
STOPPED
:
'
stopped
'
,
RELEASED
:
'
released
'
,
ERROR
:
'
error
'
,
}
export
function
resourceName
(){
let
timestamp
=
Date
.
now
();
let
filename
=
`avRecorder_
${
timestamp
}
.mp4`
;
return
filename
;
}
export
async
function
initCamera
()
{
// 创建CameraManager对象
let
context
=
globalThis
.
contextVideo
;
cameraManager
=
camera
.
getCameraManager
(
context
)
if
(
!
cameraManager
)
{
console
.
error
(
"
camera.getCameraManager error
"
)
return
;
}
cameraManager
.
on
(
'
cameraStatus
'
,
(
cameraStatusInfo
)
=>
{
console
.
log
(
`camera :
${
cameraStatusInfo
.
camera
.
cameraId
}
`
);
console
.
log
(
`status:
${
cameraStatusInfo
.
status
}
`
);
})
// 获取相机列表
let
cameras
=
cameraManager
.
getSupportedCameras
();
let
cameraDevice
=
cameras
[
0
];
// 查询相机设备在模式下支持的输出能力
let
cameraOutputCapability
=
cameraManager
.
getSupportedOutputCapability
(
cameraDevice
);
console
.
info
(
'
getSupportedOutputCapability success
'
);
console
.
log
(
`cameraOutputCapability previewProfiles:
${
cameraOutputCapability
.
previewProfiles
}
`
);
console
.
log
(
`cameraOutputCapability photoProfiles:
${
cameraOutputCapability
.
photoProfiles
}
`
);
console
.
log
(
`cameraOutputCapability videoProfiles:
${
cameraOutputCapability
.
videoProfiles
}
`
);
// 创建相机输入流
try
{
cameraInput
=
cameraManager
.
createCameraInput
(
cameraDevice
);
console
.
info
(
'
createCameraInput success
'
);
}
catch
(
error
)
{
console
.
error
(
'
Failed to createCameraInput errorCode =
'
+
error
.
code
);
}
// 监听cameraInput错误信息
cameraInput
.
on
(
'
error
'
,
cameraDevice
,
(
error
)
=>
{
console
.
log
(
`Camera input error code:
${
error
.
code
}
`
);
})
// 创建VideoOutput对象
let
profile
=
cameraOutputCapability
.
videoProfiles
[
0
];
try
{
videoOutput
=
cameraManager
.
createVideoOutput
(
profile
,
videoSurfaceId
)
console
.
info
(
'
createVideoOutput success
'
);
}
catch
(
error
)
{
console
.
error
(
'
Failed to create the videoOutput instance. errorCode =
'
+
error
.
code
);
}
// 监听视频输出错误信息
videoOutput
.
on
(
'
error
'
,
(
error
)
=>
{
console
.
log
(
`Preview output error code:
${
error
.
code
}
`
);
})
// 创建previewOutput输出对象
let
surfaceId
=
globalThis
.
value
;
let
previewProfile
=
cameraOutputCapability
.
previewProfiles
[
0
];
try
{
previewOutput
=
cameraManager
.
createPreviewOutput
(
previewProfile
,
surfaceId
)
console
.
info
(
'
createPreviewOutput success
'
);
}
catch
(
error
)
{
console
.
error
(
'
Failed to create the PreviewOutput instance errorCode =
'
+
error
.
code
);
}
// 打开相机
await
cameraInput
.
open
();
//创建会话
try
{
captureSession
=
cameraManager
.
createCaptureSession
()
console
.
info
(
'
createCaptureSession success
'
);
}
catch
(
error
)
{
console
.
error
(
'
Failed to create the CaptureSession instance. errorCode =
'
+
error
.
code
);
}
// 监听session错误信息
captureSession
.
on
(
'
error
'
,
(
error
)
=>
{
console
.
log
(
`Capture session error code:
${
error
.
code
}
`
);
})
// 开始配置会话
try
{
captureSession
.
beginConfig
()
console
.
info
(
'
beginConfig success
'
);
}
catch
(
error
)
{
console
.
error
(
'
Failed to beginConfig. errorCode =
'
+
error
.
code
);
}
// 向会话中添加相机输入流
try
{
captureSession
.
addInput
(
cameraInput
)
}
catch
(
error
)
{
console
.
error
(
'
Failed to addInput. errorCode =
'
+
error
.
code
);
}
// 向会话中添加预览输入流
try
{
captureSession
.
addOutput
(
previewOutput
)
}
catch
(
error
)
{
console
.
error
(
'
Failed to addOutput(previewOutput). errorCode =
'
+
error
.
code
);
}
// 向会话中添加录像输出流
try
{
captureSession
.
addOutput
(
videoOutput
)
}
catch
(
error
)
{
console
.
error
(
'
Failed to addOutput(videoOutput). errorCode =
'
+
error
.
code
);
}
// 提交会话配置
await
captureSession
.
commitConfig
()
// 启动会话
await
captureSession
.
start
().
then
(()
=>
{
console
.
log
(
'
Promise returned to indicate the session start success.
'
);
})
}
\ No newline at end of file
multimedia/media/media_js_standard/avRecorder/src/main/js/test/AvVideoRecorderFuncTestOne.test.js
0 → 100644
浏览文件 @
e71a0278
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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
deviceInfo
from
'
@ohos.deviceInfo
'
import
media
from
'
@ohos.multimedia.media
'
import
camera
from
'
@ohos.multimedia.camera
'
import
*
as
mediaTestBase
from
'
../../../../../MediaTestBase.js
'
;
import
*
as
avRecorderTestBase
from
'
../../../../../AVRecorderTestBase.js
'
;
import
*
as
avVideoRecorderTestBase
from
'
../../../../../AvVideoRecorderTestBase.js
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
;
export
default
function
avVideoRecorderTestOne
()
{
describe
(
'
avVideoRecorderTestOne
'
,
function
()
{
let
avRecorder
=
null
;
const
recorderTime
=
3000
;
const
RECORDER_LONG_TIME
=
3600000
;
const
LOOP_TIMES
=
1000
;
const
FORMAT_M4A
=
media
.
ContainerFormatType
.
CFT_MPEG_4A
;
const
ENCORDER_AAC
=
media
.
CodecMimeType
.
AUDIO_AAC
;
const
ONLYAUDIO_TYPE
=
'
only_audio
'
;
let
trackArray
;
let
fdObject
;
let
fdPath
;
let
TAG
=
"
[avVideoRecorderTestOne]
"
;
let
avProfile
=
{
audioBitrate
:
48000
,
audioChannels
:
2
,
audioCodec
:
media
.
CodecMimeType
.
AUDIO_AAC
,
audioSampleRate
:
48000
,
fileFormat
:
media
.
ContainerFormatType
.
CFT_MPEG_4
,
// 视频文件封装格式,只支持MP4
videoBitrate
:
100000
,
// 视频比特率
videoCodec
:
media
.
CodecMimeType
.
VIDEO_MPEG4
,
// 视频文件编码格式,支持mpeg4和avc两种格式
videoFrameWidth
:
640
,
// 视频分辨率的宽
videoFrameHeight
:
480
,
// 视频分辨率的高
videoFrameRate
:
30
// 视频帧率
}
let
avConfig
=
{
audioSourceType
:
media
.
AudioSourceType
.
AUDIO_SOURCE_TYPE_MIC
,
videoSourceType
:
media
.
VideoSourceType
.
VIDEO_SOURCE_TYPE_SURFACE_ES
,
// 视频源类型,支持YUV和ES两种格式
profile
:
avProfile
,
url
:
'
fd://35
'
,
// 参考应用文件访问与管理开发示例新建并读写一个文件
rotation
:
0
,
// 视频旋转角度,默认为0不旋转,支持的值为0、90、180、270
location
:
{
latitude
:
30
,
longitude
:
130
},
}
let
events
=
require
(
'
events
'
);
let
eventEmitter
=
new
events
.
EventEmitter
();
beforeAll
(
async
function
()
{
console
.
info
(
'
beforeAll in1
'
);
if
(
deviceInfo
.
deviceType
===
'
default
'
)
{
avConfig
.
videoSourceType
=
media
.
VideoSourceType
.
VIDEO_SOURCE_TYPE_SURFACE_ES
console
.
info
(
TAG
+
'
rk3568 avConfig.videoSourceType is :
'
+
avConfig
.
videoSourceType
)
}
else
{
avConfig
.
videoSourceType
=
media
.
VideoSourceType
.
VIDEO_SOURCE_TYPE_SURFACE_YUV
console
.
info
(
TAG
+
'
rk3568 avConfig.videoSourceType is :
'
+
avConfig
.
videoSourceType
)
}
let
permissionName1
=
'
ohos.permission.MICROPHONE
'
;
let
permissionName2
=
'
ohos.permission.MEDIA_LOCATION
'
;
let
permissionName3
=
'
ohos.permission.READ_MEDIA
'
;
let
permissionName4
=
'
ohos.permission.WRITE_MEDIA
'
;
let
permissionName5
=
'
ohos.permission.CAMERA
'
;
let
permissionNames
=
[
permissionName1
,
permissionName2
,
permissionName3
,
permissionName4
,
permissionName5
];
await
mediaTestBase
.
getPermission
(
permissionNames
);
await
mediaTestBase
.
msleepAsync
(
3000
);
await
mediaTestBase
.
driveFn
(
3
)
console
.
info
(
'
beforeAll out
'
);
})
beforeEach
(
async
function
()
{
console
.
info
(
'
beforeEach case
'
);
await
avRecorderTestBase
.
sleep
(
1000
);
})
afterEach
(
async
function
()
{
console
.
info
(
'
afterEach case
'
);
if
(
avRecorder
!=
null
)
{
avRecorder
.
release
().
then
(()
=>
{
console
.
info
(
TAG
+
'
this testCase execution completed
'
)
},
mediaTestBase
.
failureCallback
).
catch
(
mediaTestBase
.
catchCallback
);
}
await
avRecorderTestBase
.
sleep
(
1000
);
})
afterAll
(
function
()
{
mediaTestBase
.
closeFd
(
fdObject
.
fileAsset
,
fdObject
.
fdNumber
);
console
.
info
(
'
afterAll case
'
);
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_PROMISE_MPEG4_0100
* @tc.name : 001.test 1,record 3s; 2,pause 3,resume 4,stop 5,restart
* @tc.desc : Recorder video 1,record 3s; 2,pause 3,resume 4,stop 5,restart
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_PROMISE_MPEG4_0100
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
'
SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_PROMISE_MPEG4_0100 start
'
)
let
fileName
=
avVideoRecorderTestBase
.
resourceName
()
fdObject
=
await
mediaTestBase
.
getAvRecorderFd
(
fileName
,
"
video
"
);
fdPath
=
"
fd://
"
+
fdObject
.
fdNumber
;
avConfig
.
url
=
fdPath
;
avVideoRecorderTestBase
.
avRecorderWithPromise
(
avConfig
,
avRecorder
,
recorderTime
,
done
);
console
.
info
(
TAG
+
'
SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_PROMISE_MPEG4_0100 end
'
)
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVRECORDER_VIDEO_STOP_PROMISE_0100
* @tc.name : 001.test create-stop
* @tc.desc : Recorder video create-stop
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVRECORDER_VIDEO_STOP_PROMISE_0100
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
'
SUB_MULTIMEDIA_AVRECORDER_VIDEO_STOP_PROMISE_0100 start
'
)
let
fileName
=
avVideoRecorderTestBase
.
resourceName
()
fdObject
=
await
mediaTestBase
.
getAvRecorderFd
(
fileName
,
"
video
"
);
fdPath
=
"
fd://
"
+
fdObject
.
fdNumber
;
avConfig
.
url
=
fdPath
;
avVideoRecorderTestBase
.
avRecorderStopPromise1
(
avConfig
,
avRecorder
,
recorderTime
,
done
);
console
.
info
(
TAG
+
'
SUB_MULTIMEDIA_AVRECORDER_VIDEO_STOP_PROMISE_0100 end
'
)
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVRECORDER_VIDEO_STOP_PROMISE_0200
* @tc.name : 001.test prepare-stop
* @tc.desc : Recorder video prepare-stop
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVRECORDER_VIDEO_STOP_PROMISE_0200
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
'
SUB_MULTIMEDIA_AVRECORDER_VIDEO_STOP_PROMISE_0200 start
'
)
let
fileName
=
avVideoRecorderTestBase
.
resourceName
()
fdObject
=
await
mediaTestBase
.
getAvRecorderFd
(
fileName
,
"
video
"
);
fdPath
=
"
fd://
"
+
fdObject
.
fdNumber
;
avConfig
.
url
=
fdPath
;
avVideoRecorderTestBase
.
avRecorderStopPromise2
(
avConfig
,
avRecorder
,
recorderTime
,
done
);
console
.
info
(
TAG
+
'
SUB_MULTIMEDIA_AVRECORDER_VIDEO_STOP_PROMISE_0200 end
'
)
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVRECORDER_VIDEO_STOP_PROMISE_0700
* @tc.name : 001.test getInputSurface-stop
* @tc.desc : Recorder video getInputSurface-stop
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVRECORDER_VIDEO_STOP_PROMISE_0700
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
'
SUB_MULTIMEDIA_AVRECORDER_VIDEO_STOP_PROMISE_0700 start
'
)
let
fileName
=
avVideoRecorderTestBase
.
resourceName
()
fdObject
=
await
mediaTestBase
.
getAvRecorderFd
(
fileName
,
"
video
"
);
fdPath
=
"
fd://
"
+
fdObject
.
fdNumber
;
avConfig
.
url
=
fdPath
;
avVideoRecorderTestBase
.
avRecorderStopPromise7
(
avConfig
,
avRecorder
,
recorderTime
,
done
);
console
.
info
(
TAG
+
'
SUB_MULTIMEDIA_AVRECORDER_VIDEO_STOP_PROMISE_0700 end
'
)
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVRECORDER_VIDEO_RESET_PROMISE_0700
* @tc.name : 001.test create-prepare-getInputSurface-reset
* @tc.desc : Recorder create-prepare-getInputSurface-reset
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVRECORDER_VIDEO_RESET_PROMISE_0700
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
'
SUB_MULTIMEDIA_AVRECORDER_VIDEO_RESET_PROMISE_0700 start
'
)
let
fileName
=
avVideoRecorderTestBase
.
resourceName
()
fdObject
=
await
mediaTestBase
.
getAvRecorderFd
(
fileName
,
"
video
"
);
fdPath
=
"
fd://
"
+
fdObject
.
fdNumber
;
avConfig
.
url
=
fdPath
;
avVideoRecorderTestBase
.
avRecorderResetPromise7
(
avConfig
,
avRecorder
,
recorderTime
,
done
);
console
.
info
(
TAG
+
'
SUB_MULTIMEDIA_AVRECORDER_VIDEO_RESET_PROMISE_0700 end
'
)
})
})
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录