未验证 提交 b275bddf 编写于 作者: O openharmony_ci 提交者: Gitee

!5958 Modify xts cases for camere session

Merge pull request !5958 from wuhao/master
......@@ -78,8 +78,12 @@
"reason": "use ohos.permission.READ_MEDIA"
},
{
"name": "ohos.permission.START_ABILITIES_FROM_BACKGROUND",
"reason": "use ohos.permission.START_ABILITIES_FROM_BACKGROUND"
"name": "ohos.permission.WRITE_MEDIA",
"reason": "use ohos.permission.WRITE_MEDIA"
},
{
"name": "ohos.permission.START_ABILIIES_FROM_BACKGROUND",
"reason": "use ohos.permission.START_ABILIIES_FROM_BACKGROUND"
},
{
"name": "ohos.permission.START_INVISIBLE_ABILITY",
......
......@@ -113,23 +113,35 @@ export default function cameraJSUnitOutput(surfaceId: any) {
}
}
async function getvideosurface() {
await getFd('CameraOutput.mp4');
videoConfig.url = fdPath;
videoConfig.url = fdPath;
media.createVideoRecorder((err, recorder) => {
console.info(TAG + 'createVideoRecorder called')
videoRecorder = recorder
console.info(TAG + 'videoRecorder is :' + JSON.stringify(videoRecorder))
console.info(TAG + 'videoRecorder.prepare called.')
videoRecorder.prepare(videoConfig, (err) => {
console.info(TAG + 'videoRecorder.prepare success.')
})
videoRecorder.getInputSurface((err, id) => {
console.info(TAG + 'getInputSurface called')
videoSurfaceId = id
console.info(TAG + 'getInputSurface surfaceId: ' + JSON.stringify(videoSurfaceId))
})
if (!err) {
console.info(TAG + 'createVideoRecorder called')
videoRecorder = recorder
console.info(TAG + 'videoRecorder is :' + JSON.stringify(videoRecorder))
console.info(TAG + 'videoRecorder.prepare called.')
videoRecorder.prepare(videoConfig, (err) => {
if (!err) {
console.info(TAG + 'videoRecorder.prepare success.')
videoRecorder.getInputSurface((err, id) => {
console.info(TAG + 'getInputSurface called')
if (!err) {
videoSurfaceId = id
console.info(TAG + 'getInputSurface surfaceId: ' + JSON.stringify(videoSurfaceId))
} else {
console.info(TAG + 'getInputSurface FAILED')
}
})
} else {
console.info(TAG + 'prepare FAILED')
}
})
}
else {
console.info(TAG + 'createVideoRecorder FAILED')
}
})
}
......@@ -164,7 +176,7 @@ export default function cameraJSUnitOutput(surfaceId: any) {
let permissionName3 = 'ohos.permission.MEDIA_LOCATION';
let permissionName4 = 'ohos.permission.READ_MEDIA';
let permissionName5 = 'ohos.permission.WRITE_MEDIA';
let permissionName6 = 'ohos.permission.START_ABILITIES_FROM_BACKGROUND';
let permissionName6 = 'ohos.permission.START_ABILIIES_FROM_BACKGROUND';
let permissionName7 = 'ohos.permission.START_INVISIBLE_ABILITY';
let permissionName8 = 'ohos.permission.ABILITY_BACKGROUND_COMMUNICATION';
await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => {
......
......@@ -82,47 +82,59 @@ export default function cameraManagerTest(surfaceId: any) {
let publicPath = await mediaTest.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO);
let dataUri = await mediaTest.createAsset(mediaType, displayName, publicPath);
if (dataUri != undefined) {
let args = dataUri.id.toString();
let fetchOp = {
selections: fileKeyObj.ID + "=?",
selectionArgs: [args],
}
let fetchFileResult = await mediaTest.getFileAssets(fetchOp);
mFileAsset = await fetchFileResult.getAllObject();
mFdNumber = await mFileAsset[0].open('Rw');
mFdPath = "fd://" + mFdNumber.toString();
let args = dataUri.id.toString();
let fetchOp = {
selections: fileKeyObj.ID + "=?",
selectionArgs: [args],
}
let fetchFileResult = await mediaTest.getFileAssets(fetchOp);
mFileAsset = await fetchFileResult.getAllObject();
mFdNumber = await mFileAsset[0].open('Rw');
mFdPath = "fd://" + mFdNumber.toString();
}
}
}
async function closeFd() {
async function closeFd() {
if (mFileAsset != null) {
await mFileAsset[0].close(mFdNumber).then(() => {
console.info('[mediaLibrary] case close fd success');
}).catch((err) => {
console.info('[mediaLibrary] case close fd failed');
});
await mFileAsset[0].close(mFdNumber).then(() => {
console.info('[mediaLibrary] case close fd success');
}).catch((err) => {
console.info('[mediaLibrary] case close fd failed');
});
} else {
console.info('[mediaLibrary] case fileAsset is null');
console.info('[mediaLibrary] case fileAsset is null');
}
}
}
async function getVideoReceiveSurface() {
async function getVideoReceiveSurface() {
console.log(TAG + 'Entering getVideoReceiveSurface')
await getFd('CameraManager.mp4');
mVideoConfig.url = mFdPath;
media.createVideoRecorder((err, recorder) => {
console.info(TAG + 'Entering create video receiver')
mVideoRecorder = recorder
console.info(TAG + 'videoRecorder is :' + JSON.stringify(mVideoRecorder))
console.info(TAG + 'videoRecorder.prepare called.')
mVideoRecorder.prepare(mVideoConfig, (err) => {
console.info(TAG + 'videoRecorder.prepare success.')
mVideoRecorder.getInputSurface((err, id) => {
console.info(TAG + 'getInputSurface called')
mVideoSurface = id
console.info(TAG + 'getInputSurface surfaceId: ' + JSON.stringify(mVideoSurface))
if (!err) {
console.info(TAG + 'Entering create video receiver')
mVideoRecorder = recorder
console.info(TAG + 'videoRecorder is :' + JSON.stringify(mVideoRecorder))
console.info(TAG + 'videoRecorder.prepare called.')
mVideoRecorder.prepare(mVideoConfig, (err) => {
if (!err) {
console.info(TAG + 'videoRecorder.prepare success.')
mVideoRecorder.getInputSurface((err, id) => {
console.info(TAG + 'getInputSurface called')
if (!err) {
mVideoSurface = id
console.info(TAG + 'getInputSurface surfaceId: ' + JSON.stringify(mVideoSurface))
} else {
console.info(TAG + 'getInputSurface FAILED')
}
})
} else {
console.info(TAG + 'prepare FAILED')
}
})
})
} else {
console.info(TAG + 'createVideoRecorder FAILED')
}
})
console.log(TAG + 'Exit getVideoReceiveSurface')
}
......@@ -218,7 +230,7 @@ export default function cameraManagerTest(surfaceId: any) {
let permissionName3 = 'ohos.permission.MEDIA_LOCATION';
let permissionName4 = 'ohos.permission.READ_MEDIA';
let permissionName5 = 'ohos.permission.WRITE_MEDIA';
let permissionName6 = 'ohos.permission.START_ABILITIES_FROM_BACKGROUND';
let permissionName6 = 'ohos.permission.START_ABILIIES_FROM_BACKGROUND';
let permissionName7 = 'ohos.permission.START_INVISIBLE_ABILITY';
let permissionName8 = 'ohos.permission.ABILITY_BACKGROUND_COMMUNICATION';
await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册