diff --git a/multimedia/media/media_js_standard/videoEncoder/BUILD.gn b/multimedia/media/media_js_standard/videoEncoder/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..b0500e8e282dafafe1310dedd61ba108b94bed28
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoEncoder/BUILD.gn
@@ -0,0 +1,32 @@
+# Copyright (C) 2021 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import("//test/xts/tools/build/suite.gni")
+
+ohos_js_hap_suite("video_encoder_js_hap") {
+ hap_profile = "./src/main/config.json"
+ js2abc = true
+ deps = [
+ ":video_encoder_js_assets",
+ ":video_encoder_resources",
+ ]
+ certificate_profile = "./signature/openharmony_sx.p7b"
+ hap_name = "ActsVideoEncoderJsTest"
+}
+ohos_js_assets("video_encoder_js_assets") {
+ source_dir = "./src/main/js/default"
+}
+ohos_resources("video_encoder_resources") {
+ sources = [ "./src/main/resources" ]
+ hap_profile = "./src/main/config.json"
+}
diff --git a/multimedia/media/media_js_standard/videoEncoder/Test.json b/multimedia/media/media_js_standard/videoEncoder/Test.json
new file mode 100644
index 0000000000000000000000000000000000000000..a79347e73127e4912f81997763bd2e3e30698b46
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoEncoder/Test.json
@@ -0,0 +1,38 @@
+{
+ "description": "Configuration for videoPlayer Tests",
+ "driver": {
+ "type": "JSUnitTest",
+ "test-timeout": "2000000",
+ "package": "ohos.acts.multimedia.video.videoencoder",
+ "shell-timeout": "60000"
+ },
+ "kits": [
+ {
+ "type": "PushKit",
+ "pre-push": [
+ ],
+ "push": [
+ ]
+ },
+ {
+ "type": "ShellKit",
+ "run-command": [
+ "rm -R /data/media/results",
+ "chmod 777 -R /data/media",
+ "chmod 777 /data/media/*",
+ "mkdir /data/media/results",
+ "setenforce 0"
+ ],
+ "teardown-command":[
+ "setenforce 1"
+ ]
+ },
+ {
+ "test-file-name": [
+ "ActsVideoEncoderJsTest.hap"
+ ],
+ "type": "AppInstallKit",
+ "cleanup-apps": true
+ }
+ ]
+}
diff --git a/multimedia/media/media_js_standard/videoEncoder/signature/openharmony_sx.p7b b/multimedia/media/media_js_standard/videoEncoder/signature/openharmony_sx.p7b
new file mode 100644
index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5
Binary files /dev/null and b/multimedia/media/media_js_standard/videoEncoder/signature/openharmony_sx.p7b differ
diff --git a/multimedia/media/media_js_standard/videoEncoder/src/main/config.json b/multimedia/media/media_js_standard/videoEncoder/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..b52e6a6816dd98d69a1b95ebd59800dc35a0bb5d
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoEncoder/src/main/config.json
@@ -0,0 +1,74 @@
+{
+ "app": {
+ "apiVersion": {
+ "compatible": 6,
+ "releaseType": "Beta1",
+ "target": 7
+ },
+ "vendor": "acts",
+ "bundleName": "ohos.acts.multimedia.video.videoencoder",
+ "version": {
+ "code": 1000000,
+ "name": "1.0.0"
+ }
+ },
+ "deviceConfig": {
+ "default": {
+ "debug": true
+ }
+ },
+ "module": {
+ "abilities": [
+ {
+ "iconId": 16777218,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ],
+ "descriptionId": 16777217,
+ "visible": true,
+ "labelId": 16777216,
+ "icon": "$media:icon",
+ "name": "ohos.acts.multimedia.video.videoencoder.MainAbility",
+ "description": "$string:mainability_description",
+ "label": "$string:entry_MainAbility",
+ "type": "page",
+ "homeAbility": true,
+ "launchType": "standard"
+ }
+ ],
+ "deviceType": [
+ "phone",
+ "tablet",
+ "tv",
+ "wearable"
+ ],
+ "mainAbility": "ohos.acts.multimedia.video.videoencoder.MainAbility",
+ "distro": {
+ "moduleType": "entry",
+ "installationFree": false,
+ "deliveryWithInstall": true,
+ "moduleName": "entry"
+ },
+ "package": "ohos.acts.multimedia.video.videoencoder",
+ "name": ".MyApplication",
+ "js": [
+ {
+ "pages": [
+ "pages/index/index"
+ ],
+ "name": "default",
+ "window": {
+ "designWidth": 720,
+ "autoDesignWidth": true
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/multimedia/media/media_js_standard/videoEncoder/src/main/js/default/app.js b/multimedia/media/media_js_standard/videoEncoder/src/main/js/default/app.js
new file mode 100644
index 0000000000000000000000000000000000000000..e423f4bce4698ec1d7dc86c3eea3990a5e7b1085
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoEncoder/src/main/js/default/app.js
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export default {
+ onCreate() {
+ console.info('AceApplication onCreate');
+ },
+ onDestroy() {
+ console.info('AceApplication onDestroy');
+ }
+};
diff --git a/multimedia/media/media_js_standard/videoEncoder/src/main/js/default/i18n/en-US.json b/multimedia/media/media_js_standard/videoEncoder/src/main/js/default/i18n/en-US.json
new file mode 100644
index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoEncoder/src/main/js/default/i18n/en-US.json
@@ -0,0 +1,6 @@
+{
+ "strings": {
+ "hello": "Hello",
+ "world": "World"
+ }
+}
\ No newline at end of file
diff --git a/multimedia/media/media_js_standard/videoEncoder/src/main/js/default/i18n/zh-CN.json b/multimedia/media/media_js_standard/videoEncoder/src/main/js/default/i18n/zh-CN.json
new file mode 100644
index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoEncoder/src/main/js/default/i18n/zh-CN.json
@@ -0,0 +1,6 @@
+{
+ "strings": {
+ "hello": "您好",
+ "world": "世界"
+ }
+}
\ No newline at end of file
diff --git a/multimedia/media/media_js_standard/videoEncoder/src/main/js/default/pages/index/index.css b/multimedia/media/media_js_standard/videoEncoder/src/main/js/default/pages/index/index.css
new file mode 100644
index 0000000000000000000000000000000000000000..5bd7567028568bd522193b2519d545ca6dcf397d
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoEncoder/src/main/js/default/pages/index/index.css
@@ -0,0 +1,46 @@
+.container {
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ width: 100%;
+ height: 100%;
+}
+
+.title {
+ font-size: 40px;
+ color: #000000;
+ opacity: 0.9;
+}
+
+@media screen and (device-type: tablet) and (orientation: landscape) {
+ .title {
+ font-size: 100px;
+ }
+}
+
+@media screen and (device-type: wearable) {
+ .title {
+ font-size: 28px;
+ color: #FFFFFF;
+ }
+}
+
+@media screen and (device-type: tv) {
+ .container {
+ background-image: url("/common/images/Wallpaper.png");
+ background-size: cover;
+ background-repeat: no-repeat;
+ background-position: center;
+ }
+
+ .title {
+ font-size: 100px;
+ color: #FFFFFF;
+ }
+}
+
+@media screen and (device-type: phone) and (orientation: landscape) {
+ .title {
+ font-size: 60px;
+ }
+}
diff --git a/multimedia/media/media_js_standard/videoEncoder/src/main/js/default/pages/index/index.hml b/multimedia/media/media_js_standard/videoEncoder/src/main/js/default/pages/index/index.hml
new file mode 100644
index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoEncoder/src/main/js/default/pages/index/index.hml
@@ -0,0 +1,5 @@
+
+
+ {{ $t('strings.hello') }} {{ title }}
+
+
diff --git a/multimedia/media/media_js_standard/videoEncoder/src/main/js/default/pages/index/index.js b/multimedia/media/media_js_standard/videoEncoder/src/main/js/default/pages/index/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..a0719cee588ac4b0f56efbf784b19647bc6645de
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoEncoder/src/main/js/default/pages/index/index.js
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import {Core, ExpectExtend} from 'deccjsunit/index'
+
+export default {
+ data: {
+ title: ""
+ },
+ onInit() {
+ this.title = this.$t('strings.world');
+ },
+ onShow() {
+ console.info('onShow finish')
+ const core = Core.getInstance()
+ const expectExtend = new ExpectExtend({
+ 'id': 'extend'
+ })
+ core.addService('expect', expectExtend)
+ core.init()
+ const configService = core.getDefaultService('config')
+ this.timeout = 60000
+ configService.setConfig(this)
+ require('../../../test/List.test')
+ core.execute()
+ },
+ onReady() {
+ },
+}
\ No newline at end of file
diff --git a/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/List.test.js b/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/List.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..ec4e1abb331a79daa4c923a1855ee1b77408978e
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/List.test.js
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+require('./VideoEncoderFuncPromiseTest.test.js')
+require('./VideoEncoderReliabilityPromiseTest.test.js')
+require('./VideoEncoderMultiInstancesTest.test.js')
diff --git a/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderMultiInstancesTest.test.js b/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderMultiInstancesTest.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..4cb84a03bc36a174bd4c48ace583cac1ffe86f38
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderMultiInstancesTest.test.js
@@ -0,0 +1,325 @@
+/*
+ * Copyright (C) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import media from '@ohos.multimedia.media'
+import mediademo from '@ohos.multimedia.mediademo'
+import Fileio from '@ohos.fileio'
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
+
+describe('videoEncoderSoftwareMultiInstances', function () {
+ const events = require('events');
+ const eventEmitter = new events.EventEmitter();
+ const BASIC_PATH = '/data/media/results/videoencode_multiinstances_';
+ let videoEncodeProcessor;
+ let mediaTest;
+ let surfaceID = '';
+ let outputQueue = [];
+ let outputCnt = 0;
+ let frameTotal = 100;
+ let stopAtEOS = false;
+ let resetAtEOS = false;
+ let flushAtEOS = false;
+ let sawOutputEOS = false;
+ let needGetMediaDes = false;
+
+ beforeAll(function() {
+ console.info('beforeAll case');
+ })
+
+ beforeEach(function() {
+ console.info('beforeEach case');
+ videoEncodeProcessor = null;
+ mediaTest = null;
+ surfaceID = '';
+ outputQueue = [];
+ outputCnt = 0;
+ frameTotal = 100;
+ stopAtEOS = false;
+ resetAtEOS = false;
+ flushAtEOS = false;
+ sawOutputEOS = false;
+ needGetMediaDes = false;
+ })
+
+ afterEach(async function() {
+ console.info('afterEach case');
+ if (videoEncodeProcessor != null){
+ await videoEncodeProcessor.release().then(() => {
+ console.info("case release success");
+ videoEncodeProcessor = null;
+ }, failCallback).catch(failCatch);
+ }
+ })
+
+ afterAll(function() {
+ console.info('afterAll case');
+ })
+
+ let failCallback = function(err) {
+ console.info('case callback err : ' + err);
+ expect(err).assertUndefined();
+ }
+
+ let failCatch = function(err) {
+ console.info('case catch err : ' + err);
+ expect(err).assertUndefined();
+ }
+
+ function resetParam() {
+ outputQueue = [];
+ outputCnt = 0;
+ frameTotal = 100;
+ stopAtEOS = false;
+ resetAtEOS = false;
+ flushAtEOS = false;
+ sawOutputEOS = false;
+ needGetMediaDes = false;
+ }
+
+ function writeFile(path, buf, len){
+ try{
+ let writestream = Fileio.createStreamSync(path, "ab+");
+ let num = writestream.writeSync(buf, {length:len});
+ writestream.flushSync();
+ writestream.closeSync();
+ } catch(e) {
+ console.info(e)
+ }
+ }
+
+ function sleep(time) {
+ return new Promise((resolve) => setTimeout(resolve, time));
+ }
+
+ function wait(time) {
+ for(let t = Date.now(); Date.now() - t <= time;);
+ }
+
+ async function dequeueOutputs(path, nextStep) {
+ while (outputQueue.length > 0) {
+ let outputObject = outputQueue.shift();
+ outputCnt += 1;
+ if (outputObject.flags == 1) {
+ console.info("case last frame");
+ mediaTest.closeStream(surfaceID);
+ toRelease();
+ nextStep();
+ return;
+ } else {
+ console.info('not last frame, write data to file');
+ writeFile(path, outputObject.data, outputObject.length);
+ console.info("write to file success");
+ videoEncodeProcessor.releaseOutput(outputObject).then(() => {
+ console.info('release output success');
+ });
+ }
+ }
+ }
+
+ function setCallback(path, nextStep) {
+ console.info('case callback');
+ videoEncodeProcessor.on('outputBufferAvailable', async(outBuffer) => {
+ console.info('outputBufferAvailable');
+ console.info('outBuffer.flags: ' + outBuffer.flags);
+ if (needGetMediaDes) {
+ videoEncodeProcessor.getOutputMediaDescription().then((MediaDescription) => {
+ console.info("get OutputMediaDescription success");
+ console.info('get outputMediaDescription : ' + MediaDescription);
+ needGetMediaDes = false;
+ }, failCallback).catch(failCatch);
+ }
+ outputQueue.push(outBuffer);
+ dequeueOutputs(path, nextStep);
+ });
+
+ videoEncodeProcessor.on('error',(err) => {
+ console.info('case error called,errName is' + err);
+ });
+ videoEncodeProcessor.on('outputFormatChanged',(format) => {
+ console.info('Output format changed: ' + format);
+ });
+ }
+
+ async function toCreateByMime(mime, done) {
+ await media.createVideoEncoderByMime(mime).then((processor) => {
+ if (typeof (processor) != 'undefined') {
+ videoEncodeProcessor = processor;
+ console.info('in case : createVideoEncoderByMime success');
+ } else {
+ console.info('in case : createVideoEncoderByMime fail');
+ expect().assertFail();
+ done();
+ }
+ })
+ }
+
+ async function toCreateByName(name, done) {
+ await media.createVideoEncoderByName(name).then((processor) => {
+ if (typeof (processor) != 'undefined') {
+ videoEncodeProcessor = processor;
+ console.info('in case : createVideoEncoderByName success');
+ } else {
+ console.info('in case : createVideoEncoderByName fail');
+ expect().assertFail();
+ done();
+ }
+ })
+ }
+
+ async function toGetVideoEncoderCaps() {
+ await videoEncodeProcessor.getVideoEncoderCaps().then((videoCaps) => {
+ console.info("case get getVideoEncoderCaps success");
+ console.info("print videoCaps: " + videoCaps)
+ }, failCallback).catch(failCatch);
+ }
+
+ function toCreateStream() {
+ mediaTest = mediademo.createMediaTest();
+ }
+
+ function toSetStreamParam(width, height, framerate, frameTotal) {
+ console.info('case set stream parameter');
+ mediaTest.setResolution(width, height);
+ mediaTest.setFrameRate(framerate);
+ mediaTest.setFrameCount(frameTotal);
+ }
+
+ async function toGetInputSurface() {
+ await videoEncodeProcessor.getInputSurface().then((inputSurface) => {
+ expect(inputSurface != undefined).assertTrue();
+ console.info('case getInputSurface success');
+ surfaceID = inputSurface;
+ }, failCallback).catch(failCatch);
+ }
+
+ function toStartStream() {
+ console.info('case start stream');
+ mediaTest.startStream(surfaceID);
+ }
+
+ function toStopStream() {
+ console.info('case stop stream');
+ mediaTest.closeStream(surfaceID);
+ }
+
+ async function toConfigure(mediaDescription) {
+ await videoEncodeProcessor.configure(mediaDescription).then(() => {
+ console.info("case configure success");
+ }, failCallback).catch(failCatch);
+ }
+
+ async function toPrepare() {
+ await videoEncodeProcessor.prepare().then(() => {
+ console.info("case prepare success");
+ }, failCallback).catch(failCatch);
+ }
+
+ async function toStart() {
+ await videoEncodeProcessor.start().then(() => {
+ console.info("case start success");
+ }, failCallback).catch(failCatch);
+ }
+
+ async function toFlush() {
+ outputQueue = [];
+ await videoEncodeProcessor.flush().then(() => {
+ console.info("case flush success");
+ }, failCallback).catch(failCatch);
+ }
+
+ async function toStop() {
+ await videoEncodeProcessor.stop().then(() => {
+ console.info("case stop success");
+ }, failCallback).catch(failCatch);
+ }
+
+ async function toReset() {
+ await videoEncodeProcessor.reset().then(() => {
+ console.info("case reset success");
+ }, failCallback).catch(failCatch);
+ }
+
+ async function toRelease() {
+ await videoEncodeProcessor.release().then(() => {
+ console.info("case release success");
+ videoEncodeProcessor = null;
+ }, failCallback).catch(failCatch);
+ }
+
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_MULTIINSTANCE_0100
+ * @tc.name : 001.create 16 encoder
+ * @tc.desc : basic encode function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_MULTIINSTANCE_0100', 0, async function (done) {
+ console.info("case test multiple encoder instances");
+ let savepath = BASIC_PATH + '0100.txt';
+ let mime = 'video/mp4v-es';
+ let width = 720;
+ let height = 480;
+ let framerate = 60;
+ let mediaDescription = {
+ "width": width,
+ "height": height,
+ "pixel_format": 3,
+ "frame_rate" : framerate,
+ }
+ let array = new Array();
+
+ eventEmitter.once('nextStep', async () => {
+ for (let j = 1; j < 16; j++) {
+ await array[j].release().then(() => {
+ console.info("case release encoder " + j);
+ array[j] = null;
+ }, failCallback).catch(failCatch);
+ }
+ console.info('release 16 encoders success');
+ done();
+ });
+ async function runCase() {
+ toCreateStream();
+ toSetStreamParam(width, height, framerate, frameTotal);
+ await toConfigure(mediaDescription);
+ setCallback(savepath, function(){eventEmitter.emit('nextStep')});
+ await toGetInputSurface();
+ await toPrepare();
+ toStartStream();
+ await toStart();
+ }
+ for (let i = 1; i <= 16; i += 1) {
+ await media.createVideoEncoderByMime(mime).then((processor) => {
+ if (typeof(processor) != 'undefined') {
+ console.info("case create createVideoEncoder success: " + i);
+ if (i == 16) {
+ videoEncodeProcessor = processor;
+ runCase();
+ } else {
+ array[i] = processor;
+ }
+ } else {
+ console.info("case create createVideoEncoder failed: " + i);
+ expect().assertFail();
+ done();
+ }
+ }, failCallback).catch(failCatch);
+ }
+ })
+})
+
+
\ No newline at end of file
diff --git a/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareFuncCallbackTest.test.js b/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareFuncCallbackTest.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..7d0e29af639772e1c69875ff09696a8508fda40e
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareFuncCallbackTest.test.js
@@ -0,0 +1,555 @@
+/*
+ * Copyright (C) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import media from '@ohos.multimedia.media'
+import mediademo from '@ohos.multimedia.mediademo'
+import Fileio from '@ohos.fileio'
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
+
+describe('VideoEncoderSoftwareFuncCallbackTest', function () {
+ let videoEncodeProcessor = null;
+ let mediaTest;
+ let surfaceID = '';
+ let frameCountOut = 0;
+ let outputQueue = [];
+ let frameTotal = 100;
+ let finalFrameId = 100;
+ let reStart = false;
+ let isStreamRunning = false;
+ let stopBuffer = false;
+ const events = require('events');
+ const eventEmitter = new events.EventEmitter();
+ const BASIC_PATH = '/data/media/results/';
+
+ beforeAll(function() {
+ console.info('beforeAll case');
+ })
+
+ beforeEach(function() {
+ console.info('beforeEach case');
+ videoEncodeProcessor = null;
+ mediaTest = null;
+ surfaceID = '';
+ frameCountOut = 0;
+ outputQueue = [];
+ frameTotal = 100;
+ finalFrameId = 100;
+ reStart = false;
+ isStreamRunning = false;
+ stopBuffer = false;
+ })
+
+ afterEach(async function() {
+ console.info('afterEach case');
+ if (videoEncodeProcessor != null) {
+ await videoEncodeProcessor.release().then(() => {
+ console.info('case videoEncodeProcessor release');
+ }, failCallback).catch(failCatch);
+ videoEncodeProcessor = null;
+ }
+ })
+
+ afterAll(function() {
+ console.info('afterAll case');
+ })
+ let failCallback = function(err) {
+ console.error(`in case error failCallback called, errMessage is ${err.message}`);
+ expect(err == undefined).assertTrue();
+ }
+ let failCatch = function(err) {
+ console.error(`in case error failCatch called,errMessage is ${err.message}`);
+ expect(err == undefined).assertTrue();
+ }
+
+ function writeFile(path, buf, len){
+ try {
+ let writestream = Fileio.createStreamSync(path, 'ab+');
+ let num = writestream.writeSync(buf, {length:len});
+ writestream.flushSync();
+ writestream.closeSync();
+ } catch(e) {
+ console.error('in case error writeFile: ' + e);
+ }
+ }
+
+ async function dequeueOutputs(path, nextStep) {
+ while (outputQueue.length > 0) {
+ let outputObject = outputQueue.shift();
+ if (outputObject.flags == 1 || frameCountOut == frameTotal || frameCountOut == finalFrameId) {
+ nextStep();
+ return;
+ }
+ frameCountOut++;
+ writeFile(path, outputObject.data, outputObject.length);
+ videoEncodeProcessor.releaseOutput(outputObject, (err) => {
+ if (typeof(err) == 'undefined') {
+ console.log('in case release output count:' + frameCountOut);
+ } else {
+ console.info(`in case release output called,errMessage is ${err.message}`);
+ }
+ });
+ }
+ }
+ function printDescription(obj) {
+ for (let item in obj) {
+ let property = obj[item];
+ console.info('video encoder key is ' + item);
+ console.info('video encoder value is ' + property);
+ }
+ }
+ function setCallback(path, nextStep) {
+ console.info('case callback');
+ videoEncodeProcessor.on('outputBufferAvailable', async(outBuffer) => {
+ console.info('outputBufferAvailable');
+ if (stopBuffer == false) {
+ outputQueue.push(outBuffer);
+ dequeueOutputs(path, nextStep);
+ }
+ });
+
+ videoEncodeProcessor.on('error',(err) => {
+ console.info('in case error called, errName is' + err);
+ });
+ videoEncodeProcessor.on('outputFormatChanged',(format) => {
+ if (typeof(format) != undefined) {
+ printDescription(format);
+ }
+ });
+ }
+ function toCreateStream() {
+ mediaTest = mediademo.createMediaTest();
+ }
+ function toSetStreamParam(width, height, framerate, frameTotal) {
+ mediaTest.setResolution(width, height);
+ mediaTest.setFrameRate(framerate);
+ mediaTest.setFrameCount(frameTotal);
+ }
+
+ function toStartStream() {
+ if (isStreamRunning == false) {
+ console.info('in case : toStartStream');
+ mediaTest.startStream(surfaceID);
+ isStreamRunning = true;
+ }
+ }
+
+ function toStopStream() {
+ if (isStreamRunning == true) {
+ console.info('in case : toStopStream');
+ mediaTest.closeStream(surfaceID);
+ isStreamRunning = false;
+ }
+ }
+
+ eventEmitter.on('configure', (mediaDescription, decPath, nextStep, done) => {
+ console.info('in case : configure in');
+ videoEncodeProcessor.configure(mediaDescription, (err) => {
+ expect(err).assertUndefined();
+ console.info('in case : configure success');
+ setCallback(decPath, nextStep);
+ eventEmitter.emit('getVideoEncoderCaps', done);
+ });
+ });
+ eventEmitter.on('getVideoEncoderCaps', (done) => {
+ videoEncodeProcessor.getVideoEncoderCaps((err, videoCaps) => {
+ expect(err).assertUndefined();
+ console.info("case get getVideoEncoderCaps success");
+ console.info(`print videoCaps:
+ codecInfo.name ${videoCaps.codecInfo.name}
+ codecInfo.type ${videoCaps.codecInfo.type}
+ codecInfo.mimeType ${videoCaps.codecInfo.mimeType}
+ codecInfo.isHardwareAccelerated ${videoCaps.codecInfo.isHardwareAccelerated}
+ codecInfo.isSoftwareOnly ${videoCaps.codecInfo.isSoftwareOnly}
+ codecInfo.isVendor ${videoCaps.codecInfo.isVendor}
+ supportedBitrate [${videoCaps.supportedBitrate.min}, ${videoCaps.supportedBitrate.max}]
+ supportedFormats ${videoCaps.supportedFormats}
+ supportedHeightAlignment ${videoCaps.supportedHeightAlignment}
+ supportedWidthAlignment ${videoCaps.supportedWidthAlignment}
+ supportedWidth [${videoCaps.supportedWidth.min}, ${videoCaps.supportedWidth.max}]
+ supportedHeight [${videoCaps.supportedHeight.min}, ${videoCaps.supportedHeight.max}]
+ supportedProfiles ${videoCaps.supportedProfiles}
+ supportedLevels ${videoCaps.supportedLevels}
+ supportedBitrateMode ${videoCaps.supportedBitrateMode}
+ supportedQuality [${videoCaps.supportedQuality.min}, ${videoCaps.supportedQuality.max}]
+ supportedComplexity [${videoCaps.supportedComplexity.min}, ${videoCaps.supportedComplexity.max}]
+ `);
+ eventEmitter.emit('getInputSurface', done);
+ });
+ });
+ eventEmitter.on('getInputSurface', (done) => {
+ videoEncodeProcessor.getInputSurface((err, inputSurface) => {
+ expect(err).assertUndefined();
+ expect(inputSurface != undefined).assertTrue();
+ surfaceID = inputSurface;
+ console.info('in case : getInputSurface success, surfaceID ' + surfaceID);
+ eventEmitter.emit('prepare', done);
+ })
+ });
+ eventEmitter.on('prepare', (done) => {
+ videoEncodeProcessor.prepare((err) => {
+ expect(err).assertUndefined();
+ console.info('in case : prepare success');
+ toStartStream();
+ eventEmitter.emit('start', done);
+ });
+ });
+ eventEmitter.on('start', (done) => {
+ toStartStream();
+ videoEncodeProcessor.start((err) => {
+ expect(err).assertUndefined();
+ console.info('in case : start success');
+ });
+ stopBuffer = false;
+ });
+ eventEmitter.on('stop', (done) => {
+ videoEncodeProcessor.stop((err) => {
+ expect(err).assertUndefined();
+ toStopStream();
+ console.info('in case : stop success');
+ if (reStart == true) {
+ frameCountOut = 0;
+ outputQueue = [];
+ reStart = false;
+ eventEmitter.emit('start', done);
+ } else {
+ eventEmitter.emit('reset', done);
+ }
+ });
+ stopBuffer = true;
+ });
+ eventEmitter.on('flush', (done) => {
+ videoEncodeProcessor.flush((err) => {
+ expect(err).assertUndefined();
+ console.info('in case : flush success');
+ eventEmitter.emit('reset', done);
+ });
+ });
+ eventEmitter.on('reset', (done) => {
+ videoEncodeProcessor.reset((err) => {
+ toStopStream();
+ expect(err).assertUndefined();
+ console.info('in case : reset success');
+ eventEmitter.emit('release', done);
+ });
+ });
+ eventEmitter.on('release', (done) => {
+ videoEncodeProcessor.release((err) => {
+ toStopStream();
+ expect(err).assertUndefined();
+ console.info('in case : release success');
+ videoEncodeProcessor = null;
+ done();
+ });
+ });
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_CALLBACK_00_0100
+ * @tc.name : 000.test stop after last frame and reset
+ * @tc.desc : basic encode function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_CALLBACK_00_0100', 0, async function (done) {
+ let decPath = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_CALLBACK_00_0100.es';
+ let mime = 'video/mp4v-es';
+ let mediaDescription = {
+ "codec_mime": 'video/mp4v-es',
+ 'width': 720,
+ 'height': 480,
+ 'pixel_format': 3,
+ 'frame_rate': 60,
+ }
+ media.getMediaCapability((err, mediaCaps) => {
+ expect(err).assertUndefined();
+ console.info(`case getMediaCapability 1`);
+ mediaCaps.getVideoEncoderCaps((err, videoCapsArray) => {
+ expect(err).assertUndefined();
+ console.info('getVideoDecoderCaps success');
+ if (typeof (videoCapsArray) != 'undefined') {
+ console.info("case videoCapsArray" + videoCapsArray);
+ } else {
+ console.info("case videoCapsArray is not defined");
+ expect().assertFail();
+ done();
+ }
+ })
+ mediaCaps.findVideoEncoder(mediaDescription, (err, codecname) => {
+ expect(err).assertUndefined();
+ console.info('findVideoEncoder success');
+ if (typeof (codecname) != 'undefined') {
+ console.info("case codecname " + codecname);
+ } else {
+ console.info("case codecname is not defined");
+ expect().assertFail();
+ done();
+ }
+ })
+ })
+ media.createVideoEncoderByMime(mime, (err, processor) => {
+ expect(err).assertUndefined();
+ if (typeof(processor) != 'undefined') {
+ console.info('case create createVideoEncoderByName success');
+ videoEncodeProcessor = processor;
+ toCreateStream();
+ toSetStreamParam(mediaDescription.width, mediaDescription.height,
+ mediaDescription.frame_rate, frameTotal);
+ eventEmitter.emit('configure', mediaDescription, decPath,
+ function(){eventEmitter.emit('stop', done);}, done);
+ } else {
+ console.info('case create createVideoEncoderByName fail');
+ expect().assertFail();
+ done();
+ }
+ });
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_CALLBACK_01_0100
+ * @tc.name : 000.test stop at running state and reset
+ * @tc.desc : basic encode function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_CALLBACK_01_0100', 0, async function (done) {
+ let decPath = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_CALLBACK_01_0100.es';
+ let name= 'avenc_mpeg4';
+ let mediaDescription = {
+ 'width': 720,
+ 'height': 480,
+ 'pixel_format': 3,
+ 'frame_rate': 60.00,
+ }
+ finalFrameId = 50;
+ media.createVideoEncoderByName(name, (err, processor) => {
+ expect(err).assertUndefined();
+ if (typeof(processor) != 'undefined') {
+ console.info('case create createVideoEncoderByName success');
+ videoEncodeProcessor = processor;
+ toCreateStream();
+ toSetStreamParam(mediaDescription.width, mediaDescription.height,
+ mediaDescription.frame_rate, frameTotal);
+ eventEmitter.emit('configure', mediaDescription, decPath,
+ function(){eventEmitter.emit('stop', done);}, done);
+ } else {
+ console.info('case create createVideoEncoderByName fail');
+ expect().assertFail();
+ done();
+ }
+ });
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_CALLBACK_01_0200
+ * @tc.name : 000.test stop at end of stream and restart
+ * @tc.desc : basic encode function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_CALLBACK_01_0200', 0, async function (done) {
+ let decPath = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_CALLBACK_01_0200.es';
+ let name= 'avenc_mpeg4';
+ let mediaDescription = {
+ 'width': 720,
+ 'height': 480,
+ 'pixel_format': 3,
+ 'frame_rate': 60.00,
+ }
+ reStart = true;
+ media.createVideoEncoderByName(name, (err, processor) => {
+ expect(err).assertUndefined();
+ if (typeof(processor) != 'undefined') {
+ console.info('case create createVideoEncoderByName success');
+ videoEncodeProcessor = processor;
+ toCreateStream();
+ toSetStreamParam(mediaDescription.width, mediaDescription.height,
+ mediaDescription.frame_rate, frameTotal);
+ eventEmitter.emit('configure', mediaDescription, decPath,
+ function(){eventEmitter.emit('stop', done);}, done);
+ } else {
+ console.info('case create createVideoEncoderByName fail');
+ expect().assertFail();
+ done();
+ }
+ });
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_CALLBACK_01_0300
+ * @tc.name : 000.test stop at running state and restart
+ * @tc.desc : basic encode function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_CALLBACK_01_0300', 0, async function (done) {
+ let decPath = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_CALLBACK_01_0300.es';
+ let name= 'avenc_mpeg4';
+ let mediaDescription = {
+ 'width': 720,
+ 'height': 480,
+ 'pixel_format': 3,
+ 'frame_rate': 60.00,
+ }
+ finalFrameId = 50;
+ reStart = true;
+ media.createVideoEncoderByName(name, (err, processor) => {
+ expect(err).assertUndefined();
+ if (typeof(processor) != 'undefined') {
+ console.info('case create createVideoEncoderByName success');
+ videoEncodeProcessor = processor;
+ toCreateStream();
+ toSetStreamParam(mediaDescription.width, mediaDescription.height,
+ mediaDescription.frame_rate, frameTotal);
+ eventEmitter.emit('configure', mediaDescription, decPath,
+ function(){eventEmitter.emit('stop', done);}, done);
+ } else {
+ console.info('case create createVideoEncoderByName fail');
+ expect().assertFail();
+ done();
+ }
+ });
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_CALLBACK_01_0400
+ * @tc.name : 000.test flush at running state
+ * @tc.desc : basic encode function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_CALLBACK_01_0400', 0, async function (done) {
+ let decPath = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_CALLBACK_01_0400.es';
+ let name= 'avenc_mpeg4';
+ let mediaDescription = {
+ 'width': 720,
+ 'height': 480,
+ 'pixel_format': 3,
+ 'frame_rate': 60.00,
+ }
+ finalFrameId = 50;
+ media.createVideoEncoderByName(name, (err, processor) => {
+ expect(err).assertUndefined();
+ if (typeof(processor) != 'undefined') {
+ console.info('case create createVideoEncoderByName success');
+ videoEncodeProcessor = processor;
+ toCreateStream();
+ toSetStreamParam(mediaDescription.width, mediaDescription.height,
+ mediaDescription.frame_rate, frameTotal);
+ eventEmitter.emit('configure', mediaDescription, decPath,
+ function(){eventEmitter.emit('flush', done);}, done);
+ } else {
+ console.info('case create createVideoEncoderByName fail');
+ expect().assertFail();
+ done();
+ }
+ });
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_CALLBACK_01_0500
+ * @tc.name : 000.test flush at end of stream
+ * @tc.desc : basic encode function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_CALLBACK_01_0500', 0, async function (done) {
+ let decPath = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_CALLBACK_01_0500.es';
+ let name= 'avenc_mpeg4';
+ let mediaDescription = {
+ 'width': 720,
+ 'height': 480,
+ 'pixel_format': 3,
+ 'frame_rate': 60.00,
+ }
+ media.createVideoEncoderByName(name, (err, processor) => {
+ expect(err).assertUndefined();
+ if (typeof(processor) != 'undefined') {
+ console.info('case create createVideoEncoderByName success');
+ videoEncodeProcessor = processor;
+ toCreateStream();
+ toSetStreamParam(mediaDescription.width, mediaDescription.height,
+ mediaDescription.frame_rate, frameTotal);
+ eventEmitter.emit('configure', mediaDescription, decPath,
+ function(){eventEmitter.emit('flush', done);}, done);
+ } else {
+ console.info('case create createVideoEncoderByName fail');
+ expect().assertFail();
+ done();
+ }
+ });
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_CALLBACK_01_0600
+ * @tc.name : 000.test reconfigure
+ * @tc.desc : basic encode function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_CALLBACK_01_0600', 0, async function (done) {
+ let decPath = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_CALLBACK_01_0600.es';
+ let name= 'avenc_mpeg4';
+ let mediaDescription = {
+ 'width': 720,
+ 'height': 480,
+ 'pixel_format': 3,
+ 'frame_rate': 60.00,
+ }
+ let decPath2 = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_CALLBACK_01_0600_2.es';
+ let mediaDescription2 = {
+ 'width': 1920,
+ 'height': 1080,
+ 'pixel_format': 3,
+ 'frame_rate': 30.00,
+ }
+ eventEmitter.on('reset_for_callback_01_0600', (done) => {
+ videoEncodeProcessor.reset((err) => {
+ expect(err).assertUndefined();
+ console.info('in case : reset_for_callback_01_0600 success');
+ toStopStream();
+ surfaceID = '';
+ frameCountOut = 0;
+ outputQueue = [];
+ isStreamRunning = false;
+ toSetStreamParam(mediaDescription2.width, mediaDescription2.height,
+ mediaDescription2.frame_rate, frameTotal);
+ eventEmitter.emit('configure', mediaDescription2, decPath2,
+ function(){eventEmitter.emit('stop', done);}, done);
+ })
+ })
+ media.createVideoEncoderByName(name, (err, processor) => {
+ expect(err).assertUndefined();
+ if (typeof(processor) != 'undefined') {
+ console.info('case create createVideoEncoderByName success');
+ videoEncodeProcessor = processor;
+ toCreateStream();
+ toSetStreamParam(mediaDescription.width, mediaDescription.height,
+ mediaDescription.frame_rate, frameTotal);
+ eventEmitter.emit('configure', mediaDescription, decPath,
+ function(){eventEmitter.emit('reset_for_callback_01_0600', done);}, done);
+ } else {
+ console.info('case create createVideoEncoderByName fail');
+ expect().assertFail();
+ done();
+ }
+ });
+ })
+})
diff --git a/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareFuncPromiseTest.test.js b/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareFuncPromiseTest.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..7fdcc5fe916b7d42c0b2f34ffdb821f4d7b95773
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareFuncPromiseTest.test.js
@@ -0,0 +1,694 @@
+/*
+ * Copyright (C) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import media from '@ohos.multimedia.media'
+import mediademo from '@ohos.multimedia.mediademo'
+import Fileio from '@ohos.fileio'
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
+
+describe('videoSoftwareEncoderFuncPromise', function () {
+ const BASIC_PATH = '/data/media/results/videoencode_func_promise_';
+ let videoEncodeProcessor;
+ let mediaTest;
+ let surfaceID = '';
+ let outputQueue = [];
+ let outputCnt = 0;
+ let frameTotal = 100;
+ let stopAtEOS = false;
+ let resetAtEOS = false;
+ let flushAtEOS = false;
+ let sawOutputEOS = false;
+ let needGetMediaDes = false;
+
+ beforeAll(function() {
+ console.info('beforeAll case');
+ })
+
+ beforeEach(function() {
+ console.info('beforeEach case');
+ videoEncodeProcessor = null;
+ mediaTest = null;
+ surfaceID = '';
+ outputQueue = [];
+ outputCnt = 0;
+ frameTotal = 100;
+ stopAtEOS = false;
+ resetAtEOS = false;
+ flushAtEOS = false;
+ sawOutputEOS = false;
+ needGetMediaDes = false;
+ })
+
+ afterEach(async function() {
+ console.info('afterEach case');
+ if (videoEncodeProcessor != null){
+ await videoEncodeProcessor.release().then(() => {
+ console.info("case release success");
+ }, failCallback).catch(failCatch);
+ videoEncodeProcessor = null;
+ }
+ })
+
+ afterAll(function() {
+ console.info('afterAll case');
+ })
+
+ let failCallback = function(err) {
+ console.info('case callback err : ' + err);
+ expect(err).assertUndefined();
+ }
+
+ let failCatch = function(err) {
+ console.info('case catch err : ' + err);
+ expect(err).assertUndefined();
+ }
+
+ function resetParam() {
+ outputQueue = [];
+ outputCnt = 0;
+ frameTotal = 100;
+ stopAtEOS = false;
+ resetAtEOS = false;
+ flushAtEOS = false;
+ sawOutputEOS = false;
+ needGetMediaDes = false;
+ }
+
+ function writeFile(path, buf, len){
+ try{
+ let writestream = Fileio.createStreamSync(path, "ab+");
+ let num = writestream.writeSync(buf, {length:len});
+ writestream.flushSync();
+ writestream.closeSync();
+ } catch(e) {
+ console.info(e)
+ }
+ }
+
+ function sleep(time) {
+ return new Promise((resolve) => setTimeout(resolve, time));
+ }
+
+ function wait(time) {
+ for(let t = Date.now(); Date.now() - t <= time;);
+ }
+
+ async function dequeueOutputs(path, done) {
+ while (outputQueue.length > 0) {
+ let outputObject = outputQueue.shift();
+ outputCnt += 1;
+ if (outputObject.flags == 1) {
+ console.info("last frame, make choice");
+ mediaTest.closeStream(surfaceID);
+ sawOutputEOS = true;
+ if (stopAtEOS) {
+ await toStop();
+ } else if (resetAtEOS) {
+ await toReset();
+ } else if (flushAtEOS) {
+ await toFlush();
+ } else {
+ await toReset();
+ await toRelease();
+ done();
+ }
+ } else {
+ console.info('not last frame, write data to file');
+ writeFile(path, outputObject.data, outputObject.length);
+ console.info("write to file success");
+ videoEncodeProcessor.releaseOutput(outputObject).then(() => {
+ console.info('release output success');
+ });
+ }
+ }
+ }
+
+ function setCallback(path, done) {
+ console.info('case callback');
+ videoEncodeProcessor.on('outputBufferAvailable', async(outBuffer) => {
+ console.info('outputBufferAvailable');
+ console.info('outBuffer.flags: ' + outBuffer.flags);
+ if (needGetMediaDes) {
+ videoEncodeProcessor.getOutputMediaDescription().then((MediaDescription) => {
+ console.info("get OutputMediaDescription success");
+ console.info('get outputMediaDescription : ' + MediaDescription);
+ needGetMediaDes = false;
+ }, failCallback).catch(failCatch);
+ }
+ outputQueue.push(outBuffer);
+ dequeueOutputs(path, done);
+ });
+
+ videoEncodeProcessor.on('error',(err) => {
+ console.info('case error called,errName is' + err);
+ });
+ videoEncodeProcessor.on('outputFormatChanged',(format) => {
+ console.info('Output format changed: ' + format);
+ });
+ }
+
+ async function toCreateByMime(mime, done) {
+ await media.createVideoEncoderByMime(mime).then((processor) => {
+ if (typeof (processor) != 'undefined') {
+ videoEncodeProcessor = processor;
+ console.info('in case : createVideoEncoderByMime success');
+ } else {
+ console.info('in case : createVideoEncoderByMime fail');
+ expect().assertFail();
+ done();
+ }
+ })
+ }
+
+ async function toCreateByName(name, done) {
+ await media.createVideoEncoderByName(name).then((processor) => {
+ if (typeof (processor) != 'undefined') {
+ videoEncodeProcessor = processor;
+ console.info('in case : createVideoEncoderByName success');
+ } else {
+ console.info('in case : createVideoEncoderByName fail');
+ expect().assertFail();
+ done();
+ }
+ })
+ }
+
+ async function toGetVideoEncoderCaps(width, height) {
+ await videoEncodeProcessor.getVideoEncoderCaps().then((videoCaps) => {
+ console.info("case get getVideoEncoderCaps success");
+ printVideoCaps(videoCaps, width, height);
+ }, failCallback).catch(failCatch);
+ }
+
+ async function printVideoCaps(videoCaps, width, height) {
+ console.info(`print videoCaps:
+ codecInfo.name ${videoCaps.codecInfo.name}
+ codecInfo.type ${videoCaps.codecInfo.type}
+ codecInfo.mimeType ${videoCaps.codecInfo.mimeType}
+ codecInfo.isHardwareAccelerated ${videoCaps.codecInfo.isHardwareAccelerated}
+ codecInfo.isSoftwareOnly ${videoCaps.codecInfo.isSoftwareOnly}
+ codecInfo.isVendor ${videoCaps.codecInfo.isVendor}
+ supportedBitrate [${videoCaps.supportedBitrate.min}, ${videoCaps.supportedBitrate.max}]
+ supportedFormats ${videoCaps.supportedFormats}
+ supportedHeightAlignment ${videoCaps.supportedHeightAlignment}
+ supportedWidthAlignment ${videoCaps.supportedWidthAlignment}
+ supportedWidth [${videoCaps.supportedWidth.min}, ${videoCaps.supportedWidth.max}]
+ supportedHeight [${videoCaps.supportedHeight.min}, ${videoCaps.supportedHeight.max}]
+ supportedProfiles ${videoCaps.supportedProfiles}
+ supportedLevels ${videoCaps.supportedLevels}
+ supportedBitrateMode ${videoCaps.supportedBitrateMode}
+ supportedQuality [${videoCaps.supportedQuality.min}, ${videoCaps.supportedQuality.max}]
+ supportedComplexity [${videoCaps.supportedComplexity.min}, ${videoCaps.supportedComplexity.max}]
+ `);
+ await videoCaps.getPreferredFrameRate(width, height).then((valueRange) => {
+ console.info("case getPreferredFrameRate valueRange success");
+ if (typeof (valueRange) != 'undefined') {
+ console.info('getPreferredFrameRate.min: ' + valueRange.min);
+ console.info('getPreferredFrameRate.max: ' + valueRange.max);
+ } else {
+ console.info('case getPreferredFrameRate valueRange is not defined');
+ expect().assertFail();
+ }
+ }, failCallback).catch(failCatch);
+ await videoCaps.getSupportedFrameRate(width, height).then((valueRange) => {
+ console.info("case getSupportedFrameRate valueRange success");
+ if (typeof (valueRange) != 'undefined') {
+ console.info('getSupportedFrameRate.min: ' + valueRange.min);
+ console.info('getSupportedFrameRate.max: ' + valueRange.max);
+ } else {
+ console.info('case getSupportedFrameRate valueRange is not defined');
+ expect().assertFail();
+ }
+ }, failCallback).catch(failCatch);
+ await videoCaps.isSizeSupported(width, height).then((trueORfalse) => {
+ console.info("case isSizeSupported valueRange for width:" + width + ", height: " + height);
+ if (typeof (trueORfalse) != 'undefined') {
+ console.info('videoCaps.isSizeSupported: ' + trueORfalse);
+ } else {
+ console.info('case isSizeSupported is not defined');
+ expect().assertFail();
+ }
+ }, failCallback).catch(failCatch);
+ }
+
+ function toCreateStream() {
+ mediaTest = mediademo.createMediaTest();
+ }
+
+ function toSetStreamParam(width, height, framerate, frameTotal) {
+ console.info('case set stream parameter');
+ mediaTest.setResolution(width, height);
+ mediaTest.setFrameRate(framerate);
+ mediaTest.setFrameCount(frameTotal);
+ }
+
+ async function toGetInputSurface() {
+ await videoEncodeProcessor.getInputSurface().then((inputSurface) => {
+ expect(inputSurface != undefined).assertTrue();
+ console.info('case getInputSurface success');
+ surfaceID = inputSurface;
+ }, failCallback).catch(failCatch);
+ }
+
+ function toStartStream() {
+ console.info('case start stream');
+ mediaTest.startStream(surfaceID);
+ }
+
+ function toStopStream() {
+ console.info('case stop stream');
+ mediaTest.closeStream(surfaceID);
+ }
+
+ async function toConfigure(mediaDescription) {
+ await videoEncodeProcessor.configure(mediaDescription).then(() => {
+ console.info("case configure success");
+ }, failCallback).catch(failCatch);
+ }
+
+ async function toPrepare() {
+ await videoEncodeProcessor.prepare().then(() => {
+ console.info("case prepare success");
+ }, failCallback).catch(failCatch);
+ }
+
+ async function toStart() {
+ await videoEncodeProcessor.start().then(() => {
+ console.info("case start success");
+ }, failCallback).catch(failCatch);
+ }
+
+ async function toFlush() {
+ outputQueue = [];
+ await videoEncodeProcessor.flush().then(() => {
+ console.info("case flush success");
+ }, failCallback).catch(failCatch);
+ }
+
+ async function toStop() {
+ await videoEncodeProcessor.stop().then(() => {
+ console.info("case stop success");
+ }, failCallback).catch(failCatch);
+ }
+
+ async function toReset() {
+ resetParam();
+ await videoEncodeProcessor.reset().then(() => {
+ console.info("case reset success");
+ }, failCallback).catch(failCatch);
+ }
+
+ async function toRelease() {
+ resetParam();
+ await videoEncodeProcessor.release().then(() => {
+ console.info("case release success");
+ videoEncodeProcessor = null;
+ }, failCallback).catch(failCatch);
+ }
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_PROMISE_00_0100
+ * @tc.name : 000.test stop after last frame and reset
+ * @tc.desc : basic encode function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_PROMISE_00_0100', 0, async function (done) {
+ console.info("case test stop after last frame");
+ let savepath = BASIC_PATH + '0000.es';
+ let name= 'avenc_mpeg4';
+ let width = 720;
+ let height = 480;
+ let framerate = 60;
+ let mediaDescription = {
+ "codec_mime": 'video/mp4v-es',
+ "width": width,
+ "height": height,
+ "pixel_format": 3,
+ "frame_rate" : framerate,
+ }
+ await media.getMediaCapability().then((mediaCaps) => {
+ console.info('getMediaCapability success');
+ if (typeof (mediaCaps) != 'undefined') {
+ mediaCaps.getVideoEncoderCaps().then((videoCapsArray) => {
+ console.info('getVideoEncoderCaps from media success');
+ if (typeof (videoCapsArray) != 'undefined') {
+ let videoCaps = videoCapsArray[0];
+ console.info('print first videoCaps from videoCapsArray');
+ printVideoCaps(videoCaps, width, height);
+ } else {
+ console.info("case videoCapsArray is not defined");
+ expect().assertFail();
+ done();
+ }
+ }, failCallback).catch(failCatch);
+ mediaCaps.findVideoEncoder(mediaDescription).then((codecname) => {
+ console.info('findVideoEncoder success');
+ if (typeof (codecname) != 'undefined') {
+ console.info("case codecname " + codecname);
+ } else {
+ console.info("case codecname is not defined");
+ expect().assertFail();
+ done();
+ }
+ }, failCallback).catch(failCatch);
+ } else {
+ console.info('mediaCaps is not defined');
+ expect().assertFail();
+ done();
+ }
+ }, failCallback).catch(failCatch);
+ await toCreateByName(name, done);
+ await toGetVideoEncoderCaps(width, height);
+ toCreateStream();
+ toSetStreamParam(width, height, framerate, frameTotal);
+ await toConfigure(mediaDescription);
+ setCallback(savepath, done);
+ await toGetInputSurface();
+ await toPrepare();
+ toStartStream();
+ await toStart();
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_PROMISE_01_0100
+ * @tc.name : 001.test stop at runnning state and reset
+ * @tc.desc : basic encode function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level1
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_PROMISE_01_0100', 0, async function (done) {
+ console.info("case test stop at runnning state and reset");
+ let savepath = BASIC_PATH + '0100.es';
+ let mime = 'video/mp4v-es';
+ let width = 720;
+ let height = 480;
+ let framerate = 60;
+ let mediaDescription = {
+ "width": width,
+ "height": height,
+ "pixel_format": 3,
+ "frame_rate" : framerate,
+ }
+ await toCreateByMime(mime, done);
+ await toGetVideoEncoderCaps(width, height);
+ toCreateStream();
+ toSetStreamParam(width, height, framerate, frameTotal);
+ await toConfigure(mediaDescription);
+ setCallback(savepath, done);
+ await toGetInputSurface();
+ await toPrepare();
+ toStartStream();
+ await toStart();
+ await sleep(1000);
+ await toStop();
+ toStopStream();
+ await toReset();
+ await toRelease();
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_PROMISE_01_0200
+ * @tc.name : 002.test stop at end of stream and restart
+ * @tc.desc : basic encode function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level1
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_PROMISE_01_0200', 0, async function (done) {
+ console.info("test stop at end of stream and restart");
+ let savepath = BASIC_PATH + '0200.es';
+ let mime = 'video/mp4v-es';
+ let width = 720;
+ let height = 480;
+ let framerate = 60;
+ let mediaDescription = {
+ "width": width,
+ "height": height,
+ "pixel_format": 3,
+ "frame_rate" : framerate,
+ }
+ frameTotal = 10;
+ stopAtEOS = true;
+ await toCreateByMime(mime, done);
+ await toGetVideoEncoderCaps(width, height);
+ toCreateStream();
+ toSetStreamParam(width, height, framerate, frameTotal);
+ await toConfigure(mediaDescription);
+ setCallback(savepath, done);
+ await toGetInputSurface();
+ await toPrepare();
+ toStartStream();
+ await toStart();
+ await sleep(5000);
+ resetParam();
+ toSetStreamParam(width, height, framerate, frameTotal);
+ await toStart();
+ toStartStream();
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_PROMISE_01_0300
+ * @tc.name : 003.test stop at running state and restart
+ * @tc.desc : basic encode function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level1
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_PROMISE_01_0300', 0, async function (done) {
+ console.info("test stop at runnning state and restart");
+ let savepath = BASIC_PATH + '0300.es';
+ let mime = 'video/mp4v-es';
+ let width = 720;
+ let height = 480;
+ let framerate = 60;
+ let mediaDescription = {
+ "width": width,
+ "height": height,
+ "pixel_format": 3,
+ "frame_rate" : framerate,
+ }
+ frameTotal = 1000;
+ await toCreateByMime(mime, done);
+ await toGetVideoEncoderCaps(width, height);
+ toCreateStream();
+ toSetStreamParam(width, height, framerate, frameTotal);
+ await toConfigure(mediaDescription);
+ setCallback(savepath, done);
+ await toGetInputSurface();
+ await toPrepare();
+ toStartStream();
+ await toStart();
+ await sleep(500);
+ toStopStream();
+ await toStop();
+ resetParam();
+ toSetStreamParam(width, height, framerate, frameTotal);
+ await toStart();
+ toStartStream();
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_PROMISE_01_0400
+ * @tc.name : 004.test flush at running state
+ * @tc.desc : basic encode function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level1
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_PROMISE_01_0400', 0, async function (done) {
+ console.info("case test flush at running state");
+ let savepath = BASIC_PATH + '0400.es';
+ let mime = 'video/mp4v-es';
+ let width = 720;
+ let height = 480;
+ let framerate = 60;
+ let mediaDescription = {
+ "width": width,
+ "height": height,
+ "pixel_format": 3,
+ "frame_rate" : framerate,
+ }
+ frameTotal = 1000;
+ await toCreateByMime(mime, done);
+ await toGetVideoEncoderCaps(width, height);
+ toCreateStream();
+ toSetStreamParam(width, height, framerate, frameTotal);
+ await toConfigure(mediaDescription);
+ setCallback(savepath, done);
+ await toGetInputSurface();
+ await toPrepare();
+ toStartStream();
+ await toStart();
+ await sleep(1000);
+ await toFlush();
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_PROMISE_01_0500
+ * @tc.name : 005.test flush at end of stream
+ * @tc.desc : basic encode function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level1
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_PROMISE_01_0500', 0, async function (done) {
+ console.info("case test flush at end of stream");
+ let savepath = BASIC_PATH + '0500.es';
+ let mime = 'video/mp4v-es';
+ let width = 720;
+ let height = 480;
+ let framerate = 60;
+ let mediaDescription = {
+ "width": width,
+ "height": height,
+ "pixel_format": 3,
+ "frame_rate" : framerate,
+ }
+ flushAtEOS = true;
+ frameTotal = 10;
+ await toCreateByMime(mime, done);
+ await toGetVideoEncoderCaps(width, height);
+ toCreateStream();
+ toSetStreamParam(width, height, framerate, frameTotal);
+ await toConfigure(mediaDescription);
+ setCallback(savepath, done);
+ await toGetInputSurface();
+ await toPrepare();
+ toStartStream();
+ await toStart();
+ await sleep(5000);
+ toStopStream();
+ resetParam();
+ toSetStreamParam(width, height, framerate, frameTotal);
+ toStartStream();
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_PROMISE_01_0600
+ * @tc.name : 006.test reconfigure
+ * @tc.desc : basic encode function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_PROMISE_01_0600', 0, async function (done) {
+ console.info("case test reconfigure");
+ let savepath = BASIC_PATH + '0600.es';
+ let mime = 'video/mp4v-es';
+ let width = 720;
+ let height = 480;
+ let framerate = 60;
+ let mediaDescription = {
+ "width": width,
+ "height": height,
+ "pixel_format": 3,
+ "frame_rate" : framerate,
+ }
+ resetAtEOS = true;
+ frameTotal = 10;
+ await toCreateByMime(mime, done);
+ await toGetVideoEncoderCaps(width, height);
+ toCreateStream();
+ toSetStreamParam(width, height, framerate, frameTotal);
+ await toConfigure(mediaDescription);
+ setCallback(savepath, done);
+ await toGetInputSurface();
+ await toPrepare();
+ toStartStream();
+ await toStart();
+ await sleep(5000);
+ toStopStream();
+ resetParam();
+ width = 720;
+ height = 480;
+ framerate = 30;
+ let mediaDescription2 = {
+ "width": width,
+ "height": height,
+ "pixel_format": 3,
+ "frame_rate" : framerate,
+ }
+ let savepath2 = BASIC_PATH + '0601.es';
+ toSetStreamParam(width, height, framerate, frameTotal);
+ await toConfigure(mediaDescription2);
+ setCallback(savepath2, done);
+ await toGetInputSurface();
+ await toPrepare();
+ toStartStream();
+ await toStart();
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_PROMISE_01_0700
+ * @tc.name : 007.test recreate videoencoder
+ * @tc.desc : basic encode function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_PROMISE_01_0700', 0, async function (done) {
+ console.info("case test recreate videoencoder");
+ let savepath = BASIC_PATH + '0700.es';
+ let mime = 'video/mp4v-es';
+ let width = 720;
+ let height = 480;
+ let framerate = 60;
+ let mediaDescription = {
+ "width": width,
+ "height": height,
+ "pixel_format": 3,
+ "frame_rate" : framerate,
+ }
+ resetAtEOS = true;
+ frameTotal = 10;
+ await toCreateByMime(mime, done);
+ await toGetVideoEncoderCaps(width, height);
+ toCreateStream();
+ toSetStreamParam(width, height, framerate, frameTotal);
+ await toConfigure(mediaDescription);
+ setCallback(savepath, done);
+ await toGetInputSurface();
+ await toPrepare();
+ toStartStream();
+ await toStart();
+ await sleep(5000);
+ toStopStream();
+ await toRelease();
+ resetParam();
+ width = 720;
+ height = 480;
+ framerate = 30;
+ let mediaDescription2 = {
+ "width": width,
+ "height": height,
+ "pixel_format": 3,
+ "frame_rate" : framerate,
+ }
+ let savepath2 = BASIC_PATH + '0701.es';
+ await toCreateByMime(mime, done);
+ toSetStreamParam(width, height, framerate, frameTotal);
+ await toConfigure(mediaDescription2);
+ setCallback(savepath2, done);
+ await toGetInputSurface();
+ await toPrepare();
+ toStartStream();
+ await toStart();
+ })
+})
+
diff --git a/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareReliabilityCallbackTest.test.js b/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareReliabilityCallbackTest.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..22a1a04d6b3f31b31c766c1923bd0267f952c1f9
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareReliabilityCallbackTest.test.js
@@ -0,0 +1,1542 @@
+/*
+ * Copyright (C) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import media from '@ohos.multimedia.media'
+import mediademo from '@ohos.multimedia.mediademo'
+import Fileio from '@ohos.fileio'
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
+export
+const ENCODE_STEP = {
+ WAIT_FOR_EOS : 'encode:waitForEOS',
+ CONFIGURE : 'encode:configure',
+ GET_INPUTSURFACE : 'encode:getSurface',
+ PREPARE : 'encode:prepare',
+ START : 'encode:start',
+ FLUSH : 'encode:flush',
+ STOP : 'encode:stop',
+ RESET : 'encode:reset',
+ WAIT_FOR_ALL_OUTS : 'encode:waitForAllOuts',
+ ERROR : 'encode:error',
+ RELEASE : 'encode:release',
+}
+const STREAM_STEP = {
+ CREATE : 'stream:create',
+ PREPARE : 'stream:prepare',
+ SET_PARAM: 'stream:setParam',
+ SET_EOS_FRAME: 'stream:setEOSFrame',
+ START : 'stream:start',
+ STOP : 'stream:stop',
+}
+describe('VideoEncoderSoftwareReliCallbackTest', function () {
+ let videoEncodeProcessor = null;
+ let mediaTest = null;
+ let surfaceID = '';
+ let frameCountOut = 0;
+ let outputQueue = [];
+ let frameTotal = 100;
+ let finalFrameId = 100;
+ let isStreamRunning = false;
+ let workdoneAtEOS = false;
+ let stopBuffer = false;
+ const BASIC_PATH = '/data/media/results/';
+ let mediaDescription = {
+ 'width': 720,
+ 'height': 480,
+ 'pixel_format': 3,
+ 'frame_rate': 60,
+ }
+ beforeAll(function() {
+ console.info('beforeAll case');
+ })
+
+ beforeEach(async function() {
+ console.info('beforeEach case');
+ videoEncodeProcessor = null;
+ mediaTest = null;
+ surfaceID = '';
+ frameCountOut = 0;
+ outputQueue = [];
+ workdoneAtEOS = false;
+ frameTotal = 100;
+ finalFrameId = 100;
+ isStreamRunning = false;
+ stopBuffer = false;
+ })
+
+ afterEach(async function() {
+ console.info('afterEach case');
+ if (videoEncodeProcessor != null) {
+ await videoEncodeProcessor.release().then(() => {
+ console.info('in case : videoEncodeProcessor release success');
+ }, failCallback).catch(failCatch);
+ videoEncodeProcessor = null;
+ }
+ toStopStream();
+ })
+
+ afterAll(function() {
+ console.info('afterAll case');
+ })
+ let failCallback = function(err) {
+ console.error(`in case error failCallback called, errMessage is ${err.message}`);
+ expect(err == undefined).assertTrue();
+ }
+ let failCatch = function(err) {
+ console.error(`in case error failCatch called,errMessage is ${err.message}`);
+ expect(err == undefined).assertTrue();
+ }
+ function printError(err, expectFail) {
+ expect((err != undefined) == expectFail).assertTrue();
+ if (expectFail == false && err != undefined) {
+ console.error('in case error failCatch called,err is ' + err);
+ console.error(`in case error failCatch called,errMessage is ${err.message}`);
+ }
+ }
+ function writeFile(path, buf, len){
+ try {
+ let writestream = Fileio.createStreamSync(path, 'ab+');
+ let num = writestream.writeSync(buf, {length:len});
+ writestream.flushSync();
+ writestream.closeSync();
+ } catch(e) {
+ console.error('in case error writeFile: ' + e);
+ }
+ }
+
+ /* get outputbuffers from codec */
+ async function dequeueOutputs(path, nextStep) {
+ console.log('outputQueue.length:' + outputQueue.length);
+ while (outputQueue.length > 0){
+ let outputObject = outputQueue.shift();
+ if (outputObject.flags == 1 || frameCountOut == frameTotal) {
+ if (workdoneAtEOS) {
+ doneWork(nextStep);
+ }
+ return;
+ }
+ frameCountOut++;
+ writeFile(path, outputObject.data, outputObject.length);
+ videoEncodeProcessor.releaseOutput(outputObject, (err) => {
+ if (typeof(err) == 'undefined') {
+ console.debug('in case release output count:' + frameCountOut);
+ } else {
+ console.info(`in case release output called,errMessage is ${err.message}`);
+ }
+ })
+ }
+ }
+ function printDescription(obj) {
+ for (let item in obj) {
+ let property = obj[item];
+ console.info('video encoder key is ' + item);
+ console.info('video encoder value is ' + property);
+ }
+ }
+ function setCallback(path, nextStep) {
+ videoEncodeProcessor.on('outputBufferAvailable', async (outBuffer) => {
+ console.info('in case: outputBufferAvailable outBuffer.index: '+ outBuffer.index);
+ if (stopBuffer == false) {
+ outputQueue.push(outBuffer);
+ dequeueOutputs(path, nextStep);
+ }
+ });
+
+ videoEncodeProcessor.on('error',(err) => {
+ console.info('in case: error called,errName is' + err);
+ });
+
+ videoEncodeProcessor.on('outputFormatChanged', (format) => {
+ if (typeof(format) != undefined) {
+ printDescription(format);
+ }
+ });
+ }
+ function toCreateStream(mySteps, done) {
+ mediaTest = mediademo.createMediaTest();
+ toNextStep(mySteps, done);
+ }
+ function toSetStreamParam(mySteps, done) {
+ mediaTest.setResolution(mediaDescription.width, mediaDescription.height);
+ mediaTest.setFrameRate(mediaDescription.frame_rate);
+ toNextStep(mySteps, done);
+ }
+ function toSetEOSFrame(mySteps, done) {
+ mediaTest.setFrameCount(frameTotal);
+ toNextStep(mySteps, done);
+ }
+ function toStartStream(mySteps, done) {
+ if (isStreamRunning == false) {
+ console.info('in case : toStartStream');
+ mediaTest.startStream(surfaceID);
+ isStreamRunning = true;
+ }
+ toNextStep(mySteps, done);
+ }
+
+ function toStopStream(mySteps, done) {
+ if (isStreamRunning == true) {
+ console.info('in case : toStopStream');
+ mediaTest.closeStream(surfaceID);
+ isStreamRunning = false;
+ }
+ toNextStep(mySteps, done);
+ }
+ function toConfigure(mySteps, done, expectFail) {
+ videoEncodeProcessor.configure(mediaDescription, (err) => {
+ console.info(`case configure callback`);
+ printError(err, expectFail);
+ toNextStep(mySteps, done);
+ })
+ }
+ function toGetInputSurface(mySteps, done, expectFail) {
+ videoEncodeProcessor.getInputSurface((err, inputSurface) => {
+ expect(err).assertUndefined();
+ expect(inputSurface != undefined).assertTrue();
+ printError(err, expectFail);
+ surfaceID = inputSurface;
+ console.info('in case : getInputSurface success, surfaceID ' + surfaceID);
+ toNextStep(mySteps, done);
+ })
+ }
+ function toPrepare(mySteps, done, expectFail) {
+ videoEncodeProcessor.prepare((err) => {
+ console.info(`case prepare callback`);
+ printError(err, expectFail);
+ toNextStep(mySteps, done);
+ });
+ }
+ function toStart(mySteps, done, expectFail) {
+ videoEncodeProcessor.start((err) => {
+ console.info(`case start callback`);
+ printError(err, expectFail);
+ toNextStep(mySteps, done);
+ });
+ stopBuffer = false;
+ }
+ function toStop(mySteps, done, expectFail) {
+ videoEncodeProcessor.stop((err) => {
+ console.info(`case stop callback`);
+ printError(err, expectFail);
+ toNextStep(mySteps, done);
+ });
+ stopBuffer = true;
+ }
+ function toFlush(mySteps, done, expectFail) {
+ videoEncodeProcessor.flush((err) => {
+ console.info(`case flush callback`);
+ printError(err, expectFail);
+ toNextStep(mySteps, done);
+ });
+ }
+ function toReset(mySteps, done, expectFail) {
+ videoEncodeProcessor.reset((err) => {
+ console.info(`case reset callback`);
+ printError(err, expectFail);
+ toNextStep(mySteps, done);
+ });
+ }
+ function runCase(mySteps, nextCase, done) {
+ if (mySteps[0] == ENCODE_STEP.ERROR) {
+ mySteps.shift();
+ nextCase(mySteps, done, true);
+ } else {
+ nextCase(mySteps, done, false);
+ }
+ }
+ function toNextStep(mySteps, done) {
+ console.info('case myStep[0]: ' + mySteps[0]);
+ if (mySteps[0] == ENCODE_STEP.RELEASE) {
+ if (videoEncodeProcessor != null){
+ videoEncodeProcessor.release((err) => {
+ printError(err, false);
+ console.info('in case : videoEncodeProcessor release callback');
+ videoEncodeProcessor = null;
+ console.info('case to done');
+ done();
+ });
+ }
+ return;
+ }
+ switch (mySteps[0]) {
+ case ENCODE_STEP.CONFIGURE:
+ mySteps.shift();
+ console.info(`case to configure`);
+ runCase(mySteps, toConfigure, done);
+ break;
+ case STREAM_STEP.CREATE:
+ mySteps.shift();
+ console.info(`case to createStream`);
+ toCreateStream(mySteps, done);
+ break;
+ case STREAM_STEP.SET_PARAM:
+ mySteps.shift();
+ console.info(`case to SetStreamParam`);
+ toSetStreamParam(mySteps, done);
+ break;
+ case STREAM_STEP.SET_EOS_FRAME:
+ mySteps.shift();
+ console.info(`case to SetEOSFrame`);
+ toSetEOSFrame(mySteps, done);
+ break;
+ case STREAM_STEP.START:
+ mySteps.shift();
+ console.info(`case to StartStream`);
+ toStartStream(mySteps, done);
+ break;
+ case STREAM_STEP.STOP:
+ mySteps.shift();
+ console.info(`case to StoptStream`);
+ toStopStream(mySteps, done);
+ break;
+ case ENCODE_STEP.GET_INPUTSURFACE:
+ mySteps.shift();
+ console.info(`case to setOutputSurface`);
+ runCase(mySteps, toGetInputSurface, done);
+ break;
+ case ENCODE_STEP.PREPARE:
+ mySteps.shift();
+ console.info(`case to prepare`);
+ runCase(mySteps, toPrepare, done);
+ break;
+ case ENCODE_STEP.START:
+ mySteps.shift();
+ console.info(`case to start`);
+ runCase(mySteps, toStart, done);
+ break;
+ case ENCODE_STEP.FLUSH:
+ mySteps.shift();
+ console.info(`case to flush`);
+ runCase(mySteps, toFlush, done);
+ break;
+ case ENCODE_STEP.STOP:
+ mySteps.shift();
+ console.info(`case to stop`);
+ runCase(mySteps, toStop, done);
+ break;
+ case ENCODE_STEP.RESET:
+ mySteps.shift();
+ console.info(`case to reset`);
+ runCase(mySteps, toReset, done);
+ break;
+ case ENCODE_STEP.WAIT_FOR_EOS:
+ mySteps.shift();
+ setTimeout(() =>{
+ toNextStep(mySteps, done);
+ }, 5000); // wait 5000 ms for eos
+ break;
+ case ENCODE_STEP.WAIT_FOR_ALL_OUTS:
+ mySteps.shift();
+ console.info(`case wait for all outputs`);
+ break;
+ default:
+ break;
+ }
+ }
+
+ function toCreateVideoEncoderByMime(mime, path, mySteps, done) {
+ media.createVideoEncoderByMime(mime, (err, processor) => {
+ console.info(`case createVideoEncoderByMime callback`);
+ printError(err, false);
+ if (typeof(processor) != 'undefined') {
+ videoEncodeProcessor = processor;
+ setCallback(path, done);
+ toNextStep(mySteps, done);
+ } else {
+ done();
+ }
+ })
+ }
+ function toCreateVideoEncoderByName(name, path, mySteps, done) {
+ media.createVideoEncoderByName(name, (err, processor) => {
+ printError(err, false);
+ if (typeof(processor) != 'undefined') {
+ videoEncodeProcessor = processor;
+ setCallback(path, done);
+ toNextStep(mySteps, done);
+ } else {
+ done();
+ }
+ })
+ }
+ async function doneWork(nextStep) {
+ videoEncodeProcessor.stop((err) => {
+ printError(err, false);
+ console.info('case stop callback');
+ mediaTest.closeStream(surfaceID);
+ videoEncodeProcessor.reset((err) => {
+ printError(err, false);
+ console.info('case reset callback');
+ videoEncodeProcessor.release((err) => {
+ printError(err, false);
+ console.info('case release callback');
+ videoEncodeProcessor = null;
+ nextStep();
+ })
+ })
+ })
+ }
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_CALLBACK_0100
+ * @tc.name : 001.create -> configure
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability test
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_CALLBACK_0100', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_CALLBACK_0100.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_CALLBACK_0200
+ * @tc.name : 002.prepare -> configure
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability test
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_CALLBACK_0200', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_CALLBACK_0200.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START, ENCODE_STEP.PREPARE,
+ ENCODE_STEP.CONFIGURE, ENCODE_STEP.ERROR, STREAM_STEP.STOP, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_CALLBACK_0300
+ * @tc.name : 003.start -> configure
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability test
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_CALLBACK_0300', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_CALLBACK_0300.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START, ENCODE_STEP.PREPARE,
+ ENCODE_STEP.START, ENCODE_STEP.CONFIGURE, ENCODE_STEP.ERROR, STREAM_STEP.STOP, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_CALLBACK_0400
+ * @tc.name : 004.flush -> configure
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability test
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_CALLBACK_0400', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_CALLBACK_0400.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START, ENCODE_STEP.PREPARE,
+ ENCODE_STEP.START, ENCODE_STEP.FLUSH, ENCODE_STEP.CONFIGURE, ENCODE_STEP.ERROR, STREAM_STEP.STOP,
+ ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_CALLBACK_0500
+ * @tc.name : 005.stop -> configure
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability test
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_CALLBACK_0500', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_CALLBACK_0500.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START, ENCODE_STEP.PREPARE,
+ ENCODE_STEP.START, ENCODE_STEP.STOP, ENCODE_STEP.CONFIGURE, ENCODE_STEP.ERROR, STREAM_STEP.STOP,
+ ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_CALLBACK_0600
+ * @tc.name : 006.EOS -> configure
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability test
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_CALLBACK_0600', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_CALLBACK_0600.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START, ENCODE_STEP.PREPARE,
+ ENCODE_STEP.START, ENCODE_STEP.WAIT_FOR_EOS, ENCODE_STEP.CONFIGURE, ENCODE_STEP.ERROR,
+ STREAM_STEP.STOP, ENCODE_STEP.RELEASE);
+ frameTotal = 50;
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_CALLBACK_0700
+ * @tc.name : 007.reset -> configure
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability test
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_CALLBACK_0700', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_CALLBACK_0700.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START, ENCODE_STEP.PREPARE,
+ ENCODE_STEP.START, ENCODE_STEP.RESET, STREAM_STEP.STOP, ENCODE_STEP.CONFIGURE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START, ENCODE_STEP.PREPARE,
+ ENCODE_STEP.START, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_CALLBACK_0800
+ * @tc.name : 008.configure -> configure
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability test
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_CALLBACK_0800', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_CALLBACK_0800.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START, ENCODE_STEP.CONFIGURE,
+ ENCODE_STEP.ERROR, ENCODE_STEP.PREPARE, ENCODE_STEP.START, STREAM_STEP.STOP, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_CALLBACK_0900
+ * @tc.name : 009.configure -> reset -> configure
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability test
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_CALLBACK_0900', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_CALLBACK_0900.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START, ENCODE_STEP.PREPARE,
+ ENCODE_STEP.START, ENCODE_STEP.RESET, STREAM_STEP.STOP, ENCODE_STEP.CONFIGURE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START, ENCODE_STEP.PREPARE,
+ ENCODE_STEP.START, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_CALLBACK_0100
+ * @tc.name : 001.create -> prepare
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_CALLBACK_0100', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_CALLBACK_0100.es';
+ let mySteps = new Array(ENCODE_STEP.PREPARE, ENCODE_STEP.ERROR, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_CALLBACK_0200
+ * @tc.name : 002.configure -> prepare
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_CALLBACK_0200', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_CALLBACK_0200.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, STREAM_STEP.STOP, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_CALLBACK_0300
+ * @tc.name : 003.prepare -> prepare
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_CALLBACK_0300', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_CALLBACK_0300.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START, ENCODE_STEP.PREPARE,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.ERROR, ENCODE_STEP.START, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_CALLBACK_0400
+ * @tc.name : 004.start -> prepare
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_CALLBACK_0400', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_CALLBACK_0400.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.PREPARE, ENCODE_STEP.ERROR,
+ ENCODE_STEP.RESET, STREAM_STEP.STOP, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_CALLBACK_0500
+ * @tc.name : 005.flush -> prepare
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_CALLBACK_0500', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_CALLBACK_0500.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.FLUSH, ENCODE_STEP.PREPARE,
+ ENCODE_STEP.ERROR, ENCODE_STEP.RESET, STREAM_STEP.STOP, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_CALLBACK_0600
+ * @tc.name : 006.stop -> prepare
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_CALLBACK_0600', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_CALLBACK_0600.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.STOP, ENCODE_STEP.PREPARE,
+ ENCODE_STEP.ERROR, ENCODE_STEP.RESET, STREAM_STEP.STOP, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_CALLBACK_0700
+ * @tc.name : 007.EOS -> prepare
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_CALLBACK_0700', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_CALLBACK_0700.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.WAIT_FOR_EOS, ENCODE_STEP.PREPARE,
+ ENCODE_STEP.ERROR, STREAM_STEP.STOP, ENCODE_STEP.RELEASE);
+ frameTotal = 50;
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_CALLBACK_0800
+ * @tc.name : 008.reset -> prepare
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_CALLBACK_0800', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_CALLBACK_0800.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.RESET, ENCODE_STEP.PREPARE,
+ ENCODE_STEP.ERROR, ENCODE_STEP.RESET, STREAM_STEP.STOP, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_CALLBACK_0100
+ * @tc.name : 001.create -> start
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_CALLBACK_0100', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_CALLBACK_0100.es';
+ let mySteps = new Array(ENCODE_STEP.START, ENCODE_STEP.ERROR, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_CALLBACK_0200
+ * @tc.name : 002.configure -> start
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_CALLBACK_0200', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_CALLBACK_0200.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START, ENCODE_STEP.START,
+ ENCODE_STEP.ERROR, STREAM_STEP.STOP, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_CALLBACK_0300
+ * @tc.name : 003.prepare -> start
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_CALLBACK_0300', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_CALLBACK_0300.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_CALLBACK_0400
+ * @tc.name : 004.start -> start
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_CALLBACK_0400', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_CALLBACK_0400.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.START, ENCODE_STEP.ERROR, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_CALLBACK_0500
+ * @tc.name : 005.flush -> start
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_CALLBACK_0500', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_CALLBACK_0500.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START, ENCODE_STEP.PREPARE,
+ ENCODE_STEP.START, ENCODE_STEP.FLUSH, ENCODE_STEP.START, ENCODE_STEP.ERROR, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_CALLBACK_0600
+ * @tc.name : 006.stop -> start
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_CALLBACK_0600', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_CALLBACK_0600.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.STOP, ENCODE_STEP.START, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_CALLBACK_0700
+ * @tc.name : 007.EOS -> start
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_CALLBACK_0700', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_CALLBACK_0700.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.WAIT_FOR_EOS, ENCODE_STEP.START,
+ ENCODE_STEP.ERROR, ENCODE_STEP.RELEASE);
+ frameTotal = 50;
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_CALLBACK_0800
+ * @tc.name : 008.reset -> start
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_CALLBACK_0800', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_CALLBACK_0800.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.RESET, ENCODE_STEP.START,
+ ENCODE_STEP.ERROR, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_CALLBACK_0100
+ * @tc.name : 001.create -> flush
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_CALLBACK_0100', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_CALLBACK_0100.es';
+ let mySteps = new Array(ENCODE_STEP.FLUSH, ENCODE_STEP.ERROR, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_CALLBACK_0200
+ * @tc.name : 002.configure -> flush
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_CALLBACK_0200', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_CALLBACK_0200.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE,
+ STREAM_STEP.START, ENCODE_STEP.FLUSH, ENCODE_STEP.ERROR, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_CALLBACK_0300
+ * @tc.name : 003.prepare -> flush
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_CALLBACK_0300', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_CALLBACK_0300.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.FLUSH, ENCODE_STEP.ERROR, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_CALLBACK_0400
+ * @tc.name : 004.start -> flush
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_CALLBACK_0400', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_CALLBACK_0400.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.FLUSH, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_CALLBACK_0500
+ * @tc.name : 005.flush -> flush
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_CALLBACK_0500', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_CALLBACK_0500.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.FLUSH, ENCODE_STEP.FLUSH, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_CALLBACK_0600
+ * @tc.name : 006.stop -> flush
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_CALLBACK_0600', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_CALLBACK_0600.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.STOP , ENCODE_STEP.FLUSH,
+ ENCODE_STEP.ERROR, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_CALLBACK_0700
+ * @tc.name : 007.EOS -> flush
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_CALLBACK_0700', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_CALLBACK_0700.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.WAIT_FOR_EOS, ENCODE_STEP.FLUSH,
+ ENCODE_STEP.RELEASE);
+ frameTotal = 50;
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_CALLBACK_0800
+ * @tc.name : 008.reset -> flush
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_CALLBACK_0800', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_CALLBACK_0800.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.RESET, ENCODE_STEP.FLUSH,
+ ENCODE_STEP.ERROR, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_CALLBACK_0100
+ * @tc.name : 001.create -> stop
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_CALLBACK_0100', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_CALLBACK_0100.es';
+ let mySteps = new Array(ENCODE_STEP.STOP, ENCODE_STEP.ERROR, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_CALLBACK_0200
+ * @tc.name : 002.configure -> stop
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_CALLBACK_0200', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_CALLBACK_0200.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, STREAM_STEP.START, ENCODE_STEP.STOP, ENCODE_STEP.ERROR, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_CALLBACK_0300
+ * @tc.name : 003.prepare -> stop
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_CALLBACK_0300', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_CALLBACK_0300.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.STOP, ENCODE_STEP.ERROR, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_CALLBACK_0400
+ * @tc.name : 004.start -> stop
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_CALLBACK_0400', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_CALLBACK_0400.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.STOP, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_CALLBACK_0500
+ * @tc.name : 005.flush -> stop
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_CALLBACK_0500', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_CALLBACK_0500.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.FLUSH, ENCODE_STEP.STOP,
+ ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_CALLBACK_0600
+ * @tc.name : 006.stop -> stop
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_CALLBACK_0600', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_CALLBACK_0600.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.STOP, ENCODE_STEP.STOP, ENCODE_STEP.ERROR,
+ ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_CALLBACK_0700
+ * @tc.name : 007.EOS -> stop
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_CALLBACK_0700', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_CALLBACK_0700.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.WAIT_FOR_EOS, ENCODE_STEP.STOP,
+ ENCODE_STEP.RELEASE);
+ frameTotal = 50;
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_CALLBACK_0800
+ * @tc.name : 008.reset -> stop
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_CALLBACK_0800', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_CALLBACK_0800.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.RESET, ENCODE_STEP.STOP, ENCODE_STEP.ERROR,
+ ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_CALLBACK_0100
+ * @tc.name : 001.create -> reset
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_CALLBACK_0100', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_CALLBACK_0100.es';
+ let mySteps = new Array(ENCODE_STEP.RESET, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_CALLBACK_0200
+ * @tc.name : 002.configure -> reset
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_CALLBACK_0200', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_CALLBACK_0200.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE,
+ STREAM_STEP.START, ENCODE_STEP.RESET, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_CALLBACK_0300
+ * @tc.name : 003.prepare -> reset
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_CALLBACK_0300', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_CALLBACK_0300.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.RESET, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_CALLBACK_0400
+ * @tc.name : 004.start -> reset
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_CALLBACK_0400', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_CALLBACK_0400.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.RESET, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_CALLBACK_0500
+ * @tc.name : 005.flush -> reset
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_CALLBACK_0500', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_CALLBACK_0500.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.FLUSH, ENCODE_STEP.RESET, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_CALLBACK_0600
+ * @tc.name : 006.stop -> reset
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_CALLBACK_0600', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_CALLBACK_0600.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.STOP, ENCODE_STEP.RESET, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_CALLBACK_0700
+ * @tc.name : 007.EOS -> reset
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_CALLBACK_0700', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_CALLBACK_0700.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.WAIT_FOR_EOS, ENCODE_STEP.RESET, ENCODE_STEP.RELEASE);
+ frameTotal = 50;
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_CALLBACK_0800
+ * @tc.name : 008.reset -> reset
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_CALLBACK_0800', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_CALLBACK_0800.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.RESET, ENCODE_STEP.RESET, ENCODE_STEP.RELEASE);
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_EOS_CALLBACK_0100
+ * @tc.name : 001.EOS -> flush -> stop
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_EOS_CALLBACK_0100', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_EOS_CALLBACK_0100.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.WAIT_FOR_EOS, ENCODE_STEP.FLUSH,
+ ENCODE_STEP.STOP, ENCODE_STEP.RELEASE);
+ frameTotal = 50;
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_EOS_CALLBACK_0200
+ * @tc.name : 002.EOS -> flush -> EOS
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_EOS_CALLBACK_0200', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_EOS_CALLBACK_0200.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.WAIT_FOR_EOS, ENCODE_STEP.FLUSH,
+ ENCODE_STEP.RELEASE);
+ frameTotal = 50;
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_EOS_CALLBACK_0300
+ * @tc.name : 003.EOS -> reset -> configure
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_EOS_CALLBACK_0300', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_EOS_CALLBACK_0300.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.WAIT_FOR_EOS, ENCODE_STEP.RESET,
+ ENCODE_STEP.CONFIGURE, STREAM_STEP.STOP, STREAM_STEP.SET_PARAM, STREAM_STEP.SET_EOS_FRAME,
+ STREAM_STEP.START, ENCODE_STEP.RELEASE);
+ frameTotal = 50;
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_EOS_CALLBACK_0400
+ * @tc.name : 004.EOS -> stop -> start -> EOS
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_EOS_CALLBACK_0400', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_EOS_CALLBACK_0400.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.WAIT_FOR_EOS, ENCODE_STEP.STOP,
+ ENCODE_STEP.START, ENCODE_STEP.RELEASE);
+ frameTotal = 50;
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_EOS_CALLBACK_0500
+ * @tc.name : 005.EOS -> stop -> start -> stop
+ * @tc.desc : test for state transition
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_EOS_CALLBACK_0500', 0, async function (done) {
+ let path = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_EOS_CALLBACK_0500.es';
+ let mySteps = new Array(ENCODE_STEP.CONFIGURE, STREAM_STEP.CREATE, STREAM_STEP.SET_PARAM,
+ STREAM_STEP.SET_EOS_FRAME, ENCODE_STEP.GET_INPUTSURFACE, STREAM_STEP.START,
+ ENCODE_STEP.PREPARE, ENCODE_STEP.START, ENCODE_STEP.WAIT_FOR_EOS, ENCODE_STEP.STOP,
+ ENCODE_STEP.START, ENCODE_STEP.STOP, ENCODE_STEP.RELEASE);
+ frameTotal = 50;
+ toCreateVideoEncoderByName('avenc_mpeg4', path, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE-RESET_CALLBACK_0100
+ * @tc.name : 001. configure -> reset for 50 times
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE-RESET_CALLBACK_0100', 0, async function (done) {
+ let name = 'avenc_mpeg4';
+ let events = require('events');
+ let eventEmitter = new events.EventEmitter();
+ let loopCnt = 0;
+ eventEmitter.on('configure', (mediaDescription) => {
+ videoEncodeProcessor.configure(mediaDescription, (err) => {
+ expect(err).assertUndefined();
+ console.info(`case configure 1`);
+ eventEmitter.emit('reset');
+ })
+ });
+ eventEmitter.on('reset', () => {
+ videoEncodeProcessor.reset((err) => {
+ expect(err).assertUndefined();
+ console.info(`case reset 1`);
+ loopCnt += 1;
+ if (loopCnt < 50) {
+ console.info('case configure-reset current loop: ' + loopCnt);
+ eventEmitter.emit('configure', mediaDescription);
+ } else {
+ videoEncodeProcessor.release((err) => {
+ expect(err).assertUndefined();
+ console.info('case release callback');
+ videoEncodeProcessor = null;
+ done();
+ })
+ }
+ })
+ });
+ media.createVideoEncoderByName(name, (err, processor) => {
+ expect(err).assertUndefined();
+ if (typeof(processor) != 'undefined') {
+ videoEncodeProcessor = processor;
+ eventEmitter.emit('configure', mediaDescription);
+ } else {
+ console.info('in case : createVideoEncoderByName fail');
+ expect().assertFail();
+ done();
+ }
+ })
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START-STOP_CALLBACK_0100
+ * @tc.name : 001. start -> stop for 50 times
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START-STOP_CALLBACK_0100', 0, async function (done) {
+ let name = 'avenc_mpeg4';
+ let events = require('events');
+ let eventEmitter = new events.EventEmitter();
+ let loopCnt = 0;
+ eventEmitter.on('configure', (mediaDescription) => {
+ videoEncodeProcessor.configure(mediaDescription, (err) => {
+ expect(err).assertUndefined();
+ console.info(`case configure 1`);
+ eventEmitter.emit('getInputSurface');
+ })
+ });
+ eventEmitter.on('getInputSurface', () => {
+ videoEncodeProcessor.getInputSurface((err, inputSurface) => {
+ expect(err).assertUndefined();
+ expect(inputSurface != undefined).assertTrue();
+ surfaceID = inputSurface;
+ console.info('in case : getInputSurface success, surfaceID ' + surfaceID);
+ eventEmitter.emit('prepare');
+ })
+ });
+ eventEmitter.on('prepare', () => {
+ videoEncodeProcessor.prepare((err) => {
+ expect(err).assertUndefined();
+ console.info('in case : prepare success');
+ eventEmitter.emit('start');
+ });
+ });
+ eventEmitter.on('start', () => {
+ videoEncodeProcessor.start((err) => {
+ expect(err).assertUndefined();
+ console.info('in case : start success');
+ eventEmitter.emit('stop');
+ });
+ });
+ eventEmitter.on('stop', () => {
+ videoEncodeProcessor.stop((err) => {
+ expect(err).assertUndefined();
+ console.info(`case stop 1`);
+ loopCnt += 1;
+ if (loopCnt < 50) {
+ console.info('case start-stop current loop: ' + loopCnt);
+ eventEmitter.emit('start');
+ } else {
+ videoEncodeProcessor.release((err) => {
+ expect(err).assertUndefined();
+ console.info('case release callback');
+ videoEncodeProcessor = null;
+ done();
+ })
+ }
+ })
+ });
+ media.createVideoEncoderByName(name, (err, processor) => {
+ expect(err).assertUndefined();
+ if (typeof(processor) != 'undefined') {
+ videoEncodeProcessor = processor;
+ eventEmitter.emit('configure', mediaDescription);
+ } else {
+ console.info('in case : createVideoEncoderByName fail');
+ expect().assertFail();
+ done();
+ }
+ })
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CREATE-RELEASE_CALLBACK_0100
+ * @tc.name : 001. create -> release for 50 times
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CREATE-RELEASE_CALLBACK_0100', 0, async function (done) {
+ let name = 'avenc_mpeg4';
+ let events = require('events');
+ let eventEmitter = new events.EventEmitter();
+ let loopCnt = 0;
+ eventEmitter.on('create', (name) => {
+ media.createVideoEncoderByName(name, (err, processor) => {
+ expect(err).assertUndefined();
+ if (typeof(processor) != 'undefined') {
+ videoEncodeProcessor = processor;
+ eventEmitter.emit('release');
+ } else {
+ console.info('in case : createVideoEncoderByName fail');
+ expect().assertFail();
+ done();
+ }
+ })
+ })
+ eventEmitter.on('release', () => {
+ videoEncodeProcessor.release((err) => {
+ expect(err).assertUndefined();
+ console.info(`case release 1`);
+ videoEncodeProcessor = null;
+ loopCnt += 1;
+ if (loopCnt < 50) {
+ console.info('case create-release current loop: ' + loopCnt);
+ eventEmitter.emit('create', name);
+ } else {
+ done();
+ }
+ })
+ })
+ eventEmitter.emit('create', name);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_TOOPLOOP_CALLBACK_0100
+ * @tc.name : 001. total loop for 50 times
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CREATE-RELEASE_CALLBACK_0100', 0, async function (done) {
+ let name = 'avenc_mpeg4';
+ let events = require('events');
+ let eventEmitter = new events.EventEmitter();
+ let loopCnt = 0;
+ eventEmitter.on('create', (name) => {
+ media.createVideoEncoderByName(name, (err, processor) => {
+ expect(err).assertUndefined();
+ if (typeof(processor) != 'undefined') {
+ videoEncodeProcessor = processor;
+ eventEmitter.emit('configure', mediaDescription);
+ } else {
+ console.info('in case : createVideoEncoderByName fail');
+ expect().assertFail();
+ done();
+ }
+ })
+ })
+ eventEmitter.on('configure', (mediaDescription) => {
+ videoEncodeProcessor.configure(mediaDescription, (err) => {
+ expect(err).assertUndefined();
+ console.info(`case configure 1`);
+ eventEmitter.emit('getInputSurface');
+ })
+ });
+ eventEmitter.on('getInputSurface', () => {
+ videoEncodeProcessor.getInputSurface((err, inputSurface) => {
+ expect(err).assertUndefined();
+ expect(inputSurface != undefined).assertTrue();
+ surfaceID = inputSurface;
+ console.info('in case : getInputSurface success, surfaceID ' + surfaceID);
+ eventEmitter.emit('prepare');
+ })
+ });
+ eventEmitter.on('prepare', () => {
+ videoEncodeProcessor.prepare((err) => {
+ expect(err).assertUndefined();
+ console.info('in case : prepare success');
+ eventEmitter.emit('start');
+ });
+ });
+ eventEmitter.on('start', () => {
+ videoEncodeProcessor.start((err) => {
+ expect(err).assertUndefined();
+ console.info('in case : start success');
+ eventEmitter.emit('flush');
+ });
+ });
+ eventEmitter.on('flush', () => {
+ videoEncodeProcessor.flush((err) => {
+ expect(err).assertUndefined();
+ console.info('in case : flush success');
+ eventEmitter.emit('stop');
+ });
+ });
+ eventEmitter.on('stop', () => {
+ videoEncodeProcessor.stop((err) => {
+ expect(err).assertUndefined();
+ console.info('in case : stop success');
+ eventEmitter.emit('reset');
+ });
+ });
+ eventEmitter.on('reset', () => {
+ videoEncodeProcessor.reset((err) => {
+ expect(err).assertUndefined();
+ console.info('in case : reset success');
+ eventEmitter.emit('release');
+ });
+ });
+ eventEmitter.on('release', () => {
+ videoEncodeProcessor.release((err) => {
+ expect(err).assertUndefined();
+ console.info(`case release 1`);
+ videoEncodeProcessor = null;
+ loopCnt += 1;
+ if (loopCnt < 50) {
+ console.info('case create-release current loop: ' + loopCnt);
+ eventEmitter.emit('create', name);
+ } else {
+ done();
+ }
+ })
+ })
+ eventEmitter.emit('create', name);
+ })
+})
+
diff --git a/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareReliabilityPromiseTest.test.js b/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareReliabilityPromiseTest.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..e92722ff7ec1997856e669b2beccd36cc0ec504b
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareReliabilityPromiseTest.test.js
@@ -0,0 +1,1517 @@
+/*
+ * Copyright (C) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import media from '@ohos.multimedia.media'
+import mediademo from '@ohos.multimedia.mediademo'
+import Fileio from '@ohos.fileio'
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
+
+describe('videoEncoderReliability', function () {
+ const BASIC_PATH = '/data/media/results/videoencode_reli_promise_';
+ let videoEncodeProcessor;
+ let mediaTest = mediademo.createMediaTest();
+ let surfaceID = '';
+ let outputQueue = [];
+ let outputCnt = 0;
+ let frameTotal = 100;
+ let frameCountOut = 0;
+ let flushAtEOS = false;
+ let sawOutputEOS = false;
+ let needGetMediaDes = false;
+ let workdoneAtEOS = false;
+ const END = 0;
+ const CONFIGURE = 1;
+ const GETSURFACE = 2;
+ const SETSTREAMPARAM = 3;
+ const PREPARE = 4;
+ const STARTSTREAM = 5;
+ const STOPSTREAM = 6;
+ const START = 7;
+ const FLUSH = 8;
+ const STOP = 9;
+ const RESET = 10;
+ const RELEASE = 11;
+ const HOLDON = 12;
+ const ERROR = 13;
+ const WAITFORALLOUTS = 14;
+ const JUDGE_EOS = 15;
+ const WAITTIME = 3000;
+ let width = 720;
+ let height = 480;
+ let framerate = 60;
+ let mediaDescription = {
+ "width": width,
+ "height": height,
+ "pixel_format": 3,
+ "frame_rate" : framerate,
+ }
+ let mime = 'video/mp4v-es';
+
+
+ beforeAll(function() {
+ console.info('beforeAll case');
+ })
+
+ beforeEach(function() {
+ console.info('beforeEach case');
+ videoEncodeProcessor = null;
+ surfaceID = '';
+ outputQueue = [];
+ outputCnt = 0;
+ flushAtEOS = false;
+ sawOutputEOS = false;
+ needGetMediaDes = false;
+ workdoneAtEOS = false;
+ width = 720;
+ height = 480;
+ framerate = 60;
+ frameTotal = 100;
+ })
+
+ afterEach(async function() {
+ console.info('afterEach case');
+ if (videoEncodeProcessor != null) {
+ await videoEncodeProcessor.release().then(() => {
+ console.info(`case release 1`);
+ videoEncodeProcessor = null;
+ }, failCallback).catch(failCatch);
+ }
+ })
+
+ afterAll(function() {
+ console.info('afterAll case');
+ })
+
+ let failCallback = function(err) {
+ console.info('case callback err : ' + err);
+ expect(err).assertUndefined();
+ }
+
+ let failCallbackTrue = function(err, mySteps, done) {
+ console.info('case callback err : ' + err);
+ expect(err != undefined).assertTrue();
+ nextStep(mySteps, done);
+ }
+
+ let failCatch = function(err) {
+ console.info('case catch err : ' + err);
+ expect(err).assertUndefined();
+ }
+
+ function resetParam() {
+ outputQueue = [];
+ outputCnt = 0;
+ frameTotal = 100;
+ flushAtEOS = false;
+ sawOutputEOS = false;
+ needGetMediaDes = false;
+ workdoneAtEOS = false;
+ }
+
+ function writeFile(path, buf, len){
+ try{
+ let writestream = Fileio.createStreamSync(path, "ab+");
+ let num = writestream.writeSync(buf, {length:len});
+ writestream.flushSync();
+ writestream.closeSync();
+ } catch(e) {
+ console.info(e)
+ }
+ }
+
+ function sleep(time) {
+ return new Promise((resolve) => setTimeout(resolve, time));
+ }
+
+ function wait(time) {
+ for(let t = Date.now(); Date.now() - t <= time;);
+ }
+
+ async function nextStep(mySteps, done) {
+ console.info("case myStep[0]: " + mySteps[0]);
+ if (mySteps[0] == END) {
+ done();
+ }
+ switch (mySteps[0]) {
+ case CONFIGURE:
+ mySteps.shift();
+ console.info(`case to configure`);
+ await toConfigure(mySteps, done);
+ break;
+ case GETSURFACE:
+ mySteps.shift();
+ console.info(`case to getInputSurface`);
+ await toGetInputSurface();
+ nextStep(mySteps, done);
+ break;
+ case SETSTREAMPARAM:
+ mySteps.shift();
+ toSetStreamParam();
+ nextStep(mySteps, done);
+ break;
+ case PREPARE:
+ mySteps.shift();
+ console.info(`case to prepare`);
+ await toPrepare(mySteps, done);
+ break;
+ case STARTSTREAM:
+ mySteps.shift();
+ console.info(`case to start stream`);
+ toStartStream();
+ nextStep(mySteps, done);
+ break;
+ case STOPSTREAM:
+ mySteps.shift();
+ console.info(`case to stop stream`);
+ mediaTest.closeStream(surfaceID);
+ nextStep(mySteps, done);
+ break;
+ case START:
+ mySteps.shift();
+ console.info(`case to start`);
+ await toStart(mySteps, done);
+ break;
+ case FLUSH:
+ mySteps.shift();
+ console.info(`case to flush`);
+ await toFlush(mySteps, done);
+ break;
+ case STOP:
+ mySteps.shift();
+ console.info(`case to stop`);
+ await toStop(mySteps, done);
+ break;
+ case RESET:
+ mySteps.shift();
+ console.info(`case to reset`);
+ await toReset();
+ nextStep(mySteps, done);
+ break;
+ case RELEASE:
+ mySteps.shift();
+ console.info(`case to release`);
+ await toRelease(mySteps, done);
+ break;
+ case HOLDON:
+ mySteps.shift();
+ setTimeout(() => {
+ nextStep(mySteps, done);
+ }, WAITTIME);
+ break;
+ case WAITFORALLOUTS:
+ mySteps.shift();
+ console.info(`case wait for all outputs`);
+ break;
+ case JUDGE_EOS:
+ mySteps.shift();
+ console.info(`case judge EOS state`);
+ expect(sawOutputEOS).assertTrue();
+ nextStep(mySteps, done);
+ break;
+ default:
+ break;
+ }
+ }
+ async function dequeueOutputs(path, done) {
+ while (outputQueue.length > 0) {
+ let outputObject = outputQueue.shift();
+ outputCnt += 1;
+ if (outputObject.flags == 1) {
+ console.info("saw output EOS");
+ sawOutputEOS = true;
+ if (workdoneAtEOS) {
+ mediaTest.closeStream(surfaceID);
+ await toReset();
+ await videoEncodeProcessor.release().then(() => {
+ console.info("case release success");
+ }, failCallback).catch(failCatch);
+ videoEncodeProcessor = null;
+ done();
+ } else {
+ console.info("sawOutputEOS = true;");
+ }
+ } else {
+ writeFile(path, outputObject.data, outputObject.length);
+ console.info("write to file success");
+ videoEncodeProcessor.releaseOutput(outputObject).then(() => {
+ console.info('release output success');
+ frameCountOut++;
+ console.log('release output count:' + frameCountOut);
+ })
+ }
+ }
+ }
+
+ function setCallback(path, done) {
+ console.info('case callback');
+ videoEncodeProcessor.on('outputBufferAvailable', async(outBuffer) => {
+ console.info('outputBufferAvailable');
+ console.info('outBuffer.flags :' + outBuffer.flags);
+ if (needGetMediaDes) {
+ videoEncodeProcessor.getOutputMediaDescription().then((MediaDescription) => {
+ console.info("get OutputMediaDescription success");
+ console.info('get outputMediaDescription : ' + MediaDescription);
+ needGetMediaDes = false;
+ }, failCallback).catch(failCatch);
+ }
+ outputQueue.push(outBuffer);
+ await dequeueOutputs(path, done);
+ });
+
+ videoEncodeProcessor.on('error',(err) => {
+ console.info('case error called,errName is' + err);
+ });
+ videoEncodeProcessor.on('outputFormatChanged',(format) => {
+ console.info('Output format changed: ' + format);
+ });
+ }
+
+ async function createVideoEncoder(savepath, mySteps, done) {
+ await media.createVideoEncoderByMime(mime).then((processor) => {
+ console.info(`case createVideoEncoder 1`);
+ videoEncodeProcessor = processor;
+ setCallback(savepath, done);
+ console.info("case start api test");
+ nextStep(mySteps, done);
+ }, failCallback).catch(failCatch);
+ }
+
+ async function toCreateByMime(mime, done) {
+ await media.createVideoEncoderByMime(mime).then((processor) => {
+ if (typeof (processor) != 'undefined') {
+ videoEncodeProcessor = processor;
+ console.info('in case : createVideoEncoderByMime success');
+ } else {
+ console.info('in case : createVideoEncoderByMime fail');
+ expect().assertFail();
+ done();
+ }
+ })
+ }
+
+ function toSetStreamParam() {
+ mediaTest.setResolution(width, height);
+ mediaTest.setFrameRate(framerate);
+ mediaTest.setFrameCount(frameTotal);
+ }
+
+ async function toGetInputSurface() {
+ await videoEncodeProcessor.getInputSurface().then((inputSurface) => {
+ expect(inputSurface != undefined).assertTrue();
+ surfaceID = inputSurface;
+ }, failCallback).catch(failCatch);
+ }
+
+ function toStartStream() {
+ mediaTest.isStart = 1;
+ mediaTest.startStream(surfaceID);
+ }
+
+ async function toConfigure(mySteps, done) {
+ if (mySteps[0] == ERROR) {
+ mySteps.shift();
+ console.info(`case to configure 2`);
+ await videoEncodeProcessor.configure(mediaDescription).then(() => {
+ console.info(`case configure error 1`);
+ expect().assertFail();
+ }, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
+ } else {
+ await videoEncodeProcessor.configure(mediaDescription).then(() => {
+ console.info("case configure success");
+ }, failCallback).catch(failCatch);
+ }
+ nextStep(mySteps, done);
+ }
+
+ async function toPrepare(mySteps, done) {
+ if (mySteps[0] == ERROR) {
+ mySteps.shift();
+ console.info(`case to prepare 2`);
+ await videoEncodeProcessor.prepare().then(() => {
+ console.info(`case prepare error 1`);
+ expect().assertFail();
+ }, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
+ } else {
+ await videoEncodeProcessor.prepare().then(() => {
+ console.info("case prepare success");
+ }, failCallback).catch(failCatch);
+ }
+ nextStep(mySteps, done);
+ }
+
+ async function toStart(mySteps, done) {
+ if (mySteps[0] == ERROR) {
+ mySteps.shift();
+ console.info(`case to start 2`);
+ await videoEncodeProcessor.start().then(() => {
+ console.info(`case start error 1`);
+ expect().assertFail();
+ }, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
+ } else {
+ if (sawOutputEOS) {
+ resetParam();
+ workdoneAtEOS = true;
+ }
+ await videoEncodeProcessor.start().then(() => {
+ console.info("case start success");
+ }, failCallback).catch(failCatch);
+ }
+ nextStep(mySteps, done);
+ }
+
+ async function toFlush(mySteps, done) {
+ if (mySteps[0] == ERROR) {
+ mySteps.shift();
+ console.info(`case to flush 2`);
+ await videoEncodeProcessor.flush().then(() => {
+ console.info(`case flush error 1`);
+ expect().assertFail();
+ }, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
+ } else {
+ await videoEncodeProcessor.flush().then(() => {
+ console.info("case flush success");
+ }, failCallback).catch(failCatch);
+ if (flushAtEOS) {
+ mediaTest.closeStream(surfaceID);
+ resetParam();
+ workdoneAtEOS = true;
+ }
+ }
+ nextStep(mySteps, done);
+ }
+
+ async function toStop(mySteps, done) {
+ if (mySteps[0] == ERROR) {
+ mySteps.shift();
+ console.info(`case to stop 2`);
+ await videoEncodeProcessor.stop().then(() => {
+ console.info(`case stop error 1`);
+ expect().assertFail();
+ }, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
+ } else {
+ await videoEncodeProcessor.stop().then(() => {
+ console.info("case stop success");
+ }, failCallback).catch(failCatch);
+ }
+ nextStep(mySteps, done);
+ }
+
+ async function toReset() {
+ await videoEncodeProcessor.reset().then(() => {
+ console.info("case reset success");
+ }, failCallback).catch(failCatch);
+ }
+
+ async function toRelease(mySteps, done) {
+ if (mySteps[0] == ERROR) {
+ mySteps.shift();
+ console.info(`case to relase 2`);
+ await videoEncodeProcessor.release().then(() => {
+ console.info(`case release error 1`);
+ expect().assertFail();
+ }, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
+ videoEncodeProcessor = null;
+ } else {
+ await videoEncodeProcessor.release().then(() => {
+ console.info("case release success");
+ }, failCallback).catch(failCatch);
+ if (mySteps[0] != RELEASE) {
+ videoEncodeProcessor = null;
+ }
+ }
+ nextStep(mySteps, done);
+ }
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_PROMISE_0100
+ * @tc.name : 001.create -> configure
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_PROMISE_0100', 0, async function (done) {
+ let savepath = BASIC_PATH + 'configure_0100.es';
+ let mySteps = new Array(CONFIGURE, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_PROMISE_0200
+ * @tc.name : 002.prepare -> configure
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_PROMISE_0200', 0, async function (done) {
+ let savepath = BASIC_PATH + 'configure_0200.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, CONFIGURE, ERROR, STOPSTREAM, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_PROMISE_0300
+ * @tc.name : 003.start -> configure
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_PROMISE_0300', 0, async function (done) {
+ let savepath = BASIC_PATH + 'configure_0300.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STARTSTREAM, START,
+ CONFIGURE, ERROR, STOPSTREAM, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_PROMISE_0400
+ * @tc.name : 004.flush -> configure
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_PROMISE_0400', 0, async function (done) {
+ let savepath = BASIC_PATH + 'configure_0400.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STARTSTREAM, START, FLUSH,
+ CONFIGURE, ERROR, STOPSTREAM, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_PROMISE_0500
+ * @tc.name : 005.stop -> configure
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_PROMISE_0500', 0, async function (done) {
+ let savepath = BASIC_PATH + 'configure_0500.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STARTSTREAM, START, STOP ,
+ CONFIGURE, ERROR, STOPSTREAM, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_PROMISE_0600
+ * @tc.name : 006.EOS -> configure
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_PROMISE_0600', 0, async function (done) {
+ let savepath = BASIC_PATH + 'configure_0600.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, START, STARTSTREAM, HOLDON,
+ JUDGE_EOS, CONFIGURE, ERROR, STOPSTREAM, END);
+ frameTotal = 2;
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_PROMISE_0700
+ * @tc.name : 007.reset -> configure
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_PROMISE_0700', 0, async function (done) {
+ let savepath = BASIC_PATH + 'configure_0700.es';
+ let mySteps = new Array(RESET, CONFIGURE, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_PROMISE_0800
+ * @tc.name : 008.configure -> configure
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_PROMISE_0800', 0, async function (done) {
+ let savepath = BASIC_PATH + 'configure_0800.es';
+ let mySteps = new Array(CONFIGURE, CONFIGURE, ERROR, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_PROMISE_0900
+ * @tc.name : 009.configure -> reset -> configure
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_PROMISE_0900', 0, async function (done) {
+ let savepath = BASIC_PATH + 'configure_0900.es';
+ let mySteps = new Array(CONFIGURE, RESET, CONFIGURE, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_PROMISE_0100
+ * @tc.name : 001.create -> prepare
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_PROMISE_0100', 0, async function (done) {
+ let savepath = BASIC_PATH + 'prepare_0100.es';
+ let mySteps = new Array(PREPARE, ERROR, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_PROMISE_0200
+ * @tc.name : 002.configure -> prepare
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_PROMISE_0200', 0, async function (done) {
+ let savepath = BASIC_PATH + 'prepare_0200.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STOPSTREAM, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_PROMISE_0300
+ * @tc.name : 003.prepare -> prepare
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_PROMISE_0300', 0, async function (done) {
+ let savepath = BASIC_PATH + 'prepare_0300.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, PREPARE, ERROR, STOPSTREAM, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_PROMISE_0400
+ * @tc.name : 004.start -> prepare
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_PROMISE_0400', 0, async function (done) {
+ let savepath = BASIC_PATH + 'prepare_0400.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STARTSTREAM, START, PREPARE, ERROR,
+ STOPSTREAM, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_PROMISE_0500
+ * @tc.name : 005.flush -> prepare
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_PROMISE_0500', 0, async function (done) {
+ let savepath = BASIC_PATH + 'prepare_0500.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STARTSTREAM, START, FLUSH,
+ PREPARE, ERROR, STOPSTREAM, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_PROMISE_0600
+ * @tc.name : 006.stop -> prepare
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_PROMISE_0600', 0, async function (done) {
+ let savepath = BASIC_PATH + 'prepare_0600.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STARTSTREAM, START, STOP,
+ PREPARE, ERROR, STOPSTREAM, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_PROMISE_0700
+ * @tc.name : 007.EOS -> prepare
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_PROMISE_0700', 0, async function (done) {
+ let savepath = BASIC_PATH + 'prepare_0700.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, START, STARTSTREAM, HOLDON,
+ JUDGE_EOS, PREPARE, ERROR, STOPSTREAM, END);
+ frameTotal = 2;
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_PROMISE_0800
+ * @tc.name : 008.reset -> prepare
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_PROMISE_0800', 0, async function (done) {
+ let savepath = BASIC_PATH + 'prepare_0800.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STARTSTREAM, START, RESET,
+ PREPARE, ERROR, STOPSTREAM, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_PROMISE_0100
+ * @tc.name : 001.create -> start
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_PROMISE_0100', 0, async function (done) {
+ let savepath = BASIC_PATH + 'start_0100.es';
+ let mySteps = new Array(START, ERROR, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_PROMISE_0200
+ * @tc.name : 002.configure -> start
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_PROMISE_0200', 0, async function (done) {
+ let savepath = BASIC_PATH + 'start_0200.es';
+ let mySteps = new Array(CONFIGURE, START, ERROR, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_PROMISE_0300
+ * @tc.name : 003.prepare -> start
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_PROMISE_0300', 0, async function (done) {
+ let savepath = BASIC_PATH + 'start_0300.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STARTSTREAM, START, WAITFORALLOUTS);
+ workdoneAtEOS = true;
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_PROMISE_0400
+ * @tc.name : 004.start -> start
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_PROMISE_0400', 0, async function (done) {
+ let savepath = BASIC_PATH + 'start_0400.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STARTSTREAM, START, START, ERROR,
+ STOPSTREAM, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_PROMISE_0500
+ * @tc.name : 005.flush -> start
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_PROMISE_0500', 0, async function (done) {
+ let savepath = BASIC_PATH + 'start_0500.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STARTSTREAM, START, FLUSH,
+ START, ERROR, STOPSTREAM, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_PROMISE_0600
+ * @tc.name : 006.stop -> start
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_PROMISE_0600', 0, async function (done) {
+ let savepath = BASIC_PATH + 'start_0600.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STARTSTREAM, START, STOP,
+ START, WAITFORALLOUTS);
+ workdoneAtEOS = true;
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_PROMISE_0700
+ * @tc.name : 007.EOS -> start
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_PROMISE_0700', 0, async function (done) {
+ let savepath = BASIC_PATH + 'start_0700.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, START, STARTSTREAM, HOLDON,
+ JUDGE_EOS, START, ERROR, STOPSTREAM, END);
+ frameTotal = 2;
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_PROMISE_0800
+ * @tc.name : 008.reset -> start
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START_PROMISE_0800', 0, async function (done) {
+ let savepath = BASIC_PATH + 'start_0800.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STARTSTREAM, START, RESET,
+ START, ERROR, STOPSTREAM, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_PROMISE_0100
+ * @tc.name : 001.create -> flush
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_PROMISE_0100', 0, async function (done) {
+ let savepath = BASIC_PATH + 'flush_0100.es';
+ let mySteps = new Array(FLUSH, ERROR, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_PROMISE_0200
+ * @tc.name : 002.configure -> flush
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_PROMISE_0200', 0, async function (done) {
+ let savepath = BASIC_PATH + 'flush_0200.es';
+ let mySteps = new Array(CONFIGURE, FLUSH, ERROR, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_PROMISE_0300
+ * @tc.name : 003.prepare -> flush
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_PROMISE_0300', 0, async function (done) {
+ let savepath = BASIC_PATH + 'flush_0300.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, FLUSH, ERROR, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_PROMISE_0400
+ * @tc.name : 004.start -> flush
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_PROMISE_0400', 0, async function (done) {
+ let savepath = BASIC_PATH + 'flush_0400.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, START, STARTSTREAM, FLUSH,
+ STOPSTREAM, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_PROMISE_0500
+ * @tc.name : 005.flush -> flush
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_PROMISE_0500', 0, async function (done) {
+ let savepath = BASIC_PATH + 'flush_0500.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STARTSTREAM, START, FLUSH, FLUSH,
+ WAITFORALLOUTS);
+ workdoneAtEOS = true;
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_PROMISE_0600
+ * @tc.name : 006.stop -> flush
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_PROMISE_0600', 0, async function (done) {
+ let savepath = BASIC_PATH + 'flush_0600.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STARTSTREAM, START, STOP,
+ FLUSH, ERROR, STOPSTREAM, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_PROMISE_0700
+ * @tc.name : 007.EOS -> flush
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_PROMISE_0700', 0, async function (done) {
+ let savepath = BASIC_PATH + 'flush_0700.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, START, STARTSTREAM, HOLDON,
+ JUDGE_EOS, FLUSH, STOPSTREAM, END);
+ frameTotal = 2;
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_PROMISE_0800
+ * @tc.name : 008.reset -> flush
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_FLUSH_PROMISE_0800', 0, async function (done) {
+ let savepath = BASIC_PATH + 'flush_0800.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STARTSTREAM, START, RESET,
+ FLUSH, ERROR, STOPSTREAM, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_PROMISE_0100
+ * @tc.name : 001.create -> stop
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_PROMISE_0100', 0, async function (done) {
+ let savepath = BASIC_PATH + 'stop_0100.es';
+ let mySteps = new Array(STOP, ERROR, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_PROMISE_0200
+ * @tc.name : 002.configure -> stop
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_PROMISE_0200', 0, async function (done) {
+ let savepath = BASIC_PATH + 'stop_0200.es';
+ let mySteps = new Array(CONFIGURE, STOP, ERROR, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_PROMISE_0300
+ * @tc.name : 003.prepare -> stop
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_PROMISE_0300', 0, async function (done) {
+ let savepath = BASIC_PATH + 'stop_0300.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STOP, ERROR, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_PROMISE_0400
+ * @tc.name : 004.start -> stop
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_PROMISE_0400', 0, async function (done) {
+ let savepath = BASIC_PATH + 'stop_0400.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STARTSTREAM, START, STOP,
+ STOPSTREAM, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_PROMISE_0500
+ * @tc.name : 005.flush -> stop
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_PROMISE_0500', 0, async function (done) {
+ let savepath = BASIC_PATH + 'stop_0500.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STARTSTREAM, START, FLUSH, STOP,
+ STOPSTREAM, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_PROMISE_0600
+ * @tc.name : 006.stop -> stop
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_PROMISE_0600', 0, async function (done) {
+ let savepath = BASIC_PATH + 'stop_0600.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STARTSTREAM, START, STOP, STOP, ERROR,
+ STOPSTREAM, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_PROMISE_0700
+ * @tc.name : 007.EOS -> stop
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_PROMISE_0700', 0, async function (done) {
+ let savepath = BASIC_PATH + 'stop_0700.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, START, STARTSTREAM, HOLDON, JUDGE_EOS,
+ STOP, STOPSTREAM, END);
+ frameTotal = 2;
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_PROMISE_0800
+ * @tc.name : 008.reset -> stop
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_STOP_PROMISE_0800', 0, async function (done) {
+ let savepath = BASIC_PATH + 'stop_0800.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STARTSTREAM, START, RESET,
+ STOP, ERROR, STOPSTREAM, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_PROMISE_0100
+ * @tc.name : 001.create -> reset
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_PROMISE_0100', 0, async function (done) {
+ let savepath = BASIC_PATH + 'reset_0100.es';
+ let mySteps = new Array(RESET, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_PROMISE_0200
+ * @tc.name : 002.configure -> reset
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_PROMISE_0200', 0, async function (done) {
+ let savepath = BASIC_PATH + 'reset_0200.es';
+ let mySteps = new Array(CONFIGURE, RESET, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_PROMISE_0300
+ * @tc.name : 003.prepare -> reset
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_PROMISE_0300', 0, async function (done) {
+ let savepath = BASIC_PATH + 'reset_0300.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, RESET, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_PROMISE_0400
+ * @tc.name : 004.start -> reset
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_PROMISE_0400', 0, async function (done) {
+ let savepath = BASIC_PATH + 'reset_0400.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STARTSTREAM, START, RESET,
+ STOPSTREAM, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_PROMISE_0500
+ * @tc.name : 005.flush -> reset
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_PROMISE_0500', 0, async function (done) {
+ let savepath = BASIC_PATH + 'reset_0500.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STARTSTREAM, START, FLUSH,
+ RESET, STOPSTREAM, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_PROMISE_0600
+ * @tc.name : 006.stop -> reset
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_PROMISE_0600', 0, async function (done) {
+ let savepath = BASIC_PATH + 'reset_0600.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STARTSTREAM, START, STOP,
+ RESET, STOPSTREAM, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_PROMISE_0700
+ * @tc.name : 007.EOS -> reset
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_PROMISE_0700', 0, async function (done) {
+ let savepath = BASIC_PATH + 'reset_0700.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, START, STARTSTREAM, HOLDON,
+ JUDGE_EOS, RESET, STOPSTREAM, END);
+ frameTotal = 2;
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_PROMISE_0800
+ * @tc.name : 008.reset -> reset
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RESET_PROMISE_0800', 0, async function (done) {
+ let savepath = BASIC_PATH + 'reset_0800.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STARTSTREAM, START, RESET,
+ RESET, STOPSTREAM, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RELEASE_PROMISE_0100
+ * @tc.name : 001.create -> release
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RELEASE_PROMISE_0100', 0, async function (done) {
+ let savepath = BASIC_PATH + 'release_0100.es';
+ let mySteps = new Array(RELEASE, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RELEASE_PROMISE_0200
+ * @tc.name : 002.configure -> release
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RELEASE_PROMISE_0200', 0, async function (done) {
+ let savepath = BASIC_PATH + 'release_0200.es';
+ let mySteps = new Array(CONFIGURE, RELEASE, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RELEASE_PROMISE_0300
+ * @tc.name : 003.prepare -> release
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RELEASE_PROMISE_0300', 0, async function (done) {
+ let savepath = BASIC_PATH + 'release_0300.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, RELEASE, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RELEASE_PROMISE_0400
+ * @tc.name : 004.start -> release
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RELEASE_PROMISE_0400', 0, async function (done) {
+ let savepath = BASIC_PATH + 'release_0400.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STARTSTREAM, START,
+ RELEASE, STOPSTREAM, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RELEASE_PROMISE_0500
+ * @tc.name : 005.flush -> release
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RELEASE_PROMISE_0500', 0, async function (done) {
+ let savepath = BASIC_PATH + 'release_0500.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STARTSTREAM, START, FLUSH,
+ RELEASE, STOPSTREAM, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RELEASE_PROMISE_0600
+ * @tc.name : 006.stop -> release
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RELEASE_PROMISE_0600', 0, async function (done) {
+ let savepath = BASIC_PATH + 'release_0600.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STARTSTREAM, START, STOP,
+ RELEASE, STOPSTREAM, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RELEASE_PROMISE_0700
+ * @tc.name : 007.EOS -> release
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RELEASE_PROMISE_0700', 0, async function (done) {
+ let savepath = BASIC_PATH + 'release_0700.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, START, STARTSTREAM, HOLDON,
+ JUDGE_EOS, RELEASE, STOPSTREAM, END);
+ frameTotal = 2;
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RELEASE_PROMISE_0800
+ * @tc.name : 008.release -> release
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_RELEASE_PROMISE_0800', 0, async function (done) {
+ let savepath = BASIC_PATH + 'release_0800.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STARTSTREAM, START, RELEASE,
+ RELEASE, ERROR, STOPSTREAM, END);
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_EOS_PROMISE_0100
+ * @tc.name : 001.EOS -> flush -> stop
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_EOS_PROMISE_0100', 0, async function (done) {
+ let savepath = BASIC_PATH + 'eos_0100.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, START, STARTSTREAM, HOLDON,
+ JUDGE_EOS, FLUSH, STOP, STOPSTREAM, END);
+ frameTotal = 2;
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_EOS_PROMISE_0200
+ * @tc.name : 002.EOS -> flush -> EOS
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_EOS_PROMISE_0200', 0, async function (done) {
+ let savepath = BASIC_PATH + 'eos_0200.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, START, STARTSTREAM, HOLDON,
+ JUDGE_EOS, FLUSH, STARTSTREAM, WAITFORALLOUTS);
+ frameTotal = 2;
+ flushAtEOS = true;
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_EOS_PROMISE_0300
+ * @tc.name : 003.EOS -> reset -> configure
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_EOS_PROMISE_0300', 0, async function (done) {
+ let savepath = BASIC_PATH + 'eos_0300.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, START, STARTSTREAM, HOLDON,
+ JUDGE_EOS, RESET, CONFIGURE, STOPSTREAM, END);
+ frameTotal = 2;
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_EOS_PROMISE_0400
+ * @tc.name : 004.EOS -> stop -> start -> EOS
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_EOS_PROMISE_0400', 0, async function (done) {
+ let savepath = BASIC_PATH + 'eos_0400.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, START, STARTSTREAM, HOLDON,
+ JUDGE_EOS, STOPSTREAM, STOP, START, SETSTREAMPARAM, STARTSTREAM, WAITFORALLOUTS);
+ frameTotal = 2;
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_EOS_PROMISE_0500
+ * @tc.name : 005.EOS -> stop -> start -> stop
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_EOS_PROMISE_0500', 0, async function (done) {
+ let savepath = BASIC_PATH + 'eos_0500.es';
+ let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, START, STARTSTREAM, HOLDON,
+ JUDGE_EOS, STOP, START, STOP, STOPSTREAM, END);
+ frameTotal = 2;
+ createVideoEncoder(savepath, mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE-RESET_PROMISE_0100
+ * @tc.name : 001. configure -> reset for 50 times
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE-RESET_PROMISE_0100', 0, async function (done) {
+ let name = 'avenc_mpeg4';
+ await media.createVideoEncoderByName(name).then((processor) => {
+ if (typeof (processor) != 'undefined') {
+ videoEncodeProcessor = processor;
+ console.info('in case : createVideoEncoderByName success');
+ } else {
+ console.info('in case : createVideoEncoderByName fail');
+ expect().assertFail();
+ done();
+ }
+ })
+ for (let j = 1; j < 51; j++) {
+ console.info('case configure-reset current loop: ' + j);
+ await videoEncodeProcessor.configure(mediaDescription).then(() => {
+ console.info("case configure success");
+ }, failCallback).catch(failCatch);
+ await videoEncodeProcessor.reset().then(() => {
+ console.info("case reset success");
+ }, failCallback).catch(failCatch);
+ }
+ await videoEncodeProcessor.release().then(() => {
+ console.info("case release success");
+ }, failCallback).catch(failCatch);
+ videoEncodeProcessor = null;
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START-STOP_PROMISE_0100
+ * @tc.name : 001. start -> stop for 50 times
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_START-STOP_PROMISE_0100', 0, async function (done) {
+ let name = 'avenc_mpeg4';
+ await media.createVideoEncoderByName(name).then((processor) => {
+ if (typeof (processor) != 'undefined') {
+ videoEncodeProcessor = processor;
+ console.info('in case : createVideoEncoderByName success');
+ } else {
+ console.info('in case : createVideoEncoderByName fail');
+ expect().assertFail();
+ done();
+ }
+ })
+ await videoEncodeProcessor.configure(mediaDescription).then(() => {
+ console.info("case configure success");
+ }, failCallback).catch(failCatch);
+ await toGetInputSurface();
+ await videoEncodeProcessor.prepare().then(() => {
+ console.info("case prepare success");
+ }, failCallback).catch(failCatch);
+ for (let j = 1; j < 51; j++) {
+ console.info('case start-stop current loop: ' + j);
+ await videoEncodeProcessor.start().then(() => {
+ console.info("case start success");
+ }, failCallback).catch(failCatch);
+ await videoEncodeProcessor.stop().then(() => {
+ console.info("case stop success");
+ }, failCallback).catch(failCatch);
+ }
+ await videoEncodeProcessor.release().then(() => {
+ console.info("case release success");
+ }, failCallback).catch(failCatch);
+ videoEncodeProcessor = null;
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CREATE-RELEASE_PROMISE_0100
+ * @tc.name : 001. create -> release for 50 times
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CREATE-RELEASE_PROMISE_0100', 0, async function (done) {
+ let name = 'avenc_mpeg4';
+ for (let j = 1; j < 51; j++) {
+ console.info('case create-release current loop: ' + j);
+ await media.createVideoEncoderByName(name).then((processor) => {
+ if (typeof (processor) != 'undefined') {
+ videoEncodeProcessor = processor;
+ console.info('in case : createVideoEncoderByName success');
+ } else {
+ console.info('in case : createVideoEncoderByName fail');
+ expect().assertFail();
+ done();
+ }
+ })
+ await videoEncodeProcessor.release().then(() => {
+ console.info("case release success");
+ }, failCallback).catch(failCatch);
+ videoEncodeProcessor = null;
+ }
+ done();
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_TOTALLOOP_PROMISE_0100
+ * @tc.name : 001. total loop for 50 times
+ * @tc.desc : Reliability Test
+ * @tc.size : MediumTest
+ * @tc.type : Reliability
+ * @tc.level : Level2
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_TOTALLOOP_PROMISE_0100', 0, async function (done) {
+ let name = 'avenc_mpeg4';
+ for (let j = 1; j < 51; j++) {
+ console.info('case create-release current loop: ' + j);
+ await media.createVideoEncoderByName(name).then((processor) => {
+ if (typeof (processor) != 'undefined') {
+ videoEncodeProcessor = processor;
+ console.info('in case : createVideoEncoderByName success');
+ } else {
+ console.info('in case : createVideoEncoderByName fail');
+ expect().assertFail();
+ done();
+ }
+ })
+ await videoEncodeProcessor.configure(mediaDescription).then(() => {
+ console.info("case configure success");
+ }, failCallback).catch(failCatch);
+ await toGetInputSurface();
+ await videoEncodeProcessor.prepare().then(() => {
+ console.info("case prepare success");
+ }, failCallback).catch(failCatch);
+ await videoEncodeProcessor.start().then(() => {
+ console.info("case start success");
+ }, failCallback).catch(failCatch);
+ await videoEncodeProcessor.flush().then(() => {
+ console.info("case flush success");
+ }, failCallback).catch(failCatch);
+ await videoEncodeProcessor.stop().then(() => {
+ console.info("case stop success");
+ }, failCallback).catch(failCatch);
+ await videoEncodeProcessor.reset().then(() => {
+ console.info("case reset success");
+ }, failCallback).catch(failCatch);
+ await videoEncodeProcessor.release().then(() => {
+ console.info("case release success");
+ }, failCallback).catch(failCatch);
+ videoEncodeProcessor = null;
+ }
+ done();
+ })
+})
diff --git a/multimedia/media/media_js_standard/videoEncoder/src/main/resources/base/element/string.json b/multimedia/media/media_js_standard/videoEncoder/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..0bae6bd40f7360d5d818998221b199d3ec0f69c0
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoEncoder/src/main/resources/base/element/string.json
@@ -0,0 +1,12 @@
+{
+ "string": [
+ {
+ "name": "entry_MainAbility",
+ "value": "entry_MainAbility"
+ },
+ {
+ "name": "mainability_description",
+ "value": "JS_Empty Ability"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/multimedia/media/media_js_standard/videoEncoder/src/main/resources/base/media/icon.png b/multimedia/media/media_js_standard/videoEncoder/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/multimedia/media/media_js_standard/videoEncoder/src/main/resources/base/media/icon.png differ