From 2a98d17e896bdff38dd60c3a99a03114bfbedf5a Mon Sep 17 00:00:00 2001 From: fulizhong Date: Tue, 25 Oct 2022 17:25:16 +0800 Subject: [PATCH] modify testcases Signed-off-by: FULIZHONG Signed-off-by: fulizhong --- multimedia/BUILD.gn | 1 + .../VideoRecorderTestBase.js | 66 ++- .../test/VideoRecorderAPICallbackTest.test.js | 46 +- .../VideoRecorderFuncCallbackTest.test.js | 98 ++-- .../test/VideoRecorderFuncPromiseTest.test.js | 436 ++++++++---------- 5 files changed, 336 insertions(+), 311 deletions(-) diff --git a/multimedia/BUILD.gn b/multimedia/BUILD.gn index a5eb9e858..29d50da35 100644 --- a/multimedia/BUILD.gn +++ b/multimedia/BUILD.gn @@ -45,6 +45,7 @@ group("multimedia") { "media/media_js_standard/audioRecorder:audio_recorder_js_hap", "media/media_js_standard/recorderFormat:recorder_format_js_hap", "media/media_js_standard/videoPlayer:video_player_js_hap", + "media/media_js_standard/videoRecorder:video_recorder_js_hap", "medialibrary/mediaLibrary_album:mediaLibrary_album_hap", "medialibrary/mediaLibrary_base:mediaLibrary_base_hap", "medialibrary/mediaLibrary_favorite:mediaLibrary_favorite_hap", diff --git a/multimedia/media/media_js_standard/VideoRecorderTestBase.js b/multimedia/media/media_js_standard/VideoRecorderTestBase.js index 67ee6ffd8..f2eaaf5aa 100644 --- a/multimedia/media/media_js_standard/VideoRecorderTestBase.js +++ b/multimedia/media/media_js_standard/VideoRecorderTestBase.js @@ -27,48 +27,72 @@ const BITRATE_DELTA_TIME = 20000; const PLAY_TIME = 1000; -export async function initCaptureSession(videoOutPut, cameraManager, cameras, cameraID) { - let cameraInput = await cameraManager.createCameraInput(cameras[cameraID].cameraId); +export async function initCaptureSession(videoOutPut, cameraManager, cameraDevice, previewOutput) { + let cameraInput = await cameraManager.createCameraInput(cameraDevice); if (cameraInput != null) { console.info('[camera] case createCameraInput success'); } else { console.info('[camera] case createCameraInput failed'); return; } - let captureSession = await camera.createCaptureSession(null); + await cameraInput.open((err) => { + if(err){ + console.info('[camera] cameraInput open Failed'); + return + } + console.info('[camera] cameraInput open success'); + }) + let captureSession = await cameraManager.createCaptureSession(); await captureSession.beginConfig(); await captureSession.addInput(cameraInput); + await captureSession.addOutput(previewOutput); await captureSession.addOutput(videoOutPut); await captureSession.commitConfig(); + await captureSession.start(); return captureSession; } export async function stopCaptureSession(captureSession) { - await captureSession.release(); + await captureSession.stop().then(() => { + console.info('[camera] case captureSession stop success'); + }); + await captureSession.release().then(() => { + console.info('[camera] case captureSession release success'); + }); } -export function getTrackArray(videoType, recorderConfigFile) { +export function getTrackArray(videoType, recorderConfigFile, sourceType) { if (videoType == AUDIO_VIDEO_TYPE) { let audioTrack = new Array(recorderConfigFile.audioBitrate, recorderConfigFile.audioChannels, 'audio/mpeg', recorderConfigFile.audioSampleRate); let videoTrack = null; - if (recorderConfigFile.videoCodec == 'video/avc') { + if (sourceType == media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_ES) { videoTrack = new Array('video/x-h264', recorderConfigFile.videoFrameHeight, recorderConfigFile.videoFrameWidth); } else { - videoTrack = new Array('video/mpeg', recorderConfigFile.videoFrameHeight, - recorderConfigFile.videoFrameWidth); + if (recorderConfigFile.videoCodec == 'video/avc') { + videoTrack = new Array('video/x-h264', recorderConfigFile.videoFrameHeight, + recorderConfigFile.videoFrameWidth); + } else { + videoTrack = new Array('video/mpeg', recorderConfigFile.videoFrameHeight, + recorderConfigFile.videoFrameWidth); + } } let trackArray = new Array(videoTrack, audioTrack); return trackArray; } else if (videoType == ONLYVIDEO_TYPE) { let videoTrack = null; - if (recorderConfigFile.videoCodec == 'video/avc') { + if (sourceType == media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_ES) { videoTrack = new Array('video/x-h264', recorderConfigFile.videoFrameHeight, recorderConfigFile.videoFrameWidth); } else { - videoTrack = new Array('video/mpeg', recorderConfigFile.videoFrameHeight, - recorderConfigFile.videoFrameWidth); + if (recorderConfigFile.videoCodec == 'video/avc') { + videoTrack = new Array('video/x-h264', recorderConfigFile.videoFrameHeight, + recorderConfigFile.videoFrameWidth); + } else { + videoTrack = new Array('video/mpeg', recorderConfigFile.videoFrameHeight, + recorderConfigFile.videoFrameWidth); + } } let trackArray = new Array(videoTrack); return trackArray; @@ -115,6 +139,12 @@ export async function checkVideos(playFdPath, duration, trackArray, playerSurfac }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); console.info('[checkVideos] case checkVideos fdPath is :' + playFdPath); + videoPlayer.on('error', (error) => { + console.info(`case error called,errMessage is ${error.message}`); + expect().assertFail(); + return; + }); + videoPlayer.url = playFdPath; let tarckType = undefined; if (playerSurfaceId != null) { @@ -141,20 +171,6 @@ export async function checkVideos(playFdPath, duration, trackArray, playerSurfac expect().assertFail(); } }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - - let startTime = videoPlayer.currentTime; - await videoPlayer.play().then(() => { - console.info('case play called!!'); - mediaTestBase.msleep(PLAY_TIME); - expect(videoPlayer.state).assertEqual('playing'); - }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - let endTime = videoPlayer.currentTime; - expect(Math.abs(endTime - startTime - PLAY_TIME)).assertLess(DELTA_TIME); - - await videoPlayer.stop().then(() => { - console.info('case stop called!!'); - expect(videoPlayer.state).assertEqual('stopped'); - }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); await videoPlayer.release().then(() => { console.info('case release called!!'); diff --git a/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderAPICallbackTest.test.js b/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderAPICallbackTest.test.js index b88425eae..7066a73d3 100644 --- a/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderAPICallbackTest.test.js +++ b/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderAPICallbackTest.test.js @@ -43,6 +43,13 @@ describe('VideoRecorderAPICallbackTest', function () { let fdPath; let fdObject; let cameraID = 0; + let playerSurfaceId = ''; + let pageId = 0; + let videoProfiles; + let previewProfiles; + let previewOutput; + const pagePath1 = 'pages/surfaceTest/surfaceTest'; + const pagePath2 = 'pages/surfaceTest2/surfaceTest2'; let events = require('events'); let eventEmitter = new events.EventEmitter(); @@ -79,19 +86,42 @@ describe('VideoRecorderAPICallbackTest', function () { console.info('[camera] case getCameraManager failed'); return; } - cameras = await cameraManager.getCameras(); + await cameraManager.getSupportedCameras().then((cameraDevices)=> { + cameras = cameraDevices; + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); if (cameras != null) { console.info('[camera] case getCameras success'); } else { console.info('[camera] case getCameras failed'); } + await cameraManager.getSupportedOutputCapability(cameras[0]).then((cameraoutputcapability) => { + console.info('[camera] case getSupportedOutputCapability success'); + videoProfiles = cameraoutputcapability.videoProfiles; + videoProfiles[0].size.height = 480; + videoProfiles[0].size.width = 640; + previewProfiles = cameraoutputcapability.previewProfiles; + previewProfiles[0].size.height = 480; + previewProfiles[0].size.width = 640; + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback) + if (previewProfiles[0].format == camera.CameraFormat.CAMERA_FORMAT_YUV_420_SP) { + console.info('[camera] case format is VIDEO_SOURCE_TYPE_SURFACE_YUV'); + videoConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV; + } else { + console.info('[camera] case format is VIDEO_SOURCE_TYPE_SURFACE_ES'); + videoConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_ES; + } fdObject = await mediaTestBase.getFd('recorder_callback_api.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; console.info('beforeAll case'); }) - beforeEach(function () { + beforeEach(async function () { + await mediaTestBase.toNewPage(pagePath1, pagePath2, pageId); + pageId = (pageId + 1) % 2; + await mediaTestBase.msleepAsync(1000).then( + () => {}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + playerSurfaceId = globalThis.value; surfaceID = null; console.info('beforeEach case'); }) @@ -101,7 +131,7 @@ describe('VideoRecorderAPICallbackTest', function () { }) afterAll(async function () { - await mediaTestBase.closeFd(); + await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber); console.info('afterAll case'); }) @@ -123,13 +153,15 @@ describe('VideoRecorderAPICallbackTest', function () { eventEmitter.on(START_STREEAM, async (videoRecorder, steps, done) => { steps.shift(); - videoOutput = await camera.createVideoOutput(surfaceID); + videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); if (videoOutput == null) { console.info('[camera] case createVideoOutput failed'); } else { console.info('[camera] case createVideoOutput success'); } - captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID); + previewOutput = await cameraManager.createPreviewOutput(previewProfiles[0], playerSurfaceId) + captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, + cameras[0], previewOutput); await videoOutput.start().then(() => { console.info('[camera] case videoOutput start success'); }); @@ -141,10 +173,6 @@ describe('VideoRecorderAPICallbackTest', function () { await videoOutput.stop().then(() => { console.info('[camera] case videoOutput stop success'); }); - await videoOutput.release().then(() => { - console.info('[camera] case videoOutput release success'); - }); - videoOutput = undefined; await videoRecorderBase.stopCaptureSession(captureSession); toNextStep(videoRecorder, steps, done); }); diff --git a/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncCallbackTest.test.js b/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncCallbackTest.test.js index 02ca9ddc8..fc5f5708a 100644 --- a/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncCallbackTest.test.js +++ b/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncCallbackTest.test.js @@ -48,6 +48,9 @@ describe('VideoRecorderFuncCallbackTest', function () { let fdObject; let cameraID = 0; let pageId = 0; + let videoProfiles; + let previewProfiles; + let previewOutput; let configFile = { audioBitrate : 48000, audioChannels : 2, @@ -101,18 +104,48 @@ describe('VideoRecorderFuncCallbackTest', function () { console.info('[camera] case getCameraManager failed'); return; } - cameras = await cameraManager.getCameras(); + await cameraManager.getSupportedCameras().then((cameraDevices)=> { + cameras = cameraDevices; + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); if (cameras != null) { console.info('[camera] case getCameras success'); } else { console.info('[camera] case getCameras failed'); } + await cameraManager.getSupportedOutputCapability(cameras[0]).then((cameraoutputcapability) => { + console.info('[camera] case getSupportedOutputCapability success'); + videoProfiles = cameraoutputcapability.videoProfiles; + videoProfiles[0].size.height = 480; + videoProfiles[0].size.width = 640; + previewProfiles = cameraoutputcapability.previewProfiles; + previewProfiles[0].size.height = 480; + previewProfiles[0].size.width = 640; + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback) + if (previewProfiles[0].format == camera.CameraFormat.CAMERA_FORMAT_YUV_420_SP) { + console.info('[camera] case format is VIDEO_SOURCE_TYPE_SURFACE_YUV'); + videoConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV; + } else { + console.info('[camera] case format is VIDEO_SOURCE_TYPE_SURFACE_ES'); + videoConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_ES; + } console.info('beforeAll case'); }) beforeEach(async function () { await mediaTestBase.toNewPage(pagePath1, pagePath2, pageId); pageId = (pageId + 1) % 2; + if (previewProfiles[0].format == camera.CameraFormat.CAMERA_FORMAT_YUV_420_SP) { + if (pageId == 0) { + configFile.videoCodec = media.CodecMimeType.VIDEO_MPEG4; + onlyVideoProfile.videoCodec = media.CodecMimeType.VIDEO_MPEG4; + } else { + configFile.videoCodec = media.CodecMimeType.VIDEO_AVC; + onlyVideoProfile.videoCodec = media.CodecMimeType.VIDEO_AVC; + } + } else { + configFile.videoCodec = media.CodecMimeType.VIDEO_MPEG4; + onlyVideoProfile.videoCodec = media.CodecMimeType.VIDEO_MPEG4; + } await mediaTestBase.msleepAsync(1000).then( () => {}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); playerSurfaceId = globalThis.value; @@ -218,13 +251,15 @@ describe('VideoRecorderFuncCallbackTest', function () { eventEmitter.on(START_EVENT, async (videoRecorder, steps, done) => { steps.shift(); - videoOutput = await camera.createVideoOutput(surfaceID); + videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); if (videoOutput == null) { console.info('case createVideoOutput failed'); } else { console.info('case createVideoOutput success'); } - captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID); + previewOutput = await cameraManager.createPreviewOutput(previewProfiles[0], playerSurfaceId) + captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, + cameras[0], previewOutput); await videoOutput.start().then(() => { console.info('case videoOutput start success'); }); @@ -300,10 +335,6 @@ describe('VideoRecorderFuncCallbackTest', function () { await videoOutput.stop().then(() => { console.info('case videoOutput stop success'); }); - await videoOutput.release().then(() => { - console.info('case videoOutput release success'); - }); - videoOutput = undefined; await videoRecorderBase.stopCaptureSession(captureSession); if (typeof (err) == 'undefined') { expect(videoRecorder.state).assertEqual('idle'); @@ -337,7 +368,7 @@ describe('VideoRecorderFuncCallbackTest', function () { fdObject = await mediaTestBase.getFd('recorder_callback_01.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); let videoRecorder = null; let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT); @@ -356,7 +387,7 @@ describe('VideoRecorderFuncCallbackTest', function () { fdObject = await mediaTestBase.getFd('recorder_callback_02.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); let videoRecorder = null; let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, PAUSE_EVENT, RELEASE_EVENT, CHECK_EVENT, @@ -376,7 +407,7 @@ describe('VideoRecorderFuncCallbackTest', function () { fdObject = await mediaTestBase.getFd('recorder_callback_03.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); let videoRecorder = null; let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, PAUSE_EVENT, RESUME_EVENT, RELEASE_EVENT, CHECK_EVENT, @@ -396,7 +427,7 @@ describe('VideoRecorderFuncCallbackTest', function () { fdObject = await mediaTestBase.getFd('recorder_callback_04.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); let videoRecorder = null; let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, STOP_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT); @@ -415,7 +446,7 @@ describe('VideoRecorderFuncCallbackTest', function () { fdObject = await mediaTestBase.getFd('recorder_callback_05.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); let videoRecorder = null; let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, RESET_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT); @@ -434,7 +465,7 @@ describe('VideoRecorderFuncCallbackTest', function () { fdObject = await mediaTestBase.getFd('recorder_callback_06.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); let videoRecorder = null; let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, PAUSE_EVENT, STOP_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT); @@ -453,7 +484,7 @@ describe('VideoRecorderFuncCallbackTest', function () { fdObject = await mediaTestBase.getFd('recorder_callback_07.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); let videoRecorder = null; let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, PAUSE_EVENT, RESET_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT); @@ -472,7 +503,7 @@ describe('VideoRecorderFuncCallbackTest', function () { fdObject = await mediaTestBase.getFd('recorder_callback_08.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); let videoRecorder = null; let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, PAUSE_EVENT, RESUME_EVENT, STOP_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME * 2, END_EVENT); @@ -491,7 +522,7 @@ describe('VideoRecorderFuncCallbackTest', function () { fdObject = await mediaTestBase.getFd('recorder_callback_09.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); let videoRecorder = null; let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, PAUSE_EVENT, RESUME_EVENT, RESET_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME * 2, END_EVENT); @@ -514,7 +545,7 @@ describe('VideoRecorderFuncCallbackTest', function () { fdObject = await mediaTestBase.getFd('recorder_callback_10.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); let videoRecorder = null; let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, STOP_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT); @@ -537,7 +568,7 @@ describe('VideoRecorderFuncCallbackTest', function () { fdObject = await mediaTestBase.getFd('recorder_callback_11.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); let videoRecorder = null; let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, STOP_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT); @@ -560,7 +591,7 @@ describe('VideoRecorderFuncCallbackTest', function () { fdObject = await mediaTestBase.getFd('recorder_callback_12.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); let videoRecorder = null; let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, STOP_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT); @@ -583,7 +614,7 @@ describe('VideoRecorderFuncCallbackTest', function () { fdObject = await mediaTestBase.getFd('recorder_callback_13.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); let videoRecorder = null; let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, STOP_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT); @@ -602,7 +633,8 @@ describe('VideoRecorderFuncCallbackTest', function () { fdObject = await mediaTestBase.getFd('recorder_callback_14.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); onlyVideoConfig.url = fdPath; - let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile); + let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile, + onlyVideoConfig.videoSourceType); let videoRecorder = null; let mySteps = new Array(CREATE_EVENT, PREPARE_OLNYVIDEO_EVENT, GETSURFACE_EVENT, START_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT); @@ -621,7 +653,8 @@ describe('VideoRecorderFuncCallbackTest', function () { fdObject = await mediaTestBase.getFd('recorder_callback_15.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); onlyVideoConfig.url = fdPath; - let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile); + let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile, + onlyVideoConfig.videoSourceType); let videoRecorder = null; let mySteps = new Array(CREATE_EVENT, PREPARE_OLNYVIDEO_EVENT, GETSURFACE_EVENT, START_EVENT, PAUSE_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT); @@ -640,7 +673,8 @@ describe('VideoRecorderFuncCallbackTest', function () { fdObject = await mediaTestBase.getFd('recorder_callback_16.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); onlyVideoConfig.url = fdPath; - let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile); + let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile, + onlyVideoConfig.videoSourceType); let videoRecorder = null; let mySteps = new Array(CREATE_EVENT, PREPARE_OLNYVIDEO_EVENT, GETSURFACE_EVENT, START_EVENT, PAUSE_EVENT, RESUME_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME * 2, END_EVENT); @@ -659,7 +693,8 @@ describe('VideoRecorderFuncCallbackTest', function () { fdObject = await mediaTestBase.getFd('recorder_callback_17.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); onlyVideoConfig.url = fdPath; - let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile); + let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile, + onlyVideoConfig.videoSourceType); let videoRecorder = null; let mySteps = new Array(CREATE_EVENT, PREPARE_OLNYVIDEO_EVENT, GETSURFACE_EVENT, START_EVENT, STOP_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT); @@ -678,7 +713,8 @@ describe('VideoRecorderFuncCallbackTest', function () { fdObject = await mediaTestBase.getFd('recorder_callback_18.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); onlyVideoConfig.url = fdPath; - let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile); + let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile, + onlyVideoConfig.videoSourceType); let videoRecorder = null; let mySteps = new Array(CREATE_EVENT, PREPARE_OLNYVIDEO_EVENT, GETSURFACE_EVENT, START_EVENT, RESET_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT); @@ -699,7 +735,7 @@ describe('VideoRecorderFuncCallbackTest', function () { videoConfig.url = fdPath; configFile.audioSampleRate = 48000; videoConfig.rotation = 90; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); let videoRecorder = null; let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT); @@ -719,7 +755,7 @@ describe('VideoRecorderFuncCallbackTest', function () { fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; videoConfig.rotation = 180; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); let videoRecorder = null; let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT); @@ -739,7 +775,7 @@ describe('VideoRecorderFuncCallbackTest', function () { fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; videoConfig.rotation = 270; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); let videoRecorder = null; let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT); @@ -759,7 +795,7 @@ describe('VideoRecorderFuncCallbackTest', function () { fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; configFile.videoFrameRate = 20; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); let videoRecorder = null; let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT); @@ -779,7 +815,7 @@ describe('VideoRecorderFuncCallbackTest', function () { fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; configFile.videoFrameRate = 30; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); let videoRecorder = null; let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT); @@ -799,7 +835,7 @@ describe('VideoRecorderFuncCallbackTest', function () { fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; configFile.videoFrameRate = 60; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); let videoRecorder = null; let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT); diff --git a/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncPromiseTest.test.js b/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncPromiseTest.test.js index e4759a863..af15ee910 100644 --- a/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncPromiseTest.test.js +++ b/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncPromiseTest.test.js @@ -32,6 +32,8 @@ describe('VideoRecorderFuncPromiseTest', function () { let cameraID = 0; let playerSurfaceId = ''; let pageId = 0; + let videoProfiles; + let previewProfiles; const pagePath1 = 'pages/surfaceTest/surfaceTest'; const pagePath2 = 'pages/surfaceTest2/surfaceTest2'; let configFile = { @@ -50,7 +52,7 @@ describe('VideoRecorderFuncPromiseTest', function () { let videoConfig = { audioSourceType : 1, - videoSourceType : 0, + videoSourceType : media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_ES, profile : configFile, url : 'fd://', rotation : 0, @@ -70,7 +72,7 @@ describe('VideoRecorderFuncPromiseTest', function () { } let onlyVideoConfig = { - videoSourceType : media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV, + videoSourceType : media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_ES, profile : onlyVideoProfile, url : 'fd://', rotation : 0, @@ -87,18 +89,50 @@ describe('VideoRecorderFuncPromiseTest', function () { console.info('[camera] case getCameraManager failed'); return; } - cameras = await cameraManager.getCameras(); + await cameraManager.getSupportedCameras().then((cameraDevices)=> { + cameras = cameraDevices; + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); if (cameras != null) { console.info('[camera] case getCameras success'); } else { console.info('[camera] case getCameras failed'); } + await cameraManager.getSupportedOutputCapability(cameras[0]).then((cameraoutputcapability) => { + console.info('[camera] case getSupportedOutputCapability success'); + videoProfiles = cameraoutputcapability.videoProfiles; + videoProfiles[0].size.height = 480; + videoProfiles[0].size.width = 640; + previewProfiles = cameraoutputcapability.previewProfiles; + previewProfiles[0].size.height = 480; + previewProfiles[0].size.width = 640; + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback) + if (previewProfiles[0].format == camera.CameraFormat.CAMERA_FORMAT_YUV_420_SP) { + console.info('[camera] case format is VIDEO_SOURCE_TYPE_SURFACE_YUV'); + videoConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV; + onlyVideoConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV; + } else { + console.info('[camera] case format is VIDEO_SOURCE_TYPE_SURFACE_ES'); + videoConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_ES; + onlyVideoConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_ES; + } console.info('beforeAll case'); }) beforeEach(async function () { await mediaTestBase.toNewPage(pagePath1, pagePath2, pageId); pageId = (pageId + 1) % 2; + if (previewProfiles[0].format == camera.CameraFormat.CAMERA_FORMAT_YUV_420_SP) { + if (pageId == 0) { + configFile.videoCodec = media.CodecMimeType.VIDEO_MPEG4; + onlyVideoProfile.videoCodec = media.CodecMimeType.VIDEO_MPEG4; + } else { + configFile.videoCodec = media.CodecMimeType.VIDEO_AVC; + onlyVideoProfile.videoCodec = media.CodecMimeType.VIDEO_AVC; + } + } else { + configFile.videoCodec = media.CodecMimeType.VIDEO_MPEG4; + onlyVideoProfile.videoCodec = media.CodecMimeType.VIDEO_MPEG4; + } await mediaTestBase.msleepAsync(1000).then( () => {}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); playerSurfaceId = globalThis.value; @@ -125,80 +159,9 @@ describe('VideoRecorderFuncPromiseTest', function () { }); } - /* * - * @tc.number : SUB_MULTIMEDIA_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_ALL_CAMERAS_0100 - * @tc.name : 01.all cameras recordering (promise) - * @tc.desc : Video recordr control test - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level0 - */ - it('SUB_MULTIMEDIA_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_ALL_CAMERAS_0100', 0, async function (done) { - for (let i = 0; i < 2; i++) { - cameraID = i; - console.info('[camera] case cameraID is :' + cameraID); - let videoRecorder = undefined; - let surfaceID = ''; - let videoOutput; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); - fdObject = await mediaTestBase.getFd('recorder_promise_cameraID_' + cameraID + '.mp4'); - fdPath = "fd://" + fdObject.fdNumber.toString(); - videoConfig.url = fdPath; - await media.createVideoRecorder().then((recorder) => { - console.info('case createVideoRecorder called'); - if (typeof (recorder) != 'undefined') { - videoRecorder = recorder; - expect(videoRecorder.state).assertEqual('idle'); - } else { - console.info('case recordr is undefined!!'); - expect().assertFail(); - } - }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - - await videoRecorder.prepare(videoConfig).then(() => { - console.info('case prepare called'); - expect(videoRecorder.state).assertEqual('prepared'); - }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - - await videoRecorder.getInputSurface().then((outPutSurface) => { - console.info('case getInputSurface called'); - surfaceID = outPutSurface; - }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - - videoOutput = await camera.createVideoOutput(surfaceID); - captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID); - await startVideoOutput(videoOutput); - - await videoRecorder.start().then(() => { - expect(videoRecorder.state).assertEqual('playing'); - console.info('case start called'); - mediaTestBase.msleep(RECORDER_TIME); - }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - - await videoRecorder.stop().then(() => { - expect(videoRecorder.state).assertEqual('stopped'); - console.info('case stop called'); - }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - - await videoRecorder.release().then(() => { - expect(videoRecorder.state).assertEqual('idle'); - console.info('case release '); - }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - await videoOutput.stop(); - await videoOutput.release().then(() => { - console.info('[camera] case videoOutput release success'); - }); - videoOutput = undefined; - await videoRecorderBase.stopCaptureSession(captureSession); - await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId); - await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber); - } - done(); - }) - /* * * @tc.number : SUB_MULTIMEDIA_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_0100 - * @tc.name : 02.start->release (promise) + * @tc.name : 01.start->release (promise) * @tc.desc : Video recordr control test * @tc.size : MediumTest * @tc.type : Function @@ -208,7 +171,8 @@ describe('VideoRecorderFuncPromiseTest', function () { let videoRecorder = undefined; let surfaceID = ''; let videoOutput; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let previewOutput; + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); fdObject = await mediaTestBase.getFd('recorder_promise_01.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; @@ -232,8 +196,11 @@ describe('VideoRecorderFuncPromiseTest', function () { expect(videoRecorder.state).assertEqual('prepared'); surfaceID = outPutSurface; }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - videoOutput = await camera.createVideoOutput(surfaceID); - captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID); + + videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); + previewOutput = await cameraManager.createPreviewOutput(previewProfiles[0], playerSurfaceId) + captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, + cameras[0], previewOutput); await startVideoOutput(videoOutput); await videoRecorder.start().then(() => { console.info('case start called'); @@ -246,10 +213,6 @@ describe('VideoRecorderFuncPromiseTest', function () { expect(videoRecorder.state).assertEqual('idle'); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); await videoOutput.stop(); - await videoOutput.release().then(() => { - console.info('[camera] case videoOutput release success'); - }); - videoOutput = undefined; await videoRecorderBase.stopCaptureSession(captureSession); await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId); await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber); @@ -268,7 +231,8 @@ describe('VideoRecorderFuncPromiseTest', function () { let videoRecorder = undefined; let surfaceID = ''; let videoOutput; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let previewOutput; + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); fdObject = await mediaTestBase.getFd('recorder_promise_02.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; @@ -292,8 +256,10 @@ describe('VideoRecorderFuncPromiseTest', function () { expect(videoRecorder.state).assertEqual('prepared'); surfaceID = outPutSurface; }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - videoOutput = await camera.createVideoOutput(surfaceID); - captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID); + videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); + previewOutput = await cameraManager.createPreviewOutput(previewProfiles[0], playerSurfaceId) + captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, + cameras[0], previewOutput); await startVideoOutput(videoOutput); await videoRecorder.start().then(() => { console.info('case start called'); @@ -311,10 +277,6 @@ describe('VideoRecorderFuncPromiseTest', function () { expect(videoRecorder.state).assertEqual('idle'); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); await videoOutput.stop(); - await videoOutput.release().then(() => { - console.info('[camera] case videoOutput release success'); - }); - videoOutput = undefined; await videoRecorderBase.stopCaptureSession(captureSession); await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId); await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber); @@ -333,7 +295,8 @@ describe('VideoRecorderFuncPromiseTest', function () { let videoRecorder = undefined; let surfaceID = ''; let videoOutput; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let previewOutput; + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); fdObject = await mediaTestBase.getFd('recorder_promise_03.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; @@ -357,8 +320,10 @@ describe('VideoRecorderFuncPromiseTest', function () { console.info('case getInputSurface called'); surfaceID = outPutSurface; }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - videoOutput = await camera.createVideoOutput(surfaceID); - captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID); + videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); + previewOutput = await cameraManager.createPreviewOutput(previewProfiles[0], playerSurfaceId) + captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, + cameras[0], previewOutput); await startVideoOutput(videoOutput); await videoRecorder.start().then(() => { expect(videoRecorder.state).assertEqual('playing'); @@ -385,10 +350,6 @@ describe('VideoRecorderFuncPromiseTest', function () { console.info('case release '); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); await videoOutput.stop(); - await videoOutput.release().then(() => { - console.info('[camera] case videoOutput release success'); - }); - videoOutput = undefined; await videoRecorderBase.stopCaptureSession(captureSession); await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME * 2, trackArray, playerSurfaceId); await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber); @@ -407,7 +368,8 @@ describe('VideoRecorderFuncPromiseTest', function () { let videoRecorder = undefined; let surfaceID = ''; let videoOutput; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let previewOutput; + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); fdObject = await mediaTestBase.getFd('recorder_promise_04.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; @@ -431,8 +393,10 @@ describe('VideoRecorderFuncPromiseTest', function () { expect(videoRecorder.state).assertEqual('prepared'); surfaceID = outPutSurface; }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - videoOutput = await camera.createVideoOutput(surfaceID); - captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID); + videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); + previewOutput = await cameraManager.createPreviewOutput(previewProfiles[0], playerSurfaceId); + captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, + cameras[0], previewOutput); await startVideoOutput(videoOutput); await videoRecorder.start().then(() => { console.info('case start called'); @@ -444,15 +408,11 @@ describe('VideoRecorderFuncPromiseTest', function () { expect(videoRecorder.state).assertEqual('stopped'); console.info('case stop called'); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - await videoOutput.stop(); await videoRecorder.release().then(() => { expect(videoRecorder.state).assertEqual('idle'); console.info('case release '); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - await videoOutput.release().then(() => { - console.info('[camera] case videoOutput release success'); - }); - videoOutput = undefined; + await videoOutput.stop(); await videoRecorderBase.stopCaptureSession(captureSession); await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId); await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber); @@ -471,7 +431,8 @@ describe('VideoRecorderFuncPromiseTest', function () { let videoRecorder = undefined; let surfaceID = ''; let videoOutput; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let previewOutput; + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); fdObject = await mediaTestBase.getFd('recorder_promise_05.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; @@ -495,8 +456,10 @@ describe('VideoRecorderFuncPromiseTest', function () { console.info('case getInputSurface called'); surfaceID = outPutSurface; }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - videoOutput = await camera.createVideoOutput(surfaceID); - captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID); + videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); + previewOutput = await cameraManager.createPreviewOutput(previewProfiles[0], playerSurfaceId) + captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, + cameras[0], previewOutput); await startVideoOutput(videoOutput); await videoRecorder.start().then(() => { console.info('case start called'); @@ -508,15 +471,11 @@ describe('VideoRecorderFuncPromiseTest', function () { console.info('case reset called'); expect(videoRecorder.state).assertEqual('idle'); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - await videoOutput.stop(); await videoRecorder.release().then(() => { expect(videoRecorder.state).assertEqual('idle'); console.info('case release '); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - await videoOutput.release().then(() => { - console.info('[camera] case videoOutput release success'); - }); - videoOutput = undefined; + await videoOutput.stop(); await videoRecorderBase.stopCaptureSession(captureSession); await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId); await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber); @@ -535,7 +494,8 @@ describe('VideoRecorderFuncPromiseTest', function () { let videoRecorder = undefined; let surfaceID = ''; let videoOutput; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let previewOutput; + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); fdObject = await mediaTestBase.getFd('recorder_promise_06.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; @@ -559,8 +519,10 @@ describe('VideoRecorderFuncPromiseTest', function () { console.info('case getInputSurface called'); surfaceID = outPutSurface; }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - videoOutput = await camera.createVideoOutput(surfaceID); - captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID); + videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); + previewOutput = await cameraManager.createPreviewOutput(previewProfiles[0], playerSurfaceId) + captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, + cameras[0], previewOutput); await startVideoOutput(videoOutput); await videoRecorder.start().then(() => { console.info('case start called'); @@ -584,11 +546,6 @@ describe('VideoRecorderFuncPromiseTest', function () { expect(videoRecorder.state).assertEqual('idle'); console.info('case release '); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - - await videoOutput.release().then(() => { - console.info('[camera] case videoOutput release success'); - }); - videoOutput = undefined; await videoRecorderBase.stopCaptureSession(captureSession); await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId); await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber); @@ -607,7 +564,8 @@ describe('VideoRecorderFuncPromiseTest', function () { let videoRecorder = undefined; let surfaceID = ''; let videoOutput; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let previewOutput; + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); fdObject = await mediaTestBase.getFd('recorder_promise_07.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; @@ -631,8 +589,10 @@ describe('VideoRecorderFuncPromiseTest', function () { console.info('case getInputSurface called'); surfaceID = outPutSurface; }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - videoOutput = await camera.createVideoOutput(surfaceID); - captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID); + videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); + previewOutput = await cameraManager.createPreviewOutput(previewProfiles[0], playerSurfaceId) + captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, + cameras[0], previewOutput); await startVideoOutput(videoOutput); await videoRecorder.start().then(() => { console.info('case start called'); @@ -656,10 +616,6 @@ describe('VideoRecorderFuncPromiseTest', function () { expect(videoRecorder.state).assertEqual('idle'); console.info('case release '); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - await videoOutput.release().then(() => { - console.info('[camera] case videoOutput release success'); - }); - videoOutput = undefined; await videoRecorderBase.stopCaptureSession(captureSession); await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId); await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber); @@ -678,7 +634,8 @@ describe('VideoRecorderFuncPromiseTest', function () { let videoRecorder = undefined; let surfaceID = ''; let videoOutput; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let previewOutput; + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); fdObject = await mediaTestBase.getFd('recorder_promise_08.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; @@ -702,8 +659,10 @@ describe('VideoRecorderFuncPromiseTest', function () { console.info('case getInputSurface called'); surfaceID = outPutSurface; }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - videoOutput = await camera.createVideoOutput(surfaceID); - captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID); + videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); + previewOutput = await cameraManager.createPreviewOutput(previewProfiles[0], playerSurfaceId) + captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, + cameras[0], previewOutput); await startVideoOutput(videoOutput); await videoRecorder.start().then(() => { console.info('case start called'); @@ -735,10 +694,6 @@ describe('VideoRecorderFuncPromiseTest', function () { console.info('case release '); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); await videoOutput.stop(); - await videoOutput.release().then(() => { - console.info('[camera] case videoOutput release success'); - }); - videoOutput = undefined; await videoRecorderBase.stopCaptureSession(captureSession); await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME * 2, trackArray, playerSurfaceId); await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber); @@ -757,7 +712,8 @@ describe('VideoRecorderFuncPromiseTest', function () { let videoRecorder = undefined; let surfaceID = ''; let videoOutput; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let previewOutput; + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); fdObject = await mediaTestBase.getFd('recorder_promise_09.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; @@ -781,8 +737,10 @@ describe('VideoRecorderFuncPromiseTest', function () { console.info('case getInputSurface called'); surfaceID = outPutSurface; }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - videoOutput = await camera.createVideoOutput(surfaceID); - captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID); + videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); + previewOutput = await cameraManager.createPreviewOutput(previewProfiles[0], playerSurfaceId) + captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, + cameras[0], previewOutput); await startVideoOutput(videoOutput); await videoRecorder.start().then(() => { console.info('case start called'); @@ -813,10 +771,6 @@ describe('VideoRecorderFuncPromiseTest', function () { expect(videoRecorder.state).assertEqual('idle'); console.info('case release '); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - await videoOutput.release().then(() => { - console.info('[camera] case videoOutput release success'); - }); - videoOutput = undefined; await videoRecorderBase.stopCaptureSession(captureSession); await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME * 2, trackArray, playerSurfaceId); await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber); @@ -836,13 +790,14 @@ describe('VideoRecorderFuncPromiseTest', function () { let videoRecorder = undefined; let surfaceID = ''; let videoOutput; + let previewOutput; fdObject = await mediaTestBase.getFd('recorder_promise_10.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; configFile.audioBitrate = 8000; configFile.audioSampleRate = 8000; configFile.videoBitrate = 8000; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); if (typeof (recorder) != 'undefined') { @@ -863,8 +818,10 @@ describe('VideoRecorderFuncPromiseTest', function () { expect(videoRecorder.state).assertEqual('prepared'); surfaceID = outPutSurface; }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - videoOutput = await camera.createVideoOutput(surfaceID); - captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID); + videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); + previewOutput = await cameraManager.createPreviewOutput(previewProfiles[0], playerSurfaceId) + captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, + cameras[0], previewOutput); await startVideoOutput(videoOutput); await videoRecorder.start().then(() => { console.info('case start called'); @@ -882,10 +839,6 @@ describe('VideoRecorderFuncPromiseTest', function () { expect(videoRecorder.state).assertEqual('idle'); console.info('case release '); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - await videoOutput.release().then(() => { - console.info('[camera] case videoOutput release success'); - }); - videoOutput = undefined; await videoRecorderBase.stopCaptureSession(captureSession); await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId); await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber); @@ -905,13 +858,14 @@ describe('VideoRecorderFuncPromiseTest', function () { let videoRecorder = undefined; let surfaceID = ''; let videoOutput; + let previewOutput; fdObject = await mediaTestBase.getFd('recorder_promise_11.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; configFile.audioBitrate = 16000; configFile.audioSampleRate = 32000; configFile.videoBitrate = 16000; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); if (typeof (recorder) != 'undefined') { @@ -932,8 +886,10 @@ describe('VideoRecorderFuncPromiseTest', function () { expect(videoRecorder.state).assertEqual('prepared'); surfaceID = outPutSurface; }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - videoOutput = await camera.createVideoOutput(surfaceID); - captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID); + videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); + previewOutput = await cameraManager.createPreviewOutput(previewProfiles[0], playerSurfaceId) + captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, + cameras[0], previewOutput); await startVideoOutput(videoOutput); await videoRecorder.start().then(() => { console.info('case start called'); @@ -951,10 +907,6 @@ describe('VideoRecorderFuncPromiseTest', function () { expect(videoRecorder.state).assertEqual('idle'); console.info('case release '); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - await videoOutput.release().then(() => { - console.info('[camera] case videoOutput release success'); - }); - videoOutput = undefined; await videoRecorderBase.stopCaptureSession(captureSession); await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId); await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber); @@ -974,13 +926,14 @@ describe('VideoRecorderFuncPromiseTest', function () { let videoRecorder = undefined; let surfaceID = ''; let videoOutput; + let previewOutput; fdObject = await mediaTestBase.getFd('recorder_promise_12.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; configFile.audioBitrate = 32000; configFile.audioSampleRate = 44100; configFile.videoBitrate = 32000; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); if (typeof (recorder) != 'undefined') { @@ -1001,8 +954,10 @@ describe('VideoRecorderFuncPromiseTest', function () { expect(videoRecorder.state).assertEqual('prepared'); surfaceID = outPutSurface; }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - videoOutput = await camera.createVideoOutput(surfaceID); - captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID); + videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); + previewOutput = await cameraManager.createPreviewOutput(previewProfiles[0], playerSurfaceId) + captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, + cameras[0], previewOutput); await startVideoOutput(videoOutput); await videoRecorder.start().then(() => { console.info('case start called'); @@ -1020,10 +975,6 @@ describe('VideoRecorderFuncPromiseTest', function () { expect(videoRecorder.state).assertEqual('idle'); console.info('case release '); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - await videoOutput.release().then(() => { - console.info('[camera] case videoOutput release success'); - }); - videoOutput = undefined; await videoRecorderBase.stopCaptureSession(captureSession); await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId); await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber); @@ -1043,13 +994,14 @@ describe('VideoRecorderFuncPromiseTest', function () { let videoRecorder = undefined; let surfaceID = ''; let videoOutput; + let previewOutput; fdObject = await mediaTestBase.getFd('recorder_promise_13.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; configFile.audioBitrate = 112000; configFile.audioSampleRate = 96000; configFile.videoBitrate = 112000; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); if (typeof (recorder) != 'undefined') { @@ -1070,8 +1022,10 @@ describe('VideoRecorderFuncPromiseTest', function () { expect(videoRecorder.state).assertEqual('prepared'); surfaceID = outPutSurface; }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - videoOutput = await camera.createVideoOutput(surfaceID); - captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID); + videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); + previewOutput = await cameraManager.createPreviewOutput(previewProfiles[0], playerSurfaceId) + captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, + cameras[0], previewOutput); await startVideoOutput(videoOutput); await videoRecorder.start().then(() => { console.info('case start called'); @@ -1089,10 +1043,6 @@ describe('VideoRecorderFuncPromiseTest', function () { expect(videoRecorder.state).assertEqual('idle'); console.info('case release '); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - await videoOutput.release().then(() => { - console.info('[camera] case videoOutput release success'); - }); - videoOutput = undefined; await videoRecorderBase.stopCaptureSession(captureSession); await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId); await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber); @@ -1111,10 +1061,12 @@ describe('VideoRecorderFuncPromiseTest', function () { let videoRecorder = undefined; let surfaceID = ''; let videoOutput; + let previewOutput; fdObject = await mediaTestBase.getFd('recorder_promise_14.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); onlyVideoConfig.url = fdPath; - let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile); + let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile, + onlyVideoConfig.videoSourceType); await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); if (typeof (recorder) != 'undefined') { @@ -1134,8 +1086,10 @@ describe('VideoRecorderFuncPromiseTest', function () { await videoRecorder.getInputSurface().then((outPutSurface) => { surfaceID = outPutSurface; }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - videoOutput = await camera.createVideoOutput(surfaceID); - captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID); + videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); + previewOutput = await cameraManager.createPreviewOutput(previewProfiles[0], playerSurfaceId) + captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, + cameras[0], previewOutput); await startVideoOutput(videoOutput); await videoRecorder.start().then(() => { expect(videoRecorder.state).assertEqual('playing'); @@ -1147,10 +1101,6 @@ describe('VideoRecorderFuncPromiseTest', function () { expect(videoRecorder.state).assertEqual('idle'); console.info('case release '); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - await videoOutput.release().then(() => { - console.info('[camera] case videoOutput release success'); - }); - videoOutput = undefined; await videoRecorderBase.stopCaptureSession(captureSession); await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId); await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber); @@ -1169,10 +1119,12 @@ describe('VideoRecorderFuncPromiseTest', function () { let videoRecorder = undefined; let surfaceID = ''; let videoOutput; + let previewOutput; fdObject = await mediaTestBase.getFd('recorder_promise_15.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); onlyVideoConfig.url = fdPath; - let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile); + let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile, + onlyVideoConfig.videoSourceType); await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); if (typeof (recorder) != 'undefined') { @@ -1194,8 +1146,10 @@ describe('VideoRecorderFuncPromiseTest', function () { expect(videoRecorder.state).assertEqual('prepared'); surfaceID = outPutSurface; }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - videoOutput = await camera.createVideoOutput(surfaceID); - captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID); + videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); + previewOutput = await cameraManager.createPreviewOutput(previewProfiles[0], playerSurfaceId) + captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, + cameras[0], previewOutput); await startVideoOutput(videoOutput); await videoRecorder.start().then(() => { console.info('case start called'); @@ -1214,10 +1168,6 @@ describe('VideoRecorderFuncPromiseTest', function () { console.info('case release '); expect(videoRecorder.state).assertEqual('idle'); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - await videoOutput.release().then(() => { - console.info('[camera] case videoOutput release success'); - }); - videoOutput = undefined; await videoRecorderBase.stopCaptureSession(captureSession); await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId); await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber); @@ -1236,10 +1186,12 @@ describe('VideoRecorderFuncPromiseTest', function () { let videoRecorder = undefined; let surfaceID = ''; let videoOutput; + let previewOutput; fdObject = await mediaTestBase.getFd('recorder_promise_16.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); onlyVideoConfig.url = fdPath; - let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile); + let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile, + onlyVideoConfig.videoSourceType); await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); if (typeof (recorder) != 'undefined') { @@ -1260,8 +1212,10 @@ describe('VideoRecorderFuncPromiseTest', function () { console.info('case getInputSurface called'); surfaceID = outPutSurface; }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - videoOutput = await camera.createVideoOutput(surfaceID); - captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID); + videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); + previewOutput = await cameraManager.createPreviewOutput(previewProfiles[0], playerSurfaceId) + captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, + cameras[0], previewOutput); await startVideoOutput(videoOutput); await videoRecorder.start().then(() => { expect(videoRecorder.state).assertEqual('playing'); @@ -1287,10 +1241,6 @@ describe('VideoRecorderFuncPromiseTest', function () { expect(videoRecorder.state).assertEqual('idle'); console.info('case release '); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - await videoOutput.release().then(() => { - console.info('[camera] case videoOutput release success'); - }); - videoOutput = undefined; await videoRecorderBase.stopCaptureSession(captureSession); await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME * 2, trackArray, playerSurfaceId); await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber); @@ -1309,10 +1259,12 @@ describe('VideoRecorderFuncPromiseTest', function () { let videoRecorder = undefined; let surfaceID = ''; let videoOutput; + let previewOutput; fdObject = await mediaTestBase.getFd('recorder_promise_17.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); onlyVideoConfig.url = fdPath; - let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile); + let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile, + onlyVideoConfig.videoSourceType); await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); if (typeof (recorder) != 'undefined') { @@ -1333,8 +1285,10 @@ describe('VideoRecorderFuncPromiseTest', function () { expect(videoRecorder.state).assertEqual('prepared'); surfaceID = outPutSurface; }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - videoOutput = await camera.createVideoOutput(surfaceID); - captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID); + videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); + previewOutput = await cameraManager.createPreviewOutput(previewProfiles[0], playerSurfaceId) + captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, + cameras[0], previewOutput); await startVideoOutput(videoOutput); await videoRecorder.start().then(() => { console.info('case start called'); @@ -1351,10 +1305,6 @@ describe('VideoRecorderFuncPromiseTest', function () { expect(videoRecorder.state).assertEqual('idle'); console.info('case release '); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - await videoOutput.release().then(() => { - console.info('[camera] case videoOutput release success'); - }); - videoOutput = undefined; await videoRecorderBase.stopCaptureSession(captureSession); await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId); await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber); @@ -1373,10 +1323,12 @@ describe('VideoRecorderFuncPromiseTest', function () { let videoRecorder = undefined; let surfaceID = ''; let videoOutput; + let previewOutput; fdObject = await mediaTestBase.getFd('recorder_promise_18.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); onlyVideoConfig.url = fdPath; - let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile); + let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile, + onlyVideoConfig.videoSourceType); await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); if (typeof (recorder) != 'undefined') { @@ -1397,8 +1349,10 @@ describe('VideoRecorderFuncPromiseTest', function () { console.info('case getInputSurface called'); surfaceID = outPutSurface; }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - videoOutput = await camera.createVideoOutput(surfaceID); - captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID); + videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); + previewOutput = await cameraManager.createPreviewOutput(previewProfiles[0], playerSurfaceId) + captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, + cameras[0], previewOutput); await startVideoOutput(videoOutput); await videoRecorder.start().then(() => { console.info('case start called'); @@ -1415,10 +1369,6 @@ describe('VideoRecorderFuncPromiseTest', function () { expect(videoRecorder.state).assertEqual('idle'); console.info('case release '); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - await videoOutput.release().then(() => { - console.info('[camera] case videoOutput release success'); - }); - videoOutput = undefined; await videoRecorderBase.stopCaptureSession(captureSession); await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId); await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber); @@ -1437,12 +1387,13 @@ describe('VideoRecorderFuncPromiseTest', function () { let videoRecorder = undefined; let surfaceID = ''; let videoOutput; + let previewOutput; fdObject = await mediaTestBase.getFd('recorder_promise_19.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; configFile.audioSampleRate = 48000; videoConfig.rotation = 90; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); if (typeof (recorder) != 'undefined') { @@ -1461,8 +1412,10 @@ describe('VideoRecorderFuncPromiseTest', function () { await videoRecorder.getInputSurface().then((outPutSurface) => { surfaceID = outPutSurface; }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - videoOutput = await camera.createVideoOutput(surfaceID); - captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID); + videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); + previewOutput = await cameraManager.createPreviewOutput(previewProfiles[0], playerSurfaceId) + captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, + cameras[0], previewOutput); await startVideoOutput(videoOutput); await videoRecorder.start().then(() => { expect(videoRecorder.state).assertEqual('playing'); @@ -1474,10 +1427,6 @@ describe('VideoRecorderFuncPromiseTest', function () { expect(videoRecorder.state).assertEqual('idle'); console.info('case release '); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - await videoOutput.release().then(() => { - console.info('[camera] case videoOutput release success'); - }); - videoOutput = undefined; await videoRecorderBase.stopCaptureSession(captureSession); await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId); await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber); @@ -1496,11 +1445,12 @@ describe('VideoRecorderFuncPromiseTest', function () { let videoRecorder = undefined; let surfaceID = ''; let videoOutput; + let previewOutput; fdObject = await mediaTestBase.getFd('recorder_promise_20.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; videoConfig.rotation = 180; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); if (typeof (recorder) != 'undefined') { @@ -1519,8 +1469,10 @@ describe('VideoRecorderFuncPromiseTest', function () { await videoRecorder.getInputSurface().then((outPutSurface) => { surfaceID = outPutSurface; }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - videoOutput = await camera.createVideoOutput(surfaceID); - captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID); + videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); + previewOutput = await cameraManager.createPreviewOutput(previewProfiles[0], playerSurfaceId) + captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, + cameras[0], previewOutput); await startVideoOutput(videoOutput); await videoRecorder.start().then(() => { expect(videoRecorder.state).assertEqual('playing'); @@ -1532,10 +1484,6 @@ describe('VideoRecorderFuncPromiseTest', function () { expect(videoRecorder.state).assertEqual('idle'); console.info('case release '); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - await videoOutput.release().then(() => { - console.info('[camera] case videoOutput release success'); - }); - videoOutput = undefined; await videoRecorderBase.stopCaptureSession(captureSession); await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId); await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber); @@ -1554,11 +1502,12 @@ describe('VideoRecorderFuncPromiseTest', function () { let videoRecorder = undefined; let surfaceID = ''; let videoOutput; + let previewOutput; fdObject = await mediaTestBase.getFd('recorder_promise_21.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; videoConfig.rotation = 270; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); if (typeof (recorder) != 'undefined') { @@ -1577,8 +1526,10 @@ describe('VideoRecorderFuncPromiseTest', function () { await videoRecorder.getInputSurface().then((outPutSurface) => { surfaceID = outPutSurface; }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - videoOutput = await camera.createVideoOutput(surfaceID); - captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID); + videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); + previewOutput = await cameraManager.createPreviewOutput(previewProfiles[0], playerSurfaceId) + captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, + cameras[0], previewOutput); await startVideoOutput(videoOutput); await videoRecorder.start().then(() => { expect(videoRecorder.state).assertEqual('playing'); @@ -1590,10 +1541,6 @@ describe('VideoRecorderFuncPromiseTest', function () { expect(videoRecorder.state).assertEqual('idle'); console.info('case release '); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - await videoOutput.release().then(() => { - console.info('[camera] case videoOutput release success'); - }); - videoOutput = undefined; await videoRecorderBase.stopCaptureSession(captureSession); await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId); await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber); @@ -1612,11 +1559,12 @@ describe('VideoRecorderFuncPromiseTest', function () { let videoRecorder = undefined; let surfaceID = ''; let videoOutput; + let previewOutput; fdObject = await mediaTestBase.getFd('recorder_promise_22.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; configFile.videoFrameRate = 20; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); if (typeof (recorder) != 'undefined') { @@ -1635,8 +1583,10 @@ describe('VideoRecorderFuncPromiseTest', function () { await videoRecorder.getInputSurface().then((outPutSurface) => { surfaceID = outPutSurface; }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - videoOutput = await camera.createVideoOutput(surfaceID); - captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID); + videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); + previewOutput = await cameraManager.createPreviewOutput(previewProfiles[0], playerSurfaceId) + captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, + cameras[0], previewOutput); await startVideoOutput(videoOutput); await videoRecorder.start().then(() => { expect(videoRecorder.state).assertEqual('playing'); @@ -1648,10 +1598,6 @@ describe('VideoRecorderFuncPromiseTest', function () { expect(videoRecorder.state).assertEqual('idle'); console.info('case release '); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - await videoOutput.release().then(() => { - console.info('[camera] case videoOutput release success'); - }); - videoOutput = undefined; await videoRecorderBase.stopCaptureSession(captureSession); await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId); await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber); @@ -1670,11 +1616,12 @@ describe('VideoRecorderFuncPromiseTest', function () { let videoRecorder = undefined; let surfaceID = ''; let videoOutput; + let previewOutput; fdObject = await mediaTestBase.getFd('recorder_promise_23.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; configFile.videoFrameRate = 30; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); if (typeof (recorder) != 'undefined') { @@ -1693,8 +1640,10 @@ describe('VideoRecorderFuncPromiseTest', function () { await videoRecorder.getInputSurface().then((outPutSurface) => { surfaceID = outPutSurface; }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - videoOutput = await camera.createVideoOutput(surfaceID); - captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID); + videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); + previewOutput = await cameraManager.createPreviewOutput(previewProfiles[0], playerSurfaceId) + captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, + cameras[0], previewOutput); await startVideoOutput(videoOutput); await videoRecorder.start().then(() => { expect(videoRecorder.state).assertEqual('playing'); @@ -1706,10 +1655,6 @@ describe('VideoRecorderFuncPromiseTest', function () { expect(videoRecorder.state).assertEqual('idle'); console.info('case release '); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - await videoOutput.release().then(() => { - console.info('[camera] case videoOutput release success'); - }); - videoOutput = undefined; await videoRecorderBase.stopCaptureSession(captureSession); await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId); await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber); @@ -1728,11 +1673,12 @@ describe('VideoRecorderFuncPromiseTest', function () { let videoRecorder = undefined; let surfaceID = ''; let videoOutput; + let previewOutput; fdObject = await mediaTestBase.getFd('recorder_promise_24.mp4'); fdPath = "fd://" + fdObject.fdNumber.toString(); videoConfig.url = fdPath; configFile.videoFrameRate = 60; - let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile); + let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile, videoConfig.videoSourceType); await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); if (typeof (recorder) != 'undefined') { @@ -1751,8 +1697,10 @@ describe('VideoRecorderFuncPromiseTest', function () { await videoRecorder.getInputSurface().then((outPutSurface) => { surfaceID = outPutSurface; }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - videoOutput = await camera.createVideoOutput(surfaceID); - captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID); + videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); + previewOutput = await cameraManager.createPreviewOutput(previewProfiles[0], playerSurfaceId) + captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, + cameras[0], previewOutput); await startVideoOutput(videoOutput); await videoRecorder.start().then(() => { expect(videoRecorder.state).assertEqual('playing'); @@ -1764,10 +1712,6 @@ describe('VideoRecorderFuncPromiseTest', function () { expect(videoRecorder.state).assertEqual('idle'); console.info('case release '); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - await videoOutput.release().then(() => { - console.info('[camera] case videoOutput release success'); - }); - videoOutput = undefined; await videoRecorderBase.stopCaptureSession(captureSession); await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId); await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber); -- GitLab